Revision: 201003 default
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 02 Feb 2010 01:11:40 +0200
changeset 0 d0791faffa3f
child 1 f8e15b44d440
Revision: 201003 Kit: 201005
backupandrestore/backupengine/group/Doxyfile
backupandrestore/backupengine/group/MakeDoc.cmd
backupandrestore/backupengine/group/bld.inf
backupandrestore/backupengine/group/configureIndex.pl
backupandrestore/backupengine/group/connectivity_backupengine.mrp
backupandrestore/backupengine/group/connectivity_securebackupengine.history.xml
backupandrestore/backupengine/group/connectivity_securebackupengine.iby
backupandrestore/backupengine/group/sbeclient.mmp
backupandrestore/backupengine/group/sbencrypt.mmp
backupandrestore/backupengine/group/sbengine.mmh
backupandrestore/backupengine/group/sbengine.mmp
backupandrestore/backupengine/group/sbenginenojava.mmp
backupandrestore/backupengine/group/sysdoc.css
backupandrestore/backupengine/inc/abserver.h
backupandrestore/backupengine/inc/absession.h
backupandrestore/backupengine/inc/absessionmap.h
backupandrestore/backupengine/inc/installmimetypes.h
backupandrestore/backupengine/inc/javamanagerinterface.h
backupandrestore/backupengine/inc/javamanagerinterface.inl
backupandrestore/backupengine/inc/sbebufferhandler.h
backupandrestore/backupengine/inc/sbeclient.h
backupandrestore/backupengine/inc/sbeclientserver.h
backupandrestore/backupengine/inc/sbeclientsession.h
backupandrestore/backupengine/inc/sbecompressionandencryption.h
backupandrestore/backupengine/inc/sbeconfig.h
backupandrestore/backupengine/inc/sbedataowner.h
backupandrestore/backupengine/inc/sbedataownermanager.h
backupandrestore/backupengine/inc/sbencrypt.h
backupandrestore/backupengine/inc/sbencryptimpl.h
backupandrestore/backupengine/inc/sbeparserdefs.h
backupandrestore/backupengine/inc/sbeparserproxy.h
backupandrestore/backupengine/inc/sbeserver.h
backupandrestore/backupengine/inc/sbesession.h
backupandrestore/backupengine/inc/sbexternalisablearray.h
backupandrestore/backupengine/inc/sbexternalisablearray.inl
backupandrestore/backupengine/inc/sbheapwrapper.h
backupandrestore/backupengine/inc/sblog.h
backupandrestore/backupengine/inc/sbmain.h
backupandrestore/backupengine/inc/sbpackagedatatransfer.h
backupandrestore/backupengine/inc/sbshutdown.h
backupandrestore/backupengine/inc/sbtypes.h
backupandrestore/backupengine/src/abserver.cpp
backupandrestore/backupengine/src/absession.cpp
backupandrestore/backupengine/src/absessionmap.cpp
backupandrestore/backupengine/src/sbebufferhandler.cpp
backupandrestore/backupengine/src/sbeclient.cpp
backupandrestore/backupengine/src/sbeclientsession.cpp
backupandrestore/backupengine/src/sbecompressionandencryption.cpp
backupandrestore/backupengine/src/sbeconfig.cpp
backupandrestore/backupengine/src/sbedataowner.cpp
backupandrestore/backupengine/src/sbedataownermanager.cpp
backupandrestore/backupengine/src/sbencrypt.cpp
backupandrestore/backupengine/src/sbencryptimpl.cpp
backupandrestore/backupengine/src/sbeparserproxy.cpp
backupandrestore/backupengine/src/sbeserver.cpp
backupandrestore/backupengine/src/sbesession.cpp
backupandrestore/backupengine/src/sbheapwrapper.cpp
backupandrestore/backupengine/src/sblog.cpp
backupandrestore/backupengine/src/sbmain.cpp
backupandrestore/backupengine/src/sbpackagedatatransfer.cpp
backupandrestore/backupengine/src/sbshutdown.cpp
backupandrestore/backupengine/src/sbtypes.cpp
backupandrestore/backuptest/ABTester/group/abtestclient.mmp
backupandrestore/backuptest/ABTester/group/abtestclient2.mmp
backupandrestore/backuptest/ABTester/group/abtestclient3.mmp
backupandrestore/backuptest/ABTester/group/abtestclient4.mmp
backupandrestore/backuptest/ABTester/group/abtester.iby
backupandrestore/backuptest/ABTester/group/abtester.mmh
backupandrestore/backuptest/ABTester/group/abtester.oby
backupandrestore/backuptest/ABTester/group/bld.inf
backupandrestore/backuptest/ABTester/inc/abdataowner.h
backupandrestore/backuptest/ABTester/inc/abtester.h
backupandrestore/backuptest/ABTester/inc/abtesterlog.h
backupandrestore/backuptest/ABTester/src/abdataowner.cpp
backupandrestore/backuptest/ABTester/src/abtesterlog.cpp
backupandrestore/backuptest/burtestserver/Group/bld.inf
backupandrestore/backuptest/burtestserver/Group/burtestserver.iby
backupandrestore/backuptest/burtestserver/Group/burtestserver.mmp
backupandrestore/backuptest/burtestserver/Group/testtools_burtestserver.history.xml
backupandrestore/backuptest/burtestserver/TestServer/inc/t_asyncbackuptransferhandler.h
backupandrestore/backuptest/burtestserver/TestServer/inc/t_burcommon.h
backupandrestore/backuptest/burtestserver/TestServer/inc/t_burtestserver.h
backupandrestore/backuptest/burtestserver/TestServer/inc/t_storagemanager.h
backupandrestore/backuptest/burtestserver/TestServer/src/t_asyncbackuptransferhandler.cpp
backupandrestore/backuptest/burtestserver/TestServer/src/t_burtestserver.cpp
backupandrestore/backuptest/burtestserver/TestServer/src/t_storagemanager.cpp
backupandrestore/backuptest/burtestserver/TestSteps/inc/t_burteststepbase.h
backupandrestore/backuptest/burtestserver/TestSteps/inc/t_teststepbackup.h
backupandrestore/backuptest/burtestserver/TestSteps/inc/t_teststepbackup2.h
backupandrestore/backuptest/burtestserver/TestSteps/inc/t_teststepbackupasync.h
backupandrestore/backuptest/burtestserver/TestSteps/inc/t_teststeprestore.h
backupandrestore/backuptest/burtestserver/TestSteps/inc/t_teststeprestoreasync.h
backupandrestore/backuptest/burtestserver/TestSteps/src/t_burteststepbase.cpp
backupandrestore/backuptest/burtestserver/TestSteps/src/t_teststepbackup.cpp
backupandrestore/backuptest/burtestserver/TestSteps/src/t_teststepbackup2.cpp
backupandrestore/backuptest/burtestserver/TestSteps/src/t_teststepbackupasync.cpp
backupandrestore/backuptest/burtestserver/TestSteps/src/t_teststeprestore.cpp
backupandrestore/backuptest/burtestserver/TestSteps/src/t_teststeprestoreasync.cpp
backupandrestore/backuptest/group/bld.inf
backupandrestore/backuptest/group/connectivity_backuptest.mrp
connectivitymodules/SeCon/apple/S60_RnD_32.phoneplugin/Contents/Info.plist
connectivitymodules/SeCon/apple/S60_RnD_32.phoneplugin/Contents/Resources/MetaClasses.plist
connectivitymodules/SeCon/apple/S60_RnD_32.phoneplugin/Contents/Resources/PhoneConduit.plist
connectivitymodules/SeCon/apple/S60_RnD_32.phoneplugin/Contents/Resources/SyncEngine.plist
connectivitymodules/SeCon/apple/S60_RnD_32.phoneplugin/Contents/Resources/com.nokia.S6032.tiff
connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Archive.bom
connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Archive.pax.gz
connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Info.plist
connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/PkgInfo
connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Resources/Description.plist
connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Resources/English.lproj/ReadMe.rtf
connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Resources/IFRequirement.strings
connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Resources/PhonePlugin.info
connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Resources/TokenDefinitions.plist
connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Resources/Welcome.rtf
connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Resources/en.lproj/Description.plist
connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Resources/package_version
connectivitymodules/SeCon/apple/S60_RnD_32.ppdoc/Icon.tiff
connectivitymodules/SeCon/apple/S60_RnD_32.ppdoc/InstallerReadMe-en.rtf
connectivitymodules/SeCon/apple/S60_RnD_32.ppdoc/Properties.plist
connectivitymodules/SeCon/catalogspcconnectivityplugin/bwins/catalogspcconnectivitypluginu.def
connectivitymodules/SeCon/catalogspcconnectivityplugin/eabi/catalogspcconnectivitypluginu.def
connectivitymodules/SeCon/catalogspcconnectivityplugin/group/bld.inf
connectivitymodules/SeCon/catalogspcconnectivityplugin/group/catalogspcconnectivityplugin.mmp
connectivitymodules/SeCon/catalogspcconnectivityplugin/inc/catalogspcconnectivityclient.h
connectivitymodules/SeCon/catalogspcconnectivityplugin/inc/catalogspcconnectivitydefines.h
connectivitymodules/SeCon/catalogspcconnectivityplugin/inc/catalogspcconnectivityplugin.h
connectivitymodules/SeCon/catalogspcconnectivityplugin/src/catalogspcconnectivityclient.cpp
connectivitymodules/SeCon/catalogspcconnectivityplugin/src/catalogspcconnectivityplugin.cpp
connectivitymodules/SeCon/clients/pcconn/bld/bld.inf
connectivitymodules/SeCon/clients/pcconn/bld/def/bwinscwu.def
connectivitymodules/SeCon/clients/pcconn/bld/def/eabiuu.def
connectivitymodules/SeCon/clients/pcconn/bld/sconpcconnclient.mmp
connectivitymodules/SeCon/clients/pcconn/inc/sconpcconnclient.h
connectivitymodules/SeCon/clients/pcconn/src/sconpcconnclient.cpp
connectivitymodules/SeCon/cntparser/bld/bld.inf
connectivitymodules/SeCon/cntparser/bld/cntparsersrv.mmp
connectivitymodules/SeCon/cntparser/bld/cntparsersrvexe.mmp
connectivitymodules/SeCon/cntparser/bld/def/bwinscwu.def
connectivitymodules/SeCon/cntparser/bld/def/eabiuu.def
connectivitymodules/SeCon/cntparser/inc/clientserver.h
connectivitymodules/SeCon/cntparser/inc/cntparserclient.h
connectivitymodules/SeCon/cntparser/inc/cntparsercollector.h
connectivitymodules/SeCon/cntparser/inc/cntparserinfolog.h
connectivitymodules/SeCon/cntparser/inc/cntparserserver.h
connectivitymodules/SeCon/cntparser/inc/cntparserserversession.h
connectivitymodules/SeCon/cntparser/inc/irmcconsts.h
connectivitymodules/SeCon/cntparser/src/cntparserclient.cpp
connectivitymodules/SeCon/cntparser/src/cntparsercollector.cpp
connectivitymodules/SeCon/cntparser/src/cntparserinfolog.cpp
connectivitymodules/SeCon/cntparser/src/cntparserserverexe.cpp
connectivitymodules/SeCon/cntparser/src/cntparserserversession.cpp
connectivitymodules/SeCon/common/conmltask/inc/sconconmltask.h
connectivitymodules/SeCon/common/conmltask/src/sconconmltask.cpp
connectivitymodules/SeCon/group/bld.inf
connectivitymodules/SeCon/group/stubs/createstubs.bat
connectivitymodules/SeCon/group/stubs/sconftpplugin_stub.SIS
connectivitymodules/SeCon/group/stubs/sconftpplugin_stub.pkg
connectivitymodules/SeCon/group/stubs/sconpcconnplugin_stub.SIS
connectivitymodules/SeCon/group/stubs/sconpcconnplugin_stub.pkg
connectivitymodules/SeCon/group/stubs/secon_stub.SIS
connectivitymodules/SeCon/group/stubs/secon_stub.pkg
connectivitymodules/SeCon/inc/debug.h
connectivitymodules/SeCon/plugins/ftp/bld/bld.inf
connectivitymodules/SeCon/plugins/ftp/bld/def/bwinscwU.DEF
connectivitymodules/SeCon/plugins/ftp/bld/def/eabiU.DEF
connectivitymodules/SeCon/plugins/ftp/bld/sconftpplugin.mmp
connectivitymodules/SeCon/plugins/ftp/inc/sconftpplugin.h
connectivitymodules/SeCon/plugins/ftp/inc/sconftppluginutils.h
connectivitymodules/SeCon/plugins/ftp/inc/sconservicetimer.h
connectivitymodules/SeCon/plugins/ftp/inc/sconshutdownwatcher.h
connectivitymodules/SeCon/plugins/ftp/src/101f9686.rss
connectivitymodules/SeCon/plugins/ftp/src/proxy.cpp
connectivitymodules/SeCon/plugins/ftp/src/sconftpplugin.cpp
connectivitymodules/SeCon/plugins/ftp/src/sconftppluginutils.cpp
connectivitymodules/SeCon/plugins/ftp/src/sconservicetimer.cpp
connectivitymodules/SeCon/plugins/ftp/src/sconshutdownwatcher.cpp
connectivitymodules/SeCon/plugins/hapticsconnplugin/data/2001FE54.rss
connectivitymodules/SeCon/plugins/hapticsconnplugin/group/bld.inf
connectivitymodules/SeCon/plugins/hapticsconnplugin/group/hapticsconnplugin.mmp
connectivitymodules/SeCon/plugins/hapticsconnplugin/inc/hapticsbridgeclient.h
connectivitymodules/SeCon/plugins/hapticsconnplugin/inc/hapticsconnplugin.h
connectivitymodules/SeCon/plugins/hapticsconnplugin/inc/hapticsconntimer.h
connectivitymodules/SeCon/plugins/hapticsconnplugin/inc/hapticsconntrace.h
connectivitymodules/SeCon/plugins/hapticsconnplugin/inc/hapticsmsghandler.h
connectivitymodules/SeCon/plugins/hapticsconnplugin/rom/hapticsconnplugin.iby
connectivitymodules/SeCon/plugins/hapticsconnplugin/src/hapticsbridgeclient.cpp
connectivitymodules/SeCon/plugins/hapticsconnplugin/src/hapticsconnplugin.cpp
connectivitymodules/SeCon/plugins/hapticsconnplugin/src/hapticsconntimer.cpp
connectivitymodules/SeCon/plugins/hapticsconnplugin/src/hapticsmsghandler.cpp
connectivitymodules/SeCon/plugins/hapticsconnplugin/src/proxy.cpp
connectivitymodules/SeCon/plugins/pcconn/bld/bld.inf
connectivitymodules/SeCon/plugins/pcconn/bld/def/bwinscwu.def
connectivitymodules/SeCon/plugins/pcconn/bld/def/eabiu.def
connectivitymodules/SeCon/plugins/pcconn/bld/sconpcconnplugin.mmp
connectivitymodules/SeCon/plugins/pcconn/inc/sconpcconnplugin.h
connectivitymodules/SeCon/plugins/pcconn/inc/sconpcconnpluginutils.h
connectivitymodules/SeCon/plugins/pcconn/inc/sconservicetimer.h
connectivitymodules/SeCon/plugins/pcconn/inc/sconshutdownwatcher.h
connectivitymodules/SeCon/plugins/pcconn/src/101f9688.rss
connectivitymodules/SeCon/plugins/pcconn/src/proxy.cpp
connectivitymodules/SeCon/plugins/pcconn/src/sconpcconnplugin.cpp
connectivitymodules/SeCon/plugins/pcconn/src/sconpcconnpluginutils.cpp
connectivitymodules/SeCon/plugins/pcconn/src/sconservicetimer.cpp
connectivitymodules/SeCon/plugins/pcconn/src/sconshutdownwatcher.cpp
connectivitymodules/SeCon/rom/cntparser.iby
connectivitymodules/SeCon/rom/sconcsc.iby
connectivitymodules/SeCon/rom/sconftp.iby
connectivitymodules/SeCon/rom/sconftpplugin.iby
connectivitymodules/SeCon/rom/sconftpresources.iby
connectivitymodules/SeCon/rom/sconpcconnclientserver.iby
connectivitymodules/SeCon/rom/sconpcconnplugin.iby
connectivitymodules/SeCon/rom/sconpcd.iby
connectivitymodules/SeCon/servers/pcconn/bld/bld.inf
connectivitymodules/SeCon/servers/pcconn/bld/sconpcconnserver.mmp
connectivitymodules/SeCon/servers/pcconn/inc/sconpcconnclientserver.h
connectivitymodules/SeCon/servers/pcconn/inc/sconpcconnserver.h
connectivitymodules/SeCon/servers/pcconn/src/sconpcconnserver.cpp
connectivitymodules/SeCon/services/csc/bld/101F9698.xml
connectivitymodules/SeCon/services/csc/bld/101F99F6.xml
connectivitymodules/SeCon/services/csc/bld/bld.inf
connectivitymodules/SeCon/services/csc/bld/def/bwinscwu.def
connectivitymodules/SeCon/services/csc/bld/def/eabiuu.def
connectivitymodules/SeCon/services/csc/bld/fwdcomp.xml
connectivitymodules/SeCon/services/csc/bld/sconcsc.mmp
connectivitymodules/SeCon/services/csc/inc/capability.h
connectivitymodules/SeCon/services/csc/inc/capinfo.h
connectivitymodules/SeCon/services/csc/inc/caplist.h
connectivitymodules/SeCon/services/csc/inc/capparser.h
connectivitymodules/SeCon/services/csc/inc/caputils.h
connectivitymodules/SeCon/services/csc/inc/sconcsc.h
connectivitymodules/SeCon/services/csc/inc/sconsyncservice.h
connectivitymodules/SeCon/services/csc/inc/sconversioninfo.h
connectivitymodules/SeCon/services/csc/inc/stringlist.h
connectivitymodules/SeCon/services/csc/src/capinfo.cpp
connectivitymodules/SeCon/services/csc/src/caplist.cpp
connectivitymodules/SeCon/services/csc/src/capparser.cpp
connectivitymodules/SeCon/services/csc/src/caputils.cpp
connectivitymodules/SeCon/services/csc/src/sconcsc.cpp
connectivitymodules/SeCon/services/csc/src/sconsyncservice.cpp
connectivitymodules/SeCon/services/csc/src/sconversioninfo.cpp
connectivitymodules/SeCon/services/csc/src/stringlist.cpp
connectivitymodules/SeCon/services/ftp/bld/bld.inf
connectivitymodules/SeCon/services/ftp/bld/def/bwinscwu.def
connectivitymodules/SeCon/services/ftp/bld/def/eabiuu.def
connectivitymodules/SeCon/services/ftp/bld/sconftp.mmp
connectivitymodules/SeCon/services/ftp/inc/sconconstants.h
connectivitymodules/SeCon/services/ftp/inc/sconconsts.h
connectivitymodules/SeCon/services/ftp/inc/sconfshandler.h
connectivitymodules/SeCon/services/ftp/inc/sconftp.h
connectivitymodules/SeCon/services/ftp/inc/sconinboxhandler.h
connectivitymodules/SeCon/services/ftp/loc/sconftp.loc
connectivitymodules/SeCon/services/ftp/src/sconfshandler.cpp
connectivitymodules/SeCon/services/ftp/src/sconftp.cpp
connectivitymodules/SeCon/services/ftp/src/sconftp.rss
connectivitymodules/SeCon/services/ftp/src/sconinboxhandler.cpp
connectivitymodules/SeCon/services/pcd/bld/bld.inf
connectivitymodules/SeCon/services/pcd/bld/def/bwinscwu.def
connectivitymodules/SeCon/services/pcd/bld/def/eabiuu.def
connectivitymodules/SeCon/services/pcd/bld/sbeconfig.xml
connectivitymodules/SeCon/services/pcd/bld/sconpcd.mmp
connectivitymodules/SeCon/services/pcd/inc/cscontimeout.h
connectivitymodules/SeCon/services/pcd/inc/sconbackuprestore.h
connectivitymodules/SeCon/services/pcd/inc/sconbrqueue.h
connectivitymodules/SeCon/services/pcd/inc/sconinstaller.h
connectivitymodules/SeCon/services/pcd/inc/sconinstqueue.h
connectivitymodules/SeCon/services/pcd/inc/sconmetadata.h
connectivitymodules/SeCon/services/pcd/inc/sconmetadatafielddefs.h
connectivitymodules/SeCon/services/pcd/inc/sconpcd.h
connectivitymodules/SeCon/services/pcd/inc/sconpcdconsts.h
connectivitymodules/SeCon/services/pcd/inc/sconpcdutility.h
connectivitymodules/SeCon/services/pcd/inc/sconqueue.h
connectivitymodules/SeCon/services/pcd/inc/sconsbeclient.h
connectivitymodules/SeCon/services/pcd/inc/sconvideoparser.h
connectivitymodules/SeCon/services/pcd/src/cscontimeout.cpp
connectivitymodules/SeCon/services/pcd/src/sconbackuprestore.cpp
connectivitymodules/SeCon/services/pcd/src/sconbrqueue.cpp
connectivitymodules/SeCon/services/pcd/src/sconinstaller.cpp
connectivitymodules/SeCon/services/pcd/src/sconinstqueue.cpp
connectivitymodules/SeCon/services/pcd/src/sconmetadata.cpp
connectivitymodules/SeCon/services/pcd/src/sconpcd.cpp
connectivitymodules/SeCon/services/pcd/src/sconpcdutility.cpp
connectivitymodules/SeCon/services/pcd/src/sconqueue.cpp
connectivitymodules/SeCon/services/pcd/src/sconsbeclient.cpp
connectivitymodules/SeCon/services/pcd/src/sconvideoparser.cpp
connectivitymodules/SeCon/wbxml/conmlhandler/bld/bld.inf
connectivitymodules/SeCon/wbxml/conmlhandler/bld/def/bwinscwu.def
connectivitymodules/SeCon/wbxml/conmlhandler/bld/def/eabiu.def
connectivitymodules/SeCon/wbxml/conmlhandler/bld/sconconmlhandler.mmp
connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconconmldtd.h
connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconconmlgenerator.h
connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconconmlhandler.h
connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconconmlhandlererror.h
connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconconmltags.h
connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconwbxmldefs.h
connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconwbxmlparser.inl
connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconxmlelement.h
connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconxmlelement.inl
connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconxmlstack.h
connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconxmlstack.inl
connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconxmlworkspace.h
connectivitymodules/SeCon/wbxml/conmlhandler/src/sconconmldtd.cpp
connectivitymodules/SeCon/wbxml/conmlhandler/src/sconconmlgenerator.cpp
connectivitymodules/SeCon/wbxml/conmlhandler/src/sconconmlhandler.cpp
connectivitymodules/SeCon/wbxml/conmlhandler/src/sconxmlelement.cpp
connectivitymodules/SeCon/wbxml/conmlhandler/src/sconxmlworkspace.cpp
connectivitymodules/group/bld.inf
group/bld.inf
layers.sysdef.xml
mtpdataproviders/mtpfileandfolderdp/group/bld.inf
mtpdataproviders/mtpfileandfolderdp/group/mtp_filedp.iby
mtpdataproviders/mtpfileandfolderdp/group/mtp_filedp.mrp
mtpdataproviders/mtpfileandfolderdp/group/mtpfiledp.mmp
mtpdataproviders/mtpfileandfolderdp/inc/cmtpfiledp.h
mtpdataproviders/mtpfileandfolderdp/inc/cmtpfiledpconfigmgr.h
mtpdataproviders/mtpfileandfolderdp/inc/cmtpfiledpexclusionmgr.h
mtpdataproviders/mtpfileandfolderdp/inc/mmtpfileexclusionmgr.h
mtpdataproviders/mtpfileandfolderdp/inc/mtpfiledp_config.rh
mtpdataproviders/mtpfileandfolderdp/inc/mtpfiledpconst.h
mtpdataproviders/mtpfileandfolderdp/inc/mtpfiledppanic.h
mtpdataproviders/mtpfileandfolderdp/inc/mtpfiledpprocessor.h
mtpdataproviders/mtpfileandfolderdp/inc/rmtpfiledpsingletons.h
mtpdataproviders/mtpfileandfolderdp/src/cmtpfiledp.cpp
mtpdataproviders/mtpfileandfolderdp/src/cmtpfiledpconfigmgr.cpp
mtpdataproviders/mtpfileandfolderdp/src/cmtpfiledpexclusionmgr.cpp
mtpdataproviders/mtpfileandfolderdp/src/mtpfiledp.rss
mtpdataproviders/mtpfileandfolderdp/src/mtpfiledp_config.rss
mtpdataproviders/mtpfileandfolderdp/src/mtpfiledpimplementations.cpp
mtpdataproviders/mtpfileandfolderdp/src/mtpfiledpprocessor.cpp
mtpdataproviders/mtpfileandfolderdp/src/rmtpfiledpsingletons.cpp
mtpdataproviders/mtpimagedp/group/2001FCA2.txt
mtpdataproviders/mtpimagedp/group/bld.inf
mtpdataproviders/mtpimagedp/group/mtp_imagedp.iby
mtpdataproviders/mtpimagedp/group/mtp_imagedp.mrp
mtpdataproviders/mtpimagedp/group/mtpimagedp.mmp
mtpdataproviders/mtpimagedp/inc/cmtpimagedp.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpcopyobject.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpdeleteobject.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetformatcapabilities.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobject.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobjectinfo.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobjectpropdesc.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobjectproplist.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobjectpropssupported.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobjectpropvalue.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobjectreferences.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetpartialobject.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetthumb.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpmdeobserver.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpmoveobject.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpobjectpropertymgr.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedprenameobject.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpsendobjectinfo.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpsetobjectproplist.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpsetobjectpropvalue.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpsetobjectprotection.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpsetobjectreferences.h
mtpdataproviders/mtpimagedp/inc/cmtpimagedpthumbnailcreator.h
mtpdataproviders/mtpimagedp/inc/mtpimagedpconst.h
mtpdataproviders/mtpimagedp/inc/mtpimagedppanic.h
mtpdataproviders/mtpimagedp/inc/mtpimagedprequestprocessor.h
mtpdataproviders/mtpimagedp/inc/mtpimagedputilits.h
mtpdataproviders/mtpimagedp/mediasyncserver/group/bld.inf
mtpdataproviders/mtpimagedp/mediasyncserver/group/mediasyncserver.iby
mtpdataproviders/mtpimagedp/mediasyncserver/group/mediasyncserver.mmp
mtpdataproviders/mtpimagedp/mediasyncserver/group/rmediasyncserver.mmp
mtpdataproviders/mtpimagedp/mediasyncserver/inc/cmediasyncdatabase.h
mtpdataproviders/mtpimagedp/mediasyncserver/inc/cmediasyncdatawriter.h
mtpdataproviders/mtpimagedp/mediasyncserver/inc/cmediasyncobserver.h
mtpdataproviders/mtpimagedp/mediasyncserver/inc/cmediasyncserver.h
mtpdataproviders/mtpimagedp/mediasyncserver/inc/cmediasyncserverdef.h
mtpdataproviders/mtpimagedp/mediasyncserver/inc/cmediasyncserversession.h
mtpdataproviders/mtpimagedp/mediasyncserver/inc/rmediasyncserver.h
mtpdataproviders/mtpimagedp/mediasyncserver/src/cmediasyncdatabase.cpp
mtpdataproviders/mtpimagedp/mediasyncserver/src/cmediasyncdatawriter.cpp
mtpdataproviders/mtpimagedp/mediasyncserver/src/cmediasyncobserver.cpp
mtpdataproviders/mtpimagedp/mediasyncserver/src/cmediasyncserver.cpp
mtpdataproviders/mtpimagedp/mediasyncserver/src/cmediasyncserversession.cpp
mtpdataproviders/mtpimagedp/mediasyncserver/src/main.cpp
mtpdataproviders/mtpimagedp/mediasyncserver/src/rmediasyncserver.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpcopyobject.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpdeleteobject.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobject.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectinfo.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectpropdesc.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectproplist.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectpropssupported.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectpropvalue.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectreferences.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpgetpartialobject.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpgetthumb.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpmdeobserver.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpmoveobject.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedprenameobject.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpsendobjectinfo.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpsetobjectproplist.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpsetobjectpropvalue.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpsetobjectprotection.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpsetobjectreferences.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpthumbnailcreator.cpp
mtpdataproviders/mtpimagedp/src/mtpimagedp.rss
mtpdataproviders/mtpimagedp/src/mtpimagedp_config.rss
mtpdataproviders/mtpimagedp/src/mtpimagedpgetformatcapabilities.cpp
mtpdataproviders/mtpimagedp/src/mtpimagedpimplementations.cpp
mtpdataproviders/mtpimagedp/src/mtpimagedprequestprocessor.cpp
mtpdataproviders/mtpimagedp/src/mtpimagedputilits.cpp
mtpdataproviders/mtppictbridgedp/group/bld.inf
mtpdataproviders/mtppictbridgedp/group/mtp_pictbridgedp.mrp
mtpdataproviders/mtppictbridgedp/group/mtppictbridgedp.iby
mtpdataproviders/mtppictbridgedp/group/mtppictbridgedp.mmp
mtpdataproviders/mtppictbridgedp/group/rptp.iby
mtpdataproviders/mtppictbridgedp/group/rptp.mmp
mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgedp.h
mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgedpgetobject.h
mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgedpgetobjectinfo.h
mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgedpgetobjectpropdesc.h
mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgedpgetobjectproplist.h
mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgedpsendobjectinfo.h
mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgeenumerator.h
mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgegetformatcapabilities.h
mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgegetobjectpropssupported.h
mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgeprinter.h
mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgeusbconnection.h
mtpdataproviders/mtppictbridgedp/inc/cptpreceivedmsghandler.h
mtpdataproviders/mtppictbridgedp/inc/cptpserver.h
mtpdataproviders/mtppictbridgedp/inc/cptpsession.h
mtpdataproviders/mtppictbridgedp/inc/cptptimer.h
mtpdataproviders/mtppictbridgedp/inc/mmtppictbridgeenumeratorcallback.h
mtpdataproviders/mtppictbridgedp/inc/mtppictbridgedpconst.h
mtpdataproviders/mtppictbridgedp/inc/mtppictbridgedppanic.h
mtpdataproviders/mtppictbridgedp/inc/mtppictbridgedpprocessor.h
mtpdataproviders/mtppictbridgedp/inc/ptpdef.h
mtpdataproviders/mtppictbridgedp/inc/rptp.h
mtpdataproviders/mtppictbridgedp/inc/s60dependency.h
mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedp.cpp
mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpgetformatcapabilities.cpp
mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpgetobject.cpp
mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpgetobjectinfo.cpp
mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpgetobjectpropdesc.cpp
mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpgetobjectproplist.cpp
mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpsendobjectinfo.cpp
mtpdataproviders/mtppictbridgedp/src/cmtppictbridgeenumerator.cpp
mtpdataproviders/mtppictbridgedp/src/cmtppictbridgegetobjectpropssupported.cpp
mtpdataproviders/mtppictbridgedp/src/cmtppictbridgeprinter.cpp
mtpdataproviders/mtppictbridgedp/src/cmtppictbridgeusbconnection.cpp
mtpdataproviders/mtppictbridgedp/src/cptpreceivedmsghandler.cpp
mtpdataproviders/mtppictbridgedp/src/cptpserver.cpp
mtpdataproviders/mtppictbridgedp/src/cptpsession.cpp
mtpdataproviders/mtppictbridgedp/src/cptptimer.cpp
mtpdataproviders/mtppictbridgedp/src/mtppictbridgedp.rss
mtpdataproviders/mtppictbridgedp/src/mtppictbridgedp_config.rss
mtpdataproviders/mtppictbridgedp/src/mtppictbridgedpimplementations.cpp
mtpdataproviders/mtppictbridgedp/src/mtppictbridgerequestprocessor.cpp
mtpdataproviders/mtppictbridgedp/src/rptp.cpp
mtpfws/mtpfw/common/inc/cmtprequestlogger.h
mtpfws/mtpfw/common/inc/mtpbuildoptions.hrh
mtpfws/mtpfw/common/inc/mtpdatacapture.h
mtpfws/mtpfw/common/inc/mtpdebug.h
mtpfws/mtpfw/daemon/client/group/bld.inf
mtpfws/mtpfw/daemon/client/group/mtpclient.mmp
mtpfws/mtpfw/daemon/client/interface/rmtpclient.h
mtpfws/mtpfw/daemon/client/src/rmtpclient.cpp
mtpfws/mtpfw/daemon/common/inc/mtpclientserver.h
mtpfws/mtpfw/daemon/group/bld.inf
mtpfws/mtpfw/daemon/server/group/bld.inf
mtpfws/mtpfw/daemon/server/group/mtpserver.mmp
mtpfws/mtpfw/daemon/server/inc/cmtpserver.h
mtpfws/mtpfw/daemon/server/inc/cmtpserversession.h
mtpfws/mtpfw/daemon/server/inc/cmtpshutdown.h
mtpfws/mtpfw/daemon/server/src/cmtpserver.cpp
mtpfws/mtpfw/daemon/server/src/cmtpserversession.cpp
mtpfws/mtpfw/daemon/server/src/cmtpshutdown.cpp
mtpfws/mtpfw/dataproviders/dataproviderapi/group/bld.inf
mtpfws/mtpfw/dataproviders/dataproviderapi/group/mtpdataproviderapi.mmp
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/cmtpdataproviderplugin.h
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/cmtpmetadata.h
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/cmtpobjectmetadata.h
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/cmtpstoragemetadata.h
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpconnection.h
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpdatacodegenerator.h
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpdataprovider.h
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpdataproviderconfig.h
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpdataproviderframework.h
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpframeworkconfig.h
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpobjectmgr.h
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpreferencemgr.h
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpsession.h
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpstoragemgr.h
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mtpdataproviderapitypes.h
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mtpdataproviderconfig.hrh
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mtpdataproviderconfig.rh
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mtpobjectmgrquerytypes.h
mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mtpstoragemgrquerytypes.h
mtpfws/mtpfw/dataproviders/dataproviderapi/src/cmtpdataproviderplugin.cpp
mtpfws/mtpfw/dataproviders/dataproviderapi/src/cmtpmetadata.cpp
mtpfws/mtpfw/dataproviders/dataproviderapi/src/cmtpobjectmetadata.cpp
mtpfws/mtpfw/dataproviders/dataproviderapi/src/cmtpstoragemetadata.cpp
mtpfws/mtpfw/dataproviders/dataproviderapi/src/mmtpdataprovider.cpp
mtpfws/mtpfw/dataproviders/dataproviderapi/src/mtpobjectmgrquerytypes.cpp
mtpfws/mtpfw/dataproviders/dataproviderapi/src/mtpstoragemgrquerytypes.cpp
mtpfws/mtpfw/dataproviders/devdp/devdpextn/group/bld.inf
mtpfws/mtpfw/dataproviders/devdp/devdpextn/group/devdpextn.mmp
mtpfws/mtpfw/dataproviders/devdp/devdpextn/inc/cmtpextndevdpplugin.h
mtpfws/mtpfw/dataproviders/devdp/devdpextn/src/cmtpextndevdpplugin.cpp
mtpfws/mtpfw/dataproviders/devdp/devdpextn/src/devdpextn.rss
mtpfws/mtpfw/dataproviders/devdp/devdpextn/src/implproxy.cpp
mtpfws/mtpfw/dataproviders/devdp/devdpextnapi/group/bld.inf
mtpfws/mtpfw/dataproviders/devdp/devdpextnapi/group/mtpdevdpextnapi.mmp
mtpfws/mtpfw/dataproviders/devdp/devdpextnapi/interface/cmtpextndevdp.h
mtpfws/mtpfw/dataproviders/devdp/devdpextnapi/interface/mmtpdevdpextn.h
mtpfws/mtpfw/dataproviders/devdp/devdpextnapi/src/cmtpdevdpextn.cpp
mtpfws/mtpfw/dataproviders/devdp/group/bld.inf
mtpfws/mtpfw/dataproviders/devdp/group/mtp_devicedp.iby
mtpfws/mtpfw/dataproviders/devdp/group/mtpdevice.ico
mtpfws/mtpfw/dataproviders/devdp/group/mtpdevicedp.mmp
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpclosesession.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevdpexclusionmgr.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevdpextnmap.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevicedatastore.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevicedp.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevicedpconfigmgr.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevrequestunknown.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetdeviceinfo.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetdevicepropdesc.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetdevicepropvalue.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetnumobjects.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetobjecthandles.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetserviceids.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetserviceinfo.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetstorageids.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetstorageinfo.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpopensession.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpresetdevice.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpresetdevicepropvalue.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpsetdevicepropvalue.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpstoragewatcher.h
mtpfws/mtpfw/dataproviders/devdp/inc/cmtptypedeviceinfo.h
mtpfws/mtpfw/dataproviders/devdp/inc/mextndevplugincallback.h
mtpfws/mtpfw/dataproviders/devdp/inc/mtpdevdppanic.h
mtpfws/mtpfw/dataproviders/devdp/inc/mtpdevicedp_config.rh
mtpfws/mtpfw/dataproviders/devdp/inc/mtpdevicedpconst.h
mtpfws/mtpfw/dataproviders/devdp/inc/mtpdevicedpprocessor.h
mtpfws/mtpfw/dataproviders/devdp/inc/rmtpdevicedpsingletons.h
mtpfws/mtpfw/dataproviders/devdp/src/cmtpclosesession.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevdpexclusionmgr.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevdpextnmap.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedatastore.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedp.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedpconfigmgr.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevrequestunknown.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetdeviceinfo.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetdevicepropdesc.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetdevicepropvalue.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetnumobjects.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetobjecthandles.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetserviceids.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetserviceinfo.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageids.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageinfo.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpopensession.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpresetdevice.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpresetdevicepropvalue.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpsetdevicepropvalue.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpstoragewatcher.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtptypedeviceinfo.cpp
mtpfws/mtpfw/dataproviders/devdp/src/mtpdevicedp.rss
mtpfws/mtpfw/dataproviders/devdp/src/mtpdevicedp_config.rss
mtpfws/mtpfw/dataproviders/devdp/src/mtpdevicedpimplementations.cpp
mtpfws/mtpfw/dataproviders/devdp/src/mtpdevicedpprocessor.cpp
mtpfws/mtpfw/dataproviders/devdp/src/rmtpdevicedpsingletons.cpp
mtpfws/mtpfw/dataproviders/dputility/group/bld.inf
mtpfws/mtpfw/dataproviders/dputility/group/mtpdataproviderutility.mmp
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpabstractdatacodemgr.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpcommonrequestprocessor.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpcopyobject.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpdeleteobject.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpextensionmapping.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpfsenumerator.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpfsexclusionmgr.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpfullenumservicehandler.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetformatcapabilities.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetinterdependentpropdesc.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetobject.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetobjectinfo.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetobjectpropdesc.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetobjectproplist.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetobjectpropssupported.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetobjectpropvalue.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetpartialobject.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetreferences.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpknowledgehandler.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpmoveobject.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtprequestchecker.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtprequestprocessor.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtprequestunknown.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsendobjectinfo.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsetobjectproplist.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsetobjectpropvalue.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsetobjectprotection.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsetreferences.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvccompoundprocessor.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcdeleteobject.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcdeleteobjectproplist.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcdeleteserviceproplist.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetobject.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetobjectinfo.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetobjectproplist.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetreferences.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetservicecapabilities.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetserviceinfo.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetservicepropdesc.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetserviceproplist.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetstorageinfo.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcsetobjectproplist.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcsetreferences.h
mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcsetserviceproplist.h
mtpfws/mtpfw/dataproviders/dputility/inc/mmtpenumerationcallback.h
mtpfws/mtpfw/dataproviders/dputility/inc/mmtpservicedataprovider.h
mtpfws/mtpfw/dataproviders/dputility/inc/mmtpservicehandler.h
mtpfws/mtpfw/dataproviders/dputility/inc/mmtpsvcobjecthandler.h
mtpfws/mtpfw/dataproviders/dputility/inc/mtpdpconst.h
mtpfws/mtpfw/dataproviders/dputility/inc/mtpdppanic.h
mtpfws/mtpfw/dataproviders/dputility/inc/mtpsvcdpconst.h
mtpfws/mtpfw/dataproviders/dputility/inc/rmtpdpsingletons.h
mtpfws/mtpfw/dataproviders/dputility/inc/rmtputility.h
mtpfws/mtpfw/dataproviders/dputility/src/cmtpabstractdatacodemgr.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpcommonrequestprocessor.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpcopyobject.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpdeleteobject.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpextensionmapping.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsenumerator.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsexclusionmgr.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpfullenumservicehandler.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetformatcapabilities.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetinterdependentpropdesc.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobject.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectinfo.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectpropdesc.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectproplist.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectpropssupported.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectpropvalue.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetpartialobject.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetreferences.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpknowledgehandler.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpmoveobject.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtprequestchecker.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtprequestprocessor.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtprequestunknown.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectproplist.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectpropvalue.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectprotection.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetreferences.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvccompoundprocessor.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcdeleteobject.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcdeleteobjectproplist.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcdeleteserviceproplist.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetobject.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetobjectinfo.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetobjectproplist.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetreferences.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetservicecapabilities.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetserviceinfo.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetservicepropdesc.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetserviceproplist.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetstorageinfo.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcsetobjectproplist.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcsetreferences.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcsetserviceproplist.cpp
mtpfws/mtpfw/dataproviders/dputility/src/mmtpservicedataprovider.cpp
mtpfws/mtpfw/dataproviders/dputility/src/mmtpservicehandler.cpp
mtpfws/mtpfw/dataproviders/dputility/src/mmtpsvcobjecthandler.cpp
mtpfws/mtpfw/dataproviders/dputility/src/rmtpdpsingletons.cpp
mtpfws/mtpfw/dataproviders/dputility/src/rmtputility.cpp
mtpfws/mtpfw/dataproviders/group/bld.inf
mtpfws/mtpfw/dataproviders/proxydp/group/bld.inf
mtpfws/mtpfw/dataproviders/proxydp/group/mtpproxydp.mmp
mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpcopyobject.h
mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpdeleteobject.h
mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpdeleteobjectproplist.h
mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpgetformatcapabilities.h
mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpgetobjectproplist.h
mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpgetobjectpropssupported.h
mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpmoveobject.h
mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpobjectbrowser.h
mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpproxydp.h
mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpproxydpconfigmgr.h
mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpsendobjectinfo.h
mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpsendobjectproplist.h
mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpsetobjectproplist.h
mtpfws/mtpfw/dataproviders/proxydp/inc/mtpproxydppanic.h
mtpfws/mtpfw/dataproviders/proxydp/inc/mtpproxydpprocessor.h
mtpfws/mtpfw/dataproviders/proxydp/inc/rmtpproxydpsingletons.h
mtpfws/mtpfw/dataproviders/proxydp/src/cmtpcopyobject.cpp
mtpfws/mtpfw/dataproviders/proxydp/src/cmtpdeleteobject.cpp
mtpfws/mtpfw/dataproviders/proxydp/src/cmtpdeleteobjectproplist.cpp
mtpfws/mtpfw/dataproviders/proxydp/src/cmtpgetformatcapabilities.cpp
mtpfws/mtpfw/dataproviders/proxydp/src/cmtpgetobjectproplist.cpp
mtpfws/mtpfw/dataproviders/proxydp/src/cmtpgetobjectpropssupported.cpp
mtpfws/mtpfw/dataproviders/proxydp/src/cmtpmoveobject.cpp
mtpfws/mtpfw/dataproviders/proxydp/src/cmtpobjectbrowser.cpp
mtpfws/mtpfw/dataproviders/proxydp/src/cmtpproxydp.cpp
mtpfws/mtpfw/dataproviders/proxydp/src/cmtpproxydpconfigmgr.cpp
mtpfws/mtpfw/dataproviders/proxydp/src/cmtpsendobjectinfo.cpp
mtpfws/mtpfw/dataproviders/proxydp/src/cmtpsendobjectproplist.cpp
mtpfws/mtpfw/dataproviders/proxydp/src/cmtpsetobjectproplist.cpp
mtpfws/mtpfw/dataproviders/proxydp/src/mtpproxydp.rss
mtpfws/mtpfw/dataproviders/proxydp/src/mtpproxydp_config.rss
mtpfws/mtpfw/dataproviders/proxydp/src/mtpproxydpimplementations.cpp
mtpfws/mtpfw/dataproviders/proxydp/src/mtpproxydpprocessor.cpp
mtpfws/mtpfw/dataproviders/proxydp/src/rmtpproxydpsingletons.cpp
mtpfws/mtpfw/datatypes/group/bld.inf
mtpfws/mtpfw/datatypes/group/mtpdatatypes.mmp
mtpfws/mtpfw/datatypes/inc/cmtptypecomplexbuffer.h
mtpfws/mtpfw/datatypes/inc/mtpdatatypespanic.h
mtpfws/mtpfw/datatypes/interface/cmtptypearray.h
mtpfws/mtpfw/datatypes/interface/cmtptypecompoundbase.h
mtpfws/mtpfw/datatypes/interface/cmtptypedeleteobjectproplist.h
mtpfws/mtpfw/datatypes/interface/cmtptypedeleteserviceproplist.h
mtpfws/mtpfw/datatypes/interface/cmtptypedevicepropdesc.h
mtpfws/mtpfw/datatypes/interface/cmtptypefile.h
mtpfws/mtpfw/datatypes/interface/cmtptypeformatcapabilitylist.h
mtpfws/mtpfw/datatypes/interface/cmtptypeinterdependentpropdesc.h
mtpfws/mtpfw/datatypes/interface/cmtptypelist.h
mtpfws/mtpfw/datatypes/interface/cmtptypeobjectinfo.h
mtpfws/mtpfw/datatypes/interface/cmtptypeobjectpropdesc.h
mtpfws/mtpfw/datatypes/interface/cmtptypeobjectproplist.h
mtpfws/mtpfw/datatypes/interface/cmtptypeopaquedata.h
mtpfws/mtpfw/datatypes/interface/cmtptypeservicecapabilitylist.h
mtpfws/mtpfw/datatypes/interface/cmtptypeserviceevent.h
mtpfws/mtpfw/datatypes/interface/cmtptypeserviceformat.h
mtpfws/mtpfw/datatypes/interface/cmtptypeserviceinfo.h
mtpfws/mtpfw/datatypes/interface/cmtptypeservicemethod.h
mtpfws/mtpfw/datatypes/interface/cmtptypeservicemethodparamextnform.h
mtpfws/mtpfw/datatypes/interface/cmtptypeserviceobjpropextnform.h
mtpfws/mtpfw/datatypes/interface/cmtptypeserviceprop.h
mtpfws/mtpfw/datatypes/interface/cmtptypeservicepropdesclist.h
mtpfws/mtpfw/datatypes/interface/cmtptypeserviceproplist.h
mtpfws/mtpfw/datatypes/interface/cmtptypestorageinfo.h
mtpfws/mtpfw/datatypes/interface/cmtptypestring.h
mtpfws/mtpfw/datatypes/interface/cmtptypetrivialdata.h
mtpfws/mtpfw/datatypes/interface/mmtptype.h
mtpfws/mtpfw/datatypes/interface/mtpdatatypeconstants.h
mtpfws/mtpfw/datatypes/interface/mtpprotocolconstants.h
mtpfws/mtpfw/datatypes/interface/mtptypes.h
mtpfws/mtpfw/datatypes/interface/mtptypescomplex.h
mtpfws/mtpfw/datatypes/interface/mtptypescompound.h
mtpfws/mtpfw/datatypes/interface/mtptypesflat.h
mtpfws/mtpfw/datatypes/interface/mtptypessimple.h
mtpfws/mtpfw/datatypes/interface/rmtptype.h
mtpfws/mtpfw/datatypes/interface/tmtptypedatapair.h
mtpfws/mtpfw/datatypes/interface/tmtptypeevent.h
mtpfws/mtpfw/datatypes/interface/tmtptypeflatbase.h
mtpfws/mtpfw/datatypes/interface/tmtptypeguid.h
mtpfws/mtpfw/datatypes/interface/tmtptypeint128.h
mtpfws/mtpfw/datatypes/interface/tmtptypeint16.h
mtpfws/mtpfw/datatypes/interface/tmtptypeint32.h
mtpfws/mtpfw/datatypes/interface/tmtptypeint64.h
mtpfws/mtpfw/datatypes/interface/tmtptypeint8.h
mtpfws/mtpfw/datatypes/interface/tmtptypeintbase.h
mtpfws/mtpfw/datatypes/interface/tmtptypenull.h
mtpfws/mtpfw/datatypes/interface/tmtptyperequest.h
mtpfws/mtpfw/datatypes/interface/tmtptyperesponse.h
mtpfws/mtpfw/datatypes/interface/tmtptypeuint128.h
mtpfws/mtpfw/datatypes/interface/tmtptypeuint16.h
mtpfws/mtpfw/datatypes/interface/tmtptypeuint32.h
mtpfws/mtpfw/datatypes/interface/tmtptypeuint64.h
mtpfws/mtpfw/datatypes/interface/tmtptypeuint8.h
mtpfws/mtpfw/datatypes/interface/tmtptypeuintbase.h
mtpfws/mtpfw/datatypes/src/cmtptypearray.cpp
mtpfws/mtpfw/datatypes/src/cmtptypecomplexbuffer.cpp
mtpfws/mtpfw/datatypes/src/cmtptypecompoundbase.cpp
mtpfws/mtpfw/datatypes/src/cmtptypedeleteobjectproplist.cpp
mtpfws/mtpfw/datatypes/src/cmtptypedeleteserviceproplist.cpp
mtpfws/mtpfw/datatypes/src/cmtptypedevicepropdesc.cpp
mtpfws/mtpfw/datatypes/src/cmtptypefile.cpp
mtpfws/mtpfw/datatypes/src/cmtptypeinterdependentpropdesc.cpp
mtpfws/mtpfw/datatypes/src/cmtptypelist.cpp
mtpfws/mtpfw/datatypes/src/cmtptypeobjectinfo.cpp
mtpfws/mtpfw/datatypes/src/cmtptypeobjectpropdesc.cpp
mtpfws/mtpfw/datatypes/src/cmtptypeobjectproplist.cpp
mtpfws/mtpfw/datatypes/src/cmtptypeopaquedata.cpp
mtpfws/mtpfw/datatypes/src/cmtptypeservicecapabilitylist.cpp
mtpfws/mtpfw/datatypes/src/cmtptypeserviceevent.cpp
mtpfws/mtpfw/datatypes/src/cmtptypeserviceformat.cpp
mtpfws/mtpfw/datatypes/src/cmtptypeserviceinfo.cpp
mtpfws/mtpfw/datatypes/src/cmtptypeservicemethod.cpp
mtpfws/mtpfw/datatypes/src/cmtptypeservicemethodparamextnform.cpp
mtpfws/mtpfw/datatypes/src/cmtptypeserviceobjpropextnform.cpp
mtpfws/mtpfw/datatypes/src/cmtptypeserviceprop.cpp
mtpfws/mtpfw/datatypes/src/cmtptypeservicepropdesclist.cpp
mtpfws/mtpfw/datatypes/src/cmtptypeserviceproplist.cpp
mtpfws/mtpfw/datatypes/src/cmtptypestorageinfo.cpp
mtpfws/mtpfw/datatypes/src/cmtptypestring.cpp
mtpfws/mtpfw/datatypes/src/cmtptypetrivialdata.cpp
mtpfws/mtpfw/datatypes/src/mmtptype.cpp
mtpfws/mtpfw/datatypes/src/rmtptype.cpp
mtpfws/mtpfw/datatypes/src/tmtptypedatapair.cpp
mtpfws/mtpfw/datatypes/src/tmtptypeevent.cpp
mtpfws/mtpfw/datatypes/src/tmtptypeflatbase.cpp
mtpfws/mtpfw/datatypes/src/tmtptypeguid.cpp
mtpfws/mtpfw/datatypes/src/tmtptypeint128.cpp
mtpfws/mtpfw/datatypes/src/tmtptypeint16.cpp
mtpfws/mtpfw/datatypes/src/tmtptypeint32.cpp
mtpfws/mtpfw/datatypes/src/tmtptypeint64.cpp
mtpfws/mtpfw/datatypes/src/tmtptypeint8.cpp
mtpfws/mtpfw/datatypes/src/tmtptypeintbase.cpp
mtpfws/mtpfw/datatypes/src/tmtptypenull.cpp
mtpfws/mtpfw/datatypes/src/tmtptyperequest.cpp
mtpfws/mtpfw/datatypes/src/tmtptyperesponse.cpp
mtpfws/mtpfw/datatypes/src/tmtptypeuint128.cpp
mtpfws/mtpfw/datatypes/src/tmtptypeuint16.cpp
mtpfws/mtpfw/datatypes/src/tmtptypeuint32.cpp
mtpfws/mtpfw/datatypes/src/tmtptypeuint64.cpp
mtpfws/mtpfw/datatypes/src/tmtptypeuint8.cpp
mtpfws/mtpfw/datatypes/src/tmtptypeuintbase.cpp
mtpfws/mtpfw/group/10282FCC_ARMV5.cre
mtpfws/mtpfw/group/10282FCC_ARMV5.txt
mtpfws/mtpfw/group/10282FCC_WINSCW.cre
mtpfws/mtpfw/group/10282FCC_WINSCW.txt
mtpfws/mtpfw/group/backup_registration.xml
mtpfws/mtpfw/group/bld.inf
mtpfws/mtpfw/group/centrep_compile.cmd
mtpfws/mtpfw/group/mtp_framework.iby
mtpfws/mtpfw/group/mtp_framework.mrp
mtpfws/mtpfw/group/mtpframework.mmp
mtpfws/mtpfw/inc/cdummydp.h
mtpfws/mtpfw/inc/cmtpconnection.h
mtpfws/mtpfw/inc/cmtpconnectionmgr.h
mtpfws/mtpfw/inc/cmtpdatacodegenerator.h
mtpfws/mtpfw/inc/cmtpdataprovider.h
mtpfws/mtpfw/inc/cmtpdataproviderconfig.h
mtpfws/mtpfw/inc/cmtpdataprovidercontroller.h
mtpfws/mtpfw/inc/cmtpdeltadatamgr.h
mtpfws/mtpfw/inc/cmtpdpidstore.h
mtpfws/mtpfw/inc/cmtpframeworkconfig.h
mtpfws/mtpfw/inc/cmtphandleallocator.h
mtpfws/mtpfw/inc/cmtpobjectmgr.h
mtpfws/mtpfw/inc/cmtpobjectstore.h
mtpfws/mtpfw/inc/cmtpparserrouter.h
mtpfws/mtpfw/inc/cmtppkgidstore.h
mtpfws/mtpfw/inc/cmtpreferencemgr.h
mtpfws/mtpfw/inc/cmtpserviceconfig.h
mtpfws/mtpfw/inc/cmtpserviceinfo.h
mtpfws/mtpfw/inc/cmtpservicemgr.h
mtpfws/mtpfw/inc/cmtpsession.h
mtpfws/mtpfw/inc/cmtpstoragemgr.h
mtpfws/mtpfw/inc/cmtpxmlparserlogger.h
mtpfws/mtpfw/inc/dbutility.h
mtpfws/mtpfw/inc/mmtptransactionproxy.h
mtpfws/mtpfw/inc/mtpframeworkconst.h
mtpfws/mtpfw/inc/mtpservicecommon.h
mtpfws/mtpfw/inc/mtpserviceconfig.hrh
mtpfws/mtpfw/inc/mtpserviceconfig.rh
mtpfws/mtpfw/inc/rmtpframework.h
mtpfws/mtpfw/inc/ruidmapper.h
mtpfws/mtpfw/inc/tmtptypeobjecthandle.h
mtpfws/mtpfw/src/cdummydp.cpp
mtpfws/mtpfw/src/cmtpconnection.cpp
mtpfws/mtpfw/src/cmtpconnectionmgr.cpp
mtpfws/mtpfw/src/cmtpdatacodegenerator.cpp
mtpfws/mtpfw/src/cmtpdataprovider.cpp
mtpfws/mtpfw/src/cmtpdataproviderconfig.cpp
mtpfws/mtpfw/src/cmtpdataprovidercontroller.cpp
mtpfws/mtpfw/src/cmtpdeltadatamgr.cpp
mtpfws/mtpfw/src/cmtpdpidstore.cpp
mtpfws/mtpfw/src/cmtpframeworkconfig.cpp
mtpfws/mtpfw/src/cmtphandleallocator.cpp
mtpfws/mtpfw/src/cmtpobjectmgr.cpp
mtpfws/mtpfw/src/cmtpobjectstore.cpp
mtpfws/mtpfw/src/cmtpparserrouter.cpp
mtpfws/mtpfw/src/cmtppkgidstore.cpp
mtpfws/mtpfw/src/cmtpreferencemgr.cpp
mtpfws/mtpfw/src/cmtpserviceconfig.cpp
mtpfws/mtpfw/src/cmtpserviceinfo.cpp
mtpfws/mtpfw/src/cmtpservicemgr.cpp
mtpfws/mtpfw/src/cmtpsession.cpp
mtpfws/mtpfw/src/cmtpstoragemgr.cpp
mtpfws/mtpfw/src/dbutility.cpp
mtpfws/mtpfw/src/dummydp_config.rss
mtpfws/mtpfw/src/framework_config.rss
mtpfws/mtpfw/src/rmtpframework.cpp
mtpfws/mtpfw/src/ruidmapper.cpp
mtpfws/mtpfw/src/services_config.rss
mtpfws/mtpfw/src/tmtptypeobjecthandle.cpp
mtpfws/mtpfw/transports/transportapi/group/bld.inf
mtpfws/mtpfw/transports/transportapi/group/mtptransportapi.mmp
mtpfws/mtpfw/transports/transportapi/inc/cmtptransportplugin.h
mtpfws/mtpfw/transports/transportapi/inc/mmtpconnectionmgr.h
mtpfws/mtpfw/transports/transportapi/inc/mmtpconnectionprotocol.h
mtpfws/mtpfw/transports/transportapi/inc/mmtptransportconnection.h
mtpfws/mtpfw/transports/transportapi/src/cmtptransportplugin.cpp
mtptransports/mtpcontroller/group/bld.inf
mtptransports/mtpcontroller/group/mtp_controller.iby
mtptransports/mtpcontroller/group/mtpcontroller.mmp
mtptransports/mtpcontroller/group/mtpcontroller.mrp
mtptransports/mtpcontroller/inc/cmtpbearermonitor.h
mtptransports/mtpcontroller/inc/cmtpbluetoothcontroller.h
mtptransports/mtpcontroller/inc/cmtpcontrollerbase.h
mtptransports/mtpcontroller/inc/cmtpoperator.h
mtptransports/mtpcontroller/inc/mmtpoperatornotifier.h
mtptransports/mtpcontroller/locodinc/locodbearer.h
mtptransports/mtpcontroller/locodinc/locodplugin.hrh
mtptransports/mtpcontroller/locodinc/locodserviceplugin.h
mtptransports/mtpcontroller/locodinc/locodserviceplugin.inl
mtptransports/mtpcontroller/locodinc/locodservicepluginobserver.h
mtptransports/mtpcontroller/locodinc/locodservicepluginparams.h
mtptransports/mtpcontroller/locodinc/locodservicepluginparams.inl
mtptransports/mtpcontroller/src/cmtpbearermonitor.cpp
mtptransports/mtpcontroller/src/cmtpbluetoothcontroller.cpp
mtptransports/mtpcontroller/src/cmtpcontrollerbase.cpp
mtptransports/mtpcontroller/src/cmtpoperator.cpp
mtptransports/mtpcontroller/src/mtpcontroller.rss
mtptransports/mtpcontroller/src/proxy.cpp
mtptransports/mtpptpiptransport/common/inc/ptpippanic.h
mtptransports/mtpptpiptransport/common/inc/ptpipprotocolconstants.h
mtptransports/mtpptpiptransport/common/inc/ptpipsocketpublish.h
mtptransports/mtpptpiptransport/filterapi/group/bld.inf
mtptransports/mtpptpiptransport/filterapi/group/ptpipfilterapi.mmp
mtptransports/mtpptpiptransport/filterapi/interface/cptpiphostfilterinterface.h
mtptransports/mtpptpiptransport/filterapi/interface/mptpiphostfilter.h
mtptransports/mtpptpiptransport/filterapi/src/cptpiphostfilterinterface.cpp
mtptransports/mtpptpiptransport/group/bld.inf
mtptransports/mtpptpiptransport/group/mtp_ptpip.iby
mtptransports/mtpptpiptransport/group/mtp_ptpip.mrp
mtptransports/mtpptpiptransport/ptpipcontroller/group/bld.inf
mtptransports/mtpptpiptransport/ptpipcontroller/group/ptpipcontroller.mmp
mtptransports/mtpptpiptransport/ptpipcontroller/inc/cptpipcontroller.h
mtptransports/mtpptpiptransport/ptpipcontroller/inc/cptpipsockethandler.h
mtptransports/mtpptpiptransport/ptpipcontroller/inc/cptpiptimer.h
mtptransports/mtpptpiptransport/ptpipcontroller/interface/mptpipcontroller.h
mtptransports/mtpptpiptransport/ptpipcontroller/interface/rptpipframework.h
mtptransports/mtpptpiptransport/ptpipcontroller/src/cptpipcontroller.cpp
mtptransports/mtpptpiptransport/ptpipcontroller/src/cptpipsockethandler.cpp
mtptransports/mtpptpiptransport/ptpipcontroller/src/cptpiptimer.cpp
mtptransports/mtpptpiptransport/ptpipcontroller/src/rptpipframework.cpp
mtptransports/mtpptpiptransport/ptpipdatatypes/group/bld.inf
mtptransports/mtpptpiptransport/ptpipdatatypes/group/ptpipdatatypes.mmp
mtptransports/mtpptpiptransport/ptpipdatatypes/inc/cptpipdatacontainer.h
mtptransports/mtpptpiptransport/ptpipdatatypes/inc/cptpipgenericcontainer.h
mtptransports/mtpptpiptransport/ptpipdatatypes/inc/cptpipinitcmdack.h
mtptransports/mtpptpiptransport/ptpipdatatypes/inc/cptpipinitcmdreq.h
mtptransports/mtpptpiptransport/ptpipdatatypes/inc/ptpipdatatypes.h
mtptransports/mtpptpiptransport/ptpipdatatypes/inc/tptpipinitevtack.h
mtptransports/mtpptpiptransport/ptpipdatatypes/inc/tptpipinitevtreq.h
mtptransports/mtpptpiptransport/ptpipdatatypes/inc/tptpipinitfailed.h
mtptransports/mtpptpiptransport/ptpipdatatypes/inc/tptpiprequestpayload.h
mtptransports/mtpptpiptransport/ptpipdatatypes/inc/tptpipresponsepayload.h
mtptransports/mtpptpiptransport/ptpipdatatypes/inc/tptpipstartdatapayload.h
mtptransports/mtpptpiptransport/ptpipdatatypes/src/cptpipdatacontainer.cpp
mtptransports/mtpptpiptransport/ptpipdatatypes/src/cptpipgenericcontainer.cpp
mtptransports/mtpptpiptransport/ptpipdatatypes/src/cptpipinitcmdack.cpp
mtptransports/mtpptpiptransport/ptpipdatatypes/src/cptpipinitcmdreq.cpp
mtptransports/mtpptpiptransport/ptpipdatatypes/src/tptpipinitevtack.cpp
mtptransports/mtpptpiptransport/ptpipdatatypes/src/tptpipinitevtreq.cpp
mtptransports/mtpptpiptransport/ptpipdatatypes/src/tptpipinitfailed.cpp
mtptransports/mtpptpiptransport/ptpipdatatypes/src/tptpiprequestpayload.cpp
mtptransports/mtpptpiptransport/ptpipdatatypes/src/tptpipresponsepayload.cpp
mtptransports/mtpptpiptransport/ptpipdatatypes/src/tptpipstartdatapayload.cpp
mtptransports/mtpptpiptransport/ptpipplugin/group/bld.inf
mtptransports/mtpptpiptransport/ptpipplugin/group/ptpipplugin.mmp
mtptransports/mtpptpiptransport/ptpipplugin/inc/cptpipcommandhandler.h
mtptransports/mtpptpiptransport/ptpipplugin/inc/cptpipconnection.h
mtptransports/mtpptpiptransport/ptpipplugin/inc/cptpipeventhandler.h
mtptransports/mtpptpiptransport/ptpipplugin/inc/cptpipsockhandlerbase.h
mtptransports/mtpptpiptransport/ptpipplugin/inc/cptpiptransport.h
mtptransports/mtpptpiptransport/ptpipplugin/src/cptpipcommandhandler.cpp
mtptransports/mtpptpiptransport/ptpipplugin/src/cptpipconnection.cpp
mtptransports/mtpptpiptransport/ptpipplugin/src/cptpipeventhandler.cpp
mtptransports/mtpptpiptransport/ptpipplugin/src/cptpipsockhandlerbase.cpp
mtptransports/mtpptpiptransport/ptpipplugin/src/cptpiptransport.cpp
mtptransports/mtpptpiptransport/ptpipplugin/src/ptpipplugin.rss
mtptransports/mtpusbtransport/common/inc/mtpusbpanic.h
mtptransports/mtpusbtransport/common/inc/mtpusbprotocolconstants.h
mtptransports/mtpusbtransport/group/bld.inf
mtptransports/mtpusbtransport/group/mtp_usbsic.iby
mtptransports/mtpusbtransport/group/mtp_usbsic.mrp
mtptransports/mtpusbtransport/usbdatatypes/group/bld.inf
mtptransports/mtpusbtransport/usbdatatypes/group/mtpusbdatatypes.mmp
mtptransports/mtpusbtransport/usbdatatypes/inc/cmtpusbcontainer.h
mtptransports/mtpusbtransport/usbdatatypes/inc/mtpusbdatatypeconstants.h
mtptransports/mtpusbtransport/usbdatatypes/inc/tmtpusbcontrolrequestcanceldata.h
mtptransports/mtpusbtransport/usbdatatypes/inc/tmtpusbcontrolrequestdevicestatus.h
mtptransports/mtpusbtransport/usbdatatypes/inc/tmtpusbcontrolrequestmodfunction.h
mtptransports/mtpusbtransport/usbdatatypes/inc/tmtpusbcontrolrequestmodheader.h
mtptransports/mtpusbtransport/usbdatatypes/inc/tmtpusbcontrolrequestsetup.h
mtptransports/mtpusbtransport/usbdatatypes/inc/tmtpusbparameterpayloadblock.h
mtptransports/mtpusbtransport/usbdatatypes/src/cmtpusbcontainer.cpp
mtptransports/mtpusbtransport/usbdatatypes/src/tmtpusbcontrolrequestcanceldata.cpp
mtptransports/mtpusbtransport/usbdatatypes/src/tmtpusbcontrolrequestdevicestatus.cpp
mtptransports/mtpusbtransport/usbdatatypes/src/tmtpusbcontrolrequestmodfunction.cpp
mtptransports/mtpusbtransport/usbdatatypes/src/tmtpusbcontrolrequestmodheader.cpp
mtptransports/mtpusbtransport/usbdatatypes/src/tmtpusbcontrolrequestsetup.cpp
mtptransports/mtpusbtransport/usbdatatypes/src/tmtpusbparameterpayloadblock.cpp
mtptransports/mtpusbtransport/usbsic_cc/group/bld.inf
mtptransports/mtpusbtransport/usbsic_cc/group/mtpusbsiccc.mmp
mtptransports/mtpusbtransport/usbsic_cc/inc/cmtpusbsicclasscontroller.h
mtptransports/mtpusbtransport/usbsic_cc/src/cmtpusbsicclasscontroller.cpp
mtptransports/mtpusbtransport/usbsic_cc/src/cmtpusbsicclassimpcollection.cpp
mtptransports/mtpusbtransport/usbsic_cc/src/mtpusbsiccc.rss
mtptransports/mtpusbtransport/usbsic_imp/group/bld.inf
mtptransports/mtpusbtransport/usbsic_imp/group/mtpusbsicimp.mmp
mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbconnection.h
mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepbase.h
mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepbulkin.h
mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepbulkout.h
mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepcontrol.h
mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepinterruptin.h
mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepwatcher.h
mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbtransport.h
mtptransports/mtpusbtransport/usbsic_imp/inc/mtpusbtransportconstants.h
mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbconnection.cpp
mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbase.cpp
mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbulkin.cpp
mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbulkout.cpp
mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepcontrol.cpp
mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepinterruptin.cpp
mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepwatcher.cpp
mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbtransport.cpp
mtptransports/mtpusbtransport/usbsic_imp/src/mtpusbsicimp.rss
obex/obexextensionapi/group/bld.inf
obex/obexextensionapi/group/obex_extensionapis.history.xml
obex/obexextensionapi/group/obex_extensionapis.mrp
obex/obexextensionapi/group/obexextensionapis.mmp
obex/obexextensionapi/inc/obexextensionapifaults.h
obex/obexextensionapi/public/mobexclienterrorresolver.h
obex/obexextensionapi/public/mobexserverrequestpacketnotify.h
obex/obexextensionapi/public/mobexserverrequestpacketnotifyregister.h
obex/obexextensionapi/public/obexclienterrorresolver.h
obex/obexextensionapi/public/obexserverpacketaccessextension.h
obex/obexextensionapi/src/obexerrorextension.cpp
obex/obexextensionapi/src/obexserverpacketaccessextension.cpp
obex/obexextensionapi/test/headercheck/group/t_obexextensionapisheadercheck.mmp
obex/obexextensionapi/test/headercheck/src/main.cpp
obex/obexextensionapi/test/headercheck/src/t_mobexclienterrorresolver.cpp
obex/obexextensionapi/test/headercheck/src/t_mobexserverrequestpacketnotify.cpp
obex/obexextensionapi/test/headercheck/src/t_mobexserverrequestpacketnotifyregister.cpp
obex/obexextensionapi/test/headercheck/src/t_obexclienterrorresolver.cpp
obex/obexextensionapi/test/headercheck/src/t_obexserverpacketaccessextension.cpp
obex/obexprotocol/bld.inf
obex/obexprotocol/common/logger.h
obex/obexprotocol/group/bld.inf
obex/obexprotocol/group/obex.history.xml
obex/obexprotocol/group/obex.mrp
obex/obexprotocol/group/obexprotocol.iby
obex/obexprotocol/obex/group/BLD.INF
obex/obexprotocol/obex/group/irobex.mmp
obex/obexprotocol/obex/group/obex.mmp
obex/obexprotocol/obex/inc/OBEXUTIL.H
obex/obexprotocol/obex/inc/authentication.h
obex/obexprotocol/obex/inc/obexasyncfilewriter.h
obex/obexprotocol/obex/inc/obexcommon.h
obex/obexprotocol/obex/inc/obexconstantsinternal.h
obex/obexprotocol/obex/inc/obexerrorengine.h
obex/obexprotocol/obex/inc/obexfaults.h
obex/obexprotocol/obex/inc/obexfilewriter.h
obex/obexprotocol/obex/inc/obexheaderutil.h
obex/obexprotocol/obex/inc/obexnotifyhandlerbase.h
obex/obexprotocol/obex/inc/obexnotifyhandlerclient.h
obex/obexprotocol/obex/inc/obexnotifyhandlerserver.h
obex/obexprotocol/obex/inc/obexpacketsignaller.h
obex/obexprotocol/obex/inc/obexpackettimer.h
obex/obexprotocol/obex/inc/obexservernotifysyncwrapper.h
obex/obexprotocol/obex/inc/obexserveroperationstates.h
obex/obexprotocol/obex/inc/obexserverrequestpacketengine.h
obex/obexprotocol/obex/inc/obexserverstatemachine.h
obex/obexprotocol/obex/inc/obexsetpathdata.h
obex/obexprotocol/obex/inc/obexsyncfilewriter.h
obex/obexprotocol/obex/inc/obexunderlyingheader.h
obex/obexprotocol/obex/public/OBEX.H
obex/obexprotocol/obex/public/ObexBtTransportInfo.h
obex/obexprotocol/obex/public/ObexIrTransportInfo.h
obex/obexprotocol/obex/public/ObexTransportInfo.h
obex/obexprotocol/obex/public/ObexUsbTransportInfo.h
obex/obexprotocol/obex/public/obexbase.h
obex/obexprotocol/obex/public/obexbaseobject.h
obex/obexprotocol/obex/public/obexclient.h
obex/obexprotocol/obex/public/obexconstants.h
obex/obexprotocol/obex/public/obexfinalpacketobserver.h
obex/obexprotocol/obex/public/obexheaders.h
obex/obexprotocol/obex/public/obexobjects.h
obex/obexprotocol/obex/public/obexpanics.h
obex/obexprotocol/obex/public/obexreadactivityobserver.h
obex/obexprotocol/obex/public/obexserver.h
obex/obexprotocol/obex/public/obextypes.h
obex/obexprotocol/obex/src/OBEX.CPP
obex/obexprotocol/obex/src/OBEXUTIL.CPP
obex/obexprotocol/obex/src/TObexServerOperationState.cpp
obex/obexprotocol/obex/src/TObexServerStateDisconnected.cpp
obex/obexprotocol/obex/src/TObexServerStateDisconnecting.cpp
obex/obexprotocol/obex/src/TObexServerStateGetOpFinal.cpp
obex/obexprotocol/obex/src/TObexServerStateGetOpReceiveSpecification.cpp
obex/obexprotocol/obex/src/TObexServerStateGetOpSendObject.cpp
obex/obexprotocol/obex/src/TObexServerStateGetOpWaitForUser.cpp
obex/obexprotocol/obex/src/TObexServerStateObexConnecting.cpp
obex/obexprotocol/obex/src/TObexServerStatePutOpFinal.cpp
obex/obexprotocol/obex/src/TObexServerStatePutOpReceiveObject.cpp
obex/obexprotocol/obex/src/TObexServerStatePutOpWaitForUser.cpp
obex/obexprotocol/obex/src/TObexServerStateReady.cpp
obex/obexprotocol/obex/src/TObexServerStateSetPathOp.cpp
obex/obexprotocol/obex/src/TObexServerStateTransportConnected.cpp
obex/obexprotocol/obex/src/TObexServerStateWaitForUserPassword.cpp
obex/obexprotocol/obex/src/authentication.cpp
obex/obexprotocol/obex/src/obexasyncfilewriter.cpp
obex/obexprotocol/obex/src/obexauthchallengehandler.cpp
obex/obexprotocol/obex/src/obexclient.cpp
obex/obexprotocol/obex/src/obexconstants.cpp
obex/obexprotocol/obex/src/obexerrorengine.cpp
obex/obexprotocol/obex/src/obexfilewriter.cpp
obex/obexprotocol/obex/src/obexheader.cpp
obex/obexprotocol/obex/src/obexheaderset.cpp
obex/obexprotocol/obex/src/obexheaderutil.cpp
obex/obexprotocol/obex/src/obexnotifyhandlerbase.cpp
obex/obexprotocol/obex/src/obexnotifyhandlerclient.cpp
obex/obexprotocol/obex/src/obexnotifyhandlerserver.cpp
obex/obexprotocol/obex/src/obexobjectexpandedbaseobject.cpp
obex/obexprotocol/obex/src/obexobjects.cpp
obex/obexprotocol/obex/src/obexpacketsignaller.cpp
obex/obexprotocol/obex/src/obexpackettimer.cpp
obex/obexprotocol/obex/src/obexserver.cpp
obex/obexprotocol/obex/src/obexservernotify.cpp
obex/obexprotocol/obex/src/obexservernotifysyncwrapper.cpp
obex/obexprotocol/obex/src/obexserverrequestpacketengine.cpp
obex/obexprotocol/obex/src/obexserverstatemachine.cpp
obex/obexprotocol/obex/src/obexsetpathdata.cpp
obex/obexprotocol/obex/src/obexsyncfilewriter.cpp
obex/obexprotocol/obex/test/headercheck/group/t_obexheadercheck.mmp
obex/obexprotocol/obex/test/headercheck/src/main.cpp
obex/obexprotocol/obex/test/headercheck/src/t_ObexBtTransportInfo.cpp
obex/obexprotocol/obex/test/headercheck/src/t_ObexIrTransportInfo.cpp
obex/obexprotocol/obex/test/headercheck/src/t_ObexTransportInfo.cpp
obex/obexprotocol/obex/test/headercheck/src/t_ObexUsbTransportInfo.cpp
obex/obexprotocol/obex/test/headercheck/src/t_obex.cpp
obex/obexprotocol/obex/test/headercheck/src/t_obexbase.cpp
obex/obexprotocol/obex/test/headercheck/src/t_obexbaseobject.cpp
obex/obexprotocol/obex/test/headercheck/src/t_obexclient.cpp
obex/obexprotocol/obex/test/headercheck/src/t_obexconstants.cpp
obex/obexprotocol/obex/test/headercheck/src/t_obexfinalpacketobserver.cpp
obex/obexprotocol/obex/test/headercheck/src/t_obexheaders.cpp
obex/obexprotocol/obex/test/headercheck/src/t_obexobjects.cpp
obex/obexprotocol/obex/test/headercheck/src/t_obexserver.cpp
obex/obexprotocol/obex/test/headercheck/src/t_obextypes.cpp
obex/obexprotocol/obex/test/testobexerrorcodes/TestObexErrorCodes.cpp
obex/obexprotocol/obex/test/testobexerrorcodes/TestObexErrorCodes.h
obex/obexprotocol/obex/test/testobexerrorcodes/TestObexErrorCodes.mmp
obex/obexprotocol/obex/test/testobexerrorcodes/TestObexErrorCodesClient.cpp
obex/obexprotocol/obex/test/testobexerrorcodes/TestObexErrorCodesServer.cpp
obex/obexprotocol/obex/test/tobex/Contactsbak.vcf
obex/obexprotocol/obex/test/tobex/Contactsbak2.vcf
obex/obexprotocol/obex/test/tobex/Contactsbak3.vcf
obex/obexprotocol/obex/test/tobex/TOBEX.CPP
obex/obexprotocol/obex/test/tobex/TOBEX.MMP
obex/obexprotocol/obex/test/tobex/TOBEXCON.CPP
obex/obexprotocol/obex/test/tobex/TOBEXCON.H
obex/obexprotocol/obex/test/tobex/TREFHANDLER.CPP
obex/obexprotocol/obex/test/tobex/btutils.cpp
obex/obexprotocol/obex/test/tobex/btutils.h
obex/obexprotocol/obex/test/tobex/clienthandler.cpp
obex/obexprotocol/obex/test/tobex/clienthandler.h
obex/obexprotocol/obex/test/tobex/constants.h
obex/obexprotocol/obex/test/tobex/emptyheaderstest.cpp
obex/obexprotocol/obex/test/tobex/emptyheaderstest.h
obex/obexprotocol/obex/test/tobex/readme.txt
obex/obexprotocol/obex/test/tobex/serverasyncao.cpp
obex/obexprotocol/obex/test/tobex/serverasyncao.h
obex/obexprotocol/obex/test/tobex/serverhandler.cpp
obex/obexprotocol/obex/test/tobex/serverhandler.h
obex/obexprotocol/obex/test/tobex/serverhandlerbase.cpp
obex/obexprotocol/obex/test/tobex/serverhandlerbase.h
obex/obexprotocol/obex/test/tobex/serverhandlerfile.cpp
obex/obexprotocol/obex/test/tobex/serverhandlerfile.h
obex/obexprotocol/obex/test/tobex/serverpacketaccessui.cpp
obex/obexprotocol/obex/test/tobex/serverpacketaccessui.h
obex/obexprotocol/obexbttransport/group/BLD.INF
obex/obexprotocol/obexbttransport/group/ObexBtRfcommTransportController.mmp
obex/obexprotocol/obexbttransport/inc/ObexActiveRfcommConnector.h
obex/obexprotocol/obexbttransport/inc/ObexBtRfcommTransportController.h
obex/obexprotocol/obexbttransport/inc/ObexListenerRfcommConnector.h
obex/obexprotocol/obexbttransport/inc/ObexRfcommConnector.h
obex/obexprotocol/obexbttransport/inc/connectobserver.h
obex/obexprotocol/obexbttransport/inc/obexbtfaults.h
obex/obexprotocol/obexbttransport/src/1020E043.rss
obex/obexprotocol/obexbttransport/src/ObexActiveRfcommConnector.cpp
obex/obexprotocol/obexbttransport/src/ObexBtRfcommImpCollection.cpp
obex/obexprotocol/obexbttransport/src/ObexBtRfcommTransportController.cpp
obex/obexprotocol/obexbttransport/src/ObexListenerRfcommConnector.cpp
obex/obexprotocol/obexbttransport/src/ObexRfcommConnector.cpp
obex/obexprotocol/obextransport/group/BLD.INF
obex/obexprotocol/obextransport/group/obexcommontransport.MMP
obex/obexprotocol/obextransport/inc/ObexTransportUtil.h
obex/obexprotocol/obextransport/inc/obexconnectdata.h
obex/obexprotocol/obextransport/inc/obextransportfaults.h
obex/obexprotocol/obextransport/public/ObexReaderBase.h
obex/obexprotocol/obextransport/public/ObexWriterBase.h
obex/obexprotocol/obextransport/public/mobexnotify.h
obex/obexprotocol/obextransport/public/mobexnotifyextend.h
obex/obexprotocol/obextransport/public/mobextransportnotify.h
obex/obexprotocol/obextransport/public/obexactivereader.h
obex/obexprotocol/obextransport/public/obexactiverw.h
obex/obexprotocol/obextransport/public/obexactivewriter.h
obex/obexprotocol/obextransport/public/obexconnector.h
obex/obexprotocol/obextransport/public/obexdata.h
obex/obexprotocol/obextransport/public/obexinternalconstants.h
obex/obexprotocol/obextransport/public/obexinternalheader.h
obex/obexprotocol/obextransport/public/obexpacket.h
obex/obexprotocol/obextransport/public/obextransport.hrh
obex/obexprotocol/obextransport/public/obextransportconstants.h
obex/obexprotocol/obextransport/public/obextransportcontrollerbase.h
obex/obexprotocol/obextransport/src/ObexReaderBase.cpp
obex/obexprotocol/obextransport/src/ObexTransportUtil.cpp
obex/obexprotocol/obextransport/src/ObexWriterBase.cpp
obex/obexprotocol/obextransport/src/logengine.cpp
obex/obexprotocol/obextransport/src/mobextransportnotify.cpp
obex/obexprotocol/obextransport/src/obexactivereader.cpp
obex/obexprotocol/obextransport/src/obexactiverw.cpp
obex/obexprotocol/obextransport/src/obexactivewriter.cpp
obex/obexprotocol/obextransport/src/obexconnectdata.cpp
obex/obexprotocol/obextransport/src/obexconnector.cpp
obex/obexprotocol/obextransport/src/obexdata.cpp
obex/obexprotocol/obextransport/src/obexinternalheader.cpp
obex/obexprotocol/obextransport/src/obexpacket.cpp
obex/obexprotocol/obextransport/src/obextransportcontrollerbase.cpp
obex/obexprotocol/obextransport/test/headercheck/group/t_obextransportheadercheck.mmp
obex/obexprotocol/obextransport/test/headercheck/src/main.cpp
obex/obexprotocol/obextransport/test/headercheck/src/t_ObexReaderBase.cpp
obex/obexprotocol/obextransport/test/headercheck/src/t_ObexWriterBase.cpp
obex/obexprotocol/obextransport/test/headercheck/src/t_Obextransport.cpp
obex/obexprotocol/obextransport/test/headercheck/src/t_mobexnotify.cpp
obex/obexprotocol/obextransport/test/headercheck/src/t_mobexnotifyextend.cpp
obex/obexprotocol/obextransport/test/headercheck/src/t_mobextransportnotify.cpp
obex/obexprotocol/obextransport/test/headercheck/src/t_obexactivereader.cpp
obex/obexprotocol/obextransport/test/headercheck/src/t_obexactiverw.cpp
obex/obexprotocol/obextransport/test/headercheck/src/t_obexactivewriter.cpp
obex/obexprotocol/obextransport/test/headercheck/src/t_obexconnector.cpp
obex/obexprotocol/obextransport/test/headercheck/src/t_obexdata.cpp
obex/obexprotocol/obextransport/test/headercheck/src/t_obexinternalconstants.cpp
obex/obexprotocol/obextransport/test/headercheck/src/t_obexinternalheader.cpp
obex/obexprotocol/obextransport/test/headercheck/src/t_obexpacket.cpp
obex/obexprotocol/obextransport/test/headercheck/src/t_obextransportconstants.cpp
obex/obexprotocol/obextransport/test/headercheck/src/t_obextransportcontrollerbase.cpp
obex/obexprotocol/obexusbtransport/group/BLD.INF
obex/obexprotocol/obexusbtransport/group/ObexUsbTransportController.mmp
obex/obexprotocol/obexusbtransport/inc/ObexUsbTransportController.h
obex/obexprotocol/obexusbtransport/inc/obexusbfaults.h
obex/obexprotocol/obexusbtransport/inc/usbconn.h
obex/obexprotocol/obexusbtransport/src/1020DE87.rss
obex/obexprotocol/obexusbtransport/src/ObexUsbImpCollection.cpp
obex/obexprotocol/obexusbtransport/src/ObexUsbTransportController.cpp
obex/obexprotocol/obexusbtransport/src/usbconn.cpp
package_definition.xml
remoteconn_plat/group/bld.inf
sysdef_1_4_0.dtd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/group/Doxyfile	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,233 @@
+# Symbian SymDox Configuratrion file version 1.0 [15.02.2003]
+# Doxyfile for Doxygen version 1.3-rc2 
+#---------------------------------------------------------------------------
+# General configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME           = Symbian Connect Secure Backup Engine
+PROJECT_NUMBER         = 
+OUTPUT_DIRECTORY       = C:/public_html/zephyr-connect/SecureBackupEngine/
+OUTPUT_LANGUAGE        = English
+EXTRACT_ALL            = YES
+EXTRACT_PRIVATE        = YES
+EXTRACT_STATIC         = YES
+EXTRACT_LOCAL_CLASSES  = YES
+HIDE_UNDOC_MEMBERS     = NO
+HIDE_UNDOC_CLASSES     = NO
+HIDE_FRIEND_COMPOUNDS  = NO
+HIDE_IN_BODY_DOCS      = NO
+BRIEF_MEMBER_DESC      = YES
+REPEAT_BRIEF           = YES
+ALWAYS_DETAILED_SEC    = NO
+INLINE_INHERITED_MEMB  = NO
+FULL_PATH_NAMES        = NO
+STRIP_FROM_PATH        =
+INTERNAL_DOCS          = YES
+CASE_SENSE_NAMES       = YES
+SHORT_NAMES            = NO
+HIDE_SCOPE_NAMES       = NO
+VERBATIM_HEADERS       = YES
+SHOW_INCLUDE_FILES     = YES
+JAVADOC_AUTOBRIEF      = NO
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP         = YES
+INHERIT_DOCS           = YES
+INLINE_INFO            = YES
+SORT_MEMBER_DOCS       = NO
+DISTRIBUTE_GROUP_DOC   = YES
+TAB_SIZE               = 8
+GENERATE_TODOLIST      = YES
+GENERATE_TESTLIST      = YES
+GENERATE_BUGLIST       = YES
+GENERATE_DEPRECATEDLIST= YES
+
+ALIASES	      = panic=@exception \
+	     	leave=@exception \             
+		"capability=@par Capabilities" \
+		"internalTechnology=@par Internal technology" \
+		"internalComponent=@par Internal component"\
+		"internalAll=@par Internal all" \
+		"publishedPartner=@par Published-partner" \
+		"publishedAll=@par Published-all" \
+		"prototype=@par Prototype" \
+		"interim=@par Interim" \
+		"released=@par Released" \
+		"removed=@par Removed" \
+		"test=@par Test" \
+		"realtime=@par Realtime"
+
+ENABLED_SECTIONS       =
+MAX_INITIALIZER_LINES  = 30
+OPTIMIZE_OUTPUT_FOR_C  = NO
+OPTIMIZE_OUTPUT_JAVA   = NO
+SHOW_USED_FILES        = YES
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET                  = YES
+WARNINGS               = YES
+WARN_IF_UNDOCUMENTED   = YES
+WARN_IF_DOC_ERROR      = YES
+WARN_FORMAT            = "<br> <b>File:</b> $file<br><b>Line:</b> $line, $text <br>"
+WARN_LOGFILE           = C:/public_html/zephyr-connect/SecureBackupEngine/doxygen_warning_log.html
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT                  = ../inc ../src
+FILE_PATTERNS          = *.cpp \
+                         *.h \
+                         *.inl \
+                         *.mmp \
+                         *.rss \
+                         *.hrh \
+                         *.pam \
+                         *.dox
+RECURSIVE              = YES
+EXCLUDE                =
+EXCLUDE_SYMLINKS       = NO
+EXCLUDE_PATTERNS       = test/*
+EXAMPLE_PATH           = 
+EXAMPLE_PATTERNS       =
+EXAMPLE_RECURSIVE      = NO
+IMAGE_PATH             = 
+INPUT_FILTER           =
+FILTER_SOURCE_FILES    = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER         = NO
+INLINE_SOURCES         = NO
+STRIP_CODE_COMMENTS    = YES
+REFERENCED_BY_RELATION = YES
+REFERENCES_RELATION    = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX     = YES
+COLS_IN_ALPHA_INDEX    = 5
+IGNORE_PREFIX          = C \
+                         T \
+                         R \
+                         M
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML          = YES
+HTML_OUTPUT            = html
+HTML_FILE_EXTENSION    = .html
+HTML_HEADER            = /development/zephyr-connect/latest/documentation/doxygen_templates/connect_header.html
+HTML_FOOTER            = /development/zephyr-connect/latest/documentation/doxygen_templates/connect_footer.html
+HTML_STYLESHEET        =
+HTML_ALIGN_MEMBERS     = YES
+GENERATE_HTMLHELP      = YES
+CHM_FILE               =
+HHC_LOCATION           =
+GENERATE_CHI           = NO
+BINARY_TOC             = NO
+TOC_EXPAND             = NO
+DISABLE_INDEX          = NO
+ENUM_VALUES_PER_LINE   = 4
+GENERATE_TREEVIEW      = NO
+TREEVIEW_WIDTH         = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX         = NO
+LATEX_OUTPUT           = latex
+LATEX_CMD_NAME         = latex
+MAKEINDEX_CMD_NAME     = makeindex
+COMPACT_LATEX          = NO
+PAPER_TYPE             = a4wide
+EXTRA_PACKAGES         =
+LATEX_HEADER           =
+PDF_HYPERLINKS         = NO
+USE_PDFLATEX           = NO
+LATEX_BATCHMODE        = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF           = NO
+RTF_OUTPUT             = rtf
+COMPACT_RTF            = NO
+RTF_HYPERLINKS         = NO
+RTF_STYLESHEET_FILE    =
+RTF_EXTENSIONS_FILE    =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN           = NO
+MAN_OUTPUT             = man
+MAN_EXTENSION          = .3
+MAN_LINKS              = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML           = NO
+XML_SCHEMA             =
+XML_DTD                =
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF   = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD       = NO
+PERLMOD_LATEX          = NO
+PERLMOD_PRETTY         = YES
+PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING   = YES
+MACRO_EXPANSION        = NO
+EXPAND_ONLY_PREDEF     = NO
+SEARCH_INCLUDES        = YES
+INCLUDE_PATH           =
+INCLUDE_FILE_PATTERNS  =
+PREDEFINED             = NDEBUG \
+                         _UNICODE \
+                         __SYMBIAN32__ \
+                         __GCC32__ \
+                         __EPOC32__ \
+                         __MARM__ \
+                         __MARM_ARMI__ \
+                         __DLL__
+EXPAND_AS_DEFINED      =
+SKIP_FUNCTION_MACROS   = YES
+#---------------------------------------------------------------------------
+# Configuration::addtions related to external references
+#---------------------------------------------------------------------------
+TAGFILES               =
+GENERATE_TAGFILE       =
+ALLEXTERNALS           = NO
+EXTERNAL_GROUPS        = YES
+PERL_PATH              = 
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS         = YES
+HIDE_UNDOC_RELATIONS   = YES
+HAVE_DOT               = YES
+CLASS_GRAPH            = YES
+COLLABORATION_GRAPH    = YES
+TEMPLATE_RELATIONS     = YES
+INCLUDE_GRAPH          = YES
+INCLUDED_BY_GRAPH      = YES
+GRAPHICAL_HIERARCHY    = YES
+DOT_IMAGE_FORMAT       = png
+DOT_PATH               = "C:\Program Files\doxygen\graphviz\bin"
+DOTFILE_DIRS           =
+MAX_DOT_GRAPH_WIDTH    = 1024
+MAX_DOT_GRAPH_HEIGHT   = 1024
+GENERATE_LEGEND        = YES
+DOT_CLEANUP            = YES
+#---------------------------------------------------------------------------
+# Configuration::addtions related to the search engine
+#---------------------------------------------------------------------------
+SEARCHENGINE           = NO
+CGI_NAME               = search.cgi
+CGI_URL                =
+DOC_URL                =
+DOC_ABSPATH            = 
+BIN_ABSPATH            = /usr/local/bin/
+EXT_DOC_PATHS          =
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/group/MakeDoc.cmd	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,35 @@
+@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 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
+
+md C:\public_html\zephyr-connect\SecureBackupEngine
+doxygen Doxyfile
+
+set CURRENT_DIR=%CD%
+set CURRENT_DRIVE=%CD:~0,2%
+
+C:
+cd \public_html\zephyr-connect\SecureBackupEngine\html
+
+%CURRENT_DIR%\configureIndex.pl index.hhc > _index.hhc
+del index.hhc
+ren _index.hhc index.hhc
+
+hhc index.hhp
+
+copy index.chm %CURRENT_DIR%\SecureBackupEngine.chm
+%CURRENT_DRIVE%
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+@file
+
+@SYMPurpose Secure Backup Engine
+*/
+
+PRJ_MMPFILES
+sbencrypt.mmp
+sbeclient.mmp
+sbengine.mmp
+
+
+PRJ_TESTMMPFILES
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+./connectivity_securebackupengine.iby  /epoc32/rom/include/connectivity_securebackupengine.iby
+../inc/sbeclient.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(connect/sbeclient.h)
+../inc/sbtypes.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(connect/sbtypes.h)
+../inc/installmimetypes.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(connect/installmimetypes.h)
+../inc/sbexternalisablearray.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(connect/sbexternalisablearray.h)
+../inc/sbexternalisablearray.inl SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(connect/sbexternalisablearray.inl)
+../inc/sbencrypt.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(connect/sbencrypt.h)
+../inc/javamanagerinterface.h		SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(connect/javamanagerinterface.h)	
+../inc/javamanagerinterface.inl		SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(connect/javamanagerinterface.inl)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/group/configureIndex.pl	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,71 @@
+#!/usr/local/bin/perl
+# unused in NT but there for completeness
+
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+# Configures the index.hhc file for generating compiled html help
+# by removing lines that should not be displayed
+
+# Usage: configureIndex index.hhc > index.hhc
+
+if ($#ARGV != 0)
+	{
+	die "Usage: configureIndex index.hhc > index.hhc\n";
+	}
+
+$file=shift(@ARGV);
+open (FILE, $file) or die "Can't open $file: $!\n";
+my $printLine = 1;
+my $inRelatedPages = 0;
+my $compoundMembersLine = "\n";
+while (<FILE>)
+{
+    if (/^<LI>.*/)
+    {
+	if (/.*Compound List.*/ || /.*Namespace List.*/ || 
+	    /.*Namespace Members.*/ || /.*File Members.*/)
+	{
+	    $printLine = 0;
+	}
+	elsif ( /.*Compound Members.*/)
+	{
+	    $compoundMembersLine = $_;
+	    ##print $compoundMembersLine;
+	}
+	else
+	{
+	    if (/.*Related Pages.*/)
+	    {
+		$inRelatedPages = 1;
+	    }
+	    $printLine = 1;
+	    print $_;
+	}
+    }
+    elsif ( /^\s*<\/UL>$/ && $inRelatedPages == 1)
+    {
+	$inRelatedPages = 0;
+	print "  ";
+	print $compoundMembersLine;
+	print $_;
+    }
+    else
+    {
+	if ($printLine == 1)
+	{
+	    print $_;
+	}
+    }
+}
+close FILE;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/group/connectivity_backupengine.mrp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,33 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	connectivity_backupengine
+source \sf\mw\remoteconn\backupandrestore\backupengine\bmarm
+source \sf\mw\remoteconn\backupandrestore\backupengine\bwins
+source \sf\mw\remoteconn\backupandrestore\backupengine\eabi
+source \sf\mw\remoteconn\backupandrestore\backupengine\group
+source \sf\mw\remoteconn\backupandrestore\backupengine\inc
+source \sf\mw\remoteconn\backupandrestore\backupengine\src
+
+binary	\sf\mw\remoteconn\backupandrestore\backupengine\group all
+exports	\sf\mw\remoteconn\backupandrestore\backupengine\group
+
+
+notes_source	\component_defs\release.src
+
+
+ipr E 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/group/connectivity_securebackupengine.history.xml	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<relnotes name="Backup Engine">
+  <purpose>
+    This component manages backup and restore operations. It manages the backup and restore of private data and installed software on behalf of other data owners. This component exposes an API and can be used by other components to carry out a remote backup / restore (for example to a connected PC) or a local backup / restore (for example to a removable memory card).
+  </purpose>
+  
+  <defect number="PDEF121045 " title="Updating API clasification from prototype to released in ThirdPartyJavaManager" revision="008">
+		  Modified the clasification tag form @prototype to @released in mentioned file.
+  </defect>
+
+  <defect number="PDEF117905 " title="SBE assumes only one mass-memory drive" revision="007">
+		  Now SB Engine handles the Exclamation (!) mark in public data paths mentioned in backup_registration.xml.
+		  If backup_registration.xml file contains an Exclamation (!) mark in place of the drive in the public data paths then the public data is searched in all available drives.
+  </defect>
+
+  <defect number="INC117583" title="MCCE_32.50_FAT: Connectivity_PC Suite does not restore the Message item succes" revision="006">
+		  Now SBE handles backup and restoration of messaging properly. Now SBE cleans the all data folders of messaging before restoring.
+  </defect>
+
+  <defect number="PDEF117154" title="Backup of sql databases" revision="005">
+		  Fix allows SBE to handle the backup and restore of SQL databases kept in SysLib data cage with the size of more than 64 KB.
+  </defect>
+
+  <defect number="DEF116358" title="Update comments and IM Tagging in sbebufferhandler.h of SBEJavaUtils" revision="004">
+		  Updated the IM tagging of of sbebufferhandler.h to @publishedPartner. Also aligned or modified the comments in few files including thirdpartyjavamanager.mmp.
+  </defect>
+  
+  <defect number="DEF116254" title="sbejavautils.dll - reporting build error for ARMV5" revision="003">
+		SBEJavaUtils using static variable in on of its function. Now,allowed WSD by putting EPOCALLOWDLLDATA in sbejavautils.mmp.
+  </defect>
+
+  <defect number="DEF091392" title="We don't restore an empty directory previously backed-up" revision="002">
+          Save empty directory paths also in the list of files to be backed up, if its not in 
+          the exclude list specified by the corresponding backup_registration file. Treat them
+          as file entries having no attributes and zero size. These entries will be supplied to
+          SCOM as part of Transfer Units in the same way as files and get stored in the Archive.
+          While restoring the entries are scanned by the Secure Backup Engine. If its a 
+          directory (path ending with "\"), then only the directory path is created and no file data is expected.
+  </defect>
+  
+  <defect number="PDEF109726" title="MMC application fails to backup data from a package backup registration file" revision="001">
+          Modify line 1205 of sbpackagedatatransfer.cpp to make the comparison case insensitive.
+  </defect>
+
+</relnotes>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/group/connectivity_securebackupengine.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#ifndef __CONNECTIVITY_SBENGINE_IBY__
+#define __CONNECTIVITY_SBENGINE_IBY__
+
+// SECUREBACKUPENGINE
+file=ABI_DIR\BUILD_DIR\sbeclient.dll			System\libs\sbeclient.dll
+file=ABI_DIR\BUILD_DIR\abclient.dll			System\libs\abclient.dll
+
+#ifndef SBEHEAPMAX
+#define SBEHEAPMAX  0x400000
+#endif
+
+file=ABI_DIR\BUILD_DIR\sbengine.exe			System\programs\sbengine.exe heapmax=SBEHEAPMAX
+
+file=ABI_DIR\BUILD_DIR\sbencrypt.dll			System\programs\sbencrypt.dll
+
+#endif  // __CONNECTIVITY_SBENGINE_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/group/sbeclient.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,44 @@
+// 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
+
+@SYMPurpose sbeclient.dll Secure Backup Engine Client
+*/
+
+TARGET sbeclient.dll
+TARGETTYPE DLL
+UID 0x1000008d 0x10202D2C	// Assgined UID
+VENDORID 0x70000001
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+USERINCLUDE ../../../../../os/ossrv/genericservices/activebackupclient/inc
+SOURCEPATH ../../../../../os/ossrv/genericservices/activebackupclient/src
+SOURCE panic.cpp
+
+
+USERINCLUDE . ../inc
+SOURCEPATH ../src
+SOURCE sbheapwrapper.cpp
+SOURCE sbeclient.cpp
+SOURCE sbeclientsession.cpp
+SOURCE sbtypes.cpp
+
+LIBRARY euser.lib estor.lib apgrfx.lib apmime.lib 
+
+CAPABILITY ALL -Tcb
+
+SMPSAFE
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/group/sbencrypt.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+/**
+@file
+
+@SYMPurpose sbencrypt.dll Secure Backup Key Provider
+*/
+TARGET sbencrypt.dll
+TARGETTYPE DLL
+UID  0x1000008d 0x10207FAF
+VENDORID 0x70000001
+
+USERINCLUDE .
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+USERINCLUDE ../../../../../os/ossrv/genericservices/activebackupclient/inc
+SOURCEPATH ../../../../../os/ossrv/genericservices/activebackupclient/src
+SOURCE panic.cpp
+
+
+USERINCLUDE . ../inc
+SOURCEPATH ../src
+SOURCE	sbencrypt.cpp
+SOURCE	sbencryptimpl.cpp
+
+LIBRARY euser.lib
+
+CAPABILITY ProtServ AllFiles WriteDeviceData ReadUserData TrustedUi
+
+SMPSAFE
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/group/sbengine.mmh	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,59 @@
+// 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:
+// SBE MMP Configuration Header File
+// 
+//
+
+/**
+ @file
+*/
+
+#ifndef __SBENGINE_MMH__
+#define __SBENGINE_MMH__
+
+
+/** By default, the SBE logs only in DEBUG builds. If you want
+ both release and debug logging, then comment this line out */
+#define __SBE_DISABLE_RELEASE_LOGGING
+
+
+#if defined(__SBE_DISABLE_RELEASE_LOGGING)
+    
+    MACRO SBE_LOGGING_DEBUG_ONLY
+
+#else
+
+    MACRO SBE_LOGGING_DEBUG_AND_RELEASE
+
+#endif
+
+
+/** The following macros are used (when logging is enabled) to
+ configure the type of logging to perform */
+
+
+/** Uncomment this line to enable FLOGGER (File) logging */
+MACRO SBE_LOGGING_METHOD_FLOGGER
+
+/** Uncomment this line to enable RDEBUG logging */
+//MACRO SBE_LOGGING_METHOD_RDEBUG
+
+/** Uncomment this line to enable UI (User::InfoPrint) logging. This
+ can cause UI deadlock in some UI systems. */
+//MACRO SBE_LOGGING_METHOD_UI
+
+
+
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/group/sbengine.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+/**
+@file
+
+@SYMPurpose sbengine.exe Secure Backup Engine
+*/
+
+#include "sbengine.mmh"
+
+
+TARGET sbengine.exe
+TARGETTYPE EXE
+
+EPOCSTACKSIZE 24576
+
+UID  0 0x10202D56	// Assigned UID
+VENDORID 0x70000001
+
+USERINCLUDE ../../../../../os/ossrv/genericservices/activebackupclient/inc
+SOURCEPATH ../../../../../os/ossrv/genericservices/activebackupclient/src
+SOURCE panic.cpp
+
+SOURCEPATH ../src
+SOURCE	sbtypes.cpp
+SOURCE	sbheapwrapper.cpp
+SOURCE	sbedataowner.cpp
+SOURCE	sbedataownermanager.cpp
+SOURCE  sbebufferhandler.cpp
+SOURCE  sbmain.cpp
+SOURCE  sblog.cpp
+SOURCE  abserver.cpp
+SOURCE  absession.cpp
+SOURCE	absessionmap.cpp
+SOURCE  sbeserver.cpp
+SOURCE  sbesession.cpp
+SOURCE  sbshutdown.cpp
+SOURCE	sbpackagedatatransfer.cpp
+SOURCE  sbecompressionandencryption.cpp
+SOURCE  sbeconfig.cpp
+SOURCE	sbeparserproxy.cpp
+
+USERINCLUDE . ../inc
+
+USERINCLUDE .
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+LIBRARY euser.lib efsrv.lib ecom.lib bafl.lib estor.lib
+LIBRARY sisregistryclient.lib backuprestore.lib
+LIBRARY xmlframework.lib charconv.lib edbms.lib
+LIBRARY apgrfx.lib apmime.lib
+LIBRARY ezlib.lib sbencrypt.lib cryptography.lib
+
+#ifdef __SBE_DISABLE_RELEASE_LOGGING
+
+    // Flogger will not be linked do this binary in UREL builds
+    DEBUGLIBRARY flogger.lib
+
+#else
+
+    // Flogger always statically linked to this binary.
+    LIBRARY flogger.lib
+
+#endif
+
+CAPABILITY ProtServ AllFiles WriteDeviceData ReadUserData
+
+START WINS      
+// ?wins_specific_information
+END
+
+START MARM
+// ?marm_specific_information
+END
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/group/sbenginenojava.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,86 @@
+// 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
+
+@SYMPurpose sbengine.exe Secure Backup Engine
+*/
+
+#include "sbengine.mmh"
+
+TARGET sbenginenojava.exe
+TARGETTYPE EXE
+
+EPOCSTACKSIZE 24576
+
+UID  0 0x10202D56	// Assigned UID
+VENDORID 0x70000001
+
+MACRO SBENGINE_EXCLUDE_JAVA
+
+USERINCLUDE ../../../../../os/ossrv/genericservices/activebackupclient/inc
+SOURCEPATH ../../../../../os/ossrv/genericservices/activebackupclient/src
+SOURCE panic.cpp
+
+SOURCEPATH ../src
+SOURCE	sbtypes.cpp
+SOURCE	sbheapwrapper.cpp
+SOURCE	sbedataowner.cpp
+SOURCE	sbedataownermanager.cpp
+SOURCE  sbebufferhandler.cpp
+SOURCE  sbmain.cpp
+SOURCE  sblog.cpp
+SOURCE  abserver.cpp
+SOURCE  absession.cpp
+SOURCE	absessionmap.cpp
+SOURCE  sbeserver.cpp
+SOURCE  sbesession.cpp
+SOURCE  sbshutdown.cpp
+SOURCE	sbpackagedatatransfer.cpp
+SOURCE  sbecompressionandencryption.cpp
+SOURCE  sbeconfig.cpp
+SOURCE	sbeparserproxy.cpp
+
+USERINCLUDE . ../inc
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+LIBRARY euser.lib efsrv.lib ecom.lib bafl.lib
+LIBRARY sisregistryclient.lib backuprestore.lib
+LIBRARY xmlframework.lib charconv.lib edbms.lib
+LIBRARY apgrfx.lib apmime.lib estor.lib 
+LIBRARY ezlib.lib sbencrypt.lib cryptography.lib
+
+#ifdef __SBE_DISABLE_RELEASE_LOGGING
+
+    // Flogger will not be linked do this binary in UREL builds
+    DEBUGLIBRARY flogger.lib
+
+#else
+
+    // Flogger always statically linked to this binary.
+    LIBRARY flogger.lib
+
+#endif
+
+CAPABILITY ProtServ AllFiles WriteDeviceData ReadUserData
+
+START WINS      
+// ?wins_specific_information
+END
+
+START MARM
+// ?marm_specific_information
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/group/sysdoc.css	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,231 @@
+/*                                                   -*- c -*-
+   System Documentation HTML presentation stylesheet.
+   Copyright 2000 Symbian Ltd.
+ */
+
+
+/* Overall page styles */
+
+body {
+  background-color: white;
+  color: black;
+}
+
+body, .Bodytext, p, td, th, ul, ol, li, dl, dt, dd,  
+.Head1, .Head2, .Head3, h1, h2, h3, h4, h5, h6, .Author, 
+.Abstract, .Contents1, .Contents2 {
+  font-family: arial, lucida, helvetica, verdana, sans-serif;
+  font-size: 10pt;
+}
+
+a:link    { color: #0000cc; }
+a:visited { color: #663399; }
+a:active  { color: #ff9900; }
+a:hover   { color: #ff9900; }
+
+
+/* Areas in the navigation table */
+
+.breadcrumbNav,
+.breadcrumbNav a:link, .breadcrumbNav a:visited {
+  color: #006699;
+}
+.breadcrumbNav a:link, .breadcrumbNav a:visited {
+  text-decoration: underline;
+}
+.breadcrumbNav {
+  margin: 0.0em;
+  padding: 0.0em;
+  text-align: left;
+  font-weight: bold;
+}
+.breadcrumbNav .separator {
+  color: #ff9900;
+}
+
+.DocSetBox {
+  background-image: none;
+  background-color: #006699;  /* Symbian Blue */
+  color:            #aaccee;  /* Lightish blue */
+}
+
+.DocSetBox p {
+  font-family: meta, arial, sans-serif;
+  font-size: 12px;
+  font-weight: bold;
+  margin-left: 0.5em;
+}
+
+.LogoBox 
+
+.DocSetBox p a:link,
+.DocSetBox p a:visited
+{
+  color: white;
+  text-decoration: none;
+}
+
+.ButtonBox {
+  background-color: white;  /* contrast with dark-blue image text */
+  color:            black;  /* for imageless people */
+  /*
+   Background image must be defined separately in each file due to
+   widespread lack of standards compliance in UAs.
+  */
+}
+
+.ButtonBox p,
+.DocSetBox p
+{
+  margin-top:     0em;
+  margin-bottom:  0em;
+  padding-top:    1px;
+  padding-bottom: 1px;
+}
+
+
+.copyrightStatement {
+  font-size: 12px;
+}
+
+
+/* Ordinary items in the main area */
+
+h1, h2, h3, h4, h5, h6 {
+  font-family: arial, lucida, helvetica, verdana, sans-serif;
+  font-weight: normal;
+  font-style: normal;
+  font-weight: bold;
+  color: #333333;
+  padding-left: 0.1em;
+}
+
+
+h1 { font-size: 180%; }
+h2 { font-size: 140%; }
+h3 { font-size: 120%; } 
+h4 { font-size: 100%; padding-left: 0em; }
+h5 { font-size: 100%; padding-left: 0em; }
+h6 { font-size: 100%; padding-left: 0em; }
+
+.Title    { text-align: left;  font-weight: bold;  font-size: 180%; }
+.Author   { text-align: right; font-style: italic;}
+.Abstract  { margin-left: 9%; margin-right: 2%;  font-style: italic; font-size: 12pt; 
+ font-family: arial, lucida, helvetica, verdana,  
+ sans-serif; font-weight: normal;}
+.Contents1 {margin-left: 3%; margin-right: 2%;};
+.Contents2 {margin-left: 9%; margin-right: 2%;};
+.Head1    { margin-left: 0%; }
+.Head2    { margin-left: 3%; }
+.Head3    { margin-left: 6%; }
+.Bodytext { margin-left: 9%; margin-right: 2%; }
+
+code, pre, .CodeBlock, tt, kbd, samp {
+  font-family: courier new, courier, lucida console,
+               lucida typewriter, monospace;
+}
+
+
+/* Blocks of special information */
+
+.Structure, .CodeBlock, .Prototype, .Instructions, .Process, .Concept,
+.Guideline, .DataDescription, .Classification, .Example
+{
+  padding: 0.33em;
+  border: solid white 1px; /* Netscape 4.x workaround. */
+  background-color: #dddddd;
+  display: block;
+  width: 100%;
+  margin-right: 1%;
+}
+
+
+.CodeBlock,
+.Prototype
+{
+  border: solid white 1px;
+  background-color: #dddddd;
+}
+
+
+/* CodeBlocks in blue boxes want to be blue too. */
+
+.Structure       .CodeBlock,
+.Instructions    .CodeBlock,
+.Process         .CodeBlock,
+.Concept         .CodeBlock,
+.Guideline       .CodeBlock,
+.DataDescription .CodeBlock,
+.Classification  .CodeBlock,
+.Example         .CodeBlock
+{
+  background-color: #cccccc;
+  border: solid #dddddd 1px;
+}
+
+
+/* Tables. It would be nice to have the cell and border colours adapt
+to whatever the background colour is rather than just being grey. */
+
+td.Cell {
+  background-color: white;
+  color: black;
+  text-align: left;
+}
+
+th.Cell {
+  background-color: #eeeeee;
+  color: black;
+  text-align: left;
+  font-weight: bold;
+}
+
+.TableWrap, .ValueTableWrap {
+  background-color: #aaaaaa;
+  color: white;
+}
+
+/* Figures */
+
+/* This was messing up IE5's tables...
+.Figure {
+  margin-left: 5%;
+  margin-right: 5%;
+}
+*/
+
+.Figure .Caption, .Figure .Image, .RelatedItems .Image {
+  text-align: center;
+}
+
+.Caption {
+  font-style: italic;
+}
+
+
+/* Other */
+
+.unresolvedLink {
+  color: #ff0000;
+  background-color: #ffddbb;
+}
+
+
+/* Glossary layout */
+
+/*
+.Glossary dd p,
+.Glossary dd ul,
+.Glossary dd ol
+{ margin: 0.5em; }
+*/
+
+/*
+.Glossary dd,
+{
+   margin-top: 1.0em;
+}
+*/
+
+.Glossary dt { margin-top: 1.5em; }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/abserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,109 @@
+/**
+* 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:
+* Declaration of CABServer class.
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+
+#ifndef __ABSERVER_H__
+#define __ABSERVER_H__
+
+#include <e32base.h>
+#include <connect/sbtypes.h>
+
+namespace conn
+	{
+
+	/** @defgroup ABServer Active Backup Server Documentation
+	*/
+
+	/** Constant for defining an unset Secure ID 
+	@internalTechnology
+	*/
+	const TUint32 KNullABSid = 0;
+	
+	class CDataOwnerManager;
+	class CABSessionMap;
+
+	class CABServer :	public CPolicyServer
+
+	/**
+    @internalComponent
+	@ingroup ABServer
+	
+	Active Backup Server to support Active Backup sessions
+	*/
+		{
+		public:
+			~CABServer();
+			static CABServer* NewLC(CDataOwnerManager* aDOM);
+			void AddSession();
+			void DropSession();
+			void RemoveElement(TSecureId aSecureId);
+			CDataOwnerManager& DataOwnerManager() const;
+			void SupplyDataL(TSecureId aSID, TDriveNumber aDriveNumber, TTransferDataType aTransferType, 
+				TDesC8& aBuffer, TBool aLastSection, TBool aSuppressInitDataOwner = EFalse, 
+				TSecureId aProxySID = KNullABSid);
+			void RequestDataL(TSecureId aSID, TDriveNumber aDriveNumber, TTransferDataType aTransferType, 
+				TPtr8& aBuffer, TBool& aLastSection, TBool aSuppressInitDataOwner = EFalse, 
+				TSecureId aProxySID = KNullABSid);
+		    void GetExpectedDataSizeL(TSecureId aSID, TDriveNumber aDriveNumber, TUint& aSize);
+		    void AllSnapshotsSuppliedL(TSecureId aSID);
+		    TDataOwnerStatus SessionReadyStateL(TSecureId aSID);
+		    void RestoreCompleteL(TSecureId aSID, TDriveNumber aDrive);
+		    void InvalidateABSessions();//Invalidate the CABSession for each ab client
+		    
+		private:
+			CABServer(CDataOwnerManager* aDOM);
+			void ConstructL();
+			
+			//
+			// From CServer2
+			virtual CSession2* NewSessionL(const TVersion& aVersion,
+				const RMessage2& aMessage) const;
+			
+			TInt RunError(TInt aError);
+			void PanicClient(TInt aPanic) const;
+
+		private:
+			/** Active client sessions. */
+			TInt iSessionCount;
+			
+			/** Pointer to the Data Owner Manager */
+			CDataOwnerManager* iDOM;
+			
+			/** Pointer to the session map */
+			CABSessionMap* iSessionMap;
+		};
+		
+	inline CDataOwnerManager& CABServer::DataOwnerManager() const
+	/**
+	Return a reference to the data owner manager
+	
+	@return Reference to the data owner manager object
+	*/
+		{
+		return *iDOM;
+		}
+		
+	}
+
+#endif //__ABSERVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/absession.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,154 @@
+/**
+* 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:
+* Declaration of CABSession class.
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+#ifndef __ABSESSION_H__
+#define __ABSESSION_H__
+
+#include <e32std.h>
+#include "abserver.h"
+#include <connect/sbtypes.h>
+#include <connect/abclientserver.h>
+
+namespace conn
+	{
+	class CDataOwner;
+	
+	/** Constant definition for the watchdog timer */
+	const TTimeIntervalMicroSeconds32 KABCallbackWatchdogTimeout(200000000);
+	
+	class CABSession : public CSession2
+	/**
+    @internalComponent
+	@ingroup Server
+
+	A AB client Session.
+	*/
+		{
+		public:
+			virtual void CreateL();
+			static CABSession* NewL(TSecureId aSecureId);
+			
+			// Methods
+			void RestoreCompleteL(TDriveNumber aDriveNumber);
+			void AllSnapshotsSuppliedL();
+		    void GetExpectedDataSizeL(TDriveNumber aDriveNumber, TUint& aSize);
+		    void SupplyDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, TDesC8& aBuffer,
+		                     TBool aLastSection, TBool aSuppressInitDataOwner, TSecureId aProxySID);
+		    void RequestDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, TPtr8& aBuffer,
+		    				  TBool& aLastSection, TBool aSuppressInitDataOwner, TSecureId aProxySID);
+			void TerminateMultiStageOperationL();
+			TUint GetDataChecksumL(TDriveNumber aDrive);
+			static TInt ABSessionStaticWatchdogCaller(TAny* aWatchdoggingObject);
+			TInt WatchdogExpired();
+			TBool ConfirmedReadyForBUR() const;
+			TBool CallbackInterfaceAvailable() const;
+			void RestoreCompleteL();
+			void SetInvalid();
+			TBool Invalidated();
+
+		private:
+			CABSession(TSecureId aSecureId);
+			~CABSession();
+			void ConstructL();
+			inline CABServer& Server() const;
+			CDataOwner& DataOwnerL() const;
+			void ServiceL(const RMessage2& aMessage);
+			void TakeOwnershipOfIPCMessage(const RMessage2& aMessage);
+			void CleanupClientSendState();
+			
+			// Handle IPC messages
+			void HandleIPCBURModeInfoL(const RMessage2& aMessage);
+			void HandleIPCDoesPartialBURAffectMeL(const RMessage2& aMessage);
+			void HandleIPCConfirmReadyForBURL(const RMessage2& aMessage);
+			void HandleIPCPropagateLeaveL(const RMessage2& aMessage);
+			TInt HandleIPCGetDataSyncL(const RMessage2& aMessage);
+			TInt HandleIPCSendDataLengthL(const RMessage2& aMessage);
+			TInt HandleIPCClosingDownCallback();
+			
+			// Callback methods
+		    void MadeCallback();
+		    void ReturnFromCallback();
+		    void CheckCallbackAvailableL();
+			void MakeCallbackAllSnapshotsSuppliedL();
+			void MakeCallbackReceiveSnapshotDataL(TDriveNumber aDrive, TDesC8& aBuffer, TBool aLastSection);
+			TUint MakeCallbackGetExpectedDataSizeL(TDriveNumber aDrive);
+			void MakeCallbackGetSnapshotDataL(TDriveNumber aDrive, TPtr8& aBuffer, TBool& aFinished);
+			void MakeCallbackInitialiseGetBackupDataL(TDriveNumber aDrive);
+			void MakeCallbackGetBackupDataSectionL(TPtr8& aBuffer, TBool& aFinished);
+			void MakeCallbackInitialiseRestoreBaseDataL(TDriveNumber aDrive);
+			void MakeCallbackRestoreBaseDataSectionL(TDesC8& aBuffer, TBool aFinished);
+			void MakeCallbackInitialiseRestoreIncrementDataL(TDriveNumber aDrive);
+			void MakeCallbackRestoreIncrementDataSectionL(TDesC8& aBuffer, TBool aFinished);
+			void MakeCallbackRestoreCompleteL(TDriveNumber aDrive);
+			void MakeCallbackInitialiseGetProxyBackupDataL(TSecureId aSID, TDriveNumber aDrive);
+			void MakeCallbackInitialiseRestoreProxyBaseDataL(TSecureId aSID, TDriveNumber aDrive);
+			void MakeCallbackTerminateMultiStageOperationL();
+			TUint MakeCallbackGetDataChecksumL(TDriveNumber aDrive);
+
+		private:
+			/** Last message received from client.  Stored and used when 
+			the connection status changes. */
+			RMessage2 iMessage;
+			
+			/** The SecureId of the client that should be connecting to this session */
+			TSecureId iClientSID;
+			
+			/** Callback Timer used to determine whether a rogue client is attempting a denial of service */
+			CPeriodic* iCallbackWatchdog;
+
+		    CActiveSchedulerWait* iActiveSchedulerWait; /*!< Inner scheduler for blocking on active callback */
+		    
+		    /** The leave code that must persist so that leaves can be propagated from the abclient */
+		    TInt iABClientLeaveCode;
+		    
+		    /** Identifies the callback that is in progress. Used for validating multiple calls for a callback */
+		    TABCallbackCommands iCallbackInProgress;
+		    
+		    /** This flag records whether or not the client has finished sending data */
+		    TBool iReceiveFromClientFinished;
+		    
+		    /** Assign data to this TPtr so that it may be sent to the client */
+		    TPtrC8 iSendToClientBuffer;
+		    
+		    /** Function pointer to the handler function that */
+		    TCallBack iWatchdogHandler;
+		    
+		    /** Client has not responded - potentially allow some operations */
+		    TBool iMisbehavingClient;
+		    
+		    /** The drive that snapshot data has been supplied for */
+		    TDriveNumber iSuppliedSnapshotDriveNum;
+		    
+		    /** Flag to store whether or not client has called ConfirmReadyForBURL */
+		    TBool iConfirmedReadyForBUR;
+		    
+		    /** Flag to indicate whether this session is valid or not,invalid
+		     * session means this session is for a backup/restore event which is
+		     * already over, but not disconnect from the client
+		     */
+		    TBool iInvalid;
+		};
+
+	}
+#endif //__ABSESSION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/absessionmap.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,106 @@
+/**
+* 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:
+* Declaration of CABSession class.
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+#ifndef __ABSESSIONMAP_H__
+#define __ABSESSIONMAP_H__
+
+#include <e32std.h>
+
+namespace conn
+	{
+	class CABSession;
+	
+	class CABSessionElement : public CBase
+	/**
+	@internalComponent
+	@ingroup Server
+	
+	The elements hold the TSecureId (key) and own the CABSession (value)
+	*/
+		{
+		public:
+			static CABSessionElement* NewL(TSecureId aSecureId);
+			TSecureId Key() const;
+			CABSession& Value() const;
+			~CABSessionElement();
+		private:
+			CABSessionElement(TSecureId aSecureId);
+			void ConstructL();
+			
+		private:
+			TSecureId iKey;
+			CABSession* iValue;
+		};
+		
+	inline TSecureId CABSessionElement::Key() const
+	/**
+	Return the key of this element
+	
+	@return The key
+	*/
+		{
+		return iKey;
+		}
+
+	inline CABSession& CABSessionElement::Value() const
+	/**
+	Return a reference to the session
+	
+	@return Reference to the session object that this element owns
+	*/
+		{
+		return *iValue;
+		}
+	
+
+
+
+
+	class CABSessionMap : public CBase
+	/**
+    @internalComponent
+	@ingroup Server
+
+	An AB client Session map for holding key-value records to map between SID's and their sessions
+	*/
+		{
+		public:
+			static CABSessionMap* NewL();
+			CABSession& CreateL(TSecureId aSecureId);
+			void Delete(TSecureId aSecureId);
+			CABSession& SessionL(TSecureId aSecureId);
+
+			~CABSessionMap();
+			void InvalidateABSessions();
+			
+		private:
+			CABSessionMap();
+
+		private:
+			RPointerArray<CABSessionElement> iMapElements;
+		};
+
+	}
+
+#endif //__ABSESSIONMAP_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/installmimetypes.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,44 @@
+/**
+* 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
+ @publishedPartner
+ @released
+*/
+
+#ifndef __INSTALLMIMETYPES_H__
+#define __INSTALLMIMETYPES_H__
+
+#include <e32cmn.h>
+
+namespace conn
+	{
+	_LIT8(KSisDataType, "x-epoc/x-sisx-app");
+	_LIT8(KJavaDataType1, "application/java-archive");
+	_LIT8(KJavaDataType2, "application/vnd.symbian.install");
+	_LIT8(KJavaDataType3, "text/vnd.sun.j2me.app-descriptor");
+	_LIT8(KJavaDataType4, "application/x-java-archive");
+	
+	_LIT8(KJarXMimeTypeCAF, "x-caf-application/x-java-archive");
+	_LIT8(KJarMimeTypeCAF, "x-caf-application/java-archive");
+	_LIT8(KJadMimeTypeCAF, "x-caf-text/vnd.sun.j2me.app-descriptor");
+	} // conn
+
+#endif // __INSTALLMIMETYPES_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/javamanagerinterface.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,204 @@
+/**
+* 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:
+* Declaration of CJavaManagerInterface
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+#ifndef __JAVAMANAGERINTERFACE_H__
+#define __JAVAMANAGERINTERFACE_H__
+
+// System
+#include <e32base.h>
+#include <ecom/ecom.h>
+#include <apmrec.h>
+
+#include <connect/sbtypes.h>
+
+/*
+@KJavaManagerInterfaceUid, Ther JavaMangerInterface Uid.
+This UID is used by the implementer of the ThirdPartyJavaManager plugin. 
+This plugin is used in Backup and restore engine.
+*/
+const TUid KJavaManagerInterfaceUid = { 0x2000D924 };
+
+namespace conn
+	{
+	
+	class CDataOwnerInfo;
+	class CSBGenericTransferType;
+	class CSBGenericDataType;
+/**
+Clients creating a java backup and restore plugin should derive from and implement this interface.
+@publishedPartner
+@released
+*/	
+	class CJavaManagerInterface : public CBase
+		{	
+		
+		public:
+	
+		/** 
+		  static function to create and return the object.
+		  
+		  @return CJavaManagerInterface* Pointer to newly instantiated object.
+		 */
+			inline static CJavaManagerInterface* NewL( const TUid& aImplementationUid );
+			    
+		/** 
+		  Destructor.
+		  
+		 */ 
+			inline virtual ~CJavaManagerInterface();	    	
+			
+			
+		public:	
+		
+		/**
+		Method requesting information about all of the Java data owners that are represented by this object
+		@param aDataOwners Array of data owner info's to populate
+		*/			
+		   	virtual void GetDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners)=0;
+		/**
+		Return the expected size of data to be returned to the PC client. Used for displaying progress information
+		@param aGenericTransferType The type of data that the expected size is being requested for
+		@param aSize Stores the expected size value to be returned to the PC side client
+		*/	
+		    virtual void GetExpectedDataSizeL(CSBGenericTransferType* aGenericTransferType, TUint& aSize)=0;
+
+		/**
+		Get a list of public files that the java data owners are requesting to be backed up in addition to their 
+		own private data stores
+		@param aDriveNumber The drive that these public files are being requested for
+		@param aFiles An array of filenames that will be populated upon return of this method
+		*/		    
+		    virtual void GetPublicFileListL(CSBGenericDataType* aGenericDataType, TDriveNumber aDriveNumber, RFileArray& aFiles)=0;
+
+		/**
+		Get a list of public files that the java data owners are requesting to be backed up in addition to their 
+		own private data stores
+		@param aDriveNumber The drive that these public files are being requested for
+		@param aFiles An array of filenames that will be populated upon return of this method
+		*/		    
+		    virtual void GetRawPublicFileListL(CSBGenericDataType* aGenericDataType, TDriveNumber aDriveNumber, RRestoreFileFilterArray& aFileFilter)=0;
+
+		/**
+		Supplies data to the particular data owners to process
+		@param 	aGenericTransferType The type of data that's being supplied
+		@param 	aBuffer Buffer containing the data to be supplied
+		@param 	aFinished Flag determining whether or not this buffer is the last in a multipart sequence
+		*/		    
+		    virtual void SupplyDataL(CSBGenericTransferType* aGenericTransferType, TDesC8& aBuffer, TBool aFinished)=0;
+
+		/**
+		Request a type of data from a particular data owner
+		@param 	aGenericTransferType The type of data being requested
+		@param 	aBuffer The buffer to populate with data
+		@param 	aFinished Flag to be set depending on whether another request is required to transfer 
+					all of this data owner's data
+		*/		    
+		    virtual void RequestDataL(CSBGenericTransferType* aGenericTransferType, TPtr8& aBuffer, TBool& aFinished)=0;
+
+		/**
+		Called by the PC client once all registration and binary files have been restored. Used as a signal to 
+		indicate that the next set of transfers will include data
+		*/		    
+			virtual void AllSystemFilesRestored()=0;
+		/**
+		Method to check the data type of the file
+		@param TDesC& aFileName File name of the file to recognize
+		@return TDataRecognitionResult Data Recognized Result
+		*/
+			virtual TDataRecognitionResult RecognizeDataTypeL(const TDesC& aFileName)=0;
+		/**
+		Returns the handle to File Server.
+		*/	
+
+			virtual RFs& GetRFs()=0;
+
+		/** Returns a pointer to a specified interface extension - to allow future extension
+		of this class without breaking binary compatibility
+
+		@param aInterfaceUid Identifier of the interface to be retrieved
+		@param aInterface A reference to a pointer that retrieves the specified interface.
+		*/	
+		virtual void GetExtendedInterface(TUid aInterfaceUid, TAny*& aInterface)=0;
+					
+		protected:
+		/**
+		Scan the SystemAMS data cage (private directory) for all registration files corresponding to installed MIDlet's
+		@param aRegFileArray Array of registration files that will be populated with all reg files in the SystemAMS data cage
+		**/		 
+			virtual void ScanForRegistrationFilesL(RFileArray& aRegFileArray)=0;
+			
+		/**
+		Tries Parsing the Java Data Owner at runtime.
+		@param aFileName aSuiteHash the suite hash of the java data owner 
+		*/			
+			virtual void ParseJavaDataOwnerL(const TDesC& aSuiteHash)=0;
+			
+			
+		protected:
+		
+		/** 
+ 		* Constructor.
+ 		*/
+		    inline CJavaManagerInterface();		
+			
+		private:
+			TUid iDtor_ID_Key; //ECOM Plugin identifier 
+		
+		};		
+
+	/**
+	 * Template classes to call ResetAndDestroy on array classes
+	 * automatically, when ::PopAndDestroy'ing from the cleanup stack.
+	 */
+	template <class T>
+	class CleanupResetAndDestroy
+		{
+	public:
+		inline static void PushL(T& aRef);
+	private:
+		static void ResetAndDestroy(TAny *aPtr);
+		};
+	template <class T>
+	inline void CleanupResetAndDestroyL(T& aRef);
+
+	// Template class CleanupClose
+	template <class T>
+	inline void CleanupResetAndDestroy<T>::PushL(T& aRef)
+		{CleanupStack::PushL(TCleanupItem(&ResetAndDestroy, &aRef));}
+	template <class T>
+	void CleanupResetAndDestroy<T>::ResetAndDestroy(TAny *aPtr)
+		{static_cast<T*>(aPtr)->ResetAndDestroy();}
+	template <class T>
+	inline void CleanupResetAndDestroyPushL(T& aRef)
+		{CleanupResetAndDestroy<T>::PushL(aRef);}
+
+
+	#include <connect/javamanagerinterface.inl>
+	   
+
+	}// namespace conn
+	
+	
+	
+#endif // __JAVAMANAGERINTERFACE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/javamanagerinterface.inl	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* JavaManagerInterface plugin interface.
+* Constructor.
+* 
+*
+*/
+
+
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+inline CJavaManagerInterface::CJavaManagerInterface()
+
+	{		
+	}
+ 
+/** 
+ * Destructor.
+ * 
+ */ 
+inline CJavaManagerInterface::~CJavaManagerInterface()
+	{
+	REComSession::DestroyedImplementation(iDtor_ID_Key);
+	}
+    
+/** 
+ * static function to create and return the object.
+ * 
+ * @return CJavaManagerInterface* Pointer to newly instantiated object.
+ */
+CJavaManagerInterface* CJavaManagerInterface::NewL( const TUid& aImplementationUid )
+	{
+	
+	RImplInfoPtrArray implementationsArray;
+	CleanupResetAndDestroyPushL(implementationsArray);
+
+	
+	REComSession::ListImplementationsL(KJavaManagerInterfaceUid,implementationsArray );
+	
+	TInt isImplementationFound = 0;
+	
+	for ( TInt a=0; a<implementationsArray.Count(); a++ )
+		{
+		if ( aImplementationUid ==( implementationsArray.operator[](a)->ImplementationUid() ) )
+			{
+			isImplementationFound = 1; 
+			break;
+			}
+		}
+	
+	if ( implementationsArray.Count() <= 0 || isImplementationFound == 0 )
+		{
+		CleanupStack::PopAndDestroy(&implementationsArray);
+		return NULL;
+		}	
+	
+	TAny* javaManagerInterface = REComSession::CreateImplementationL( implementationsArray.operator[](0)->ImplementationUid(), 
+								_FOFF(CJavaManagerInterface,iDtor_ID_Key) );   
+								
+	CleanupStack::PopAndDestroy(&implementationsArray);								
+
+	return reinterpret_cast<CJavaManagerInterface*>(javaManagerInterface);    		
+	}
+			
+		
+		
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbebufferhandler.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,291 @@
+/**
+* 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:
+* Declaration of Classes used to handle buffers
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+#ifndef __SBEBUFFERHANDLER_H__
+#define __SBEBUFFERHANDLER_H__
+
+#include <e32base.h>
+#include <f32file.h>
+#include <connect/sbtypes.h>
+#include <badesca.h>
+
+namespace conn
+	{
+	
+	const TInt KDesCArrayGranularity = 8;
+	
+	/**
+	This class defines the interface required to validate backup/restore data
+	
+	@internalTechnology
+	*/
+	class MValidationHandler
+		{
+	public:
+		/**
+		This method will check if the file name is in the 
+		list of the files to be restored/backuped up
+		
+		@param aFileName reference to the filename to check
+		@return ETrue if file to backup/restore is valid
+		*/
+		virtual TBool ValidFileL(const TDesC& aFileName) = 0;
+		};
+	
+	/** Temporary path used for restoring midlets
+	@internalTechnology
+	*/
+	_LIT(KMIDletTempRestorePath, "C:\\system\\temp\\MIDletRestore\\");
+
+
+	/* Reads a fixed size object from a buffer
+	@internalTechnology
+	*/
+	template<class T>
+	TBool ReadFromBufferF(T& aT, TUint8*& appCurrent, const TUint8* apEnd);
+	
+	/* Reads a vairable size object from a buffer
+	@internalTechnology
+	*/
+	TBool ReadFromBufferV(TPtr8& aT, TInt aSize, TUint8*& appCurrent,
+						  const TUint8* apEnd);
+						  
+	/** Simple class to wrap up the fixed elements for a snapshot.
+	@internalTechnology
+	*/
+	class TSnapshot
+		{
+	public:
+		TSnapshot()
+		/** Standard C++ Constructor.
+		*/
+			{
+			}
+		TSnapshot(const TDesC& aFileName, TInt64 aModified) :
+			iFileName(aFileName), iModified(aModified)
+		/** Standard C++ Constructor.
+		@param aFileName name of file
+		@param aModified modification attribute of file
+		*/
+			{
+			}
+	public:
+		TFileName	iFileName; /*<! Filename */
+		TInt64		iModified; /*<! The modified time of the file */
+		};
+		
+	/** Simple class to store snapshot file
+        @internalComponent
+	*/
+	class CSnapshot : public CBase
+		{
+	public:
+		static CSnapshot* NewLC(const TInt64& aModified, const TDesC& aFileName);
+		static CSnapshot* NewLC(const TSnapshot& aSnapshot);
+		
+		static TInt Compare(const CSnapshot& aFirst, const CSnapshot& aSecond);
+		static TBool Match(const CSnapshot& aFirst, const CSnapshot& aSecond);
+
+		
+		~CSnapshot();
+		const TInt64& Modified() const;
+		const TDesC& FileName() const;
+		void Snapshot(TSnapshot& aSnapshot);
+		
+	private:
+		CSnapshot(const TInt64& aModified);
+		void ConstructL(const TDesC& aFileName);
+		
+	private:
+    	TInt64				iModified; /*<! The type of the selection */
+    	HBufC*		       	iFileName; /*<! The actual selection */
+		};
+	
+	/** Simple array of TSnapshot
+	@internalTechnology
+	*/
+	typedef RPointerArray<CSnapshot> RSnapshots;
+
+	/** Simple class to wrap up the fixed elements for a file.
+
+	@internalComponent
+	*/
+	class TFileFixedHeader
+		{
+	public:
+		TFileFixedHeader()
+		/** Standard C++ constructor
+		*/
+			{
+			}
+		
+		
+		TFileFixedHeader(const TUint aFileNameLength, TUint aFileSize, 
+						 TUint aAttributes, TInt64 aModified) :
+			iFileNameLength(aFileNameLength), iFileSize(aFileSize), iAttributes(aAttributes), iModified(aModified)
+		/** Standard C++ constructor
+		*/
+			{
+			}
+	public:
+		TUint	iFileNameLength; /*<! The length of the name of the current file */
+		TUint	iFileSize; /*<! The length of the current file */
+		TUint	iAttributes; /*<! The attributes for the file */
+		TInt64	iModified; /*<! The modifed time for the file */
+		}; 
+
+	/** Class to write one or more files to a memory buffer
+	@internalTechnology
+	*/
+	class CBufferFileWriter : public CBase
+		{
+	public:
+		// Constructors
+		static CBufferFileWriter* NewL(RFs& aFs, CDesCArray* aFileNames);
+		~CBufferFileWriter();
+		
+		// Methods
+		void StartL(TPtr8& aBuffer, TBool& aCompleted);
+		void ContinueL(TPtr8& aBuffer, TBool& aCompleted);
+		void WriteToBufferL(TPtr8& aBuffer, TBool& aCompleted);
+	private:
+		// Constructors
+		CBufferFileWriter(RFs& aFs, CDesCArray* aFileNames);
+		void ConstructL();
+		
+	private:
+		RFs&				iFs; /*<! File server to use */
+		CDesCArray*			iFileNames; /*<! Array of files to write to the buffer */
+		
+		// State
+		RFile				iFileHandle; /*<! File handle of current file writing to buffer */
+		TBool				iFileOpen; /*<! Is the file open */
+		TInt				iCurrentFile; /*<! Current file we are writing -> offset into array */
+		TInt				iOffset; /*<! Offset into file to start writing from */
+		TBool				iHeaderWritten; /*<! Has the header been written */
+		TBool				iFileNameWritten; /*<! Have we written the filename? */
+		}; // CBufferFileWriter
+		
+	/** Class to read one or more files from a memory buffer to disk
+	@internalTechnology
+	*/
+	class CBufferFileReader : public CBase
+		{
+	public:
+		// Constructors
+		static CBufferFileReader* NewL(RFs& aFs, RSnapshots* aSnapshots = NULL, MValidationHandler* aValidationHandler = NULL);
+		~CBufferFileReader();
+		
+		// Methods
+		void StartL(const TDesC8& aBuffer, TBool aLastSection);
+		void ContinueL(const TDesC8& aBuffer, TBool aLastSection);
+		void ReadFromBufferL(const TDesC8& aBuffer, TBool aLastSection);
+		void ReadMIDletsFromBufferL(const TDesC8& aBuffer, TBool aLastSection, 
+			CDesCArray& aUnpackedFileNames);
+		void Reset();
+	private:
+		// Constructors
+		CBufferFileReader(RFs& aFs, RSnapshots* aSnapshots, MValidationHandler* aValidationHandler);
+		void CheckFileInSnapshotL();
+		void RecreateDirL();
+		void RecreateFileL();
+		TBool WriteToFileL(TUint8*& aCurrent, const TUint8* aEnd);
+		void RedirectMIDletRestorePathL(const TDesC& aOriginal, CDesCArray& aRedirected);
+	private:
+		TFileFixedHeader iFixedHeader; 
+	
+		RFs&				iFs; /*<! File server to use */
+		RSnapshots*			iSnapshots; /*<! Snapshot used to detect deleted files */
+		
+		// State
+		TBool				iFixedHeaderRead; /*<! Have we read the fixed header? */
+		TBool				iFileNameRead; /*<! Have we read the filename? */
+		TBool				iSnapshotChecked; /*! Have we checked the snapshot */
+		TBool				iRestore; /*<! Are we skipping the bytes are restoring them? */
+		TInt				iLeftToSkip; /*<! If we are skipping data, how much is left? */
+		TFileName			iFileName; /*<! The file name */
+		RFile				iFileHandle; /*<! The file handle */
+		TBool				iFileOpen; /*<! Is the file open? */
+		MValidationHandler* iValidationHandler; /*<! Handler to Validation Implementation */
+		TUint				iBytesRead; /*<! Number of bytes Read */
+		}; // CBufferFileReader
+		
+		
+	/** Class to write snapshot data to a memory buffer
+	@internalTechnology
+	*/
+	class CBufferSnapshotWriter : public CBase
+		{
+	public:
+		// Constructors
+		static CBufferSnapshotWriter* NewL(RSnapshots* aSnapshot);
+		~CBufferSnapshotWriter();
+		
+		// Methods
+		void StartL(TPtr8& aBuffer, TBool& aCompleted);
+		void ContinueL(TPtr8& aBuffer, TBool& aCompleted);
+	private:
+		// Constructors
+		CBufferSnapshotWriter(RSnapshots* aSnapshot);
+		void ConstructL();
+		
+		void WriteToBufferL(TPtr8& aBuffer, TBool& aCompleted);
+	private:
+		// Files
+		RSnapshots*			iSnapshots; /*<! List of files */
+	
+		// State
+		TInt				iCurrentSnapshot; /*<! Current file writing */
+		}; // CBufferSnapshotWriter
+		
+	/** Class to read snapshot data from a memory buffer
+	@internalTechnology
+	*/
+	class CBufferSnapshotReader : public CBase
+		{
+	public:
+		// Constructors
+		static CBufferSnapshotReader* NewL(RSnapshots& aSnapshots);
+		~CBufferSnapshotReader();
+		
+		// Methods
+		void StartL(const TDesC8& aBuffer, TBool aLastSection);
+		void ContinueL(const TDesC8& aBuffer, TBool aLastSection);
+	private:
+		// Constructor
+		CBufferSnapshotReader(RSnapshots& aSnapshots);
+		
+		void ReadFromBufferL(const TDesC8& aBuffer, TBool aLastSection);
+	private:
+		// Files
+		RSnapshots&			iSnapshots; /*<! Build up list of files here */
+		
+		// State
+		TSnapshot				iSnapshot; /*<! The fixed header */
+		}; // CBufferSnapshotReader
+	
+	} // namespace
+
+
+#endif // __SBEBUFFERHANDLER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbeclient.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,144 @@
+/**
+* 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:
+* Declaration of CSBEClient
+* 
+*
+*/
+
+
+
+/**
+ @file
+ @released
+*/
+
+#ifndef __SBECLIENT_H__
+#define __SBECLIENT_H__
+
+#include <e32base.h>
+#include <e32cmn.h>
+#include <connect/sbtypes.h>
+
+namespace conn
+	{ 
+	class RSBEClientSession;
+
+	class CSBEClient : public CBase
+		/** The client to the Secure Backup Engine.
+		This class is for use by a Secure Backup Server.  It provides backup data and receives
+		restore data.  It encapsulates some state information as backup or restore operations require
+		a range of actions to be undertaken in the correct order.
+
+		It is loaded into the same process as the Secure Backup Server - this is the client interface
+		of the server that is the Secure Backup Engine.
+
+		Methods that transfer large amounts of data are asynchronous (to allow the Secure Backup Engine
+		to carry out asynchronous operations) but synchronous versions are included for the benefit of
+		clients that cannot handle asynchronous methods.  The asynchronous methods should be used if 
+		possible.
+
+		Because of the potential large size of backup data it is not copied into descriptors
+		but is located in a transfer buffer.
+
+		When requesting backup data the asynchronous call is made and the relevant AO (whose
+		TRequestStatus was supplied) will be activated when the data is available and the
+		completion code will indicate success or failure.  If successful, the data can be 
+		accessed by means of the GetTransferDataInfo() method and the SignalTransferDataComplete() 
+		method is used to indicate that the transfer is complete and the transfer buffer can be re-used.
+
+		When supplying snapshot data or restore data the data is copied into a transfer buffer
+		and the asynchronous call is made.  Then the relevant AO will be activated when the data
+		has been absorbed by the Secure Backup Engine.  An error completion code is supplied.
+		The Secure Backup Server must assume that the transfer buffer is in use until the AO
+		is completed.
+
+		During a backup operation, all snapshot data should be provided (or data owners told that
+		they will be doing a base backup) before any data is requested.  This is because providing
+		snapshots allows data owners to calculate their data and their data sizes.  We cannot provide
+		the expected data sizes until we have received all snapshots.
+ 
+		Once all snapshots have been provided, the order in which backup data is requested is not
+		constrained (except that one multi-chunk set of data must be fully retrieved before the next
+		is requested.
+
+		During a restore operation, the Secure Backup Engine expects data in the following order:
+
+		1) Registration files
+
+		2) Hash data for signed system files.
+
+		3) System files for all required data owners.
+
+		4) Data for data owners.
+    
+		Stages (1) through (3) are required in a fixed order.  Once stage (4) has been reached
+		the SBE does not impose an order between data owners and does not require that all data
+		from a specific data owner be restored before the next one be started, i.e. it is possible
+		to send base data to all data owners and then increments (but this is not recommended).
+
+		@released
+		@publishedPartner
+		*/
+		{
+	public:
+		IMPORT_C static CSBEClient* NewL();
+		IMPORT_C ~CSBEClient();
+		IMPORT_C void ListOfDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners);
+		IMPORT_C void PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, RFileArray& aFiles);
+		IMPORT_C void RawPublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType,
+										 RRestoreFileFilterArray& aFileFilter);
+		IMPORT_C void PublicFileListXMLL(TDriveNumber aDrive, TSecureId aSID, HBufC*& aFileList);
+		IMPORT_C void SetBURModeL(const TDriveList& aDriveList, TBURPartType aBURType, 
+								  TBackupIncType aBackupIncType);
+		IMPORT_C void SetSIDListForPartialBURL(RSIDArray& aSIDs);
+		IMPORT_C void SIDStatusL(RSIDStatusArray& aSIDStatus);		
+		IMPORT_C TPtr8& TransferDataAddressL();
+		IMPORT_C TPtrC8& TransferDataInfoL(CSBGenericTransferType*& aGenericTransferType,
+										   TBool& aFinished);
+		IMPORT_C void RequestDataL(CSBGenericTransferType& aGenericTransferType,
+								   TRequestStatus& aStatus);
+		IMPORT_C void RequestDataL(CSBGenericTransferType& aGenericTransferType);
+		IMPORT_C void SupplyDataL(CSBGenericTransferType& aGenericTransferType,
+								  TBool aFinished, TRequestStatus& aStatus);
+		IMPORT_C void SupplyDataL(CSBGenericTransferType& aGenericTransferType,
+								  TBool aFinished);
+		IMPORT_C void AllSnapshotsSuppliedL();								  
+		IMPORT_C TUint ExpectedDataSizeL(CSBGenericTransferType& aGenericTransferType);
+		IMPORT_C void AllSystemFilesRestored();
+		IMPORT_C TUint DataChecksum(TDriveNumber aDrive, TSecureId aSID);
+		
+		IMPORT_C void ListOfDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners, TRequestStatus& aStatus);
+		IMPORT_C void PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, RFileArray& aFiles, TRequestStatus& aStatus);
+		IMPORT_C void SetBURModeL(const TDriveList& aDriveList, TBURPartType aBURType, 
+								  TBackupIncType aBackupIncType, TRequestStatus& aStatus);
+		IMPORT_C void AllSnapshotsSuppliedL(TRequestStatus& aStatus);
+		IMPORT_C void AllSystemFilesRestoredL(TRequestStatus& aStatus);
+
+		IMPORT_C void PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, 
+										RPointerArray<CSBEFileEntry>& aFileList, TBool& aFinished,
+										TInt aTotalListCursor, TInt aMaxResponseSize, TRequestStatus& aStatus);
+
+	private:
+		CSBEClient();
+		void ConstructL();
+
+	private:
+		/** Pointer to the client session R class wrapped by this class */
+		RSBEClientSession* iClientSession;
+		};
+
+	} // end namespace
+
+#endif // __SBECLIENT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbeclientserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,102 @@
+/**
+* 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:
+* Contains defines shared between the Secure Backup Engine client and Server.
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+
+#ifndef __SBECLIENTSERVER_H__
+#define __SBECLIENTSERVER_H__
+
+#include <connect/tserverstart.h>
+
+namespace conn
+	{
+	/** The name of the SBE server execuatable.
+	@ingroup Client
+	@internalComponent
+	*/
+	_LIT(KSBEServerName,"!SBEServer");
+
+	/** Number of times to attempt connection to server.
+	@ingroup Client
+	@internalComponent
+	*/
+	const TInt KSBERetryCount = 4;
+
+	/** Number of async message slots.
+	@ingroup Client
+	@internalComponent
+	*/
+	const TInt KSBEASyncMessageSlots = 3;
+
+
+	/** The SBE major version number.
+	@ingroup Client
+	@internalComponent
+	*/
+	const TUint KSBEMajorVersionNumber = 1;
+
+    /** The SBE minor version number.
+	@ingroup Client
+	@internalComponent
+	*/
+	const TUint KSBEMinorVersionNumber = 0;
+
+    /** The SBE build number
+	@ingroup Client
+	@internalComponent
+	*/
+	const TUint KSBEBuildVersionNumber = 0;
+
+	enum TSBEMessages
+	/** SBE Client/Server Messages
+	@internalComponent
+	*/
+		{
+		ESBEMsgGetGSHHandle,			/*!< Pass the the Global Anonymous Shared Heap handle to client */
+		ESBEMsgPrepDataOwnerInfo,		/*!< Prepare the data owner information for a specific SID */
+		ESBEMsgGetDataOwnerInfo,		/*!< Transfer the data owner information for a specific SID */
+		ESBEMsgPrepPublicFiles,			/*!< Prepare the data owner information for a specific SID */
+		ESBEMsgGetPublicFiles,			/*!< Transfer the data owner information for a specific SID */
+		ESBEMsgPrepPublicFilesRaw,		/*!< Prepare the data owner information for a specific SID */
+		ESBEMsgGetPublicFilesRaw,		/*!< Transfer the data owner information for a specific SID */
+		ESBEMsgPrepPublicFilesXML,		/*!< Prepare the data owner information for a specific SID */
+		ESBEMsgGetPublicFilesXML,		/*!< Transfer the data owner information for a specific SID */
+		ESBEMsgSetBURMode,				/*!< Set the Backup and Restore mode and associatedial BUR */
+		ESBEMsgPrepSIDStatus,			/*!< Get the returned descriptor length from a SIDS params */
+		ESBEMsgSetSIDListPartial,		/*!< Set the list of data owners affected in a parttatus array */
+		ESBEMsgGetSIDStatus,			/*!< Transfer the array of SID's and statuses */
+		ESBEMsgRequestDataSync,			/*!< Request that the SBE transfers some data to the client */
+		ESBEMsgSupplyDataSync,			/*!< Instruct the SBE that data has been supplied ine client */
+		ESBEMsgRequestDataAsync,		/*!< Request that the SBE transfers some data to th the GSH */
+		ESBEMsgSupplyDataAsync,			/*!< Instruct the SBE that data has been supplied in the GSH */
+		ESBEMsgAllSnapshotsSupplied,	/*!< Request that supplied SID's are subject to a Base backup */
+		ESBEMsgGetExpectedDataSize,		/*!< Ask the SBE for the expected size of backup data */
+		ESBEMsgAllSystemFilesRestored,	/*!< Instruct the SBE that all system files have now been restored */
+		ESBEMsgGetDataChecksum,			/*!< For testing - Request the checksum of a SID's backup data */
+		ESBEMsgPrepLargePublicFiles,	/*!< Instruct the SBE to build the public file list and place in GSH */
+		ESBEMsgGetLargePublicFiles		/*!< Retrieve parameters such as the finished flag from SBE */
+		};
+
+	}
+
+#endif //__SBECLIENTSERVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbeclientsession.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,168 @@
+/**
+* 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:
+* Declaration of RSBEClientSession
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+#ifndef __SBECLIENTSESSION_H__
+#define __SBECLIENTSESSION_H__
+
+#include <connect/sbdefs.h>
+#include <e32std.h>
+#include <connect/sbtypes.h>
+#include "sbheapwrapper.h"
+
+namespace conn
+	{
+	class CSBECallbackHandler;
+	/** List of Operations for Active Callback execution 
+	
+	@internalComponent
+	*/
+	enum TState
+		{
+		ENone,
+		EListOfDataOwners,
+		EPublicFileList,
+		ELargePublicFileList
+		};
+	 
+	class TServerStart;
+	class CSBECallbackHandler;
+
+    /** The client to the Secure Backup Engine
+    
+    This class should be accessed only through the CSBEClient class. These two classes make up 
+    a facade pattern to protect against Binary Compatibility breaks. As large chunks of data are 
+    transferred using the global shared heap, this class owns an instantiation of CHeapWrapper 
+    that wraps access to the Global Shared Heap, providing an easier to use common interface.
+
+	@internalComponent
+    */
+	class RSBEClientSession : public RSessionBase
+    {
+	public:
+		static RSBEClientSession* NewL();
+		TInt Connect();
+		void Close();
+		TVersion Version() const;
+		TPtr8& TransferDataAddressL();
+		TPtrC8& TransferDataInfoL(CSBGenericTransferType*& aGenericTransferType, TBool& aFinished);
+		void ListOfDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners);
+		void PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, RFileArray& aFiles);
+		void RawPublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, RRestoreFileFilterArray& aFileFilter);
+		void PublicFileListXMLL(TDriveNumber aDrive, TSecureId aSID, HBufC*& aFileList);
+		void SetBURModeL(const TDriveList& aDriveList, TBURPartType aBURType, TBackupIncType aBackupIncType);
+		void SetSIDListForPartialBURL(RSIDArray& aSIDs);
+		void SIDStatusL(RSIDStatusArray& aSIDStatus);
+		void RequestDataL(CSBGenericTransferType& aGenericTransferType, TRequestStatus& aStatus);
+		void RequestDataL(CSBGenericTransferType& aGenericTransferType);
+		void SupplyDataL(CSBGenericTransferType& aGenericTransferType, TBool aFinished);
+		void SupplyDataL(CSBGenericTransferType& aGenericTransferType, TBool aFinished, TRequestStatus& aStatus);
+		TUint ExpectedDataSizeL(CSBGenericTransferType& aGenericTransferType);
+		void AllSnapshotsSuppliedL();
+		void AllSystemFilesRestored();
+	
+		void ListOfDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners, TRequestStatus& aStatus);
+		void PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, RFileArray& aFiles, TRequestStatus& aStatus);
+		void SetBURModeL(const TDriveList& aDriveList, TBURPartType aBURType, 
+									  TBackupIncType aBackupIncType, TRequestStatus& aStatus);
+		void AllSnapshotsSuppliedL(TRequestStatus& aStatus);
+		void AllSystemFilesRestoredL(TRequestStatus& aStatus);
+	
+		void PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, RPointerArray<CSBEFileEntry>& aFileList, 
+			TBool& aFinished, TInt aTotalListCursor, TInt aMaxResponseSize, TRequestStatus& aStatus);
+
+		friend class CSBECallbackHandler;
+
+		~RSBEClientSession();
+
+	private:
+		RSBEClientSession();
+		static TInt StartServer();
+		TInt GetGlobalSharedHeapHandle();
+		void ConstructL();
+
+	protected:	
+		// callback functions
+		void PopulateListOfDataOwnersL(TUint aBufferSize);
+		void PopulatePublicFileListL(TUint aBufferSize);
+		void PopulateLargePublicFileListL(TInt aResult);
+	
+	private:
+		/** Handle to the Global Shared Heap */
+		RChunk iGlobalSharedHeap;
+	
+		/** Pointer to a CheapWrapper object that marshalls access to the Global Shared Heap */
+		CHeapWrapper* iGSHInterface;
+		
+		/** Pointer to the Client's Data Owners Array */
+		RPointerArray<CDataOwnerInfo>* 	iDataOwnersArray;
+		/** Poitner to the Client's File Array */
+		RFileArray*						iFileArray;
+	
+		/** Async callback handler for handling responses from the sbengine */
+		CSBECallbackHandler* 			iCallbackHandler;
+		/** Attributes that store parameters passed into async methods */
+		RPointerArray<CSBEFileEntry>* iFileList;
+		TBool* iFinished;
+		TInt* iTotalListCursor;
+    };
+    
+  
+  /** The Callback Handler for the RSBEClientSession
+    
+    This class implements an Active Object interface in order to perform asynchronous calls in a callback manner.
+
+	@internalComponent
+   */
+  class CSBECallbackHandler : public CActive
+  	{  	
+  public:
+  
+  	static CSBECallbackHandler* NewL(RSBEClientSession& aClientSession);
+  	~CSBECallbackHandler();
+  	
+  	void StartL(TRequestStatus& aStatus, TState aState);
+  	void CancelRequest();
+  	
+  private:
+
+  	CSBECallbackHandler(RSBEClientSession& aClientSession);
+  	void ConstructL();
+  	
+  	// From CActive
+	void RunL();
+	void DoCancel();
+	TInt RunError(TInt aError);
+	void CompleteObserver(TInt aError);
+  private:
+  	/** Reference to the Client Session Class */
+  	RSBEClientSession& 	iClientSession;
+  	/** Observer's TRequestStatus */
+  	TRequestStatus*		iObserver;
+  	/** State to know which function to run */
+  	TState				iState;
+  	};
+  	
+  } // end namespace
+
+#endif // __SBECLIENTSESSION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbecompressionandencryption.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,160 @@
+/**
+* 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:
+* Declaration of CSBECompressionAndEncryption class.
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+#ifndef __SBECOMPRESSIONANDENCRYPTION_H__
+#define __SBECOMPRESSIONANDENCRYPTION_H__
+
+#include <e32base.h>
+
+#include "sbtypes.h"
+
+// Forwards
+class CARC4;
+
+namespace conn
+	{
+	// Forwards
+	class CSecureBUREncryptKeySource;
+	
+	/** Constants used in the class below
+	@internalTechnology
+	*/	
+	const TInt KKeySize = 32;
+	/** Constants used in the class below
+	@internalTechnology
+	*/	
+	const TInt KEncryptionBufferSize = 256;
+	
+	// Template classes for handling byte alignment issues
+	template<class T> void ReadL(T& aT, TPtr8& aBuffer);
+	template<class T> void WriteL(T& aT, TPtr8& aBuffer);
+	
+	/** Type: Compression Header
+	@internalTechnology
+	*/
+	class TCompressionHeader
+		{
+	public:
+		TInt	iCompressedSize;
+		TInt	iUncompressedSize;
+		};
+		
+	/** Type: Encryption Header
+	@internalTechnology
+	*/
+	class TEncryptionHeader 
+		{
+	public:
+		TBool	iEncrypted;
+		TInt	iBufferSize;
+		TInt	iTotalSize;
+		};
+	
+	/** Handles compression and encryption
+	@internalTechnology
+	*/
+	class CSBECompressAndEncrypt : public CBase
+		{
+		public:
+			// Construtors
+			static CSBECompressAndEncrypt* NewLC(CSBGenericTransferType*& apTransferType, TPtr8& aInputBlock);
+			~CSBECompressAndEncrypt();
+			
+			// Methods
+			void PackL(TPtr8& aOutputData);
+			void FreeReservedSpace(TPtr8& aOutputData);
+		private:
+			// Constructors
+			CSBECompressAndEncrypt();
+			void ConstructL(CSBGenericTransferType*& apTransferType, TPtr8& aInputBlock);
+		private:
+			// Compression statics
+			const static TInt iCompressionGrowthSize;
+			
+			// Members
+			TBool							iDoEncrypt; /*<! To encryption */
+			TBool							iGotBuffer; /*<! Do we have an encryption buffer */
+			TBuf8<KKeySize>					iKey; /*<! Encryption key */
+			TBuf<KEncryptionBufferSize>		iBuffer; /*<! Encryption buffer */
+			TPtr8							iActualStart; /*<! Real start of data block */
+			TPtr8*							iOffsetStart; /*<! Star of data */
+		
+			// Encryption
+			CARC4*							iCipher; /*<! Used for encryption */
+			TBool							iIsFreed;	/*Is freed reserved memory*/
+		};
+		
+	/** Handles decompression and decryption
+	@internalTechnology
+	*/
+	class CSBEDecompressAndEncrypt : public CBase
+		{
+		public:
+			// Constructors
+			static CSBEDecompressAndEncrypt* NewL();
+			static CSBEDecompressAndEncrypt* NewLC();
+			~CSBEDecompressAndEncrypt();
+			
+			// Methods
+			void SetGenericTransferTypeL(CSBGenericTransferType*& apTransferType);
+			void SetBuffer(TDesC8& aOutputData);
+			TBool NextLC(HBufC8*& apOutput, TBool& aFinished);
+		private:
+			// Constructors
+			CSBEDecompressAndEncrypt();
+
+			// Methods
+			void Reset();
+			TBool CreateCipherL();
+			void MoveAlongL(TPtr8& aPtr, TInt aAmount);
+		private:
+			// Enum
+			enum TTransferType {ENotSet, ESid, EJava, EPackage};
+			
+			
+			// Members
+			TBool 							iDoDecrypt; /*<! Do decryption */
+			TTransferType					iType;
+			TPtr8							iCurrentPtr; /*<! Pointer to the current work position */
+			TEncryptionHeader				iEncryptionHeader; /*<! An encryption headear */
+			TDriveNumber					iDriveNumber; /*<! Drive number */
+			TSecureId						iSecureId; /*<! Secure Id */
+			TInt							iCount; /*<! Count of data unpacked */
+			TCompressionHeader				iCompressionHeader; /*<! A compression header */
+			TUid							iPackageId; /*<! A package header */
+			HBufC*							iJavaHash; /*<! For storing the java hash */
+			
+			// Buffering
+			TBool							iGotCompressionHeader; /*<! Have we got the compression header */
+			TBool							iDoneDecompression;
+			TBool							iGotCipher;
+			TInt							iCompressionSizeRead; /*<! Used for buffering */
+			TInt							iEncryptionSizeRead; 
+			HBufC8*							iBuffer;
+		
+			// Encryption
+			CARC4*							iCipher; /*<! Used for encryption */
+		};
+	}
+#endif // __SBECOMPRESSIONANDENCRYPTION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbeconfig.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,124 @@
+/**
+* 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:
+* SBE Config.
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+
+#ifndef __SBECONFIG_H__
+#define __SBECONFIG_H__
+
+#include <e32base.h>
+#include <f32file.h>
+#include <xml/contenthandler.h> // MContentHandler mix in class
+#include <charconv.h>
+using namespace Xml;
+
+/**
+@namespace conn
+
+This namespace is the global Symbian Connect namespace which encapsulates 
+all of the connectivity components within Symbian OS.
+*/
+
+namespace conn
+	{
+	/**
+	SBEConfig class is designed to read data from the ini file in order to make configurable the following data:
+	Global Shared Heap 
+	Drives not to Backup Up
+	Secure Id of Central Repository - in order to support deprecated flag (cent_rep) in registration file
+
+	@internalTechnology
+	*/
+	class CSBEConfig : public CBase, public MContentHandler
+		{
+	public:
+		static CSBEConfig* NewL(RFs& aRFs);
+		void ParseL();
+		void SetDefault();
+		~CSBEConfig();
+		
+	public:
+	// From MContentHandler
+		void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode);
+		void OnEndDocumentL(TInt aErrorCode);
+		void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrCode);
+		void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode);
+		void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
+		void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
+		void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
+		void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
+		void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
+		void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode);
+		void OnError(TInt aErrorCode);
+		TAny* GetExtendedInterface(const TInt32 aUid);
+// End MContentHandler
+
+	public:
+		//getters
+		void HeapValues(TInt& aMaxSize, TInt& aReductionFactor, TInt& aMaxRetries) const;
+		TSecureId CentRepId() const ;
+		const TDriveList& ExcludeDriveList() const ;
+		TUint AppCloseDelay() const ;
+		
+	private:
+		CSBEConfig(RFs& aRFs);
+		TInt StringToDrives(const TDesC8& aDes);
+		
+		TInt HandleAttributesElement(const RAttributeArray& aAttributes);
+		
+	private:
+		/** reference to RFs */
+		RFs& iRFs;
+		
+		/** Config File Name */
+		TFileName iFileName;
+		
+		/** Config Tag visited */
+		TBool iConfigTagVisited;
+		
+		/** Character converter to convert between UTF-8 and UTF-16 */
+		CCnvCharacterSetConverter* iConverter;
+		
+		/** SBE Global Share Heap Size */
+		TInt iSBEGSHMaxSize;
+		
+		/** Drives Not to Backup */
+		TDriveList iDrives;
+		
+		/** Cent Rep Secure Id */
+		TSecureId iCentRepId;
+		
+		/** Reduction factor if allocation fails */
+		TInt iReductionFactor;
+		
+		/** Number of retries if allocation fails */
+		TInt iMaxRetries;
+		
+		/** Extra time delay to close all non-system apps */
+		TUint iAppCloseDelay;
+		};
+	
+	}// end of namespace
+		
+	
+#endif //__SBECONFIG_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbedataowner.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,476 @@
+/**
+* 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:
+* Declaration of CDataOwner
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+#ifndef __DATAOWNER_H__
+#define __DATAOWNER_H__
+
+/// System
+#include <e32base.h>
+#include <connect/sbtypes.h>
+#include <f32file.h>
+#include <xml/contenthandler.h> // MContentHandler mix in class
+
+// Other
+#include "sbeparserproxy.h"
+#include "sbebufferhandler.h"
+#include "sbedataownermanager.h"
+
+using namespace Xml;
+
+namespace conn
+	{
+	
+	void CleanupRPointerArray(TAny* aPtr);
+	
+	/** Name of Central Repository Server
+	@internalTechnology
+	*/
+	
+	_LIT(KCentRepProcessName, "centralrepositorysrv.exe");
+	_LIT8(KYes, "yes");
+	
+	// Forwards
+	class CABServer;
+	class CDataOwnerManager;
+	class CBufferFileWriter;
+	class CBufferFileReader;
+	class CBufferSnapshotWriter;
+	class CBufferSnapshotReader;
+	
+	/** Enumeration to specify if a selection should be included or excluded
+        @internalComponent
+	*/
+	enum TSelectionType 
+		{
+		EInclude, /*<!< Is included */
+		EExclude /*!< Is excluded */
+		};
+		
+	
+	/** Simple class to store registraion file selections
+        @internalComponent
+	*/
+	class CSelection : public CBase
+		{
+	public:
+		static CSelection* NewLC(TSelectionType aType, const TDesC& aSelection);
+		~CSelection();
+		TSelectionType SelectionType() const;
+		const TDesC& SelectionName() const;
+		
+	private:
+		CSelection(TSelectionType aType);
+		void ConstructL(const TDesC& aSelection);
+		
+	private:
+    	TSelectionType		iType; /*<! The type of the selection */
+    	HBufC*		       	iSelection; /*<! The actual selection */
+		};
+	
+	/** An RArray of selections
+		@internalComponent
+	*/
+	typedef RPointerArray<CSelection> RSelections;
+	
+	/** Simple class to store passive information
+        @internalComponent
+	*/
+	class TPassiveInformation
+		{
+	public:
+		TPassiveInformation() :
+			iSupported(EFalse),
+			iSupportsSelective(EFalse),
+			iDeleteBeforeRestore(EFalse),
+			iBaseBackupOnly(EFalse)
+		/** C++ Constructor
+		*/
+			{}
+	public:
+		TUint8		iSupported; /*<! supported */
+		TUint8		iSupportsSelective; /*<! Supports selective */
+		TUint8		iDeleteBeforeRestore; /*<! Delete before restore */
+		TUint8		iBaseBackupOnly; /*<! Base backup */
+		};
+	
+	/** Simple class to store public backup information
+        @internalComponent
+	*/
+	class TPublicInformation
+		{
+	public:
+		TPublicInformation() :
+			iSupported(EFalse), iDeleteBeforeRestore(EFalse)
+			/** C++ Constructor
+			*/
+			{}
+	public:
+		TUint8		iSupported; /*<! supported */
+		TUint8		iDeleteBeforeRestore; /*<! Delete before restore */
+		};
+		
+	/** Simple class to store system backup information
+        @internalComponent
+	*/
+	class TSystemInformation
+		{
+	public:
+		TSystemInformation() :
+			iSupported(EFalse)
+		/** C++ Constructor
+		*/
+			{}
+	public:
+		TUint8	iSupported; /*!< backup system files */
+		};
+		
+	/** Information about proxy data owners (i.e. CentRep etc.)
+	@internalComponent
+	*/	
+	class TProxyInformation
+		{
+	public:
+		/** C++ Constructor
+		*/
+		TProxyInformation() : iDataRequested(EFalse), iDataSupplied(EFalse), iOpInProgress(EFalse)
+			{}
+	public:
+		TSecureId 	iSecureId; /*!< The secure ID of the proxy data manager */
+		TInt		iDataRequested; /*!< Data has already been requested from this data owner. While restoring it is used for Proxy data length*/
+		TInt 		iDataSupplied; /*!< Data has already been supplied to this data owner. While restoring it is used for consumed/restored data length.  */
+		TBool		iOpInProgress; /*!< The proxy hasn't yet completed the op and is waiting a further call. While restoring it is used for proxy finished flag and 1 means proxy data finished 0 means has more data to store  */
+		};
+		
+	/** Simple class to store restore information
+        @internalComponent
+	*/
+	class TRestoreInformation
+		{
+	public:
+		/** C++ Constructor
+		*/
+		TRestoreInformation() :
+			iSupported(EFalse), iRequiresReboot(EFalse)
+			{};
+	public:
+		TUint8	iSupported; /*<! supported */
+		TUint8	iRequiresReboot; /*<! requires reboot */
+		};
+		
+	/** enum representing TActiveType */
+    enum TActiveType
+    	{
+    	EActiveOnly = 0, /*<! Data Owner have Active Implementaion only */
+    	EActiveAndProxyImpl = 1, /*<! Data Owner have Active and Proxy Implementation */
+    	EProxyImpOnly = 2, /*<! Data Owner have only Proxy Implementation */
+    	};
+	
+	/** Simple class to store active information
+        @internalComponent
+	*/
+	class TActiveInformation
+		{
+	public:
+		/** C++ Constructor
+		*/
+		TActiveInformation() :
+			iSupported(EFalse), iRequiresDelayToPrepareData(EFalse),
+			iSupportsSelective(EFalse), iSupportsIncremental(ETrue), iActiveDataOwner(EFalse), iActiveType(EActiveOnly)
+				{
+				}
+	public:
+		TUint8 	iSupported; /*<! supported? */
+		TName	iProcessName; /*<! Active process name */
+		TUint8	iRequiresDelayToPrepareData; /*<! Requires delay to prepare data */
+		TUint8	iSupportsSelective; /*<! Supports selective */
+		TUint8	iSupportsIncremental; /*<! Supports Incremental */
+		TUint8	iActiveDataOwner; /*<! Although we say we're active, we're not really */
+		TActiveType	iActiveType; /*<! Type of the Active DO */
+		};
+		
+	/** Data Owner support classes and enums */
+	
+	/**
+	This class holds the state of the data owner by the drive
+	@internalComponent
+	*/
+	class TDataOwnerStateByDrive
+		{
+	public:
+		TDataOwnerStateByDrive(TDriveNumber aDrive) : iDrive(aDrive), iPassiveSnapshotReceived(EFalse),
+	    	iPassiveBaseDataReceived(EFalse), iPassiveIncDataReceived(EFalse), 
+	    	iPassiveSnapshotRequested(EFalse), iPassiveBaseDataRequested(EFalse), 
+	    	iPassiveIncDataRequested(EFalse), iActiveSnapshotReceived(EFalse),
+	    	iActiveBaseDataReceived(EFalse), iActiveIncDataReceived(EFalse), 
+	    	iActiveSnapshotRequested(EFalse), iActiveBaseDataRequested(EFalse), 
+	    	iActiveIncDataRequested(EFalse), iFirstActiveTransaction(ETrue),
+	    	iDeleteBeforeRestorePerformed(EFalse), iOpInProgress(EFalse)
+	    	{}
+		
+	public:
+		TDriveNumber iDrive; /*!< Record whether any snapshot data has been received */
+	    TUint8 iPassiveSnapshotReceived; /*!< Record whether any snapshot data has been received */
+	    TUint8 iPassiveBaseDataReceived; /*!< Record whether or not any data has been received */
+	    TUint8 iPassiveIncDataReceived; /*!< Record whether or not any data has been received */
+	    TUint8 iPassiveSnapshotRequested; /*!< Record whether any snapshot data has been requested */
+	    TUint8 iPassiveBaseDataRequested; /*!< Record whether or not any data has been requested */
+	    TUint8 iPassiveIncDataRequested; /*!< Record whether or not any data has been requested */
+	    TUint8 iActiveSnapshotReceived; /*!< Record whether any snapshot data has been received */
+	    TUint8 iActiveBaseDataReceived; /*!< Record whether or not any data has been received */
+	    TUint8 iActiveIncDataReceived; /*!< Record whether or not any data has been received */
+	    TUint8 iActiveSnapshotRequested; /*!< Record whether any snapshot data has been requested */
+	    TUint8 iActiveBaseDataRequested; /*!< Record whether or not any data has been requested */
+	    TUint8 iActiveIncDataRequested; /*!< Record whether or not any data has been requested */
+	    TUint8 iFirstActiveTransaction; /*!< Is this the first of an active transaction sequence */
+	    TUint8 iDeleteBeforeRestorePerformed; /*!< Have we performed the delete before restore */
+ 	    TUint8 iOpInProgress; /*!< The active data owner hasn't yet completed the op and is waiting a further call */
+		};
+
+
+	/**
+	This class holds the state of each proxy for a particular drive
+	@internalComponent
+	*/
+	class TProxyStateByDrive
+		{
+	public:
+		TProxyStateByDrive(TDriveNumber aDrive, TInt aProxy) : iDrive(aDrive), iProxy(aProxy),
+			iDataRequested(EFalse), iDataSupplied(EFalse), iOpInProgress(EFalse)
+	    	{}
+		
+	public:
+		TDriveNumber iDrive; /*!< The drive that this state relates to */
+		TInt iProxy; /*!< The proxy that this state relates to */
+		TUint8 iDataRequested; /*!< Data has already been requested from this data owner */
+		TUint8 iDataSupplied; /*!< Data has already been supplied to this data owner */
+		TUint8 iOpInProgress; /*!< The proxy hasn't yet completed the op and is waiting a further call */
+		};
+
+
+    /** Class to store the state of the data owner
+    @internalComponent
+    */
+    class TDOState
+    	{
+    public:
+        TState          	iState; /*<! The current state of the DOM */
+        TDriveNumber    	iDriveNumber; /*<! The drive number for the current request */
+        TTransferDataType   iTransferType; /*<! The transfer type of the current request */
+    	};
+	    
+
+    /** Class representing the snapshot
+    @internalComponent
+    */
+    class CSnapshotHolder : public CBase
+    	{
+    public:
+    	// Constructors
+    	static CSnapshotHolder* NewL();
+    	static CSnapshotHolder* NewLC();
+    	~CSnapshotHolder();
+	    	
+    	// Members
+    	TDriveNumber	iDriveNumber;
+    	RSnapshots		iSnapshots;
+    private:
+    	CSnapshotHolder();
+    	};
+    	
+	/** A data owner
+
+	@internalTechnology
+	*/
+	class CDataOwner : public CBase, public MContentHandler, public MValidationHandler
+		{
+	public:
+	    static CDataOwner* NewL(TSecureId aSID, CDataOwnerManager* apDataOwnerManager);
+		static CDataOwner* NewLC(TSecureId aSID, CDataOwnerManager* pDataOwnerManager);
+	    ~CDataOwner();
+	    
+
+	    // Methods
+	    void AddRegistrationFilesL(const TDesC& aFileName);
+	    void ParseFilesL();
+	    void GetExpectedDataSizeL(TTransferDataType aTransferType, TDriveNumber aDriveNumber, TUint& aSize);
+	    void GetPublicFileListL(TDriveNumber aDriveNumber, RFileArray& aFiles);
+	    void GetRawPublicFileListL(TDriveNumber aDriveNumber, RRestoreFileFilterArray& aRestoreFileFilter);
+	    void SupplyDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, TDesC8& aBuffer,
+	                     TBool aLastSection);
+	    void RequestDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, TPtr8& aBuffer,
+	    				  TBool& aLastSection);
+		void RestoreCompleteL();
+		void GetNextPublicFileL(TBool aReset, TDriveNumber aDriveNumber, TEntry& aEntry);
+   				  
+	    // Accessors
+	    TSecureId SecureId() const;
+	    TDataOwnerStatus ReadyState();
+		void SetReadyState(TDataOwnerStatus aDataOwnerStatus);
+	    TCommonBURSettings CommonSettingsL();
+	    TPassiveBURSettings PassiveSettingsL();
+	    TActiveBURSettings ActiveSettingsL();
+	    void GetDriveListL(TDriveList& aDriveList);
+	    void SetBackedUpAsPartial(TBool aPartial);
+	    TBool PartialAffectsMe() const;
+		void StartProcessIfNecessaryL();
+		void BuildDriveStateArrayL();
+		void DisableSystemData();
+		TActiveInformation ActiveInformation();
+		TBool ValidFileL(const TDesC& aFileName);
+		
+		// MContentHandler
+		void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode);
+		void OnEndDocumentL(TInt aErrorCode);
+		void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode);
+		void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode);
+		void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
+		void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
+		void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
+		void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
+		void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
+		void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode);
+		void OnError(TInt aErrorCode);
+		TAny* GetExtendedInterface(const TInt32 aUid);
+		// MContentHandler
+		
+	private:
+	    // Constructors
+	    CDataOwner(TSecureId aSID, CDataOwnerManager* apDataOwnerManager);
+	    void ConstructL();
+		
+		// Methods
+		void PrivatePathL(const TDesC& aFileName);
+		void ParseFileL(const TDesC& aFileName);
+		TInt GetDrive(const TDesC& aPath) const;
+		void BuildFileListL(const RSelections& aFileSelection, 
+							const TDriveNumber aDriveNumber,
+							const TTransferDataType aTransferType,
+							const TBool aIsPublic,
+							RSnapshots* apSnapshot,
+							RFileArray* apFileEntries,
+							CDesCArray* apFileNames);
+		void AddDBMSFilesL(TDriveNumber aDriveNumber, 
+						   CDesCArray* apFileNames, 
+						   RFileArray* apEntries);
+		void ParseDirL(const TDesC& aDirName, 
+					   const RArray<TPtrC>& aExclude, 
+					   const TTransferDataType aTransferType,
+					   const TBool aIsPublic,
+					   RSnapshots* apSnapshots,
+					   RFileArray* apFileEntries, 
+					   CDesCArray* apFileNames);
+		TBool IsExcluded(const TBool aIsPublic, const TDesC& aFileName, const RArray<TPtrC>& aExclude);
+		void IsNewerL(const TDesC& aFileName, const TEntry& aFile, const RSnapshots* aSnapshots, TBool& aNewer);
+		RSnapshots* FindSnapshot(TDriveNumber aDriveNumber);
+		void ResetState();
+		TDataOwnerStateByDrive& StateByDriveL(TDriveNumber& aDrive);
+		TProxyStateByDrive& ProxyStateByDriveL(TDriveNumber& aDrive, TInt aProxy);
+		void CleanupBeforeRestoreL(TDriveNumber& aDriveNumber);
+		
+		// Supply
+		void SupplyPassiveSnapshotDataL(TDriveNumber aDriveNumber, TDesC8& aBuffer, TBool aLastSection);
+		void SupplyPassiveBaseDataL(TDriveNumber aDriveNumber, TDesC8& aBuffer, TBool aLastSection);
+		
+		// Request
+		void RequestPassiveSnapshotDataL(TDriveNumber aDriveNumber, TPtr8& aBuffer, TBool& aLastSection);
+		void RequestPassiveDataL(TTransferDataType aTransferType, TDriveNumber aDriveNumber, TPtr8& aBuffer, TBool& aLastSection);
+		void ProcessRequestDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, 
+    			TPtr8& aBuffer, TBool& aLastSection);
+    	void ProcessSupplyDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, 
+				TDesC8& aBuffer, TBool aLastSection);
+		TInt AddProxyToList(TProxyInformation aProxy);
+		
+				
+		// private methods for parsing
+	private:
+		// Element handlers 
+  		void HandleBackupRegistrationL(const RAttributeArray& aAttributes);
+  		void HandlePathL(const TSelectionType aType, const RAttributeArray& aAttributes, const TBool aDir);
+  		TInt HandlePassiveBackup(const RAttributeArray& aAttributes);
+  		TInt HandlePublicBackup(const RAttributeArray& aAttributes);
+  		TInt HandleSystemBackup(const RAttributeArray& aAttributes);
+  		TInt HandleCenrepBackup(const RAttributeArray& aAttributes);
+ 		TInt HandleProxyDataManager(const RAttributeArray& aAttributes);
+  		TInt HandleDBMSBackupL(const RAttributeArray& aAttributes);
+  		TInt HandleActiveBackupL(const RAttributeArray& aAttributes);
+  		TInt HandleRestore(const RAttributeArray& aAttributes);
+	private:
+		// Internal
+	    TDOState           				iState; /*<! The state of the data owner */
+	    TDataOwnerStatus				iStatus; /*!< Is the DO ready for operations - only relevant for active */
+	    CDesCArray*						iRegistrationFiles; /*<! A list of registration files for this data owner */
+	    TUint8							iFilesParsed; /*<! Have we parsed the registration files */
+	    TUint8							iPrimaryFile; /*<! Have we found a primary file */
+	    TUint8							iBackupAsPartial; /*!< Will this DO be backed up as partial */
+	    
+	    // Options
+	    TSecureId            			iSecureId; /*<! The data owners SID */
+	    TPassiveInformation				iPassiveInformation; /*<! Passive backup information */
+	    TPublicInformation				iPublicInformation; /*<! Public backup information */
+	    TSystemInformation				iSystemInformation; /*<! System backup information */
+	    TActiveInformation				iActiveInformation; /*<! Active information */
+	    TRestoreInformation				iRestoreInformation; /*<! restore information */
+	    RArray<TProxyInformation>		iProxyInformationArray; /*!< The various proxies that we support */
+	    TBufC<KMaxPackageNameLength>	iName; /*<! The data owners nice name */
+	    RArray<TDataOwnerStateByDrive>	iStateByDrive; /*<! Array storing the state of the DO's by drive */
+	    RArray<TProxyStateByDrive>		iProxyStateByDrive; /*<! Array storing the state of the proxies for each drive */
+		RArray<TUid>					iDBMSSelections; /*<! Array storing the list of DBMS selections */
+	    
+	    // Reader\Writer handlers
+	    CBufferFileWriter*				iBufferFileWriter; /*<! Handles writing files to the buffer */
+	    CBufferFileReader*				iBufferFileReader; /*<! Handles reading files from the buffer */
+	    CBufferSnapshotWriter*			iBufferSnapshotWriter; /*<! Handles writing snapshots to the buffer */
+	    CBufferSnapshotReader*			iBufferSnapshotReader; /*<! Handles reading snapshots from the buffer */
+	    
+	    // Selections
+	    RSelections						iPassiveSelections; /*<! Passive selections */
+	    RSelections						iPublicSelections; /*<! Public selections */
+
+        // Snapshots
+	    CSnapshotHolder*				iTempSnapshotHolder; /*<! Hold a temporary snapshot */
+	    RPointerArray<CSnapshotHolder>	iSnapshots; /*<! Stores the snapshots we have been sent */
+	    
+	    // Resources
+	    CDataOwnerManager*				ipDataOwnerManager; /*<! To access resources */
+	 	HBufC*							iPrivatePath; /*<! The path to the private directory */
+	 	
+	 	/* Simple enumeration: What is our current element?
+		*/
+		enum TCurrentElement 			{ENoElement = 0, // No element 
+										 EPassive = 1, // Passive element 
+										 EPublic = 2 // Public element
+										};
+		
+		TCurrentElement					iCurrentElement; /*<! Current element */
+	 
+	 	RArray<RDir>					iPublicDirStack; /*<! Stack of public directories for enumerating public files */
+	 	RPointerArray<HBufC>			iPublicDirNameStack; /*<! Directory names corresponding to entries in the above stack */
+		RArray<TPtrC>					iPublicExcludes; /*<! Stores list of excludes while enumerating public files */
+		TInt							iPublicFileIndex; /*<! Index of current element being enumerated in public file list */
+		TInt 							iCurrentProxy;  // Used to restore the proxy data
+	 	
+		};
+		
+	}
+#endif // __DATAOWNER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbedataownermanager.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,255 @@
+/**
+* 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:
+* Declaration of CDataOwnerManager
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+#ifndef __DATAOWNERMANAGER_H__
+#define __DATAOWNERMANAGER_H__
+
+// System
+#include <e32base.h>
+#include <connect/sbtypes.h>
+#include <f32file.h>
+#include <e32property.h>
+#include <swi/sisregistrysession.h>
+#include <badesca.h>
+
+#include "sbeconfig.h"
+#include "sbeparserproxy.h"
+#include <connect/javamanagerinterface.h>
+
+
+// Forwards
+class CBaBackupSessionWrapper;
+class CARC4;
+
+
+
+namespace conn
+	{
+	// Forwards
+	class CDataOwner;
+	class CABServer;
+	class CBufferFileReader;
+	class CPackageDataTransfer;
+	class CDataOwnerManager;
+	class CJavaDataOwnerManager;
+	class CSecureBUREncryptKeySource;
+	class CSBEDecompressAndEncrypt;
+	
+    /** The current request state 
+    @internalComponent
+    */
+    enum TState 
+    	{
+    	ENone, /*<! The DataOwnerManager is not requesting or supplying */ 
+    	ERequest, /*<! The DataOwnerManager is currently dealing with a request */
+    	ESupply, /*<! The DataOwnerManager is currently dealing with a supply */
+    	EBuffer /*<! The DataOwnerManager is currently dealing with buffering */
+    	};
+
+	// Globals
+	_LIT(KStar, "*");
+	_LIT(KPrivate, "\\private\\");
+	_LIT(KBackSlash, "\\");
+	_LIT(KColon, ":");
+	_LIT(KBackupRegistrationFile, "backup_registration*.xml");
+	_LIT(KPrimaryBackupRegistrationFile, "backup_registration.xml");
+	_LIT(KImportDir, "\\private\\10202D56\\import\\packages\\");
+
+	/**
+		Simple container to map Secure ID's to there assocaited Data Owner
+		@internalComponent
+	*/
+    class CDataOwnerContainer : public CBase
+    	{
+    	public:
+    		static CDataOwnerContainer* NewL(TSecureId aSid, CDataOwnerManager* apDataOwnerManager);
+    		~CDataOwnerContainer();
+    		
+    		static TInt Compare(const CDataOwnerContainer& aFirst, const CDataOwnerContainer& aSecond);
+			static TBool Match(const CDataOwnerContainer& aFirst, const CDataOwnerContainer& aSecond);
+	    		
+    		TSecureId SecureId() const;
+    		CDataOwner& DataOwner() const;
+        private:
+        	CDataOwnerContainer(TSecureId aSID);
+        	void ConstructL(CDataOwnerManager* apDataOwnerManager);
+    	private:
+        	TSecureId       iSecureId; /*<! Contains the secure ID */
+        	CDataOwner*     ipDataOwner; /*<! Contains the data owner.*/
+    	};
+    	
+    /** The state of the data owner manager
+    @internalComponent
+    */
+    class TDOMState
+    	{
+	public:
+		TState          	iState; /*<! The current state of the DataOwnerManager */
+		TSecureId       	iSID; /*<! The secure ID we are currently working with */
+		};
+
+	/**
+	Manager for data owners.
+	@internalTechnology
+	*/
+	class CDataOwnerManager : public CBase
+		{
+    	
+	public:
+	    // Construction
+	    static CDataOwnerManager* NewLC();
+	    ~CDataOwnerManager();
+	    
+	    // Methods
+	    void SetBURModeL(const TDriveList& aDriveList, TBURPartType aBURType, 
+						TBackupIncType aBackupIncType);
+	    void GetDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners);
+	    void GetExpectedDataSizeL(CSBGenericTransferType* aGenericTransferType, TUint& aSize);
+	    void GetPublicFileListL(CSBGenericDataType* aGenericDataType, TDriveNumber aDriveNumber, RFileArray& aFiles);
+	    void GetRawPublicFileListL(CSBGenericDataType* aGenericDataType, TDriveNumber aDriveNumber, 
+	    						   RRestoreFileFilterArray& aRestoreFileFilter);
+	    void GetXMLPublicFileListL(TSecureId aSID, TDriveNumber aDriveNumber, HBufC*& aBuffer);
+	    
+	    void SetSIDListForPartialBURL(TDesC8& aFlatArrayPtr);
+	    void SIDStatusL(RSIDStatusArray& aSIDStatus);
+	    void AllSnapshotsSuppliedL();
+	    void GetNextPublicFileL(CSBGenericDataType* aGenericDataType, TBool aReset,
+	                           TDriveNumber aDriveNumber, TEntry& aEntry);
+	    
+	    // Global heap 
+	    void SupplyDataL(CSBGenericTransferType* aGenericTransferType, TDesC8& aBuffer, 
+	    				 TBool aLastSection);
+	    void RequestDataL(CSBGenericTransferType* aGenericTransferType,
+	    	    		  TPtr8& aBuffer, TBool& aLastSection);
+	                         
+	    // Accessors
+	    void SetActiveBackupServer(CABServer* aABServer);
+	    RFs& GetRFs();
+	    CABServer& ABServer();
+	    CDataOwner& DataOwnerL(TSecureId aSID);
+	    
+	    TDriveList& DriveList();
+	    TBURPartType BURType() const;
+	    TBackupIncType IncType() const;
+		void AllSystemFilesRestoredL();
+		
+		CSBEConfig& Config();
+		inline CSBEParserProxy& ParserProxy();
+		TBool IsSetForPartialL(TSecureId aSecureId) const;
+
+	private:
+		// Constructor
+		void ConstructL();
+		CDataOwnerManager();
+		
+		// Methods
+		void FindDataOwnersL();
+		CDataOwnerContainer* FindL(TSecureId aSID);
+		CPackageDataTransfer* FindPackageDataContainerL(TUid pid);
+		void StripSecureIdL(const TDesC& aStrip, TSecureId& aSecureId);
+		void UpdateDataOwnersPartialStateL();
+		void FindImportPackagesL(Swi::RSisRegistrySession& aRegistry, RPointerArray<CDataOwnerInfo>& aDataOwners);
+		void FindRegistrationFilesL(const TDesC& aPath, CDesCArray& aFiles);
+	private:
+	    RPointerArray<CDataOwnerContainer>  iDataOwners; /*<! An array of TDataOwnerContainers */
+		RPointerArray<CPackageDataTransfer> iPackageDataOwners; /*<! An array of package data transfer objects */
+	    TDOMState           iState; /*!< The state of the DataOwnerManager */
+	    
+	    // Current backup options (set in SetBURModeL -> needed for active clients)
+	    TDriveList			iDriveList; /*<! Drive list for backup */
+	    TBURPartType		iBURType; /*<! Backup/restore type */
+	    TBackupIncType		iIncType; /*<! Incrementatl type */
+	    
+	    // Resources
+	    CABServer*          ipABServer; /*!< The active backup server */
+	    RFs					iFs; /*!< A RFs used in this class and all DataOwners */
+	    CBufferFileReader*	iBufferFileReader; /*<! Used to restore registration files */
+	    CSBEDecompressAndEncrypt* iDecompressor;
+	    
+	    /** Set to true if we need to reset the device after a restore */
+	    TBool				iResetAfterRestore;
+	    
+	    /** Object to handle Java data owners */
+		CJavaManagerInterface* iJavaDOM;
+	    
+	    /** List of Secure IDs for Partial Restore */
+	    RSIDArray* iSIDListForPartial;
+	    
+	    /** Config for SBE */
+	    CSBEConfig* iConfig;
+	    
+	    /** Base Backup Session Wrapper */
+	    CBaBackupSessionWrapper* iBaBackupSession;
+	    
+	    /** Backup Registration Parser Proxy */
+	    CSBEParserProxy*		 iParserProxy;
+		};
+		
+    inline TDriveList& CDataOwnerManager::DriveList()
+    /**
+    Return the list of drives specified for the operation
+    @return Drivelist
+    */
+    	{
+    	return iDriveList;
+    	}
+    	
+    inline TBURPartType CDataOwnerManager::BURType() const
+    /**
+    Return the partial backup type
+    @return The partial backup type
+    */
+    	{
+    	return iBURType;
+    	}
+    	
+    inline TBackupIncType CDataOwnerManager::IncType() const
+    /**
+    Return the incremental backup type
+    @return The incremental backup type
+    */
+    	{
+    	return iIncType;
+    	}
+    
+    /**
+    Return Active Backup Server
+    @return reference to Active Backup Server
+    */	
+	inline CABServer& CDataOwnerManager::ABServer()
+		{
+		return *ipABServer;
+		}
+		
+	/**
+	Return Parser Proxy
+	@return reference to Parser Proxy
+	*/
+	inline CSBEParserProxy& CDataOwnerManager::ParserProxy()
+		{
+		return *iParserProxy;
+		}
+    	
+	} // namespace conn
+#endif // __DATAOWNERMANAGER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbencrypt.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,151 @@
+/**
+* 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:
+* Declaration of CSecureBUREncryptKeySource
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+#ifndef __SBENCRYPT_H__
+#define __SBENCRYPT_H__
+#include <e32base.h>
+#include <f32file.h>
+
+namespace conn
+  { 
+class CSecureBURKeySourceImpl;
+
+class CSecureBUREncryptKeySource : public CBase
+	/**
+    This class is responsible for providing keys for encryption of backup data
+    or decryption of restore data based on drive and SID of the data owner.
+
+    The class will be included in a separate key-providing DLL provided by licensees
+    at build time.  The default Symbian implementation will not provide keys.
+
+    It is permissible to not provide any keys and to not encrypt data.  It is also
+    permissible for one key to be common to all or a set of SIDs or for one key to be 
+    common to a set of drives.
+
+    The class can provide a data buffer with backup keys.  If it does then the buffer
+    will be stored (un-encrypted!) with the backup and will be provided when keys are
+    requested for a restore operation.  The class supports a default data buffer for a
+    whole backup plus the ability to override it with buffers for specific SIDs.  If 
+    the buffer is used then the implementor must be aware that is is not encrypted in the
+    backup and so must not contain any sensitive data or any data that would allow an
+    attacker to recreate the key.  If a buffer is provided then it is returned at restore
+    time on a per-SID basis - there is no provision to provide a default buffer at restore
+    time.
+
+    If keys are provided then the implementor needs to consider a number of factors:
+    
+    @li If the key is entered by the user then it should be assumed that the user can 
+    decrypt data off the device.
+
+    @li If the key is local to the device then the data cannot be restored to a new device.
+
+    @li If the key depends on the drive being backed up or restored then the implementor
+    needs to consider whether a drive may have its letter changed (e.g. if a device has
+    multiple slots for removable media).
+
+    This class owns a CSecureBURKeySourceImpl instance and publishes the 
+    public API to the outside world. The reason for this facade class is twofold:
+
+    @li Hiding the implementation details of CSecureBURKeySourceImpl 
+
+    @li Future binary compatibility
+    
+    @released
+    @publishedPartner
+	*/	
+    {
+public:
+	/**
+	Static factory method (two phase construction)
+
+    @return  Pointer to the CSecureBUREncryptKeySource instance
+	*/	
+    IMPORT_C static CSecureBUREncryptKeySource* NewL();
+    /**
+    Standard virtual destructor
+    */
+    IMPORT_C virtual ~CSecureBUREncryptKeySource();
+
+    /**
+    Get a default data buffer for all backups of a specified drive.
+
+    @param aDrive the drive being backed up - may be ignored
+    @param aGotBuffer set to ETrue on return if a buffer is supplied
+    @param aBuffer if aGotBuffer is set to ETrue then this is a buffer of data to be
+    included with backups.
+    */
+    IMPORT_C void GetDefaultBufferForBackupL(TDriveNumber aDrive, TBool& aGotBuffer, TDes& aBuffer);
+
+    /**
+    Provides a key to use to encrypt backup data for a specific data owner from a specific
+    drive.  It is permissible to provide the same key for some or all data owners.  It is 
+    permissible to provide the same key for some or all drives.
+    
+    @param aDrive the drive (EDrive A to EDriveZ) which is being backed up
+    @param aSID the secure id of the data owner
+    @param aDoEncrypt returns ETrue if a key is provided, EFalse if data is not to be encrypted
+    @param aKey the key to use to encrypt data - ignored if aDoEncrypt is set to EFalse
+    @param aGotBuffer returns ETrue if a buffer is returned that is specific to this SID
+    @param aBuffer if aGotBuffer is set to ETrue then this is a buffer of data to be
+    included with backups.
+    */
+    IMPORT_C void GetBackupKeyL(TDriveNumber aDrive, TSecureId aSID,
+                                TBool &aDoEncrypt, TDes8& aKey,
+                                TBool& aGotBuffer, TDes& aBuffer);
+
+    /**
+    Provides a key to use to decrypt backup data for a specific data owner from a specific
+    drive.  It is permissible to provide the same key for some or all data owners.  It is 
+    permissible to provide the same key for some or all drives.
+    
+    @param aDrive the drive (EDrive A to EDriveZ) which is being restored
+    @param aSID the secure id of the data owner
+    @param aGotBuffer set to ETrue if a buffer is provided
+    @param aBuffer if aGotBuffer is set to ETrue then this is a buffer of data that was 
+    provided with the key for the backup (or the default buffer)
+    @param aGotKey returns ETrue if a key is provided, EFalse if data is not to be decrypted
+    @param aKey the key to use to decrypt data - ignored if aGotKey is set to EFalse
+    */
+    IMPORT_C void GetRestoreKeyL(TDriveNumber aDrive, TSecureId aSID, 
+                                 TBool aGotBuffer, TDes& aBuffer,
+                                 TBool &aGotKey, TDes8& aKey);
+
+private:
+    /**
+    Standard C++ Constructor
+    */
+    CSecureBUREncryptKeySource();
+    /**
+    Symbian Second phase constructor
+    */
+    void ConstructL();
+ 
+private:
+	/** Pointer the the CSecureBURKeySourceImpl implementation */
+	CSecureBURKeySourceImpl* iImpl;
+    };
+
+  } // end namespace
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbencryptimpl.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,57 @@
+/**
+* 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:
+* Declaration of CSecureBURKeySourceImpl
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+#ifndef __SBENCRYPTIMPL_H__
+#define __SBENCRYPTIMPL_H__
+#include <e32base.h>
+#include <f32file.h>
+
+namespace conn
+	{
+	class CSecureBURKeySourceImpl : public CBase
+	/**
+	Implementation for the CSecureBURKeySourceImpl
+	
+	@internalTechnology
+	*/
+		{
+	public:
+	    // Construction
+	    static CSecureBURKeySourceImpl* NewL();
+	    virtual ~CSecureBURKeySourceImpl();
+
+	    // Methods
+	    void GetDefaultBufferForBackupL(TDriveNumber aDrive, TBool& aGotBuffer, TDes& aBuffer);
+	    void GetBackupKeyL(TDriveNumber aDrive, TSecureId aSID,
+	                       TBool& aDoEncrypt, TDes8& aKey,
+	                       TBool& aGotBuffer, TDes& aBuffer);
+	    void GetRestoreKeyL(TDriveNumber aDrive, TSecureId aSID, 
+	                        TBool aGotBuffer, TDes& aBuffer,
+	                        TBool &aGotKey, TDes8& aKey);
+
+	private:
+	    CSecureBURKeySourceImpl();
+		};
+	}
+#endif __SBENCRYPTIMPL_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbeparserdefs.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,72 @@
+/**
+* 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:
+* Constant definitions
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+#ifndef __SBEPARSERDEFS_H__
+#define __SBEPARSERDEFS_H__
+
+namespace conn
+	{
+	// Max number of characters that the field value for a hex UID can be i.e. 0x12345678
+	const TInt KSBEMaxHexStringLength = 10;
+	
+	// XML type
+	_LIT8(KMimeType, "text/xml");
+	
+	// Elements
+	_LIT8(KSupportsSelective, "supports_selective"); 
+	_LIT8(KPassiveBackup, "passive_backup");
+	_LIT8(KPublicBackup, "public_backup");
+	_LIT8(KIncludeFile, "include_file");
+	_LIT8(KIncludeDirectory, "include_directory");
+	_LIT8(KExclude, "exclude");
+	_LIT8(KBackupRegistration, "backup_registration");
+	_LIT8(KSystemBackup, "system_backup");
+	_LIT8(KCenrepBackup, "cenrep_backup");
+	_LIT8(KDBMSBackup, "dbms_backup");
+	_LIT8(KActiveBackup, "active_backup");
+	_LIT8(KRestore, "restore");
+	_LIT8(KProxyDataManager, "proxy_data_manager");
+	_LIT8(KJavaXMLElementMIDletSuite, "midlet_suite");
+	_LIT8(KJavaXMLElementIncludeDirectory, "java_include_directory");
+	_LIT8(KJavaXMLElementJavaBackupMIDlet, "java_backup_midlet");
+	
+	_LIT8(KProxySID, "SID");
+	_LIT8(KHexLeader, "0x");
+	_LIT8(KDatabase, "database");
+	_LIT8(KPolicy, "policy");
+	
+	_LIT8(KProcessName, "process_name");
+	_LIT8(KRequiresDelay, "requires_delay_to_prepare_data");
+	_LIT8(KSupportsInc, "supports_incremental");
+	_LIT8(KActiveType, "active_type");
+	
+	_LIT8(KActiveOnly, "activeonly");
+	_LIT8(KActiveAndProxy, "activeandproxy");
+	_LIT8(KProxyOnly, "proxyonly");
+	_LIT8(KRequiresReboot, "requires_reboot");
+	_LIT8(KDeleteBeforeRestore, "delete_before_restore");
+	_LIT8(KBaseBackupOnly, "base_backup_only");
+
+	}
+#endif // __SBEPARSERDEFS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbeparserproxy.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,81 @@
+/**
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* Declaration of CSBEParserProxy
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+#ifndef SBEPARSERPROXY_H
+#define SBEPARSERPROXY_H
+
+// System
+#include <f32file.h>
+#include <xml/contenthandler.h> // MContentHandler mix in class
+#include <xml/parser.h>
+
+// Classes referenced
+class CCnvCharacterSetConverter;
+
+using namespace Xml;
+
+namespace conn
+	{
+	/** Class used as a proxy to redirect CParser calls to the relevant data owner
+
+	@internalTechnology
+	*/
+	class CSBEParserProxy : public CBase, public MContentHandler
+		{
+	public:
+	    static CSBEParserProxy* NewL( RFs& aFsSession );
+	    ~CSBEParserProxy();
+	    // API
+	    void ParseL( const TDesC& aFileName, MContentHandler& aObserver );
+        TInt ConvertToUnicodeL( TDes16& aUnicode, const TDesC8& aForeign );
+	    
+	private: // Constructors
+	    CSBEParserProxy( RFs& aFsSession );
+	    void ConstructL();
+
+ 		// From MContentHandler
+		void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode);
+		void OnEndDocumentL(TInt aErrorCode);
+		void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode);
+		void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode);
+		void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
+		void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
+		void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
+		void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
+		void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
+		void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode);
+		void OnError(TInt aErrorCode);
+		TAny* GetExtendedInterface(const TInt32 aUid);
+
+    private: // Internal
+        RFs& iFsSession; /*<! File server session */
+	    CParser* iParser; /*<! Parser for xml */
+        MContentHandler* iTransientObserver; /*<! XML observer that we will call back */
+        TInt iTransientParsingError; /*<! Transient parsing error code, supplied to XML parsing callbacks */
+        CCnvCharacterSetConverter* iConverter; /*<! Convert from UTF-8 to unicode */
+		TInt iConverterState; /* State for converter object */
+		};
+	}
+
+#endif // SBEPARSERPROXY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbeserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,118 @@
+/**
+* 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:
+* Declaration of CSBEServer class.
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+
+#ifndef __SBESERVER_H__
+#define __SBESERVER_H__
+
+#include "sbshutdown.h"
+#include "sbheapwrapper.h"
+
+namespace conn
+	{
+
+	/** @defgroup SBEServer SBE Server Documentation
+	*/
+
+	class CSBShutdown;
+	class CDataOwnerManager;
+	
+
+	class CSBEServer :	public CPolicyServer
+	/** The SBE Server.
+    @internalComponent
+	@ingroup SBEServer
+	*/
+		{
+		public:
+			~CSBEServer();
+			static CSBEServer* NewLC(CDataOwnerManager* aDOM);
+			void AddSession();
+			void DropSession();
+			inline RChunk& GlobalSharedHeap();
+			inline CHeapWrapper& GSHInterface();
+			inline CDataOwnerManager& DataOwnerManager();
+
+		private:
+			CSBEServer(CDataOwnerManager* aDOM);
+			void ConstructL();
+			
+			//
+			// From CServer2
+			virtual CSession2* NewSessionL(const TVersion& aVersion,
+				const RMessage2& aMessage) const;
+			
+			TInt RunError(TInt aError);
+			void PanicClient(TInt aPanic) const;
+			void AllocateGlobalSharedHeapL();
+
+		private:
+			/** Active client sessions. */
+			TInt iSessionCount;
+			
+			/** Shutdown timer. */
+			CSBShutdown iShutdown;
+			
+			/** Global shared heap for passing large amounts of data between client and server
+			without having to use IPC */
+			RChunk iGlobalSharedHeap;
+			
+			/** Interface to the global shared heap */
+			CHeapWrapper* iGSHInterface;
+			
+			/** Pointer to the Data owner manager */
+			CDataOwnerManager* iDOM;
+		};
+
+		inline RChunk& CSBEServer::GlobalSharedHeap()
+		/* Get the global shared heap
+		
+		@return the global shared heap
+		*/
+			{
+			return iGlobalSharedHeap;
+			}
+			
+		inline CHeapWrapper& CSBEServer::GSHInterface()
+			/** Get the global shared heap interface
+			
+			@return the global shared heap interface
+			*/
+			{
+			return *iGSHInterface;
+			}
+			
+		inline CDataOwnerManager& CSBEServer::DataOwnerManager()
+			/* Get the data owner manager
+			
+			@return the data owner manager.
+			*/
+			{
+			
+			
+			return *iDOM;
+			}
+	}
+
+#endif //__SBESERVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbesession.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,99 @@
+/**
+* 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:
+* Declaration of CSBESession class.
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+#ifndef __SBESESSION_H__
+#define __SBESESSION_H__
+
+namespace conn
+	{
+	class CDataOwnerInfo;
+	class CSBESession : public CSession2
+	/**
+    @internalComponent
+	@ingroup Server
+
+	A SBE client Session.
+	*/
+		{
+		public:
+			CSBESession();
+			virtual void CreateL();
+
+		private:
+			~CSBESession();
+			inline CSBEServer& Server() const;
+			void ServiceL(const RMessage2& aMessage);
+
+			void PrepDataOwnerInfoL(const RMessage2& aMessage);
+			void ReturnDataOwnerInfoL(const RMessage2& aMessage);
+			void PrepPublicFileListL(const RMessage2& aMessage);
+			void ReturnPublicFileListL(const RMessage2& aMessage);
+			void PrepPublicFileListRawL(const RMessage2& aMessage);
+			void ReturnPublicFileListRawL(const RMessage2& aMessage);
+			void PrepPublicFileListXMLL(const RMessage2& aMessage);
+			void ReturnPublicFileListXMLL(const RMessage2& aMessage);
+			void SetBURModeL(const RMessage2& aMessage);
+			void SetSIDListForPartialBURL(const RMessage2& aMessage);
+			void PrepSIDStatusL(const RMessage2& aMessage);
+			void ReturnSIDStatusL(const RMessage2& aMessage);
+			void RequestDataAsyncL(const RMessage2& aMessage);
+			void RequestDataSyncL(const RMessage2& aMessage);
+			void SupplyDataSyncL(const RMessage2& aMessage);
+			void GetExpectedDataSizeL(const RMessage2& aMessage);
+			void AllSnapshotsSuppliedL(const RMessage2& aMessage);
+			void AllSystemFilesRestoredL();
+			void PrepLargePublicFileListL(const RMessage2& aMessage);
+			void ReturnLargePublicFileListL(const RMessage2& aMessage);
+			
+			void ResetTransferBuf();
+
+		private:
+			/** Heap allocated descriptor for storing an externalised array upon a 
+			2 stage server-client descriptor send */
+			HBufC8* iTransferBuf;
+			
+			/** Heap allocated descriptor for storing a text string upon a 
+			2 stage server-client descriptor send */
+			HBufC* iTransferTextBuf;
+
+			/** Used in conjunction with iTransferBuf when passing back CDataOwnerInfo array 
+			so that message is completed on the second IPC call with the num of elements in
+			returned externalised array */
+			TInt iArrayCount;
+			
+			/** Message member used for asynchronous IPC calls */
+			RMessage2 iMessage;
+			
+			/** Finished flag used for storing data in a large public file list 2-part IPC call */
+			TBool iFinished;
+			
+			/** Count used for large public file list 2-part IPC call */
+			TInt iTotalEntries;
+			
+			/** Saves the externalised current entry for packing into the next message */
+			HBufC8* iExtCurEntry;
+		};
+	}
+
+#endif //__SBESESSION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbexternalisablearray.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,50 @@
+// 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:
+// Templated RArray for serialising and deserialising simple (flat) classes
+// for transmission inside descriptors over IPC
+// 
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef __SBEXTERNALISABLEARRAY_H__
+#define __SBEXTERNALISABLEARRAY_H__
+
+#include <e32std.h>
+#include <e32base.h>
+
+namespace conn
+	{
+	template<class T>
+	class RExternalisableArray : public RArray<T>
+	/**
+	Template inheriting from RArray, providing functionality to externalise and then internalise 
+	an RArray of flat (i.e. without pointers) objects into a descriptor for passing over IPC
+	
+	@publishedPartner
+	@released
+	*/
+		{
+	public:
+		inline static RExternalisableArray<T>* InternaliseL(const TDesC8& aExternalisedArray);
+		inline HBufC8* ExternaliseL();
+		};
+	}
+	
+#include <connect/sbexternalisablearray.inl>
+#endif //__SBEXTERNALISABLEARRAY_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbexternalisablearray.inl	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,86 @@
+// 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:
+// externalisablearray.inl
+// Templated RArray for serialising and deserialising simple (flat) classes
+// for transmission inside descriptors over IPC
+// 
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+namespace conn
+	{
+	template<class T> inline RExternalisableArray<T>* RExternalisableArray<T>::InternaliseL(const TDesC8& aExternalisedArray)
+	/**
+	Internalises an RArray of objects passed via IPC from a descriptor
+	
+	@param aExternalisedArray The descriptor passed via IPC that contains the flattened array to internalise
+	@return Pointer to a newly created RExternalisableArray
+	*/
+		{
+		RExternalisableArray<T>* self = new (ELeave) RExternalisableArray<T>;
+		
+		CleanupStack::PushL(self);
+		
+		TUint8* unpackPtr = const_cast<TUint8*>(aExternalisedArray.Ptr());
+		TInt elementCount = *reinterpret_cast<TInt*>(unpackPtr);
+		
+		// point to the start of the packed elements
+		unpackPtr += sizeof(TInt);
+		
+		for (TInt index = 0; index < elementCount; index++)
+			{
+			User::LeaveIfError(self->Append(*reinterpret_cast<T*>(unpackPtr)));
+			unpackPtr += sizeof(T);
+			}
+			
+		CleanupStack::Pop(self);
+			
+		return self;
+		}
+	
+	template<class T> inline HBufC8* RExternalisableArray<T>::ExternaliseL()
+	/**
+	Externalises an RArray of objects (not pointers) into a descriptor so that the RArray
+	may be passed via IPC
+	
+	@return Pointer to the created HBufC8
+	*/
+		{
+		// calculate the flattened size of the array
+		TInt elementSize = sizeof(T);
+		TInt count = RArray<T>::Count();
+		TInt totalPackedSize = sizeof(TInt) + (sizeof(T) * count);	// TInt stores the number of elements to be packed
+	
+		// create the HBufC8 to be returned
+		HBufC8* externalisedArray = HBufC8::NewL(totalPackedSize);
+	
+		TPtr8 buffer = externalisedArray->Des();
+	
+		// Append the number of entries to the beginning of the array
+		buffer.Append(reinterpret_cast<TUint8*>(&count), sizeof(TInt));
+	
+		// bitwise copy each entry into the buffer
+		for (TInt index = 0; index < count; index++)
+			{
+			buffer.Append(reinterpret_cast<TUint8*>(&(*this)[index]), elementSize);
+			}
+		
+		return externalisedArray;
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbheapwrapper.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,132 @@
+/**
+* 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:
+* Definition of CHeapWrapper and THeapWrapperHeader
+* 
+*
+*/
+
+
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __HEAPWRAPPER_H__
+#define __HEAPWRAPPER_H__
+
+#include <e32std.h>
+#include <connect/sbtypes.h>
+
+namespace conn
+	{
+	/** KMaxGenericTypeSize must be a multiple of 4 to ensure that all structures are 4-byte aligned 
+	@internalTechnology */
+	const TInt KMaxGenericTypeSize = 1024;
+	
+	class THeapWrapperHeader
+	/**
+	This class is packed at the beginning of the heap and stores information about the data
+	contained in the descriptor.
+	
+	Note that all structures in here must be 4-byte aligned, using dummy padding if necessary.
+	
+	@internalTechnology
+	*/
+		{
+	public:
+		inline TBool LockedFlag();
+		inline void SetLockedFlag(TBool aLockedFlag);
+		inline TBuf8<KMaxGenericTypeSize>& GenericTransferTypeBuffer();
+
+	public:
+		/** Finished flag, set to ETrue when the data in the descriptor 
+		is the last in a multi-part transfer*/
+		TBool iFinished;
+
+	private:
+		/** Flag to indicate that the heap has been locked for writing 
+		by an instance of CHeapWrapper */
+		TBool iLockedFlag;
+
+		/** Generic transfer type */
+		TBuf8<KMaxGenericTypeSize> iGenericDataTransferInfo;
+		};
+		
+	inline TBool THeapWrapperHeader::LockedFlag()
+	/** Getter for the private locked flag 
+	@return The status of the locked flag */
+		{
+		return iLockedFlag;
+		}
+		
+	inline void THeapWrapperHeader::SetLockedFlag(TBool aLockedFlag)
+	/** Setter for the locked flag
+	@param aLockedFlag The new state of the heap locked flag */
+		{
+		iLockedFlag = aLockedFlag;
+		}
+
+	inline TBuf8<KMaxGenericTypeSize>& THeapWrapperHeader::GenericTransferTypeBuffer()
+	/** Getter for the generic type buffer
+	@return Reference to generic type buffer
+	*/
+		{
+		return iGenericDataTransferInfo;
+		}
+
+	
+	// Offsets for defining pointers relative the the RChunk::Base() pointer
+
+	/** Offset for the lock flag */
+	const TInt KHeaderOffset = 0;
+	
+	/** Offset to the beginning of the main descriptor */
+	const TInt KDescriptorOffset = KHeaderOffset + sizeof(THeapWrapperHeader); // lock flag is 1 byte
+	
+	/** Offset to the data that the TPtr8 will point to */
+	const TInt KDataOffset = KDescriptorOffset + sizeof(TPtr8);
+	
+	class CHeapWrapper : public CBase
+	/**
+	This class is instantiated to ensure that data is passed over the Global Shared Heap 
+	by a common interface
+	
+	@internalTechnology
+	*/
+		{
+	public:
+		static CHeapWrapper* NewL();
+		TPtrC8& ReadBufferL(const RChunk& aChunk);
+		TPtr8& WriteBufferL(const RChunk& aChunk);
+		TInt ResetHeap(const RChunk& aChunk);
+		THeapWrapperHeader& Header(const RChunk& aChunk) const;
+
+		/** virtual C++ destructor */
+		~CHeapWrapper();
+	private:
+		/** C++ constructor initialises read buffer pointer to NULL*/
+		CHeapWrapper() : iReadBuf(NULL) {};
+
+		TPtr8& Buffer(const RChunk& aChunk);
+		void CleanReadBuffer();
+	private:
+		/** Pointer to the global buffer */
+		TPtrC8* iReadBuf; 
+		};
+
+	} // namespace conn
+
+#endif //__HEAPWRAPPER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sblog.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+* Logging utilities
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+
+#ifndef __SBLOG_H__
+#define __SBLOG_H__
+
+#include <flogger.h>
+#include <e32debug.h>
+
+/**
+@defgroup Log Log
+
+This module implements logging utilities. Information is currently
+logged via flogger, but this can be easily changed as logging is
+hidden by global macros.
+
+A nested namespace, log, contains the class and global function that
+performs the logging operations: TLog, OpenLog(), CloseLog() and TLog
+operator() - which accepts a variable number of arguments. There is
+macro for each of these functions.
+
+OpenLog() and CloseLog() must be called only once and this is done by
+MainL().
+*/ 
+
+namespace conn
+	{
+    
+	/** LOG CONTROL MACROS */
+
+    /** @{ */
+      
+    #if (defined(SBE_LOGGING_DEBUG_ONLY) && defined(_DEBUG)) || defined(SBE_LOGGING_DEBUG_AND_RELEASE)
+
+        #define SBE_LOGGING_ENABLED
+
+        namespace securebackuplog
+        /**
+        @ingroup Log
+            This namespace hides the internal of logging from the rest of the system.
+        */
+            {
+            void __LogRaw( TDes& aData );
+		    void __Log(TRefByValue<const TDesC> aFmt,...);	
+		    void __DebugDump( const TDesC& aFormat, const TUint8* aAddress, TInt aLength );
+	        }//securebackuplog
+
+        /** Logs a message */
+        #define __LOG(TXT)                              { _LIT(__KText,TXT); securebackuplog::__Log(__KText); }
+
+        /** Logs a message plus an additional value. The text must
+         contain an appropriate printf alike indication, e.g. %d if the additional
+        value is an integer. */
+        #define __LOG1(TXT, A)                          { _LIT(__KText,TXT); securebackuplog::__Log(__KText, A); }
+        #define __LOG2(TXT, A, B)                       { _LIT(__KText,TXT); securebackuplog::__Log(__KText, A, B); }
+        #define __LOG3(TXT, A, B, C )                   { _LIT(__KText,TXT); securebackuplog::__Log(__KText, A, B, C); }
+        #define __LOG4(TXT, A, B, C, D )                { _LIT(__KText,TXT); securebackuplog::__Log(__KText, A, B, C, D); }
+        #define __LOG5(TXT, A, B, C, D, E )             { _LIT(__KText,TXT); securebackuplog::__Log(__KText, A, B, C, D, E); }
+        #define __LOG6(TXT, A, B, C, D, E, F )          { _LIT(__KText,TXT); securebackuplog::__Log(__KText, A, B, C, D, E, F); }
+        
+        /** Logs data as ascii text (hex encoded) */
+        #define __LOGDATA(TXT, DATAPOINTER, LEN)        { _LIT(__KText,TXT); securebackuplog::__DebugDump(__KText, DATAPOINTER, LEN); }
+    
+    #else
+
+    	#define __LOG(TXT)
+        #define __LOG1(TXT, A)
+        #define __LOG2(TXT, A, B)
+        #define __LOG3(TXT, A, B, C )
+        #define __LOG4(TXT, A, B, C, D )
+        #define __LOG5(TXT, A, B, C, D, E )
+        #define __LOG6(TXT, A, B, C, D, E, F )
+        #define __LOGDATA(TXT, DATAPOINTER, LEN)
+    
+    #endif
+
+    /** @} */
+	
+	}//conn
+		
+#endif //__SBLOG_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbmain.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,76 @@
+/**
+* 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:
+* Main entry point in the process.
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+
+#ifndef __SBMAIN_H__
+#define __SBMAIN_H__
+
+#include <e32base.h>
+
+
+/** @mainpage Secure Backup Documentation
+
+This is the documentation for Secure Backup.
+
+
+@section UsingDoc How to use this documentation
+
+The documentation can be split into three logical groups and they are as follows:
+
+
+@par Secure Backup Modules
+
+@li @ref SBEServer  This is the Secure Backup Engine module documentation
+
+@li @ref ABServer  This is Active Backup module documentation
+
+*/
+
+
+/**
+@namespace conn
+
+This namespace is the global Symbian Connect namespace which encapsulates 
+all of the connectivity components within Symbian OS.
+*/
+
+namespace conn
+	{
+	
+	class CSBActiveScheduler : public CActiveScheduler
+	/**
+	@internalComponent
+    
+    The active scheduler for secure backup.
+	*/	
+		{
+		public:
+		    /** C++ Constructor */
+			CSBActiveScheduler() : CActiveScheduler() { }
+			void Error(TInt aError) const;
+		};
+	}	
+		
+	
+#endif //__SBMAIN_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbpackagedatatransfer.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,180 @@
+/**
+* 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:
+* Declaration of CPackageDataTransfer
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+
+#ifndef __PACKAGEDATATRANSFER_H__
+#define __PACKAGEDATATRANSFER_H__
+
+// System
+#include <e32base.h>
+#include <connect/sbtypes.h>
+#include <swi/sisregistryentry.h>
+#include <swi/sisregistrysession.h>
+#include <swi/backuprestore.h>
+
+// MContentHandler mix in class
+#include <xml/contenthandler.h>
+
+#include "sbebufferhandler.h"
+#include "sbedataownermanager.h"
+#include "sbedataowner.h"
+
+namespace conn
+	{
+	using namespace Swi;
+	// Forwards
+	class CSnapshotHolder;
+	
+	/** Class to store the state of the data owner
+    @internalComponent
+    */
+    class TPDState
+    	{
+    public:
+        TState          	iState; /*<! The current state of the DOM */
+        TDriveNumber    	iDriveNumber; /*<! The drive number for the current request */
+        TPackageDataType    iTransferType; /*<! The transfer type of the current request */
+    	};
+
+	/** A Package data owner
+	
+	@internalComponent
+	*/
+	class CPackageDataTransfer : public CBase, public MContentHandler
+		{
+	public:
+		static CPackageDataTransfer* NewL(TUid aPid, CDataOwnerManager* aDOM);
+		static CPackageDataTransfer* NewLC(TUid aPid, CDataOwnerManager* aDOM);
+		~CPackageDataTransfer();
+		
+		static TInt Compare(const CPackageDataTransfer& aFirst, const CPackageDataTransfer& aSecond);
+		static TBool Match(const CPackageDataTransfer& aFirst, const CPackageDataTransfer& aSecond);
+		
+		void GetExpectedDataSizeL(TPackageDataType aTransferType, TDriveNumber aDriveNumber, TUint& aSize);
+	    void SupplyDataL(TDriveNumber aDriveNumber, TPackageDataType aTransferType, TDesC8& aBuffer,
+	                     TBool aLastSection);
+	    void RequestDataL(TDriveNumber aDriveNumber, TPackageDataType aTransferType, TPtr8& aBuffer,
+	    				  TBool& aLastSection);
+		TUid PackageId() const;
+		TCommonBURSettings CommonSettingsL();
+	    TPassiveBURSettings PassiveSettingsL();
+	    TActiveBURSettings ActiveSettingsL();
+	    void GetDriveListL(TDriveList& aDriveList);
+	    void ParseL();
+	    void SetRegistrationFileL(const TDesC& aFileName);
+	    
+	    void GetPublicFileListL(TDriveNumber aDriveNumber, RFileArray& aFiles);
+	    void GetRawPublicFileListL(TDriveNumber aDriveNumber, RRestoreFileFilterArray& aRestoreFileFilter);
+	    
+	    // MContentHandler
+		void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode);
+		void OnEndDocumentL(TInt aErrorCode);
+		void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode);
+		void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode);
+		void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
+		void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
+		void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
+		void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
+		void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
+		void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode);
+		void OnError(TInt aErrorCode);
+		TAny* GetExtendedInterface(const TInt32 aUid);
+		// MContentHandler
+		
+	    
+	private:
+		CPackageDataTransfer(TUid aPid, CDataOwnerManager* aDOM);
+		void ConstructL();
+		
+		void BuildPackageFileList();
+		void WriteData(TAny* aItem, TPtr8& aBuffer, TInt aSize);
+		void ReadData(TAny* aItem, const TDesC8& aBuffer, TInt aSize);
+	    void DoSupplyDataL(TDriveNumber aDriveNumber, const TDesC8& aBuffer, TBool aLastSection);
+		void SupplySnapshotL(TDriveNumber aDriveNumber, const TDesC8& aBuffer, TBool aLastSection);
+	    void DoRequestDataL(TDriveNumber aDriveNumber, TPtr8& aBuffer, TBool& aLastSection);
+		void RequestSnapshotL(TDriveNumber aDriveNumber, TPtr8& aBuffer, TBool& aLastSection);
+		void SupplyFileDataL( const TDesC8& aBuffer, TBool aLastSection);
+		void Cleanup();
+		TBool IsDataOnDrive(TDriveNumber aDrive);
+		
+		void ParseDirL(const TDesC& aDirName, const RArray<TPtrC>& aExclude, RFileArray& apFileEntries);
+		TBool IsExcluded(const TBool aIsPublic, const TDesC& aFileName, const RArray<TPtrC>& aExclude);
+		
+		// Element handlers 
+  		void HandleBackupRegistrationL(const RAttributeArray& aAttributes);
+  		void HandlePathL(const TSelectionType aType, const RAttributeArray& aAttributes, const TBool aDir);
+  		
+  		TInt HandlePublicBackup(const RAttributeArray& aAttributes);
+  		TInt HandleSystemBackup(const RAttributeArray& aAttributes);
+  		
+	private:
+		TUint8					iGotFileName; /*<! Have we got the filename */
+		TUint8					iFixedHeaderRead; /*<! Have we got the header information */
+		TUint8					iFileNameRead; /*<! Is the filename read */
+		RFile					iFileHandle; /*<! The file handle */
+		TUint8					iFileOpen; /*<! Is the file open */
+		TFileFixedHeader 		iFixedHeader; /*<! The fixed header */
+		HBufC*			 		iFileName; /*<! The file name */
+		HBufC*					iTempFileName; /*<! A tempory filename */
+		TPDState              	iState; /*<! The state of the object */
+		RFs						iFs; /*<! File system handle to use */
+		CBufferSnapshotReader* 	iBufferSnapshotReader; /*<! Handles writing snapshots to the buffer */
+		CBufferFileWriter*  	iBufferFileWriter; /*<! Handles reading files from the buffer */
+		CBufferSnapshotWriter* 	iBufferSnapshotWriter; /*<! Handles reading snapshots from the buffer */
+		TUid					iPackageID; /*<! The package id */
+		RRestoreSession			iSWIRestore; /*<! Handle to software restore */
+		RBackupSession			iSWIBackup; /*<! Handle to backup session */
+		
+        // Snapshots
+	    CSnapshotHolder*		iSnapshot; /*<! Holds a tempory snapshot */
+	    TDriveList			 	iDriveList; /*<! Drives on which pages exists */
+	    RPointerArray<HBufC>	iFiles; /*<! System files */
+	    HBufC8*					iMetaData; /*<! Meta data for a package */
+	    TPublicInformation		iPublicInformation; /*<! Public backup information */
+	    TSystemInformation		iSystemInformation; /*<! System backup information */
+	    
+	    ///////// FOR Parsing ////////////////
+	 	
+	 	/* Simple enumeration: What is our current element?
+		*/
+		enum TCurrentElement 	{ENoElement = 0, // No element 
+								 EPassive = 1, // Passive element 
+								 EPublic = 2 // Public element
+								};
+		
+		TCurrentElement			iCurrentElement; /*<! Current element */
+		
+		RSelections				iPublicSelections; /*<! Public selections */
+		HBufC*					iRegistrationFile; /*<! Path to registration file */
+		CDataOwnerManager*		ipDataOwnerManager; /*<! To access resources */
+		TUint8					iRestored; /*<! Used for speed optimization if we already restored this package */
+		TUint					iBytesRead; /*<! Number of bytes read */
+		TInt 					iMetaDataSize; /*<! Meta Data Size */
+		TInt 					iMetaDataLeft; /*<! Meta Data Size left to write */
+		};
+	} // namespace conn
+
+			
+
+#endif __PACKAGEDATATRANSFER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbshutdown.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,48 @@
+/**
+* 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:
+* Declaration of CSBShutdown class.
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+#ifndef __SBSHUTDOWN_H__
+#define __SBSHUTDOWN_H__
+
+namespace conn
+	{
+	class CSBShutdown : public CTimer
+	/**
+    @internalComponent
+	@ingroup Server
+
+	Timer class used to shutdown the server after a specific interval.
+	*/
+		{
+		public:
+			CSBShutdown();
+			void ConstructL();
+			void Start();
+
+		private:
+			void RunL();
+		};
+	}
+
+#endif //__SBSHUTDOWN_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/inc/sbtypes.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1020 @@
+/**
+* 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:
+* Declaration of Types and Constants for Secure Backup and Restore
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+#ifndef __SBTYPES_H__
+#define __SBTYPES_H__
+
+#include <connect/sbdefs.h>
+#include <e32cmn.h>
+#include <f32file.h>
+#include <connect/sbexternalisablearray.h>
+
+class RApaLsSession;
+
+namespace conn
+	{
+	/** Maximum length of package name
+	@released
+	@publishedPartner
+	*/
+	const TInt KMaxPackageNameLength = 128; // Arbitrary name length
+
+	/** Length of the 128 bit Java hash in bytes
+	@released
+	@publishedPartner
+	*/
+	const TInt KJavaIdLength = 16;
+
+	/** Used for unpacking unicode descriptors 
+	@released
+	@publishedPartner
+	*/
+	#ifdef UNICODE
+	const TInt KCharWidthInBytes = 2;
+	#else
+	const TInt KCharWidthInBytes = 1;
+	#endif // UNICODE
+	
+	/**
+	@released
+	@publishedPartner
+	*/
+	typedef TBufC<KMaxPackageNameLength> TPackageName;
+
+	enum TCommonBUROptions
+		/** 
+		The passive backup options
+
+		@released
+		@publishedPartner
+		*/
+		{
+		ENoOptions 				= 0x00000000, /*!< 0x00000000: no common options selected */
+		EActiveBUR				= 0x00000001, /*!< 0x00000001: Does the data owner do active backup / restore? */
+		EPassiveBUR				= 0x00000002, /*!< 0x00000002: Does the data owner do passive backup / restore? */
+		EHasSystemFiles 		= 0x00000004, /*!< 0x00000004: Does the data owner want system files backed up? */
+		ESupportsSelective		= 0x00000008, /*!< 0x00000008: Can the data owner do BUR selectively? */
+		ERequiresReboot			= 0x00000010  /*!< 0x00000010: Does the data owner require reboot after restore? */
+		};
+	
+	enum TPassiveBUROptions
+		/** 
+		The passive backup options
+
+		@released
+		@publishedPartner
+		*/
+		{
+		ENoPassiveOptions 		= 0x00000000, /*!< 0x00000000: no passive options selected */
+		EHasPublicFiles			= 0x00000001, /*!< 0x00000001: data owner has public files to BUR ? */
+		EDeleteBeforeRestore	= 0x00000002, /*!< 0x00000002: data owner requires a delete before restore ? */
+		EPassiveSupportsInc 	= 0x00000004  /*!< 0x00000004: data owner supports incremental BUR ? */
+		};
+	
+	enum TActiveBUROptions
+		/** 
+		The active backup options
+
+		@released
+		@publishedPartner
+		*/
+		{
+		ENoActiveOptions 		= 0x00000000, /*!< 0x00000000: no active backup options selected */
+		EDelayToPrepareData 	= 0x00000001, /*!< 0x00000001: data owner slow to prepare active data */
+		EActiveSupportsInc		= 0x00000002  /*!< 0x00000002: data owner supports incremental BUR ? */
+		};
+		
+	/**	Common BUR Settings
+	This structure will store the common backup and restore options for a SID 
+	@released
+	@publishedPartner	
+	*/
+	typedef TUint32 TCommonBURSettings;
+	
+	/**	Passive BUR Settings
+	This structure will store the passive backup and restore options for a SID 
+	@released
+	@publishedPartner	
+	*/	
+	typedef TUint32 TPassiveBURSettings;
+	
+	/**	Active BUR Settings
+	This structure will store the active backup and restore options for a SID 
+	@released
+	@publishedPartner	
+	*/
+	typedef TUint32 TActiveBURSettings;
+
+	class TRestoreFileFilter
+		/**
+		TRestoreFileFilter packages up a file or directory name and an include or exclude flag.
+
+		This type is used when telling a client during a restore operation which public files are
+		to be restored for a specific data owner.
+
+		@released
+		@publishedPartner
+		*/
+		{
+	public:
+		/**
+		Constructor
+		
+		@param aInclude ETrue if the file or directory is to be
+						included, EFalse for exclusion
+		@param aName The name of the file or directory (directory
+					 names end with a slash)
+		*/
+		TRestoreFileFilter(TBool aInclude, const TFileName& aName)
+			: iInclude(aInclude), iName(aName) {}
+	public:
+		TBool iInclude ; /*!< ETrue if the file or directory is to be included, EFalse for exclusion */
+		TFileName iName; /*!< The name of the file or directory (directory names end with a slash) */
+		};
+
+	/** Array of TEntry objects
+	@released
+	@publishedPartner
+	*/
+	typedef RExternalisableArray<TEntry> RFileArray;
+
+	/** Array of TRestoreFileFilter objects 
+	@released
+	@publishedPartner
+	*/
+	typedef RExternalisableArray<TRestoreFileFilter> RRestoreFileFilterArray;
+
+	/** Array of TSecureId objects
+	@released
+	@publishedPartner
+	*/
+	typedef RExternalisableArray<TSecureId> RSIDArray;
+
+	enum TDataOwnerStatus
+		/**
+		TDataOwnerStatus encapsulates the status of a data owner.
+
+		@released
+		@publishedPartner
+		*/
+		{
+		EUnset = 0, /*!< 0x00000000: Unset - allows creation of object without incorrect status */
+		EDataOwnerNotFound = 1, /*!< 0x00000001: Data owner not found in registration files */
+		EDataOwnerReady = 2, /*!< 0x00000002: Data owner ready for backup / restore */
+		EDataOwnerNotReady = 3, /*!< 0x00000003: Data owner not yet ready for backup / restore */
+		EDataOwnerFailed = 4, /*!< 0x00000004: Data owner failed to become ready */
+		EDataOwnerNotConnected = 5, /*!< 0x00000005: Data owner alive, but not fully ready */
+		EDataOwnerReadyNoImpl = 6 /*!< 0x00000006: Data owner ready for backup / restore but does not provide callback implementation */
+		};
+
+	class TDataOwnerAndStatus
+		/**
+		TDataOwnerAndStatus encapsulates the identity and status of a data owner.
+		Access to members is direct.
+
+		@released
+		@publishedPartner
+		*/
+		{
+	public:
+		/**
+		Constructor
+		
+		@param aSID Data owner secure id - identifies the data owner
+		@param aStatus Status of the data owner
+		@param aDataOwnerError Error code if data owner failed to be ready
+							   or KErrNone
+		*/
+		TDataOwnerAndStatus(TSecureId aSID, TDataOwnerStatus aStatus, TInt aDataOwnerError)
+			: iSID(aSID), iStatus(aStatus), iDataOwnerError(aDataOwnerError) {}
+	public:
+		TSecureId iSID; /*!< Data owner secure id - identifies the data owner */
+		TDataOwnerStatus iStatus; /*!< Status of the data owner */
+		TInt iDataOwnerError; /*!< Error code if data owner failed to be ready or KErrNone */
+		};
+
+	/** Array of data owners with their status
+	@released
+	@publishedPartner
+	*/
+	typedef RExternalisableArray<TDataOwnerAndStatus> RSIDStatusArray;
+
+	enum TBackupDataType
+		/**
+		TBackupDataType indicates whether a specific data stream or operation relates to active or
+		passive backup or restore.  A specific data owner can use both active and passive and so we
+		need to differentiate between operations.
+
+		@released
+		@publishedPartner
+		*/
+		{
+		EActive = 0, /*!< 0x00000000: The backup or restore operation is active rather than passive */
+		EPassive = 1 /*!< 0x00000001: The backup or restore operation is passive rather than active */
+		};
+
+	enum TTransferDataType
+		/**
+		TTransferDataType indicates the type of data being transferred from the Secure Backup
+		Engine to the Secure Backup Server or vice versa.
+
+		@released
+		@publishedPartner
+		*/
+		{
+		ERegistrationData = 0, /*!< 0x00000000: deprecated */
+		EPassiveSnapshotData = 1, /*!< 0x00000001: The data is a snapshot for passive backup that includes file details*/
+		EPassiveBaseData = 2, /*!< 0x00000002: The data is passively backup up private data with no previous history */
+		EPassiveIncrementalData = 3, /*!< 0x00000003: The data is passively backed up private data as an increment on a previous base backup */
+		EActiveSnapshotData = 4, /*!< 0x00000004: The data is a snapshot for active backup that includes file details*/
+		EActiveBaseData = 5, /*!< 0x00000005: The data is actively backup up private data with no previous history */
+		EActiveIncrementalData = 6, /*!< 0x00000006: The data is actively backed up private data as an increment on a previous base backup */
+		ECentralRepositoryData = 7, /*!< 0x00000007: deprecated */
+		EPublicFileListing = 8, /*!< 0x00000008: An externalised list of public file entries belonging to a single data owner */
+		};
+		
+	enum TSBDerivedType
+		/**
+		Used to identify the derived type that the base generic type represents
+		
+		@deprecated
+		@publishedPartner
+		*/
+		{
+		ESIDDerivedType = 0, /*!< 0x00000000: SID derived type  */
+		EPackageDerivedType = 1, /*!< 0x00000001: Package derived type */
+		ESIDTransferDerivedType = 2, /*!< 0x00000002: SID data transfer derived type  */
+		EPackageTransferDerivedType = 3, /*!< 0x00000003: Package data transfer derived type */
+		EJavaDerivedType = 4, /*!< 0x00000004: Java ID derived type */
+		EJavaTransferDerivedType = 5, /*!< 0x00000005: Java ID derived type */
+		};
+		
+		/**
+		Maximum number of derived types specified in TSBDerivedType
+
+		@released
+		@publishedPartner
+		*/
+	const TUint KMaxDerivedTypes = 6;	
+		
+	enum TPackageDataType
+		/**
+		TPackageDataType indicates the type of package data being
+		transferred from the Secure Backup Engine to the Secure Backup
+		Server or vice versa.
+
+		@deprecated
+		@publishedPartner
+		*/
+		{
+		ESystemData = 0, /*!< 0x00000000: The data is system files (typically executables or resource files) */
+		ESystemSnapshotData = 1, /*!< 0x00000001: The data is a snapshot for system files */
+		};
+		
+	enum TJavaTransferType
+		/**
+		This enum defines the type of Java data that is being transferred and can indicate either a MIDlet 
+		suite archive (Jad/Jar etc.) or data for an installed MIDlet suite
+		
+		@released
+		@publishedPartner
+		*/
+		{
+		EJavaMIDlet = 0,
+		EJavaMIDletData = 1,
+		};
+
+	enum TTransferDirection
+		/**
+		TTransferDirection indicates whether a (just completed) data transfer is from the
+		Secure Backup Server to a data owner or vice versa.
+
+		@released
+		@publishedPartner
+		*/
+		{
+		EServerToDataOwner = 0, /*!< 0x00000000: The transfer is from the Secure Backup Server to a data owner */
+		EDataOwnerToServer = 1/*!< 0x00000001: The transfer is from a data owner to the Secure Backup Server */
+		};
+		
+	/** Generic Data Type is a class for representing any type of data owner so that it 
+	may be passed through a common interface
+		
+	<H2>Introduction</H2>
+	
+	The CSBEClient Secure backup interface class is designed to perform backup operations 
+	on many different types of data owners. This presents a problem in that the interfaces 
+	sometimes require arguments that are specific to the data type in question. In addition, 
+	we can't predict the new data types that may appear in future, therefore a "generic" data 
+	type was proposed that could be passed through interfaces as a base class and contained 
+	enough information to enable Runtime Type Identification (RTTI) to be performed.
+	
+	This approach means that only one interface needs to be maintained for each backup 
+	operation whilst still allowing the Secure Backup Engine to determine which type was 
+	originally sent by a PC client.
+	
+	As well as acting as an identifier for different Data Owner's (DO's), it was decided 
+	to extend the usage of the class to identify Data Owner's Data as each DO may require 
+	specific information to identify data being transferred (such as finished flags etc.)
+	
+	The identifier is transparent to the user of CSBEClient, meaning that it can be 
+	extracted directly from the message sent by the PC into a generic type and passed through 
+	to the SBEngine without being instantiated as a derived class.
+	
+	<H2>Usage</H2>
+	
+	The general usage of the generic data type is to extract it from a PC sent message as a 
+	CSBGenericDataType object using CSBGenericDataType::NewL(const TDesC8& aDes).
+	
+	There are a few conventions that have been followed within the Secure Backup component 
+	that a developer must bear in mind:
+	
+	@li Ownership of the CSBGenericDataType, CSBGenericTransferType or derived 
+		object is generally passed between interfaces and as such it is the resposibility 
+		of the receiving function to delete it. Unless otherwise stated in the documentation
+		for an interface, this is assumed to be the case;
+		
+	@li When a CSBGenericDataType or CSBGenericTransferType is to be converted into 
+		a derived type, it must be passed in as a parameter to the constructor of the derived 
+		type. It must not be downcasted as it may never have been a derived type, and the 
+		derived types contain extra member data;
+		
+	In order to convert a base type to a derived type, a method CSBGenericDataType::DerivedTypeL() 
+	that returns a conn::TSBDerivedType can be called to query the base object for it's derived type.
+	
+	A typical mechanism would be to use a switch statement, switching on the return value of 
+	DerivedTypeL() and taking appropriate action with regards to creating a derived object.
+		
+	<H2>Internal Operation</H2>
+	
+	<H3>Initialisation</H3>
+	
+	CSBGenericDataType is underneath basically a descriptor buffer. All accessor functions 
+	simply extract and pack values from this descriptor. This means that the type can be 
+	safely transferred via IPC between processes and safely transferred between a device 
+	and a PC independently of communications bearer or transport.
+	
+	The base class CSBGenericDataType has ownership of the data buffer, iDataBuffer, used 
+	to store the member data in and in order to keep the derived classes atomic, a running 
+	total size variable is updated by the C++ constructors of each class in the inheritence 
+	chain. Because of Symbian's static NewL idiom, all C++ constructors are executed before 
+	CSBGenericDataType::ConstructL() is called to instantiate the buffer, hence the size 
+	can be guaranteed to be big enough to hold all of the derived type's data.
+	
+	In order to ensure that the derived types know whereabouts in the descriptor to extract 
+	and pack values, an initialisation routine, InitialiseL(TInt& aOffset), is implemented 
+	by each class. Each class is responsible for calling it's parents InitialiseL(), before 
+	initialising itself and passing in an offset. The job of the initialisation method is 
+	to walk the descriptor, storing the offset's of it's member data. The offset is a 
+	reference and is hence updated so that the child class begins unpacking after the parents 
+	data ends. In this way, each class is atomic apart from having to explicitly scope it's 
+	parent's InitialiseL() method.
+	
+	<H3>Accessing Data</H3>
+	
+	Data is accessed by the use of packing and unpacking bytes directly from the descriptor 
+	using the UnpackType, PackType and associated function templates. These will be unpacked 
+	in the endianness of the system and therefore the PC will have to ensure that this 
+	is taken into account when packing the type into the message.
+	
+	Although this method suffers in terms of performance, for the reasons of platform 
+	independence, this is the most reliable method of packing/unpacking.
+	
+	<H2>Byte Structure</H2>
+	
+	All child classes have their data following on from the parent classes so that the parent 
+	classes may remain atomic with respect to the structure of their data. The binary structure 
+	of this data type inside the descriptor buffer is as follows. Note that the endianness of 
+	the data types specified below is determined by the platform and the PC must pack accordingly:
+		
+	<table border="1">
+		<tr>
+			<td>TSBDerivedType [4-bytes]</td>
+		</tr>
+	</table>
+
+
+	@deprecated
+	@publishedPartner
+	*/
+	class CSBGenericDataType : public CBase
+		{
+	public:
+		IMPORT_C static CSBGenericDataType* NewL(const TDesC8& aDes);
+		IMPORT_C ~CSBGenericDataType();
+		IMPORT_C const TDesC8& Externalise() const;
+		IMPORT_C TSBDerivedType DerivedTypeL() const;
+		
+	protected:
+		CSBGenericDataType();
+		void ConstructL(const TDesC8& aDes);
+		void BaseConstructL();
+		virtual void InitialiseL(TInt& aOffset);
+		void UnpackDescriptorTypeAdvance(TDesC16& aDes, TInt& aOffset);
+		void UnpackDescriptorTypeAdvance(TDesC8& aDes, TInt& aOffset);
+		void UnpackTPtrAdvance(TPtrC16& aDes, TInt& aOffset);
+		void UnpackTPtrAdvance(TPtrC8& aDes, TInt& aOffset);
+		void PackDescriptorTypeAdvance(const TDesC16& aDes, TInt& aOffset);
+		void PackDescriptorTypeAdvance(const TDesC8& aDes, TInt& aOffset);
+
+	protected:
+		/** the data buffer */
+		HBufC8* iDataBuffer;
+
+		/** Cumulative size of the derived type. All ctors in the inheritence tree increment 
+		with their size */
+		TInt iSize;
+
+		/** the derived type */
+		TInt iDerivedTypeOffset;
+		};
+		
+	template<class T> inline void UnpackType(T& aType, TDesC8& aDes, TInt aOffset)
+		/**
+		Templated function to copy a simple type from a specified position in aDes
+		defined by aOffset. aOffset is not updated on return.
+		
+		@param aType This pointer is set with the pointer to the type in aDes
+		@param aDes The buffer that contains the type T pointed to by aPtr
+		@param aOffset The running index of where the following type begins. Updated by ExtractPointer
+		*/
+		{
+		// Set the position at which to finish copying
+		TInt endOffset = aOffset + sizeof(T);
+		
+		TUint8* pRawType = reinterpret_cast<TUint8*>(&aType);
+		TUint8* pRawSource = const_cast<TUint8*>(aDes.Ptr()) + aOffset;
+		
+		for (TInt offset = aOffset; offset < endOffset; offset++)
+			{
+			*pRawType++ = *pRawSource++;
+			}
+		}
+		
+	template<class T> inline void UnpackTypeAdvance(T& aType, TDesC8& aDes, TInt& aOffset)
+		/**
+		Templated function to copy a simple type from a specified position in aDes
+		defined by aOffset. aOffset is advanced so that on return, the new 
+		offset is stored enabling the next call to UnpackType() to point at the position 
+		following this type.
+		
+		@param aType This pointer is set with the pointer to the type in aDes
+		@param aDes The buffer that contains the type T pointed to by aPtr
+		@param aOffset The running index of where the following type begins. Updated by ExtractPointer
+		*/
+		{
+		// Set the position at which to finish copying
+		TInt endOffset = aOffset + sizeof(T);
+		
+		TUint8* pRawType = reinterpret_cast<TUint8*>(&aType);
+		TUint8* pRawSource = const_cast<TUint8*>(aDes.Ptr()) + aOffset;
+		
+		for (; aOffset < endOffset; aOffset++)
+			{
+			*pRawType++ = *pRawSource++;
+			}
+		}
+
+	template<> inline void UnpackTypeAdvance(TDriveList& aType, TDesC8& aDes, TInt& aOffset)
+		/**
+		Templated function to copy a simple type from a specified position in aDes
+		defined by aOffset. aOffset is advanced so that on return, the new 
+		offset is stored enabling the next call to UnpackType() to point at the position 
+		following this type.
+		
+		@param aType This pointer is set with the pointer to the type in aDes
+		@param aDes The buffer that contains the type T pointed to by aPtr
+		@param aOffset The running index of where the following type begins. Updated by ExtractPointer
+		*/
+		{
+		TUint8* pRawSource = const_cast<TUint8*>(aDes.Ptr()) + aOffset;
+		
+		aType.SetMax();
+		
+		for (TInt index = 0; index < KMaxDrives; index++)
+			{
+			aType[index] = *pRawSource++;
+			}
+
+		aOffset += KMaxDrives;
+		}
+		
+	template<class T> inline void PackType(T& aType, TDesC8& aDes, TInt aOffset)
+		/**
+		Templated function to copy a simple type into a specified position in aDes
+		defined by aOffset. aOffset is not advanced as a result of this operation
+		
+		@param aType This object is overwritten with the flattened type in aDes
+		@param aDes The buffer that contains the type T pointed to by aPtr
+		@param aOffset The running index of where the following type begins. Updated by ExtractPointer
+
+		@return The new offset after packing the data type
+		*/
+		{
+		// Set the position at which to finish copying
+		TInt endOffset = aOffset + sizeof(T);		
+		
+		TUint8* pRawType = reinterpret_cast<TUint8*>(&aType);
+		TUint8* pRawBuf = const_cast<TUint8*>(aDes.Ptr()) + aOffset;
+		
+		for (TInt offset = aOffset; offset < endOffset; offset++)
+			{
+			*pRawBuf++ = *pRawType++;
+			}
+		}
+
+	template<class T> inline void PackTypeAdvance(T& aType, TDesC8& aDes, TInt& aOffset)
+		/**
+		Templated function to copy a simple type into a specified position in aDes
+		defined by aOffset. aOffset is updated to reflect the advance along aDes
+		
+		@param aType This object is overwritten with the flattened type in aDes
+		@param aDes The buffer that contains the type T pointed to by aPtr
+		@param aOffset The running index of where the following type begins. Updated by ExtractPointer
+
+		@return The new offset after packing the data type
+		*/
+		{
+		// Set the position at which to finish copying
+		TInt endOffset = aOffset + sizeof(T);		
+		
+		TUint8* pRawType = reinterpret_cast<TUint8*>(&aType);
+		TUint8* pRawBuf = const_cast<TUint8*>(aDes.Ptr() + aOffset);
+		
+		for (; aOffset < endOffset; aOffset++)
+			{
+			*pRawBuf++ = *pRawType++;
+			}
+		}
+		
+
+	/** Generic Data Type representing a data owner identified by a SecureId
+	
+	<H2>Byte Structure</H2>
+	
+	All child classes have their data following on from the parent classes so that the parent 
+	classes may remain atomic with respect to the structure of their data. The binary structure 
+	of this data type inside the descriptor buffer is as follows. Note that the endianness of 
+	the data types specified below is determined by the platform and the PC must pack accordingly:
+		
+	<table border="1">
+		<tr>
+			<td>TSBDerivedType [4-bytes]</td>
+			<td>TSecureId [4-bytes]</td>
+		</tr>
+	</table>
+		
+	@deprecated
+	@publishedPartner
+	*/
+	class CSBSecureId : public CSBGenericDataType
+		{
+	public:
+		IMPORT_C static CSBSecureId* NewL(TSecureId aSecureId);
+		IMPORT_C static CSBSecureId* NewL(CSBGenericDataType* aGenericDataType);
+		IMPORT_C ~CSBSecureId();
+		IMPORT_C TSecureId SecureIdL() const;
+		
+	protected:
+		void InitialiseL(TInt& aOffset);
+
+	private:
+		CSBSecureId();
+		void ConstructL(TSecureId aSecureId);
+		void ConstructL(CSBGenericDataType* aGenericDataType);
+		
+	private:
+		/** the secure identifier */
+		TInt iSecureIdOffset;
+		};
+		
+	/** Generic Data Type representing a data owner identified by a Package Id, Secure Id and 
+	Package Name. Package Id's are used to represent multiple SID's installed under a single 
+	package. There would potentially be several CSBPackageId's associated with a package, each 
+	detailing a single SID.
+
+	<H2>Byte Structure</H2>
+	
+	All child classes have their data following on from the parent classes so that the parent 
+	classes may remain atomic with respect to the structure of their data. The binary structure 
+	of this data type inside the descriptor buffer is as follows. Note that the endianness of 
+	the data types specified below is determined by the platform and the PC must pack accordingly:
+
+	<table border="1">
+		<tr>
+			<td>TSBDerivedType [4-bytes]</td>
+			<td>TUid [4-bytes]</td>
+			<td>TSecureId [4-bytes]</td>
+			<td>Pkg name length [4-bytes]</td>
+			<td>Pkg name data [variable]</td>
+		</tr>
+	</table>
+
+	@deprecated
+	@publishedPartner
+	*/
+	class CSBPackageId : public CSBGenericDataType
+		{
+	public:
+		IMPORT_C static CSBPackageId* NewL(TUid aPackageId, TSecureId aSecureId, const TDesC& aPackageName);
+		IMPORT_C static CSBPackageId* NewL(CSBGenericDataType* aGenericDataType);
+		IMPORT_C ~CSBPackageId();
+		IMPORT_C TUid PackageIdL() const;
+		IMPORT_C TSecureId SecureIdL() const;
+		IMPORT_C TPackageName PackageNameL() const;
+		
+	protected:
+		void InitialiseL(TInt& aOffset);
+		void InitialiseL(TInt& aOffset, TInt aPackageNameLength);
+
+	private:
+		CSBPackageId();
+		void ConstructL(TUid aPackageId, TSecureId aSecureId, const TDesC& aPackageName);
+		void ConstructL(CSBGenericDataType* aGenericDataType);
+		
+	private:
+		/** the package identifier */
+		TInt iPackageIdOffset;
+		/** the secure identifier */
+		TInt iSecureIdOffset;
+		/** user-readable name for the package */
+		TInt iPackageNameOffset;
+		};
+
+	/** Generic Transfer Type
+	
+	This is also a semi-abstract class similar to the CSBGenericDataType in that logically it may 
+	only be instantiated by being internalised from a descriptor. This class and classes that derive 
+	from it are intended to identify a data transfer to or from a particular data owner.
+	
+	<H2>Byte Structure</H2>
+	
+	All child classes have their data following on from the parent classes so that the parent 
+	classes may remain atomic with respect to the structure of their data. The binary structure 
+	of this data type inside the descriptor buffer is as follows. Note that the endianness of 
+	the data types specified below is determined by the platform and the PC must pack accordingly:
+
+	<table border="1">
+		<tr>
+			<td>TSBDerivedType [4-bytes]</td>
+			<td>TDriveNumber [4-bytes]</td>
+		</tr>
+	</table>
+	
+	@deprecated
+	@publishedPartner
+	*/	
+	class CSBGenericTransferType : public CSBGenericDataType
+		{
+	public:
+		IMPORT_C static CSBGenericTransferType* NewL(const TDesC8& aDes);
+		IMPORT_C ~CSBGenericTransferType();
+		IMPORT_C TDriveNumber DriveNumberL() const;
+		
+	protected:
+		CSBGenericTransferType();
+		virtual void InitialiseL(TInt& aOffset);
+	
+	protected:
+		/** the drive number */
+		TInt iDriveNumberOffset;		
+		};
+
+	/** SID Transfer type is used to identify data associated with a particular SID
+	
+	<H2>Byte Structure</H2>
+	
+	All child classes have their data following on from the parent classes so that the parent 
+	classes may remain atomic with respect to the structure of their data. The binary structure 
+	of this data type inside the descriptor buffer is as follows. Note that the endianness of 
+	the data types specified below is determined by the platform and the PC must pack accordingly:
+
+	<table border="1">
+		<tr>
+			<td>TSBDerivedType [4-bytes]</td>
+			<td>TDriveNumber [4-bytes]</td>
+			<td>TSecureId [4-bytes]</td>
+			<td>TTransferDataType [4-bytes]</td>
+		</tr>
+	</table>
+
+	@deprecated
+	@publishedPartner
+	*/
+	class CSBSIDTransferType : public CSBGenericTransferType
+		{
+	public:
+		IMPORT_C static CSBSIDTransferType* NewL(TSecureId aSecureId, TDriveNumber aDriveNumber, TTransferDataType aTransferDataType);
+		IMPORT_C static CSBSIDTransferType* NewL(CSBGenericTransferType* aGenericTransferType);
+		IMPORT_C ~CSBSIDTransferType();
+		IMPORT_C TSecureId SecureIdL() const;
+		IMPORT_C TTransferDataType DataTypeL() const;
+		
+	protected:
+		void InitialiseL(TInt& aOffset);
+
+	private:
+		CSBSIDTransferType();
+		void ConstructL(TSecureId aSecureId, TDriveNumber aDriveNumber, TTransferDataType aTransferDataType);
+		void ConstructL(CSBGenericTransferType* aGenericTransferType);
+		
+	private:
+		/** the secure identifier */
+		TInt iSecureIdOffset;
+		/** the transfer data type */
+		TInt iTransferDataTypeOffset;
+		};
+
+	/** Package Transfer Type is used to identify data related to a particular Package ID
+	
+	<H2>Byte Structure</H2>
+	
+	All child classes have their data following on from the parent classes so that the parent 
+	classes may remain atomic with respect to the structure of their data. The binary structure 
+	of this data type inside the descriptor buffer is as follows. Note that the endianness of 
+	the data types specified below is determined by the platform and the PC must pack accordingly:
+
+	<table border="1">
+		<tr>
+			<td>TSBDerivedType [4-bytes]</td>
+			<td>TDriveNumber [4-bytes]</td>
+			<td>TUid [4-bytes]</td>
+			<td>TPackageDataType [4-bytes]</td>
+		</tr>
+	</table>
+
+	@deprecated
+	@publishedPartner
+	*/
+	class CSBPackageTransferType : public CSBGenericTransferType
+		{
+	public:
+		IMPORT_C static CSBPackageTransferType* NewL(TUid aPackageId, TDriveNumber aDriveNUmber, TPackageDataType aPackageDataType);
+		IMPORT_C static CSBPackageTransferType* NewL(CSBGenericTransferType* aGenericTransferType);
+		IMPORT_C ~CSBPackageTransferType();
+		IMPORT_C TUid PackageIdL() const;
+		IMPORT_C TPackageDataType DataTypeL() const;
+		
+	protected:
+		void InitialiseL(TInt& aOffset);
+
+	private:
+		CSBPackageTransferType();
+		void ConstructL(TUid aPackageId, TDriveNumber aDriveNumber, TPackageDataType aPackageDataType);
+		void ConstructL(CSBGenericTransferType* aGenericTransferType);
+		
+	private:
+		/** the package identifier */
+		TInt iPackageIdOffset;
+		/** the package data type */
+		TInt iPackageDataTypeOffset;
+		};
+		
+	class CDataOwnerInfo : public CBase
+		/** 
+		CDataOwnerInfo packages up information for the backup / restore client on an
+		individual data owner.
+
+		Access to the data members is direct.
+
+		@deprecated
+		@publishedPartner
+		*/
+		{
+	public:								  
+		IMPORT_C static CDataOwnerInfo* NewL( CSBGenericDataType* aGenericDataType,
+											  TCommonBURSettings aCommonSettings,
+											  TPassiveBURSettings aPassiveSettings,
+											  TActiveBURSettings aActiveSettings,
+											  const TDriveList& aDriveList );
+											  
+		IMPORT_C static CDataOwnerInfo* NewL ( const TDesC8& aFlatDataOwnerInfo );
+		IMPORT_C ~CDataOwnerInfo();
+		IMPORT_C CSBGenericDataType& Identifier();
+		IMPORT_C const CSBGenericDataType& Identifier() const;
+		IMPORT_C TCommonBURSettings CommonSettings() const;
+		IMPORT_C TPassiveBURSettings PassiveSettings() const;
+		IMPORT_C TActiveBURSettings ActiveSettings() const;
+		IMPORT_C TDriveList& DriveList();
+		IMPORT_C const TDriveList& DriveList() const;
+		IMPORT_C HBufC8* ExternaliseL();
+		IMPORT_C TInt Size() const;
+		IMPORT_C HBufC8* ExternaliseLC();
+
+	private:
+		CDataOwnerInfo();
+		void ConstructL(CSBGenericDataType* aGenericDataType, TCommonBURSettings aCommonSettings,
+						TPassiveBURSettings aPassiveSettings, TActiveBURSettings aActiveSettings,
+						const TDriveList& aDriveList);
+		void ConstructL(const TDesC8& aFlatDataOwnerInfo);
+
+	private:
+		CSBGenericDataType* iGenericDataType; /*!< generic data type object */
+		TCommonBURSettings iCommonBURSettings; /*!< flags for storing common backup and restore settings */
+		TPassiveBURSettings iPassiveBURSettings; /*!< flags for storing passive backup and restore settings */
+		TActiveBURSettings iActiveBURSettings; /*!< flags for storing active backup and restore settings */
+		TDriveList iDriveList; /*!< List of drives that the data owner has data on */
+		};
+
+	/** Generic Data Type representing a MIDlet data owner identified by a Suite Name, Vendor Name, 
+	Version and a unique MIDlet Suite Hash. The Suite Hash should be used as the unique identifier for 
+	the MIDlet suite.
+
+	<H2>Byte Structure</H2>
+	
+	All child classes have their data following on from the parent classes so that the parent 
+	classes may remain atomic with respect to the structure of their data. The binary structure 
+	of this data type inside the descriptor buffer is as follows. Note that the endianness of 
+	the data types specified below is determined by the platform and the PC must pack accordingly:
+
+	<table border="1">
+		<tr>
+			<td>TSBDerivedType [4-bytes]</td>
+			<td>MIDlet suite name length [4-bytes]</td>
+			<td>MIDlet suite name [2*length]</td>
+			<td>MIDlet suite vendor length [4-bytes]</td>
+			<td>MIDlet suite vendor [2*length]</td>
+			<td>MIDlet suite version length [4-bytes]</td>
+			<td>MIDlet suite version [2*length]</td>
+			<td>MIDlet suite hash length [4-bytes] (should be 32)</td>
+			<td>MIDlet suite hash [2*length]</td>
+		</tr>
+	</table>
+
+	@deprecated
+	@publishedPartner
+	*/
+	class CSBJavaId : public CSBGenericDataType
+		{
+	public:
+		IMPORT_C static CSBJavaId* NewL(const TDesC& aSuiteName, const TDesC& aSuiteVendor,const TDesC& aSuiteVersion, const TDesC& aSuiteHash);
+		IMPORT_C static CSBJavaId* NewL(CSBGenericDataType* aGenericDataType);
+		IMPORT_C ~CSBJavaId();
+		IMPORT_C const TDesC& SuiteNameL() const;
+		IMPORT_C const TDesC& SuiteVendorL() const;
+		IMPORT_C const TDesC& SuiteVersionL() const;
+		IMPORT_C const TDesC& SuiteHashL() const;
+		
+	protected:
+		void InitialiseL(TInt& aOffset);
+		void InitialiseL(TInt& aOffset, const TDesC& aSuiteName, const TDesC& aSuiteVendor,const TDesC& aSuiteVersion, const TDesC& aSuiteHash);
+
+	private:
+		CSBJavaId();
+		CSBJavaId(const TDesC& aSuiteName, const TDesC& aSuiteVendor,const TDesC& aSuiteVersion, const TDesC& aSuiteHash);
+		void ConstructL(const TDesC& aSuiteName, const TDesC& aSuiteVendor,const TDesC& aSuiteVersion, const TDesC& aSuiteHash);
+		void ConstructFromExistingL(CSBGenericDataType* aGenericDataType);
+		
+	private:
+		/** The MIDlet suite Name */
+		TPtrC iSuiteName;
+		
+		/** The MIDlet suite Vendor */
+		TPtrC iSuiteVendor;
+		
+		/** The MIDlet suite Version */
+		TPtrC iSuiteVersion;
+
+		/** The MIDlet suite Hash */
+		TPtrC iSuiteHash;
+		};
+
+	/** The Java Transfer Type identifies types of data belonging to particular MIDlet suites (identified 
+	by the Suite Hash)
+	
+	<H2>Byte Structure</H2>
+	
+	All child classes have their data following on from the parent classes so that the parent 
+	classes may remain atomic with respect to the structure of their data. The binary structure 
+	of this data type inside the descriptor buffer is as follows. Note that the endianness of 
+	the data types specified below is determined by the platform and the PC must pack accordingly:
+
+	<table border="1">
+		<tr>
+			<td>TSBDerivedType [4-bytes]</td>
+			<td>TDriveNumber [4-bytes]</td>
+			<td>TJavaTransferType [4-bytes]</td>
+			<td>MIDlet suite hash length [4-bytes] (should be 32)</td>
+			<td>MIDlet suite hash [2*length]</td>
+		</tr>
+	</table>
+
+	@deprecated
+	@publishedPartner
+	*/
+	class CSBJavaTransferType : public CSBGenericTransferType
+		{
+	public:
+		IMPORT_C static CSBJavaTransferType* NewL(const TDesC& aSuiteHash, TDriveNumber aDriveNumber, TJavaTransferType aTransferDataType);
+		IMPORT_C static CSBJavaTransferType* NewL(CSBGenericTransferType* aGenericTransferType);
+		IMPORT_C ~CSBJavaTransferType();
+		IMPORT_C const TDesC& SuiteHashL() const;
+		IMPORT_C TJavaTransferType DataTypeL() const;
+		
+	protected:
+		void InitialiseL(TInt& aOffset);
+		void InitialiseL(TInt& aOffset, const TDesC& aSuiteHash, TDriveNumber aDriveNumber,
+			TJavaTransferType aTransferDataType);
+
+	private:
+		CSBJavaTransferType();
+		CSBJavaTransferType(const TDesC& aSuiteHash);
+		void ConstructL(const TDesC& aSuiteHash, TDriveNumber aDriveNumber, TJavaTransferType aTransferDataType);
+		void ConstructL(CSBGenericTransferType* aGenericTransferType);
+		
+	private:
+		/** The MIDlet suite Hash */
+		TPtrC iSuiteHash;
+
+		/** the transfer data type */
+		TInt iTransferDataTypeOffset;
+		};
+ 
+	class CSBEFileEntry : public CBase
+	/** This class is a more memory efficient heap based externalisable version of 
+	TEntry containing just the information required for public backup. 
+	TEntry contains a TFileName which is a modifiable descriptor of 512 bytes
+	and therefore takes up needless memory. CSBEFileEntry on the other hand occupies
+	only as much RAM as is required to represent the name and path of the file that
+	it represents.
+	@deprecated
+	@publishedPartner
+	*/
+		{
+	public:
+		IMPORT_C static CSBEFileEntry* NewLC(const TEntry& aEntry, RApaLsSession& aSession);
+		IMPORT_C static CSBEFileEntry* NewLC(const TDesC8& aStream, TInt& aBytesRead);
+		IMPORT_C ~CSBEFileEntry();
+		IMPORT_C HBufC8* ExternaliseLC() const;
+		IMPORT_C TUint FileAttributes() const;
+		IMPORT_C TInt FileSize() const;
+		IMPORT_C TTime LastModified() const;
+		IMPORT_C TDesC16& Filename() const;
+		IMPORT_C TDesC16& MIMEType() const;
+		IMPORT_C TUidType& MIMEUid();
+	private:
+		void ConstructL(const TEntry& aEntry, RApaLsSession& aSession);
+		void InternaliseL(const TDesC8& aStream, TInt& aBytesRead);
+		CSBEFileEntry();
+		CSBEFileEntry(const TEntry& aEntry);
+		TUint16 CalculatePackedSize() const;
+	private:
+	    /**
+	    The individual bits within this byte indicate which attributes
+	    have been set.
+	    
+	    @see KEntryAttNormal
+		@see KEntryAttReadOnly
+		@see KEntryAttHidden
+	    @see KEntryAttSystem
+	    */
+		TUint iAtt;
+		
+		/**
+		The size of the file in bytes.
+		*/
+		TInt iSize;
+		
+		/**
+		The system time of last modification, in universal time.
+		*/
+		TTime iModified;
+
+		/**
+		The textual version of the file's UIDtype
+		*/
+		HBufC* iType;
+		
+		/**
+		Array of UID Types corresponding to this file
+		*/
+		TUidType iUidType;
+		
+		/**
+		Path and name of the file
+		*/
+		HBufC* iFilename;
+		};
+	} // end namespace
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/abserver.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,355 @@
+// 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:
+// Implementation of CABServer class.
+// 
+//
+
+/**
+ @file
+*/
+
+#include <e32std.h>
+#include <e32base.h>
+#include <connect/abclientserver.h>
+#include "abserver.h"
+#include "absession.h"
+#include "absessionmap.h"
+#include "sbedataownermanager.h"
+#include <connect/panic.h>
+#include "sblog.h"
+
+namespace conn
+	{
+
+
+	/** Active Backup security request ranges
+	
+	This is a breakdown of the active backup requests into ranges
+	for security checking purposes.
+
+	@internalComponent
+	*/
+	const TInt myABRanges[] = {0,11};
+
+	/** Active Backup range count
+
+	The number of different security ranges for active backup request numbers
+
+	@internalComponent
+	*/
+	const TUint myABRangeCount = sizeof(myABRanges)/sizeof(myABRanges[0]);
+
+	/** Active Backup security action array
+
+	An array with a one-to-one mapping with the range array
+	specifiying what security action to take for each server request.
+
+	@internalComponent
+	*/
+	const TUint8 myABElementsIndex[myABRangeCount] =
+		{
+		CPolicyServer::EAlwaysPass,
+		CPolicyServer::ENotSupported
+		};
+
+	/**
+	@internalComponent
+	*/
+	const CPolicyServer::TPolicyElement myABElements[] =
+		{_INIT_SECURITY_POLICY_PASS};
+
+	/**
+	@internalComponent
+	*/
+	const CPolicyServer::TPolicy myABPolicy =
+		{
+		CPolicyServer::EAlwaysPass,
+		myABRangeCount,
+		myABRanges,
+		myABElementsIndex,
+		myABElements,
+		};
+
+	CABServer::CABServer(CDataOwnerManager* aDOM)
+		: CPolicyServer(EPriorityNormal,myABPolicy), iDOM(aDOM)
+    /** 
+    Class constructor
+    */
+		{
+		__ASSERT_DEBUG(iDOM, Panic(KErrArgument));
+		}
+
+	CABServer::~CABServer()
+    /**
+    Class destructor
+    */
+		{
+		delete iSessionMap;
+		}
+		
+	CABServer* CABServer::NewLC(CDataOwnerManager* aDOM)
+	/**
+	Constructs a new instance of the CABServer, calls ConstructL, 
+	and returns it to the caller leaving it on the cleanup stack.
+
+	@return The new instance of CABServer.
+	*/
+		{
+		CABServer* pSelf = new (ELeave) CABServer(aDOM);
+		CleanupStack::PushL(pSelf);
+		pSelf->ConstructL();
+		return pSelf;
+		}
+
+	void CABServer::ConstructL()
+	/**
+	Construct this instance of CABServer.
+	*/
+		{
+		iSessionMap = CABSessionMap::NewL();
+		//
+		// Start the server 
+		StartL(KABServerName);
+		}
+
+	void CABServer::AddSession()
+	/** Increments the server session count.
+	
+	The server will shutdown when its 
+	session count drops to zero.
+	*/
+		{
+		++iSessionCount;
+		}
+
+	void CABServer::DropSession()
+	/** Decrements the server session count.  
+	
+	The server will shutdown when its 
+	session count drops to zero.
+	*/
+		{		
+		--iSessionCount;
+		}
+		
+	void CABServer::RemoveElement(TSecureId aSecureId)
+	/**
+	Remove the element with key aSecureId from the session map
+	
+	@param aSecureId The key of the element to be removed
+	*/
+		{
+		iSessionMap->Delete(aSecureId);
+		}
+
+	void CABServer::SupplyDataL(TSecureId aSID, TDriveNumber aDriveNumber, TTransferDataType aTransferType, 
+		TDesC8& aBuffer, TBool aLastSection, TBool aSuppressInitDataOwner, TSecureId aProxySID)
+	/**
+	Supply data to the data owner
+	
+	@param aSID The secure ID of the data owner to signal
+	@param aDriveNumber The drive number that the data corresponds to
+	@param aTransferType The type of operation to perform on the data
+	@param aBuffer The buffer containing data for the operation
+	@param aLastSection Flag to indicate whether this is the last operation in a multi-part transfer
+	@param aSuppressInitDataOwner Suppress the initialisation of Data Owner
+	@param aProxySID The secure ID of the proxy
+	*/
+		{
+		CABSession& session = iSessionMap->SessionL(aSID);
+		
+		session.SupplyDataL(aDriveNumber, aTransferType, aBuffer, aLastSection, aSuppressInitDataOwner, aProxySID);
+		}
+
+	void CABServer::RequestDataL(TSecureId aSID, TDriveNumber aDriveNumber, TTransferDataType aTransferType, 
+		TPtr8& aBuffer, TBool& aLastSection, TBool aSuppressInitDataOwner, TSecureId aProxySID)
+	/**
+	Request data from the data owner
+	
+	@param aSID The secure ID of the data owner to signal
+	@param aDriveNumber The drive number that the data corresponds to
+	@param aTransferType The type of operation to perform on the data
+	@param aBuffer The buffer containing data for the operation
+	@param aLastSection Flag to indicate whether this is the last operation in a multi-part transfer
+	@param aSuppressInitDataOwner Suppress the initialisation of Data Owner
+	@param aProxySID The secure ID of the proxy
+	*/
+		{
+		CABSession& session = iSessionMap->SessionL(aSID);
+		
+		session.RequestDataL(aDriveNumber, aTransferType, aBuffer, aLastSection, aSuppressInitDataOwner, aProxySID);
+		}
+
+	void CABServer::GetExpectedDataSizeL(TSecureId aSID, TDriveNumber aDriveNumber, TUint& aSize)
+	/**
+	Get the expected size of the data that will be returned
+	
+	@param aSID The secure ID of the data owner to signal
+	@param aDriveNumber The drive number that the data corresponds to
+	@param aSize The size of the data owner's data
+	*/
+		{
+		CABSession& session = iSessionMap->SessionL(aSID);
+		
+		session.GetExpectedDataSizeL(aDriveNumber, aSize);
+		}
+		
+	void CABServer::AllSnapshotsSuppliedL(TSecureId aSID)
+	/** Lets the client know that all its snapshots have been supplied
+	
+	@param aSID The secure ID of the data owner to signal
+	*/
+		{
+		CABSession& session = iSessionMap->SessionL(aSID);
+		
+		session.AllSnapshotsSuppliedL();
+		}
+
+	void CABServer::InvalidateABSessions()
+	/** Set each CABSession currently hold for each active backup
+	 * client as invalid, since there maybe some delay for the
+	 * arrival of disconnect request from client. Within this time,
+	 * this session can not be used for another backup/restore.
+	 */
+		{
+		iSessionMap->InvalidateABSessions();
+		}
+	
+	TDataOwnerStatus CABServer::SessionReadyStateL(TSecureId aSID)
+	/**
+	Returns the status of the active backup client
+	
+	@param aSID The SecureId of the session to query for
+	@return Data owner status of the session
+	*/
+		{
+		CABSession& session = iSessionMap->SessionL(aSID);
+		
+		TDataOwnerStatus doStatus = EDataOwnerNotConnected;
+		if (session.Invalidated())
+			{
+			__LOG1("CABServer::SessionReadyStateL session for 0x%08x has been invalidated, return NotConnected",
+					aSID.iId);
+			
+			return doStatus;	
+			}
+		
+		if (session.CallbackInterfaceAvailable())
+			{
+			__LOG2("CABServer::SessionReadyStateL session for 0x%08x already have interface, confirmed:%d ",
+					aSID.iId, session.ConfirmedReadyForBUR());
+			
+			doStatus = EDataOwnerNotReady;
+			
+			if (session.ConfirmedReadyForBUR())
+				{
+				doStatus = EDataOwnerReady;
+				}
+			}
+		else 
+			{
+			__LOG2("CABServer::SessionReadyStateL session for 0x%08x does not have interface, confimed:%d",
+								aSID.iId, session.ConfirmedReadyForBUR());
+			
+			doStatus = EDataOwnerNotReady;
+			
+			if (session.ConfirmedReadyForBUR())
+				{
+				doStatus = EDataOwnerReadyNoImpl;
+				}				
+			}
+			
+		return doStatus;
+		}
+		
+	void CABServer::RestoreCompleteL(TSecureId aSID, TDriveNumber aDrive)
+	/**
+	Called to indicate to the active backup client that a restore has completed
+	
+	@param aSID The secure Id of the active client for which the restore has completed
+	@param aDrive The drive number for which the restore has completed
+	*/
+		{
+		CABSession& session = iSessionMap->SessionL(aSID);
+
+		session.RestoreCompleteL(aDrive);
+		}
+		
+	CSession2* CABServer::NewSessionL(const TVersion& aVersion,
+		const RMessage2& aMessage) const
+	/** Constructs a new AB session.
+	
+	Querys the supplied version infomation from the client
+	with that of this server, and leaves if they are incompatable.
+
+	@param aVersion The clients version information
+	@param aMessage Is ignored
+	@return A new instance of CABSession
+	@leave KErrNotSupported if the version passed in aVersion is not the same as this one
+	*/
+		{
+		TVersion thisVersion(KABMajorVersionNumber, 
+								KABMinorVersionNumber,
+								KABBuildVersionNumber);
+		
+	    if (!User::QueryVersionSupported(thisVersion, aVersion))
+			{
+			User::Leave(KErrNotSupported);
+			}
+			
+		TSecureId sid = aMessage.SecureId();
+
+		// The map creates the session and a map entry, then session ownership is passed to the server
+		return &(iSessionMap->CreateL(sid));
+		}
+
+	TInt CABServer::RunError(TInt aError)
+	/** Called when this active objects RunL leaves. 
+	
+	May be due to a bad client or the server itself.  In either 
+	case, complete the last outstanding message with the error 
+	code and continue handling client requests.
+
+    @param aError  Standard Symbian OS error code
+	@return The error code to be passed back to the active scheduler framework.
+	*/
+		{
+		//
+		// A Bad descriptor is a bad client - panic it.
+		if(aError == KErrBadDescriptor)
+			{
+			PanicClient(KErrBadDescriptor);
+			}
+
+		//
+		// Complete the message and continue handling requests.
+		Message().Complete(aError);
+		ReStart();
+		return KErrNone;
+		}
+
+	void CABServer::PanicClient(TInt aPanic) const
+	/** Panic a client.
+
+	@param aPanic The panic code.
+	*/
+		{
+		__DEBUGGER()
+		_LIT(KPanicCategory,"AB Server");
+		RThread client;
+		Message().Client(client);
+		client.Panic(KPanicCategory, aPanic);
+		}
+
+	} // end namespace
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/absession.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1238 @@
+// 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:
+// Implementation of CABSession class.
+// 
+//
+
+/**
+ @file
+*/
+
+#include <e32base.h>
+#include "abserver.h"
+#include "absession.h"
+#include <connect/abclientserver.h>
+#include "sbedataownermanager.h"
+#include "sbedataowner.h"
+#include <connect/sbtypes.h>
+#include <connect/panic.h>
+#include "sblog.h"
+
+namespace conn
+	{
+	CABSession* CABSession::NewL(TSecureId aSecureId)
+	/**
+	Symbian first phase constructor
+	
+	@param aSecureId The SID of the client that's connecting to this session
+	*/
+		{
+		CABSession* self = new (ELeave) CABSession(aSecureId);
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		CleanupStack::Pop(self);
+		return self;
+		}
+		
+	void CABSession::ConstructL()
+	/**
+	Symbian second phase constructor. Initialise some more of the data members
+	*/
+		{
+		iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait;
+		__LOG1("CABSession::ConstructL() [0x%08x]", iClientSID.iId);
+		}
+		
+	CABSession::CABSession(TSecureId aSecureId) : iClientSID(aSecureId), 
+		iCallbackWatchdog(NULL), iActiveSchedulerWait(NULL), iABClientLeaveCode(KErrNone), 
+		iReceiveFromClientFinished(ETrue), iSendToClientBuffer(NULL, 0), 
+		iWatchdogHandler(ABSessionStaticWatchdogCaller, static_cast<TAny*>(this)), iMisbehavingClient(EFalse),
+		iInvalid(EFalse)
+    /**
+    Class Constructor
+    
+	@param aSecureId The SID of the client that's connecting to this session
+    */
+		{
+		}
+		
+	CDataOwner& CABSession::DataOwnerL() const
+	/**
+	Return the active data owner
+	
+	@return A reference to the active data owner
+	*/
+		{
+		return Server().DataOwnerManager().DataOwnerL(iClientSID);
+		}
+		
+	TInt CABSession::ABSessionStaticWatchdogCaller(TAny* aWatchdoggingObject)
+	/**
+	CPeriodic only accepts a TCallBack style function pointer which must be a pointer to a static or
+	non-member function. As we need to have watchdogs per session object instead of per class, we 
+	must make the call to the particular object from within this static method.
+	
+	@param aWatchdoggingObject CABSession* to the object that watchdogged
+	@return Any error code - enforced return, not necessarily used by this function
+	@see TCallBack
+	*/
+		{
+		return (static_cast<CABSession*>(aWatchdoggingObject))->WatchdogExpired();
+		}
+		
+	TInt CABSession::WatchdogExpired()
+	/**
+	Called by ABSessionStaticWatchdogCaller to indicate that the watchdog has expired on this particular 
+	session as a result of the callback not being returned from by the client
+	
+	@return An error code
+	*/
+		{
+		__LOG1("CABSession::WatchdogExpired() - [0x%08x] Watchdog expired on session", iClientSID.iId);
+		
+		iMisbehavingClient = ETrue;			// Flag the client as having not responded
+		
+		// Inform the Data Owner of the new status
+		TRAP_IGNORE(DataOwnerL().SetReadyState(EDataOwnerFailed));
+		
+		if (iActiveSchedulerWait->IsStarted())
+			{
+			iABClientLeaveCode = KErrTimedOut;
+			ReturnFromCallback();
+			}
+		else
+			{
+			// We should never get here - only a callback call should time out
+			Panic(KErrTimedOut);
+			}
+			
+		return KErrTimedOut;
+		}
+
+	TBool CABSession::ConfirmedReadyForBUR() const
+	/** Accessor to get the state from an already existing connection
+	
+	@return ETrue if the active client has previously confirmed that it's ready for a backup or restore
+	*/
+		{
+		return iConfirmedReadyForBUR;
+		}
+		
+	TBool CABSession::CallbackInterfaceAvailable() const
+	/** Accessor to indicate whether or not the client has enabled the callback interface or not
+	
+	@return ETrue if the callback interface is available
+	*/
+		{
+		return !iMessage.IsNull();
+		}
+		
+	CABSession::~CABSession()
+    /**
+    Class destructor
+    */
+		{
+		__LOG1("~CABSession for sid:0x%08x", iClientSID.iId);
+		delete iCallbackWatchdog;
+		iCallbackWatchdog = NULL;
+		
+		// Remove this session from the server's session map
+		Server().RemoveElement(iClientSID);
+		
+		// Clear up any outstanding message
+		HandleIPCClosingDownCallback();
+		
+		delete iActiveSchedulerWait;
+
+		//
+		// If the client has detached properly, they should
+		// have done this - but just in case.
+		//DoCancelWaitForCallback();
+		Server().DropSession();
+		}
+		
+	void CABSession::CreateL()
+	/**
+	Creates a connection between active backup server and the active backup session.
+	Increments the server's session count
+	*/
+		{
+		//
+		// Increase the servers session count.
+		Server().AddSession();
+		}
+
+	void CABSession::RestoreCompleteL(TDriveNumber aDriveNumber)
+	/**
+	Signal the client that the restore operation is complete
+
+	@param aDriveNumber The drive that has finished being backed up
+	*/
+		{
+		MakeCallbackRestoreCompleteL(aDriveNumber);
+		}
+
+	void CABSession::AllSnapshotsSuppliedL()
+	/**
+	Lets the session know that all snapshots have been supplied.
+	
+	*/
+		{
+		MakeCallbackAllSnapshotsSuppliedL();
+		}
+
+	void CABSession::GetExpectedDataSizeL(TDriveNumber aDriveNumber, TUint& aSize)
+	/**
+	Get the expected data size from the active backup client
+
+	@param aDriveNumber The drive number of the data
+	@param aSize Upon exit, this parameter will indicate the expected data size
+	*/
+		{
+		aSize = MakeCallbackGetExpectedDataSizeL(aDriveNumber);
+		}
+		
+	void CABSession::SupplyDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, TDesC8& aBuffer,
+			TBool aLastSection, TBool aSuppressInitDataOwner, TSecureId aProxySID)
+	/**
+	Supply data to the active backup client
+
+	@param aDriveNumber The drive number of the data
+	@param aTransferType Specifies the type of data to get the expected data size of
+	@param aBuffer The data to send to the Active Backup Client
+	@param aLastSection Specifies whether or not additional SupplyDataL calls will be made (multi-part)
+	@param aSuppressInitDataOwner Suppress the initialisation of Data Owner
+	@param aProxySID The secure ID of the proxy
+	*/
+		{
+		TInt dataSizeTransferred = 0;
+		TInt remainingBlockSize = 0;
+		TBool lastSection;
+		TPtrC8 transferBlock;
+
+		// Repeat the data transfer until all data has been sent
+		while (dataSizeTransferred < aBuffer.Size())
+			{
+			remainingBlockSize = aBuffer.Size() - dataSizeTransferred;
+			
+			if (remainingBlockSize > KIPCMessageSize)
+				{
+				remainingBlockSize = KIPCMessageSize;
+				lastSection = EFalse;
+				}
+			else
+				{
+				lastSection = aLastSection;
+				}
+				
+			// Create a temporary descriptor representing the next block to send
+			transferBlock.Set(aBuffer.Mid(dataSizeTransferred, remainingBlockSize));
+			
+			dataSizeTransferred += transferBlock.Size();
+
+			// If we're sending
+			if ((transferBlock.Size() <= KIPCMessageSize) && (dataSizeTransferred != aBuffer.Size()))
+				{
+				lastSection = EFalse;
+				}
+			else
+				{
+				lastSection = aLastSection;
+				}
+			
+			__LOG2("CABSession::SupplyDataL() - [0x%08x] Supplying data to ABClient, %d bytes transferred", iClientSID.iId, dataSizeTransferred);
+	
+			switch(aTransferType)
+				{
+				case EActiveSnapshotData:
+					{
+					MakeCallbackReceiveSnapshotDataL(aDriveNumber, transferBlock, lastSection);
+					} break;
+				case EActiveBaseData:
+					{
+					if (!aSuppressInitDataOwner)
+						{
+						if (aProxySID != KNullABSid)
+							{
+							MakeCallbackInitialiseRestoreProxyBaseDataL(aProxySID, aDriveNumber);
+							}
+						else
+							{
+							MakeCallbackInitialiseRestoreBaseDataL(aDriveNumber);
+							}
+						}
+					MakeCallbackRestoreBaseDataSectionL(transferBlock, lastSection);
+					} break;
+				case EActiveIncrementalData:
+					{
+					if (!aSuppressInitDataOwner)
+						{
+						MakeCallbackInitialiseRestoreIncrementDataL(aDriveNumber);
+						}
+					MakeCallbackRestoreIncrementDataSectionL(transferBlock, lastSection);
+					} break;
+				default:
+					{
+					User::Leave(KErrNotSupported);
+					}
+				}
+			
+			// Even if we were supposed to suppress it first time round, for a multipart supply, it 
+			// shouldn't be sent again
+			aSuppressInitDataOwner = ETrue;
+			}
+		}
+			
+	void CABSession::RequestDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, TPtr8& aBuffer,
+			TBool& aLastSection, TBool aSuppressInitDataOwner, TSecureId aProxySID)
+	/**
+	Request data from the active backup client
+
+	@param aDriveNumber The drive number of the data 
+	@param aTransferType Specifies the type of data to get the expected data size of
+	@param aBuffer This buffer will be filled by the Active Backup Client upon return
+	@param aLastSection Upon return indicates whether or not additional RequestDataL calls will be made (multi-part)
+	@param aSuppressInitDataOwner Suppress the initialisation of Data Owner
+	@param aProxySID The secure ID of the proxy
+	*/
+		{
+        __LOG5("CABSession::RequestDataL() - START - aDrive: %c, aTType: %d, aBuffer.Ptr(): 0x%08x, aBuffer.Length(): %d, aProxySID: 0x%08x", 
+            aDriveNumber + 'A', aTransferType, aBuffer.Ptr(), aBuffer.Length(), aProxySID.iId );
+
+        TInt dataSizeTransferred = 0;
+		TInt remainingBlockSize = 0;
+		TBool lastSection = EFalse;
+		TPtr8 transferBlock(NULL, 0);
+		
+		// While there is space left in aBuffer and the client hasn't finished, keep requesting data
+		do
+			{
+			// Set max for the MidTPtr call to work. Length of this buffer is reset after each data transfer
+			aBuffer.SetMax();
+
+			remainingBlockSize = aBuffer.MaxSize() - dataSizeTransferred;
+			__LOG2("CABSession::RequestDataL() - dataSizeTransferred: %d, remainingBlockSize: %d", dataSizeTransferred, remainingBlockSize);
+
+			if (remainingBlockSize > KIPCMessageSize)
+				{
+				remainingBlockSize = KIPCMessageSize;
+				}
+				
+			transferBlock.Set(aBuffer.MidTPtr(dataSizeTransferred, remainingBlockSize));
+			__LOG2("CABSession::RequestDataL() - transferBlock: 0x%08x (%d)", transferBlock.Ptr(), transferBlock.Length());
+
+			switch(aTransferType)
+				{
+				case EActiveSnapshotData:
+					{
+					MakeCallbackGetSnapshotDataL(aDriveNumber, transferBlock, lastSection);
+					} break;
+				case EActiveBaseData:
+				case EActiveIncrementalData:
+					{
+					if (!aSuppressInitDataOwner)
+						{
+						if (aProxySID != KNullABSid)
+							{
+							MakeCallbackInitialiseGetProxyBackupDataL(aProxySID, aDriveNumber);
+							}
+						else
+							{
+							MakeCallbackInitialiseGetBackupDataL(aDriveNumber);
+							}
+						}
+					MakeCallbackGetBackupDataSectionL(transferBlock, lastSection);
+					} break;
+				default:
+					{
+					User::Leave(KErrNotSupported);
+					}
+				}
+			
+			// Even if we were supposed to suppress it first time round, for a multipart get, it 
+			// shouldn't be sent again
+			aSuppressInitDataOwner = ETrue;
+
+			// update our count to reflect the new data supplied by the client
+			dataSizeTransferred += transferBlock.Size();
+
+            __LOG2("CABSession::RequestDataL() - received data so far: %d, buffer start address: 0x%08x", dataSizeTransferred, aBuffer.Ptr());
+            //__LOGDATA("CABSession::RequestDataL() - total received data - %S", aBuffer.Ptr(), dataSizeTransferred);
+
+			__LOG2("CABSession::RequestDataL() - [0x%08x] Requesting data from ABClient %d bytes so far)", iClientSID.iId, dataSizeTransferred);
+			
+			aBuffer.SetLength(dataSizeTransferred);
+			} while (!lastSection && (dataSizeTransferred < aBuffer.MaxSize()));
+		
+		aLastSection = lastSection;
+		}
+		
+	void CABSession::TerminateMultiStageOperationL()
+	/**
+	Instruct the client that copying of data has been aborted and it should clean up
+	*/
+		{
+		MakeCallbackTerminateMultiStageOperationL();
+		}
+		
+	TUint CABSession::GetDataChecksumL(TDriveNumber aDrive)
+	/**
+	Test method for validating data
+	
+	@param aDrive The drive from which the data is backed up from
+	@return The checksum
+	*/
+		{
+		return MakeCallbackGetDataChecksumL(aDrive);
+		}
+
+	void CABSession::CleanupClientSendState()
+	/**
+	Delete the client sending buffer and reset multipart flag
+	*/
+		{
+		iReceiveFromClientFinished = ETrue;
+		}
+		
+	void CABSession::MadeCallback()
+	/**
+	Start the CActiveSchedulerWait() object. The ABServer will stop this wait object when it's callback 
+	has returned, this way the thread's AS still processes ABServer ServiceL's etc. but it appears as 
+	though the request to the ABClient is synchronous. This method will be called from the ABServer inside 
+	the call from the Data Owner requesting an operation
+	
+	@see CDataOwner::ReturnFromActiveCall()
+	*/
+		{
+		// Reset the leave flag
+		iABClientLeaveCode = KErrNone;
+		
+		
+		#ifndef _DEBUG
+		// Start the callback timer only in release builds
+		delete iCallbackWatchdog;
+		iCallbackWatchdog = NULL;
+		iCallbackWatchdog = CPeriodic::NewL(EPriorityHigh);
+		TTimeIntervalMicroSeconds32 KWatchdogIntervalNone = 0;
+		iCallbackWatchdog->Start(KABCallbackWatchdogTimeout, KWatchdogIntervalNone, iWatchdogHandler);
+		#endif
+
+		// Send the message back to the callback handler
+		iMessage.Complete(KErrNone);
+		
+		__LOG1("CABSession::MadeCallback() - [0x%08x] Calling ABClient to process callback", iClientSID.iId);
+
+		// Set the timeout for the callback
+		iActiveSchedulerWait->Start();
+		}
+		
+	void CABSession::ReturnFromCallback()
+	/**
+	This method is called by the ABServer once it's completed it's request from the Active Backup Client 
+	so that the Data Owner appears to have made a synchronous call into the ABServer
+	*/
+		{
+		if (iCallbackWatchdog)
+			{
+			if (iCallbackWatchdog->IsActive())
+				{
+				iCallbackWatchdog->Cancel();
+
+				delete iCallbackWatchdog;
+				iCallbackWatchdog = NULL;
+				}
+			}
+
+		if (iActiveSchedulerWait->IsStarted())
+			{
+			__LOG1("CABSession::MadeCallback() - [0x%08x] has returned from callback - CASW::AsyncStop()", iClientSID.iId);
+			iActiveSchedulerWait->AsyncStop();
+			}
+		}
+
+	void CABSession::TakeOwnershipOfIPCMessage(const RMessage2& aMessage)
+	/**
+	Take ownership of the IPC message so that we're able to signal the Active Backup Callback Handler
+	
+	@param aMessage The IPC message that we're going to take ownership of
+	*/
+		{
+		iMessage = aMessage;
+		}
+	
+	void CABSession::HandleIPCBURModeInfoL(const RMessage2& aMessage)
+	/**
+	Return information about the backup and restore mode to the active backup client
+
+	@param aMessage The IPC message
+	*/
+		{
+		__LOG1("CABSession::HandleIPCBURModeInfoL() - [0x%08x] Received IPC IPCBURModeInfo", iClientSID.iId);
+
+		TPckgC<TBURPartType> partType(Server().DataOwnerManager().BURType());
+		TPckgC<TBackupIncType> incType(Server().DataOwnerManager().IncType());
+		
+		// Return the backup and restore settings to the client
+		aMessage.WriteL(0, Server().DataOwnerManager().DriveList());
+		aMessage.WriteL(1, partType);
+		aMessage.WriteL(2, incType);
+		}
+		
+	void CABSession::HandleIPCDoesPartialBURAffectMeL(const RMessage2& aMessage)
+	/**
+	Return information about the backup and restore mode to the active backup client
+
+	@param aMessage The IPC message
+	*/
+		{
+		__LOG1("CABSession::HandleIPCDoesPartialBURAffectMeL() - [0x%08x] Received IPC DoesPartialBURAffectMe", iClientSID.iId);
+
+		TPckgC<TBool> resultPkg(Server().DataOwnerManager().IsSetForPartialL(iClientSID));
+		aMessage.WriteL(0, resultPkg);
+		}
+
+	void CABSession::HandleIPCConfirmReadyForBURL(const RMessage2& aMessage)
+	/**
+	Respond to an event from abclient informing us that it's prepared it's data and is ready for backup
+
+	@param aMessage The IPC message
+	*/
+		{
+		TInt errorCode = aMessage.Int0();
+		__LOG2("CABSession::HandleIPCConfirmReadyForBURL() - [0x%08x] Received IPC ConfirmReadyForBUR, errorCode: %d", iClientSID.iId, errorCode);
+		
+		// Set our internal state to indicate that the client has confirmed ready for BUR
+		iConfirmedReadyForBUR = ETrue;
+
+		TDataOwnerStatus status;
+
+		if (errorCode == KErrNone)
+			{
+			if (CallbackInterfaceAvailable())
+				{
+				status = EDataOwnerReady;
+				}
+			else
+				{
+				status = EDataOwnerReadyNoImpl;
+				}
+			}
+		else				
+			{
+			status = EDataOwnerFailed;
+			}
+		
+		// Inform the Data Owner of the new status
+		TRAP_IGNORE(DataOwnerL().SetReadyState(status));
+		}
+
+	void CABSession::HandleIPCPropagateLeaveL(const RMessage2& aMessage)
+	/** Leave with the propagated leave code
+
+	@param aMessage The IPC message
+	*/
+		{
+		// Leave with the propagated leave code, but not inside this ServiceL, it'll leave to the client again 
+		// We need to ensure that it leaves through SBEngine back to SBEClient. Leave code will be checked 
+		// after the callback has been made and leave will be made then if necessary
+		iABClientLeaveCode = aMessage.Int0();
+
+		__LOG2("CABSession::HandleIPCPropagateLeaveL() - [0x%08x] Received IPC Leave(%d)", iClientSID.iId, iABClientLeaveCode);
+		}
+
+	TInt CABSession::HandleIPCGetDataSyncL(const RMessage2& aMessage)
+	/**
+	Handles the synchronous method called by the client to get it's data transferred
+
+	@param aMessage The IPC message
+	@return KErrNone if OK, standard error code otherwise
+	*/
+		{
+		__LOG1("CABSession::HandleIPCGetDataSyncL() - [0x%08x] has requested data over IPC", iClientSID.iId);
+
+		TInt completionCode = KErrNone;
+		
+		if (iCallbackInProgress == static_cast<TABCallbackCommands>(aMessage.Int0()))
+			{
+			// Write the clients data into the buffer
+			aMessage.WriteL(1, iSendToClientBuffer);
+			}
+		else
+			{
+			completionCode = KErrCorrupt;
+			}
+			
+		__LOG2("CABSession::HandleIPCGetDataSyncL() - [0x%08x] completion code: %d", iClientSID.iId, completionCode);
+		return completionCode;
+		}
+
+	TInt CABSession::HandleIPCSendDataLengthL(const RMessage2& aMessage)
+	/**
+	Synchronous IPC call from the ABClient to inform the server about the data that is being returned from it
+
+	@param aMessage The IPC message
+	@return KErrNone if OK, standard error code otherwise
+	*/
+		{
+		__LOG1("CABSession::HandleIPCSendDataLengthL() - [0x%08x] is informing server of the data length coming back", iClientSID.iId);
+
+		TInt completionCode = KErrNone;
+
+		// Check that this operation is as part of our expected callback
+		if (iCallbackInProgress == static_cast<TABCallbackCommands>(aMessage.Int2()))
+			{
+			CleanupClientSendState();
+			// Ignore the size returned from the client (Int0()) because we've told it how much it can send
+			iReceiveFromClientFinished = static_cast<TBool>(aMessage.Int1());
+			}
+		else
+			{
+			completionCode = KErrCorrupt;
+			}
+			
+		return completionCode;
+		}
+
+	TInt CABSession::HandleIPCClosingDownCallback()
+	/**
+	Respond to the client, informing it that the server is closing down the callback interface
+
+	@return KErrNone if OK, standard error code otherwise
+	*/
+		{
+		TInt completionCode = KErrNotFound;
+		__LOG1("CABSession::HandleIPCClosingDownCallback() - [0x%08x] is closing down the callback interface", iClientSID.iId);
+		if (!iMessage.IsNull())
+			{
+			completionCode = KErrNone;
+			iMessage.Complete(KErrCancel);
+			}
+
+		return completionCode;
+		}
+
+	void CABSession::ServiceL(const RMessage2& aMessage)
+	/**
+	Called by the client server framework to service a message request
+	from a client.
+
+    @param aMessage  Reference to a RMessage2 object
+	*/
+		{
+ 		const TInt ipcMessageFn = aMessage.Function();
+ 		TInt completionCode = KErrNone;			// Complete the aMessage with this code
+
+	#if defined(SBE_LOGGING_ENABLED)
+		RThread client;
+		aMessage.Client(client);
+		const TFullName name(client.FullName());
+		client.Close();
+		__LOG5("CABSession::ServiceL() - START - [0x%08x] function: %d from client: %S, iMisbehavingClient: %d, iConfirmedReadyForBUR: %d", iClientSID.iId, ipcMessageFn, &name, iMisbehavingClient, iConfirmedReadyForBUR);
+	#endif
+		
+		switch(ipcMessageFn)
+			{
+			case EABMsgBURModeInfo:
+	            __LOG("CABSession::ServiceL() - EABMsgBURModeInfo");
+				{
+				HandleIPCBURModeInfoL(aMessage);
+				break;
+				}
+			case EABMsgDoesPartialAffectMe:
+	            __LOG("CABSession::ServiceL() - EABMsgDoesPartialAffectMe");
+				{
+				HandleIPCDoesPartialBURAffectMeL(aMessage);
+				break;
+				}
+			case EABMsgConfirmReadyForBUR:
+	            __LOG("CABSession::ServiceL() - EABMsgConfirmReadyForBUR");
+				{
+				if (iMisbehavingClient)
+					{
+					completionCode = KErrTimedOut;
+					}
+				else
+					{
+					HandleIPCConfirmReadyForBURL(aMessage);
+					}
+					
+				break;
+				}
+			case EABMsgPrimeForCallback:
+			case EABMsgPrimeForCallbackAndResponse:
+			case EABMsgPrimeForCallbackAndResponseDes:
+	            __LOG("CABSession::ServiceL() - EABMsgPrimeForCallback/EABMsgPrimeForCallbackAndResponse/EABMsgPrimeForCallbackAndResponseDes");
+				{
+				CDataOwner* dataOwner = NULL;
+				TRAPD(err, dataOwner = &DataOwnerL());
+				// Close down the entire callback interface on a misbehaving client
+				if (iMisbehavingClient)
+					{
+					completionCode = KErrTimedOut;
+					if (err == KErrNone)
+						{
+						dataOwner->SetReadyState(EDataOwnerNotConnected);
+						}
+					else
+						{
+						if (err != KErrNotFound)
+							{
+							User::Leave(err);
+							}
+						}
+					}
+				else
+					{
+					TakeOwnershipOfIPCMessage(aMessage);
+					if (err == KErrNone)
+						{
+						if (dataOwner->ReadyState() == EDataOwnerNotConnected)
+							{
+							dataOwner->SetReadyState(EDataOwnerNotReady);
+							}
+						}
+					else
+						{
+						if (err != KErrNotFound)
+							{
+							User::Leave(err);
+							}
+						}
+						
+					// Return to the method that initiated the callback
+					ReturnFromCallback();
+					}
+
+				break;
+				}
+			case EABMsgPropagateLeave:
+	            __LOG("CABSession::ServiceL() - EABMsgPropagateLeave");
+				{
+				if (iMisbehavingClient)
+					{
+					completionCode = KErrTimedOut;
+					}
+				else
+					{
+					HandleIPCPropagateLeaveL(aMessage);
+					}
+				break;
+				}
+			case EABMsgGetDataSync:
+	            __LOG("CABSession::ServiceL() - EABMsgGetDataSync");
+				{
+				if (iMisbehavingClient)
+					{
+					completionCode = KErrTimedOut;
+					}
+				else
+					{
+					completionCode = HandleIPCGetDataSyncL(aMessage);
+					}
+				break;
+				}
+			case EABMsgSendDataLength:
+	            __LOG("CABSession::ServiceL() - EABMsgSendDataLength");
+				{
+				if (iMisbehavingClient)
+					{
+					completionCode = KErrTimedOut;
+					}
+				else
+					{
+					completionCode = HandleIPCSendDataLengthL(aMessage);
+					}
+				break;
+				}
+			case EABMsgClosingDownCallback:
+	            __LOG("CABSession::ServiceL() - EABMsgClosingDownCallback");
+				{
+				completionCode = HandleIPCClosingDownCallback();
+
+				CDataOwner* dataOwner = NULL;
+				TRAPD(err, dataOwner = &DataOwnerL());
+				if (err == KErrNone && ( dataOwner->ReadyState() == EDataOwnerReady || dataOwner->ReadyState() == EDataOwnerReadyNoImpl ))
+					{
+					dataOwner->SetReadyState(EDataOwnerNotConnected);
+					}
+				break;
+				}
+			case EABMsgGetDriveNumForSuppliedSnapshot:
+	            __LOG("CABSession::ServiceL() - EABMsgGetDriveNumForSuppliedSnapshot");
+				{
+				// Return the drive number to the client
+				completionCode = static_cast<TInt>(iSuppliedSnapshotDriveNum);
+				break;
+				}
+			//
+			// Connection config getting/setting.
+			default:
+				{
+				Panic(KErrNotSupported);
+				break;
+				}
+			}
+		
+		if ((ipcMessageFn != EABMsgPrimeForCallback) &&
+			(ipcMessageFn != EABMsgPrimeForCallbackAndResponse) &&
+			(ipcMessageFn != EABMsgPrimeForCallbackAndResponseDes))
+			{
+			// If the message was a synchrnous one and has not already been completed, then complete
+			if (!aMessage.IsNull())
+				{
+				aMessage.Complete(completionCode);
+		        __LOG3("CABSession::ServiceL() - END - function: %d from client: %S - COMPLETED (%d)", aMessage.Function(), &name, completionCode);
+				}
+			}
+
+	#if defined(SBE_LOGGING_ENABLED)
+		if	(!aMessage.IsNull())
+			{
+			__LOG2("CABSession::ServiceL() - END - function: %d from client: %S - ASYNCH -> NOT COMPLETED", aMessage.Function(), &name);
+			}
+	#endif
+		}
+
+	inline CABServer& CABSession::Server() const
+	/**
+	Returns a non-cost reference to this CServer object.
+
+	@return The non-const reference to this.
+	*/
+		{
+		return *static_cast<CABServer*>(const_cast<CServer2*>(CSession2::Server()));
+		}
+
+	void CABSession::CheckCallbackAvailableL()
+	/**
+	Leave if the callback is not available
+	
+	@leave KErrNotReady if the callback hasn't been primed
+	*/
+		{
+		TBool primed = !iMessage.IsNull();
+		
+		__LOG2("CABSession::CheckCallbackAvailableL() - [0x%08x] primed: %d", iClientSID.iId, static_cast<TInt>(primed));
+		
+		if (iMisbehavingClient)
+			{
+			User::Leave(KErrAccessDenied);
+			}
+
+		if (!primed)
+			{
+			User::Leave(KErrNotReady);
+			}
+		}
+		
+	void CABSession::MakeCallbackAllSnapshotsSuppliedL()
+	/**
+	Synchronous call to make the callback on the active backup client
+	
+	*/
+		{
+		__LOG1("CABSession::MakeCallbackAllSnapshotsSuppliedL() - [0x%08x] Calling AllSnapshotsSuppliedL", iClientSID.iId);
+
+		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackAllSnapshotsSupplied);
+
+		CheckCallbackAvailableL();
+		
+		// Make the callback
+		iMessage.WriteL(0, callbackPkg);
+		MadeCallback();
+		}
+	
+	void CABSession::MakeCallbackReceiveSnapshotDataL(TDriveNumber aDrive, TDesC8& aBuffer, 
+		TBool aLastSection)
+	/**
+	Synchronous call to make the callback on the active backup client
+	
+	@param aDrive Drive number that the snapshot relates to
+	@param aBuffer The snapshot
+	@param aLastSection Flag to indicate to the client whether this is the last of a multipart snapshot
+	*/
+		{
+		__LOG1("CABSession::MakeCallbackReceiveSnapshotDataL() - [0x%08x] Calling ReceiveSnapshotData", iClientSID.iId);
+		
+		iSuppliedSnapshotDriveNum = aDrive;
+
+		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackReceiveSnapshotData);
+		TPckgC<TInt> sizePkg(aBuffer.Size());
+		TPckgC<TBool> lastSectionPkg(aLastSection);
+
+		iCallbackInProgress = EABCallbackReceiveSnapshotData;
+
+		iSendToClientBuffer.Set(aBuffer);
+		
+		CheckCallbackAvailableL();
+		iMessage.WriteL(0, callbackPkg);
+		iMessage.WriteL(1, sizePkg);
+		iMessage.WriteL(2, lastSectionPkg);
+		MadeCallback();
+
+		User::LeaveIfError(iABClientLeaveCode);
+		}
+
+	TUint CABSession::MakeCallbackGetExpectedDataSizeL(TDriveNumber aDrive)
+	/**
+	Synchronous call to make the callback on the active backup client
+	
+	@param aDrive The drive to get the expected data size for
+	@return The size of the data that will be transferred
+	*/
+		{
+		__LOG1("CABSession::MakeCallbackGetExpectedDataSizeL() - [0x%08x] Calling GetExpectedDataSize", iClientSID.iId);
+
+		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackGetExpectedDataSize);
+		TPckgC<TDriveNumber> drivePkg(aDrive);
+		TUint returnedSize;
+
+		iCallbackInProgress = EABCallbackGetExpectedDataSize;
+
+		CheckCallbackAvailableL();
+		iMessage.WriteL(0, callbackPkg);
+		iMessage.WriteL(1, drivePkg);
+		MadeCallback();
+		
+		// Check that a response has been received
+		CheckCallbackAvailableL();
+		returnedSize = iMessage.Int3();
+		
+		return returnedSize;
+		}
+
+	void CABSession::MakeCallbackGetSnapshotDataL(TDriveNumber aDrive, TPtr8& aBuffer, TBool& aFinished)
+	/**
+	Synchronous call to make the callback on the active backup client
+	
+	@param aDrive Drive number that the snapshot is required for
+	@param aBuffer The snapshot
+	@param aFinished Flag to indicate to the client whether this is the last of a multipart snapshot
+	*/
+		{
+		__LOG1("CABSession::MakeCallbackGetSnapshotDataL() - [0x%08x] Calling GetSnapshotData", iClientSID.iId);
+
+		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackGetSnapshotData);
+		TPckgC<TDriveNumber> drivePkg(aDrive);
+		TPckgC<TInt> size(aBuffer.Size());
+		
+		iCallbackInProgress = EABCallbackGetSnapshotData;
+
+		CheckCallbackAvailableL();
+		iMessage.WriteL(0, callbackPkg);
+		iMessage.WriteL(1, size);
+		iMessage.WriteL(2, drivePkg);
+		MadeCallback();
+
+		User::LeaveIfError(iABClientLeaveCode);
+		
+		// Read the buffer from the client
+		CheckCallbackAvailableL();
+
+		TInt bufLength = iMessage.GetDesLengthL(3);
+		aBuffer.SetLength(bufLength);
+
+		iMessage.ReadL(3, aBuffer);
+		aFinished = iReceiveFromClientFinished;
+		}
+
+	void CABSession::MakeCallbackInitialiseGetBackupDataL(TDriveNumber aDrive)
+	/**
+	Synchronous call to make the callback on the active backup client
+	
+	@param aDrive the Drive Number
+	*/
+		{
+		__LOG1("CABSession::MakeCallbackInitialiseGetBackupDataL() - [0x%08x] Calling InitGetBackupData", iClientSID.iId);
+
+		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackInitialiseGetBackupData);
+		TPckgC<TDriveNumber> drivePkg(aDrive);
+		
+		iCallbackInProgress = EABCallbackInitialiseGetBackupData;
+		
+		CheckCallbackAvailableL();
+		iMessage.WriteL(0, callbackPkg);
+		iMessage.WriteL(1, drivePkg);
+		MadeCallback();
+
+		User::LeaveIfError(iABClientLeaveCode);
+		}
+
+	void CABSession::MakeCallbackGetBackupDataSectionL(TPtr8& aBuffer, TBool& aFinished)
+	/**
+	Synchronous call to make the callback on the active backup client
+	
+	@param aBuffer Data returned from the client 
+	@param aFinished Does the client have more data to send? 
+	*/
+		{
+        __LOG2("CABSession::MakeCallbackGetBackupDataSectionL() - START - aBuffer.Ptr(): 0x%08x, aBuffer.Length(): %d", aBuffer.Ptr(), aBuffer.Length());
+
+        __LOG1("CABSession::MakeCallbackGetBackupDataSectionL() - [0x%08x] Calling GetBackupDataSection", iClientSID.iId);
+
+		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackGetBackupDataSection);
+		TPckgC<TInt> sizePkg(aBuffer.Size());
+		
+		iCallbackInProgress = EABCallbackGetBackupDataSection;
+		
+		CheckCallbackAvailableL();
+		iMessage.WriteL(0, callbackPkg);
+		iMessage.WriteL(1, sizePkg);
+		MadeCallback();
+
+		User::LeaveIfError(iABClientLeaveCode);
+		CheckCallbackAvailableL();
+		
+		TInt bufLength = iMessage.GetDesLengthL(3);
+		aBuffer.SetLength(bufLength);
+        iMessage.ReadL(3, aBuffer);
+		aFinished = iReceiveFromClientFinished;
+ 
+        //__LOGDATA("CABSession::MakeCallbackGetBackupDataSectionL() - received %S", aBuffer.Ptr(), aBuffer.Length());
+
+        __LOG2("CABSession::MakeCallbackGetBackupDataSectionL() - END - aBuffer.Ptr(): 0x%08x, aBuffer.Length(): %d", aBuffer.Ptr(), aBuffer.Length());
+        }
+
+	void CABSession::MakeCallbackInitialiseRestoreBaseDataL(TDriveNumber aDrive)
+	/**
+	Synchronous call to make the callback on the active backup client
+	
+	@param aDrive The drive that's affected by the operation
+	*/
+		{
+		__LOG1("CABSession::MakeCallbackInitialiseRestoreBaseDataL() - [0x%08x] Calling InitRestoreBaseData", iClientSID.iId);
+
+		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackInitialiseRestoreBaseDataSection);
+		TPckgC<TDriveNumber> drivePkg(aDrive);
+
+		iCallbackInProgress = EABCallbackInitialiseRestoreBaseDataSection;
+
+		CheckCallbackAvailableL();
+		iMessage.WriteL(0, callbackPkg);
+		iMessage.WriteL(1, drivePkg);
+		MadeCallback();
+
+		User::LeaveIfError(iABClientLeaveCode);
+		}
+
+	void CABSession::MakeCallbackRestoreBaseDataSectionL(TDesC8& aBuffer, TBool aFinished)
+	/**
+	Synchronous call to make the callback on the active backup client
+	
+	@param aBuffer The data to restore
+	@param aFinished Is this the last of a multi-part data call
+	*/
+		{
+		__LOG1("CABSession::MakeCallbackRestoreBaseDataSectionL() - [0x%08x] Calling RestoreBaseDataSection", iClientSID.iId);
+
+		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackRestoreBaseDataSection);
+		TPckgC<TInt> sizePkg(aBuffer.Size());
+		TPckgC<TBool> lastSectionPkg(aFinished);
+		
+		iCallbackInProgress = EABCallbackRestoreBaseDataSection;
+
+		iSendToClientBuffer.Set(aBuffer);
+		
+		CheckCallbackAvailableL();
+		iMessage.WriteL(0, callbackPkg);
+		iMessage.WriteL(1, sizePkg);
+		iMessage.WriteL(2, lastSectionPkg);
+		MadeCallback();
+
+		User::LeaveIfError(iABClientLeaveCode);
+		}
+
+	void CABSession::MakeCallbackInitialiseRestoreIncrementDataL(TDriveNumber aDrive)
+	/**
+	Synchronous call to make the callback on the active backup client
+	
+	@param aDrive The drive that's affected by the operation
+	*/
+		{
+		__LOG1("CABSession::MakeCallbackInitialiseRestoreIncrementDataL() - [0x%08x] Calling InitRestoreIncrementData", iClientSID.iId);
+
+		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackInitialiseRestoreIncrementData);
+		TPckgC<TDriveNumber> drivePkg(aDrive);
+
+		iCallbackInProgress = EABCallbackInitialiseRestoreIncrementData;
+
+		CheckCallbackAvailableL();
+		iMessage.WriteL(0, callbackPkg);
+		iMessage.WriteL(1, drivePkg);
+		MadeCallback();
+
+		User::LeaveIfError(iABClientLeaveCode);
+		}
+
+	void CABSession::MakeCallbackRestoreIncrementDataSectionL(TDesC8& aBuffer, TBool aFinished)
+	/**
+	Synchronous call to make the callback on the active backup client
+	
+	@param aBuffer The data to restore
+	@param aFinished Is this the last of a multi-part data call
+	*/
+		{
+		__LOG1("CABSession::MakeCallbackRestoreIncrementDataSectionL() - [0x%08x] Calling RestoreIncrementData", iClientSID.iId);
+
+		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackRestoreIncrementDataSection);
+		TPckgC<TInt> sizePkg(aBuffer.Size());
+		TPckgC<TBool> lastSectionPkg(aFinished);
+
+		iCallbackInProgress = EABCallbackRestoreIncrementDataSection;
+
+		iSendToClientBuffer.Set(aBuffer);
+		
+		CheckCallbackAvailableL();
+		iMessage.WriteL(0, callbackPkg);
+		iMessage.WriteL(1, sizePkg);
+		iMessage.WriteL(2, lastSectionPkg);
+		MadeCallback();
+
+		User::LeaveIfError(iABClientLeaveCode);
+		}
+
+	void CABSession::MakeCallbackRestoreCompleteL(TDriveNumber aDrive)
+	/**
+	Synchronous call to make the callback on the active backup client
+	
+	@param aDrive The drive that's affected by the operation
+	*/
+		{
+		__LOG1("CABSession::MakeCallbackRestoreCompleteL() - [0x%08x] Calling RestoreComplete", iClientSID.iId);
+
+		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackRestoreComplete);
+		TPckgC<TDriveNumber> drivePkg(aDrive);
+
+		iCallbackInProgress = EABCallbackRestoreComplete;
+
+		CheckCallbackAvailableL();
+		iMessage.WriteL(0, callbackPkg);
+		iMessage.WriteL(1, drivePkg);
+		MadeCallback();
+		}
+
+	void CABSession::MakeCallbackInitialiseGetProxyBackupDataL(TSecureId aSID, TDriveNumber aDrive)
+	/**
+	Synchronous call to make the callback on the active backup client
+	
+	@param aSID The SecureId of the Proxy
+	@param aDrive The drive that's affected by the operation
+	*/
+		{
+		__LOG1("CABSession::MakeCallbackInitialiseGetProxyBackupDataL() - [0x%08x] Calling InitGetProxyBackupData", iClientSID.iId);
+
+		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackInitialiseGetProxyBackupData);
+		TPckgC<TSecureId> sidPkg(aSID);
+		TPckgC<TDriveNumber> drivePkg(aDrive);
+
+		iCallbackInProgress = EABCallbackInitialiseGetProxyBackupData;
+
+		CheckCallbackAvailableL();
+		iMessage.WriteL(0, callbackPkg);
+		iMessage.WriteL(1, sidPkg);
+		iMessage.WriteL(2, drivePkg);
+		MadeCallback();
+
+		User::LeaveIfError(iABClientLeaveCode);
+		}
+
+	void CABSession::MakeCallbackInitialiseRestoreProxyBaseDataL(TSecureId aSID, TDriveNumber aDrive)
+	/**
+	Synchronous call to make the callback on the active backup client
+	
+	@param aSID The SecureId of the Proxy
+	@param aDrive The drive that's affected by the operation
+	*/
+		{
+		__LOG1("CABSession::MakeCallbackInitialiseRestoreProxyBaseDataL() - [0x%08x] Calling InitRestoreProxyBaseData", iClientSID.iId);
+
+		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackInitialiseRestoreProxyBaseData);
+		TPckgC<TSecureId> sidPkg(aSID);
+		TPckgC<TDriveNumber> drivePkg(aDrive);
+
+		iCallbackInProgress = EABCallbackInitialiseRestoreProxyBaseData;
+
+		CheckCallbackAvailableL();
+		iMessage.WriteL(0, callbackPkg);
+		iMessage.WriteL(1, sidPkg);
+		iMessage.WriteL(2, drivePkg);
+		MadeCallback();
+
+		User::LeaveIfError(iABClientLeaveCode);
+		}
+
+	void CABSession::MakeCallbackTerminateMultiStageOperationL()
+	/**
+	Synchronous call to make the callback on the active backup client
+	
+	*/
+		{
+		__LOG1("CABSession::MakeCallbackTerminateMultiStageOperationL() - [0x%08x] Calling TermiateMultiStageOp", iClientSID.iId);
+
+		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackTerminateMultiStageOperation);
+
+		iCallbackInProgress = EABCallbackTerminateMultiStageOperation;
+
+		CheckCallbackAvailableL();
+		iMessage.WriteL(0, callbackPkg);
+		MadeCallback();
+		}
+
+	TUint CABSession::MakeCallbackGetDataChecksumL(TDriveNumber aDrive)
+	/**
+	Synchronous call to make the callback on the active backup client
+	
+	@param aDrive The drive that's affected by the operation
+	@return The checksum of the data
+	*/
+		{
+		__LOG1("CABSession::MakeCallbackGetDataChecksumL() - [0x%08x] Calling GetDataChecksum", iClientSID.iId);
+
+		TPckgC<TABCallbackCommands> callbackPkg(EABCallbackGetDataChecksum);
+		TPckgC<TDriveNumber> drivePkg(aDrive);
+		TPckgBuf<TUint> returnPkg;
+
+		iCallbackInProgress = EABCallbackGetDataChecksum;
+
+		CheckCallbackAvailableL();
+		iMessage.WriteL(0, callbackPkg);
+		iMessage.WriteL(1, drivePkg);
+		MadeCallback();
+		
+		iMessage.ReadL(3, returnPkg);
+		
+		return returnPkg();
+		}
+	
+	void CABSession::SetInvalid()
+	/** 
+	Invalidate this session, so that this session can not be 
+	used in sequent backup/restore event
+	*/
+		{
+		iInvalid = ETrue;
+		}
+		
+	TBool CABSession::Invalidated()
+	/** 
+	Return whether this session has been invalidated
+		 
+	@Return ETrue if this session aleady be invalidated;otherwise EFalse
+	*/
+		{
+		return iInvalid;
+		}
+	}
+
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/absessionmap.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,178 @@
+// 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:
+// Implementations of CABSessionMap and CABSessionElement classes.
+// 
+//
+
+/**
+ @file
+*/
+
+#include "absession.h"
+#include "absessionmap.h"
+#include "sbedataowner.h"
+#include <connect/panic.h>
+
+namespace conn
+	{
+	
+	CABSessionElement::CABSessionElement(TSecureId aSecureId) : iKey(aSecureId), iValue(NULL)
+    /**
+    Class Constructor
+
+	@param aSecureId The secure Id of the data owner that the session has been created for    
+	*/
+		{
+		}
+
+	CABSessionElement::~CABSessionElement()
+    /**
+    Class destructor
+    */
+		{
+		}
+
+	CABSessionElement* CABSessionElement::NewL(TSecureId aSecureId)
+	/**
+	Symbian first phase constructor
+	@param aSecureId The secure Id of the data owner that the session has been created for
+	*/
+		{
+		CABSessionElement* self = new (ELeave) CABSessionElement(aSecureId);
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		CleanupStack::Pop(self);
+		return self;
+		}
+		
+	void CABSessionElement::ConstructL()
+	/**
+	Create the session for the data owner specified by iKey
+	*/
+		{
+		// Note that the server takes ownership of the session, not this object
+		iValue = CABSession::NewL(iKey);
+		}
+					
+	CABSessionMap* CABSessionMap::NewL()
+	/**
+	Symbian first phase constructor
+	
+	@return Pointer to a created CABSessionMap object
+	*/
+		{
+		CABSessionMap* self = new (ELeave) CABSessionMap;
+		return self;
+		}
+		
+	CABSession& CABSessionMap::CreateL(TSecureId aSecureId)
+	/**
+	Create a new element and session, returning that session if required
+	
+	@param aSecureId The SID to initialise the session with
+	@return Reference to the created session
+	*/
+		{
+		CABSessionElement* element = CABSessionElement::NewL(aSecureId);
+		CleanupStack::PushL(element);
+		iMapElements.AppendL(element);
+		CleanupStack::Pop(element);
+		return element->Value();
+		}
+		
+	void CABSessionMap::Delete(TSecureId aSecureId)
+	/**
+	Delete the session and remove it from the map
+	
+	@param aSecureId The key to the session to be deleted
+	*/
+		{
+		TInt count = iMapElements.Count();
+		
+		for (TInt index = 0; index < count; index++)
+			{
+			if (iMapElements[index]->Key() == aSecureId)
+				{
+				delete iMapElements[index];
+				iMapElements.Remove(index);
+				
+				break;
+				}
+			}
+		}
+		
+	CABSession& CABSessionMap::SessionL(TSecureId aSecureId)
+	/**
+	Accessor for the session using the SID as the key
+	
+	@param aSecureId The SID of the DO that's connected to the returned session
+	@leave KErrNotFound If no session exists for that SID
+	@return The session that the DO with SID aSecureId is connected to
+	*/
+		{
+		TInt count = iMapElements.Count();
+		CABSession* pSession = NULL;
+		
+		for (TInt index = 0; index < count; index++)
+			{
+			if (iMapElements[index]->Key() == aSecureId)
+				{
+				pSession = &iMapElements[index]->Value();
+				
+				break;
+				}
+			}
+			
+		if (!pSession)
+			{
+			User::Leave(KErrNotFound);
+			}
+		
+		return *pSession;
+		}
+
+	CABSessionMap::CABSessionMap()
+    /**
+    Class Constructor
+    */
+		{
+		}
+
+	CABSessionMap::~CABSessionMap()
+    /**
+    Class destructor
+    */
+		{
+		iMapElements.ResetAndDestroy();
+		iMapElements.Close();
+		}
+	
+	void CABSessionMap::InvalidateABSessions()
+	/** 
+	Set each CABSession currently hold in the map as invalid
+	*/ 
+		{
+		TInt count = iMapElements.Count();
+		CABSession* pSession = NULL;
+					
+		for (TInt index = 0; index < count; index++)
+			{
+			pSession = &iMapElements[index]->Value();
+			if (pSession)
+				{
+				pSession->SetInvalid();
+				}
+			}
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sbebufferhandler.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1198 @@
+// 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:
+// Implementation of CBufferFileWriter and CBufferReader
+// 
+//
+
+/**
+ @file
+*/
+
+
+#include "sbebufferhandler.h"
+#include "sblog.h"
+#include <connect/panic.h>
+
+namespace conn
+	{
+	template<class T>
+	TBool ReadFromBufferF(T& aT, TUint8*& appCurrent, const TUint8* apEnd)
+	/** Template class to read flat structures from the buffer
+	
+	@param aT on return the flat structure.
+	@param appCurrent The current point into the buffer.
+	@param apEnd The end of the buffer.
+	@return ETrue if read succesfully. EFalse if a retry is needed.
+	*/
+		{
+		static TBuf8<sizeof(T)> SBuffer; // Static buffer used for buffering!
+		TBool ret = EFalse;
+		
+		// Is there anything already in the buffer?
+		TUint8* ptr = NULL;
+		if (SBuffer.Size() > 0)
+			{
+			TInt size = SBuffer.Size();
+			SBuffer.Append(appCurrent, sizeof(T) - size);
+			ptr = const_cast<TUint8*>(SBuffer.Ptr());
+			
+			appCurrent += sizeof(T) - size;
+			
+			ret = ETrue;
+			} // if
+		else
+			{
+			// Is there enough room in current
+			if ((apEnd - appCurrent) < static_cast<TInt>(sizeof(T)))
+				{
+				// Need to buffer
+				SBuffer.Copy(appCurrent, apEnd - appCurrent);
+				} // if
+			else
+				{
+				ptr = appCurrent;
+				appCurrent += sizeof(T);
+				ret = ETrue;
+				} // else
+			} // else
+			
+		if (ret)
+			{
+			// Use a loop to copy to avoid alignment issues
+			TUint8* ptrOut = reinterpret_cast<TUint8*>(&aT);
+			for (TUint x = 0; x < sizeof(T); x++)
+				{
+				*ptrOut++ = *ptr++;
+				} // for
+			
+			SBuffer.SetLength(0);
+			}
+			
+		return ret;
+		}
+
+	template TBool ReadFromBufferF<TFileFixedHeader>(TFileFixedHeader&, TUint8*&, const TUint8*);
+	template TBool ReadFromBufferF<TSnapshot>(TSnapshot&, TUint8*&, const TUint8*);
+	
+	template<class T>
+	TBool WriteToBufferF(T& aT, TPtr8& aPtr)
+	/** Writes flat structures to the buffer.
+	
+	NOTE: This should _ONLY_ be used to write T classes to the buffer.
+	
+	@param aT The flat structure to write to the buffer.
+	@param ptr The buffer to write to.
+	@return ETrue on success. EFalse on failure.
+	*/
+		{
+		TBool ret = EFalse;
+		
+		if ((aPtr.MaxSize() - aPtr.Size()) >= static_cast<TInt>(sizeof(T)))
+			{
+			aPtr.Append(reinterpret_cast<TUint8*>(&aT), sizeof(T));
+			ret = ETrue;
+			} // if
+		
+		return ret;
+		}
+		
+	TBool ReadFromBufferV(TPtr8& aT, TInt aSize, TUint8*& appCurrent, const TUint8* apEnd)
+	/** Reads from the buffer.
+	
+	@param aT on return the data read.
+	@param aSize size of the data to read.
+	@param appCurrent Pointer to read from.
+	@param apEnd the end of the data.
+	@return ETrue on success. EFalse on failure.
+	*/
+		{
+		TBool ret = EFalse;
+		
+		// Does into already contain data?
+		if (aT.Size() > 0)
+			{
+			TInt tocopy = aSize - aT.Size();
+			aT.Append(appCurrent, tocopy);
+			appCurrent += tocopy;
+			ret = ETrue;
+			} // if
+		else
+			{
+			// Is there enough data?
+			if ((apEnd - appCurrent) < aSize)
+				{
+				aT.Copy(appCurrent, apEnd - appCurrent);
+				appCurrent = const_cast<TUint8*>(apEnd);
+				} // if
+			else
+				{
+				aT.Copy(appCurrent, aSize);
+				appCurrent += aSize;
+				ret = ETrue;
+				} // else
+			} // else
+		
+		return ret;
+		}
+		
+	TBool WriteToBufferV(const TPtr8& aPtr, TInt aSize, TPtr8& aBuffer)
+	/** Writes some vairable data to the buffer.
+	
+	NOTE: This should _ONLY_ be used to write T classes to the buffer.
+	
+	@param aPtr buffer to read from.
+	@param aSize size of the data to write.
+	@param aBuffer the buffer to write to.
+	@return ETrue on success. EFalse on failure.
+	*/
+		{
+		TBool ret = EFalse;
+		
+		if ((aBuffer.MaxSize() - aBuffer.Size()) >= aSize)
+			{
+			aBuffer.Append(aPtr.Ptr(), aSize);
+			ret = ETrue;
+			} // if
+		
+		
+		return ret;
+		}
+		
+	CBufferFileWriter* CBufferFileWriter::NewL(RFs& aFs, CDesCArray* aFileNames)
+	/** Symbain constructor
+	
+	@param aFs Handle to the Symbian Fs file server
+	@param aFileNames list of files to write ownership transfer
+	@return a CBufferFileWriter.
+	*/
+		{
+		CBufferFileWriter* self = new(ELeave) CBufferFileWriter(aFs, aFileNames);
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		CleanupStack::Pop(self);
+		
+		return self;
+		} // NewL
+		
+	CBufferFileWriter::CBufferFileWriter(RFs& aFs, CDesCArray* aFileNames) :
+		iFs(aFs), iFileNames(aFileNames)
+	/** Standard C++ constructor
+	
+	@param aFs an RFS to use in this class.
+	*/
+		{
+		} // CBufferFileWriter
+		
+	CBufferFileWriter::~CBufferFileWriter()
+	/** Standard C++ destructor
+	*/
+		{
+		delete iFileNames;
+		iFileHandle.Close();
+		}
+		
+	void CBufferFileWriter::ConstructL()
+	/** Symbain second phase constructor
+	
+	@param aFileNames list of files to write
+	*/
+		{
+		#if defined(SBE_LOGGING_ENABLED)
+		if (iFileNames)
+			{
+			TUint count = iFileNames->Count();
+			while(count--)
+				{
+				const TDesC& fileName = (*iFileNames)[count];
+            	__LOG2("CBufferFileWriter::ConstructL() - file[%04d] is: %S", count, &fileName);
+				}
+			}
+		
+		#endif
+		}
+		
+	void CBufferFileWriter::StartL(TPtr8& aBuffer, TBool& aCompleted)
+	/** Start writing the files to the buffer
+	
+	@param aBuffer The buffer to write to.
+	@param aCompleted on return if we have finished.
+	*/
+		{
+        __LOG("CBufferFileWriter::StartL() - START");
+		WriteToBufferL(aBuffer, aCompleted);
+        __LOG("CBufferFileWriter::StartL() - END");
+		} // StartL
+		
+	void CBufferFileWriter::ContinueL(TPtr8& aBuffer, TBool& aCompleted)
+	/** Continue writing the files to the buffer
+	
+	@param aBuffer The buffer to write to.
+	@param aCompleted on return if we have finished.
+	*/
+		{
+        __LOG("CBufferFileWriter::ContinueL() - START");
+		WriteToBufferL(aBuffer, aCompleted);
+        __LOG("CBufferFileWriter::ContinueL() - END");
+		}
+
+	void CBufferFileWriter::WriteToBufferL(TPtr8& aBuffer, TBool& aCompleted)
+	/** Writes files to the buffer
+	
+	@param aBuffer The buffer to write to.
+	@param aCompleted on return if we have finished.
+	*/
+		{
+		aCompleted = EFalse;
+		
+		const TUint count = iFileNames->Count();
+		while (iCurrentFile < count)
+			{
+            const TDesC& name = (*iFileNames)[iCurrentFile];
+			
+			_LIT( KTrailingBackSlash, "\\" );
+            if (name.Right(1) == KTrailingBackSlash() )
+            	{
+             	// Directory entry
+ 	           	__LOG1("CBufferFileWriter::WriteToBufferL() - empty directory: %S ", &name);
+ 	           	if(!iHeaderWritten)
+ 	        	   {
+ 	        	   TFileFixedHeader header(name.Length(), 0, 0, 0);
+ 	        	   if (WriteToBufferF(header, aBuffer) == EFalse)
+ 	        		   {
+ 	        		   __LOG("CBufferFileReader::WriteToBufferL() - WriteToBufferF() returned False so breaking!");
+ 	        		   break;
+ 	        		   }
+ 	        	   iHeaderWritten = ETrue;
+ 	        	   } // if
+ 	           	
+				TPtr8 ptr(reinterpret_cast<TUint8*>(const_cast<TUint16*>(name.Ptr())), name.Size(), name.Size());
+				
+				if (WriteToBufferV(ptr, ptr.Size(), aBuffer) == EFalse)
+					{
+					__LOG("CBufferFileReader::WriteToBufferL() - WriteToBufferV() returned False so breaking!");
+					break;
+					}
+
+ 	           	iHeaderWritten = EFalse;
+ 	           	iFileNameWritten = EFalse;
+            	}
+            else
+            	{
+				if (!iFileOpen) // File needs to be opened
+					{
+	                __LOG1("CBufferFileWriter::WriteToBufferL() - trying to open: %S for reading", &name);
+					const TInt error = iFileHandle.Open(iFs, name, EFileRead | EFileShareReadersOnly);
+	                if  (error != KErrNone)
+	                    {
+	                    __LOG2("CBufferFileWriter::WriteToBufferL() - opening: %S for reading failed with error: %d", &name, error);
+	                    User::Leave(error);
+	                    }
+
+					iFileOpen = ETrue;
+					} // if
+					
+				if (iFileOpen && !iHeaderWritten)
+					{
+					// File size
+					TInt size;
+					TInt err = iFileHandle.Size(size);
+	                __LOG2("CBufferFileWriter::WriteToBufferL() - size of file is: %d (err: %d)", size, err);
+					TUint att;
+					err = iFileHandle.Att(att);
+					__LOG2("CBufferFileWriter::WriteToBufferL() - attributes: %d (err: %d)", size, err);
+					TTime modified;
+					err = iFileHandle.Modified(modified);
+					__LOG2("CBufferFileWriter::WriteToBufferL() - modified: %d (err: %d)", size, err);
+					TFileFixedHeader header((*iFileNames)[iCurrentFile].Length(), size, att, modified.Int64());
+					if (WriteToBufferF(header, aBuffer) == EFalse)
+						{
+						__LOG("CBufferFileReader::WriteToBufferL() - WriteToBufferF() returned False so breaking!");
+						break;
+						}
+						
+					iHeaderWritten = ETrue;
+					} // if
+					
+				// Write filename
+				if (!iFileNameWritten)
+					{
+					
+					TPtr8 ptr(reinterpret_cast<TUint8*>(const_cast<TUint16*>(name.Ptr())), name.Size(), name.Size());
+					
+					if (WriteToBufferV(ptr, ptr.Size(), aBuffer) == EFalse)
+						{
+						__LOG("CBufferFileReader::WriteToBufferV() - WriteToBufferF() returned False so breaking!");
+						break;
+						}
+					iFileNameWritten = ETrue;
+					}
+
+	            __LOG1("CBufferFileWriter::WriteToBufferL() - buffer is of length: %d", aBuffer.Length());
+					
+				TInt bufferLeft = aBuffer.MaxSize() - aBuffer.Size();
+				TPtr8 ptr(const_cast<TUint8*>(aBuffer.Ptr()) + aBuffer.Size(), bufferLeft);
+				TInt fileSize = 0;
+				iFileHandle.Size(fileSize);
+				TInt fileLeft = fileSize - iOffset;
+				if (bufferLeft < fileLeft)
+					{
+	                __LOG("CBufferFileWriter::WriteToBufferL() - buffer space available is less than file size!");
+
+	                // Write buffer size
+					User::LeaveIfError(iFileHandle.Read(iOffset, ptr, bufferLeft)); // TODO: Is this correct?
+					aBuffer.SetLength(aBuffer.Length() + bufferLeft);
+					iOffset += bufferLeft;
+					break;
+					} // if
+				else
+					{
+	                __LOG("CBufferFileWriter::WriteToBufferL() - enough space in buffer for whole file...");
+
+	                // Write file size
+					User::LeaveIfError(iFileHandle.Read(ptr, fileLeft)); // TODO: Is this correct?
+					aBuffer.SetLength(aBuffer.Length() + fileLeft);
+					} // else
+
+	            __LOG1("CBufferFileWriter::WriteToBufferL() - After read from file, buffer is now of length: %d", aBuffer.Length());
+	            
+				iFileHandle.Close();
+				iFileOpen = EFalse;
+				iHeaderWritten = EFalse;
+				iFileNameWritten = EFalse;
+				iOffset = 0;
+            	} //else
+			++iCurrentFile;
+			} // while
+			
+		if (iCurrentFile >= count)
+			{
+			aCompleted = ETrue;
+			} // if
+		} // WriteToBufferL
+		
+	CBufferFileReader* CBufferFileReader::NewL(RFs& aFs, RSnapshots* apSnapshots, MValidationHandler* aValidationHandler)
+	/** Symbian OS constructor
+	
+	@param aFs File server to use.
+	@param apSnapshots list of snapshots.
+	*/
+		{
+        __LOG("CBufferFileReader::NewL() - START");
+		CBufferFileReader* self = new(ELeave) CBufferFileReader(aFs, apSnapshots, aValidationHandler);
+		
+		CleanupStack::PushL( self );
+		
+	#ifdef SBE_LOGGING_ENABLED
+        if  (apSnapshots)
+            {
+		    const TInt count = apSnapshots->Count();
+            __LOG1("CBufferFileReader::NewL() - Got %d snapshots to compare against during restore...", count);
+
+		    for(TInt x = 0; x < count; ++x)
+			    {
+                const TDesC& snapshot = (*apSnapshots)[x]->FileName();
+                __LOG3("CBufferFileReader::NewL() -    snapshot[%4d/%4d] is: %S", x+1, count, &snapshot);
+			    } // for x
+
+		    }
+	#endif
+        
+        __LOG("CBufferFileReader::NewL() - END");
+        
+        CleanupStack::Pop( self );
+		return self;
+		} // NewL
+		
+	CBufferFileReader::CBufferFileReader(RFs& aFs, RSnapshots* apSnapshots, MValidationHandler* aValidationHandler) :
+		iFs(aFs), iSnapshots(apSnapshots), iValidationHandler(aValidationHandler)
+	/** C++ constructor
+	
+	@param aFs File server to use.
+	@param apSnapshots list of snapshots.
+	*/
+		{
+		} // CBufferFileReader
+		
+	void CBufferFileReader::StartL(const TDesC8& aBuffer, TBool aLastSection)
+	/** Start reading from the buffer.
+	
+	@param aBuffer The buffer to read from.
+	@param aLastSection Is this the last section?
+	*/
+		{
+        __LOG("CBufferFileReader::StartL() - START");
+        if (iSnapshots)
+        	{
+        	iSnapshots->Sort(CSnapshot::Compare);
+        	}
+		ReadFromBufferL(aBuffer, aLastSection);
+        __LOG("CBufferFileReader::StartL() - END");
+		} // StartL
+	
+	void CBufferFileReader::ContinueL(const TDesC8& aBuffer, TBool aLastSection)
+	/** Continue reading from the buffer.
+	
+	@param aBuffer The buffer to read from.
+	@param aLastSection Is this the last section?
+	*/
+		{
+        __LOG("CBufferFileReader::ContinueL() - START");
+		ReadFromBufferL(aBuffer, aLastSection);
+        __LOG("CBufferFileReader::ContinueL() - END");
+		} // ContinueL
+	
+	void CBufferFileReader::CheckFileInSnapshotL()
+	/**
+	Checks to see if a given file is in a snapshot.
+	*/
+		{
+        __LOG2("CBufferFileReader::CheckFileInSnapshot() - START - ipSnapshots: 0x%08x, iSnapshotChecked: %d", iSnapshots, iSnapshotChecked);
+
+		iRestore = ETrue;
+		
+		if (iSnapshots)
+			{
+			CSnapshot* snapshot = CSnapshot::NewLC(TTime().Int64(), iFileName);
+			TInt res = iSnapshots->Find(snapshot, CSnapshot::Match);
+			if (res == KErrNotFound)
+				{
+				iRestore = EFalse;
+				}
+			CleanupStack::PopAndDestroy(snapshot);		
+			} // if
+		
+		iSnapshotChecked = ETrue;
+
+        __LOG2("CBufferFileReader::CheckFileInSnapshot() - END - iSnapshotChecked: %d, iRestore: %d", iSnapshotChecked, iRestore);
+		}
+		
+	void CBufferFileReader::RecreateDirL()
+	/**
+	Recreates a directory path on disk.
+	*/
+		{
+        __LOG1("CBufferFileReader::RecreateDirL() - START - iFileName: %S", &iFileName);
+		// Create the path
+		TInt err = iFs.MkDirAll(iFileName);
+		if ((err != KErrNone) && (err != KErrAlreadyExists))
+			{
+            __LOG1("CBufferFileReader::WriteToFile() - making directory resulted in fatal error: %d", err);
+			User::Leave(err);
+			} // if
+        
+        __LOG("CBufferFileReader::RecreateDirL() - END");
+		}
+		
+	
+	void CBufferFileReader::RecreateFileL()
+	/**
+	Recreates a file on disk. Deletes the original if it still exists.
+	*/
+		{
+        __LOG1("CBufferFileReader::RecreateFileL() - START - iFileName: %S", &iFileName);
+		// Create the path
+		TInt err = iFs.MkDirAll(iFileName);
+		if ((err != KErrNone) && (err != KErrAlreadyExists))
+			{
+            __LOG1("CBufferFileReader::WriteToFile() - making directory resulted in fatal error: %d", err);
+			User::Leave(err);
+			} // if
+
+        
+        err = iFileHandle.Replace(iFs, iFileName, EFileWrite);
+        __LOG1("CBufferFileReader::WriteToFile() - replacing file returned err: %d", err);
+        User::LeaveIfError( err );
+			
+		iFileOpen = ETrue;
+        __LOG("CBufferFileReader::RecreateFileL() - END");
+		}
+	
+		
+	TBool CBufferFileReader::WriteToFileL(TUint8*& aCurrent, const TUint8* aEnd)
+	/**
+	Writes data to a file.
+	
+	@param aCurrent start point of data to write.
+	@param aEnd end point of data to write.
+	@return ETrue if write finished. EFalse if there is more data to write.
+	*/
+		{
+        __LOG2("CBufferFileReader::WriteToFile() - START - iFileHandle: 0x%08x, iFixedHeader.iFileSize: %d", iFileHandle.SubSessionHandle(), iFixedHeader.iFileSize);
+		TBool retVal = ETrue;
+		TInt filesize;
+		const TInt err1 = iFileHandle.Size(filesize);
+        __LOG2("CBufferFileReader::WriteToFile() - fileSize: %d (err: %d)", filesize, err1);
+		User::LeaveIfError(err1);
+		if ((aEnd - aCurrent) >= (iFixedHeader.iFileSize - filesize))
+			{
+			TPtr8 ptr(aCurrent, iFixedHeader.iFileSize -filesize, iFixedHeader.iFileSize - filesize);
+			const TInt err2 = iFileHandle.Write(ptr);
+            __LOG2("CBufferFileReader::WriteToFile() - writing %d bytes returned error: %d", ptr.Length(), err2);
+			User::LeaveIfError(err2);
+
+			// Write the attributes & modified time
+			const TInt err3 = iFileHandle.Set(iFixedHeader.iModified, 
+					iFixedHeader.iAttributes, KEntryAttNormal);
+
+            __LOG1("CBufferFileReader::WriteToFile() - setting attribs returned error: %d", err3);
+			User::LeaveIfError(err3);
+			
+			// Move current along
+			aCurrent += iFixedHeader.iFileSize - filesize;
+
+			// Finished reset state
+			Reset();
+			} // if
+		else
+			{
+			TInt size = aEnd - aCurrent;
+			TPtr8 ptr(aCurrent, size, size);
+			const TInt err2 = iFileHandle.Write(ptr);
+            __LOG2("CBufferFileReader::WriteToFile() - writing %d bytes returned error: %d", ptr.Length(), err2);
+
+			retVal = EFalse;
+			} // else
+			
+        __LOG1("CBufferFileReader::WriteToFile() - END - finished: %d", retVal);
+		return retVal;
+		}
+
+	void CBufferFileReader::ReadFromBufferL(const TDesC8& aBuffer, TBool aLastSection)
+	/** Reads from the buffer and writes files to disk.
+	
+	@param aBuffer The buffer to read from.
+	@param aLastSection Is this the last section?
+	@leave KErrUnderflow More data is needed.
+	*/	
+        {
+        __LOG5("CBufferFileReader::ReadFromBufferL() - START - iFileNameRead: %d, iSnapshotChecked: %d, iRestore: %d, iFileOpen: %d, iFileName: %S", iFileNameRead, iSnapshotChecked, iRestore, iFileOpen, &iFileName);
+
+        TUint8* current = const_cast<TUint8*>(aBuffer.Ptr());
+		const TUint8* end = current + aBuffer.Size();
+		
+		// Workaround for "dual fixed header in backup" error. Tries to detect the special error case where iFixedHeaderRead=true but filename wasn't read
+		if(iFixedHeaderRead && !iFileNameRead && !iBytesRead && (end-current) >= 12)
+			{
+			// Check the first 12 bytes of the header we already got (the iModified is different between the problematic second header)
+			const TUint8* tempbuf = (TUint8*)&iFixedHeader;
+			TBool workAroundNeeded = ETrue;
+			for(TInt i = 0; i < 12; i++)
+				{
+				if(current[i] != tempbuf[i])
+					{
+					workAroundNeeded = EFalse;
+					break;
+					}
+				}
+
+			if(workAroundNeeded)
+				{
+				__LOG("CBufferFileReader::ReadFromBufferL() - Dual header was detected, workaround!!!");
+				iFixedHeaderRead = EFalse; // Mark that the processing loop reads the fixed header again
+				}
+			}
+		
+		while (current < end)
+			{
+            __LOG2("CBufferFileReader::ReadFromBufferL() - iFixedHeaderRead: %d, iLeftToSkip: %d", iFixedHeaderRead, iLeftToSkip);
+
+			// Do we have the fixed header?
+			if (!iFixedHeaderRead)
+				{
+				if (ReadFromBufferF(iFixedHeader, current, end) == EFalse)
+					{
+					__LOG("CBufferFileReader::ReadFromBufferL() - ReadFromBufferF() returned False so breaking!");
+					break;
+					} // if
+				
+                __LOG1("CBufferFileReader::ReadFromBufferL() - fixed header - iFileNameLength:  %d", iFixedHeader.iFileNameLength);
+                __LOG1("CBufferFileReader::ReadFromBufferL() - fixed header - iFileSize:        %d", iFixedHeader.iFileSize);
+                __LOG1("CBufferFileReader::ReadFromBufferL() - fixed header - iAttributes:      %d", iFixedHeader.iAttributes);
+                
+                if ((iFixedHeader.iFileNameLength > KMaxFileName) || (!iFixedHeader.iFileNameLength))
+					{
+					__LOG1("CBufferFileReader::ReadFromBufferL() - Leaving - iFileNameLength: %d more then MaxLength", iFixedHeader.iFileNameLength);
+					User::Leave(KErrOverflow);
+					}
+                
+				iFixedHeaderRead = ETrue;
+				} // if
+
+				
+            __LOG1("CBufferFileReader::ReadFromBufferL() - iFileNameRead: %d", iFileNameRead);
+			if (!iFileNameRead)
+				{
+				TPtr8 ptr(reinterpret_cast<TUint8*>(const_cast<TUint16*>(iFileName.Ptr())), iBytesRead, iFixedHeader.iFileNameLength * KCharWidthInBytes);
+				
+				if (ReadFromBufferV(ptr, iFixedHeader.iFileNameLength * KCharWidthInBytes, current, end) == EFalse)
+					{
+					iBytesRead = ptr.Size();
+					__LOG1("CBufferFileReader::ReadFromBufferL() - ReadFromBufferV() returned False - Filename bytes read: %d", iBytesRead);
+					break;
+					} // if
+				
+				iFileName.SetLength(iFixedHeader.iFileNameLength);
+				iFileNameRead = ETrue;
+                __LOG1("CBufferFileReader::ReadFromBufferL() - Got filename: %S", &iFileName);
+				}
+			
+			// Is the file in the snapshot, if not it was deleted in an increment and does not need restoring
+            __LOG1("CBufferFileReader::ReadFromBufferL() - iSnapshotChecked: %d", iSnapshotChecked);
+			if (!iSnapshotChecked)
+				{
+				CheckFileInSnapshotL();
+				} // if
+			
+            __LOG2("CBufferFileReader::ReadFromBufferL() - iValidationHandler: 0x%08x, iRestore: %d", iValidationHandler, iRestore);
+			if (iValidationHandler != NULL)
+				{
+				if (iRestore)
+					{
+					iRestore = iValidationHandler->ValidFileL(iFileName);
+                    __LOG1("CBufferFileReader::ReadFromBufferL() - validation handler result: %d", iRestore);
+					}
+				}
+			
+			if (!iRestore && !iLeftToSkip)
+				{
+                __LOG1("CBufferFileReader::ReadFromBufferL() - restore not permitted, skipping file data (%d bytes)", iFixedHeader.iFileSize);
+				iLeftToSkip = iFixedHeader.iFileSize; // So we can skip the bytes
+				}
+			
+            __LOG1("CBufferFileReader::ReadFromBufferL() - iFileOpen: %d", iFileOpen);
+			if (iRestore)
+				{
+				// Check if it is a directory or file
+				_LIT( KTrailingBackSlash, "\\" );
+				if (iFileName.Right(1) == KTrailingBackSlash())
+					{
+					__LOG("CBufferFileReader::ReadFromBufferL() - Attempting to recreate directory path...");
+					RecreateDirL();
+					Reset();
+					}
+				else 
+					{
+					// Have we opened the file?
+					if (!iFileOpen)
+						{
+						__LOG("CBufferFileReader::ReadFromBufferL() - Attempting to recreate file...");
+						RecreateFileL();		
+						}
+					
+					// Write to the file
+	                __LOG("CBufferFileReader::ReadFromBufferL() - Attempting to write to file...");
+					if (!WriteToFileL(current, end))
+						{
+						__LOG("CBufferFileReader::ReadFromBufferL() - WriteToFileL() returned False so breaking!");
+						break;
+						}	
+					}//if
+				} // if
+			else
+				{
+				// We need to skip the bytes in the data
+                __LOG2("CBufferFileReader::ReadFromBufferL() - We\'re in skip mode. EndPos: %8d, CurrentPos: %8d", end, current);
+				if ((end - current) >= iLeftToSkip)
+					{
+					current += iLeftToSkip;
+
+					// Finished reset state
+                    __LOG("CBufferFileReader::ReadFromBufferL() - Finished skipping");
+					Reset();
+					} // if
+				else
+					{
+                    __LOG1("CBufferFileReader::ReadFromBufferL() - Still more data to skip...: %d bytes", iLeftToSkip);
+					iLeftToSkip = iLeftToSkip - (end - current);
+					break;
+					} // else
+				} // else
+			} // while
+			
+            __LOG3("CBufferFileReader::ReadFromBufferL() - aLastSection: %d, iFileOpen: %d, iLeftToSkip: %d", aLastSection, iFileOpen, iLeftToSkip);
+
+			if ((aLastSection && iFileOpen) ||
+			    (aLastSection && (iLeftToSkip > 0)))
+				{
+                __LOG("CBufferFileReader::ReadFromBufferL() - Leaving with KErrUnderflow because not all skipped data was consumed!");
+				User::Leave(KErrUnderflow);
+			} // if
+
+        __LOG("CBufferFileReader::ReadFromBufferL() - END");
+		} // ReadFromBufferL
+		
+	void CBufferFileReader::RedirectMIDletRestorePathL(const TDesC& aOriginal, CDesCArray& aRedirected)
+	/** Redirects the midlet restore path
+	
+	@param aOriginal the original path
+	@param aRedirected the redirected path
+	*/
+		{
+		TFileName redirectedFilename(KMIDletTempRestorePath);
+		// Backslash used to isolate the filename from aOriginal's absolute path
+		const TChar KTCharBackslash('\\');
+		
+		// Isolate the filename from aOriginal and Append it to our temp path
+		redirectedFilename.Append(aOriginal.Mid(aOriginal.LocateReverseF(KTCharBackslash) + 1));
+		aRedirected.AppendL(redirectedFilename);
+		}
+
+	void CBufferFileReader::ReadMIDletsFromBufferL(const TDesC8& aBuffer, TBool aLastSection, 
+		CDesCArray& aUnpackedFileNames)
+	/** Reads from the buffer and writes files to disk.
+	
+	@param aBuffer The buffer to read from.
+	@param aLastSection Is this the last section?
+	@leave KErrUnderflow More data is needed.
+	*/	
+		{
+		TUint8* current = const_cast<TUint8*>(aBuffer.Ptr());
+		const TUint8* end = current + aBuffer.Size();
+		TInt fileIndex = 0;
+		while (current < end)
+			{
+			// Do we have the fixed header?
+			if (!iFixedHeaderRead)
+				{
+				if (ReadFromBufferF(iFixedHeader, current, end) == EFalse)
+					{
+					__LOG("CBufferFileReader::ReadMIDletsFromBufferL() - ReadFromBufferF() returned False so breaking!");
+					break;
+					} // if
+				__LOG1("CBufferFileReader::ReadMIDletsFromBufferL() - fixed header - iFileNameLength:  %d", iFixedHeader.iFileNameLength);
+                __LOG1("CBufferFileReader::ReadMIDletsFromBufferL() - fixed header - iFileSize:        %d", iFixedHeader.iFileSize);
+                __LOG1("CBufferFileReader::ReadMIDletsFromBufferL() - fixed header - iAttributes:      %d", iFixedHeader.iAttributes);	
+					
+				if ((iFixedHeader.iFileNameLength > KMaxFileName) || (!iFixedHeader.iAttributes) || (!iFixedHeader.iFileNameLength))
+					{
+					__LOG1("CBufferFileReader::ReadMIDletsFromBufferL() - Leaving - iFileNameLength: %d more then MaxLength", iFixedHeader.iFileNameLength);
+					User::Leave(KErrOverflow);
+					}
+				
+				iFixedHeaderRead = ETrue;
+				} // if
+				
+			if (!iFileNameRead)
+				{
+				TPtr8 ptr(reinterpret_cast<TUint8*>(const_cast<TUint16*>(iFileName.Ptr())), iBytesRead, iFixedHeader.iFileNameLength * KCharWidthInBytes);
+				
+				if (ReadFromBufferV(ptr, iFixedHeader.iFileNameLength * KCharWidthInBytes, current, end) == EFalse)
+					{
+					iBytesRead = ptr.Size();
+					__LOG1("CBufferFileReader::ReadMIDletsFromBufferL() - ReadFromBufferV() returned False - Filename bytes read: %d", iBytesRead);
+					break;
+					} // if
+				
+					
+				iFileName.SetLength(iFixedHeader.iFileNameLength);
+				
+				// Throw away the unpacked filename, as we're now
+				RedirectMIDletRestorePathL(iFileName, aUnpackedFileNames);
+				
+				// We don't need the original filename any more, we're using the one returne by Redirect...
+				iFileName = aUnpackedFileNames[fileIndex];
+				
+				iFileNameRead = ETrue;
+				
+				// set the index to the next file in the list
+				fileIndex++;
+				}
+				
+			// Is the file in the snapshot, if not it was deleted in an increment and does not need restoring
+			if (!iSnapshotChecked)
+				{
+				CheckFileInSnapshotL();
+				} // if
+			
+			if (!iRestore && !iLeftToSkip)
+				{
+                __LOG1("CBufferFileReader::ReadMIDletsFromBufferL() - restore not permitted, skipping file data (%d bytes)", iFixedHeader.iFileSize);
+				iLeftToSkip = iFixedHeader.iFileSize; // So we can skip the bytes
+				}
+
+			if (iRestore)
+				{
+				// Have we opened the file?
+				if (!iFileOpen)
+					{
+					RecreateFileL();
+					}
+					
+				// Write to the file
+				if (!WriteToFileL(current, end))
+					{
+					__LOG("CBufferFileReader::ReadMIDletsFromBufferL() - WriteToFileL() returned False so breaking!");
+					break;
+					}
+				} // if
+			else
+				{
+				// We need to skip the bytes in the data
+				if ((end - current) >= iLeftToSkip)
+					{
+					current += iLeftToSkip;
+
+					// Finished reset state
+					Reset();
+					} // if
+				else
+					{
+					__LOG1("CBufferFileReader::ReadMIDletsFromBufferL() - Still more data to skip...: %d bytes", iLeftToSkip);
+					iLeftToSkip = iLeftToSkip - (end - current);
+					break;
+					} // else
+				} // else
+			} // while
+			
+			if ((aLastSection && iFileOpen) ||
+			    (aLastSection && (iLeftToSkip > 0)))
+				{
+				User::Leave(KErrUnderflow);
+				} // if
+		} // ReadMIDletsFromBufferL
+		
+	void CBufferFileReader::Reset()
+	/** Resets the state of the object.
+	*/
+		{
+		iFileHandle.Close();
+		iFileOpen = EFalse;
+		iFileNameRead = EFalse;
+		iLeftToSkip = 0;
+		iSnapshotChecked = EFalse;
+		iFileName.SetLength(0);
+		iFixedHeaderRead = EFalse;
+		iBytesRead = 0;
+		}
+		
+	CBufferFileReader::~CBufferFileReader()
+	/** destructor
+	*/
+		{
+		iFileHandle.Close();
+		}
+		
+	
+	
+	CBufferSnapshotWriter* CBufferSnapshotWriter::NewL(RSnapshots* aSnapshots)
+	/** Symbian OS constructor
+	
+	@param aFiles File information to write to the buffer.ownernship transfer
+	*/
+		{
+		CBufferSnapshotWriter* self = new(ELeave) CBufferSnapshotWriter(aSnapshots);
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		CleanupStack::Pop(self);
+		
+		return self;
+		} // NewL
+		
+	CBufferSnapshotWriter::CBufferSnapshotWriter(RSnapshots* aSnapshots) : iSnapshots(aSnapshots)
+	/** Standard C++ constructor
+	*/
+		{
+		}
+		
+	void CBufferSnapshotWriter::ConstructL()
+	/** Symbian second phase constructor
+
+	@param aFiles File information to write to the buffer.
+	*/
+		{
+		__ASSERT_DEBUG(iSnapshots, Panic(KErrArgument));
+		#ifdef SBE_LOGGING_ENABLED
+        const TInt count = iSnapshots->Count();
+        __LOG1("CBufferFileReader::NewL() - Got %d snapshots to compare against during restore...", count);
+
+	    for(TInt x = 0; x < count; ++x)
+		    {
+            const TDesC& snapshot = (*iSnapshots)[x]->FileName();
+            __LOG3("CBufferFileReader::NewL() -    snapshot[%4d/%4d] is: %S", x+1, count, &snapshot);
+		    } // for x
+
+		#endif
+		} // ConstructL
+		
+	CBufferSnapshotWriter::~CBufferSnapshotWriter()
+	/** Standard C++ destructor
+	*/
+		{
+		if(iSnapshots)
+			{
+			iSnapshots->ResetAndDestroy();
+			delete iSnapshots;
+			}
+		} // ~CBufferSnapshotWriter
+		
+	void CBufferSnapshotWriter::StartL(TPtr8& aBuffer, TBool& aCompleted)
+	/** Starts writing to the buffer 
+	
+	@param aBuffer The buffer.
+	@param aCompleted On return if we have finished writing data.
+	*/
+		{
+        __LOG("CBufferSnapshotWriter::StartL() - START");
+		WriteToBufferL(aBuffer, aCompleted);
+        __LOG("CBufferSnapshotWriter::StartL() - END");
+		} // WriteToBufferL
+
+	void CBufferSnapshotWriter::ContinueL(TPtr8& aBuffer, TBool& aCompleted)
+	/** Continues writing to the buffer 
+	
+	@param aBuffer The buffer.
+	@param aCompleted On return if we have finished writing data.
+	*/
+		{
+        __LOG("CBufferSnapshotWriter::ContinueL() - START");
+		WriteToBufferL(aBuffer, aCompleted);
+        __LOG("CBufferSnapshotWriter::ContinueL() - END");
+		} // WriteToBufferL
+		
+	void CBufferSnapshotWriter::WriteToBufferL(TPtr8& aBuffer, TBool& aCompleted)
+	/** Writes to the buffer 
+
+	@param aBuffer The buffer.
+	@param aCompleted On return if we have finished writing data.
+	*/
+		{
+        __LOG1("CBufferSnapshotWriter::WriteToBufferL() - START - aBuffer length: %d", aBuffer.Length());
+		aCompleted = EFalse;
+		
+		const TUint count = iSnapshots->Count();
+		while (iCurrentSnapshot < count)
+			{
+            __LOG1("CBufferSnapshotWriter::WriteToBufferL() - iCurrentSnapshot: %d", iCurrentSnapshot);
+
+			// Check there is enough room
+			if (sizeof(TSnapshot) > static_cast<TUint>(aBuffer.MaxSize() - aBuffer.Size()))
+				{
+				__LOG("CBufferSnapshotWriter::WriteToBufferL() - Snapshot size is more than buffer available - break");
+				break;
+				} // if
+				
+			// Write modified
+			TSnapshot snapshot;
+			(*iSnapshots)[iCurrentSnapshot]->Snapshot(snapshot);
+            __LOG1("CBufferSnapshotWriter::WriteToBufferL() - writing snapshot for file: %S", &snapshot.iFileName);
+
+			WriteToBufferF(snapshot, aBuffer);
+			
+			++iCurrentSnapshot;			
+			} // while
+
+		if (iCurrentSnapshot >= count)
+			{
+			aCompleted = ETrue;
+			} // if
+
+        __LOG1("CBufferSnapshotWriter::WriteToBufferL() - END - aCompleted: %d", aCompleted);
+		} // WriteToBufferL
+	
+	CBufferSnapshotReader* CBufferSnapshotReader::NewL(RSnapshots& aSnapshots)
+	/** Symbian constructor
+	
+	@param aFiles Locaton to store files read from buffer.
+	*/
+		{
+		return new (ELeave) CBufferSnapshotReader(aSnapshots);
+		}
+		
+	CBufferSnapshotReader::CBufferSnapshotReader(RSnapshots& aSnapshots) :
+		iSnapshots(aSnapshots)
+	/** C++ constructor
+	
+	@param aSnapshots snapshots of files.
+	*/
+		{
+		}
+		
+	CBufferSnapshotReader::~CBufferSnapshotReader()
+	/**
+	C++ destructor
+	*/
+		{
+		}
+		
+	void CBufferSnapshotReader::StartL(const TDesC8& aBuffer, TBool aLastSection)
+	/** Starts reading data from the buffer
+	
+	@param aBuffer buffer to read from.
+	@param aLastSection is this the last section.
+	*/
+		{
+        __LOG2("CBufferSnapshotReader::StartL() - START - buffer len: %d, aLastSection: %d", aBuffer.Length(), aLastSection);
+
+		ReadFromBufferL(aBuffer, aLastSection);
+
+        __LOG("CBufferSnapshotReader::StartL() - END");
+		}
+		
+	void CBufferSnapshotReader::ContinueL(const TDesC8& aBuffer, TBool aLastSection)
+	/** Continues reading data from the buffer
+	
+	@param aBuffer buffer to read from.
+	@param aLastSection is this the last section.
+	*/
+		{
+        __LOG2("CBufferSnapshotReader::ContinueL() - START - buffer len: %d, aLastSection: %d", aBuffer.Length(), aLastSection);
+
+		ReadFromBufferL(aBuffer, aLastSection);
+
+        __LOG("CBufferSnapshotReader::ContinueL() - END");
+		}
+		
+	void CBufferSnapshotReader::ReadFromBufferL(const TDesC8& aBuffer, TBool /*aLastSection*/)
+	/** Reads data from the buffer
+	
+	@param aBuffer buffer to read from.
+	@param aLastSection is this the last section.
+	*/
+		{
+        __LOG("CBufferSnapshotReader::ReadFromBufferL() - START");
+
+		TUint8* current = const_cast<TUint8*>(aBuffer.Ptr());
+		const TUint8* end = current + aBuffer.Size();
+		while (current < end)
+			{
+			if (ReadFromBufferF(iSnapshot, current, end) == EFalse)
+				{
+				__LOG("CBufferSnapshotReader::ReadFromBufferL() - returned EFalse breaking!");
+				break;
+				}
+			
+            __LOG1("CBufferSnapshotReader::ReadFromBufferL() - read snapshot info for file: %S", &iSnapshot.iFileName);
+            CSnapshot* snapshot = CSnapshot::NewLC(iSnapshot);
+			iSnapshots.AppendL(snapshot);
+			CleanupStack::Pop(snapshot);
+			} // while
+
+        __LOG("CBufferSnapshotReader::ReadFromBufferL() - END");
+		} // ReadFromBufferL
+		
+	
+	// CSnapshot //
+	
+	/**
+	
+	Symbian 2nd phase construction creates a CSelection
+	
+	@param aType - Selection Type
+	@param aSelection - Selection Nmae
+	@return CSelection a pointer to a new object 
+	*/
+	CSnapshot* CSnapshot::NewLC(const TInt64& aModified, const TDesC& aFileName)
+		{
+		CSnapshot* self = new (ELeave) CSnapshot(aModified);
+		CleanupStack::PushL(self);
+		self->ConstructL(aFileName);
+		return self;
+		}
+	
+	/**
+	
+	Symbian 2nd phase construction creates a Selection
+	
+	@param aSnapshot - TSnapshot snapshot
+	@return CSelection a pointer to a new object 
+	*/
+	CSnapshot* CSnapshot::NewLC(const TSnapshot& aSnapshot)
+		{
+		return CSnapshot::NewLC(aSnapshot.iModified, aSnapshot.iFileName);
+		}
+	
+	/**
+	Standard C++ destructor
+	*/
+	CSnapshot::~CSnapshot()
+		{
+		delete iFileName;
+		}
+	
+	/**
+	Standard C++ constructor
+	*/
+	CSnapshot::CSnapshot(const TInt64& aModified) : iModified(aModified)
+		{
+		}
+		
+	/**
+	Symbian 2nd phase constructor
+	*/
+	void CSnapshot::ConstructL(const TDesC& aFileName)
+		{
+		iFileName = aFileName.AllocL();
+		}
+	
+	/**
+	Selection Type
+	
+	@return TSelectionType Type
+	*/
+	const TInt64& CSnapshot::Modified() const
+		{
+		return iModified;
+		}
+	
+	/**
+	Selection Name
+	
+	@return const TDesC& Name
+	*/
+	const TDesC& CSnapshot::FileName() const
+		{
+		return *iFileName;
+		}
+		
+	/**
+	Create snapshot of type TSnapshot
+	
+	@return TSnapshot snapshot
+	
+	*/
+	void CSnapshot::Snapshot(TSnapshot& aSnapshot)
+		{
+		aSnapshot.iFileName = *iFileName;
+		aSnapshot.iModified = iModified;
+		}
+		
+	/**
+	Method will be used for Sort on RPointerArray
+	
+	@param aFirst CSnapshot& snapshot to compare
+	@param aSecond CSnapshot& snapshot to compare
+	
+	@see RArray::Sort()
+	*/
+	TInt CSnapshot::Compare(const CSnapshot& aFirst, const CSnapshot& aSecond)
+		{
+		return aFirst.FileName().CompareF(aSecond.FileName());
+		}
+		
+	/**
+	Method will be used for Find on RPointerArray
+	
+	@param aFirst CSnapshot& snapshot to match
+	@param aSecond CSnapshot& snapshot to match
+	
+	@see RArray::Find()
+	*/
+	TBool CSnapshot::Match(const CSnapshot& aFirst, const CSnapshot& aSecond)
+		{
+		return (aFirst.FileName() == aSecond.FileName());
+		}
+
+
+	} // namespace conn
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sbeclient.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,469 @@
+// 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:
+// Implementation of CSBEClient class.
+// 
+//
+
+/**
+ @file
+ @released
+*/
+
+#include "sbeclient.h"
+#include "sbeclientsession.h"
+#include <connect/panic.h>
+
+namespace conn
+	{
+
+	CSBEClient::CSBEClient()
+	/** Class constructor. */
+		{
+		}
+
+
+	EXPORT_C CSBEClient* CSBEClient::NewL()
+	/**
+	Standard creation method.
+
+	@return a new CSBEClient.
+	*/
+		{
+		CSBEClient* self = new (ELeave) CSBEClient();
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		CleanupStack::Pop(self);
+		return self;
+		}
+
+	void CSBEClient::ConstructL()
+	/**
+	Construct this instance of CSBEClient
+	*/
+		{
+		iClientSession = RSBEClientSession::NewL();
+		
+		User::LeaveIfError(iClientSession->Connect());
+		}
+
+
+	EXPORT_C CSBEClient::~CSBEClient()
+	/**
+	Standard destructor
+	*/
+		{
+		if (iClientSession)
+			{
+			iClientSession->Close();
+			}
+		
+		delete iClientSession;
+		iClientSession = NULL;
+		}
+
+
+	EXPORT_C void CSBEClient::ListOfDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners)
+	/**
+	Gets a list of all registered data owners.
+	This method can be called regardless of backup or restore mode.
+	N.B. If it is called before a restore the set may not include all data owners that 
+	are to be restored.
+
+	If the Secure Backup Engine has not parsed backup registration files then this call
+	will trigger scanning and parsing.
+
+	@param aDataOwners on return an array of information about backup data owners.
+	*/
+		{
+		iClientSession->ListOfDataOwnersL(aDataOwners);
+		}
+
+	EXPORT_C void CSBEClient::PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, RFileArray& aFiles)
+	/**
+	Gets a list of actual public files associated with an SID for partial backup. This allows
+	a client to backup only the public files associated with an SID.
+	This method must only be called when the device is in backup mode as the set of files may
+	not be final until then.  This method takes no account of any snapshots - the full list
+	of candidate public files is returned and it is up to the Secure Backup Server to check
+	file attributes if an incremental backup is required.
+
+	If the Secure Backup Engine has not parsed backup registration files then this call
+	will trigger scanning and parsing.
+
+	@param aDrive the drive concerned.
+	@param aGenericDataType reference to the data type.
+	@param aFiles on return an array of information about files.
+	*/
+		{
+		iClientSession->PublicFileListL(aDrive, aGenericDataType, aFiles);
+		}
+
+	EXPORT_C void CSBEClient::RawPublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType,
+									RRestoreFileFilterArray& aFileFilter)
+	/**
+	Gets a list of public files and directories associated with an SID for partial restore.
+	This method must only be called when the device is in restore mode.
+	This method must only be called after a registration file has been supplied and parsed.
+	Directories can be distinguished from files by a terminating slash.
+
+	During a restore operation, the client will have the archive or public files available but the
+	Secure Backup Engine does not.  Therefore, the engine cannot list the exact files.  This method
+	returns the list of files or directories that were specified in the backup registration file without
+	further analysis and the client can use this information to filter public files for restore.
+
+	This allows a client that has taken a full backup to be selective about restore .
+
+	If the Secure Backup Engine has not parsed backup registration files then this call
+	will trigger scanning and parsing.
+
+	@param aDrive the drive concerned.
+	@param aGenericDataType reference to the data type.
+	@param aFileFilter on return an array of names of files or directories for restore.
+	*/
+		{
+		iClientSession->RawPublicFileListL(aDrive, aGenericDataType, aFileFilter);
+		}
+
+	EXPORT_C void CSBEClient::PublicFileListXMLL(TDriveNumber aDrive, TSecureId aSID, HBufC*& aFileList)
+	/**
+	Gets a list of public files and directories associated with an SID for partial backup or restore.
+	This method returns the data in the form of an XML description for compatibility with older
+	devices.
+
+	This method can be called regardless of the backup or restore mode as it does not rely on the
+	set of public files being final.
+
+	If the Secure Backup Engine has not parsed backup registration files then this call
+	will trigger scanning and parsing.
+
+	@param aDrive the drive concerned.
+	@param aSID the data owner.
+	@param aFileList on return a description of the list of files and directories. Must be NULL
+	*/
+		{
+		__ASSERT_DEBUG(aFileList == NULL, Panic(KErrArgument));
+		iClientSession->PublicFileListXMLL(aDrive, aSID, aFileList);
+		}
+
+	EXPORT_C void CSBEClient::SetBURModeL(const TDriveList& aDriveList, TBURPartType aBURType, 
+						  TBackupIncType aBackupIncType)
+	/**
+	Sets B&R on or off and sets the base / increment and full / partial mode and the affected drives
+
+	@param aDriveList the drives affected.
+	@param aBURType is a full or partial backup or restore desired or normal operation.
+	@param aBackupIncType is a backup base or incremental (ignored for restore operations).
+	*/
+		{
+		iClientSession->SetBURModeL(aDriveList, aBURType, aBackupIncType);
+		}
+
+	EXPORT_C void CSBEClient::SetSIDListForPartialBURL(RSIDArray& aSIDs)
+	/**
+	If a partial backup is required then this sets the list of data owners.
+	This method must only be called when the device has just been put into backup or restore mode.
+	It must only be called once for a backup or restore operation.
+
+	@param aSIDs array of affected data owners.
+	*/
+		{
+		iClientSession->SetSIDListForPartialBURL(aSIDs);
+		}
+
+
+	EXPORT_C void CSBEClient::SIDStatusL(RSIDStatusArray& aSIDStatus)
+	/**
+	Gets the status of a set of data owners.
+	This method must only be called in backup or restore mode.
+	
+	You must populate the array with the TDataOwnerAndStatus's for each secure id the client 
+	is interested in.
+	
+	@param aSIDStatus an array of structures for information about data owners. On return
+	the status information is filled in.
+	*/
+		{
+		iClientSession->SIDStatusL(aSIDStatus);
+		}
+
+
+	// Data Access Methods //
+
+	EXPORT_C TPtr8& CSBEClient::TransferDataAddressL()
+	/**
+	Provides access to the base of the global chunk used to transfer data between
+	the Secure Backup Engine and a Secure Backup Server.  This method should be used
+	when the Secure Backup Server is providing data to the Secure Backup Engine (either as part 
+	of a restore operation or when supplying snapshots during a backup operation.
+
+	The Secure Backup Engine only uses one global chunk at a time. It is not permissible to
+	try to carry out multiple backup or restore operations in parallel.  Normally a chunk
+	of global heap would be protected by a mutex.  In this case, all the methods of the 
+	Secure Backup Engine must be regarded as synchronous and mutually exclusive - it is not
+	permissible to make parallel calls.
+
+	The global chunk used during a backup or restore operation may change and so the address must
+	be requested whenever required rather than being cached.
+
+	@return Pointer to the start of the buffer for writing
+	*/
+		{
+		return iClientSession->TransferDataAddressL();
+		}
+		
+	EXPORT_C TPtrC8& CSBEClient::TransferDataInfoL(CSBGenericTransferType*& aGenericTransferType,
+												   TBool& aFinished)
+	/**
+	Provides access to the data received from the Secure Backup Engine during a backup operation.
+
+	This method should be called after a synchronous or asynchronous request for data has
+	completed.
+
+	@param aGenericTransferType  Reference to a CSBGenericTransferType pointer. Must be NULL
+	@param aFinished ETrue if the data is the last chunk, EFalse if there is more to request.
+	@return read only pointer to the global heap.
+	*/
+		{
+		__ASSERT_DEBUG(aGenericTransferType == NULL, Panic(KErrArgument));
+		return iClientSession->TransferDataInfoL(aGenericTransferType, aFinished);
+		}
+
+	EXPORT_C void CSBEClient::RequestDataL(CSBGenericTransferType& aGenericTransferType,
+										   TRequestStatus& aStatus)
+	/**
+	This method requests package data from the Secure Backup Engine  asynchronously.
+	When the relevant AO completes the returned data (and information about it) can be accessed
+	by calling TransferDataInfoL().
+
+	Some forms of backup data may be larger than can be handled in one transfer, in which case this
+	method should be called again with the same arguments until all data is signalled as supplied.
+
+	@param aGenericTransferType  Reference to a CSBGenericTransferType object
+	@param aStatus the request status of an Active Object to be completed when the data has been received
+	*/
+		{
+		iClientSession->RequestDataL(aGenericTransferType, aStatus);
+		}
+		
+	EXPORT_C void CSBEClient::RequestDataL(CSBGenericTransferType& aGenericTransferType)
+	/**
+	This synchronous method requests backup data from the Secure Backup Engine.
+	When the method returns the returned data (and information about it) can be accessed
+	by calling TransferDataInfoL().
+
+	Some forms of backup data may be larger than can be handled in one transfer, in which case this
+	method should be called again with the same arguments until all data is signalled as supplied.
+
+	@param aGenericTransferType  Reference to a CSBGenericTransferType object
+	*/
+		{
+		iClientSession->RequestDataL(aGenericTransferType);
+		}
+	
+	EXPORT_C void CSBEClient::SupplyDataL(CSBGenericTransferType& aGenericTransferType,
+									 	  TBool aFinished, TRequestStatus& aStatus)
+	/**
+	This method supplies some form of package data during a backup or restore
+	operation  asynchronously.
+
+	When the relevant Active Object is completed the Secure Backup Engine has absorbed the
+	supplied data.
+
+	Some forms of data may be larger than can be handled in one transfer, in which case this
+	method should be called again with the same arguments until all data has been supplied.
+
+	@param aGenericTransferType  Reference to a CSBGenericTransferType object
+	@param aFinished ETrue if this buffer is the last one for this package uid, drive and data type
+	@param aStatus the request status of an Active Object to be completed when the data has been transferred
+	*/
+		{
+		iClientSession->SupplyDataL(aGenericTransferType, aFinished, aStatus);
+		}
+		
+	EXPORT_C void CSBEClient::SupplyDataL(CSBGenericTransferType& aGenericTransferType,
+									 	  TBool aFinished)
+	/**
+	This synchronous method supplies some form of package data during a backup or
+	restore operation.
+
+	When the method returns the Secure Backup Engine has absorbed the supplied data.
+
+	Some forms of data may be larger than can be handled in one transfer, in which case this
+	method should be called again with the same arguments until all data has been supplied.
+
+	@param aGenericTransferType  Reference to a CSBGenericTransferType object
+	@param aFinished ETrue if this buffer is the last one for this package uid, drive and data type
+	*/
+		{
+		iClientSession->SupplyDataL(aGenericTransferType, aFinished);
+		}
+
+	EXPORT_C void CSBEClient::AllSnapshotsSuppliedL()								  
+	/**
+	This method sets the type of backup to base for this particular data owner.
+	The whole device may be subject to an incremental backup but a particular
+	data owner may be subject to a base backup (if they have not been backed
+	up previously). The reverse is not true.
+
+	This method must only be called when the device has just been put into backup mode.
+	It must only be called once for a SID for a backup operation.
+	*/
+		{
+		iClientSession->AllSnapshotsSuppliedL();
+		}
+		
+	EXPORT_C TUint CSBEClient::ExpectedDataSizeL(CSBGenericTransferType& aGenericTransferType)
+	/**
+	This method returns the expected size of package data that will be supplied.  The size
+	data will be used for the purpose of tracking progess during a backup.  If it is
+	inaccurate then the user may see irregular progress but the actual backup data will
+	not be affected so it is acceptable to return an estimated value.
+
+	This method must only be called during a backup operation.  If it is called when the 
+	data owner is not ready for backup then the call will fail.
+
+	@param aGenericTransferType  Reference to a CSBGenericTransferType object
+	@return KErrNone if successful.
+	*/
+		{
+		return (iClientSession->ExpectedDataSizeL(aGenericTransferType));
+		}
+										 
+	EXPORT_C void CSBEClient::AllSystemFilesRestored()
+	/**
+	This method is called when all system files have been provided to allow the Secure
+	Backup Engine to start active data owners.
+	*/
+		{
+		iClientSession->AllSystemFilesRestored();
+		}
+	
+	/**
+	Gets a list of all registered data owners asynchronously.
+	This method can be called regardless of backup or restore mode.
+	N.B. If it is called before a restore the set may not include all data owners that 
+	are to be restored.
+
+	If the Secure Backup Engine has not parsed backup registration files then this call
+	will trigger scanning and parsing.
+
+	@param aDataOwners on return an array of information about backup data owners.
+	@param aStatus is TRequestStatus&
+	*/	
+	EXPORT_C void CSBEClient::ListOfDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners, TRequestStatus& aStatus)
+		{
+		iClientSession->ListOfDataOwnersL(aDataOwners, aStatus);
+		}
+	
+	/**
+	Gets a list of actual public files associated with an SID for partial backup asynchronously.
+	This allows	a client to backup only the public files associated with an SID.
+	This method must only be called when the device is in backup mode as the set of files may
+	not be final until then.  This method takes no account of any snapshots - the full list
+	of candidate public files is returned and it is up to the Secure Backup Server to check
+	file attributes if an incremental backup is required.
+
+	If the Secure Backup Engine has not parsed backup registration files then this call
+	will trigger scanning and parsing.
+
+	@param aDrive the drive concerned.
+	@param aGenericDataType reference to the data type.
+	@param aFiles on return an array of information about files.
+	@param aStatus is TRequestStatus&
+	*/	
+	EXPORT_C void CSBEClient::PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, RFileArray& aFiles, TRequestStatus& aStatus)
+		{
+		iClientSession->PublicFileListL(aDrive, aGenericDataType, aFiles, aStatus);
+		}
+	
+	/**
+	Sets B&R on or off and sets the base / increment and full / partial mode and the affected drives asynchronously.
+
+	@param aDriveList the drives affected.
+	@param aBURType is a full or partial backup or restore desired or normal operation.
+	@param aBackupIncType is a backup base or incremental (ignored for restore operations).
+	@param aStatus is TRequestStatus&
+	*/	
+	EXPORT_C void CSBEClient::SetBURModeL(const TDriveList& aDriveList, TBURPartType aBURType, 
+								  TBackupIncType aBackupIncType, TRequestStatus& aStatus)
+		{
+		iClientSession->SetBURModeL(aDriveList, aBURType, aBackupIncType, aStatus);
+		}
+	
+	/**
+	This method which sets the type of backup to base for this particular data owner asynchronously.
+	The whole device may be subject to an incremental backup but a particular
+	data owner may be subject to a base backup (if they have not been backed
+	up previously). The reverse is not true.
+
+	This method must only be called when the device has just been put into backup mode.
+	It must only be called once for a SID for a backup operation.
+	
+	@param aStatus is TRequestStatus&
+	*/
+	EXPORT_C void CSBEClient::AllSnapshotsSuppliedL(TRequestStatus& aStatus)
+		{
+		iClientSession->AllSnapshotsSuppliedL(aStatus);
+		}
+		
+	/**
+	This method is called asynchronously when all system files have been provided to allow the Secure
+	Backup Engine to start active data owners.
+	
+	@param aStatus is TRequestStatus&
+	*/
+	EXPORT_C void CSBEClient::AllSystemFilesRestoredL(TRequestStatus& aStatus)
+		{
+		iClientSession->AllSystemFilesRestoredL(aStatus);
+		}
+
+	// Test Methods //
+
+	EXPORT_C TUint CSBEClient::DataChecksum(TDriveNumber /*aDrive*/, TSecureId /*aSID*/)
+	/**
+	Get a 32-bit checksum for private data.
+	This routine is for test purposes.  It must be implemented but an invariant checksum 
+	value can be provided.  Some tests may cause checksum values to be compared.
+
+	@param aDrive the drive containing data being checksummed
+	@param aSID the data owner.
+	@return the 32-bit checksum
+	*/
+		{
+		return 0;
+		}
+		
+	EXPORT_C void CSBEClient::PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, 
+								RPointerArray<CSBEFileEntry>& aFileList, TBool& aFinished,
+								TInt aTotalListCursor, TInt aMaxResponseSize, TRequestStatus& aStatus)
+	/** This asynchronous method is used to retrieve the list of public files for the specified data owner
+	on the specified drive. Upon completion of aStatus, the caller should check aFileList 
+	@param aDrive The drive that contains the public files being retrieved
+	@param aGenericDataType The identifier for the data owner that owns the public files
+	@param aFileList Upon completion of aStatus, this array will contain the list of public files returned
+	@param aFinished Upon completion of aStatus, this flag will be set to indicate that there are more 
+						file entries available for this data owner and another call to this method should be made
+	@param aTotalListCursor Specifies the index into the complete list of public files for this data owner to start 
+						the next chunk of file entries from. The number of entries returned by a call to this
+						method can be determined by querying the count of aFileList
+	@param aMaxResponseSize The maximum total size in bytes of externalised CSBEFileEntry objects that will be returned
+	@param aStatus The TRequestStatus that will be completed once the engine has fully processed this request
+	*/
+		{
+		iClientSession->PublicFileListL(aDrive, aGenericDataType, aFileList, aFinished, aTotalListCursor, aMaxResponseSize, aStatus);
+		}
+
+	} // end of conn namespace
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sbeclientsession.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,879 @@
+// 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:
+// Implementation of RSBEClientSession class.
+// 
+//
+
+/**
+ @file
+*/
+
+#include "sbeclientsession.h"
+#include "sbeclientserver.h"
+#include <connect/sbtypes.h>
+#include <connect/panic.h>
+
+namespace conn
+	{
+
+	RSBEClientSession* RSBEClientSession::NewL()
+	/** Symbian OS constructor 
+	@return pointer to an instantiated RSBEClientSession object */
+		{
+		RSBEClientSession* self = new (ELeave) RSBEClientSession();
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		CleanupStack::Pop(self);
+		return self;
+		}
+
+	void RSBEClientSession::ConstructL()
+	/** Symbian second phase constructor */
+		{
+        iGSHInterface = CHeapWrapper::NewL();
+		}
+		
+	RSBEClientSession::RSBEClientSession() : iCallbackHandler(NULL)
+	/** Class constructor. */
+		{
+		}
+
+	RSBEClientSession::~RSBEClientSession()
+	/** Class destructor. */
+		{
+		delete iGSHInterface;
+		delete iCallbackHandler;
+		}
+
+	void RSBEClientSession::Close()
+	/** Closes the Secure Backup Engine handle. */
+		{
+		iGlobalSharedHeap.Close();
+		RSessionBase::Close();
+		}
+
+	TInt RSBEClientSession::Connect()
+	/** Connects the handle to the Secure Backup Engine.
+
+	@return KErrNone if successful, KErrCouldNotConnect otherwise
+	*/
+		{
+        TInt nRetry = KSBERetryCount;
+		TInt nRet = KErrNotFound;
+
+		while(nRetry > 0 && nRet != KErrNone)
+			{
+		    const TSecurityPolicy policy(static_cast<TSecureId>(KSBServerUID3));
+			nRet = CreateSession(KSBEServerName, Version(), KSBEASyncMessageSlots, EIpcSession_Unsharable,&policy);
+			if(nRet == KErrNotFound || nRet == KErrServerTerminated)
+				{
+				StartServer();
+				}
+			nRetry--;
+			}
+			
+		// If we were succesful, then get a handle to the server created and owned GSH
+		if (nRet == KErrNone)
+			{
+			nRet = GetGlobalSharedHeapHandle();
+			}
+
+		return nRet;
+		}
+
+	TVersion RSBEClientSession::Version() const
+	/** Returns the version of this API
+
+	@return The version of this API
+	*/
+		{
+	    return TVersion (KSBEMajorVersionNumber,
+							KSBEMinorVersionNumber,
+							KSBEBuildVersionNumber);
+	  	}
+
+	//
+	// Server startup code
+	TInt RSBEClientSession::StartServer()
+	/** Start the server as a thread on WINS or a process on ARM.
+	
+	Called by Connect when the kernel is unable to create a session
+	with the SBE server (as its not running).
+
+	@return Standard Symbian OS code from RProcess/RThread create.
+	*/
+		{
+        //
+		// Servers UID
+		const TUidType serverUid(KNullUid, KNullUid, KSBServerUID3);
+		
+	
+		RProcess server;
+    	TInt nRet=server.Create(KSBImageName,KNullDesC,serverUid);
+    	if (nRet != KErrNone)
+    	    {
+    		return nRet;
+    		}
+    		
+    	TRequestStatus stat;
+    	server.Rendezvous(stat);
+    	if (stat != KRequestPending)
+    		{
+    		server.Kill(0);
+    		}
+    	else
+    		{
+    		server.Resume();
+    		}
+    	User::WaitForRequest(stat);
+    	return (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
+		
+		}
+
+
+	void RSBEClientSession::ListOfDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners)
+	/**
+	Return the list of private data owners on the device that have backup registration files.
+	If a leave does occur, then aDataOwners
+	
+	@param aDataOwners Pointer array holding the list of Data owners requiring backup functionality.
+			Any items present in this array will be lost
+	*/
+		{
+		// Get the server to construct the flattened array and return the size of it		
+		TInt result = SendReceive(ESBEMsgPrepDataOwnerInfo);
+		
+		User::LeaveIfError(result);
+		
+		iDataOwnersArray = &aDataOwners;
+		
+		PopulateListOfDataOwnersL(result);
+		}
+		
+	void RSBEClientSession::PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, 
+												RFileArray& aFiles)
+	/**
+	Get the list of public files to backup for a particular Data Owner on a particular drive
+	
+	@param aDrive The drive that the public files exist on
+	@param aGenericDataType Reference to the generic data type that is being passed to the SBEngine.
+	@param aFiles An empty array of file information that will be filled with details of the public files
+	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
+	*/
+		{
+		// request the public file list
+		TInt result = SendReceive(ESBEMsgPrepPublicFiles, TIpcArgs(aDrive, 
+						&(aGenericDataType.Externalise())));
+		
+		User::LeaveIfError(result);
+
+		iFileArray = &aFiles;
+		
+		PopulatePublicFileListL(result);
+		}
+		
+	void RSBEClientSession::RawPublicFileListL(	TDriveNumber aDrive, 
+												CSBGenericDataType& aGenericDataType, 
+												RRestoreFileFilterArray& aFileFilter)
+	/**
+	Get the list of public files to backup for a particular Data Owner on a particular drive for 
+	a partial restore
+	
+	@param aDrive The drive that the public files exist on
+	@param aGenericDataType Reference to the generic data type that is passed to the SBEngine.
+	@param aFileFilter Empty array that will be filled with the files/directories to be backed up 
+	on return
+	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
+	*/
+		{
+        // ensure that the array is cleared out before populating with externalised data
+		aFileFilter.Reset();
+		
+		TPckgC<TDriveNumber> drive(aDrive);
+
+		// request the public file list
+		TInt result = SendReceive(ESBEMsgPrepPublicFilesRaw, TIpcArgs(&drive, 
+				&(aGenericDataType.Externalise())));
+		
+		User::LeaveIfError(result);
+
+		// Create a descriptor big enough for the array to be externalised into
+		HBufC8* pFileArray = HBufC8::NewL(result);
+		CleanupStack::PushL(pFileArray);
+		
+		TPtr8 fileArray(pFileArray->Des());
+		User::LeaveIfError(SendReceive(ESBEMsgGetPublicFilesRaw, TIpcArgs(&fileArray)));
+		
+		RRestoreFileFilterArray* pFileFilter = RRestoreFileFilterArray::InternaliseL(fileArray);
+		CleanupStack::PushL(pFileFilter);
+		CleanupClosePushL(*pFileFilter);
+		
+		TInt count = pFileFilter->Count();
+		for (TInt x = 0; x < count; x++)
+			{
+				aFileFilter.AppendL((*pFileFilter)[x]);
+			} // for x
+
+		CleanupStack::PopAndDestroy(pFileFilter); // CleanupClosePushL(*pFileFilter)
+		CleanupStack::PopAndDestroy(pFileFilter); // CleanupStack::PushL(pFileFilter)
+		CleanupStack::PopAndDestroy(pFileArray);
+		}
+	
+	void RSBEClientSession::PublicFileListXMLL(TDriveNumber aDrive, TSecureId aSID, HBufC*& aFileList)
+	/**
+	Get the list of public files in XML format
+
+	@param aDrive The drive to get the list for
+	@param aSID The SID of the data owner to get the public files for
+	@param aFileList The descriptor to populate on return should be NULL
+	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
+	*/
+		{
+        TPckgC<TDriveNumber> drive(aDrive);
+		TPckgC<TSecureId> sid(aSID);
+
+		// request the public file list
+		TInt result = SendReceive(ESBEMsgPrepPublicFilesXML, TIpcArgs(&drive, &sid));
+		
+		User::LeaveIfError(result);
+
+		// Create a descriptor big enough for the array to be externalised into
+		aFileList = HBufC::NewL(result);
+	
+		TPtr fileList(aFileList->Des());
+		User::LeaveIfError(SendReceive(ESBEMsgPrepPublicFilesXML, TIpcArgs(&fileList)));
+		}
+	
+	void RSBEClientSession::SetBURModeL(const TDriveList& aDriveList, TBURPartType aBURType, 
+						  TBackupIncType aBackupIncType)
+	/**
+	Set the Backup and Restore mode on/off and configure the BUR options
+	
+	@param aDriveList Array of drives that are to be backed up during the operations
+	@param aBURType Set the device into Full/Partial BUR or normal operation
+	@param aBackupIncType Base/Incremental backup
+	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
+	*/
+		{
+		User::LeaveIfError(SendReceive(ESBEMsgSetBURMode, TIpcArgs(&aDriveList, aBURType, aBackupIncType)));
+		}
+		
+	void RSBEClientSession::SetSIDListForPartialBURL(RSIDArray& aSIDs)
+	/**
+	If a partial backup is required then this sets the list of data owners.
+	This method must only be called when the device has just been put into backup or restore mode.
+	It must only be called once for a backup or restore operation.
+
+	@param aSIDs array of affected data owners.
+	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
+	*/
+		{
+        HBufC8* pFlattenedArray = aSIDs.ExternaliseL();
+		CleanupStack::PushL(pFlattenedArray);
+		
+		TPtrC8 flatArray(pFlattenedArray->Des());
+		
+		User::LeaveIfError(SendReceive(ESBEMsgSetSIDListPartial, TIpcArgs(&flatArray)));
+
+		CleanupStack::PopAndDestroy(pFlattenedArray);
+		}
+		
+	void RSBEClientSession::SIDStatusL(RSIDStatusArray& aSIDStatus)
+	/**
+	Gets the status of a set of data owners.
+	This method must only be called in backup or restore mode.
+
+	@param aSIDStatus an array of structures for information about data owners. On return
+	the status information is filled in.
+	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
+	*/
+		{
+        HBufC8* pExternalisedArray = aSIDStatus.ExternaliseL();
+		CleanupStack::PushL(pExternalisedArray);
+		
+		TPtr8 externArray(pExternalisedArray->Des());
+		User::LeaveIfError(SendReceive(ESBEMsgPrepSIDStatus, TIpcArgs(&externArray)));
+		
+		// Reset the descriptor, ready for getting the returned externalised array
+		externArray.Zero();
+		
+		User::LeaveIfError(SendReceive(ESBEMsgGetSIDStatus, TIpcArgs(&externArray)));
+		RSIDStatusArray* pInternalisedArray = RSIDStatusArray::InternaliseL(externArray);
+
+		CleanupStack::PopAndDestroy(pExternalisedArray); // pExternalisedArray
+		
+		CleanupStack::PushL(pInternalisedArray);
+		CleanupClosePushL(*pInternalisedArray);
+		
+		aSIDStatus.Reset();
+
+		// Copy the returned array into the passed array
+		TInt count = pInternalisedArray->Count();
+		for (TInt index = 0; index < count; index++)
+			{
+			aSIDStatus.AppendL((*pInternalisedArray)[index]);
+			}
+		CleanupStack::PopAndDestroy(pInternalisedArray);	// pInternalisedArray->Close()
+		CleanupStack::PopAndDestroy(pInternalisedArray); // pInternalisedArray
+		}
+	
+	TPtr8& RSBEClientSession::TransferDataAddressL()
+	/**
+	Provides access to the base of the global chunk used to transfer data between
+	the Secure Backup Engine and a Secure Backup Server.  This method should be used
+	when the Secure Backup Server is providing data to the Secure Backup Engine (either as part 
+	of a restore operation or when supplying snapshots during a backup operation.
+
+	The Secure Backup Engine only uses one global chunk at a time. It is not permissible to
+	try to carry out multiple backup or restore operations in parallel.  Normally a chunk
+	of global heap would be protected by a mutex.  In this case, all the methods of the 
+	CSecureBackupEngine must be regarded as synchronous and mutually exclusive - it is not
+	permissible to make parallel calls.
+
+	The global chunk used during a backup or restore operation may change and so the address must
+	be requested whenever required rather than being cached.
+
+	@return Pointer to the start of the buffer for writing
+	*/
+		{
+        return iGSHInterface->WriteBufferL(iGlobalSharedHeap);
+		}
+
+	TPtrC8& RSBEClientSession::TransferDataInfoL(CSBGenericTransferType*& aGenericTransferType,
+												 TBool& aFinished)
+	/**
+	Provides access to the data received from the Secure Backup Engine during a backup operation.
+
+	This method should be called after a synchronous or asynchronous request for data has
+	completed.
+
+	@param aGenericTransferType Pointer reference that a Generic Transfer Type is allocated to
+	@param aFinished Flag that will be set to ETrue if the data on the GSH is the last in the series
+	@return Pointer to the start of the buffer for reading
+	*/
+		{
+        TPtrC8& returnedBuf = iGSHInterface->ReadBufferL(iGlobalSharedHeap);
+		
+		TDesC8& genTypeBuffer = iGSHInterface->Header(iGlobalSharedHeap).GenericTransferTypeBuffer();
+		if (genTypeBuffer.Size() == 0)
+			{
+			User::Leave(KErrNotReady);
+			}
+		
+		// Create a new client-side transfer type and pass ownership
+		aGenericTransferType = CSBGenericTransferType::NewL(genTypeBuffer);
+		CleanupStack::PushL(aGenericTransferType);
+		
+		aFinished = iGSHInterface->Header(iGlobalSharedHeap).iFinished;
+
+		CleanupStack::Pop(aGenericTransferType);
+		
+		return returnedBuf;
+		}
+
+	TInt RSBEClientSession::GetGlobalSharedHeapHandle()
+	/**
+	Requests the handle for the Global Anonymous Shared Heap from the server that owns it and
+	sets the member RChunk with it.
+	
+	@return An error code resulting from the server request for the handle, KErrNone if ok
+	*/
+		{
+        TInt ret = SendReceive(ESBEMsgGetGSHHandle);
+		
+		// ret is negative if an error has ocurred
+		if (ret > KErrNone)
+			{
+			ret = iGlobalSharedHeap.SetReturnedHandle(ret);
+			
+			// Since a handle was returned, there were no errors
+			ret = KErrNone;
+			}
+		
+		return ret;
+		}
+		
+	void RSBEClientSession::RequestDataL(CSBGenericTransferType& aGenericTransferType, 
+		TRequestStatus& aStatus)
+	/**
+	Asynchronous request of the Secure Backup Engine to supply data for a particular data owner.
+	When the supplied TRequestStatus has been completed by the server, TransferDataInfoL should
+	be called to retrieve the requested data.
+	
+	@param aGenericTransferType Reference to the identifier of the data requested
+	@param aStatus TRequestStatus object used by the server to signal the client that a response 
+	is ready
+	*/
+		{
+        const TDesC8& transBuf = aGenericTransferType.Externalise();
+		SendReceive(ESBEMsgRequestDataAsync, TIpcArgs(&transBuf), aStatus);
+		}
+
+	void RSBEClientSession::RequestDataL(CSBGenericTransferType& aGenericTransferType)
+	/**
+	Synchronous request of the Secure Backup Engine to supply data for a particular data owner.
+	When the supplied TRequestStatus has been completed by the server, TransferDataInfoL should
+	be called to retrieve the requested data.
+	
+	@param aGenericTransferType Reference to the identifier of the data requested
+	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
+	*/
+		{
+        User::LeaveIfError(SendReceive(ESBEMsgRequestDataSync, 
+			TIpcArgs(&(aGenericTransferType.Externalise()))));
+		}
+		
+	void RSBEClientSession::SupplyDataL(CSBGenericTransferType& aGenericTransferType, 
+		TBool aFinished, TRequestStatus& aStatus)
+	/**
+	Synchronous method for signalling to the server that the client has placed an amount 
+	of data in the Global Shared Heap and
+	
+	@param aGenericTransferType Information about the data that has been transferred
+	@param aFinished ETrue indicates that additional SupplyDataL calls will be made as 
+	part of this transfer operation
+	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
+	*/
+		{
+        iGSHInterface->Header(iGlobalSharedHeap).GenericTransferTypeBuffer() 
+			= aGenericTransferType.Externalise();
+
+		SendReceive(ESBEMsgSupplyDataSync, TIpcArgs(aFinished), aStatus);
+		}
+
+	void RSBEClientSession::SupplyDataL(CSBGenericTransferType& aGenericTransferType, 
+		TBool aFinished)
+	/**
+	Synchronous method for signalling to the server that the client has placed an amount 
+	of data in the Global Shared Heap and
+	
+	@param aGenericTransferType Information about the data that has been transferred
+	@param aFinished ETrue indicates that additional SupplyDataL calls will be made as 
+	part of this transfer operation
+	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
+	*/
+		{
+        iGSHInterface->Header(iGlobalSharedHeap).GenericTransferTypeBuffer() 
+			= aGenericTransferType.Externalise();
+			
+		User::LeaveIfError(SendReceive(ESBEMsgSupplyDataSync, TIpcArgs(aFinished)));
+		}
+		
+	void RSBEClientSession::AllSnapshotsSuppliedL()
+	/**
+	This methods informs the data owner that all snapshots have been supplied.
+
+	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
+	*/
+		{
+        User::LeaveIfError(SendReceive(ESBEMsgAllSnapshotsSupplied));
+	
+		}
+		
+	TUint RSBEClientSession::ExpectedDataSizeL(CSBGenericTransferType& aGenericTransferType)
+	/**
+	Get the expected total size of the data to be returned by the SBE for the purposes 
+	of calculating progress information
+	
+	@param aGenericTransferType Reference to the identifier of the data to be retrieved
+	@leave If a synchronous IPC call to the SBEngine returns an error code (i.e. if SBEngine leaves)
+	*/
+		{
+        TPckgBuf<TUint> sizePkg;
+
+		TPtrC8 genType(aGenericTransferType.Externalise());
+		
+		User::LeaveIfError(SendReceive(ESBEMsgGetExpectedDataSize, TIpcArgs(&genType, &sizePkg)));
+			
+		return sizePkg();
+		}
+		
+	void RSBEClientSession::AllSystemFilesRestored()
+	/**
+	Signal the Secure Backup Engine that registration files are to be parsed and Active data owners 
+	are to be started
+	*/
+		{
+        SendReceive(ESBEMsgAllSystemFilesRestored);
+		}
+	
+	/**
+	Return the list of private data owners on the device that have backup registration files.
+	If a leave does occur, then aDataOwners
+	
+	@param aDataOwners Pointer array holding the list of Data owners requiring backup functionality.
+			Any items present in this array will be lost
+	@param aStatus is TRequestStatus&
+	*/
+	void RSBEClientSession::ListOfDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners, TRequestStatus& aStatus)
+		{
+		if (iCallbackHandler == NULL)
+			{
+			iCallbackHandler = CSBECallbackHandler::NewL(*this);				
+			}
+
+		if (iCallbackHandler->IsActive())
+			{
+			User::Leave(KErrInUse);
+			}
+		else
+			{
+			iDataOwnersArray = &aDataOwners;
+			SendReceive(ESBEMsgPrepDataOwnerInfo, iCallbackHandler->iStatus);
+			iCallbackHandler->StartL(aStatus, EListOfDataOwners);
+			}
+		}
+	
+	/**
+	Get the list of public files to backup for a particular Data Owner on a particular drive
+	
+	@param aDrive The drive that the public files exist on
+	@param aGenericDataType Reference to the generic data type that is being passed to the SBEngine.
+	@param aFiles An empty array of file information that will be filled with details of the public files
+	@param aStatus A reference to TRequestStatus
+	
+	*/	
+	void RSBEClientSession::PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, RFileArray& aFiles, TRequestStatus& aStatus)
+		{
+		if (iCallbackHandler == NULL)
+			{
+			iCallbackHandler = CSBECallbackHandler::NewL(*this);				
+			}
+	
+		if (iCallbackHandler->IsActive())
+			{
+			User::Leave(KErrInUse);
+			}
+		else
+			{
+			iFileArray = &aFiles;
+			// request the public file list
+			SendReceive(ESBEMsgPrepPublicFiles, TIpcArgs(aDrive, &(aGenericDataType.Externalise())), iCallbackHandler->iStatus);
+			iCallbackHandler->StartL(aStatus,EPublicFileList);
+			}
+		}
+		
+	void RSBEClientSession::SetBURModeL(const TDriveList& aDriveList, TBURPartType aBURType, 
+								  TBackupIncType aBackupIncType, TRequestStatus& aStatus)
+	/**
+	Set the Backup and Restore mode on/off and configure the BUR options asynchronously.
+	
+	@param aDriveList Array of drives that are to be backed up during the operations
+	@param aBURType Set the device into Full/Partial BUR or normal operation
+	@param aBackupIncType Base/Incremental backup
+	@param aStatus A reference to TRequestStatus
+	*/
+
+		{
+		SendReceive(ESBEMsgSetBURMode, TIpcArgs(&aDriveList, aBURType, aBackupIncType), aStatus);
+		}
+	
+	/**
+	This methods informs the data owner that all snapshots have been supplied.
+
+	@param aStatus A reference to TRequestStatus
+	*/	
+	void RSBEClientSession::AllSnapshotsSuppliedL(TRequestStatus& aStatus)
+		{
+		SendReceive(ESBEMsgAllSnapshotsSupplied, aStatus);
+		}
+	
+	/**
+	Signal the Secure Backup Engine that registration files are to be parsed and Active data owners 
+	are to be started
+	
+	@param aStatus A reference to TRequestStatus
+	*/	
+	void RSBEClientSession::AllSystemFilesRestoredL(TRequestStatus& aStatus)
+		{
+		SendReceive(ESBEMsgAllSystemFilesRestored, aStatus);
+		}
+				
+	
+	/**
+	Method to perform and IPC call to populate list of data owners.
+	@param aBufferSize Size of the buffer needed to be allocated for the IPC call
+	
+	@InternalTechnology
+	*/
+	void RSBEClientSession::PopulateListOfDataOwnersL(TUint aBufferSize)
+		{
+		__ASSERT_DEBUG(iDataOwnersArray, Panic(KErrBadHandle));
+		iDataOwnersArray->ResetAndDestroy();
+					
+		// Create a descriptor that's appropriate to hold the buffer to be returned		
+		HBufC8* pReturnedBuf = HBufC8::NewL(aBufferSize);
+		
+		CleanupStack::PushL(pReturnedBuf);
+
+		TPtr8 returnedBuf(pReturnedBuf->Des());
+		// Request that the server returns the previously packed array
+		TInt result = SendReceive(ESBEMsgGetDataOwnerInfo, TIpcArgs(&returnedBuf));
+		User::LeaveIfError(result);
+		
+		TInt offset = 0;
+		
+		for (TInt index = 0; index < result; index++)
+			{
+			CDataOwnerInfo* pDOI = CDataOwnerInfo::NewL(returnedBuf.Mid(offset));
+			CleanupStack::PushL(pDOI);
+
+			iDataOwnersArray->AppendL(pDOI);
+
+			CleanupStack::Pop(pDOI);
+			
+			offset += (*iDataOwnersArray)[index]->Size();
+			}
+			
+		CleanupStack::PopAndDestroy(pReturnedBuf);
+		}
+	
+	/**
+	Method to perform and IPC call to populate list of public files.
+	@param aBufferSize Size of the buffer needed to be allocated for the IPC call
+	
+	@InternalTechnology
+	*/	
+	void RSBEClientSession::PopulatePublicFileListL(TUint aBufferSize)
+		{
+		__ASSERT_DEBUG(iFileArray, Panic(KErrBadHandle));
+		iFileArray->Reset();
+		
+		// Create a descriptor big enough for the array to be externalised into
+		HBufC8* pFileArray = HBufC8::NewL(aBufferSize);
+		CleanupStack::PushL(pFileArray);
+		
+		TPtr8 fileArray(pFileArray->Des());
+		User::LeaveIfError(SendReceive(ESBEMsgGetPublicFiles, TIpcArgs(&fileArray)));
+		
+		RFileArray* pFiles = RFileArray::InternaliseL(fileArray);
+		CleanupStack::PopAndDestroy(pFileArray);
+		CleanupStack::PushL(pFiles);
+		CleanupClosePushL(*pFiles);
+		
+		TInt count = pFiles->Count();
+		for (TInt x = 0; x < count; x++)
+			{
+			iFileArray->AppendL((*pFiles)[0]);
+			pFiles->Remove(0);					// We're running out of memory, hence be frugal
+			} // for x
+		
+		CleanupStack::PopAndDestroy(pFiles); // CleanupClosePushL(*pFiles)
+		CleanupStack::PopAndDestroy(pFiles); // CleanupStack::PushL(pFiles)
+		}
+
+	void RSBEClientSession::PublicFileListL(TDriveNumber aDrive, CSBGenericDataType& aGenericDataType, 
+								RPointerArray<CSBEFileEntry>& aFileList, TBool& aFinished,
+								TInt aTotalListCursor, TInt aMaxResponseSize, TRequestStatus& aStatus)
+	/** 
+	This asynchronous method is used to retrieve the list of public files for the specified data owner
+	on the specified drive. Upon completion of aStatus, the caller should check aFileList 
+	@param aDrive The drive that contains the public files being retrieved
+	@param aGenericDataType The identifier for the data owner that owns the public files
+	@param aFileList Upon completion of aStatus, this array will contain the list of public files returned
+	@param aFinished Upon completion of aStatus, this flag will be set to indicate that there are more 
+						file entries available for this data owner and another call to this method should be made
+	@param aTotalListCursor Specifies the index into the complete list of public files for this data owner to start 
+						the next chunk of file entries from. The number of entries returned by a call to this
+						method can be determined by querying the count of aFileList
+	@param aMaxResponseSize The maximum total size in bytes of externalised CSBEFileEntry objects that will be returned
+	@param aStatus The TRequestStatus that will be completed once the engine has fully processed this request
+	*/
+		{
+		if (iCallbackHandler == NULL)
+			{
+			iCallbackHandler = CSBECallbackHandler::NewL(*this);				
+			}
+	
+		if (iCallbackHandler->IsActive())
+			{
+			User::Leave(KErrInUse);
+			}
+		else
+			{
+			iFileList = &aFileList;
+			iFinished = &aFinished;
+			iTotalListCursor = &aTotalListCursor;
+/*			TPckgC<TDriveNumber> drivePkg(aDrive);
+			TPckgC<TInt> cursorPkg(aTotalListCursor);
+			TPckgC<TInt> maxResp(aMaxResponseSize);*/
+			SendReceive(ESBEMsgPrepLargePublicFiles, TIpcArgs(static_cast<TInt>(aDrive), 
+				&(aGenericDataType.Externalise()), aTotalListCursor, aMaxResponseSize), 
+				iCallbackHandler->iStatus);
+			iCallbackHandler->StartL(aStatus,ELargePublicFileList);
+			}
+		}
+	
+	void RSBEClientSession::PopulateLargePublicFileListL(TInt aResult)
+	/** 
+	Callback following the asynchronous completion of the request for the public file list
+	@param aResult The error code returned by the engine as a result of the initial request
+	*/
+		{
+		// Retrieve the return parameters (finished flag and entry count) from SBE
+		if (KErrNone == aResult)
+			{
+			TBool finishedFlag;
+			TInt numEntries;
+			TPckg<TBool> finishPkg(finishedFlag);
+			TPckg<TInt> numEntriesPkg(numEntries);
+			User::LeaveIfError(SendReceive(ESBEMsgGetLargePublicFiles, TIpcArgs(&finishPkg, &numEntriesPkg)));
+			
+			*iFinished = finishPkg();
+			TInt numberOfReturnedEntries = numEntriesPkg();
+			
+			iFileList->ResetAndDestroy();
+			TInt cursor = 0;
+			TPtrC8 returnedBuf(iGSHInterface->ReadBufferL(iGlobalSharedHeap));
+			
+			// Retrieve the file list from GSH
+			// Pack into the previously supplied array
+			for (TInt entryIndex = 0; entryIndex < numberOfReturnedEntries; ++entryIndex)
+				{
+				TInt bytesRead = 0;
+				CSBEFileEntry* nextEntry = CSBEFileEntry::NewLC(returnedBuf.Mid(cursor), bytesRead);
+				cursor += bytesRead;
+				iFileList->AppendL(nextEntry);
+				CleanupStack::Pop(nextEntry);
+				}
+			}
+		else
+			{
+			*iFinished = EFalse;
+			}
+		}
+
+
+	//
+	// CSBECallbackHandler //
+	//	
+	
+	/** Symbian OS constructor 
+	@param aClientSession reference to a ClientSession to call callbacks on
+	@return pointer to an instantiated RSBEClientSession object 
+	*/
+	CSBECallbackHandler* CSBECallbackHandler::NewL(RSBEClientSession& aClientSession)
+		{
+		CSBECallbackHandler* self = new (ELeave) CSBECallbackHandler(aClientSession);
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		CleanupStack::Pop(self);
+		return self;
+		}
+		
+	/** Symbian second phase constructor */
+	void CSBECallbackHandler::ConstructL()
+		{
+		}
+		
+	/** Class constructor. */
+	CSBECallbackHandler::CSBECallbackHandler(RSBEClientSession& aClientSession)
+		: CActive(EPriorityNormal), iClientSession(aClientSession)
+		{
+		CActiveScheduler::Add(this);
+		}
+	/** Class destructor. */
+	CSBECallbackHandler::~CSBECallbackHandler()
+		{
+		Cancel();
+		}
+	
+	/** Starts Callback Handler
+	
+	@param aStatus Reference to the Client's request Status
+	@param aState State in order to make a relevant callback
+	
+	*/	
+	void CSBECallbackHandler::StartL(TRequestStatus& aStatus, TState aState)
+		{	
+		aStatus = KRequestPending;
+		iObserver = &aStatus;
+		iState = aState;
+		SetActive();
+		}
+		
+	/**
+	Cancels outsanding request
+	*/
+  	void CSBECallbackHandler::CancelRequest()
+  		{
+  		Cancel();
+  		}
+	/**
+	CActive::RunL() implementation
+	*/	
+	void CSBECallbackHandler::RunL()
+		{
+		TInt result = iStatus.Int();
+		if (result >= KErrNone)
+			{			
+			switch (iState)
+				{
+			case EListOfDataOwners:
+				iClientSession.PopulateListOfDataOwnersL(result);
+				break;
+			case EPublicFileList:
+				iClientSession.PopulatePublicFileListL(result);
+				break;
+			case ELargePublicFileList:
+				iClientSession.PopulateLargePublicFileListL(result);
+				break;
+			default:
+				result = KErrNotSupported;
+				break;
+				} //switch
+			} // if
+			
+		User::LeaveIfError(result);
+		
+		CompleteObserver(KErrNone);
+		}
+	
+	/**
+	CActive::DoCancel() implmenation
+	Completes observer's status with KErrCancel and sets the state to None
+	*/	
+	void CSBECallbackHandler::DoCancel()
+		{
+		iState = ENone;
+		// just to avoid repeating the code
+		CompleteObserver(KErrCancel);
+		}
+	
+	/**
+	Method for completing Client's request status
+	@param aError Completion Error
+	*/
+	void CSBECallbackHandler::CompleteObserver(TInt aError)
+		{
+		if(iObserver)
+			{
+			User::RequestComplete(iObserver, aError);
+			iObserver = NULL;
+			}
+		}
+		
+	/**
+	If RunL() leaves a CompleteObserver() method called
+	
+	@aError Error code
+	*/
+	TInt CSBECallbackHandler::RunError(TInt aError)
+		{
+		CompleteObserver(aError);
+		return KErrNone;
+		}
+		
+
+	} // conn namespace
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sbecompressionandencryption.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,770 @@
+// 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:
+// Implementation of compression and encryption
+// 
+//
+
+/**
+ @file
+*/
+#include "sbencrypt.h"
+#include "sbecompressionandencryption.h"
+#include "sblog.h"
+#include "sbtypes.h"
+
+#include <arc4.h>
+#include <ezcompressor.h>
+#include <ezdecompressor.h>
+
+// Uncomment the next line if you want to turn off compression & encryption, ignore the warnings.
+//#define TURN_OFF_COMPRESSION_AND_ENCRYPTION
+
+namespace conn
+	{
+#ifndef TURN_OFF_COMPRESSION_AND_ENCRYPTION
+	const TInt KJavaVirtualMachineSecureId = 0x102033e6;
+	const TInt KMaxHeapSize = KMaxTInt / 2;
+#endif
+	/** Compression block size
+	*/
+	const TInt KCompressionBlockSize = 1024 * 64; // 64K
+	/** Compression growth size
+	
+	This is calculated as the size of the block we want to compress * 1.01. As defined by the ZLib library.
+	*/
+	const TInt CSBECompressAndEncrypt::iCompressionGrowthSize = static_cast<TInt>(KCompressionBlockSize * 0.01) + 12 + sizeof(TCompressionHeader);
+	
+
+	template <class T> void ReadL(T& aT, TPtr8& aBuffer, TInt aStartAt = 0, TInt aToCopy = sizeof(T))
+	/** Reads data from any given type into aBuffer
+	
+	@param aT type to put in buffer
+	@param aBuffer the buffer
+	@param aStartAt offset of the data
+	@param aToCopy the amount of data to copy
+	*/
+		{
+		TUint8* inData = const_cast<TUint8*>(aBuffer.Ptr());
+		TUint8* outData = (reinterpret_cast<TUint8*>(&aT)) + aStartAt;
+		for (TInt x = 0; x < aToCopy; x++)
+			{
+			*(outData++) = *(inData++);
+			} // for
+		}
+	
+	
+	template<class T> void WriteL(T& aT, TPtr8& aBuffer, TInt aStartAt = 0, TInt aToCopy = sizeof(T))
+	/** Writes data from aBuffer into any given type
+	
+	@param aT type to read in from buffer
+	@param aBuffer the buffer
+	@param aStartAt offset of the data
+	@param aToCopy the amount of data to copy
+	*/
+		{
+		TUint8* inData = reinterpret_cast<TUint8*>(&aT);
+		TUint8* outData = (const_cast<TUint8*>(aBuffer.Ptr())) + aStartAt;
+		for (TInt x = 0; x < aToCopy; x++)
+			{
+			*(outData++) = *(inData++);
+			} // for
+			
+		aBuffer.SetLength(aBuffer.Length() + sizeof(T));
+		}
+
+	CSBECompressAndEncrypt* CSBECompressAndEncrypt::NewLC(CSBGenericTransferType*& apTransferType, TPtr8& aInputData)
+	/** Standard Symbian constructor
+	
+	@param apTransferType transfer type of data.
+	@param aInputData data block to be used. Start point will be changed to allow for compression.
+	*/
+		{
+		CSBECompressAndEncrypt* self = new(ELeave) CSBECompressAndEncrypt();
+		CleanupStack::PushL(self);
+		self->ConstructL(apTransferType, aInputData);
+		
+		return self;
+		}
+			
+	CSBECompressAndEncrypt::CSBECompressAndEncrypt() :
+		iActualStart(NULL, 0), iCipher(NULL), iIsFreed(EFalse)
+	/** Standard C++ Constructor
+	*/
+		{
+		}
+		
+	CSBECompressAndEncrypt::~CSBECompressAndEncrypt()
+	/** Standard C++ Destructor
+	*/
+		{
+#ifndef TURN_OFF_COMPRESSION_AND_ENCRYPTION	
+
+		if( ! iIsFreed )
+			iOffsetStart->Set(iActualStart);	// free reserved space when leave occurs.
+#endif
+		delete iCipher;
+		}
+	
+	void CSBECompressAndEncrypt::ConstructL(CSBGenericTransferType*& apTransferType, TPtr8& aOutputData)
+	/**
+		Standard Symbian second phase constructor
+		
+	@param apTransferType transfer type of data.
+	@param aInputData data block to be used. Start point will be changed to allow for compression.
+	*/
+		{
+		__LOG2("CSBECompressAndEncrypt::ConstructL() - START - aOutputData: 0x%08x (%d)", aOutputData.Ptr(), aOutputData.Length());
+
+#ifndef TURN_OFF_COMPRESSION_AND_ENCRYPTION		
+		// Do we need a key source and cipher?
+		TSBDerivedType derivedType = apTransferType->DerivedTypeL();
+		TInt extraToReserve = 0;
+		if ((derivedType == ESIDTransferDerivedType) || (derivedType == EJavaTransferDerivedType))
+			{
+		 	TSecureId secureId;
+		 	TDriveNumber driveNumber;
+		 	if (derivedType == ESIDTransferDerivedType)
+		 		{
+	    		// Need the Sid transfertype
+				CSBSIDTransferType* pSIDTransferType = CSBSIDTransferType::NewL(apTransferType);
+				CleanupStack::PushL(pSIDTransferType);
+
+		 		secureId = pSIDTransferType->SecureIdL();
+		 		driveNumber = pSIDTransferType->DriveNumberL();
+		 		
+		 		CleanupStack::PopAndDestroy(pSIDTransferType);
+		 		} // if
+		 	else
+		 		{
+		 		// Java
+		 		secureId.iId = KJavaVirtualMachineSecureId;
+		 		driveNumber = apTransferType->DriveNumberL();
+		 		} // else
+		 	
+		 	// We will be doing encryption. Get the key
+		 	CSecureBUREncryptKeySource* keySource = CSecureBUREncryptKeySource::NewL();
+		 	CleanupStack::PushL(keySource);
+		 	
+		 	// Get the key and the buffer?
+		 	keySource->GetBackupKeyL(driveNumber, secureId,
+		 							 iDoEncrypt, iKey, iGotBuffer, iBuffer);
+			if (!iGotBuffer)
+				{
+				// See if there is a default buffer
+				keySource->GetDefaultBufferForBackupL(driveNumber, iGotBuffer, iBuffer);
+				} // if
+				
+		 	CleanupStack::PopAndDestroy(keySource);
+		 	
+		 	// Create the cipher, if needed.
+		 	if (iDoEncrypt)
+		 		{
+		 		__LOG1("Key length: %d", iKey.Length() * 4);
+			 	iCipher = CARC4::NewL(iKey);
+			 	} // if
+			 	
+			extraToReserve = sizeof(TEncryptionHeader) + iBuffer.Size();
+		 	} // if
+	 	
+		// Reserve the space required
+		TInt numberBlocks = (aOutputData.MaxSize() / KCompressionBlockSize) + (((aOutputData.MaxSize() % KCompressionBlockSize) == 0) ? 0 : 1);
+		TInt reservedSpace = (numberBlocks * iCompressionGrowthSize) + extraToReserve;
+		__LOG2("CSBECompressAndEncrypt::ConstructL() - numberBlocks: %d, reservedSpace: %d", numberBlocks, reservedSpace);
+		
+		// Keep a copy of the acutual data block
+		iActualStart.Set(const_cast<TUint8*>(aOutputData.Ptr()), 0, aOutputData.MaxSize());
+		
+		// Reserve the space in the input data
+		if (reservedSpace > aOutputData.MaxSize())
+			{
+			User::Leave(KErrOverflow);
+			}
+		aOutputData.Set((const_cast<TUint8*>(aOutputData.Ptr()) + reservedSpace), 0, aOutputData.MaxSize() - reservedSpace);
+		iOffsetStart = &aOutputData;
+#endif		 	
+		__LOG2("CSBECompressAndEncrypt::ConstructL() - END - aOutputData: 0x%08x (%d)", aOutputData.Ptr(), aOutputData.Length());
+		}
+
+	void CSBECompressAndEncrypt::PackL(TPtr8& aOutputData)
+	/** Performs the compression and encryption
+	
+	@param aOutputData the compressed data
+	*/
+		{
+		__LOG4("CSBECompressAndEncrypt::PackL() - START - aOutputData: 0x%08x (%d), iActualStart: 0x%08x (%d)", aOutputData.Ptr(), aOutputData.Length(), iActualStart.Ptr(), iActualStart.Length());
+#ifndef TURN_OFF_COMPRESSION_AND_ENCRYPTION		
+		// Add the encryption header
+		TEncryptionHeader encryptionHeader;
+		encryptionHeader.iEncrypted = iDoEncrypt;
+		encryptionHeader.iBufferSize = iBuffer.Size();
+		encryptionHeader.iTotalSize = sizeof(TEncryptionHeader) + encryptionHeader.iBufferSize;
+		
+		__LOG1("CSBECompressAndEncrypt::PackL() - Encryption Header: Encryption supported %d", encryptionHeader.iEncrypted);
+		__LOG1("CSBECompressAndEncrypt::PackL() - Encryption Header: BufferSize %d", encryptionHeader.iBufferSize);
+		__LOG1("CSBECompressAndEncrypt::PackL() - Encryption Header: Total Size %d",encryptionHeader.iTotalSize);
+		
+		// Move along
+		TPtr8 encryptionOffset(const_cast<TUint8*>(iActualStart.Ptr()), 0, sizeof(TEncryptionHeader));
+		iActualStart.SetLength(sizeof(TEncryptionHeader));
+		
+		// Add the encryption buffer
+		if (encryptionHeader.iBufferSize > 0)
+			{
+			iActualStart.Append(reinterpret_cast<TUint8*>(const_cast<TUint16*>(iBuffer.Ptr())), iBuffer.Size());
+			} // if
+		
+		// Temp buffers used for compression & encryption
+		HBufC8* compressionBuffer = HBufC8::NewLC(KCompressionBlockSize + iCompressionGrowthSize);
+		HBufC8* encryptionBuffer = NULL;
+		if (iDoEncrypt)
+			{
+			encryptionBuffer = HBufC8::NewLC(KCompressionBlockSize + iCompressionGrowthSize);
+			} // if
+		
+		// Do compression and encryption
+		TInt location = 0;
+		while (location < iOffsetStart->Size())
+			{
+			// Size of data to compress
+			TInt toCompressSize = KCompressionBlockSize; 
+			if ((iOffsetStart->Size() - location) < KCompressionBlockSize)
+				{
+				toCompressSize = iOffsetStart->Size() - location;
+				}
+			
+			// Compress the data
+			TPtr8 toCompress((const_cast<TUint8*>(iOffsetStart->Ptr()) + location), toCompressSize, toCompressSize);
+			TPtr8 compress = compressionBuffer->Des();
+			CEZCompressor::CompressL(compress, toCompress, Z_BEST_COMPRESSION);
+			
+			// Add the header information
+			TCompressionHeader compressionHeader;
+			compressionHeader.iCompressedSize = compressionBuffer->Size();
+			compressionHeader.iUncompressedSize = toCompressSize;
+			
+			__LOG1("CSBECompressAndEncrypt::PackL() - Compression Header: Compressed %d", compressionHeader.iCompressedSize);
+			__LOG1("CSBECompressAndEncrypt::PackL() - Compression Header: UnCompressed %d", compressionHeader.iUncompressedSize);
+			
+			if (iDoEncrypt)
+				{
+				encryptionBuffer->Des().Append(reinterpret_cast<TUint8*>(&compressionHeader), sizeof(TCompressionHeader));
+				encryptionBuffer->Des().Append(compressionBuffer->Des());
+				
+				iCipher->Process(encryptionBuffer->Des(), iActualStart);
+				} // if
+			else
+				{
+				iActualStart.Append(reinterpret_cast<TUint8*>(&compressionHeader), sizeof(TCompressionHeader));
+				iActualStart.Append(compressionBuffer->Des());
+				} // else
+			
+			if (encryptionBuffer)
+				{
+				encryptionBuffer->Des().SetLength(0);
+				}
+			compressionBuffer->Des().SetLength(0);
+			location += toCompressSize;
+			encryptionHeader.iTotalSize += sizeof(TCompressionHeader) + compressionHeader.iCompressedSize;
+			} // while
+			
+		// Add the encryption buffer
+		WriteL(encryptionHeader, encryptionOffset, 0, sizeof(TEncryptionHeader));
+			
+		// Cleanup
+		if (encryptionBuffer)
+			{
+			CleanupStack::PopAndDestroy(encryptionBuffer);
+			} // if
+		CleanupStack::PopAndDestroy(compressionBuffer);
+	
+		aOutputData.Set(iActualStart);
+		iIsFreed = ETrue;
+#endif		
+		__LOG("CSBECompressAndEncrypt::PackL() - END");
+		}
+	void CSBECompressAndEncrypt::FreeReservedSpace(TPtr8& aOutputData)
+		/*
+		Free space researved in ConstructL if no data to be compressed.
+		@param aOutputData the compressed data
+		*/
+		{
+		__LOG("CSBECompressAndEncrypt::FreeReservedSpace() - START");
+
+#ifndef TURN_OFF_COMPRESSION_AND_ENCRYPTION	
+	
+		__LOG1("CSBECompressAndEncrypt::FreeReservedSpace() aOutputData.Length(): %d", aOutputData.Length());
+
+		aOutputData.Set(iActualStart);
+		iIsFreed = ETrue;
+#endif
+
+		__LOG("CSBECompressAndEncrypt::FreeReservedSpace() - END");		
+		}
+
+	CSBEDecompressAndEncrypt* CSBEDecompressAndEncrypt::NewL()
+	/** Standard Symbian constructor
+	*/
+		{
+		CSBEDecompressAndEncrypt* self = CSBEDecompressAndEncrypt::NewLC();
+		CleanupStack::Pop(self);
+		
+		return self;
+		}
+	
+	CSBEDecompressAndEncrypt* CSBEDecompressAndEncrypt::NewLC()
+	/** Standard Symbian constructor
+	*/
+		{
+		CSBEDecompressAndEncrypt* self = new(ELeave) CSBEDecompressAndEncrypt();
+		CleanupStack::PushL(self);
+		
+		return self;
+		}
+		
+	CSBEDecompressAndEncrypt::CSBEDecompressAndEncrypt() :
+		iType(ENotSet), iCurrentPtr(NULL, 0), iCount(0), iJavaHash(NULL), iCipher(NULL)
+		/** Stanard C++ Constructor
+		*/
+		{
+		Reset();
+		}
+		
+	CSBEDecompressAndEncrypt::~CSBEDecompressAndEncrypt()
+	/** Standard C++ Destructor 
+	*/
+		{
+		delete iCipher;
+		delete iJavaHash;
+		delete iBuffer;
+		}
+		
+	void CSBEDecompressAndEncrypt::SetBuffer(TDesC8& aOutputData)
+		{
+		iCurrentPtr.Set(const_cast<TUint8*>(aOutputData.Ptr()), aOutputData.Size(), aOutputData.Size());
+		}
+		
+	void CSBEDecompressAndEncrypt::SetGenericTransferTypeL(CSBGenericTransferType*& apTransferType)
+		{
+		__LOG("CSBEDecompressAndEncrypt::SetGenericTransferTypeL() - START");
+#ifndef TURN_OFF_COMPRESSION_AND_ENCRYPTION
+		TSBDerivedType derivedType = apTransferType->DerivedTypeL();
+		if (derivedType == ESIDTransferDerivedType)
+			{
+			// Need the Sid transfertype
+			CSBSIDTransferType* pSIDTransferType = CSBSIDTransferType::NewL(apTransferType);
+			CleanupStack::PushL(pSIDTransferType);
+			
+			// Do we need to perform a reset
+			if ((iType != ESid) ||
+				(iDriveNumber != pSIDTransferType->DriveNumberL()) ||
+			    (iSecureId != pSIDTransferType->SecureIdL()))
+				{
+				Reset();
+				
+				iDriveNumber = pSIDTransferType->DriveNumberL();
+				iSecureId = pSIDTransferType->SecureIdL();
+				__LOG1("CSBEDecompressAndEncrypt::SetGenericTransferTypeL() - SecureId ID 0x%08x", iSecureId.iId);
+				iType = ESid;
+				} // if
+				CleanupStack::PopAndDestroy(pSIDTransferType);
+			} // if
+		else if (derivedType == EJavaTransferDerivedType)
+			{
+	 		// Java
+			CSBJavaTransferType* pJavaTransferType = CSBJavaTransferType::NewL(apTransferType);
+			CleanupStack::PushL(pJavaTransferType);
+			
+			// Do we need to perform a reset
+			const TDesC& javahash = pJavaTransferType->SuiteHashL();
+			__LOG1("CSBEDecompressAndEncrypt::SetGenericTransferTypeL() - JavaHash %S", &javahash);
+			if ((iType != EJava) ||
+			    (iDriveNumber != pJavaTransferType->DriveNumberL()) ||
+			    (iJavaHash->Des() != javahash))
+				{
+				Reset();
+				
+		 		// Store java hash
+		 		delete iJavaHash;
+		 		iJavaHash = NULL;
+		 		iJavaHash = HBufC::NewL(javahash.Size());
+		 		iJavaHash->Des().Append(javahash);
+		 		
+		 		iSecureId.iId = KJavaVirtualMachineSecureId;
+		 		iDriveNumber = apTransferType->DriveNumberL();
+		 		iType = EJava;
+				}
+	 		
+	 		CleanupStack::PopAndDestroy(pJavaTransferType);
+			} // else if
+		else if (derivedType == EPackageTransferDerivedType)
+			{
+			// Package
+			CSBPackageTransferType* pPackageTransferType = CSBPackageTransferType::NewL(apTransferType);
+			CleanupStack::PushL(pPackageTransferType);
+			
+			// Do we need to perform a reset
+			if ((iType != EPackage) ||
+			    (iPackageId != pPackageTransferType->PackageIdL()))
+				{
+				Reset();
+				iPackageId = pPackageTransferType->PackageIdL();
+				__LOG1("CSBEDecompressAndEncrypt::SetGenericTransferTypeL() - Package ID 0x%08x", iPackageId.iUid);
+				iType = EPackage;
+				}
+				
+			CleanupStack::PopAndDestroy(pPackageTransferType);
+			} // else if
+		else
+			{
+			__LOG("CSBEDecompressAndEncrypt::SetGenericTransferTypeL() - DerivedType not supported");
+			User::Leave(KErrNotSupported);
+			} // else
+#endif
+		__LOG("CSBEDecompressAndEncrypt::SetGenericTransferTypeL() - END");
+		}
+		
+	void CSBEDecompressAndEncrypt::Reset()
+	/** Resets the data 
+	*/
+		{
+		__LOG("CSBEDecompressAndEncrypt::Reset()");
+		iCount = 0;
+		iType = ENotSet;
+		iDoDecrypt = EFalse;
+		iCurrentPtr.Set(NULL, 0, 0);
+		iGotCompressionHeader = EFalse;
+		iCompressionSizeRead = 0;
+		iEncryptionSizeRead = 0;
+		iDoneDecompression = EFalse;
+		iGotCipher = EFalse;
+		delete iBuffer;
+  		iBuffer = NULL;
+		}
+		
+	void CSBEDecompressAndEncrypt::MoveAlongL(TPtr8& aPtr, TInt aAmount)
+	/** Move a pointer along a given amount
+	
+	@param aPtr pointer to move
+	@param aAmount amount to move
+	*/
+		{
+		TInt newSize = aPtr.Size() - aAmount;
+		// Check
+		if (newSize < 0)
+			{
+			__LOG("CSBEDecompressAndEncrypt::MoveAlong() - Overflow");
+			User::Leave(KErrOverflow);
+			}
+		
+		aPtr.Set(const_cast<TUint8*>(aPtr.Ptr()) + aAmount, newSize, newSize);			
+		}
+	
+	TBool CSBEDecompressAndEncrypt::NextLC(HBufC8*& apOutput, TBool& aMoreData)
+	/** Decompress a block of the data
+	
+	@param apOutput on return the next block of uncompressed data. This must be deleted by the caller.
+	@param aMoreData is there more data left in the compressed block.
+	*/
+		{
+		__LOG("CSBEDecompressAndEncrypt::NextLC() - START");
+#ifndef TURN_OFF_COMPRESSION_AND_ENCRYPTION
+		if (!iGotCipher)
+			{
+			iGotCipher = CreateCipherL();
+			if (!iGotCipher)
+				{
+				return EFalse;
+				} // if
+			}
+
+		if (!iGotCompressionHeader)
+			{
+			__LOG("CSBEDecompressAndEncrypt::NextLC - No Header read yet");
+
+			// Determine how much data we need to read to complete the header
+			TInt dataAvail = iCurrentPtr.Size();
+			if (iCompressionSizeRead + dataAvail > sizeof(TCompressionHeader))
+				{
+				dataAvail = sizeof(TCompressionHeader) - iCompressionSizeRead;
+				}
+			
+			// Read data into header
+			ReadL(iCompressionHeader, iCurrentPtr, iCompressionSizeRead, dataAvail);
+			MoveAlongL(iCurrentPtr, dataAvail);
+			iCompressionSizeRead += dataAvail;
+			iCount += dataAvail;
+			
+			if (iCompressionSizeRead < sizeof(TCompressionHeader))
+				{
+				__LOG1("CSBEDecompressAndEncrypt::NextLC - Got partial compression header (%d bytes)",iCompressionSizeRead );
+				return EFalse;
+				}
+
+			__LOG2("CSBEDecompressAndEncrypt::NextLC - Got compression header (compressed size=%d, uncompressed=%d)", 
+				iCompressionHeader.iCompressedSize, iCompressionHeader.iUncompressedSize);
+			
+			// Was the header encrypted?
+			if (iEncryptionHeader.iEncrypted)
+				{
+				__LOG("CSBEDecompressAndEncrypt::NextLC - Header Encrypted!");
+				TCompressionHeader compressionHeader;
+				TPtr8 inData(reinterpret_cast<TUint8*>(&iCompressionHeader), sizeof(TCompressionHeader), sizeof(TCompressionHeader));
+				TPtr8 outData(reinterpret_cast<TUint8*>(&compressionHeader), 0, sizeof(TCompressionHeader));
+				
+				iCipher->Process(inData, outData);
+				iCompressionHeader = compressionHeader;
+				__LOG2("CSBEDecompressAndEncrypt::NextLC - unencrypted header, compressed size %d, uncompressed %d", iCompressionHeader.iCompressedSize, iCompressionHeader.iUncompressedSize);
+				}
+				
+			iCompressionSizeRead = 0;
+			iGotCompressionHeader = ETrue;
+			} // if
+			
+		// Check the compression header is sensible
+		if ((iCompressionHeader.iCompressedSize < 0) ||
+			(iCompressionHeader.iUncompressedSize < 0) || 
+			(iCompressionHeader.iCompressedSize >= KMaxHeapSize) ||
+			(iCompressionHeader.iUncompressedSize >= KMaxHeapSize))
+			{
+			__LOG("CSBEDecompressAndEncrypt::NextLC() - Compression header is corrupt");
+			User::Leave(KErrCorrupt);
+			}
+
+		if (!iDoneDecompression)
+			{
+			// Do we have enough data to decompress?
+			TInt dataSize = iCurrentPtr.Size();
+			__LOG1("CSBEDecompressAndEncrypt::NextLC() - Doing Decompression - data size %d", dataSize);
+			if (iBuffer != NULL)
+				{
+				dataSize += iBuffer->Size();
+				__LOG1("CSBEDecompressAndEncrypt::NextLC() - iBuffer not NULL new data size %d", dataSize)
+				}
+			if (dataSize < iCompressionHeader.iCompressedSize)
+				{
+				__LOG("CSBEDecompressAndEncrypt::NextLC() - data size < compressed size");
+				// Need to buffer the buffer
+				if (iBuffer == NULL)
+  					{
+  					__LOG1("CSBEDecompressAndEncrypt::NextLC() - Creating internal buffer of size %d",iCompressionHeader.iCompressedSize);
+  					iBuffer = HBufC8::NewL(iCompressionHeader.iCompressedSize);	
+  					}
+
+				iBuffer->Des().Append(const_cast<TUint8*>(iCurrentPtr.Ptr()), iCurrentPtr.Size());
+				__LOG("CSBEDecompressAndEncrypt::NextLC() - Appending data to internal buffer");
+				return EFalse;
+				} // if
+				
+			// Do we have a buffer?
+			TPtr8 inData(NULL, 0);
+			TInt toAppend = 0;
+			if (iBuffer != NULL)
+				{
+				__LOG("CSBEDecompressAndEncrypt::NextLC() - Preparing inData from internal buffer");
+				toAppend = iCompressionHeader.iCompressedSize - iBuffer->Des().Size();
+				iBuffer->Des().Append(const_cast<TUint8*>(iCurrentPtr.Ptr()), toAppend);
+				
+				inData.Set(const_cast<TUint8*>(iBuffer->Des().Ptr()), iBuffer->Des().Size(), iBuffer->Des().Size());
+				} // if
+			else
+				{
+				__LOG("CSBEDecompressAndEncrypt::NextLC() - Preparing inData");
+				inData.Set(const_cast<TUint8*>(iCurrentPtr.Ptr()), iCompressionHeader.iCompressedSize, iCompressionHeader.iCompressedSize);			
+				} // else
+				
+			// Uncompress + Decrypt the buffer
+			apOutput = HBufC8::NewLC(iCompressionHeader.iUncompressedSize);
+			__LOG1("CSBEDecompressAndEncrypt::NextLC() - Allocated Output data for uncompressed data of size %d", iCompressionHeader.iUncompressedSize);
+			if (iEncryptionHeader.iEncrypted)
+				{
+				__LOG("CSBEDecompressAndEncrypt::NextLC() Encrypted data, trying to allocate temp");
+				// Need another temp buffer
+				HBufC8* temp = HBufC8::NewLC(iCompressionHeader.iCompressedSize);
+				
+				// Decrypt
+				TPtr8 ptrTemp = temp->Des();
+				iCipher->Process(inData, ptrTemp);
+				// Decompress
+				TPtr8 ptrOutput = apOutput->Des();
+				CEZDecompressor::DecompressL(ptrOutput, ptrTemp);
+				
+				// Cleanup
+				CleanupStack::PopAndDestroy(temp);
+				__LOG("CSBEDecompressAndEncrypt::NextLC() Decryption and decompresson done");
+				} // if
+			else
+				{
+				// Decompress
+				TPtr8 ptrOutput = apOutput->Des();
+				CEZDecompressor::DecompressL(ptrOutput, inData);
+				__LOG("CSBEDecompressAndEncrypt::NextLC() decompresson done");
+				} // else
+				
+			iCount += iCompressionHeader.iCompressedSize;
+			if (toAppend != 0)
+				{
+				MoveAlongL(iCurrentPtr, toAppend);
+				}
+			else
+				{
+				MoveAlongL(iCurrentPtr, iCompressionHeader.iCompressedSize);
+				}
+			
+			delete iBuffer;
+			iBuffer = NULL;
+
+			iDoneDecompression = ETrue;
+			} // if
+		
+		__LOG2("CSBEDecompressAndEncrypt::NextLC() - encryption buffer done %d of %d", iCount, iEncryptionHeader.iTotalSize);
+
+		// If the entire encrypted block has been read, prepare to read the next one
+		if (iCount >= iEncryptionHeader.iTotalSize)
+			{
+			iGotCipher = EFalse;
+			iEncryptionSizeRead = 0;
+			iCount = 0;
+			}
+		
+		// Is there more data available?
+		if (iCurrentPtr.Size() == 0)
+			{
+			Reset();
+			aMoreData = EFalse;
+			}
+		else
+			{
+			aMoreData = ETrue;
+			}
+			
+		// Prepare to read the next compressed block
+		iGotCompressionHeader = EFalse;
+		iCompressionSizeRead = 0;
+		iDoneDecompression = EFalse;
+
+#else
+		TInt size = g_CompressionBlockSize;
+		if (size > iCurrentPtr.Size())
+			{
+			size = iCurrentPtr.Size();
+			} // if
+			
+		apOutput = HBufC8::NewLC(size);
+		apOutput->Des().Append(iCurrentPtr.Ptr(), size);
+		MoveAlong(iCurrentPtr, size);
+
+		// Is there more data available?
+		if (iCurrentPtr.Size() == 0)
+			{
+			aMoreData = EFalse;
+			}
+		else
+			{
+			aMoreData = ETrue;
+			}
+#endif			
+		__LOG("CSBEDecompressAndEncrypt::NextLC() - END");
+		return ETrue;
+		}
+		
+	TBool CSBEDecompressAndEncrypt::CreateCipherL()
+	/**
+	Creates the cipher to to use in decryption.
+	
+	@return ETrue if cipher created, otherwise EFalse.
+	*/
+		{
+		__LOG("CSBEDecompressAndEncrypt::CreateCipherL() - START");
+		
+		TInt dataAvail = iCurrentPtr.Size();
+		if (iEncryptionSizeRead + dataAvail > sizeof(TEncryptionHeader))
+			{
+			dataAvail = sizeof(TEncryptionHeader) - iEncryptionSizeRead;
+			}
+		
+		// Read data into header
+		ReadL(iEncryptionHeader, iCurrentPtr, iEncryptionSizeRead, dataAvail);
+		MoveAlongL(iCurrentPtr, dataAvail);
+		iEncryptionSizeRead += dataAvail;
+		iCount += dataAvail;
+		
+		if (iEncryptionSizeRead < sizeof(TEncryptionHeader))
+			{
+			__LOG1("CSBEDecompressAndEncrypt::CreateCipherL - Got partial encryption header (%d bytes)",iEncryptionSizeRead);
+			return EFalse;
+			}
+
+		__LOG3("CSBEDecompressAndEncrypt::CreateCipherL - Got encryption header (encrypted=%d, buffer size=%d, total size=%d)", 
+			iEncryptionHeader.iEncrypted, iEncryptionHeader.iBufferSize, iEncryptionHeader.iTotalSize);
+		
+		// Check we have a sensible encryption header
+		if ((iEncryptionHeader.iBufferSize < 0) ||
+			(iEncryptionHeader.iTotalSize < 0))
+			{
+			__LOG("CSBEDecompressAndEncrypt::CreateCipherL() - Corrupt data");
+			User::Leave(KErrCorrupt);
+			}
+		if (iEncryptionHeader.iEncrypted)
+			{
+			// Get the decryption key
+			CSecureBUREncryptKeySource* keySource = CSecureBUREncryptKeySource::NewL();
+			CleanupStack::PushL(keySource);
+				
+			HBufC* alignedBuffer = HBufC::NewLC(iEncryptionHeader.iBufferSize);
+			TBool gotBuffer = (iEncryptionHeader.iBufferSize > 0);
+			if (gotBuffer)
+				{
+				TUint8* in = reinterpret_cast<TUint8*>(const_cast<TUint16*>(alignedBuffer->Des().Ptr()));
+				TUint8* out = const_cast<TUint8*>(iCurrentPtr.Ptr());
+				
+				for (TInt x = 0; x < iEncryptionHeader.iBufferSize; x++)
+					{
+					in[x] = out[x];
+					} // for x
+				alignedBuffer->Des().SetLength(iEncryptionHeader.iBufferSize / KCharWidthInBytes);
+				}
+			
+			TBuf8<KKeySize> key;
+			TBool gotKey = EFalse;
+			TPtr16 ptrAlignedBuffer(alignedBuffer->Des());
+			keySource->GetRestoreKeyL(iDriveNumber, iSecureId, gotBuffer, ptrAlignedBuffer, gotKey, key);
+			if (!gotKey)
+				{
+				User::Leave(KErrCorrupt);
+				}
+				
+		 	// Create the cipher
+		 	if (iCipher)
+		 		{
+		 		delete iCipher;
+		 		iCipher = NULL;
+		 		}
+		 	iCipher = CARC4::NewL(key);
+				
+			// Cleanup
+			CleanupStack::PopAndDestroy(alignedBuffer);
+			CleanupStack::PopAndDestroy(keySource);				
+			} // if
+			
+		// Set iCount
+		iCount += iEncryptionHeader.iBufferSize;
+		// Move current pointer along
+		MoveAlongL(iCurrentPtr, iEncryptionHeader.iBufferSize);
+		__LOG("CSBEDecompressAndEncrypt::CreateCipherL() - END");
+		return ETrue;
+		}
+		
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sbeconfig.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,410 @@
+// 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:
+// Implementation of sbeconfig
+// 
+//
+
+/**
+ @file
+*/
+#include <e32std.h>
+#include <connect/panic.h>
+#include "sbeconfig.h"
+#include "sblog.h"
+#include <xml/parser.h>
+
+namespace conn
+	{
+	const TInt KSIDLength = 8;
+	
+	// XML type
+	_LIT8(KMimeType, "text/xml");
+	
+	// elements
+	_LIT8(KConfig, "sbe_config");
+	_LIT8(KHeap, "heap");
+	_LIT8(KCentRep, "central_repository");
+	_LIT8(KDrives, "exclude_drives");
+	_LIT8(KAppCloseDelay, "app_close_delay");
+	
+	_LIT8(KSize, "size");
+	_LIT8(KUid, "uid");
+	_LIT8(KList, "list");
+	
+	_LIT8(KRedFact, "reduction_factor");
+	_LIT8(KMaxRetries, "max_retries");
+	
+	_LIT8(KDelay, "delay");
+	
+	// default setting if no file found
+	const TInt KSBEGSHDefaultSize = 2097152;
+	const TInt KSBEGSHReductionFactor = 2;
+	const TInt KSBEGSHMaxRetries = 5;
+	
+	const TInt KMinHeapSize = 131072;
+	
+	const TInt KDefaultDelay = 0;
+	
+	_LIT_SECURE_ID(KCentRepSID,0x10202BE9);
+	_LIT(KConfigFile, "sbeconfig.xml");
+	
+	/**
+	Symbian Constructor
+	@param RFs& reference to RFs
+	@return CSBEConfig* pointer to CSBEConfig
+	*/
+	CSBEConfig* CSBEConfig::NewL(RFs& aRFs)
+		{
+		CSBEConfig* self = new (ELeave) CSBEConfig(aRFs);
+		return self;
+		}
+	
+	/**
+	C++ Constructor
+	*/
+	CSBEConfig::CSBEConfig(RFs& aRFs) : iRFs(aRFs), iFileName(KConfigFile), iConfigTagVisited(EFalse)
+		{
+		SetDefault();
+		}
+	/** 
+	Destructor
+	*/
+	CSBEConfig::~CSBEConfig()
+		{
+		delete iConverter;
+		}
+	
+	/**
+	Heap Values
+	@param TInt& aMaxSize of the heap to try to allocate
+	@param TInt& aReductionFactor in case allocation fail
+	@param TInt& number of retries to try to reduce the heap by the ReductionFactor
+	*/
+	void CSBEConfig::HeapValues(TInt& aMaxSize, TInt& aReductionFactor, TInt& aMaxRetries) const
+		{
+		aMaxSize = iSBEGSHMaxSize;
+		aReductionFactor = iReductionFactor;
+		aMaxRetries = iMaxRetries;
+		}
+		
+	/**
+	Secure Id for central repository, needed deprecated use of centrep tag in xml
+	@return TSecureId& aSecureId
+	*/	
+	TSecureId CSBEConfig::CentRepId() const
+		{
+		return iCentRepId;
+		}
+	
+	/**
+	Exclude list of drives from backup/restore
+	@return TDriveList& aDriveList
+	*/	
+	const TDriveList& CSBEConfig::ExcludeDriveList() const
+		{
+		return iDrives;
+		}
+	
+	/**
+	Extra time delay to close all non-system apps 
+	@return TInt& iAppCloseDelay
+	*/
+	TUint CSBEConfig::AppCloseDelay() const
+		{
+		return iAppCloseDelay;
+		}
+
+	/**
+	Set the values to Defaults
+	*/	
+	void CSBEConfig::SetDefault()
+		{
+		iSBEGSHMaxSize = KSBEGSHDefaultSize;
+		iCentRepId = KCentRepSID;
+		iDrives.SetLength(KMaxDrives);
+		iDrives.FillZ();
+		iDrives[EDriveZ] = ETrue;
+		iReductionFactor = KSBEGSHReductionFactor;
+		iMaxRetries = KSBEGSHMaxRetries;
+		iAppCloseDelay = KDefaultDelay;
+		}
+		
+	/**
+	Method to convert string of drives (eg. cdez) to member variable TDriveList
+	@param const TDesC8& reference to string
+	*/	
+	TInt CSBEConfig::StringToDrives(const TDesC8& aDes)
+		{
+		iDrives.SetLength(KMaxDrives);
+		iDrives.FillZ();
+		
+		TInt err = KErrNone;
+		TInt length = aDes.Length();
+		for (TInt i = 0; i < length; ++i)
+			{
+			TInt pos;
+			err = iRFs.CharToDrive(aDes.Ptr()[i], pos);
+			if (err != KErrNone)
+				{
+				break;
+				}
+			iDrives[pos] = ETrue;
+			}
+		return err;
+		}
+	
+	/**
+	Parses the config file if found
+	@leave with System wide Error Codes
+	*/	
+	void CSBEConfig::ParseL()
+		{
+		iRFs.PrivatePath(iFileName);
+		TFindFile findFile(iRFs);
+		User::LeaveIfError(findFile.FindByPath(KConfigFile, &iFileName));
+		
+		iFileName = findFile.File();
+		// Connect to the parser
+		CParser* parser = CParser::NewLC(KMimeType, *this);
+		
+		// Parse the file
+		Xml::ParseL(*parser, iRFs, iFileName);
+		
+		CleanupStack::PopAndDestroy(parser);
+		}
+		
+	/**
+	A method to handle attributes
+	@param RAttributeArray& aAttributes 
+	@return TInt System Wide Error
+	*/	
+	TInt CSBEConfig::HandleAttributesElement(const RAttributeArray& aAttributes)
+		{
+		TInt err = KErrNone;
+		// Loop through reading out attribute values
+		const TUint count = aAttributes.Count();
+		for (TInt x = 0; x < count && err == KErrNone; x++)
+			{
+			TPtrC8 attrib = aAttributes[x].Attribute().LocalName().DesC();
+			TPtrC8 value = aAttributes[x].Value().DesC();
+			if (!attrib.CompareF(KDelay))
+				{
+				TLex8 lex(value);
+				TInt appCloseDelay = 0;
+				err = lex.Val(appCloseDelay);
+				if (appCloseDelay < 0)
+					{
+					__LOG("CSBEConfig::HandleAttributesElement() - Configuration Error: the time delay is negative");
+					err = KErrCorrupt;
+					}
+				else
+					{
+					iAppCloseDelay = appCloseDelay;
+					}
+				}
+			if (!attrib.CompareF(KRedFact))
+				{
+				TLex8 lex(value);
+				err = lex.Val(iReductionFactor);
+				if (iReductionFactor < 0)
+					{
+					__LOG("CSBEConfig::HandleAttributesElement() - Configuration Error: the reductionFactor is negative");
+					err = KErrCorrupt;
+					}
+				}
+			else if (!attrib.CompareF(KMaxRetries))
+				{
+				TLex8 lex(value);
+				err = lex.Val(iMaxRetries);
+				if (iMaxRetries < 0)
+					{
+					__LOG("CSBEConfig::HandleAttributesElement() - Configuration Error: the maxRetries is negative");
+					err = KErrCorrupt;
+					}
+				}
+			if (!attrib.CompareF(KSize))
+				{
+				TLex8 lex(value);
+				err = lex.Val(iSBEGSHMaxSize);
+				if (iSBEGSHMaxSize < KMinHeapSize)
+					{
+					__LOG1("CSBEConfig::HandleAttributesElement() - Configuration Error: heap size is less then minimum %d", KMinHeapSize);
+					err = KErrCorrupt;
+					}
+				} // if
+			else if (!attrib.CompareF(KUid))
+				{
+				TLex8 lex;
+				if (value.Length() >= KSIDLength)
+					{
+					lex = value.Right(KSIDLength);
+					err = lex.Val(iCentRepId.iId, EHex);
+					if (iCentRepId.iId == 0)
+						{
+						err = KErrCorrupt;
+						}
+					}
+				if (err != KErrNone)
+					{
+					__LOG("CSBEConfig::HandleAttributesElement() - Configuration Error: central_repostiory is NOT a HEX number");
+					err = KErrCorrupt;
+					}
+				} // else if
+			else if (!attrib.CompareF(KList))
+				{
+				err = StringToDrives(value);
+				if (err != KErrNone)
+					{
+					__LOG("CSBEConfig::HandleAttributesElement() - Configuration Error: list doesn't have valid characters from a-z");
+					}
+				} // else if
+				
+			} // for x
+		return err;
+		}
+		
+// From MContentHandler
+	void CSBEConfig::OnStartDocumentL(const RDocumentParameters& /*aDocParam*/, TInt /*aErrorCode*/)
+	/**
+	Start of the document, creates Character Converter to convert from/to unicode
+	
+	@see MContentHandler::OnStartDocumentL()
+	@leave if fails to set encoding
+	*/
+		{
+		// Create a converter for converting strings to Unicode
+		iConverter = CCnvCharacterSetConverter::NewL();
+
+		// We only convert from UTF-8 to UTF-16
+		if (iConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierUtf8, iRFs) == CCnvCharacterSetConverter::ENotAvailable)
+			{
+			User::Leave(KErrNotFound);
+			}
+		}
+		
+	void CSBEConfig::OnEndDocumentL(TInt /*aErrorCode*/)
+	/**
+	End of document. destroys converter object
+	
+	@see MContentHandler::OnEndDocumentL()
+	*/
+		{
+		// We've finished parsing the document, hence destroy the converter object
+		delete iConverter;
+		iConverter = NULL;
+		}
+		
+	void CSBEConfig::OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt /*aErrCode*/)
+	/**
+	Element to parse on the start
+	
+	@see MContentHandler::OnStartElementL()
+	
+	@param aElement RTagInfo&
+	@param aAttributes RAttributeArray&
+	*/
+		{
+		TInt err = KErrNone;
+		TPtrC8 localName(aElement.LocalName().DesC());
+		if (!localName.CompareF(KConfig))
+			{
+			iConfigTagVisited = ETrue;
+			} // if
+		else if (iConfigTagVisited)
+			{
+			if (!localName.CompareF(KHeap) || !localName.CompareF(KCentRep) || !localName.CompareF(KDrives) || !localName.CompareF(KAppCloseDelay))
+				{
+				err = HandleAttributesElement(aAttributes);
+				} // if
+			else
+				{
+				err = KErrCorrupt;
+				} // else if
+			} // else if
+		else
+			{
+			err = KErrCorrupt;
+			}
+		User::LeaveIfError(err);
+		}
+		
+	void CSBEConfig::OnEndElementL(const RTagInfo& /*aElement*/, TInt /*aErrorCode*/)
+	/**
+	Element to parse at the end
+	
+	@see MContentHandler::OnEndElementL()
+	@param const aElement RTagInfo&
+	*/
+		{
+		}
+		
+	void CSBEConfig::OnContentL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/)
+	/** 
+	@see MContentHandler::OnContentL()
+	*/
+		{
+		}
+		
+	void CSBEConfig::OnStartPrefixMappingL(const RString& /*aPrefix*/, const RString& /*aUri*/, TInt /*aErrorCode*/)
+	/** 
+	@see MContentHandler::OnStartPrefixMappingL()
+	*/
+		{
+		}
+		
+	void CSBEConfig::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt /*aErrorCode*/)
+	/** 
+	@see MContentHandler::OnEndPrefixMappingL()
+	*/
+		{
+		}
+		
+	void CSBEConfig::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/)
+	/** 
+	@see MContentHandler::OnIgnorableWhiteSpaceL()
+	*/
+		{
+		}
+		
+	void CSBEConfig::OnSkippedEntityL(const RString& /*aName*/, TInt /*aErrorCode*/)
+	/** 
+	@see MContentHandler::OnSkippedEntityL()
+	*/
+		{
+		}
+		
+	void CSBEConfig::OnProcessingInstructionL(const TDesC8& /*aTarget*/, const TDesC8& /*aData*/, TInt /*aErrorCode*/)
+	/** 
+	@see MContentHandler::OnProcessingInstructionL()
+	*/
+		{
+		}
+		
+	void CSBEConfig::OnError(TInt /*aErrorCode*/)
+	/** 
+	@see MContentHandler::OnError()
+	*/
+		{
+		}
+		
+	TAny* CSBEConfig::GetExtendedInterface(const TInt32 /*aUid*/)
+	/** 
+	@see MContentHandler::GetExtendedInterface()
+	*/
+		{
+		return NULL;
+		}
+		
+	
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sbedataowner.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,3722 @@
+// 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:
+// Implementation of CDataOwner
+// 
+//
+
+/**
+ @file
+*/
+#include <d32dbms.h>
+
+#include "sbedataowner.h"
+#include "abserver.h"
+#include "sbtypes.h"
+#include "sblog.h"
+#include "sbeparserdefs.h"
+#include <connect/panic.h>
+
+namespace conn
+	{	
+	_LIT(KDrive, "?:");
+	_LIT(KDriveAndSlash, "?:\\");
+	_LIT(KPrivateMatch, "?:\\private\\*");
+	_LIT(KPrivateSidMatch, "?:\\private\\");
+	_LIT(KSys, "?:\\sys\\*");
+	_LIT(KSystem, "?:\\system\\*");
+	_LIT(KResource, "?:\\resource\\*");
+	_LIT(KOther, "*\\..\\*");
+	_LIT(KPad, "00000000"); // Used for padding if required
+	_LIT(KQuestionMark, "?");
+	_LIT8(KVersion, "1.0");
+	_LIT( KExclamationAsDrive, "!"); // Used to generic drives for public data as in .SIS file package
+	_LIT( KPrivateNoBackup, "?:\\private\\????????\\NoBackup\\*"); // Used to exclude the file if it is in "NoBackup" folder.
+	
+		
+	
+	void CleanupRPointerArray(TAny* aPtr)
+		{
+		RPointerArray<CBase>* array = static_cast<RPointerArray<CBase>*>(aPtr);
+		array->ResetAndDestroy();
+		delete array;
+		}
+	
+	// CSelection //
+	
+	/**
+	
+	Symbian 2nd phase construction creates a Selection
+	
+	@param aType - Selection Type
+	@param aSelection - Selection Nmae
+	@return CSelection a pointer to a new object 
+	*/
+	CSelection* CSelection::NewLC(TSelectionType aType, const TDesC& aSelection)
+		{
+		CSelection* self = new (ELeave) CSelection(aType);
+		CleanupStack::PushL(self);
+		self->ConstructL(aSelection);
+		return self;
+		}
+	
+	/**
+	Standard C++ destructor
+	*/
+	CSelection::~CSelection()
+		{
+		delete iSelection;
+		}
+	
+	/**
+	Standard C++ constructor
+	*/
+	CSelection::CSelection(TSelectionType aType) : iType(aType)
+		{
+		}
+		
+	/**
+	Symbian 2nd phase constructor
+	*/
+	void CSelection::ConstructL(const TDesC& aSelection)
+		{
+		iSelection = aSelection.AllocL();
+		}
+	
+	/**
+	Selection Type
+	
+	@return TSelectionType Type
+	*/
+	TSelectionType CSelection::SelectionType() const
+		{
+		return iType;
+		}
+	
+	/**
+	Selection Name
+	
+	@return const TDesC& Name
+	*/
+	const TDesC& CSelection::SelectionName() const
+		{
+		return *iSelection;
+		}
+	
+	// CSelection End //
+		
+	CDataOwner* CDataOwner::NewL(TSecureId aSID, CDataOwnerManager* apDataOwnerManager)
+	/** Symbian OS static constructor
+
+	@param aSID secure id of data owner
+	@param apDataOwnerManager data owner manager to access resources
+	@return a CDataOwner object
+	*/
+		{
+		CDataOwner* self = CDataOwner::NewLC(aSID, apDataOwnerManager);
+		CleanupStack::Pop(self);
+
+		return self;
+		}
+
+	CDataOwner* CDataOwner::NewLC(TSecureId aSID, CDataOwnerManager* apDataOwnerManager)
+	/** Symbian OS static constructor
+
+	@param aSID secure id of data owner
+	@param apDataOwnerManager data owner manager to access resources
+	@return a CDataOwner object
+	*/
+		{
+		CDataOwner* self = new(ELeave) CDataOwner(aSID, apDataOwnerManager);
+		CleanupStack::PushL(self);
+
+		self->ConstructL();
+		
+		return self;
+		}
+
+	CDataOwner::CDataOwner(TSecureId aSID, CDataOwnerManager* apDataOwnerManager) :
+	    iStatus(EUnset), iFilesParsed(EFalse), iPrimaryFile(EFalse), /*iBackupAsPartial(EFalse), */
+	    iSecureId(aSID),
+	    iBufferFileWriter(NULL), iBufferFileReader(NULL), iBufferSnapshotWriter(NULL), 
+	    iTempSnapshotHolder(NULL), ipDataOwnerManager(apDataOwnerManager)
+	/** Standard C++ constructor
+
+	@param aSID secure id of data owner
+	@param apDataOwnerManager data owner manager to access resources
+	*/
+		{
+		}
+		
+	void CDataOwner::ConstructL()
+	/** Symbian 2nd stage constructor */
+		{
+		iRegistrationFiles = new (ELeave) CDesCArrayFlat(KDesCArrayGranularity);
+		iPrivatePath = HBufC::NewL(0);
+		iProxyInformationArray.Reset();
+		iPublicDirStack.Reset();
+		iPublicDirNameStack.Reset();
+		iPublicExcludes.Reset();
+		}
+
+	CDataOwner::~CDataOwner()
+	/** Standard C++ destructor
+	*/
+		{
+		// Close the RArrays
+		iProxyInformationArray.Close();
+		iStateByDrive.Close();
+		iProxyStateByDrive.Close();
+		iDBMSSelections.Close();
+		
+		iPublicSelections.ResetAndDestroy();
+		iPassiveSelections.ResetAndDestroy();
+		iSnapshots.ResetAndDestroy();
+		
+		for (TInt x = iPublicDirStack.Count(); x > 0; --x)
+			{
+			iPublicDirStack[x-1].Close();
+			delete iPublicDirNameStack[x-1];
+			}
+		iPublicDirStack.Close();
+		iPublicDirNameStack.Close();
+		iPublicExcludes.Close();
+		
+		delete iPrivatePath;
+		delete iBufferFileWriter;
+		delete iBufferFileReader;
+		delete iBufferSnapshotWriter;
+		delete iBufferSnapshotReader;
+		delete iTempSnapshotHolder;
+		delete iRegistrationFiles;
+		}
+
+	void CDataOwner::AddRegistrationFilesL(const TDesC& aFileName)
+	/** Adds a registration file
+
+	Adds a registration file to the list of registration files for this data owner
+
+	@param aFileName the filename of the 
+	*/
+		{
+		iRegistrationFiles->AppendL(aFileName);
+		}
+		
+	void CDataOwner::StartProcessIfNecessaryL()
+	/**
+	Start the active process
+	*/
+		{
+		// Do we need to check that the process is started?
+		if (iActiveInformation.iSupported && iActiveInformation.iActiveDataOwner)
+			{
+			// Get the list of currently running processes
+			TBool processFound = EFalse;
+			TFullName processName;
+			TFindProcess findProcess;
+			while (!processFound && (findProcess.Next(processName) == KErrNone))
+				{
+				RProcess process;
+				CleanupClosePushL(process);
+				if (process.Open(processName) == KErrNone) // Should we leave on any errors?
+					{
+					if (process.SecureId() == iSecureId)
+						{
+						// Process already exists - see if it's previuosly connected and has a current session
+						__LOG1("Process %S already exists - not starting", &processName);
+						TRAPD(err, iStatus = ipDataOwnerManager->ABServer().SessionReadyStateL(iSecureId));
+						if (err == KErrNone)
+							{
+							__LOG2("Existing session for process %S has status %d", &processName, iStatus);
+							} // if
+						else
+							{
+							__LOG1("Existing process %S hasn't yet connected to a session", &processName);
+							iStatus = EDataOwnerNotConnected;//ReadyState only check session state when this status not equal to 'EDataOwnerReadyNoImpl' and 'EDataOwnerReady' 
+							} // else
+						
+						processFound = ETrue;
+						} // if
+					} // if
+					
+					CleanupStack::PopAndDestroy(&process);
+				} // while
+				
+			// If the process is not started then we need to start it
+			if (!processFound)
+				{
+				// Create the process
+				TUidType uidType(KNullUid, KNullUid, iSecureId);
+				RProcess process;
+				CleanupClosePushL(process);
+				TInt createErr = process.Create(iActiveInformation.iProcessName, KNullDesC, uidType);
+				if (createErr != KErrNone)
+					{
+					__LOG2("Process %S failed to start(%d)", &iActiveInformation.iProcessName, createErr);
+					iStatus = EDataOwnerFailed;
+					} // if
+				else
+					{
+					__LOG1("Process %S started.", &iActiveInformation.iProcessName);
+					process.Resume();
+					} // else
+					
+				CleanupStack::PopAndDestroy(&process);
+				} // if
+			} // if
+		}
+		
+
+	void CDataOwner::ParseFilesL()
+	/** Parse the registration files
+
+	@leave KErrGeneral data owner has no primary registration file
+	*/
+		{
+		if (!iFilesParsed)
+			{
+			TUint count = iRegistrationFiles->Count();
+			TBool foundPrimaryFile = EFalse;
+			while(count--)
+				{
+				const TDesC& fileName = (*iRegistrationFiles)[count];
+
+			  // Determine if this is the primary file
+				iPrimaryFile = (fileName.FindF(KPrimaryBackupRegistrationFile) != KErrNotFound);
+				if (iPrimaryFile)
+					{
+					foundPrimaryFile = ETrue;
+					}
+
+				// Parse file
+
+				__LOG2("CDataOwner::ParseFilesL() - [0x%08x] - parsing reg file: %S...", iSecureId.iId, &fileName);
+				TRAPD(err, ParseFileL(fileName));
+				if	(err == KErrNone)
+					{
+					__LOG1("CDataOwner::ParseFilesL() - [0x%08x] - ...file parsed okay", iSecureId.iId);
+					}
+				else
+					{
+					__LOG2("CDataOwner::ParseFilesL() - [0x%08x] - ...*** PARSING FAILED *** - error: %d", iSecureId.iId, err);
+					User::Leave(err);
+					}
+				
+				// Add the registration file to the exclude list
+				CSelection* selection = CSelection::NewLC(EExclude, fileName);
+				iPassiveSelections.AppendL(selection);
+				CleanupStack::Pop(selection);
+				}
+
+			// Check that a primary file was found, as there must be one	
+			if (!foundPrimaryFile)
+				{
+				User::Leave(KErrGeneral);
+				} // if
+			
+			iFilesParsed = ETrue;
+			} // if
+		
+		if (!iActiveInformation.iSupported && (iPassiveInformation.iSupported || iSystemInformation.iSupported))
+			{
+			iStatus = EDataOwnerReady;
+			}
+ 		}
+		
+	void CDataOwner::GetExpectedDataSizeL(TTransferDataType aTransferType,
+										  TDriveNumber aDriveNumber, TUint& aSize)
+	/** Gets the expected data size of the backkup.
+	
+	@param aTransferType the type of the transfer
+	@param aDriveNumber the drive to check for files
+	@param aSize on return the total size in bytes of the backup
+	@leave KErrNotReady the snapshot has not been set
+	*/
+		{
+		aSize = 0;
+		switch (aTransferType)
+			{
+		case EPassiveSnapshotData:
+			{
+			__LOG1("CDataOwner::GetExpectedDataSizeL() - START - EPassiveSnapshotData - aDriveNumber: %c", aDriveNumber + 'A');
+
+            CDesCArray* files = new(ELeave) CDesC16ArrayFlat(KDesCArrayGranularity);
+            CleanupStack::PushL(files);
+		
+			BuildFileListL(iPassiveSelections, aDriveNumber, aTransferType, EFalse, NULL, NULL, files);
+			
+			// DBMS file?
+			AddDBMSFilesL(aDriveNumber, files, NULL);
+			
+			TUint count = files->Count();
+			aSize = count * sizeof(TSnapshot);
+            __LOG2("CDataOwner::GetExpectedDataSizeL() - passive snapshot count: %d, expected size: %d", count, aSize);
+			
+			CleanupStack::PopAndDestroy(files);
+			break;
+			}
+		case EPassiveBaseData:
+		case EPassiveIncrementalData:
+			{
+			__LOG1("CDataOwner::GetExpectedDataSizeL() - START - EPassiveBaseData/EPassiveIncrementalData - aDriveNumber: %c", aDriveNumber + 'A');
+
+            RFileArray files;
+			CleanupClosePushL(files);
+			
+			// Find all the files
+			if (aTransferType == EPassiveBaseData)
+				{
+	            __LOG("CDataOwner::GetExpectedDataSizeL() - EPassiveBaseData");
+				BuildFileListL(iPassiveSelections, aDriveNumber, aTransferType, EFalse, NULL, &files, NULL);
+				
+				// Do we need to add the DBMS file?
+				AddDBMSFilesL(aDriveNumber, NULL, &files);
+				} // if
+			else
+				{
+	            __LOG("CDataOwner::GetExpectedDataSizeL() - EPassiveIncrementalData");
+
+				// Do we have a snapshot?
+				const TUint count = iSnapshots.Count();
+				RSnapshots* pSnapshot = NULL;
+				for (TInt x = 0; !pSnapshot && (x < count); x++)
+					{
+					if (iSnapshots[x]->iDriveNumber == aDriveNumber)
+						{
+						pSnapshot = &(iSnapshots[x]->iSnapshots);
+						} // if
+					} // for x
+					
+				BuildFileListL(iPassiveSelections, aDriveNumber, aTransferType, EFalse, pSnapshot, &files, NULL);
+				
+				// Do we need to add the DBMS file?
+				AddDBMSFilesL(aDriveNumber, NULL, &files);
+				} // else
+			
+			// Calculate the expected data size
+			const TUint count = files.Count();
+	        __LOG1("CDataOwner::GetExpectedDataSizeL() - passive file count: %d", count);
+			aSize = (count * sizeof(TFileFixedHeader));
+			for (TInt x = 0; x < count; x++)
+				{
+                const TEntry& fileEntry = files[x];
+                const TInt fileSize = fileEntry.iSize;
+                __LOG2("CDataOwner::GetExpectedDataSizeL() - passive file: %S, size: %d", &fileEntry.iName, fileSize);
+
+				aSize += fileEntry.iName.Length();
+				aSize += fileSize;
+				}
+			CleanupStack::PopAndDestroy(&files);
+			break;
+			}
+		case EActiveBaseData:
+		case EActiveIncrementalData:
+			{
+			__LOG1("CDataOwner::GetExpectedDataSizeL() - START - EActiveBaseData/EActiveIncrementalData - aDriveNumber: %c", aDriveNumber + 'A');
+			// Only request expected data size if it's for this data owner, not the proxies
+			if (iActiveInformation.iSupported && iActiveInformation.iActiveDataOwner && (iActiveInformation.iActiveType != EProxyImpOnly))
+				{
+				ipDataOwnerManager->ABServer().GetExpectedDataSizeL(iSecureId, aDriveNumber, aSize);
+				}
+			else
+				{
+				aSize = 0;
+                __LOG1("CDataOwner::GetExpectedDataSizeL() - ACTIVE BASE - DO 0x%08x is PROXY, so setting size to 0!", iSecureId.iId);
+				}
+				
+			} break;
+		case EActiveSnapshotData:
+			{
+			__LOG1("CDataOwner::GetExpectedDataSizeL() - START - EActiveSnapshotData - aDriveNumber: %c", aDriveNumber + 'A');
+			aSize = 0;		// ABClient M class doesn't provide retrieval of snapshot data size
+			} break;
+		default:
+			__LOG1("CDataOwner::GetExpectedDataSizeL() - START - ERROR - UNSUPPORTED TYPE! => KErrNotSupported - aDriveNumber: %c", aDriveNumber + 'A');
+			User::Leave(KErrNotSupported);
+			} // switch
+
+		__LOG2("CDataOwner::GetExpectedDataSizeL() - END - size is: %d, data owner 0x%08x", aSize, iSecureId.iId);
+		}
+
+
+	void CDataOwner::GetPublicFileListL(TDriveNumber aDriveNumber, RFileArray& aFiles)
+	/** Gets the public file list
+
+	Gets the public file list for the given drive
+	@param aDriveNumber the drive to retrieve the public files for
+	@param aFiles on return a list of public files
+	*/
+		{
+		BuildFileListL(iPublicSelections, aDriveNumber, EPassiveBaseData, ETrue, NULL, &aFiles, NULL);
+		}
+		
+	
+	void CDataOwner::GetRawPublicFileListL(TDriveNumber aDriveNumber, 
+										   RRestoreFileFilterArray& aRestoreFileFilter)
+	/** Gets the raw public file list 
+	
+	@param aDriveNumber the drive to return the list for
+	@param aRestoreFileFilter on return the file filter
+	*/
+		{
+		// Convert drive number to letter
+		TChar drive;
+		User::LeaveIfError(ipDataOwnerManager->GetRFs().DriveToChar(aDriveNumber, drive));
+		
+		const TUint count = iPublicSelections.Count();
+		for (TInt x = 0; x < count; x++)
+			{
+			TBool include = (iPublicSelections[x]->SelectionType() == EInclude);
+			TFileName filename;
+			
+			const TDesC& selectionName = iPublicSelections[x]->SelectionName();
+			// Name
+			TBool add = false;
+			if ((selectionName.Length() > 1) && (selectionName[1] == KColon()[0]))
+				{
+				// It has a drive specified
+				TInt drive;
+				ipDataOwnerManager->GetRFs().CharToDrive(selectionName[0], drive);
+				if (static_cast<TDriveNumber>(drive) == aDriveNumber)
+					{
+					add = true;
+					filename.Append(selectionName);
+					} // if
+				} // if
+			else if (selectionName[0] == KBackSlash()[0])
+				{
+					add = true;
+					filename.Append(drive);
+					filename.Append(KColon);
+					filename.Append(selectionName);
+				} // if
+			else
+				{
+					filename.Append(drive);
+					filename.Append(KColon);
+					filename.Append(KBackSlash);
+					filename.Append(selectionName);
+				} // else
+			
+				if (add)
+					{
+					aRestoreFileFilter.AppendL(TRestoreFileFilter(include, filename));
+					} // if
+			} // for x
+		}
+		
+	void CDataOwner::ProcessSupplyDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, 
+								 TDesC8& aBuffer, TBool aLastSection)
+	/** Supply data to the data owner
+	
+	@param aDriveNumber the drive requesting data for
+	@param aTransferType the type of transfer
+	@param aBuffer the buffer containing the data
+	@param aLastSection have we received all our information
+	@leave KErrNotReady In the process of another call
+	@leave KErrNotSupported Unsupported transfer type
+	@leave KErrCorrupt If commands have been issued that violate the allowed sequence
+	*/
+		{
+		TBURPartType burType = ipDataOwnerManager->BURType();
+        __LOG2("CDataOwner::ProcessSupplyDataL() - START - drive: %c, aTransferType: %d", aDriveNumber + 'A', aTransferType);
+		
+
+		switch (aTransferType)
+			{
+			case EPassiveSnapshotData:
+				{
+				__LOG1("CDataOwner::ProcessSupplyDataL() - Supplying passive snapshot data to data owner with SID 0x%08x", iSecureId.iId);
+				// Check that no passive data has been received for a data owner that doesn't support it
+				if (!iPassiveInformation.iSupported)
+					{
+					__LOG("CDataOwner::ProcessSupplyDataL() - State Error - Passive restore has been requested but isn't supported");
+					User::Leave(KErrCorrupt);
+					}
+				
+				// Check that no snapshot is supplied after backup data has been requested during a backup
+				if (((burType == EBURBackupFull) || (burType == EBURBackupPartial)) && 
+					(StateByDriveL(aDriveNumber).iPassiveBaseDataRequested || 
+					 StateByDriveL(aDriveNumber).iPassiveIncDataRequested))
+					{
+					__LOG("CDataOwner::ProcessSupplyDataL() - State Error - Snapshot has been supplied after data has been requested");
+					User::Leave(KErrCorrupt);
+					}
+					
+				// Check that no snapshot is supplied for a data owner expecting base backup
+				if (iPassiveInformation.iBaseBackupOnly)
+					{
+					__LOG("CDataOwner::ProcessSupplyDataL() - State Error - Snapshot data has been supplied for a base data owner");
+					User::Leave(KErrCorrupt);
+					}
+					
+				// Check that no snapshot data is provided after backup data has been supplied during a restore
+				if (((burType == EBURRestorePartial) || (burType == EBURRestoreFull)) 
+					&& (StateByDriveL(aDriveNumber).iPassiveBaseDataReceived || 
+					    StateByDriveL(aDriveNumber).iPassiveIncDataReceived))
+					{
+					__LOG("CDataOwner::ProcessSupplyDataL() - State Error - Snapshot has been supplied after restore data has been supplied");
+					User::Leave(KErrCorrupt);
+					}
+  				
+				SupplyPassiveSnapshotDataL(aDriveNumber, aBuffer, aLastSection);
+				
+				if (aLastSection)
+					{
+					StateByDriveL(aDriveNumber).iPassiveSnapshotReceived = ETrue;
+					}
+				break;
+				}
+			case EPassiveBaseData:
+			case EPassiveIncrementalData:
+				{
+				if (aTransferType == EPassiveBaseData)
+					{
+					__LOG1("CDataOwner::ProcessSupplyDataL() - Supplying passive base data to data owner with SID 0x%08x", iSecureId.iId);
+					}
+				else if (aTransferType == EPassiveIncrementalData)
+					{
+					__LOG1("CDataOwner::ProcessSupplyDataL() - Supplying passive inc data to data owner with SID 0x%08x", iSecureId.iId);
+					}
+				
+				// Check that no passive data has been received for a data owner that doesn't support it
+				if (!iPassiveInformation.iSupported)
+					{
+					__LOG("CDataOwner::ProcessSupplyDataL() - State Error - Passive restore data has been supplied but isn't supported");
+					User::Leave(KErrCorrupt);
+					}
+
+				// Check that no incremental data has been received for a SID that doesn't support it
+				if (iPassiveInformation.iBaseBackupOnly && (aTransferType == EPassiveIncrementalData))
+					{
+					__LOG("CDataOwner::ProcessSupplyDataL() - State Error - Incremental restore data has been received for a base only data owner");
+					User::Leave(KErrCorrupt);
+					}
+					
+				// Passive Base data should only have been provided once for a SID
+				if ((aTransferType == EPassiveBaseData) && StateByDriveL(aDriveNumber).iPassiveBaseDataReceived)
+					{
+					__LOG("CDataOwner::ProcessSupplyDataL() - State Error - Data is being restored more than once to a DO");
+					User::Leave(KErrCorrupt);
+					}
+				
+				// A snapshot should already have been supplied if we're incremental
+				if (!StateByDriveL(aDriveNumber).iPassiveSnapshotReceived && (aTransferType == EPassiveIncrementalData))
+					{
+					__LOG("CDataOwner::ProcessSupplyDataL() - State Error - Snapshot has not yet been supplied and should have whether we're base or inc");
+					User::Leave(KErrCorrupt);
+					}
+				
+				// If incremental data is being supplied, then base data must already have been supplied
+				if ((aTransferType == EPassiveIncrementalData) && !StateByDriveL(aDriveNumber).iPassiveBaseDataReceived)
+					{
+					__LOG("CDataOwner::ProcessSupplyDataL() - State Error - Incremental data supplied before base data");
+					User::Leave(KErrCorrupt);
+					}
+				
+				SupplyPassiveBaseDataL(aDriveNumber, aBuffer, aLastSection);
+				
+				if ((aTransferType == EPassiveBaseData) && aLastSection)
+					{
+					StateByDriveL(aDriveNumber).iPassiveBaseDataReceived = ETrue;
+					}
+				
+				if ((aTransferType == EPassiveIncrementalData) && aLastSection)
+					{
+					StateByDriveL(aDriveNumber).iPassiveIncDataReceived = ETrue;
+					}
+				break;
+				}
+			case EActiveSnapshotData:
+				{
+				__LOG1("CDataOwner::ProcessSupplyDataL() - Supplying active snapshot data to data owner with SID 0x%08x", iSecureId.iId);
+				
+				// Check that no active data has been received for a data owner that doesn't support it
+				if (!iActiveInformation.iSupported)
+					{
+					__LOG("CDataOwner::ProcessSupplyDataL() - State Error - Active snapshot data has been supplied for a DO that doesn't support it");
+					User::Leave(KErrCorrupt);
+					}
+
+				// Check that no active data has been received for a data owner that doesn't support it
+				if (!iActiveInformation.iSupportsIncremental)
+					{
+					__LOG("CDataOwner::ProcessSupplyDataL() - State Error - Active snapshot data has been supplied for a base only Data Owner");
+					User::Leave(KErrCorrupt);
+					}
+				
+				// Check that no snapshot is supplied after backup data has been requested during a backup
+				if (((burType == EBURBackupFull) || (burType == EBURBackupPartial)) && StateByDriveL(aDriveNumber).iActiveBaseDataRequested)
+					{
+					__LOG("CDataOwner::ProcessSupplyDataL() - State Error - Active snapshot has been supplied after backup data has been requested");
+					User::Leave(KErrCorrupt);
+					}
+					
+				// Check that no snapshot data is provided after backup data has been supplied during a restore
+				if (((burType == EBURRestorePartial) || (burType == EBURRestoreFull)) && StateByDriveL(aDriveNumber).iActiveBaseDataReceived)
+					{
+					__LOG("CDataOwner::ProcessSupplyDataL() - State Error - Active snapshot data has been supplied after restore data");
+					User::Leave(KErrCorrupt);
+					}
+
+				ipDataOwnerManager->ABServer().SupplyDataL(iSecureId, aDriveNumber, aTransferType, 
+					aBuffer, aLastSection);
+				
+				if (aLastSection)
+					{
+					StateByDriveL(aDriveNumber).iActiveSnapshotReceived = ETrue;
+					}
+				} break;
+			case EActiveBaseData:
+			case EActiveIncrementalData:
+				{
+				if (aTransferType == EActiveBaseData)
+					{
+					__LOG1("CDataOwner::ProcessSupplyDataL() - Supplying active base data to data owner with SID 0x%08x", iSecureId.iId);					
+					}
+				else if (aTransferType == EActiveIncrementalData)
+					{
+					__LOG1("CDataOwner::ProcessSupplyDataL() - Supplying active incremental data to data owner with SID 0x%08x", iSecureId.iId);
+					}
+				
+				const TUint supportedProxyCount = iProxyInformationArray.Count();
+				TInt offset = 0;
+				
+				// Only unpack from the first supply message
+				if (StateByDriveL(aDriveNumber).iFirstActiveTransaction)
+					{
+					iCurrentProxy = 0;
+					TInt proxyCountCheck = 0;
+					UnpackTypeAdvance(proxyCountCheck, aBuffer, offset);
+					StateByDriveL(aDriveNumber).iFirstActiveTransaction = EFalse;
+					__LOG1("CDataOwner::ProcessSupplyDataL() - Proxy Info : Unpacked TotalProxyCount = %d", proxyCountCheck);
+
+					// If the backup stream specifies a different number of proxy's to the registration file,
+					// then we're looking at different reg file versions. This isn't supported as far as proxy's
+					// are concerned
+					if (supportedProxyCount != proxyCountCheck)
+						{
+						__LOG("CDataOwner::ProcessSupplyDataL() - State Error - Number of proxies supported (reg file) differs from backed up data");
+						User::Leave(KErrCorrupt);
+						}
+
+					// Check that no active data has been requested for a data owner that doesn't support it
+					if ((!iActiveInformation.iSupported) && (supportedProxyCount == 0))
+						{
+						// No proxies or active data 
+						__LOG("CDataOwner::ProcessSupplyDataL() - State Error - Active data has been received but this DO doesn't support Active/Proxies");
+						User::Leave(KErrCorrupt);
+						}
+						
+					// Reset proxy state information for this drive
+					for (TInt numProxy=0; numProxy < supportedProxyCount; numProxy++)
+						{
+						ProxyStateByDriveL(aDriveNumber,numProxy) = TProxyStateByDrive(aDriveNumber,numProxy);
+						}
+					
+					for (TInt numProxies=0;numProxies<iProxyInformationArray.Count();numProxies++)
+						{
+						iProxyInformationArray[numProxies].iDataRequested = 0;
+						iProxyInformationArray[numProxies].iDataSupplied = 0;
+						iProxyInformationArray[numProxies].iOpInProgress = ETrue;												
+						}
+					}
+
+				__LOG1("CDataOwner::ProcessSupplyDataL() - Supplying active base data of size = %D", aBuffer.Length());
+				
+				// Restore the proxy data first
+				TBool currentBufferConsumed = EFalse;  
+				while ( (iCurrentProxy < supportedProxyCount) && (!currentBufferConsumed))
+					{
+					__LOG2("CDataOwner::ProcessSupplyDataL() - Proxy Info : Unpacking proxy info %d of %d", iCurrentProxy + 1, supportedProxyCount);
+					
+					// Unpack the proxy's finished flag, len and sid if we are handling the proxy for the first time
+					if ( iProxyInformationArray[iCurrentProxy].iDataSupplied == 0)
+						{						
+						UnpackTypeAdvance(iProxyInformationArray[iCurrentProxy].iOpInProgress, aBuffer, offset);						
+						__LOG1("CDataOwner::ProcessSupplyDataL() - Proxy Info : FinishedFlag = %d", iProxyInformationArray[iCurrentProxy].iOpInProgress);												
+						UnpackTypeAdvance(iProxyInformationArray[iCurrentProxy].iDataRequested, aBuffer, offset);						
+						__LOG1("CDataOwner::ProcessSupplyDataL() - Proxy Info : ProxyDataStreamLength = %d", iProxyInformationArray[iCurrentProxy].iDataRequested);
+						TSecureId 	proxySecureId;
+						UnpackTypeAdvance(proxySecureId, aBuffer, offset);
+						
+						if ( iProxyInformationArray[iCurrentProxy].iSecureId.iId != proxySecureId.iId )
+							{
+							User::Leave(KErrCorrupt);
+							}
+							
+						__LOG1("CDataOwner::ProcessSupplyDataL() - Proxy Info : ProxySID = 0x%08x", proxySecureId.iId);
+						}
+		
+					// Is no more data coming , either from the buffer manager or from the server
+					TBool proxyFinished = iProxyInformationArray[iCurrentProxy].iOpInProgress && aLastSection;
+
+					TInt dataLengthRemaining = iProxyInformationArray[iCurrentProxy].iDataRequested - iProxyInformationArray[iCurrentProxy].iDataSupplied;
+					
+					TInt currentBufferLen = 0;
+					
+					// The data remaining for this proxy is more than data in this buffer
+					if (dataLengthRemaining >= aBuffer.Length()-offset )
+						{
+						
+						// more data was expected but both server and data mgr have finished, then leave
+						if  (proxyFinished && dataLengthRemaining > aBuffer.Length()-offset)
+							{
+							User::Leave(KErrCorrupt);
+							}
+							
+						// use the buffer upto the end
+						currentBufferLen = aBuffer.Length() - offset;
+						currentBufferConsumed = ETrue;
+						}
+					else
+						{
+						// use the buffer upto the remaining length of this proxy
+						currentBufferLen = dataLengthRemaining;
+						}
+					
+					// Create a pointer to the data of this proxy 
+					TPtrC8 buffer(aBuffer.Mid(offset, currentBufferLen));					
+					iProxyInformationArray[iCurrentProxy].iDataSupplied +=  currentBufferLen;
+					__LOG1("CDataOwner::ProcessSupplyDataL() - iProxyConsumedLength = %D",iProxyInformationArray[iCurrentProxy].iDataSupplied);
+					
+					offset += currentBufferLen;	
+
+					TBool proxyLastSection = EFalse;
+					
+					// If the data to send is the last section, set proxyLastSection with true.
+					if ((iProxyInformationArray[iCurrentProxy].iOpInProgress == (TInt)ETrue) && (iProxyInformationArray[iCurrentProxy].iDataSupplied == iProxyInformationArray[iCurrentProxy].iDataRequested))
+						{
+						__LOG("CDataOwner::ProcessSupplyDataL() - Last Section to Proxy");
+						proxyLastSection = ETrue;
+						}
+					else
+						{
+						proxyLastSection = proxyFinished;
+						}
+
+					
+					// Call the proxy and give it the restore data. 
+					ipDataOwnerManager->ABServer().SupplyDataL(
+									iProxyInformationArray[iCurrentProxy].iSecureId,
+									aDriveNumber, 
+									aTransferType, 
+									buffer, 
+									proxyLastSection,
+									ProxyStateByDriveL(aDriveNumber,iCurrentProxy).iOpInProgress,
+									iSecureId);
+					
+					
+					// If the proxy still has data to send, record the fact to that the 
+					// data server or datamanager can supply again.
+					if (!proxyFinished)
+						{
+						__LOG("CDataOwner::ProcessSupplyDataL() - Proxy Info : Multipart send not complete, expecting more proxy data");
+						ProxyStateByDriveL(aDriveNumber,iCurrentProxy).iOpInProgress = ETrue;							
+						}
+					else
+						{
+						__LOG("CDataOwner::ProcessSupplyDataL() - Proxy Info : Send complete");
+						ProxyStateByDriveL(aDriveNumber,iCurrentProxy).iOpInProgress = EFalse;
+						ProxyStateByDriveL(aDriveNumber,iCurrentProxy).iDataSupplied = ETrue;
+	
+						}				
+					
+					__LOG2("CDataOwner::ProcessSupplyDataL() - Check proxyConsumedLength = %D & proxyTotalDataLength = %D",iProxyInformationArray[iCurrentProxy].iDataSupplied,iProxyInformationArray[iCurrentProxy].iDataRequested);
+					if (iProxyInformationArray[iCurrentProxy].iDataSupplied == iProxyInformationArray[iCurrentProxy].iDataRequested)
+						{
+						__LOG("CDataOwner::ProcessSupplyDataL() - Resetting internal variables");
+						// when whole packet from server is read.						
+						iProxyInformationArray[iCurrentProxy].iDataSupplied = 0;
+						iProxyInformationArray[iCurrentProxy].iDataRequested = 0;
+						}
+					
+					// Check 
+					if ( (iProxyInformationArray[iCurrentProxy].iOpInProgress == (TInt)ETrue) && (iProxyInformationArray[iCurrentProxy].iDataSupplied == iProxyInformationArray[iCurrentProxy].iDataRequested) )
+						{
+						__LOG("CDataOwner::ProcessSupplyDataL() - Proxy Finished");
+						iCurrentProxy++;
+						}
+						
+					} // while more proxies.
+
+				// Active data can be sent under 2 circumstances, data for a proxy and data for an actual active client				
+				if (iActiveInformation.iSupported && iActiveInformation.iActiveDataOwner && (offset < aBuffer.Size()))
+					{
+					__LOG("CDataOwner::ProcessSupplyDataL() - State iActiveInformation.iSupported");					
+					// Active Base data should only have been provided once for a SID
+					if ((aTransferType == EActiveBaseData) && StateByDriveL(aDriveNumber).iActiveBaseDataReceived)
+						{
+						__LOG("CDataOwner::ProcessSupplyDataL() - State Error - Active restore data has been provided more than once for this DO");
+						User::Leave(KErrCorrupt);
+						}
+					
+					TPtrC8 buffer(aBuffer.Mid(offset));
+
+					ipDataOwnerManager->ABServer().SupplyDataL(
+								iSecureId,
+								aDriveNumber,
+								aTransferType,
+								buffer,
+								aLastSection,
+								StateByDriveL(aDriveNumber).iOpInProgress);
+					
+					if (!aLastSection)
+						{
+						StateByDriveL(aDriveNumber).iOpInProgress = ETrue;
+						}
+					else 
+						{
+						StateByDriveL(aDriveNumber).iOpInProgress = EFalse;
+						StateByDriveL(aDriveNumber).iFirstActiveTransaction = ETrue;
+						if (aTransferType == EActiveBaseData)
+							{
+							StateByDriveL(aDriveNumber).iActiveBaseDataReceived = ETrue;
+							}
+						
+						if (aTransferType == EActiveIncrementalData)
+							{
+							StateByDriveL(aDriveNumber).iActiveIncDataReceived = ETrue;
+							}
+						}
+					}
+				} break;
+			default:
+				{
+				__LOG("CDataOwner::ProcessSupplyDataL() - State Error - An unsupported transfer type has been supplied");
+				User::Leave(KErrNotSupported);
+				}
+			} // switch
+		}
+		
+	void CDataOwner::SupplyDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, 
+								 TDesC8& aBuffer, TBool aLastSection)
+	/** Supply data to the data owner
+	
+	@param aDriveNumber the drive requesting data for
+	@param aTransferType the type of transfer
+	@param aBuffer the buffer containing the data
+	@param aLastSection have we received all our information
+	@leave KErrNotReady In the process of another call
+	@leave KErrNotSupported Unsupported transfer type
+	@leave KErrCorrupt If commands have been issued that violate the allowed sequence
+	*/
+		{
+		__LOG5("CDataOwner::SupplyDataL() - START - SID: 0x%08x, aDrive: %c, aTransferType: %d, aLastSection: %d, iState: %d", iSecureId.iId, aDriveNumber + 'A', aTransferType, aLastSection, iState.iState);
+		// Check our state
+		if (!((iState.iState == ENone) ||
+		     ((iState.iState == ESupply) && (iState.iDriveNumber == aDriveNumber) && 
+		      (iState.iTransferType == aTransferType))))
+			{
+			User::Leave(KErrNotReady);			
+			}
+			
+		// Set the state?
+		if (iState.iState == ENone)
+			{
+			iState.iState = ESupply;
+			iState.iDriveNumber = aDriveNumber;
+			iState.iTransferType = aTransferType;
+			} // if
+			
+		// What are we doing then?
+		// We must trap any errors and rethrow them so we can reset our state
+		TInt err = KErrNone;
+		
+		// Do we need to perform a cleanup before restore?
+		if ((aTransferType == EPassiveBaseData) ||
+		    (aTransferType == EPassiveIncrementalData) ||
+		    (aTransferType == EActiveBaseData) ||
+		    (aTransferType == EActiveIncrementalData))
+			{
+			TRAP(err, CleanupBeforeRestoreL(aDriveNumber));
+			}
+		if (err != KErrNone)
+			{
+			__LOG2("CDataOwner::SupplyDataL() - Data owner 0x%08x, drive %d could not cleanup before restore", iSecureId.iId, aDriveNumber);
+			}
+
+		TRAP(err, ProcessSupplyDataL(aDriveNumber, aTransferType, aBuffer, aLastSection));
+
+		
+		// Was there an error?
+		if (err != KErrNone)
+			{
+			iState.iState = ENone;
+			delete iBufferFileReader;
+			iBufferFileReader = NULL;
+			delete iBufferSnapshotReader;
+			iBufferSnapshotReader = NULL;
+			User::Leave(err);
+			} // if
+			     
+		if (aLastSection) // If last section reset state
+			{
+			iState.iState = ENone;
+			} // if
+		__LOG("CDataOwner::SupplyDataL() - END");
+		} // SupplyDataL
+		
+		
+	void CDataOwner::ProcessRequestDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, 
+    		TPtr8& aBuffer, TBool& aLastSection)
+    /**
+    So that the TRAPD isn't massive, this switch statement has been moved to this function
+    */
+		{
+        __LOG4("CDataOwner::ProcessRequestDataL() - START - aDrive: %c, aTransferType: %d, aBuffer.Ptr(): 0x%08x, aBuffer.Length(): %d", aDriveNumber + 'A', aTransferType, aBuffer.Ptr(), aBuffer.Length());
+        //__LOGDATA("CDataOwner::ProcessRequestDataL() - %S", aBuffer.Ptr(), aBuffer.Length() );
+
+        //
+		switch (aTransferType)
+			{
+			case EPassiveSnapshotData:
+				{
+				__LOG1("CDataOwner::ProcessRequestDataL() - Requesting passive snapshot data from data owner with SID 0x%08x", iSecureId.iId);
+
+				// Check that no passive data has been requested for a data owner that doesn't support it
+				if (!iPassiveInformation.iSupported)
+					{
+					__LOG("CDataOwner::ProcessRequestDataL() - State Error - Passive snapshot data has been requested for a non-passive data owner");
+					User::Leave(KErrCorrupt);
+					}
+					
+				// Check that snapshot data is only requested once
+				if (StateByDriveL(aDriveNumber).iPassiveSnapshotRequested)
+					{
+					__LOG("CDataOwner::ProcessRequestDataL() - State Error - Passive snapshot data has been requested more than once");
+					User::Leave(KErrCorrupt);
+					}
+
+				RequestPassiveSnapshotDataL(aDriveNumber, aBuffer, aLastSection);
+				
+				if (aLastSection)
+					{
+					StateByDriveL(aDriveNumber).iPassiveSnapshotRequested = ETrue;
+					}
+				break;
+				}
+			case EPassiveBaseData:
+			case EPassiveIncrementalData:
+				{
+				if (aTransferType == EPassiveBaseData)
+					{
+					__LOG1("CDataOwner::ProcessRequestDataL() - Requesting passive base data from data owner with SID 0x%08x", iSecureId.iId);
+					}
+				else if (aTransferType == EPassiveIncrementalData)
+					{
+					__LOG1("CDataOwner::ProcessRequestDataL() - Requesting passive inc data from data owner with SID 0x%08x", iSecureId.iId);
+					}
+
+				// Check that no passive data has been requested for a data owner that doesn't support it
+				if (!iPassiveInformation.iSupported)
+					{
+					__LOG("CDataOwner::ProcessRequestDataL() - State Error - Passive backup data has been requested for a non-passive data owner");
+					User::Leave(KErrCorrupt);
+					}
+
+				// Check that if this is an incremental backup, complete snapshot data has been received
+				if ((aTransferType == EPassiveIncrementalData) && !StateByDriveL(aDriveNumber).iPassiveSnapshotReceived)
+					{
+					__LOG("CDataOwner::ProcessRequestDataL() - State Error - Incremental data has been requested without a snapshot being supplied");
+					User::Leave(KErrCorrupt);
+					}
+				
+				// Check that Passive data has only been requested once for a Data Owner
+				if (((aTransferType == EPassiveBaseData) && StateByDriveL(aDriveNumber).iPassiveBaseDataRequested) ||
+					((aTransferType == EPassiveIncrementalData) && StateByDriveL(aDriveNumber).iPassiveIncDataRequested))
+					{
+					__LOG("CDataOwner::ProcessRequestDataL() - State Error - Passive data has been requested more than once for this data owner");
+					User::Leave(KErrCorrupt);
+					}
+				
+				// Check that for base backup, no snapshot data has been supplied
+				if ((aTransferType == EPassiveBaseData) && StateByDriveL(aDriveNumber).iPassiveSnapshotReceived)
+					{
+					__LOG("CDataOwner::ProcessRequestDataL() - State Error - Snapshot data has been received for a base only data owner");
+					User::Leave(KErrCorrupt);
+					}
+				
+				// Check that only Base OR Incremental data is requested - not both
+				if (((aTransferType == EPassiveBaseData) && StateByDriveL(aDriveNumber).iPassiveIncDataRequested) || 
+					((aTransferType == EPassiveIncrementalData) && StateByDriveL(aDriveNumber).iPassiveBaseDataRequested))
+					{
+					__LOG("CDataOwner::ProcessRequestDataL() - State Error - Base and Incremental data have been requested in the same session");
+					User::Leave(KErrCorrupt);
+					}
+				
+				RequestPassiveDataL(aTransferType, aDriveNumber, aBuffer, aLastSection);
+				
+				if ((aTransferType == EPassiveBaseData) && aLastSection)
+					{
+					StateByDriveL(aDriveNumber).iPassiveBaseDataRequested = ETrue;
+					}
+				
+				if ((aTransferType == EPassiveIncrementalData) && aLastSection)
+					{
+					StateByDriveL(aDriveNumber).iPassiveIncDataRequested = ETrue;
+					}
+				break;
+				}
+			case EActiveSnapshotData:
+				{
+				__LOG1("CDataOwner::ProcessRequestDataL() - Requesting active snapshot data from data owner with SID 0x%08x", iSecureId.iId);
+
+				// Check that active data hasn't been requested for a data owner that doesn't support it
+				if (!iActiveInformation.iSupported)
+					{
+					__LOG("CDataOwner::ProcessRequestDataL() - State Error - Active snapshot data has been requested from a non-active data owner");
+					User::Leave(KErrCorrupt);
+					}
+
+				// Check that no active snapshot data has been requested for a base only active data owner
+				if (!iActiveInformation.iSupportsIncremental)
+					{
+					__LOG("CDataOwner::ProcessRequestDataL() - State Error - Active snapshot data has been requested from a base only data owner");
+					User::Leave(KErrCorrupt);
+					}
+
+				// Check that the Active client has prepared it's data and is ready
+				if (iStatus != EDataOwnerReady)
+					{
+					__LOG("CDataOwner::ProcessRequestDataL() - State Error - Active Snapshot data has been requested from a data owner that isn't ready");
+					User::Leave(KErrNotReady);
+					}
+					
+				// Check that snapshot data is only requested once
+				if (StateByDriveL(aDriveNumber).iActiveSnapshotRequested)
+					{
+					__LOG("CDataOwner::ProcessRequestDataL() - State Error - Active Snapshot data has been requested more than once");
+					User::Leave(KErrCorrupt);
+					}
+					
+				// Request the snapshot data from the abclient
+				ipDataOwnerManager->ABServer().RequestDataL(iSecureId, aDriveNumber, aTransferType, 
+					aBuffer, aLastSection);
+				
+				if (aLastSection)
+					{
+					StateByDriveL(aDriveNumber).iActiveSnapshotRequested = ETrue;
+					}
+				} break;
+			case EActiveBaseData:
+			case EActiveIncrementalData:
+				{
+				if (aTransferType == EActiveBaseData)
+					{
+					__LOG1("CDataOwner::ProcessRequestDataL() - Requesting active base data from data owner with SID 0x%08x", iSecureId.iId);
+					}
+				else if (aTransferType == EActiveIncrementalData)
+					{
+					__LOG1("CDataOwner::ProcessRequestDataL() - Requesting active inc data from data owner with SID 0x%08x", iSecureId.iId);
+					}
+
+				TInt supportedProxyCount = iProxyInformationArray.Count();
+				TInt offset = 0;
+
+				// Prepend the number of proxies into the data stream
+				if (StateByDriveL(aDriveNumber).iFirstActiveTransaction)
+					{
+					// Check that no active data has been requested for a data owner that doesn't support it
+					if ((!iActiveInformation.iSupported) && (supportedProxyCount == 0))
+						{
+						// No proxies or active data 
+						__LOG("CDataOwner::ProcessRequestDataL() - State Error - Active data has been requested from a non-active/no proxy data owner");
+						User::Leave(KErrCorrupt);
+						}
+					
+					StateByDriveL(aDriveNumber).iFirstActiveTransaction = EFalse;
+					
+					PackTypeAdvance(supportedProxyCount, aBuffer, offset);
+					__LOG1("CDataOwner::ProcessRequestDataL() - Proxy Info : Packing TotalProxyCount = %d", supportedProxyCount);
+
+					aBuffer.SetLength(offset);
+			        //__LOGDATA( "CDataOwner::ProcessRequestDataL() - after adding proxy info - %S", aBuffer.Ptr(), aBuffer.Length() );
+					
+					// Reset proxy state information for this drive
+					for (TInt numProxy=0; numProxy < supportedProxyCount; numProxy++)
+						{
+						ProxyStateByDriveL(aDriveNumber,numProxy) = TProxyStateByDrive(aDriveNumber,numProxy);
+						}
+					}
+					
+				// Proxy data is always at the beginning of the data block
+				for (TInt index = 0; index < supportedProxyCount; index++)
+					{
+					__LOG2("CDataOwner::ProcessRequestDataL() - Proxy Info : Packing proxy info %d of %d", index + 1, supportedProxyCount);
+
+					// Request data from each of the data owners that haven't yet been added
+					// If the buffer's overflowed, then let the PC request again
+					if (!ProxyStateByDriveL(aDriveNumber,index).iDataRequested && aLastSection)
+						{
+						if (static_cast<TUint>(aBuffer.MaxSize() - aBuffer.Size()) > (sizeof(TBool) + sizeof(TInt32) + sizeof(TSecureId)))
+							{
+							// Pack protocol into active stream [Proxy data length][Proxy SID][Proxy Data]
+							// Set the descriptor to be maximum length and use the offset to determine where we're up to
+							aBuffer.SetMax();
+							
+							// buffer for proxy data finished flag
+							TPtr8 finishedBuf(aBuffer.MidTPtr(offset, sizeof(TBool)));
+							offset += sizeof(TBool);
+							
+							// buffer for length
+							TPtr8 lengthBuf(aBuffer.MidTPtr(offset, sizeof(TInt32)));
+							offset += sizeof(TInt32);
+							
+							// buffer for the sid 
+							TPtr8 sidBuf(aBuffer.MidTPtr(offset, sizeof(TSecureId)));
+							offset += sizeof(TSecureId);
+							
+							// Create a buffer for the data
+							TPtr8 buffer(aBuffer.MidTPtr(offset));
+							
+							// Call the proxy
+							ipDataOwnerManager->ABServer().RequestDataL(
+											iProxyInformationArray[index].iSecureId,
+											aDriveNumber, 
+											aTransferType, 
+											buffer, 
+											aLastSection, 
+											ProxyStateByDriveL(aDriveNumber,index).iOpInProgress,
+											iSecureId);
+											
+							TInt size = buffer.Size();
+
+							// Write the proxy protocol block to the active backup data stream
+							PackType(aLastSection, finishedBuf, 0);
+							__LOG1("CDataOwner::ProcessRequestDataL() - Proxy Info : FinishedFlag = %d", aLastSection);
+							
+							PackType(size, lengthBuf, 0);
+							__LOG1("CDataOwner::ProcessRequestDataL() - Proxy Info : ProxyStreamSize= %d", size);
+
+							PackType(iProxyInformationArray[index].iSecureId, sidBuf, 0);
+							__LOG1("CDataOwner::ProcessRequestDataL() - Proxy Info : ProxySID = 0x%08x", iProxyInformationArray[index].iSecureId.iId);
+							
+							// Update the offset and main buffer size
+							offset += size;
+							aBuffer.SetLength(offset);
+							
+							// If the proxy still has data to send, record the fact to that the PC can request again
+							if (!aLastSection)
+								{
+								ProxyStateByDriveL(aDriveNumber,index).iOpInProgress = ETrue;
+								}
+							else
+								{
+								ProxyStateByDriveL(aDriveNumber,index).iOpInProgress = EFalse;
+								ProxyStateByDriveL(aDriveNumber,index).iDataRequested = ETrue;
+								}
+							}
+						else
+							{
+							// If there's not enough room for the protocol info, then set the last section flag
+							aLastSection = EFalse;
+							}
+						}
+					}
+
+				if (iActiveInformation.iSupported && iActiveInformation.iActiveDataOwner && (aBuffer.Size() < aBuffer.MaxLength()))
+					{
+					// Check that if this is a base backup, no snapshot has been provided
+					if ((aTransferType == EActiveBaseData) && StateByDriveL(aDriveNumber).iActiveSnapshotReceived)
+						{
+						__LOG("CDataOwner::ProcessRequestDataL() - State Error - A snapshot has been provided before a request for base data");
+						User::Leave(KErrCorrupt);
+						}
+					
+					// Check that if this is an incremental backup that at least one complete snapshot has been sent
+					if ((aTransferType == EActiveIncrementalData) && !StateByDriveL(aDriveNumber).iActiveSnapshotReceived)
+						{
+						__LOG("CDataOwner::ProcessRequestDataL() - State Error - No snapshot has been supplied, yet incremental data has been requested");
+						User::Leave(KErrCorrupt);
+						}
+					
+					// Check that only one (possibly multi-part) request of actual data is made to an active backup client
+					if (((aTransferType == EActiveBaseData) && StateByDriveL(aDriveNumber).iActiveBaseDataRequested) || 
+						((aTransferType == EActiveIncrementalData) && StateByDriveL(aDriveNumber).iActiveIncDataRequested))
+						{
+						__LOG("CDataOwner::ProcessRequestDataL() - State Error - Active data has been requested more than once (not counting multi-part)");
+						User::Leave(KErrCorrupt);
+						}
+						
+					// Check that only Base OR Incremental data is requested - not both
+					if (((aTransferType == EActiveBaseData) && StateByDriveL(aDriveNumber).iActiveIncDataRequested) || 
+						((aTransferType == EActiveIncrementalData) && StateByDriveL(aDriveNumber).iActiveBaseDataRequested))
+						{
+						__LOG("CDataOwner::ProcessRequestDataL() - State Error - Only active base or incremental data can be requested in the same session");
+						User::Leave(KErrCorrupt);
+						}
+
+					// Create a buffer pointer allowing the client to fill the remainder of the buffer
+					TInt currentBufferLength = aBuffer.Size();
+					aBuffer.SetMax();
+					
+					TPtr8 buffer(aBuffer.MidTPtr(currentBufferLength));
+					
+					// Request data from the abclient
+					ipDataOwnerManager->ABServer().RequestDataL(
+									iSecureId,
+									aDriveNumber,
+									aTransferType, 
+									buffer,
+									aLastSection,
+									StateByDriveL(aDriveNumber).iOpInProgress);
+
+					aBuffer.SetLength(currentBufferLength + buffer.Size());
+
+					// If the active data owner still has data to send, record the fact to that the PC can request again
+					if (!aLastSection)
+						{
+						StateByDriveL(aDriveNumber).iOpInProgress = ETrue;
+						}
+					else 
+						{
+						StateByDriveL(aDriveNumber).iOpInProgress = EFalse;
+						StateByDriveL(aDriveNumber).iFirstActiveTransaction = ETrue;
+						if (aTransferType == EActiveBaseData)
+							{
+							StateByDriveL(aDriveNumber).iActiveBaseDataRequested = ETrue;
+							}
+						
+						if (aTransferType == EActiveIncrementalData)
+							{
+							StateByDriveL(aDriveNumber).iActiveIncDataRequested = ETrue;
+							}
+						}
+					}	// Active data owner
+				} break;
+			default:
+				{
+				User::Leave(KErrNotSupported);
+				}
+			} // switch
+
+        __LOG2("CDataOwner::ProcessRequestDataL() - NEAR END - aBuffer.Ptr(): 0x%08x, aBuffer.Length(): %d", aBuffer.Ptr(), aBuffer.Length());
+        //__LOGDATA( "CDataOwner::ProcessRequestDataL() - %S", aBuffer.Ptr(), aBuffer.Length() );
+        __LOG("CDataOwner::ProcessRequestDataL() - END");
+		}
+		
+    void CDataOwner::RequestDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, 
+    				  			  TPtr8& aBuffer, TBool& aLastSection)
+    	{
+    	aLastSection = ETrue;		// Set the last section to be true by default
+    	
+		// Check our state
+		if (!((iState.iState == ENone) ||
+		     ((iState.iState == ERequest) && (iState.iDriveNumber == aDriveNumber) && 
+		      (iState.iTransferType == aTransferType))))
+			{
+			User::Leave(KErrNotReady);			
+			}
+			
+		// Set the state?
+		if (iState.iState == ENone)
+			{
+			iState.iState = ERequest;
+			iState.iDriveNumber = aDriveNumber;
+			iState.iTransferType = aTransferType;
+			}
+			
+		// What are we doing then?
+		// We must trap any errors and rethrow them so we can reset our state
+		TRAPD(err, ProcessRequestDataL(aDriveNumber, aTransferType, aBuffer, aLastSection));
+		
+		if (err != KErrNone)
+			{
+			__LOG4("CDataOwner::RequestDataL() - drive: %c:, aTransferType: %d, secureId: 0x%08x - ERROR: %d", 'a' + aDriveNumber, aTransferType, iSecureId.iId, err);
+			iState.iState = ENone;
+			delete iBufferFileWriter;
+			iBufferFileWriter = NULL;
+			delete iBufferSnapshotWriter;
+			iBufferSnapshotWriter = NULL;
+			User::Leave(err);
+			} // if
+		
+		if (aLastSection) // If last section reset state
+			{
+			iState.iState = ENone;
+			} // if
+    	} // RequestDataL
+    	
+    void CDataOwner::RestoreCompleteL()
+    /** Indicate to the active client that the restore operation has been completed
+    */
+    	{
+    	// Find all of the drives that this data owner could have stored data on
+    	TDriveList driveList;
+    	GetDriveListL(driveList);
+    	
+    	for (TInt driveCountIndex = 0; driveCountIndex < KMaxDrives; driveCountIndex++)
+    		{
+    		if (driveList[driveCountIndex])
+    			{
+    			// If the particular drive is supported, then indicate that the restore is complete
+    			ipDataOwnerManager->ABServer().RestoreCompleteL(iSecureId, static_cast<TDriveNumber>(driveCountIndex));
+    			}
+    		}
+    	}
+
+
+	TSecureId CDataOwner::SecureId() const
+	/** Get the secure id of the data owner
+
+	@return the secure id of the data owner
+	*/
+		{
+		return iSecureId;
+		}
+		
+	TDataOwnerStatus CDataOwner::ReadyState()
+	/** Gets the ready state of the data owner
+	
+	@return The ready state
+	*/
+		{
+		TDataOwnerStatus status = EDataOwnerReady;
+		TInt proxyIndex = 0;
+		const TUint proxyCount = iProxyInformationArray.Count();
+		CDataOwner* pProxyDataOwner = NULL; // TRAPD forces us to use a pointer instead of ref
+		
+		while ((proxyIndex < proxyCount) && (status == EDataOwnerReady || status == EDataOwnerReadyNoImpl))
+			{
+			// For each proxy required, query for ready state
+			TRAPD(err, pProxyDataOwner = &(ipDataOwnerManager->DataOwnerL(
+				iProxyInformationArray[proxyIndex].iSecureId)));
+
+			// If the proxy data owner doesn't exist - then error
+			if (err == KErrNotFound)
+				{
+				status = EDataOwnerNotFound;
+				}
+			else
+				{
+				if (pProxyDataOwner->ActiveInformation().iActiveType != EActiveOnly)
+					{
+					// Get the status from each of the supported proxies
+					status = pProxyDataOwner->ReadyState();
+					proxyIndex++;					
+					}
+				else
+					{
+					status = EDataOwnerFailed;
+					break;
+					}
+
+				}
+			}
+
+		
+		// If this data owner has only proxy data to backup, then echo the state of the proxies
+		if ((proxyCount > 0) && !iActiveInformation.iActiveDataOwner) // is passive
+			{
+			if (status == EDataOwnerReadyNoImpl) // proxy (eg.cent rep) is ready
+				{
+				iStatus = EDataOwnerReady;
+				}
+			else
+				{
+				iStatus = status;
+				}
+			}
+			
+		if ((iActiveInformation.iActiveDataOwner) && (iStatus != EDataOwnerReady) && (iStatus != EDataOwnerReadyNoImpl))
+			{
+			TRAPD(err, iStatus = ipDataOwnerManager->ABServer().SessionReadyStateL(iSecureId));
+			if (err != KErrNone)
+				{
+				iStatus = EDataOwnerNotConnected;
+				}
+			}
+
+		// If all of the proxies are ok, then set the status to be that of this data owner
+		if (status == EDataOwnerReady || status == EDataOwnerReadyNoImpl)
+			{
+			status = iStatus;
+			}
+		
+		
+		__LOG2("CDataOwner::ReadyState() - Ready status for data owner 0x%08x is %d", iSecureId.iId, static_cast<TInt>(status));
+			
+		return status;
+		}
+		
+	void CDataOwner::SetReadyState(TDataOwnerStatus aDataOwnerStatus)
+	/**
+	Set upon a ConfirmReadyForBUR IPC call from an active backup client
+	*/
+		{
+		__LOG2("CDataOwner::SetReadyState() - Setting ready state of data owner 0x%08x to %d", iSecureId.iId, static_cast<TInt>(aDataOwnerStatus));
+		iStatus = aDataOwnerStatus;
+		if (aDataOwnerStatus == EDataOwnerReady && iActiveInformation.iActiveType == EProxyImpOnly)
+			{
+			iStatus = EDataOwnerReadyNoImpl;
+			}
+		}
+
+	TCommonBURSettings CDataOwner::CommonSettingsL()
+	/** Get the common settings of the data owner
+
+	@pre CDataOwner::ParseFilesL() must have been called
+	@return the common settings of the data owner
+	@leave KErrNotReady if CDataOwner::ParseFilesL() not called
+	*/
+		{
+		__LOG2("CDataOwner::CommonSettingsL() - START - sid: 0x%08x, iFilesParsed: %d", iSecureId.iId, iFilesParsed);
+		if (!iFilesParsed)
+			{
+			User::Leave(KErrNotReady);
+			}
+			
+		__LOG2("CDataOwner::CommonSettingsL() - Active Supported: %d, proxyCount: %d", iActiveInformation.iSupported, iProxyInformationArray.Count());
+		TCommonBURSettings settings = ENoOptions;
+		if (iActiveInformation.iSupported || iProxyInformationArray.Count())
+			{
+			settings |= EActiveBUR;
+			} // if
+
+		__LOG1("CDataOwner::CommonSettingsL() - Passive Supported: %d", iPassiveInformation.iSupported);
+		if (iPassiveInformation.iSupported)
+			{
+			settings |= EPassiveBUR;
+			}
+
+		__LOG1("CDataOwner::CommonSettingsL() - System Supported: %d", iSystemInformation.iSupported);
+		if (iSystemInformation.iSupported)
+			{
+			settings |= EHasSystemFiles;
+			}
+
+		__LOG2("CDataOwner::CommonSettingsL() - SelActive: %d, SelPassive: %d", iActiveInformation.iSupportsSelective, iPassiveInformation.iSupportsSelective);
+		if (iActiveInformation.iSupportsSelective && iPassiveInformation.iSupportsSelective)
+			{
+			settings |= ESupportsSelective;
+			}
+
+		__LOG1("CDataOwner::CommonSettingsL() - Reboot required: %d", iRestoreInformation.iRequiresReboot);
+		if (iRestoreInformation.iRequiresReboot)
+			{
+			settings |= ERequiresReboot;
+			}
+
+		__LOG("CDataOwner::CommonSettingsL() - END");
+		return settings;
+		}
+
+	TPassiveBURSettings CDataOwner::PassiveSettingsL()
+	/** Get the passive settings of the data owner
+
+	@pre CDataOwner::ParseFilesL() must have been called
+	@return the passive settings of the data owner
+	@leave KErrNotReady if CDataOwner::ParseFilesL() not called
+	*/
+		{
+		if (!iFilesParsed)
+			{
+			User::Leave(KErrNotReady);
+			}
+		
+		TPassiveBURSettings settings = ENoPassiveOptions;
+		if (iPassiveInformation.iSupported)
+			{
+			if (iPassiveInformation.iDeleteBeforeRestore)
+				{
+				settings |= EDeleteBeforeRestore;
+				} // if
+			if (!iPassiveInformation.iBaseBackupOnly)
+				{
+				settings |= EPassiveSupportsInc;
+				} // if
+			} // if
+		if (iPublicInformation.iSupported)
+			{
+			settings |= EHasPublicFiles;
+			} // if
+			
+			
+		return settings;
+		}
+
+	TActiveBURSettings CDataOwner::ActiveSettingsL()
+	/** Get the active settings of the data owner
+
+	@pre CDataOwner::ParseFilesL() must have been called
+	@return the active settings of the data owner
+	@leave KErrNotReady if CDataOwner::ParseFilesL() not called
+	*/
+		{
+		if (!iFilesParsed)
+			{
+			User::Leave(KErrNotReady);
+			}
+			
+		TActiveBURSettings settings = ENoActiveOptions;
+		if (iActiveInformation.iSupported)
+			{
+			if (iActiveInformation.iRequiresDelayToPrepareData)
+				{
+				settings |= EDelayToPrepareData;
+				} // if
+			if (iActiveInformation.iSupportsIncremental)
+				{
+				settings |= EActiveSupportsInc;
+				} // if
+			} // if
+
+		return settings;
+		}
+		
+	/**
+	Get ActiveInformation of the data owner
+	
+	@return TActiveInformation active information
+	*/
+	TActiveInformation CDataOwner::ActiveInformation()
+		{
+		return iActiveInformation;
+		}
+
+	void CDataOwner::GetDriveListL(TDriveList& aDriveList)
+	/** Get the drive list for the data owner
+
+	@pre CDataOwner::ParseFilesL() must have been called
+	@return the active settings of the data owner
+	@leave KErrNotReady if CDataOwner::ParseFilesL() not called
+	*/
+		{
+		__LOG2("CDataOwner::GetDriveListL() - SID: 0x%08x, iFilesParsed: %d", iSecureId.iId, iFilesParsed);
+		if (!iFilesParsed)
+			{
+			User::Leave(KErrNotReady);
+			}
+
+		// Get the list of available drives, dont return drives that dont exist.
+		TDriveList existingDrives;
+		const TInt error = ipDataOwnerManager->GetRFs().DriveList(existingDrives);
+        if  ( error != KErrNone )
+            {
+            __LOG1("CDataOwner::GetDriveListL() - couldnt get drive list: %d", error);
+            }
+        User::LeaveIfError(error);
+		
+		// We now no longer return the Z drive, it has been decided that the Z drive will always be the
+		// ROM. Backing up and restoring the ROM drive should not be possible, as what is the point
+		
+		TDriveList notToBackup = ipDataOwnerManager->Config().ExcludeDriveList();
+		
+		for (TInt i = 0; i < KMaxDrives; i++)
+			{
+			if (notToBackup[i]) // if this drive is set
+				{
+				// don't include this drive
+				existingDrives[i] = EFalse;
+				}
+			}
+		
+		// If we do active backup or dbms backup then we
+		// have to say all drives
+		if ((iActiveInformation.iSupported) || (iDBMSSelections.Count()))
+			{
+            __LOG("CDataOwner::GetDriveListL() - active DO, so using all existing drives");
+			aDriveList = existingDrives;		
+			} // if
+		else
+			{
+			// See where we have files?
+			TBool allDrives = EFalse;
+            				
+     		// Reset drives passed in
+			aDriveList.SetLength(KMaxDrives);
+			aDriveList.FillZ();
+			
+			// Loop through passive files
+			TInt count = iPassiveSelections.Count();
+            __LOG1("CDataOwner::GetDriveListL() - checking %d passive file entries...", count);
+			for (TInt x = 0; !allDrives &&  x < count; x++)
+				{
+                const TDesC& selection = iPassiveSelections[x]->SelectionName();
+                if (iPassiveSelections[x]->SelectionType() != EExclude)
+                	{
+	                TInt drive = GetDrive(selection);
+							
+					if (drive == -1)
+						{
+	                    __LOG3("CDataOwner::GetDriveListL() - passive[%2d/%2d] => all drives (no specific drive letter) - fullName: %S", x+1, count, &selection);
+						allDrives = ETrue;
+						}
+					else if (existingDrives[drive] != 0)
+						{
+	                    __LOG4("CDataOwner::GetDriveListL() - passive[%2d/%2d] => drive: %c, fullName: %S", x+1, count, drive + 'A', &selection);
+						aDriveList[drive] = ETrue;
+						}
+                	}
+
+				} // for
+
+            __LOG(" ");
+					
+			// Loop through public files
+			count = iPublicSelections.Count();
+            __LOG1("CDataOwner::GetDriveListL() - checking %d public file entries...", count);
+
+            for (TInt x = 0; !allDrives &&  (x < count); x++)
+				{
+                const TDesC& selection = iPublicSelections[x]->SelectionName();
+                if (iPublicSelections[x]->SelectionType() != EExclude)
+                	{
+					TInt drive = GetDrive(selection);
+						
+					if (drive == -1)
+						{
+	                    __LOG3("CDataOwner::GetDriveListL() - public[%2d/%2d] => all drives (no specific drive letter) - fullName: %S", x+1, count, &selection);
+						allDrives = ETrue;
+						}
+					else if (existingDrives[drive] != 0)
+						{
+	                    __LOG4("CDataOwner::GetDriveListL() - public[%2d/%2d] => drive: %c, fullName: %S", x+1, count, drive + 'A', &selection);
+						aDriveList[drive] = ETrue;
+						}
+                	}
+				} // for
+					
+			if (allDrives)
+				{
+                __LOG("CDataOwner::GetDriveListL() - using all drives!");
+				aDriveList = existingDrives;
+				} // if
+			} // else
+
+	#ifdef SBE_LOGGING_ENABLED
+		TBuf<256> drivePrint;
+		//
+		for(TInt i=0; i<KMaxDrives; i++)
+			{
+			if	(aDriveList[i] != 0)
+				{
+				const TDriveUnit driveUnit(i);
+				const TDriveName name(driveUnit.Name());
+				drivePrint.Append(name);
+				if	(i < KMaxDrives - 1)
+					{
+					drivePrint.Append(_L(", "));
+					}
+				}
+			}
+
+        __LOG2("CDataOwner::GetDriveListL() - END - SID: 0x%08x, supports drives: %S", iSecureId.iId, &drivePrint);
+	#endif
+		}
+
+	void CDataOwner::SetBackedUpAsPartial(TBool aPartial)
+	/**
+	Inform's the data owner that upon a partial backup, this DO is to be backed up
+	*/
+		{
+		iBackupAsPartial = aPartial;
+		}
+		
+	TBool CDataOwner::PartialAffectsMe() const
+	/**
+	Accessor to discover whether or not the sbe client has specified this Data Owner to be backed 
+	up as part of a partial backup
+	
+	@return ETrue if this data owner has been requested to backup as partial
+	*/
+		{
+		return iBackupAsPartial;
+		}
+
+	void CDataOwner::ParseFileL(const TDesC& aFileName)
+	/** Parse a given registration file
+
+	@param aFileName the registration file to parse
+	*/
+		{
+		__LOG2("CDataOwner::ParseFileL() - START - aFileName: %S, iPrimaryFile: %d", &aFileName, iPrimaryFile);
+		
+		PrivatePathL(aFileName);
+		// Parse the file
+		ipDataOwnerManager->ParserProxy().ParseL(aFileName, *this);
+		}
+		
+	void CDataOwner::PrivatePathL(const TDesC& aFileName)
+	/** Get the private path
+	@param aPath The path to extract the drive from
+	*/
+		{
+		delete iPrivatePath;
+  		TParsePtrC parse(aFileName);
+  		iPrivatePath = parse.Path().AllocL();
+		}
+
+	TInt CDataOwner::GetDrive(const TDesC& aPath) const
+	/** Gets the drive relating to a path.
+	
+	@param aPath The path to extract the drive from
+	@return A TDriveNumber or -1 if a drive is not specified
+	*/
+		{
+		TInt ret = KErrNotFound;
+		
+		if (aPath.Length() > 0)
+			{
+			if (ipDataOwnerManager->GetRFs().CharToDrive(static_cast<TChar>(aPath[0]).GetLowerCase(), ret) != KErrNone)
+				{
+				ret = KErrNotFound;
+				} // if			
+			}
+
+		return ret;
+		}
+		
+	void CDataOwner::BuildFileListL(const RSelections& aFileSelection, 
+									const TDriveNumber aDriveNumber,
+									const TTransferDataType aTransferType,
+									const TBool aIsPublic,
+									RSnapshots* apSnapshots,
+								    RFileArray* apFileEntries,
+								    CDesCArray* apFileNames)
+	/** Builds a file list.
+	
+	Builds a file list for a given selection.
+	
+	@param aFileSelection the selection
+	@param aDriveNumber The drive that the file resides on
+	@param aTransferType The type of the transfer
+	@param aIsPublic Are we building a public file list
+	@param apSnapshots A snapshot to compare files against
+	@param apFileEntries Array of file info's to populate
+	@param apFileNames Array of file names to populate
+	*/
+		{
+		TInt count = aFileSelection.Count();
+		__LOG4("CDataOwner::BuildFileListL() - START - aDriveNumber: %c, count: %d, aIsPublic: %d, aTransferType: %d", aDriveNumber + 'A', count, aIsPublic, aTransferType);		
+		// Split selections into include and exclude
+		RArray<TPtrC> include;
+		CleanupClosePushL(include);
+		RArray<TPtrC> exclude;
+		CleanupClosePushL(exclude);
+		// sort the snapshost to speed up IsNewerL()
+		if (apSnapshots)
+			{
+			apSnapshots->Sort(CSnapshot::Compare);
+			}	
+
+        __LOG("CDataOwner::BuildFileListL() - file selection listing...:");
+		for (TInt x = 0; x < count; x++)
+			{
+            const TDesC& selectionName = aFileSelection[x]->SelectionName();
+            __LOG3("CDataOwner::BuildFileListL() - selection[%03d]: %S, type: %d", x, &selectionName, aFileSelection[x]->SelectionType());
+			if (aFileSelection[x]->SelectionType() == EInclude)
+				{
+				include.AppendL(selectionName);
+				} // if
+			else
+				{
+				exclude.AppendL(selectionName);
+				} // else
+			} // for x
+			
+		// Loop through all includes
+		count = include.Count();
+        __LOG("CDataOwner::BuildFileListL() - include listing...:");
+        TFileName* fileName = new(ELeave) TFileName();
+        CleanupStack::PushL(fileName);
+		for (TInt x = 0; x < count; x++)
+			{
+			fileName->Zero();
+			TChar drive;
+			User::LeaveIfError(ipDataOwnerManager->GetRFs().DriveToChar(aDriveNumber, drive));
+
+            const TDesC& includeEntry( include[x] );
+            __LOG2("CDataOwner::BuildFileListL() - entry[%03d] is: %S", x, &includeEntry);
+            
+            // See if the drive is specified
+			if (includeEntry[0] == KBackSlash()[0])
+				{
+				// Add the drive
+				fileName->Append(drive);
+				fileName->Append(KColon);
+				fileName->Append(includeEntry);
+				}
+			else if (static_cast<TChar>(includeEntry[0]).GetLowerCase() == drive.GetLowerCase())
+				{
+				fileName->Copy(includeEntry);
+				} // else
+
+			
+            __LOG2("CDataOwner::BuildFileListL() - entry[%03d] filename is therefore: %S", x, fileName);
+			if (fileName->Length() > 0)
+				{
+				
+				// Check to see if fileName is just a drive(we cant get an entry)
+				TBool isDrive = EFalse;
+				if ((fileName->MatchF(KDrive) != KErrNotFound) ||
+				    (fileName->MatchF(KDriveAndSlash) != KErrNotFound))
+					{
+					isDrive = ETrue;
+                    __LOG("CDataOwner::BuildFileListL() - filename is a drive");
+					} // if
+					
+				TEntry entry;
+				TBool isEntry = EFalse;
+				if (!isDrive)
+					{
+					TInt err = ipDataOwnerManager->GetRFs().Entry(*fileName, entry);
+                    __LOG1("CDataOwner::BuildFileListL() - get entry error: %d", err);
+					entry.iName = *fileName;
+					switch (err)
+						{
+					case KErrNone:
+						isEntry = ETrue;
+						break;
+					case KErrNotFound:
+					case KErrPathNotFound:
+					case KErrBadName:
+						break;
+					default:
+						User::Leave(err);
+						} // switch
+					} // if
+					
+				if (isDrive || (isEntry && entry.IsDir()))
+					{
+                    __LOG("CDataOwner::BuildFileListL() - parsing directory...");
+					ParseDirL(*fileName, exclude, aTransferType, aIsPublic, apSnapshots, apFileEntries, apFileNames);
+
+				#ifdef SBE_LOGGING_ENABLED
+                    if  (apFileNames)
+                        {
+                        const TInt fNameCount = apFileNames->Count();
+                        for(TInt k=0; k<fNameCount; k++)
+                            {
+                            const TDesC& fileName = (*apFileNames)[k];
+                            __LOG2("CDataOwner::BuildFileListL() - directory entry[%03d] %S", k, &fileName);
+                            }
+                        }
+
+                    __LOG("CDataOwner::BuildFileListL() - end of parsing directory");
+				#endif
+					} // if
+				else
+					{
+					if (isEntry)
+						{
+                        const TBool isExcluded = IsExcluded(aIsPublic, *fileName, exclude);
+						if (!isExcluded)
+							{
+							TInt err = KErrNone;
+							TBool newer = EFalse;
+							if (apSnapshots && (aTransferType == EPassiveIncrementalData))
+								{
+								TRAP(err, IsNewerL(*fileName, entry, apSnapshots, newer));
+								} // if
+							if (!apSnapshots || 
+							    (aTransferType == EPassiveBaseData) || 
+							    newer || 
+							    (err != KErrNone))
+								{
+                                __LOG1("CDataOwner::BuildFileListL() - adding fully verified file: %S", fileName);
+								if (apFileEntries)
+									{
+									// Add to list of files
+									apFileEntries->AppendL(entry);
+									} // if
+								
+								if (apFileNames)
+									{
+									apFileNames->AppendL(*fileName);
+									} // else
+								} // if
+							} // if
+                        else
+                            {
+                            __LOG("CDataOwner::BuildFileListL() - file is excluded!");
+                            }
+						} // if
+					} // else
+				} // if
+			} // for x
+		CleanupStack::PopAndDestroy(fileName);
+		CleanupStack::PopAndDestroy(&exclude);
+		CleanupStack::PopAndDestroy(&include);
+        __LOG("CDataOwner::BuildFileListL() - END");
+		}
+
+	void CDataOwner::ParseDirL(const TDesC& aDirName, 
+							   const RArray<TPtrC>& aExclude,
+							   const TTransferDataType aTransferType,
+							   const TBool aIsPublic,
+							   RSnapshots* apSnapshots,
+							   RFileArray* apFileEntries,
+							   CDesCArray* apFileNames)
+	/** Parses a directory for files.
+	
+	Parses the given directory for files. The function is called recursivily if a directory is found.
+	
+	@param aDirName the directory to search
+	@param aExclude a list of directories or files to exclude
+	@param apFileEntries Array of file entries to populate
+	@param apFileNames Array of filenames to populate
+	*/							   
+		{
+		CDir* pFiles = NULL;
+		
+		// This function requires a / on the end otherwise it does not work!
+		TFileName* path = new(ELeave) TFileName(aDirName);
+		CleanupStack::PushL(path);
+		
+		if ((*path)[path->Length() - 1] != KBackSlash()[0])
+			{
+			path->Append(KBackSlash);
+			}
+		
+		TInt err = ipDataOwnerManager->GetRFs().GetDir(*path, KEntryAttMatchMask, ESortNone, pFiles);
+		if ((err != KErrNone) && (err != KErrNotFound)) // Do we need to leave?
+			{
+			User::Leave(err);
+			} // if
+		
+		CleanupStack::PushL(pFiles);
+		
+		// sort the snapshost to speed up IsNewerL()
+		if (apSnapshots)
+			{
+			apSnapshots->Sort(CSnapshot::Compare);
+			}
+		
+		TUint count = pFiles->Count();
+		
+		if (count==0)
+	 		{
+ 			// empty directory			
+ 			TEntry entry;
+ 			TInt err = ipDataOwnerManager->GetRFs().Entry(*path, entry);
+ 			entry.iName = *path;
+ 			if (entry.IsDir() && (!IsExcluded(aIsPublic, entry.iName, aExclude)))
+ 				{
+				// append empty directory entry to the list
+ 				entry.iSize = 0;
+ 				if (apFileEntries)
+ 					{
+ 					apFileEntries->AppendL(entry);
+ 					} 
+ 				if (apFileNames)
+ 					{
+ 					apFileNames->AppendL(entry.iName);
+ 					} 
+ 				}	
+ 			}
+
+		TFileName* fileName = new(ELeave) TFileName();
+		CleanupStack::PushL(fileName);
+		
+		while(count--)
+			{
+			TEntry entry((*pFiles)[count]); 
+			
+			fileName->Zero();
+			// Build full path
+			fileName->Append(*path);
+			fileName->Append(entry.iName);
+			entry.iName = *fileName;
+			
+			if (!IsExcluded(aIsPublic, entry.iName, aExclude))
+				{
+				if (entry.IsDir())
+					{
+					ParseDirL(entry.iName, aExclude, aTransferType, aIsPublic, apSnapshots, apFileEntries, apFileNames);
+					} // if
+				else
+					{
+					TInt err = KErrNone;
+					TBool newer = EFalse;
+					if (apSnapshots && (aTransferType == EPassiveIncrementalData))
+						{
+						TRAP(err, IsNewerL(entry.iName, entry, apSnapshots, newer));
+						} // if
+					if (!apSnapshots ||
+					    (aTransferType == EPassiveBaseData) || 
+					    newer || 
+					    (err != KErrNone))
+						{
+						if (apFileEntries)
+							{
+							// Add to list of files
+							apFileEntries->AppendL(entry);
+							} // if
+						
+						if (apFileNames)
+							{
+							apFileNames->AppendL(entry.iName);
+							} // else
+						} // if
+					} // else
+				} // if
+			} // while
+			
+		// Cleanup
+		CleanupStack::PopAndDestroy(fileName);
+		CleanupStack::PopAndDestroy(pFiles);
+		CleanupStack::PopAndDestroy(path);
+		}
+
+
+	void CDataOwner::GetNextPublicFileL(TBool aReset, TDriveNumber aDriveNumber, TEntry& aEntry)
+	/** Gets the next public file associated with the data owner
+
+	@param aReset set true to start reading from the beginning of the list
+	@param aDriveNumber the drive to retrieve the public files for
+	@param aEntry on return the next entry in the list, an empty entry indicates the end of the list has been reached
+	*/
+		{
+		TInt stackCount;
+		TFileName fileName;
+		TBool endOfList = EFalse;
+		TBool gotEntry = EFalse;
+		TChar drive;
+		User::LeaveIfError(ipDataOwnerManager->GetRFs().DriveToChar(aDriveNumber, drive));
+		
+		if (aReset) 
+			{
+			// Reset and start at the beginning
+			iPublicFileIndex = -1;
+			
+			// Go through and close all RDirs, then reset the array.
+			for (stackCount = iPublicDirStack.Count(); stackCount > 0; --stackCount)
+				{
+				iPublicDirStack[stackCount-1].Close();
+				delete iPublicDirNameStack[stackCount-1];
+				}
+			iPublicDirStack.Reset();
+			iPublicDirNameStack.Reset();
+
+			// Build the list of excludes			
+			iPublicExcludes.Reset();
+			TInt selectionCount = iPublicSelections.Count();
+			for (TInt x = 0; x < selectionCount; ++x)
+				{
+	            const TDesC& selectionName = iPublicSelections[x]->SelectionName();
+	            __LOG3("CDataOwner::GetNextPublicFileL() - selection[%03d]: %S, type: %d", x, &selectionName, iPublicSelections[x]->SelectionType());
+				if (iPublicSelections[x]->SelectionType() == EExclude)
+					{
+					iPublicExcludes.AppendL(selectionName);
+					} // else
+				} // for x
+			} // if (aReset)
+			
+		while (!endOfList && !gotEntry)
+			{
+			stackCount = iPublicDirStack.Count();
+			if (stackCount == 0)
+				{
+				// Directory stack is empty, proceed to the next included file entry
+				do { ++iPublicFileIndex; }
+				while (iPublicFileIndex < iPublicSelections.Count() &&
+						iPublicSelections[iPublicFileIndex]->SelectionType() != EInclude);
+
+				if (iPublicFileIndex < iPublicSelections.Count())
+					{
+					const TDesC& selectionName = iPublicSelections[iPublicFileIndex]->SelectionName();
+			        
+					if (selectionName[0] == KBackSlash()[0])
+						{
+						// Add the drive
+						fileName.Zero();
+						fileName.Append(drive);
+						fileName.Append(KColon);
+						fileName.Append(selectionName);
+						}
+					else
+						{
+						// Handle the Exclamation (!) in Public data paths, if any.  
+						// Exclamation mark in place of drive letter means that the path is to be checked in all available drives.
+						// And any dataowner can keep their public files in any drive and it can be mentioned in backup_registration file as below.
+						// <public_backup>
+						// <include_directory name="!:\mydatabases\" />
+						// </public_backup>				
+						
+						if ( selectionName[0] == KExclamationAsDrive()[0])
+							{	
+							// Map public data path using current drive being backed up.
+							fileName.Zero();
+							fileName.Append(drive);
+							fileName.Append( selectionName.Mid(1) );
+							}
+						else
+							if (static_cast<TChar>(selectionName[0]).GetUpperCase() == drive.GetUpperCase())
+							{								
+							fileName.Copy(selectionName);
+							} // else
+						
+						} // else
+
+		            __LOG1("CDataOwner::GetNextPublicFileL() - next include entry filename is therefore: %S", &fileName);
+					if (fileName.Length() > 0)
+						{
+						
+						// Check to see if fileName is just a drive(we cant get an entry)
+						TBool isDrive = EFalse;
+						if ((fileName.MatchF(KDrive) != KErrNotFound) ||
+						    (fileName.MatchF(KDriveAndSlash) != KErrNotFound))
+							{
+							isDrive = ETrue;
+		                    __LOG("CDataOwner::GetNextPublicFileL() - filename is a drive");
+							} // if
+							
+						TBool isEntry = EFalse;
+						if (!isDrive)
+							{
+							TInt err = ipDataOwnerManager->GetRFs().Entry(fileName, aEntry);
+		                    __LOG1("CDataOwner::GetNextPublicFileL() - get entry error: %d", err);
+							aEntry.iName = fileName;
+							switch (err)
+								{
+							case KErrNone:
+								isEntry = ETrue;
+								break;
+							case KErrNotFound:
+							case KErrPathNotFound:
+							case KErrBadName:
+								break;
+							default:
+								User::Leave(err);
+								} // switch
+
+							// Must have a trailing backslash on a directory
+							if (aEntry.IsDir() && (fileName[fileName.Length() - 1] != '\\'))
+								{
+								fileName.Append(KBackSlash);
+								}
+							} // if
+					
+						if (isDrive || (isEntry && aEntry.IsDir()))
+							{
+		                    __LOG("CDataOwner::GetNextPublicFileL() - parsing directory...");
+							RDir dir;
+							dir.Open(ipDataOwnerManager->GetRFs(), fileName, KEntryAttMaskSupported);
+							iPublicDirStack.AppendL(dir);
+							iPublicDirNameStack.AppendL(fileName.AllocL());
+							++stackCount;
+							} // if
+						else if (isEntry)
+							{
+							if (!IsExcluded(ETrue, fileName, iPublicExcludes))
+								{
+								gotEntry = ETrue;
+								}
+	                        else
+	                            {
+	                            __LOG("CDataOwner::BuildFileListL() - file is excluded!");
+	                            }
+							} // if
+						} // else if
+					}
+				else
+					{
+					endOfList = ETrue;					
+					}
+				} // if (stackCount == 0)
+
+			if (stackCount > 0)
+				{
+				// There is a directory on the stack, so iterate through it
+				RDir& dir = iPublicDirStack[stackCount-1];
+				TInt err = dir.Read(aEntry);
+
+				if (err == KErrNone) 
+					{
+					// Succesfully read the next directory entry
+
+					// Build full file path
+					fileName.Zero();
+					
+					// loop through dir stack adding entries seperated by '\'.
+					for (TInt x = 0; x < iPublicDirStack.Count(); ++x)
+						{
+						fileName.Append(*iPublicDirNameStack[x]);
+						// Add a backslash if there's not already one
+						if (fileName[fileName.Length()-1] != KBackSlash()[0]) 
+							{
+							fileName.Append(KBackSlash);
+							}
+						}
+
+					// Append the currently entry name to complete the path
+					fileName.Append(aEntry.iName);
+
+					if (aEntry.IsDir())
+						{
+						// Must have a trailing backslash on directory paths
+						fileName.Append(KBackSlash);
+						
+						// Open the directory and push it onto the dir stack
+						RDir dir;
+						User::LeaveIfError(dir.Open(ipDataOwnerManager->GetRFs(), fileName, KEntryAttMaskSupported));
+						iPublicDirStack.AppendL(dir);
+						iPublicDirNameStack.AppendL(aEntry.iName.AllocL());
+						++stackCount;
+						}
+					else
+						{
+						// Update entry with full path ready to return
+						aEntry.iName = fileName;
+						gotEntry = ETrue;
+						}
+					// if (entry.IsDir())
+						
+					}
+				else if (err == KErrEof)
+					{
+					// Finished reading this directory, close it and pop it from the directory stack
+					stackCount--;
+					
+					iPublicDirStack[stackCount].Close();
+					iPublicDirStack.Remove(stackCount);
+					
+					delete iPublicDirNameStack[stackCount];
+					iPublicDirNameStack.Remove(stackCount);
+					}
+				else
+					{
+					User::Leave(err);
+					}
+				} // if (stackCount > 0)
+			}
+
+		if (endOfList)
+			{
+			// If the end of the list has been reached, make sure that an empty TEntry is returned
+			aEntry = TEntry();
+			}
+		}
+
+
+	TBool CDataOwner::IsExcluded(const TBool aIsPublic, const TDesC& aFileName, const RArray<TPtrC>& aExclude)
+	/** Checks to see if a given file is excluded
+	
+	Checks to see if the given file is not in a private directory or in the exclude list.
+	
+	@param aFileName file to check
+	@param aExclude list of excluded files
+	@return ETrue if excluded otherwise EFalse
+	*/
+		{
+		TBool ret = EFalse;
+		
+		// Check it is not in sys, resource, system or backwards path
+		ret = (!((aFileName.MatchF(KSystem) == KErrNotFound) &&
+			     (aFileName.MatchF(KResource) == KErrNotFound) &&
+			     (aFileName.MatchF(KSys) == KErrNotFound) && 
+			     (aFileName.MatchF(KOther) == KErrNotFound)
+			    )
+			  );
+		
+		// If this is public backup remove the private directory
+		if (!ret && aIsPublic)
+			{
+		    ret = (!(aFileName.MatchF(KPrivateMatch) == KErrNotFound));
+			}
+		
+		/**		 
+		 * Check whether file is in the "NoBackup" folder or not, if yes exclude it from the backup
+		 * @note: All files which are kept in "NoBackup" folder under the private directory will be 
+		 * excluded from the backup by default.
+		 */		
+		if (!ret)
+		    {
+		    ret = (!(aFileName.MatchF(KPrivateNoBackup) == KErrNotFound));		    
+		    }
+		
+		// See if the file is in a private directory the data owner can access
+		if (!ret && (aFileName.MatchF(KPrivateMatch) != KErrNotFound))
+			{
+			// The path includes a private directory, make sure it is the data owners
+			// private directory.
+			const TInt KSecureIdLength(8); // This is currently the length of a secure id
+			TBuf<KSecureIdLength> sid;
+			sid.Num(iSecureId, EHex);
+			TFileName match(KPrivateSidMatch());
+			match.Append(KPad().Ptr(), KPad().Length() - sid.Length());
+			match.Append(sid);
+			match.Append(KStar);
+			ret = (aFileName.MatchF(match) == KErrNotFound);
+			} // if
+		
+		if (!ret)
+			{
+			// Is the file in the exclude list?
+			const TInt count = aExclude.Count();
+			for (TInt x = 0; !ret && x < count; x++)
+				{				
+				__LOG1("file name: %S",&aFileName);
+				if (aExclude[x][0] == KBackSlash()[0])
+					{
+					// Compare with out drive
+					TFileName compare = KQuestionMark();
+					compare.Append(KColon);
+					compare.Append(aExclude[x]);
+					ret = (!(aFileName.MatchF(compare) == KErrNotFound));
+					} // if
+				else
+					{
+					// Normal compare
+					ret = (aFileName.CompareF(aExclude[x]) == 0);
+					} // else
+				} // for x
+			} // if
+		
+        __LOG2("CDataOwner::IsExcluded() - END - returns excluded: %d for file: %S", ret, &aFileName);
+		return ret;
+		}
+		
+	void CDataOwner::SupplyPassiveSnapshotDataL(TDriveNumber aDriveNumber, TDesC8& aBuffer, TBool aLastSection)
+	/** Handles the supply of passive snapshot data
+	
+	@param aBuffer The buffer containing the snapshot data.
+	@param aLastSection Is this the last section?
+	*/
+		{
+        __LOG2("CDataOwner::SupplyPassiveSnapshotDataL() - START - aDriveNumber: %c, aLastSection: %d", aDriveNumber + 'A', aLastSection);
+
+		TInt err = KErrNone;
+		if (iBufferSnapshotReader == NULL)
+			{
+            __LOG("CDataOwner::SupplyPassiveSnapshotDataL() - making temporary snapshot holder..");
+			iTempSnapshotHolder = CSnapshotHolder::NewL();
+			iTempSnapshotHolder->iDriveNumber = aDriveNumber;
+			iBufferSnapshotReader = CBufferSnapshotReader::NewL(iTempSnapshotHolder->iSnapshots);
+			
+            __LOG("CDataOwner::SupplyPassiveSnapshotDataL() - trying to unpack snapshots from buffer...");
+			TRAP(err, iBufferSnapshotReader->StartL(aBuffer, aLastSection));
+            __LOG1("CDataOwner::SupplyPassiveSnapshotDataL() - unpack result was: %d", err);
+			} // if
+		else
+			{
+            __LOG("CDataOwner::SupplyPassiveSnapshotDataL() - continuing unpack operation...");
+			TRAP(err, iBufferSnapshotReader->ContinueL(aBuffer, aLastSection));
+            __LOG1("CDataOwner::SupplyPassiveSnapshotDataL() - continued unpack operation result was: %d", err);
+			}
+			
+		if ((err != KErrNone) || aLastSection)
+			{
+			delete iBufferSnapshotReader;
+			iBufferSnapshotReader = NULL;
+			
+			if (err == KErrNone)
+				{
+                __LOG("CDataOwner::SupplyPassiveSnapshotDataL() - Snapshots identified ok!");
+				
+				iSnapshots.AppendL(iTempSnapshotHolder);
+				iTempSnapshotHolder = NULL;
+				} // if
+			else
+				{
+                __LOG1("CDataOwner::SupplyPassiveSnapshotDataL() - END - leaving with error: %d", err);
+				User::Leave(err);
+				} // else
+			} // if
+
+        __LOG("CDataOwner::SupplyPassiveSnapshotDataL() - END");
+		}
+	
+	void CDataOwner::SupplyPassiveBaseDataL(const TDriveNumber aDriveNumber, TDesC8& aBuffer, TBool aLastSection)
+	/** Handles the supply of passive base data
+	*/
+		{
+		__LOG3("CDataOwner::SupplyPassiveBaseDataL() - START - drive: %c, aLastSection: %d, iBufferFileReader: 0x%08x", aDriveNumber + 'A', aLastSection, iBufferFileReader);
+
+        TInt err = KErrNone;
+		if (iBufferFileReader == NULL)
+			{
+			iBufferFileReader = CBufferFileReader::NewL(ipDataOwnerManager->GetRFs(), FindSnapshot(aDriveNumber), this);
+			
+			TRAP(err, iBufferFileReader->StartL(aBuffer, aLastSection));
+			} // if
+		else
+			{
+			TRAP(err, iBufferFileReader->ContinueL(aBuffer, aLastSection));
+			} // else
+			
+		if ((err != KErrNone) || aLastSection)
+			{
+            if  ( err != KErrNone )
+                {
+                __LOG1("CDataOwner::SupplyPassiveBaseDataL() - ERROR - error: %d", err);
+                }
+	
+            delete iBufferFileReader;
+			iBufferFileReader = NULL;
+			
+			User::LeaveIfError(err);
+			} // if
+
+        __LOG("CDataOwner::SupplyPassiveBaseDataL() - END");
+		}
+		
+	void CDataOwner::RequestPassiveSnapshotDataL(TDriveNumber aDriveNumber, TPtr8& aBuffer, 
+												 TBool& aLastSection)
+	/** Handles the request for passive snapshot data
+	
+	@param aDriveNumber The drive snapshot data is required.
+	@param aBuffer The buffer to write the data too.
+	@param aLastSection On return set to true if finished.
+	*/													 
+		{
+        __LOG3("CDataOwner::RequestPassiveSnapshotDataL() - START - aDriveNumber: %c, owner: 0x%08x, bufferLen: %d", aDriveNumber + 'A', iSecureId.iId, aBuffer.Length() );
+
+		if (iBufferSnapshotWriter == NULL)
+			{
+			RFileArray fileinfos;
+			CleanupClosePushL(fileinfos);
+			
+			CDesCArray* filenames = new(ELeave) CDesCArrayFlat(KDesCArrayGranularity);
+			CleanupStack::PushL(filenames);
+
+			BuildFileListL(iPassiveSelections, aDriveNumber, EPassiveBaseData, EFalse, NULL, &fileinfos, filenames);
+			
+			// Add the DBMS file
+			AddDBMSFilesL(aDriveNumber, filenames, &fileinfos);
+			
+			const TInt count = fileinfos.Count();
+			if (count > 0)
+				{
+                __LOG1("CDataOwner::SupplyPassiveBaseDataL() - got %d entries...", count);
+
+				// Create a tempory snapshot holder
+				RSnapshots* tempSnapshots = new(ELeave) RSnapshots();
+				TCleanupItem cleanup(CleanupRPointerArray, tempSnapshots);
+				CleanupStack::PushL(cleanup);
+				
+				for (TInt x = 0; x < count; x++)
+					{
+					const TDesC& fileName = (*filenames)[x];
+					CSnapshot* snapshot = CSnapshot::NewLC(fileinfos[x].iModified.Int64(), fileName);
+					__LOG3("CDataOwner::RequestPassiveSnapshotDataL() - snapshot[%2d/%2d] = %S", x+1, count, &fileName);
+					tempSnapshots->AppendL(snapshot);
+					CleanupStack::Pop(snapshot);
+					} // for x
+				
+				// Create a buffer writer
+				iBufferSnapshotWriter = CBufferSnapshotWriter::NewL(tempSnapshots);
+				CleanupStack::Pop(tempSnapshots);
+				
+                __LOG("CDataOwner::RequestPassiveSnapshotDataL() - writing snapshots to buffer...");
+				iBufferSnapshotWriter->StartL(aBuffer, aLastSection);
+				if (aLastSection)
+					{
+					delete iBufferSnapshotWriter;
+					iBufferSnapshotWriter = NULL;
+					} // if
+					
+				
+				} // if
+			else
+				{
+				aLastSection = ETrue;
+				} // else
+			
+			CleanupStack::PopAndDestroy(filenames);
+			CleanupStack::PopAndDestroy(&fileinfos);
+			} // if
+		else
+			{
+			iBufferSnapshotWriter->ContinueL(aBuffer, aLastSection);
+			if (aLastSection)
+				{
+				delete iBufferSnapshotWriter;
+				iBufferSnapshotWriter = NULL;
+				} // if
+			} // else
+
+        __LOG2("CDataOwner::RequestPassiveSnapshotDataL() - END - aLastSection: %d, bufferLen: %d", aLastSection, aBuffer.Length());
+		} // RequestPassiveSnapShotDataL
+		
+	void CDataOwner::RequestPassiveDataL(TTransferDataType aTransferType, 
+										 TDriveNumber aDriveNumber, TPtr8& aBuffer, 
+									     TBool& aLastSection)
+	/** Handles the request for passive base data
+	
+	@param aDriveNumber The drive that files must be on.
+	@param aBuffer The buffer to write the data to.
+	@param aLastSection On return set to true if finished.
+	*/
+		{
+        __LOG4("CDataOwner::RequestPassiveDataL() - START - aDrive: %c, aTransferType: %d, iSecureId: 0x%08x, iBufferFileWriter: 0x%08x", aDriveNumber + 'A', aTransferType, iSecureId.iId, iBufferFileWriter);
+
+        // Build the list of files
+		if (iBufferFileWriter == NULL)
+			{
+			CDesCArray* filenames = new(ELeave) CDesCArrayFlat(KDesCArrayGranularity);
+			CleanupStack::PushL(filenames);
+
+			if (aTransferType == EPassiveBaseData)
+				{
+                __LOG("CDataOwner::RequestPassiveDataL() - EPassiveBaseData...");
+				BuildFileListL(iPassiveSelections, aDriveNumber, aTransferType, EFalse, NULL, NULL, filenames);
+				
+				// Add the DBMS file
+				AddDBMSFilesL(aDriveNumber, filenames, NULL);
+				} // if
+			else
+				{
+				// Do we have a snapshot?
+				const TInt count = iSnapshots.Count();
+				RSnapshots* pSnapshot = NULL;
+				for (TInt x = 0; !pSnapshot && (x < count); x++)
+					{
+					if (iSnapshots[x]->iDriveNumber == aDriveNumber)
+						{
+						pSnapshot = &(iSnapshots[x]->iSnapshots);
+						} // if
+					} // for x
+					
+				BuildFileListL(iPassiveSelections, aDriveNumber, aTransferType, EFalse, pSnapshot, NULL, filenames);
+				
+				// Do we need to add the DBMS file?
+				AddDBMSFilesL(aDriveNumber, filenames, NULL);
+				} // else
+
+
+            __LOG1("CDataOwner::RequestPassiveDataL() - Got %d files...", filenames->Count());
+			if (filenames->Count() > 0)
+				{
+				// Create a file writer
+				iBufferFileWriter = CBufferFileWriter::NewL(ipDataOwnerManager->GetRFs(), filenames);
+				CleanupStack::Pop(filenames);
+				
+				iBufferFileWriter->StartL(aBuffer, aLastSection);
+				if (aLastSection)
+					{
+					delete iBufferFileWriter;
+					iBufferFileWriter = NULL;
+					}
+				} // if
+			else
+				{
+				CleanupStack::PopAndDestroy(filenames);
+				aLastSection = ETrue;
+				} // else
+
+			} // if
+		else
+			{
+			iBufferFileWriter->ContinueL(aBuffer, aLastSection);
+			if (aLastSection)
+				{
+				delete iBufferFileWriter;
+				iBufferFileWriter = NULL;
+				} // if
+			} // else
+		
+        __LOG("CDataOwner::RequestPassiveDataL() - END");
+		}
+		
+	void CDataOwner::IsNewerL(const TDesC& aFileName, const TEntry& aFile, const RSnapshots* aSnapshots, TBool& aNewer)
+	/** Check to see if a file is newer.
+	
+	Checks to see if aFile is newer than the one contained in aFiles.
+	
+	@param aFile the file to check.
+	@param aFiles the array of files to check agaisnt
+	@param aNewer on return ETrue if aFile is newer, EFalse otherwise.
+	@leave KErrNotFound if aFile does not exist in aFiles.
+	*/
+		{
+		CSnapshot* snapshot = CSnapshot::NewLC(TTime().Int64(), aFileName);
+		TInt res = aSnapshots->Find(snapshot, CSnapshot::Match);
+		CleanupStack::PopAndDestroy(snapshot);
+		User::LeaveIfError(res);
+		if (aFile.iModified.Int64() > (*aSnapshots)[res]->Modified())
+			{
+			aNewer = ETrue;
+			}
+		else
+			{
+			aNewer = EFalse;
+			}
+		}
+	
+	RSnapshots* CDataOwner::FindSnapshot(TDriveNumber aDriveNumber)
+	/** Searches the snapshots find a snapshot
+	
+	@param aDriveNumber find snapshot for drive aDriveNumber
+	@return The snapshot or NULL
+	*/
+		{
+		const TInt count = iSnapshots.Count();
+		__LOG3("CDataOwner::FindSnapshot() - START - aDriveNumber: %c, count: %d, iSecureId: 0x%08x", aDriveNumber + 'A', count, iSecureId.iId);
+
+        RSnapshots* pRet = NULL;
+		
+		for (TInt x = 0; !pRet && (x < count); x++)
+			{
+            CSnapshotHolder* snapshotHolder = iSnapshots[x];
+
+		#ifdef SBE_LOGGING_ENABLED            
+            const TInt entryCount = snapshotHolder->iSnapshots.Count();
+            __LOG4("CDataOwner::FindSnapshot() - snapshot[%02d] - drive: %c, entry Count: %d, addr: 0x%08x", x, snapshotHolder->iDriveNumber + 'A', entryCount, &snapshotHolder->iSnapshots);
+
+            for(TInt i=0; i<entryCount; i++)
+                {
+                const TDesC& snapshot = snapshotHolder->iSnapshots[i]->FileName();
+                __LOG2("CDataOwner::FindSnapshot() -     file[%04d]: %S", i+1, &snapshot);
+                }
+		#endif
+
+			if (snapshotHolder->iDriveNumber == aDriveNumber)
+				{
+				pRet = &(snapshotHolder->iSnapshots);
+				} // if
+			} // for x
+			
+		__LOG1("CDataOwner::FindSnapshot() - END - ret: 0x%08x", pRet);
+		return pRet;
+		}
+		
+	/**
+	Returns a reference to a state by drive object. Object is located using aDrive as a key
+	@param aDrive Index identifying the TDataOwnerStateByDrive
+	*/
+	TDataOwnerStateByDrive& CDataOwner::StateByDriveL(TDriveNumber& aDrive)
+		{
+		TBool found = EFalse;
+		const TInt count = iStateByDrive.Count();
+		TInt index = 0;
+
+		// Loop around until we find		
+		while ((index < count) && !found)
+			{
+			if (iStateByDrive[index].iDrive == aDrive)
+				{
+				found = ETrue;
+				}
+			else
+				{
+				++index;
+				}
+			}
+		
+		// We must have found, otherwise error	
+		if (!found)
+			{
+			User::Leave(KErrNotFound);
+			}
+			
+		return iStateByDrive[index];
+		}
+
+	/**
+	Returns a reference to a proxy state by drive object. Object is located using aDrive and aProxy as keys
+	@param aDrive Index identifying the TProxyStateByDrive
+	@param aProxy Index identifying the proxy
+	*/
+	TProxyStateByDrive& CDataOwner::ProxyStateByDriveL(TDriveNumber& aDrive, TInt aProxy)
+		{
+		TBool found = EFalse;
+		const TInt count = iProxyStateByDrive.Count();
+		TInt index = 0;
+
+		// Loop around until we find		
+		while ((index < count) && !found)
+			{
+			if (iProxyStateByDrive[index].iDrive == aDrive &&
+				iProxyStateByDrive[index].iProxy == aProxy)
+				{
+				found = ETrue;
+				}
+			else
+				{
+				++index;
+				}
+			}
+		
+		// Add a new entry if not found
+		if (!found)
+			{
+			iProxyStateByDrive.Append(TProxyStateByDrive(aDrive,aProxy));
+			index = count;
+			}
+			
+		return iProxyStateByDrive[index];
+		}
+
+
+	
+	/**
+	Called to re-create the state-by-drive array
+	*/
+	void CDataOwner::BuildDriveStateArrayL()
+		{
+		TDriveList driveList;
+		driveList.SetMax();
+		
+		TRAPD(err, GetDriveListL(driveList));
+        __LOG2("CDataOwner::BuildDriveStateArrayL() - START - SID: 0x%08x, error: %d", iSecureId.iId, err);
+		
+		if (err == KErrNone)
+			{
+			for (TInt index = 0; index < KMaxDrives; index++)
+				{
+				if (driveList[index])
+					{
+					// Add a new state object to the array of states
+					iStateByDrive.AppendL(TDataOwnerStateByDrive(static_cast<TDriveNumber>(index)));
+					}
+				}
+			}
+		else
+			{
+			__LOG1("CDataOwner::BuildDriveStateArrayL() - Warning! error ocurred whilst getting the drivelist from data owner %08x", iSecureId.iId);
+			}
+		}
+		
+		
+	/** 
+	Adds the list of DBMS files to a filename list
+	*/
+	void CDataOwner::AddDBMSFilesL(TDriveNumber aDriveNumber, CDesCArray* apFileNames, RFileArray* apEntries)
+		{
+		const TInt count = iDBMSSelections.Count();
+		__LOG3("CDataOwner::AddDBMSFilesL() - START - aDriveNumber: %c, owner: 0x%08x, count: %d", aDriveNumber + 'A', iSecureId.iId, count);
+
+        if (count > 0)
+			{
+			// Get DB connection
+			RDbs dbs;
+			User::LeaveIfError(dbs.Connect());
+			CleanupClosePushL(dbs);
+			
+			for (TInt x = 0; x < count; x++)
+				{
+				// Get list of filenames
+				TInt err = KErrNone; 
+				CDbStrings* pFilenames = NULL;
+				TRAP(err, pFilenames = dbs.BackupPathsL(iSecureId, iDBMSSelections[x]));
+					
+				if (err == KErrNone)
+					{
+					CleanupStack::PushL(pFilenames);
+					
+		        	__LOG1("CDataOwner::AddDBMSFilesL() - getting backup paths for owner returned error: %d", err);
+		        	
+					const TInt count = pFilenames->Count();
+					for (TInt x = 0; x < count; x++)
+						{
+                        const TDesC& pFileName = (*pFilenames)[x];
+	                	__LOG3("CDataOwner::AddDBMSFilesL() - file[%3d/%3d] = %S", x + 1, count, &pFileName);
+
+						TInt drive = -1;
+						TInt driveerr = RFs::CharToDrive( pFileName[0], drive);
+						if ((driveerr == KErrNone) && (drive == aDriveNumber))
+							{ 
+							if (apFileNames)
+								{
+	                	        __LOG1("CDataOwner::AddDBMSFilesL() - adding validated filename: %S", &pFileName);
+								apFileNames->AppendL( pFileName );
+								}
+							if (apEntries)
+								{
+								TEntry entry;
+								TInt entryError = ipDataOwnerManager->GetRFs().Entry( pFileName, entry);
+	                	        __LOG2("CDataOwner::AddDBMSFilesL() - drive entry result for file \'%S\' is: %d", &pFileName, entryError);
+								if (entryError == KErrNone)
+									{
+	                	            __LOG1("CDataOwner::AddDBMSFilesL() - adding validated entry: %S", &pFileName);
+									apEntries->AppendL(entry);
+									} // if
+								else if (entryError != KErrNotFound)
+									{
+									__LOG2("CDataOwner::AddDBMSFilesL() - Could not get entry for 0x%08x, error: %d", iSecureId.iId, entryError);
+									} // else if
+								} // if
+							} // if
+						else
+    						{
+							__LOG("CDataOwner::AddDBMSFilesL() - File is not applicable for this drive => file ignored");
+    						}
+						} // for x
+					
+					// Cleanup	
+					CleanupStack::PopAndDestroy(pFilenames);
+					}
+				else
+					{
+					__LOG2("CDataOwner::AddDBMSFilesL() - RDbs error %d SID: 0x%08x", err, iSecureId.iId);
+					} // else
+				} // for x
+			
+			// Cleanup
+			CleanupStack::PopAndDestroy(&dbs);	
+			} // if
+		
+        __LOG2("CDataOwner::AddDBMSFilesL() - END - aDriveNumber: %c, owner: 0x%08x", aDriveNumber + 'A', iSecureId.iId);
+		} // AddDBMSFiles
+		
+	/** Disables system data
+	*/
+	void CDataOwner::DisableSystemData()
+		{
+		iSystemInformation.iSupported = EFalse;
+		} // Disable system data
+		
+	TInt CDataOwner::AddProxyToList(TProxyInformation aProxy)
+	/** Adds proxy to list making sure there are no duplicates
+	@param TProxyInformation Proxy to add 
+	@return error if Append failes
+	*/
+		{
+		TInt count = iProxyInformationArray.Count();
+		TBool found = EFalse;
+		
+		while (count && !found)
+			{
+			--count;
+			if (iProxyInformationArray[count].iSecureId == aProxy.iSecureId)
+				{
+				found = ETrue;
+				}
+			}
+			
+		TInt err = KErrNone;		
+		if (!found)
+			{
+			err = iProxyInformationArray.Append(aProxy);
+			__LOG2("Data owner(0x%08x): Adding Proxy(0x%08x) to the list", iSecureId.iId,aProxy.iSecureId.iId);
+			}
+		return err;
+		}	
+		
+	void CDataOwner::CleanupBeforeRestoreL(TDriveNumber& aDriveNumber)
+	/** Performs a cleanup before restore if required
+	@param aDriveNumber drive to clear
+	*/
+		{
+        const TBool passiveDeleteBeforeRestore = iPassiveInformation.iDeleteBeforeRestore;
+        const TBool driveAlreadyCleaned = StateByDriveL(aDriveNumber).iDeleteBeforeRestorePerformed;
+
+        __LOG4("CDataOwner::CleanupBeforeRestoreL() - START - aDriveNumber: %c, owner: 0x%08x, passiveDeleteBeforeRestore: %d, driveAlreadyCleaned: %d", aDriveNumber + 'A', iSecureId.iId, passiveDeleteBeforeRestore, driveAlreadyCleaned);
+
+        if  ( passiveDeleteBeforeRestore && !driveAlreadyCleaned )
+			{
+			RSelections* selections = new(ELeave) RSelections();
+			TCleanupItem cleanup(CleanupRPointerArray, selections);
+			CleanupStack::PushL(cleanup);
+			// The path to search for files to delete
+			
+			CSelection* selection = NULL;
+			const TDesC& privatePath = *iPrivatePath;
+			if (privatePath[0] == KBackSlash()[0])
+				{
+				selection = CSelection::NewLC(EInclude, privatePath);
+				} // if
+			else
+				{
+				selection = CSelection::NewLC(EInclude, privatePath.Right(privatePath.Length() - 2));
+				} // else
+			selections->AppendL(selection);
+			CleanupStack::Pop(selection);
+			
+			// Find the files to delete
+			CDesCArray* toDelete = new(ELeave) CDesCArrayFlat(KDesCArrayGranularity);
+			CleanupStack::PushL(toDelete);
+			
+			BuildFileListL(*selections, aDriveNumber, EPassiveBaseData, EFalse, NULL, NULL, toDelete);
+			
+			// Loop through the files to delete, deleting them
+			const TInt count = toDelete->Count();
+			for (TInt x = 0; x < count; x++)
+				{
+				const TDesC& fileName = (*toDelete)[x];
+
+	            __LOG3("CDataOwner::CleanupBeforeRestoreL() - checking file[%2d/%2d] for match = %S", x + 1, count, &fileName);
+
+                // Check it is not a backup registration file
+				if  ( fileName.MatchF(KBackupRegistrationFile) == KErrNotFound )
+					{
+					TInt deleteError=0;
+                    if((fileName[(fileName.Length())-1])== KBackSlash()[0])
+						{
+						  deleteError = ipDataOwnerManager->GetRFs().RmDir( fileName );
+						}
+					else
+						{
+						  deleteError = ipDataOwnerManager->GetRFs().Delete( fileName );
+						}
+					__LOG2("CDataOwner::CleanupBeforeRestoreL() - trying to deleting file %S (error was: %d)", &fileName, deleteError);
+					User::LeaveIfError(deleteError);
+					} // if
+				} // for
+			
+			// Mark as done
+			StateByDriveL(aDriveNumber).iDeleteBeforeRestorePerformed = ETrue;
+			
+			// Cleanup
+			CleanupStack::PopAndDestroy(toDelete);
+			CleanupStack::PopAndDestroy(selections);
+			} // if
+
+        __LOG2("CDataOwner::CleanupBeforeRestoreL() - END - aDriveNumber: %c, owner: 0x%08x", aDriveNumber + 'A', iSecureId.iId);
+		} 
+	/**
+	Check if the file is in the include list
+	
+	@param TDesC& aFileName file name to check
+	@return TBool ETrue if file is in the include list
+	*/
+	TBool CDataOwner::ValidFileL(const TDesC& aFileName)
+		{
+        __LOG2("CDataOwner::ValidFileL() - START - owner: 0x%08x, aFileName: %S", iSecureId.iId, &aFileName);
+
+        TInt include = EFalse;
+		
+        const TInt count = iPassiveSelections.Count();
+		for (TInt i =0; i < count; i++)
+			{
+			const TDesC& selectionName = iPassiveSelections[i]->SelectionName();
+			TInt match = aFileName.FindF(selectionName);
+            __LOG5("CDataOwner::ValidFileL() - match result against file[%3d/%3d], selectionType: %d, matchResult: %d, name: %S", i+1, count, iPassiveSelections[i]->SelectionType(), match, &selectionName);
+            
+            if (match >= 0)
+				{
+				if (iPassiveSelections[i]->SelectionType() == EInclude)
+					{
+                    __LOG("CDataOwner::ValidFileL() - file included");
+					include = ETrue;
+					}
+				else
+					{
+                    __LOG("CDataOwner::ValidFileL() - file excluded");
+					include = EFalse;
+					break;	
+					} // else if
+				} //if 
+			
+			} // for
+			
+
+        const TInt dbmsSelectionCount = iDBMSSelections.Count();
+		if (dbmsSelectionCount && !include)
+			{
+            __LOG1("CDataOwner::ValidFileL() - checking against %d DBMS files...", dbmsSelectionCount);
+
+            for (TInt j = 0; j < dbmsSelectionCount; j++)
+				{
+                const TDesC& pDbmsFileName =  iDBMSSelections[j].Name();
+                const TInt matchResult = aFileName.FindF( pDbmsFileName );
+
+                __LOG4("CDataOwner::ValidFileL() - checking against DBMS file[%2d/%2d] with result: %d (%S)...", j+1, dbmsSelectionCount, matchResult, &pDbmsFileName);
+
+                if  ( matchResult )
+					{
+                    __LOG("CDataOwner::ValidFileL() - DBMS file included");
+					include = ETrue;
+					break;
+					} // if
+				}//for
+			} // if
+		
+        __LOG1("CDataOwner::ValidFileL() - END - valid file result is: %d", include);
+		return include;
+		}
+		
+	//	
+	//  MContentHandler Implementaion //
+	//
+	
+
+
+	void CDataOwner::OnStartDocumentL(const RDocumentParameters& /*aDocParam*/, TInt aErrorCode)
+	/** MContentHandler::OnStartDocumentL()
+	*/
+		{
+		if (aErrorCode != KErrNone)
+			{
+			__LOG1("CDataOwner::OnStartDocumentL() - error = %d", aErrorCode);
+			User::Leave(aErrorCode);
+			}
+		}
+		
+	void CDataOwner::OnEndDocumentL(TInt aErrorCode)
+	/** MContentHandler::OnEndDocumentL()
+	*/
+		{
+		if (aErrorCode != KErrNone)
+			{
+			// just to satifsy UREL compiler
+			(void) aErrorCode;
+			__LOG1("CDataOwner::OnEndDocumentL() - error = %d", aErrorCode);
+			}
+		}
+		
+	void CDataOwner::OnStartElementL(const RTagInfo& aElement, 
+									  const RAttributeArray& aAttributes, 
+									  TInt aErrorCode)
+	/** MContentHandler::OnStartElementL()
+
+	@leave KErrUnknown an unknown element
+	*/
+		{
+		if (aErrorCode != KErrNone)
+			{
+			__LOG1("CDataOwner::OnStartElementL() - error = %d", aErrorCode);
+			User::LeaveIfError(aErrorCode);
+			}
+		
+		TBool unknownElement = EFalse;
+		const TDesC8& localName = aElement.LocalName().DesC();
+		if (localName == KIncludeFile) 
+			{
+			HandlePathL(EInclude, aAttributes, EFalse);
+			}
+		else if (!localName.CompareF(KIncludeDirectory))
+			{
+			HandlePathL(EInclude, aAttributes, ETrue);
+			}
+		else if (!localName.CompareF(KExclude))
+			{
+			HandlePathL(EExclude, aAttributes, EFalse);
+			}
+		else if (!localName.CompareF(KBackupRegistration))
+			{
+			HandleBackupRegistrationL(aAttributes);
+			}
+		else if (!localName.CompareF(KDBMSBackup))
+			{
+			User::LeaveIfError(HandleDBMSBackupL(aAttributes));
+			}
+		else if (!localName.CompareF(KSystemBackup))
+			{
+			User::LeaveIfError(HandleSystemBackup(aAttributes));
+			}
+		else if (!localName.CompareF(KProxyDataManager))
+			{
+			User::LeaveIfError(HandleProxyDataManager(aAttributes));
+			}
+		else if (!localName.CompareF(KCenrepBackup))
+			{
+			User::LeaveIfError(HandleCenrepBackup(aAttributes));
+			}
+		else if (!localName.CompareF(KPublicBackup))
+			{
+			iCurrentElement = EPublic;
+			User::LeaveIfError(HandlePublicBackup(aAttributes));
+			}
+		else if (!localName.CompareF(KPassiveBackup))
+			{
+			iCurrentElement = EPassive;
+			// Only allow passive to be switched on in primary files
+			if (iPrimaryFile)
+				{
+				User::LeaveIfError(HandlePassiveBackup(aAttributes));
+				}
+			}
+		else if (iPrimaryFile) 
+			{
+			// These remaining elements are only allowed in primary files
+			if (!localName.CompareF(KActiveBackup))
+				{
+				User::LeaveIfError(HandleActiveBackupL(aAttributes));
+				}
+			else if (!localName.CompareF(KRestore))
+				{
+				User::LeaveIfError(HandleRestore(aAttributes));
+				}
+			else 
+				{
+				unknownElement = ETrue;
+				}
+			} // if primary file true
+		else
+			{
+			unknownElement = ETrue;
+			}
+			
+		if (unknownElement)
+			{
+			__LOG1("CDataOwner::OnStartElementL() - Unknown element while parsing 0x%08x", iSecureId.iId);
+			}
+		}
+
+	
+	void CDataOwner::OnEndElementL(const RTagInfo& aElement, TInt aErrorCode)
+	/** MContentHandler::OnEndElementL()
+	*/
+		{
+		if (aErrorCode != KErrNone)
+			{
+			__LOG1("CDataOwner::OnEndElementL() - error = %d", aErrorCode);
+			User::Leave(aErrorCode);
+			}
+		
+		const TDesC8& localName = aElement.LocalName().DesC();
+		if (!localName.CompareF(KPassiveBackup))
+			{
+			iCurrentElement = ENoElement;
+			} // if
+		else if (localName == KPublicBackup)
+			{
+			iCurrentElement = ENoElement;
+			} // else if
+		}
+
+	void CDataOwner::OnContentL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/)
+	/** MContentHandler::OnContentL()
+	*/
+		{
+		// Not handled
+		}
+
+	void CDataOwner::OnStartPrefixMappingL(const RString& /*aPrefix*/, 
+											const RString& /*aUri*/, TInt /*aErrorCode*/)
+	/** MContentHandler::OnStartPrefixMappingL()
+	*/
+		{
+		// Not handled
+		}
+
+	void CDataOwner::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt /*aErrorCode*/)
+	/** MContentHandler::OnEndPrefixMappingL()
+	*/
+		{
+		// Not handled
+		}
+
+	void CDataOwner::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/)
+	/** MContentHandler::OnIgnorableWhiteSpaceL()
+	*/
+		{
+		// Not handled
+		}
+
+	void CDataOwner::OnSkippedEntityL(const RString& /*aName*/, TInt /*aErrorCode*/)
+	/** MContentHandler::OnSkippedEntityL()
+	*/
+		{
+		// Not handled
+		}
+
+	void CDataOwner::OnProcessingInstructionL(const TDesC8& /*aTarget*/, 
+											   const TDesC8& /*aData*/, 
+											   TInt /*aErrorCode*/)
+	/** MContentHandler::OnProcessingInstructionL()
+	*/
+		{
+		// Not handled
+		}
+
+	void CDataOwner::OnError(TInt aErrorCode)
+	/** MContentHandler::OnError()
+
+	@leave aErrorCode
+	*/
+		{
+		(void)aErrorCode;
+		__LOG1("CDataOwner::OnError() - error = %d", aErrorCode);
+		}
+
+	TAny* CDataOwner::GetExtendedInterface(const TInt32 /*aUid*/)
+	/** MContentHandler::OnEndPrefixMappingL()
+	*/
+		{
+		return NULL;
+		}
+
+	void CDataOwner::HandleBackupRegistrationL(const RAttributeArray& aAttributes)
+	/** Handles the "backup_registration" element
+
+	@param aAttributes the attributes for the element
+	@return KErrNone no errors
+	@return KErrUnknown unknown version
+	*/
+		{
+		if (aAttributes.Count() == 1)
+			{
+			// Check the version is correct.
+			if (aAttributes[0].Value().DesC() != KVersion()) // Only version we know about
+				{
+				__LOG1("CDataOwner::HandleBackupRegistrationL() - Unknown version at SID(0x%08x)", iSecureId.iId);
+				User::Leave(KErrNotSupported);
+				} // else
+			} // if
+		}
+
+
+	TInt CDataOwner::HandlePassiveBackup(const RAttributeArray& aAttributes)
+	/** Handles the "passive_backup" element
+
+	@param aAttributes the attributes for the element
+	@return KErrNone
+	*/
+		{
+		iPassiveInformation.iSupported = ETrue;
+		
+		// Loop through reading out attribute values
+		const TInt count = aAttributes.Count();
+		for (TInt x = 0; x < count; x++)
+			{
+			const TDesC8& localName = aAttributes[x].Attribute().LocalName().DesC();
+
+            if  ( localName.CompareF(KSupportsSelective) == 0 )
+				{
+                const TBool supportsSelective = ( aAttributes[x].Value().DesC().CompareF(KYes) == 0 );
+				iPassiveInformation.iSupportsSelective = supportsSelective;
+				__LOG2("CDataOwner::HandlePassiveBackup(0x%08x) - iPassiveInformation.iSupportsSelective: %d", iSecureId.iId, supportsSelective);
+                } // if
+			else if ( localName.CompareF(KDeleteBeforeRestore) == 0 )
+				{
+				// AW This logic looks somewhat strange.
+				if (!aAttributes[x].Value().DesC().CompareF(KYes))
+					{
+				    __LOG1("CDataOwner::HandlePassiveBackup(0x%08x) - iPassiveInformation.iDeleteBeforeRestore: ETrue", iSecureId.iId);
+					iPassiveInformation.iDeleteBeforeRestore |= ETrue;
+					} // if
+				else
+					{
+				    __LOG1("CDataOwner::HandlePassiveBackup(0x%08x) - iPassiveInformation.iDeleteBeforeRestore: EFalse", iSecureId.iId);
+					iPassiveInformation.iDeleteBeforeRestore |= EFalse;
+					} // else
+				} // else if
+			else if ( localName.CompareF(KBaseBackupOnly) == 0 )
+				{
+                const TBool baseBackupOnly = ( aAttributes[x].Value().DesC().CompareF(KYes) == 0 );
+				iPassiveInformation.iBaseBackupOnly = baseBackupOnly;
+				__LOG2("CDataOwner::HandlePassiveBackup(0x%08x) - iPassiveInformation.iBaseBackupOnly: %d", iSecureId.iId, baseBackupOnly);
+				} // else if
+			else
+				{
+				__LOG1("CDataOwner::HandlePassiveBackup() - Unknown element while parsing 0x%08x", iSecureId.iId);
+				} // else
+			} // for x
+		
+		return KErrNone;
+		}
+
+
+	TInt CDataOwner::HandlePublicBackup(const RAttributeArray& aAttributes)
+	/** Handles the "public_backup" element
+
+	@param aAttributes the attributes for the element
+	@return KErrNone
+	*/
+		{
+		iPublicInformation.iSupported = ETrue;
+		
+		if (aAttributes.Count() > 0)
+			{
+            const TBool deleteBeforeRestore = ( aAttributes[0].Value().DesC().CompareF(KYes) == 0 );
+			iPublicInformation.iDeleteBeforeRestore = deleteBeforeRestore;
+			__LOG2("CDataOwner::HandlePublicBackup(0x%08x) - iPublicInformation.iDeleteBeforeRestore: %d", iSecureId.iId, deleteBeforeRestore);
+			} // if
+		
+		return KErrNone;
+		}
+
+	TInt CDataOwner::HandleSystemBackup(const RAttributeArray& /*aAttributes*/)
+	/** Handles the "system_backup" element
+
+	@param aAttributes the attributes for the element
+	@return KErrNone
+	*/
+		{
+		iSystemInformation.iSupported = ETrue;
+		__LOG2("CDataOwner::HandleSystemBackup(0x%08x) - iSystemInformation.iSupported: %d", iSecureId.iId, iSystemInformation.iSupported);
+
+		return KErrNone;	
+		}
+
+
+	TInt CDataOwner::HandleCenrepBackup(const RAttributeArray& /*aAttributes*/)
+	/** Handles the "cenrep_backup" element
+
+	@param aAttributes the attributes for the element
+	@return KErrNone
+	*/
+		{
+		TInt err = KErrNone;
+		TProxyInformation proxyInformation;
+		
+		proxyInformation.iSecureId = ipDataOwnerManager->Config().CentRepId();
+
+		err = AddProxyToList(proxyInformation);
+		
+		if (err == KErrNone)
+			{
+			
+			if (iActiveInformation.iSupported == EFalse)
+				{
+				iActiveInformation.iSupported = ETrue;
+				iActiveInformation.iSupportsIncremental = EFalse;
+				iStatus = EDataOwnerNotConnected;
+				}
+				
+			}
+		
+		__LOG2("CDataOwner::HandleCenrepBackup(0x%08x) - proxy creation error: %d", iSecureId.iId, err);
+		return err;
+		}
+
+	TInt CDataOwner::HandleProxyDataManager(const RAttributeArray& aAttributes)
+	/** Handles the "proxy_data_manager" element
+
+	@param aAttributes the attributes for the element
+	@return KErrNone
+	*/
+		{	
+		TInt err = KErrNone;
+		
+		TProxyInformation proxyInformation;
+		
+		const TDesC8& localName = aAttributes[0].Attribute().LocalName().DesC();
+		if (!localName.CompareF(KProxySID))
+			{
+			// The value returned from the XML element attribute parse
+			const TDesC8& hexString = aAttributes[0].Value().DesC();
+			TPtrC8 strippedSID;
+			
+			// Test for lower case hex leader chars
+			TInt result = hexString.FindF(KHexLeader);
+
+			if (result != KErrNotFound)
+				{
+				if (hexString.Length() < (result + KHexLeader().Size()))
+					{
+					__LOG1("CDataOwner::HandleProxyDataManager() - The Hex number has incorrect number of digits", iSecureId.iId);
+					}
+				// Strip off the preceeding upper case hex leader characters
+				strippedSID.Set(hexString.Mid(result + KHexLeader().Size()));
+				}
+			else
+				{
+				// There were no leading characters in the data
+				strippedSID.Set(hexString);
+				}
+			
+			TLex8 sIdLex(strippedSID);
+			err = sIdLex.Val(proxyInformation.iSecureId.iId, EHex);
+			
+			if (err == KErrNone && proxyInformation.iSecureId.iId != iSecureId.iId)
+				{
+				err = AddProxyToList(proxyInformation);
+				
+				if (err == KErrNone)
+					{
+					if (iActiveInformation.iSupported == EFalse)
+						{
+						iActiveInformation.iSupported = ETrue;
+						iActiveInformation.iSupportsIncremental = EFalse;
+						iStatus = EDataOwnerNotConnected;
+						}
+					}
+        		
+                __LOG3("CDataOwner::HandleProxyDataManager(0x%08x) - proxy creation error: %d for proxySid: 0x%08x", iSecureId.iId, err, proxyInformation.iSecureId.iId);
+				}
+			else 
+				{
+				__LOG1("CDataOwner::HandleProxyDataManager() - Not a Hex Number specified in reg_file of 0x%08x)", iSecureId.iId);
+				err = KErrNone;		// We shouldn't return an error unless Append has errored (OOM etc.)
+				}
+			} // else it's corrupt - don't error, just ignore this attribute
+		
+		return err;
+		}
+
+	TInt CDataOwner::HandleDBMSBackupL(const RAttributeArray& aAttributes)
+	/** Handles the "dbms_backup" element
+
+	@param aAttributes the attributes for the element
+	@return KErrNone
+	*/
+		{
+		iPassiveInformation.iSupported = ETrue;
+		
+		const TInt count = aAttributes.Count();
+		for (TInt x = 0; x < count; x++)
+			{
+			const TDesC8& localName = aAttributes[x].Attribute().LocalName().DesC();
+			if (localName.Length() > 0)
+				{
+				if (!localName.CompareF(KDatabase))
+					{
+					__LOG1("CDataOwner::HandleDBMSBackup(0x%08x) - Still using deprecated 'database' attribute", iSecureId.iId);
+					}
+				else if (!localName.CompareF(KPolicy))
+					{
+					TName policy;
+					if (KErrNone == ipDataOwnerManager->ParserProxy().ConvertToUnicodeL(policy, aAttributes[x].Value().DesC()))
+						{
+						TLex lex(policy);
+						TUint32 temp;
+						lex.Val(temp, EHex);
+						
+						// Check we have not seen this Uid before
+						const TInt count = iDBMSSelections.Count();
+						TBool toAdd = ETrue;
+						for (TInt x = 0; toAdd && (x < count); x++)
+							{
+							if (iDBMSSelections[x].iUid == temp)
+								{
+								toAdd = EFalse;
+								} // if
+							} // for
+						
+						// Add to list of Uid's
+						if (toAdd)
+							{
+        					__LOG2("CDataOwner::HandleDBMSBackup(0x%08x) - adding database with policy uid: 0x%08x", iSecureId.iId, temp);
+							TUid tempUID;
+							tempUID.iUid = temp;
+							TRAP_IGNORE(iDBMSSelections.AppendL(tempUID));
+							} // if
+						} // if
+					else
+						{
+						__LOG1("CDataOwner::HandleDBMSBackup(0x%08x) - Error converting policy number", iSecureId.iId);
+						} // else
+					} // else if
+				} // if
+			else
+				{
+				__LOG1("CDataOwner::HandleDBMSBackup(0x%08x) - Incorrect use of attributes", iSecureId.iId);
+				}
+			} // for x
+			
+		return KErrNone;
+	}
+
+	TInt CDataOwner::HandleActiveBackupL(const RAttributeArray& aAttributes)
+	/** Handles the "active_backup" element
+
+	@param aAttributes the attributes for the element
+	@return KErrNone
+	*/
+		{
+		iActiveInformation.iSupported = ETrue;
+		iActiveInformation.iActiveDataOwner = ETrue;
+		iStatus = EDataOwnerNotConnected;
+		
+		const TInt count = aAttributes.Count();
+		for (TInt x = 0; (iActiveInformation.iSupported && (x < count)); x++)
+			{
+			const TDesC8& localName = aAttributes[x].Attribute().LocalName().DesC();
+			if (!localName.CompareF(KProcessName))
+				{
+				if (KErrNone != ipDataOwnerManager->ParserProxy().ConvertToUnicodeL(iActiveInformation.iProcessName, aAttributes[x].Value().DesC()))
+					{
+					iActiveInformation.iSupported = EFalse;
+					__LOG1("CDataOwner::HandleActiveBackup(0x%08x) - Error converting process name", iSecureId.iId);
+					}
+				}
+			else if (!localName.CompareF(KRequiresDelay))
+				{
+                const TBool required = ( aAttributes[x].Value().DesC().CompareF(KYes) == 0 );
+				iActiveInformation.iRequiresDelayToPrepareData = required;
+				__LOG2("CDataOwner::HandleActiveBackup(0x%08x) - iActiveInformation.iRequiresDelayToPrepareData: %d", iSecureId.iId, required);
+				} // else if
+			else if (!localName.CompareF(KSupportsSelective))
+				{
+                const TBool required = ( aAttributes[x].Value().DesC().CompareF(KYes) == 0 );
+				iActiveInformation.iSupportsSelective = required;
+				__LOG2("CDataOwner::HandleActiveBackup(0x%08x) - iActiveInformation.iSupportsSelective: %d", iSecureId.iId, required);
+				} // else if
+			else if (!localName.CompareF(KSupportsInc))
+				{
+                const TBool required = ( aAttributes[x].Value().DesC().CompareF(KYes) == 0 );
+				iActiveInformation.iSupportsIncremental = required;
+				__LOG2("CDataOwner::HandleActiveBackup(0x%08x) - iActiveInformation.iSupportsIncremental: %d", iSecureId.iId, required);
+				} // else if
+			else if (!localName.CompareF(KActiveType))
+				{
+				const TDesC8& value = aAttributes[x].Value().DesC();
+				if (!value.CompareF(KActiveOnly))
+					{
+    				__LOG1("CDataOwner::HandleActiveBackup(0x%08x) - iActiveInformation.iActiveType: EActiveOnly", iSecureId.iId);
+					iActiveInformation.iActiveType = EActiveOnly;
+					}
+				else if (!value.CompareF(KActiveAndProxy))
+					{
+    				__LOG1("CDataOwner::HandleActiveBackup(0x%08x) - iActiveInformation.iActiveType: EActiveAndProxyImpl", iSecureId.iId);
+					iActiveInformation.iActiveType = EActiveAndProxyImpl;
+					}
+				else if (!value.CompareF(KProxyOnly))
+					{
+    				__LOG1("CDataOwner::HandleActiveBackup(0x%08x) - iActiveInformation.iActiveType: EProxyImpOnly", iSecureId.iId);
+					iActiveInformation.iActiveType = EProxyImpOnly;
+					}
+				}
+			} // for x
+		
+		return KErrNone;
+		}
+
+
+	TInt CDataOwner::HandleRestore(const RAttributeArray& aAttributes)
+	/** Handles the "restore" element
+
+	@param aAttributes the attributes for the element
+	@return KErrNone
+	*/
+		{
+		iRestoreInformation.iSupported = ETrue;
+		
+		if (aAttributes.Count() == 1)
+			{
+			if (!aAttributes[0].Attribute().LocalName().DesC().CompareF(KRequiresReboot))
+				{
+                const TBool required = ( aAttributes[0].Value().DesC().CompareF(KYes) == 0 );
+				iRestoreInformation.iRequiresReboot = required;
+				__LOG2("CDataOwner::HandleRestore(0x%08x) - iRestoreInformation.iRequiresReboot: %d", iSecureId.iId, required);
+				} // if
+			} // if
+		
+		return KErrNone;
+		}
+
+
+	void CDataOwner::HandlePathL(const TSelectionType aType, 
+								  const RAttributeArray& aAttributes,
+								  const TBool aDir)
+	/** Handles the "include_file", "include_directory" and "exclude" elements
+
+	@param aType The selection type 
+	@param aAttributes The attributes for the element
+	@param aDir The element was found in an <include_dir/> element?
+	*/
+		{
+		// Check we dont have a NULL string
+		if (aAttributes[0].Value().DesC().Length() > 0)
+			{
+			TFileName filename;
+			if (KErrNone != ipDataOwnerManager->ParserProxy().ConvertToUnicodeL(filename, aAttributes[0].Value().DesC()))
+				{
+				__LOG1("CDataOwner::HandlePathL(0x%08x) - EPassive - Could not convert filename", iSecureId.iId);
+				return;
+				}
+			else
+				{
+				__LOG3("CDataOwner::HandlePathL(0x%08x) - path in the registration file is: %S [type: %d]", iSecureId.iId, &filename, aType);
+				}
+				
+			// If it is a directory is do we add a trailing backslash,
+			if (aDir && (filename[filename.Length() - 1] != '\\'))
+				{
+				filename.Append(KBackSlash);
+				} // if	
+				
+	
+			switch (iCurrentElement)
+				{
+			case EPassive:
+					{
+					TFileName selectionName;
+					// first check for absolute path
+					TInt offset = filename.FindC(*iPrivatePath);
+					if (offset == KErrNotFound)
+						{
+						//check for collon path
+						offset = filename.FindC(KColon);
+						if (offset != KErrNotFound)
+							{
+							// someone other absoulute path
+							__LOG2("CDataOwner::HandlePathL(0x%08x) - Path is not recognised by the data owner : %S", iSecureId.iId, &filename);
+							return;
+							}
+						else
+							{
+							selectionName = *iPrivatePath;
+							if (filename[0] == '\\')
+								{
+								// the filename begins with \, thefore we need to chop it off
+								selectionName.SetLength(selectionName.Length() - 1);
+								}
+							selectionName.Append(filename);
+							}
+						}
+					else
+						{
+						// get the path but not the drive (e.g c:) 
+						selectionName.Copy(filename.Right(filename.Length() - offset) );
+						}
+						
+					CSelection* selection = CSelection::NewLC(aType, selectionName);
+					iPassiveSelections.AppendL(selection);
+					CleanupStack::Pop(selection);
+					__LOG3("CDataOwner::HandlePathL(0x%08x) - Added selection: %S [type: %d]", iSecureId.iId, &selectionName, aType);
+					break;
+					}
+			case EPublic:
+					{
+					// check if path relative or absolute
+					if (filename.FindC(KColon) != KErrNotFound)
+						{
+						CSelection* selection = CSelection::NewLC(aType, filename);
+						iPublicSelections.AppendL(selection);
+						CleanupStack::Pop(selection);
+						__LOG3("CDataOwner::HandlePathL(0x%08x) - Added selection: %S [type: %d]", iSecureId.iId, &filename, aType);
+						}
+					else
+						{
+						__LOG3("CDataOwner::HandlePathL(0x%08x) - Not an Absolute Path: %S [type: %d]", iSecureId.iId, &filename, aType);
+						return;
+						}
+					break;
+					}
+				} // switch
+			} // if
+		else
+			{
+			__LOG1("CDataOwner::HandlePathL(0x%08x) - Path attribute error", iSecureId.iId);
+			} // else
+		}
+		
+		
+	CSnapshotHolder* CSnapshotHolder::NewL()
+	/** Symbain OS constructor
+
+	@return a CSnapshotHolder object
+	*/
+		{
+		CSnapshotHolder* self = NewLC();
+		CleanupStack::Pop(self);
+		
+		return self;
+		}
+
+	CSnapshotHolder* CSnapshotHolder::NewLC()
+	/** Symbain OS constructor
+	
+	@return a CSnapshotHolder object
+	*/
+		{
+		CSnapshotHolder* self = new(ELeave) CSnapshotHolder();
+		CleanupStack::PushL(self);
+		
+		return self;
+		}
+		
+	CSnapshotHolder::CSnapshotHolder()
+	/** Default C++ Constructor
+	*/
+		{
+		}
+		
+	CSnapshotHolder::~CSnapshotHolder()
+	/** Default C++ Constructor
+	*/
+		{
+		iSnapshots.ResetAndDestroy();
+		}
+			
+		
+	} // namespace conn
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sbedataownermanager.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1673 @@
+// 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:
+// Implementation of CDataOwnerManager
+// 
+//
+
+/**
+ @file
+*/
+#include "sbpackagedatatransfer.h"
+#include "sbedataowner.h"
+#include "sbedataownermanager.h"
+#include "sbebufferhandler.h"
+#include "sblog.h"
+#include "abserver.h"
+
+#include "sbecompressionandencryption.h"
+
+#include <e32svr.h>
+#include <arc4.h>
+#include <babackup.h>
+#include <ezcompressor.h>
+#include <ezdecompressor.h>
+#include <swi/sisregistrypackage.h>
+#include <swi/sisregistryentry.h>
+#include <swi/swispubsubdefs.h>
+
+namespace conn
+	{
+	const TInt KSID = 0x10202D56;
+	_LIT_SECURITY_POLICY_S0(KWritePolicy, KSID);
+	_LIT_SECURITY_POLICY_PASS(KReadPolicy);
+	_LIT_SECURE_ID(KDummyId,0x00000000);
+	
+	CDataOwnerContainer* CDataOwnerContainer::NewL(TSecureId aSecureId, CDataOwnerManager* apDataOwnerManager)
+	/** Symbian OS static constructor
+	*/
+		{
+		CDataOwnerContainer* self = new(ELeave) CDataOwnerContainer(aSecureId);
+		CleanupStack::PushL(self);
+		self->ConstructL(apDataOwnerManager);			
+		CleanupStack::Pop(self);
+		
+		return self;
+		}
+		
+	CDataOwnerContainer::CDataOwnerContainer(TSecureId aSecureId) :
+		iSecureId(aSecureId)
+	/** Standard C++ constructor
+	*/
+		{
+		}
+		
+	CDataOwnerContainer::~CDataOwnerContainer()
+		{
+		delete ipDataOwner;
+		}
+		
+	void CDataOwnerContainer::ConstructL(CDataOwnerManager* apDataOwnerManager)
+	/* Symbian second phase constructor
+	*/
+		{
+		ipDataOwner = CDataOwner::NewL(iSecureId, apDataOwnerManager);
+		}
+		
+	TSecureId CDataOwnerContainer::SecureId() const
+	/** Secure Id accessor
+	
+	@return the secure id for the data owner container
+	*/
+		{
+		return iSecureId;
+		}
+		
+	CDataOwner& CDataOwnerContainer::DataOwner() const
+	/** Data owner accessor
+	
+	@return the data owner
+	*/
+		{
+		return (*ipDataOwner);
+		}
+
+	/**
+	Method will be used for Sort on RPointerArray
+	
+	@param aFirst CDataOwnerContainer& data owner container to compare
+	@param aSecond CDataOwnerContainer& data owner container to compare
+	
+	@see RArray::Sort()
+	*/
+	TInt CDataOwnerContainer::Compare(const CDataOwnerContainer& aFirst, const CDataOwnerContainer& aSecond)
+		{
+		if (aFirst.SecureId() < aSecond.SecureId())
+			{
+			return -1;
+			}
+ 		else if (aFirst.SecureId() > aSecond.SecureId())
+ 			{
+ 			return 1;
+ 			}
+ 		else 
+ 			{
+ 			return 0;
+ 			}
+		}
+		
+	/**
+	Method will be used for Find on RPointerArray
+	
+	@param aFirst CDataOwnerContainer& data owner container to match
+	@param aSecond CDataOwnerContainer& data owner container to match
+	
+	@see RArray::Find()
+	*/
+	TBool CDataOwnerContainer::Match(const CDataOwnerContainer& aFirst, const CDataOwnerContainer& aSecond)
+		{
+		return (aFirst.SecureId() == aSecond.SecureId());
+		}
+
+	CDataOwnerManager* CDataOwnerManager::NewLC()
+	/** Symbian OS static constructor	
+	*/
+		{
+		CDataOwnerManager* self	= new(ELeave) CDataOwnerManager();
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		
+		return self;
+		}
+		
+	
+	CDataOwnerManager::CDataOwnerManager() 
+	/**
+	Standard C++
+	*/
+	: ipABServer(NULL), iBufferFileReader(NULL), iDecompressor(NULL), 
+	  iResetAfterRestore(EFalse), iJavaDOM(NULL), iSIDListForPartial(NULL),
+	  iConfig(NULL), iBaBackupSession(NULL)
+		{
+		}
+		
+	void CDataOwnerManager::ConstructL()
+	/** Symbian OS second phase contrutor
+	*/
+		{
+		User::LeaveIfError(iFs.Connect());
+		TInt err = RProperty::Define(TUid::Uid(KUidSystemCategoryValue), 
+						  KUidBackupRestoreKey, 
+						  RProperty::EInt, KReadPolicy, KWritePolicy, 0);
+		if ((err != KErrNone) && (err != KErrAlreadyExists))
+			{
+			User::Leave(err);
+			}
+			
+		// Load a reference plugin with implementation Uid 0x2000D926
+		const TUid aImplementationUid = { 0x2000D926 };
+		iJavaDOM = CJavaManagerInterface::NewL( aImplementationUid );
+		
+		iDecompressor = CSBEDecompressAndEncrypt::NewL();
+		iConfig = CSBEConfig::NewL(iFs);
+		TRAP(err, iConfig->ParseL());
+		if (err != KErrNone)
+			{
+			__LOG1("Error trying to parse sbeconfig.xml : %d", err);
+			__LOG("Using Default Settings !");
+			iConfig->SetDefault();
+			}
+		else
+			{
+			__LOG("sbeconfig.xml parsed sucessfully");
+			}
+		iBaBackupSession = CBaBackupSessionWrapper::NewL();
+		iParserProxy = CSBEParserProxy::NewL(iFs);
+		}
+
+
+	CDataOwnerManager::~CDataOwnerManager()
+	/** C++ Destructor
+		
+	Destructor functions are the inverse of constructor functions. They are called 
+	when objects are destroyed (deallocated).
+
+	The destructor is commonly used to "clean up" when an object is no longer necessary.
+	*/
+		{
+		if(iJavaDOM)
+			{
+			delete iJavaDOM;
+			}
+		
+		delete iParserProxy;
+		delete iBufferFileReader;
+		delete iDecompressor;
+		iDataOwners.ResetAndDestroy();
+		iDataOwners.Close();
+		iPackageDataOwners.ResetAndDestroy();
+		iPackageDataOwners.Close();
+		iFs.Close();
+		if (iSIDListForPartial != NULL)
+			{
+			iSIDListForPartial->Close();
+			delete iSIDListForPartial;
+			}
+		delete iConfig;
+		delete iBaBackupSession;
+		}
+
+	void CDataOwnerManager::AllSystemFilesRestoredL()
+	/**
+	Handle send from the client informing us that the reg files have now all been supplied and 
+	we can parse/start active data owners etc.
+	*/
+		{
+		if(iBURType == EBURRestoreFull || iBURType == EBURRestorePartial)
+			{
+			__LOG("CDataOwnerManager::AllSystemFilesRestored() - called, parse reg files & start active DO's");
+			// Build the list of dataOwners
+
+			TInt err;
+			TRAP(err, FindDataOwnersL());
+			if (err != KErrNone)
+				{
+				__LOG1("CDataOwnerManager::AllSystemFilesRestored() - Error while finding data owners: %d", err);
+				}
+
+			TInt doCount = iDataOwners.Count();
+			
+			// Loop throught the list
+			for (TInt x = 0; x < doCount; x++)
+				{
+				CDataOwnerContainer* pContainer = iDataOwners[x];
+				CDataOwner& dataOwner = pContainer->DataOwner();
+				TRAP_IGNORE(dataOwner.ParseFilesL());
+				}
+
+			doCount = iDataOwners.Count();
+			
+			// update partial state of active data owners
+			TRAP(err, UpdateDataOwnersPartialStateL());
+			if (err != KErrNone)
+				{
+				__LOG1("CDataOwnerManager::AllSystemFilesRestored() - Error while updating state: %d", err);
+				}
+				
+			for (TInt index = 0; index < doCount; index++)
+				{
+				// Start data owning process if necessary for active data owners
+				TRAP(err, iDataOwners[index]->DataOwner().StartProcessIfNecessaryL());
+				if (err != KErrNone)
+					{
+					__LOG1("CDataOwnerManager::AllSystemFilesRestored() - Error while starting process if necessary: %d", err);
+					}
+				
+				// Set up the internal state of the data owners now that all reg files and proxies are back
+				TRAP(err, iDataOwners[index]->DataOwner().BuildDriveStateArrayL());
+				if (err != KErrNone)
+					{
+					__LOG1("CDataOwnerManager::AllSystemFilesRestored() - Error while building drive array: %d", err);
+					}
+				}
+			
+			if(iJavaDOM)
+				{				
+				TRAP_IGNORE(iJavaDOM->AllSystemFilesRestored());
+				}
+			else
+				{
+				__LOG("CDataOwnerManager::AllSystemFilesRestored() - Java Backup-Restore Plug-In not loaded, java files won't be backed or restored");
+				}
+			
+			// now deal with special case packages
+			CDesCArray* files = new(ELeave) CDesCArrayFlat(KDesCArrayGranularity);
+			CleanupStack::PushL(files);
+			TRAP_IGNORE(FindRegistrationFilesL(KImportDir, *files));
+			const TInt count = files->Count();
+			for (TInt x = 0; x < count; x++)
+				{
+				// Strip the SID
+				TSecureId sid;
+				const TDesC& fileName = (*files)[x];
+				TRAPD(err, StripSecureIdL(fileName, sid));
+			
+				if (err == KErrNone) // If there was an error then ignore it as it is probally not a dir
+					{	
+					CPackageDataTransfer* pDataTransfer = NULL;
+					TRAPD(err, pDataTransfer = FindPackageDataContainerL(sid));
+					if (err == KErrNone)
+						{
+						TRAP(err, pDataTransfer->SetRegistrationFileL(fileName));
+						if (err == KErrNone)
+							{
+							TRAP(err, pDataTransfer->ParseL());
+							}
+						__LOG2("CDataOwnerManager::AllSystemFilesRestored() - found reg file: %S for Package: 0x%08x", &fileName, sid.iId);
+						}
+					if (err == KErrNoMemory)
+						{
+						User::Leave(KErrNoMemory);
+						}
+					}
+				} // for
+				
+			CleanupStack::PopAndDestroy(files);
+			
+			} // end if
+		else
+			{
+			__LOG("CDataOwnerManager::AllSystemFilesRestored() - *Error: called when device is not in Restore mode !");
+			}
+		
+		}
+
+		
+	void CDataOwnerManager::SetBURModeL(const TDriveList& aDriveList, TBURPartType aBURType, 
+						 		   	   TBackupIncType aBackupIncType)
+	/** Sets the publish & subscribe backup flag
+	
+	@param aDriveList a list of drives involved in the backup
+	@param aBURType the type
+	@param aBackupIncType the incremental type
+	@leave KErrInUse a Software install is in progress, plus system wide errors
+	*/						 		  
+		{
+		__LOG2("CDataOwnerManager::SetBURModeL() - Request new BURType (0x%08x), IncType (0x%08x)", aBURType, aBackupIncType);
+		__LOG2("CDataOwnerManager::SetBURModeL() - Previous BURType (0x%08x), IncType (0x%08x)", iBURType, iIncType);
+		// Ensure that the device can't transition directly from backup to restore mode. It must
+		// go through a normal state first. Allow the state to be set to the same.
+		switch(aBURType)
+			{
+			case EBURNormal:
+			// allow to set Normal mode in any case. no need to do anything if previous mode was Normal
+				if (iBURType == EBURNormal)
+					{
+					return;
+					}
+				break;
+			case EBURUnset:
+			// don't do anything if previous modes were Normal or Unset
+				if (iBURType == EBURNormal || iBURType == EBURUnset)
+					{
+					return;
+					}
+				break;
+			case EBURBackupFull:
+			case EBURBackupPartial:
+			case EBURRestoreFull:
+			case EBURRestorePartial:
+			// don't allow mode change unless , device was put into normal mode before
+				if (iBURType != EBURNormal && iBURType != EBURUnset)
+					{
+					__LOG2("CDataOwnerManager::SetBURModeL() - *Error: BUR type has not transitioned between modes correctly, %d became %d", iBURType, aBURType);
+					User::Leave(KErrCorrupt);
+					}
+				break;
+			} // switch
+			
+		TBURPartType previousBURType = iBURType;	 
+		
+		// Need to reset the list of data owners, and old style babackup
+		if ((aBURType == EBURNormal) || (aBURType == EBURUnset))
+			{
+			__LOG1("CDataOwnerManager::SetBURModeL() - Going Normal/Unset/NoBackup (%d)", aBURType);
+			// If we've transitioned from a Restore to a Normal mode, we need to send a RestoreComplete
+			if (previousBURType == EBURRestoreFull || previousBURType == EBURRestorePartial) 
+				{
+				__LOG("CDataOwnerManager::SetBURModeL() - Calling RestoreCompleteL on all active data owners");
+				TInt restoreCompleteCount = iDataOwners.Count();
+
+				for (TInt index = 0; index < restoreCompleteCount; index++)
+					{
+					// Start data owning process if necessary for active data owners
+					TRAP_IGNORE(iDataOwners[index]->DataOwner().RestoreCompleteL());
+					}
+					
+				// Do we need to reset the device
+				if (iResetAfterRestore)
+					{
+					//
+					// Currently there is no Symbian wide way to reset a device. The below call
+					// was intended to perform this function but has not been implemented. 
+					//
+					// When/If a Symbian way to reset a device comes into existance, or a licencee
+					// has specific reset calls then this is the location to add such code.
+					//
+					//UserSvr::ResetMachine(EStartupWarmReset);
+					} // if
+				}
+
+			iResetAfterRestore = EFalse;
+			iDataOwners.ResetAndDestroy();
+			iPackageDataOwners.ResetAndDestroy();
+			__LOG("CDataOwnerManager::SetBURModeL() - Restart All Non-System Applications");
+			iBaBackupSession->NotifyBackupOperationL(TBackupOperationAttributes(MBackupObserver::ETakeLock, MBackupOperationObserver::EEnd));
+			iBaBackupSession->RestartAll();
+			}
+		else
+			{
+			// Check that SWInstall are not doing anything.
+			TInt value;
+			TInt regErr = RProperty::Get(KUidSystemCategory, Swi::KUidSoftwareInstallKey, value);
+			if (regErr == KErrNone && value != Swi::ESwisNone)
+				{
+				__LOG("CDataOwnerManager::SetBURModeL() - *Error: Leave software Install in progress.");
+				User::Leave(KErrInUse);
+				} // if
+			else if (regErr != KErrNotFound && regErr != KErrNone)
+				{
+				__LOG("CDataOwnerManager::SetBURModeL() - *Error: Leave could not get KUidSoftwareInsallKey");
+				User::Leave(regErr);
+				} // else	
+			
+			// Clobber files that are locked open
+			TRequestStatus status;
+			__LOG("CDataOwnerManager::SetBURModeL() - Calling CloseAll()");
+			if(aBURType == EBURBackupFull || aBURType == EBURBackupPartial)
+ 				{
+ 				TBackupOperationAttributes atts(MBackupObserver::EReleaseLockReadOnly, MBackupOperationObserver::EStart);
+ 				iBaBackupSession->NotifyBackupOperationL(atts);		 		 		 
+ 				iBaBackupSession->CloseAll(MBackupObserver::EReleaseLockReadOnly, status);
+ 				}
+ 			else
+ 				{
+ 				TBackupOperationAttributes atts(MBackupObserver::EReleaseLockNoAccess, MBackupOperationObserver::EStart);
+ 				iBaBackupSession->NotifyBackupOperationL(atts);		 		 		 
+ 				iBaBackupSession->CloseAll(MBackupObserver::EReleaseLockNoAccess, status);
+ 				}
+ 		 	User::WaitForRequest(status);
+ 		 	
+			__LOG("CDataOwnerManager::SetBURModeL() - CloseAll() returned");
+			
+			// update partial state for active data owners
+			if (aBURType == EBURBackupPartial)
+				{
+				UpdateDataOwnersPartialStateL();
+				}
+				
+			if (aBURType == EBURBackupPartial || aBURType == EBURBackupFull)
+				{
+				TInt doCount = iDataOwners.Count();
+				for (TInt index = 0; index < doCount; index++)
+					{
+					// Start data owning process if necessary for active data owners
+					TRAPD(err, iDataOwners[index]->DataOwner().StartProcessIfNecessaryL());
+					if (err != KErrNone)
+						{
+						__LOG2("CDataOwnerManager::SetBURModeL() - Data owner (or proxy) with SID 0x%08x errored (%d) whilst starting", iDataOwners[index]->SecureId().iId, err);
+						}
+					}
+				}
+			}
+		
+		TInt setError = RProperty::Set(TUid::Uid(KUidSystemCategoryValue), KUidBackupRestoreKey, aBURType | aBackupIncType);
+		__LOG3("CDataOwnerManager::SetBURModeL() - Setting P&S flag to BURType (0x%08x), IncType (0x%08x), err: ", aBURType, aBackupIncType, setError);
+		User::LeaveIfError(setError);
+		
+		// This configurable delay allows extra time to close all non-system apps.
+		TUint closeDelay = iConfig->AppCloseDelay();
+	 	if((closeDelay>0) && (aBURType == EBURBackupFull || aBURType == EBURBackupPartial || 
+	 	                      aBURType == EBURRestoreFull || aBURType == EBURRestorePartial))
+			{
+			User::After(closeDelay);
+			}
+		
+		iDriveList = aDriveList;
+		iBURType = aBURType;
+		iIncType = aBackupIncType;
+		
+		//When we set back to normal mode, invalidate all current available
+		//CABSessions,since they could not be used in sequent backup/restore event
+		if (aBURType == EBURUnset || aBURType == EBURNormal) 
+			{
+			__LOG1("Invalidate all ABSessions after set Setting P&S flag to 0x%08x", aBURType);
+			ipABServer->InvalidateABSessions();
+			}
+		}
+
+	
+	void CDataOwnerManager::GetDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners)
+	/** Gets the Information about data owners
+	
+	@param aDataOwners on return the list of data owners
+	*/
+		{
+		if (iBURType != EBURNormal && iBURType != EBURUnset)
+			{
+			__LOG("CDataOwnerManager::GetDataOwnersL() - *Error: ListOfDataOnwers called when device isn't in Normal/Unset mode");
+			User::Leave(KErrAccessDenied);
+			}
+			
+		// Build the list of dataOwners
+		FindDataOwnersL();
+		Swi::RSisRegistrySession registrySession;
+		User::LeaveIfError(registrySession.Connect());
+		CleanupClosePushL(registrySession);
+		
+		TInt err = KErrNone;
+		TUint count = iDataOwners.Count();
+		// Loop throught the list
+		while(count--)
+			{
+			CDataOwnerContainer* pContainer = iDataOwners[count];
+			CDataOwner& dataOwner = pContainer->DataOwner();
+			TSecureId secureId = pContainer->SecureId();
+			
+			// forwards declarations
+			TDriveList driveList;
+			driveList.SetMax();
+			
+			TCommonBURSettings commonSettings = ENoOptions;
+			
+			// parse registration files
+			TRAP(err, dataOwner.ParseFilesL());
+			if (err != KErrNone)
+				{
+				__LOG2("CDataOwnerManager::GetDataOwnersL() - ParseFilesL() - Error in sid: 0x%08x (%d)", secureId.iId, err);
+				} // if
+			else
+				{
+				// Reset the state for these data owners
+				TRAP(err, dataOwner.BuildDriveStateArrayL());
+				if (err != KErrNone)
+					{
+					__LOG2("CDataOwnerManager::GetDataOwnersL() - BuildDriveStateArrayL() - Error in sid: 0x%08x (%d)", secureId.iId, err);
+					}//if
+				else 
+					{
+					// Get drive list (this is needed to update drive list for packages)
+					TRAP(err, dataOwner.GetDriveListL(driveList));
+					if (err != KErrNone)
+						{
+						__LOG2("CDataOwnerManager::GetDataOwnersL() - GetDriveListL() - Error in sid: 0x%08x (%d)", secureId.iId, err);
+						}//if		
+					else
+						{
+						TRAP(err, commonSettings = dataOwner.CommonSettingsL());
+						if (err != KErrNone)
+							{
+							__LOG2("CDataOwnerManager::GetDataOwnersL() - CommonSettingsL() - Error in sid: 0x%08x (%d)", secureId.iId, err);
+							}//if		
+						}//else
+					}
+				}//else
+			
+			CSBGenericDataType* pId = NULL;
+			if (err == KErrNone)
+				{
+				// check if the sid is part of the package
+				if ((commonSettings & EHasSystemFiles) == EHasSystemFiles)
+					{
+					Swi::CSisRegistryPackage* pRegistryPackage = NULL;
+					TRAPD(error, pRegistryPackage = registrySession.SidToPackageL(secureId));
+					if ((error == KErrNone))
+						{
+						TUid packageUid = pRegistryPackage->Uid();
+						__LOG2("CDataOwnerManager::GetDataOwnersL() - Found package for secure id 0x%08x, package id 0x%08x", secureId.iId, packageUid);
+						
+						CleanupStack::PushL(pRegistryPackage);
+						pId = CSBPackageId::NewL(packageUid, secureId, pRegistryPackage->Name());
+						CleanupStack::PopAndDestroy(pRegistryPackage);
+						CleanupStack::PushL(pId);
+						
+						// finds or adds package to the internal array
+						CPackageDataTransfer* pak = FindPackageDataContainerL(packageUid);
+						//renews the drive list
+						TRAP(err, pak->GetDriveListL(driveList));
+						if (err != KErrNone)
+                            {//Non-removable, ignore this data owner
+                            iDataOwners.Remove(count);
+                            CleanupStack::PopAndDestroy(pId);
+                            continue;
+                            }
+						} // if
+					else
+						{
+						__LOG2("CDataOwnerManager::GetDataOwnersL() - Error(%d) retrieving package data for sid 0x%08x", error, secureId.iId);
+						} // else
+					} // if
+				} // if
+	
+			if (pId == NULL) // not a package or error happend
+				{
+				pId = CSBSecureId::NewL(secureId);
+				CleanupStack::PushL(pId);
+				}	
+				
+			//
+			// dont create it if not required
+			
+			CDataOwnerInfo* pDataOwnerInfo = NULL;			
+			if (err != KErrNone)
+				{
+				// There has been an error create a blank data owner so the PC will now
+				pDataOwnerInfo = CDataOwnerInfo::NewL(pId, ENoOptions, ENoPassiveOptions, 
+													  ENoActiveOptions, driveList);
+				}
+			else
+				{
+				if (commonSettings & EPassiveBUR || commonSettings & EHasSystemFiles || dataOwner.ActiveInformation().iActiveType != EProxyImpOnly || dataOwner.PassiveSettingsL() & EHasPublicFiles)
+					{
+					pDataOwnerInfo = CDataOwnerInfo::NewL(pId, commonSettings, dataOwner.PassiveSettingsL(),
+														dataOwner.ActiveSettingsL(), driveList);
+					}
+				} // else
+			
+			if (pDataOwnerInfo != NULL)
+				{
+				// ownership was trasferred to pDataOwnerInfo
+				CleanupStack::Pop(pId);
+				CleanupStack::PushL(pDataOwnerInfo);	
+				aDataOwners.AppendL(pDataOwnerInfo);
+				CleanupStack::Pop(pDataOwnerInfo);
+				}
+			else
+				{
+				CleanupStack::PopAndDestroy(pId);
+				}
+			} // for
+			
+		// find special case packages which don't have private directories.
+		TRAP_IGNORE(FindImportPackagesL(registrySession, aDataOwners));
+		
+		CleanupStack::PopAndDestroy(&registrySession);
+		
+		if(iJavaDOM)
+			{
+			iJavaDOM->GetDataOwnersL(aDataOwners);
+			}
+		else
+			{
+			__LOG("CDataOwnerManager::GetDataOwnersL() - Java Backup-Restore Plug-In not loaded, java files won't be backed or restored");
+			}
+		}		
+		
+	CDataOwner& CDataOwnerManager::DataOwnerL(TSecureId aSID)
+	/**
+	Called by the ABServer when creating a session in order for the session to query the DataOwner
+	
+	@param aSID The SID of the active data owner
+	*/
+		{
+		CDataOwnerContainer* pDOContainer = NULL;
+		
+		pDOContainer = FindL(aSID);
+
+		if (!pDOContainer)
+			{
+			User::Leave(KErrNotFound);
+			}
+
+		return pDOContainer->DataOwner();
+		}
+
+	void CDataOwnerManager::GetExpectedDataSizeL(CSBGenericTransferType* apGenericTransferType, TUint& aSize)
+	/** Gets the expected data size of a backup for the given information
+
+	@param apGenericTransferType the generic transfer type
+	@param aSize on return the expected data size of the backup
+	@post deletes the apGenericTransferType
+	@leave KErrNotSupported unsupported transfer type
+	@leave KErrNotFound object relating to apGenericTransferType not found
+	*/
+		{
+		if (iBURType != EBURBackupPartial && iBURType != EBURBackupFull)
+			{
+			__LOG("CDataOwnerManager::GetExpectedDataSizeL() - *Error: GetExpectedDataSizeL called when device is not in Backup mode !");
+			User::Leave(KErrAccessDenied);
+			}
+			
+		switch (apGenericTransferType->DerivedTypeL())
+			{
+			case ESIDTransferDerivedType:
+				{
+				__LOG("CDataOwnerManager::GetExpectedDataSizeL() - ESIDTransferDerivedType");
+				CSBSIDTransferType* pSIDTransferType = CSBSIDTransferType::NewL(apGenericTransferType);
+				CleanupStack::PushL(pSIDTransferType);
+				
+				DataOwnerL(pSIDTransferType->SecureIdL()).GetExpectedDataSizeL(pSIDTransferType->DataTypeL(), pSIDTransferType->DriveNumberL(), aSize);
+				CleanupStack::PopAndDestroy(pSIDTransferType);
+				break;
+				};
+			case EPackageTransferDerivedType:
+				{
+				__LOG("CDataOwnerManager::GetExpectedDataSizeL() - EPackageTransferDerivedType");
+
+				// This code should be changed.  Ideally, the GetExpectedDataSizeL method should be virtual, rendering 
+				// this switch statement unnecessary.  When java support is added this will become even more important.
+				//
+				// For the moment, to avoid re-structuring the data owner class, 
+				// we are using completely separate classes to handle packages and non packages
+				
+				CSBPackageTransferType* pPackageTransferType = CSBPackageTransferType::NewL(apGenericTransferType);
+				CleanupStack::PushL(pPackageTransferType);
+				//
+				const TUid packageId = pPackageTransferType->PackageIdL();
+				const TPackageDataType dataType = pPackageTransferType->DataTypeL();
+				const TDriveNumber driveNumber = pPackageTransferType->DriveNumberL();
+				//
+				__LOG3("CDataOwnerManager::GetExpectedDataSizeL() - package id: 0x%08x, dataType: %d, drive: %c ", packageId.iUid, dataType, driveNumber + 'A');
+				CPackageDataTransfer* pDataTransfer = FindPackageDataContainerL(pPackageTransferType->PackageIdL());
+				pDataTransfer->GetExpectedDataSizeL(dataType, driveNumber, aSize);
+				CleanupStack::PopAndDestroy(pPackageTransferType);
+				break;
+				}
+
+			case EJavaTransferDerivedType:
+				{
+				__LOG("CDataOwnerManager::GetExpectedDataSizeL() - EJavaTransferDerivedType");
+
+				// Call the Java DOM to calculate and return the expected size of the data specified in 
+				// apGenericTransferType
+				if(iJavaDOM)
+					{
+					iJavaDOM->GetExpectedDataSizeL(apGenericTransferType, aSize);
+					}
+				else
+					{
+					__LOG("CDataOwnerManager::GetExpectedDataSizeL() - Java Backup-Restore Plug-In not loaded, java files won't be backed or restored");
+					}
+
+				break;
+				}
+
+			default:
+				{
+				__LOG("CDataOwnerManager::GetExpectedDataSizeL() - ERROR - unsupported transfer type");
+				User::Leave(KErrNotSupported);
+				}
+			} // switch
+		__LOG1("CDataOwnerManager::GetExpectedDataSizeL() - END - size is: %d", aSize);
+		}
+
+
+	void CDataOwnerManager::GetPublicFileListL(CSBGenericDataType* aGenericDataType, 
+											   TDriveNumber aDriveNumber,
+											   RFileArray& aFiles)
+	/** Retreives the public file list for the given secure id
+
+	@param aSID 			the Secure Id of the data owner you are requesting information for
+	@param aDriveNumber		the drive number to obtain the public files for
+	@param aFiles			on return the list of public files
+	*/
+		{
+		if (iBURType != EBURBackupPartial && iBURType != EBURBackupFull)
+			{
+			__LOG("CDataOwnerManager::GetPublicFileListL() - *Error: GetPublicFileListL called when device is not in Backup mode !");
+			User::Leave(KErrAccessDenied);
+			}
+		
+		if (!(iDriveList[aDriveNumber]))
+			{
+			__LOG("CDataOwnerManager::GetPublicFileListL() - The drive in the argument is not in the list of the drives for backup/restore");
+			User::Leave(KErrArgument);
+			}
+		
+		switch (aGenericDataType->DerivedTypeL())
+			{
+			case EPackageDerivedType:
+				{
+				CSBPackageId* pUID = CSBPackageId::NewL(aGenericDataType);
+				CleanupStack::PushL(pUID);
+				
+				FindPackageDataContainerL(pUID->PackageIdL())->GetPublicFileListL(aDriveNumber, aFiles);
+				CleanupStack::PopAndDestroy(pUID);
+				break;
+				}
+			case ESIDDerivedType:
+				{
+				CSBSecureId* pSID = CSBSecureId::NewL(aGenericDataType);
+				CleanupStack::PushL(pSID);
+				
+				DataOwnerL(pSID->SecureIdL()).GetPublicFileListL(aDriveNumber, aFiles);
+				CleanupStack::PopAndDestroy(pSID);
+				break;
+				}
+
+			case EJavaDerivedType:
+				{
+				if(iJavaDOM)
+					{
+					iJavaDOM->GetPublicFileListL(aGenericDataType, aDriveNumber, aFiles);
+					}
+				else
+					{
+					__LOG("CDataOwnerManager::GetPublicFileListL() - Java Backup-Restore Plug-In not loaded, java files won't be backed or restored");
+					}
+				break;
+				}
+
+			default:
+				{
+				User::Leave(KErrNotSupported);
+				}
+			}
+		}
+
+		
+    void CDataOwnerManager::GetRawPublicFileListL(CSBGenericDataType* aGenericDataType, TDriveNumber aDriveNumber, 
+    						   					  RRestoreFileFilterArray& aFileFilter)
+	/** Retrieves the raw list as described in the XML files
+	
+	@param aSID the secure id
+	@param aDriveNumber the drive number
+	@param aFileFilter on return an array of TRestoreFileFilter
+	*/
+		{
+		if (iBURType != EBURBackupPartial && iBURType != EBURBackupFull)
+			{
+			__LOG("CDataOwnerManager::GetRawPublicFileListL() - *Error: GetRawPublicFileListL called when device is not in Backup mode !");
+			User::Leave(KErrAccessDenied);
+			}
+			
+		if (!(iDriveList[aDriveNumber]))
+			{
+			__LOG("CDataOwnerManager::GetRawPublicFileListL() - The drive in the argument is not in the list of the drives for backup/restore");
+			User::Leave(KErrArgument);
+			}
+		
+		switch (aGenericDataType->DerivedTypeL())
+			{
+			case EPackageDerivedType:
+				{
+				CSBPackageId* pUID = CSBPackageId::NewL(aGenericDataType);
+				CleanupStack::PushL(pUID);
+				
+				FindPackageDataContainerL(pUID->PackageIdL())->GetRawPublicFileListL(aDriveNumber, aFileFilter);
+				CleanupStack::PopAndDestroy(pUID);
+				break;
+				}
+			case ESIDDerivedType:
+				{
+				CSBSecureId* pSID = CSBSecureId::NewL(aGenericDataType);
+				CleanupStack::PushL(pSID);
+				
+				DataOwnerL(pSID->SecureIdL()).GetRawPublicFileListL(aDriveNumber, aFileFilter);
+
+				CleanupStack::PopAndDestroy(pSID);
+				break;
+				}
+
+			case EJavaDerivedType:
+				{
+				if(iJavaDOM)
+					{
+					iJavaDOM->GetRawPublicFileListL(aGenericDataType, aDriveNumber, aFileFilter);
+					}
+				else
+					{
+					__LOG("CDataOwnerManager::GetRawPublicFileListL() - Java Backup-Restore Plug-In not loaded, java files won't be backed or restored");
+					}
+				break;
+				}
+
+			default:
+				{
+				User::Leave(KErrNotSupported);
+				}
+			}
+		}
+    	
+    	
+    void CDataOwnerManager::GetXMLPublicFileListL(TSecureId /*aSID*/, TDriveNumber /*aDriveNumber*/, 
+    											  HBufC*& /*aBuffer*/)
+	/** Gets the XML public file list
+	
+	@param aSID the secure id
+	@param aDriveNumber the drive number
+	@param aBuffer the buffer to write the data too
+	
+	*/
+    	{
+    	if (iBURType != EBURBackupPartial && iBURType != EBURBackupFull)
+			{
+			__LOG("CDataOwnerManager::GetXMLPublicFileListL() - *Error: GetXMLPublicFileListL called when device is not in Backup mode !");
+			User::Leave(KErrAccessDenied);
+			}
+		else 
+			{
+			//will need to check if the drive exists in our list
+			__LOG("CDataOwnerManager::GetXMLPublicFileListL() - *Error: GetXMLPublicFileListL Not Yet Implemented");
+			User::Leave(KErrNotSupported);
+			}
+    	}
+    	
+	void CDataOwnerManager::SetSIDListForPartialBURL(TDesC8& aFlatArrayPtr)
+	/**
+	Sets the list of Active SID's participating in a backup or restore
+	
+	@param aFlatArrayPtr Flat Array Pointer
+	*/
+		{
+		if (iBURType != EBURNormal && iBURType != EBURUnset)
+			{
+			__LOG("CDataOwnerManager::SetSIDListForPartialBURL() - *Error: called when device isn't in Normal/Unset mode");
+			User::Leave(KErrAccessDenied);
+			}
+		
+		if (iSIDListForPartial != NULL)
+			{
+			iSIDListForPartial->Close();
+			delete iSIDListForPartial;
+			iSIDListForPartial = NULL;
+			}
+			
+		iSIDListForPartial = RSIDArray::InternaliseL(aFlatArrayPtr);
+		}
+	
+	void CDataOwnerManager::UpdateDataOwnersPartialStateL()
+	/**
+	Specifies the list of SID's that are to be backed up in a partial backup
+	
+	*/
+		{
+		if (iSIDListForPartial != NULL)
+			{
+			TUint count = iSIDListForPartial->Count();
+			
+			while(count--)
+				{
+				// Find the data owner responsible for this SID and set it's partial backup flag to ETrue
+				DataOwnerL((*iSIDListForPartial)[count]).SetBackedUpAsPartial(ETrue);
+				} // for
+			} // if
+		}
+	
+	void CDataOwnerManager::SIDStatusL(RSIDStatusArray& aSIDStatus)
+	/**
+	Returns the ready statuses of selected Data Owner's
+	
+	@param aSIDStatus Array of SID's and their associated statuses. The statuses will be populated upon return
+	*/
+		{
+		if (iBURType == EBURNormal || iBURType == EBURUnset)
+			{
+			__LOG("CDataOwnerManager::SIDStatusL() - *Error: called when device is in Normal/Unset mode");
+			User::Leave(KErrAccessDenied);
+			}
+			
+		TUint count = aSIDStatus.Count();
+		CDataOwnerContainer* pDOContainer = NULL;
+		
+		while(count--)
+			{
+			pDOContainer = FindL(aSIDStatus[count].iSID);
+			if (!pDOContainer)
+				{
+				aSIDStatus[count].iStatus = EDataOwnerNotFound;
+				}
+			else
+				{
+				// Assign the status of the data owner to the array element
+				aSIDStatus[count].iStatus = pDOContainer->DataOwner().ReadyState();
+				}
+			}
+		}
+		
+	void CDataOwnerManager::AllSnapshotsSuppliedL()
+	/**
+	All the snapshots have been supplied
+	*/
+		{
+		__LOG("CDataOwnerManager::AllSnapshotsSuppliedL() - Begin");
+		if (iBURType == EBURBackupPartial || iBURType == EBURBackupFull)
+			{
+			TUint count = iDataOwners.Count();
+			while(count--)
+				{
+				CDataOwner* dataOwner = &iDataOwners[count]->DataOwner();
+				if (dataOwner->PartialAffectsMe() && dataOwner->ActiveInformation().iActiveDataOwner && (dataOwner->ActiveInformation().iActiveType != EProxyImpOnly))
+					{
+					TSecureId id = dataOwner->SecureId();
+					const TUint KActiveStateMaxRetries = 4;
+					const TUint KActiveStateDelay = 500000;
+					TUint retries = 0;
+					do
+						{
+						TRAPD(err, ipABServer->AllSnapshotsSuppliedL(id));
+						if (err == KErrNotFound)
+							{
+							retries++;
+							User::After(KActiveStateDelay);
+							}
+						else
+							{
+							break;
+							}
+						} while (retries < KActiveStateMaxRetries);
+					} // if
+				} // while
+			} //if
+		else 
+			{
+			__LOG("CDataOwnerManager::AllSnapshotsSuppliedL() - *Error: can only be called in Backup mode");
+			User::Leave(KErrAccessDenied);
+			} // else
+		__LOG("CDataOwnerManager::AllSnapshotsSuppliedL() - End");
+		}
+
+	void CDataOwnerManager::GetNextPublicFileL(CSBGenericDataType* aGenericDataType,
+											   TBool aReset,
+	                           				   TDriveNumber aDriveNumber,
+	                           				   TEntry& aEntry)
+	/** Retreives the next public file associated with the given secure id
+
+	@param aGenericDataType the generic data type
+	@param aReset set true to start reading from the beginning of the list
+	@param aDriveNumber the drive to retrieve the public files for
+	@param aEntry on return the next entry in the list, an empty entry indicates the end of the list has been reached
+	*/
+		{
+		__LOG("CDataOwnerManager::GetNextPublicFileL() - Begin");
+		if (iBURType != EBURBackupPartial && iBURType != EBURBackupFull)
+			{
+			__LOG("CDataOwnerManager::GetNextPublicFileL() - *Error: GetPublicFileListL called when device is not in Backup mode !");
+			User::Leave(KErrAccessDenied);
+			}
+		
+		if (!(iDriveList[aDriveNumber]))
+			{
+			__LOG("CDataOwnerManager::GetNextPublicFileL() - The drive in the argument is not in the list of the drives for backup/restore");
+			User::Leave(KErrArgument);
+			}
+		
+		if (aGenericDataType->DerivedTypeL() == ESIDDerivedType)
+			{
+			CSBSecureId* pSID = CSBSecureId::NewL(aGenericDataType);
+			CleanupStack::PushL(pSID);
+
+			DataOwnerL(pSID->SecureIdL()).GetNextPublicFileL(aReset, aDriveNumber, aEntry);
+			CleanupStack::PopAndDestroy(pSID);
+			}
+		else
+			{
+			User::Leave(KErrNotSupported);
+			}
+		__LOG("CDataOwnerManager::GetNextPublicFileL() - End");
+		}
+
+
+    void CDataOwnerManager::SupplyDataL(CSBGenericTransferType* apGenericTransferType, TDesC8& aBuffer, 
+    				 					TBool aLastSection)
+    /** Supply data
+    
+    @param apGenericTransferType the generic transfertype. NOTE: This function will delete this.
+    @param aBuffer the buffer to supply data from.
+    @param aLastSection is this the last section.
+    @leave KErrNotSupported Unknown transfer type
+    @leave KErrNotFound Unknown object
+    */
+		{
+		__LOG1("CDataOwnerManager::SupplyDataL() - START - about to decompress %d bytes of data", aBuffer.Length());
+
+        if (iBURType == EBURNormal || iBURType == EBURUnset)
+			{
+			__LOG("CDataOwnerManager::SupplyDataL() - *Error: called not when device in Normal/Unset mode");
+			User::Leave(KErrAccessDenied);
+			}
+			
+		// The buffer that we are given is compressed. We need to uncompress this into 
+		// 64K chunks and then pass through the code
+		iDecompressor->SetGenericTransferTypeL(apGenericTransferType);
+		iDecompressor->SetBuffer(aBuffer);
+		TBool moreData = ETrue;
+		
+		// Packages some times need to stop before the data has all been uncompressed.
+		TBool packageContinue = ETrue;
+		
+		HBufC8* uncompressedData = NULL;
+		while (moreData && packageContinue)
+			{
+			uncompressedData = NULL;
+			if (!iDecompressor->NextLC(uncompressedData, moreData))
+				{
+				__LOG("CDataOwnerManager::SupplyDataL() - iDecompressor->NextLC returned EFalse");
+				if (uncompressedData != NULL)
+					{
+					__LOG("CDataOwnerManager::SupplyDataL() - uncompressedData not NULL so cleaning up");
+					CleanupStack::PopAndDestroy(uncompressedData);
+					}
+				break;
+				}
+				
+			if (uncompressedData == NULL)
+				{
+				__LOG("CDataOwnerManager::SupplyDataL() - uncompressedData is NULL after NextLC, corrupt data");
+				User::Leave(KErrCorrupt);
+				}
+			
+			TPtr8 dataPtr(uncompressedData->Des());
+			__LOG1("CDataOwnerManager::SupplyDataL() - decompressed data length: %d", dataPtr.Length());
+			
+			// Check aLastSection
+			TBool lastSection = aLastSection && !moreData;
+			
+			switch(apGenericTransferType->DerivedTypeL())
+				{
+			case ESIDTransferDerivedType:
+				{
+				__LOG("CDataOwnerManager::SupplyDataL() - ESIDTransferDerivedType");
+				CSBSIDTransferType* pSIDTransferType = CSBSIDTransferType::NewL(apGenericTransferType);
+				CleanupStack::PushL(pSIDTransferType);
+				
+				// Is this the data for registration files? These are now not supported
+				if (pSIDTransferType->DataTypeL() == ERegistrationData)
+					{
+					User::Leave(KErrNotSupported);
+					} // if
+				else
+					{
+					// Does this dataowner require a reboot?
+					const TSecureId sid = pSIDTransferType->SecureIdL();
+					const TDriveNumber driveNumber = pSIDTransferType->DriveNumberL();
+					CDataOwner& dataOwner = DataOwnerL(sid);
+					__LOG2("CDataOwnerManager::SupplyDataL() - trying to restore data for SID: 0x%08x, drive: %c", sid.iId, 'A' + driveNumber);
+
+					if ((dataOwner.CommonSettingsL() & ERequiresReboot) == ERequiresReboot)
+						{
+						__LOG1("CDataOwnerManager::SupplyDataL() - data owner 0x%08x requires a REBOOT!", sid.iId);
+						iResetAfterRestore = ETrue;
+						}
+					
+					dataOwner.SupplyDataL(driveNumber, pSIDTransferType->DataTypeL(), dataPtr, lastSection);
+					} // else
+			
+				CleanupStack::PopAndDestroy(pSIDTransferType);
+				break;
+				}
+			case EPackageTransferDerivedType:
+				{
+				__LOG("CDataOwnerManager::SupplyDataL() - EPackageTransferDerivedType");
+				// Ideally, we would use the same CDataOwner class, or a class derived
+				// from it to handle the package backup/restore, however to do this would 
+				// require a re-design.
+				CSBPackageTransferType *pPackageTransferType = CSBPackageTransferType::NewL(apGenericTransferType);
+				CleanupStack::PushL(pPackageTransferType);
+					
+				TUid packageId = pPackageTransferType->PackageIdL();
+					
+				CPackageDataTransfer* pDataTransfer = FindPackageDataContainerL(packageId);
+				pDataTransfer->SupplyDataL(pPackageTransferType->DriveNumberL(), 
+										   pPackageTransferType->DataTypeL(),
+										   dataPtr, lastSection);
+				
+				CleanupStack::PopAndDestroy(pPackageTransferType);
+				break;
+				}
+
+		    case EJavaTransferDerivedType:
+			    { 
+				__LOG("CDataOwnerManager::SupplyDataL() - EJavaTransferDerivedType");
+			   if(iJavaDOM)
+					{
+				    iJavaDOM->SupplyDataL(apGenericTransferType, dataPtr, lastSection);
+					}
+				else
+					{
+					__LOG("CDataOwnerManager::SupplyDataL() - Java Backup-Restore Plug-In not loaded, java files won't be backed or restored");
+					}
+			    break;
+			    }					
+
+            default:
+				{
+				User::Leave(KErrNotSupported);
+				}
+				} // switch
+
+			// Cleanup
+			CleanupStack::PopAndDestroy(uncompressedData);
+			} // while
+		__LOG("CDataOwnerManager::SupplyDataL() - END");
+    	}
+
+
+    void CDataOwnerManager::RequestDataL(CSBGenericTransferType* apGenericTransferType,
+    	    		  					 TPtr8& aBuffer, TBool& aLastSection)
+	/** Request data
+	
+    @param apGenericTransferType the generic transfertype. NOTE: This function will delete this.
+    @param aBuffer the buffer to write data to.
+    @param aLastSection is this the last section.
+    @leave KErrNotSupported Unknown transfer type
+    @leave KErrNotFound Unknown object
+	*/
+    	{
+		__LOG2("CDataOwnerManager::RequestDataL() - START - aBuffer.Ptr(): 0x%08x, aBuffer.Length(): %d", aBuffer.Ptr(), aBuffer.Length());
+    	if (iBURType == EBURNormal || iBURType == EBURUnset)
+			{
+			__LOG("CDataOwnerManager::RequestDataL() - *Error: called when device is in Normal/Unset mode");
+			User::Leave(KErrAccessDenied);
+			}
+			
+		// Reserve space to perform inline compression later
+		CSBECompressAndEncrypt* pCE = CSBECompressAndEncrypt::NewLC(apGenericTransferType, aBuffer);
+		
+		switch(apGenericTransferType->DerivedTypeL())
+			{
+		case ESIDTransferDerivedType:
+			{
+			CSBSIDTransferType* pSIDTransferType = CSBSIDTransferType::NewL(apGenericTransferType);
+			CleanupStack::PushL(pSIDTransferType);
+			TSecureId sid(pSIDTransferType->SecureIdL());
+			DataOwnerL(sid).RequestDataL(pSIDTransferType->DriveNumberL(), 
+												 pSIDTransferType->DataTypeL(),
+												 aBuffer, aLastSection);
+												
+			CleanupStack::PopAndDestroy(pSIDTransferType);
+			break;
+			}
+		case EPackageTransferDerivedType:
+			{
+			CSBPackageTransferType *pPackageTransferType = CSBPackageTransferType::NewL(apGenericTransferType);
+			CleanupStack::PushL(pPackageTransferType);
+			
+			CPackageDataTransfer *packageDataTransfer = 
+				FindPackageDataContainerL(pPackageTransferType->PackageIdL());
+			
+			packageDataTransfer->RequestDataL(pPackageTransferType->DriveNumberL(),
+											  pPackageTransferType->DataTypeL(),
+											  aBuffer, aLastSection);
+			
+			CleanupStack::PopAndDestroy(pPackageTransferType);
+					
+			break;	 
+			}
+
+		case EJavaTransferDerivedType:
+			{
+			if(iJavaDOM)
+				{
+				iJavaDOM->RequestDataL(apGenericTransferType, aBuffer, aLastSection);
+				}
+			else
+				{
+				__LOG("CDataOwnerManager::RequestDataL() - Java Backup-Restore Plug-In not loaded, java files won't be backed or restored");
+				}
+			break;
+			}
+
+		default:
+			{
+			User::Leave(KErrNotSupported);
+			}
+			} // switch
+			
+		// Compress the data block
+		if (aBuffer.Size() > 0) // Dont compress no data
+			{
+		    __LOG1("CDataOwnerManager::RequestDataL() - got %d bytes of uncompressed data, about to pack it...", aBuffer.Length());
+			pCE->PackL(aBuffer);
+			}
+		else
+			{
+		    __LOG1("CDataOwnerManager::RequestDataL() - got %d bytes of uncompressed data, free reserved space...", aBuffer.Length());
+			pCE->FreeReservedSpace(aBuffer);
+			}
+		
+		
+		CleanupStack::PopAndDestroy(pCE);
+		__LOG("CDataOwnerManager::RequestDataL() - End");
+    	}
+	                     
+	// Accessors
+	void CDataOwnerManager::SetActiveBackupServer(CABServer* aABServer)
+		{
+		ipABServer = aABServer;
+		}
+		
+	RFs& CDataOwnerManager::GetRFs()
+		{
+		return iFs;
+		}
+
+	// PRIVATE //
+	/** Searches for registration files in Import Directories
+	
+	@param aDataOwners appended list of data owners infos
+	
+	*/
+	void CDataOwnerManager::FindImportPackagesL(Swi::RSisRegistrySession& aRegistry, RPointerArray<CDataOwnerInfo>& aDataOwners)
+		{
+		__LOG("CDataOwnerManager::FindImportPackagesL() - Begin");
+		CDesCArray* files = new(ELeave) CDesCArrayFlat(KDesCArrayGranularity);
+		CleanupStack::PushL(files);
+		FindRegistrationFilesL(KImportDir, *files);
+		const TInt count = files->Count();
+		
+		RSisRegistryEntry entry;
+		CleanupClosePushL(entry);
+		
+		for (TInt x = 0; x < count; x++)
+			{
+			// Strip the SID
+			TSecureId sid;
+			const TDesC& fileName = (*files)[x];
+			TRAPD(err, StripSecureIdL(fileName, sid));
+			
+			if (err == KErrNone) // If there was an error then ignore it as it is probally not a dir
+				{	
+				err = entry.Open(aRegistry, sid);
+				if (err == KErrNone)
+					{
+					__LOG2("CDataOwnerManager::FindImportPackagesL() - found reg file: %S for Package: 0x%08x", &fileName, sid.iId);
+					CPackageDataTransfer* pDataTransfer = FindPackageDataContainerL(sid);
+					
+					TRAP(err, pDataTransfer->SetRegistrationFileL(fileName));
+					if (err == KErrNone)
+						{
+						TRAP(err, pDataTransfer->ParseL());	
+						}
+					if (err == KErrNoMemory)
+						{
+						User::Leave(KErrNoMemory);
+						}
+					// create generic data type
+					HBufC* pkgName = entry.PackageNameL();
+					CleanupStack::PushL(pkgName);
+					CSBGenericDataType* pId = CSBPackageId::NewL(sid, KDummyId, *pkgName);
+					CleanupStack::PopAndDestroy(pkgName);
+					CleanupStack::PushL(pId);
+					
+					TDriveList driveList;
+					TRAP(err, pDataTransfer->GetDriveListL(driveList));
+					if (err != KErrNone)
+					    {//Non-removable, ignore this data owner
+						CleanupStack::PopAndDestroy(pId);
+						continue;
+					    }
+					// create a data owner info
+					CDataOwnerInfo* pDataOwnerInfo = CDataOwnerInfo::NewL(pId, pDataTransfer->CommonSettingsL(),
+														  pDataTransfer->PassiveSettingsL(), pDataTransfer->ActiveSettingsL(),
+														  driveList);
+					CleanupStack::PushL(pDataOwnerInfo);
+					aDataOwners.AppendL(pDataOwnerInfo);
+					CleanupStack::Pop(pDataOwnerInfo);
+					
+					CleanupStack::Pop(pId);
+					
+					/*
+					 * Check wheahter Package has public files or not. If yes then add the SID dataowner to process public files.					 * 
+					 */
+					TPassiveBURSettings passiveBURSettings = ENoPassiveOptions;
+					TRAPD( passiveErr, passiveBURSettings = pDataTransfer->PassiveSettingsL());
+					
+					if ( passiveErr == KErrNone && EHasPublicFiles & passiveBURSettings )
+						{
+						CDataOwnerContainer* pDataOwner = FindL(sid);
+						if (pDataOwner == NULL)  // If it does not exist we need to create it
+							{
+							__LOG1("CDataOwnerManager::FindImportPackagesL() - Package has the public files for SID: 0x%08x", sid.iId);
+	
+							pDataOwner = CDataOwnerContainer::NewL(sid, this);
+							CleanupStack::PushL(pDataOwner);
+							
+							iDataOwners.InsertInOrder(pDataOwner, CDataOwnerContainer::Compare);
+							CleanupStack::Pop(pDataOwner);										
+							} // if
+						else
+							{
+							__LOG1("CDataOwnerManager::FindImportPackagesL() - SID already exists in the list SID: 0x%08x", sid.iId);
+							}
+	
+						TRAP_IGNORE(pDataOwner->DataOwner().AddRegistrationFilesL(fileName));					
+						
+						// forwards declarations
+						TDriveList driveList;
+						driveList.SetMax();
+						
+												
+						// parse registration files
+						TRAP(err, pDataOwner->DataOwner().ParseFilesL());
+						if (err != KErrNone)
+							{
+							__LOG2("CDataOwnerManager::GetDataOwnersL() - ParseFilesL() - Error in sid: 0x%08x (%d)", sid.iId, err);
+							} // if
+						else
+							{
+							// Reset the state for these data owners
+							TRAP(err, pDataOwner->DataOwner().BuildDriveStateArrayL());
+							if (err != KErrNone)
+								{
+								__LOG2("CDataOwnerManager::GetDataOwnersL() - BuildDriveStateArrayL() - Error in sid: 0x%08x (%d)", sid.iId, err);
+								}//if
+							else 
+								{
+								// Get drive list (this is needed to update drive list for packages)
+								TRAP(err, pDataOwner->DataOwner().GetDriveListL(driveList));
+								if (err != KErrNone)
+									{
+									__LOG2("CDataOwnerManager::GetDataOwnersL() - GetDriveListL() - Error in sid: 0x%08x (%d)", sid.iId, err);
+									}//if		
+								else
+									{
+									TRAP(err, pDataOwner->DataOwner().CommonSettingsL());
+									if (err != KErrNone)
+										{
+										__LOG2("CDataOwnerManager::GetDataOwnersL() - CommonSettingsL() - Error in sid: 0x%08x (%d)", sid.iId, err);
+										}//if		
+									}//else
+								}
+							}//else
+							
+						} // if EHasPublicFiles & passiveBURSettings
+						
+					} //if
+				entry.Close();
+				} // if
+				
+			if (err != KErrNone)
+				{
+				__LOG1("CDataOwnerManager::FindImportPackagesL() - cannot get Package UID for reg file: %S", &fileName);
+				
+				CSBGenericDataType* pId = CSBPackageId::NewL(sid, KDummyId, KNullDesC);
+				CleanupStack::PushL(pId);
+				TDriveList driveList;
+				driveList.SetLength(driveList.MaxLength());
+				driveList.FillZ();
+				CDataOwnerInfo* pDataOwnerInfo = CDataOwnerInfo::NewL(pId, ENoOptions, ENoPassiveOptions, 
+													  ENoActiveOptions, driveList);
+				CleanupStack::PushL(pDataOwnerInfo);
+				aDataOwners.AppendL(pDataOwnerInfo);
+				CleanupStack::Pop(pDataOwnerInfo);
+					
+				CleanupStack::Pop(pId);
+				} // if
+				
+				
+			} // for x
+			
+			
+		CleanupStack::PopAndDestroy(&entry);
+		
+		CleanupStack::PopAndDestroy(files);
+		__LOG("CDataOwnerManager::FindImportPackagesL() - End");
+		}
+	
+	void CDataOwnerManager::FindRegistrationFilesL(const TDesC& aPath, CDesCArray& aFiles)
+	/** Searches the device for registration files
+
+	@param aFiles on return a list of registration files on the device
+	*/
+		{
+		__LOG("CDataOwnerManager::FindRegistrationFilesL() - START");
+		
+		// Find private directorys
+		TFindFile findDir(iFs);
+		CDir* pDir = NULL;
+		TInt errD = findDir.FindWildByDir(KStar, aPath, pDir);
+		while (errD == KErrNone)
+			{
+			CleanupStack::PushL(pDir);
+			
+			// Loop through the directorys and look for registration files
+			TUint dirCount = pDir->Count();
+			while(dirCount--)
+				{
+				const TEntry& dirEntry = (*pDir)[dirCount];
+				if (dirEntry.IsDir())
+					{
+					// Full path of dir
+					TParse path;
+					path.Set(dirEntry.iName, &findDir.File(), NULL);
+					
+					// See if there are any backup registration files
+					TFindFile findFile(iFs);
+					CDir* pFile = NULL;
+					TFileName fullPath(path.FullName());
+					fullPath.Append(KPathDelimiter);
+					TInt errF = findFile.FindWildByPath(KBackupRegistrationFile, &fullPath, pFile);
+					if (errF == KErrNone) // Where registration files found?
+						{
+						CleanupStack::PushL(pFile);
+						// Add to the list of registration files
+						TUint fileCount = pFile->Count();
+						while(fileCount--)
+							{
+							path.Set((*pFile)[fileCount].iName, &findFile.File(), NULL);
+							__LOG1("CDataOwnerManager::FindRegistrationFilesL() - found file: %S", &path.FullName());
+							aFiles.AppendL(path.FullName());
+							} // for y
+						
+						// Cleanup
+						CleanupStack::PopAndDestroy(pFile);
+						} // if
+					} // if
+				} // for x
+			
+			// Cleanup
+			CleanupStack::PopAndDestroy(pDir);
+						
+			// Check next drive
+			errD = findDir.FindWild(pDir);
+			} // while
+		
+		__LOG1("CDataOwnerManager::FindRegistrationFilesL() - END - total files %d", aFiles.Count());
+		}
+
+	CDataOwnerContainer* CDataOwnerManager::FindL(TSecureId aSID)
+	/** Finds a data owner in the array given a secure id
+
+	@param aSID 			the Secure Id of the data owner you want
+	@leave KErrNotFound		no such secure id
+	*/
+		{
+		CDataOwnerContainer* tempCont = CDataOwnerContainer::NewL(aSID, this);
+		TInt res = iDataOwners.Find(tempCont, CDataOwnerContainer::Match);
+		delete tempCont;
+		
+		if (res == KErrNotFound)
+			{
+			return NULL;
+			}
+		else
+			{
+			return iDataOwners[res];
+			}
+		}
+		
+
+	CPackageDataTransfer* CDataOwnerManager::FindPackageDataContainerL(TUid aPid)
+	/** Finds the package data container
+	
+	@param aPid The process id
+	*/
+		{
+		CPackageDataTransfer* pPackageTransfer = CPackageDataTransfer::NewL(aPid, this);
+		CleanupStack::PushL(pPackageTransfer);
+		TInt res = iPackageDataOwners.Find(pPackageTransfer, CPackageDataTransfer::Match);
+		if (res == KErrNotFound)
+			{
+			User::LeaveIfError(iPackageDataOwners.InsertInOrder(pPackageTransfer, CPackageDataTransfer::Compare));
+			CleanupStack::Pop(pPackageTransfer);
+			return pPackageTransfer;
+			}
+		else
+			{
+			CleanupStack::PopAndDestroy(pPackageTransfer);
+			return iPackageDataOwners[res];
+			}
+		}
+
+	void CDataOwnerManager::StripSecureIdL(const TDesC& aStrip, TSecureId& aSecureId)
+	/** Strips a Secure Id from a text string
+
+	Looks for a "//private//" directory in the string and strips the SID after it.
+	*/
+		{
+		
+		TInt start = aStrip.FindF(KImportDir);
+		if (start == KErrNotFound)
+			{
+			start = aStrip.FindF(KPrivate);
+			if (start == KErrNotFound)
+				{
+				User::Leave(KErrArgument);
+				}
+			start += KPrivate().Length();
+			}
+		else
+			{
+			start += KImportDir().Length();
+			}
+			
+		// Find the end of the SID
+		TInt end = (aStrip.Right(aStrip.Length() - start)).FindF(KBackSlash);
+		end += start;
+		
+		// Create the secure Id
+		TLex sIdLex(aStrip.Mid(start, end - start + 1));
+		// If we cant do the convert then ignore as it is a directory that is not a SID.
+		if (sIdLex.Val(aSecureId.iId, EHex) != KErrNone)
+			{
+			User::Leave(KErrArgument);
+			}
+		}
+
+	
+	void CDataOwnerManager::FindDataOwnersL()
+	/** Gets a list of data owners
+
+	This list only contains the Secure ID's for applications that have a backup 
+	registration files.
+	*/
+		{
+		__LOG("CDataOwnerManager::FindDataOwnersL() - Begin");
+		// Clear out any current list
+		iDataOwners.ResetAndDestroy();
+		
+		// Find all registration files on the device
+		CDesCArray* registrationFiles = new(ELeave) CDesCArrayFlat(KDesCArrayGranularity);
+		CleanupStack::PushL(registrationFiles);
+		FindRegistrationFilesL(KPrivate, *registrationFiles);
+		__LOG(" ");
+		
+		// Add registration files to iDataOwners
+		const TInt count = registrationFiles->Count();
+		for (TInt x = 0; x < count; x++)
+			{
+			// Strip the SID
+			TSecureId sid;
+			const TDesC& fileName = (*registrationFiles)[x];
+			TRAPD(err, StripSecureIdL(fileName, sid));
+			if (err == KErrNone) // If there was an error then ignore it as it is probally not a dir
+				{
+				CDataOwnerContainer* pDataOwner = FindL(sid);
+				if (pDataOwner == NULL)  // If it does not exist we need to create it
+					{
+					__LOG2("CDataOwnerManager::FindDataOwnersL() - found reg file: %S for sid: 0x%08x", &fileName, sid.iId);
+
+					pDataOwner = CDataOwnerContainer::NewL(sid, this);
+					CleanupStack::PushL(pDataOwner);
+					
+					iDataOwners.InsertInOrder(pDataOwner, CDataOwnerContainer::Compare);
+					CleanupStack::Pop(pDataOwner);										
+					} // if
+				else
+					{
+					__LOG2("CDataOwnerManager::FindDataOwnersL() - found reg file: %S for existing sid: 0x%08x", &fileName, sid.iId);
+					}
+
+				pDataOwner->DataOwner().AddRegistrationFilesL(fileName);
+				} // if
+			} // for x
+		
+		CleanupStack::PopAndDestroy(registrationFiles);
+		__LOG("CDataOwnerManager::FindDataOwnersL() - End");
+		}
+		
+	CSBEConfig& CDataOwnerManager::Config()
+	/** Getter for the Secure Backup configuration
+	@return Reference to the CSBEConfig instance
+	*/
+		{
+		return *iConfig;
+		}
+		
+	TBool CDataOwnerManager::IsSetForPartialL(TSecureId aSecureId) const
+	/** Queries whether a SID is included in a partial operation
+	@return TBool specifying whether a SID is included or not
+	*/
+		{
+		TBool found = EFalse;
+		
+		if (iSIDListForPartial != NULL)
+			{
+			TInt result = iSIDListForPartial->Find(aSecureId);
+			if (result != KErrNotFound)
+				{
+				found = ETrue;
+				}
+			}
+		else
+			{
+			__LOG("CDataOwnerManager::IsSetForPartialL() - SID list not created yet so leaving!");
+			User::Leave(KErrNotFound);
+			}
+		
+		__LOG2("CDataOwnerManager::IsSetForPartialL() - SID: 0x%08x, found: %d", aSecureId.iId, found);	
+		
+		return found;
+		}
+	} // namespace conn
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sbencrypt.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,82 @@
+// 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:
+// Implementation of CSecureBUREncryptKeySource class.
+// 
+//
+
+/**
+ @file
+ @released
+*/
+#include "sbencrypt.h"
+#include "sbencryptimpl.h"
+
+namespace conn
+	{
+	EXPORT_C CSecureBUREncryptKeySource* CSecureBUREncryptKeySource::NewL()
+		{
+		CSecureBUREncryptKeySource* pSelf = new CSecureBUREncryptKeySource();
+		CleanupStack::PushL(pSelf);
+		pSelf->ConstructL();
+		CleanupStack::Pop(pSelf);
+		
+		return pSelf;
+		}
+
+	CSecureBUREncryptKeySource::CSecureBUREncryptKeySource()
+	/**
+	C++ constructor
+	*/
+		{
+		}
+		
+	EXPORT_C CSecureBUREncryptKeySource::~CSecureBUREncryptKeySource()
+		{
+		delete iImpl;
+		}
+
+	void CSecureBUREncryptKeySource::ConstructL()
+	/**
+	Symbian 2nd phase construction
+	*/
+		{
+		iImpl = CSecureBURKeySourceImpl::NewL();
+		}
+
+	EXPORT_C void CSecureBUREncryptKeySource::GetDefaultBufferForBackupL(TDriveNumber aDrive, 
+																TBool& aGotBuffer, 
+																TDes& aBuffer)
+		{
+		iImpl->GetDefaultBufferForBackupL(aDrive, aGotBuffer, aBuffer);
+		}
+
+
+
+	EXPORT_C void CSecureBUREncryptKeySource::GetBackupKeyL(TDriveNumber aDrive, TSecureId aSID,
+	                            		  	   TBool &aDoEncrypt, TDes8& aKey,
+	                            		  	   TBool& aGotBuffer, TDes& aBuffer)
+		{
+		iImpl->GetBackupKeyL(aDrive, aSID, aDoEncrypt, aKey, aGotBuffer, aBuffer);
+		}
+
+
+
+	EXPORT_C void CSecureBUREncryptKeySource::GetRestoreKeyL(TDriveNumber aDrive, TSecureId aSID, 
+	                             				TBool aGotBuffer, TDes& aBuffer,
+	                             				TBool &aGotKey, TDes8& aKey)
+		{
+		iImpl->GetRestoreKeyL(aDrive, aSID, aGotBuffer, aBuffer, aGotKey, aKey);
+		}
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sbencryptimpl.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,104 @@
+// 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:
+// Implementation of CSecureBURKeySourceImpl
+// 
+//
+
+/**
+ @file
+*/
+#include "sbencryptimpl.h"
+
+// If you want this code to actually test encryption then uncomment the next line
+//#define __TEST_ENCRYPTION__
+
+namespace conn
+	{
+	/**
+	Symbian OS constructor
+	*/
+    CSecureBURKeySourceImpl* CSecureBURKeySourceImpl::NewL()
+    	{
+    	CSecureBURKeySourceImpl* pSelf = new(ELeave) CSecureBURKeySourceImpl();
+    	return pSelf;
+    	}
+    
+    /**
+    Standard C++ constructor 
+    */
+    CSecureBURKeySourceImpl::CSecureBURKeySourceImpl()
+    	{
+    	}
+    
+    /**
+    Standard C++ destructor
+    */
+    CSecureBURKeySourceImpl::~CSecureBURKeySourceImpl()
+    	{
+    	}
+
+	/**
+	See sbencrypt.h
+	*/
+    void CSecureBURKeySourceImpl::GetDefaultBufferForBackupL(TDriveNumber /*aDrive*/, 
+    														 TBool& aGotBuffer, 
+    														 TDes& /*aBuffer*/)
+    	{
+    	#ifdef __TEST_ENCRYPTION__
+    		_LIT(KTestBuffer, "TEST_BUFFER");
+    		
+    		aGotBuffer = ETrue;
+    		aBuffer = KTestBuffer;
+    	#else
+    		aGotBuffer = EFalse;
+    	#endif
+    	}
+    	
+	/**
+	See sbencrypt.h
+	*/
+    void CSecureBURKeySourceImpl::GetBackupKeyL(TDriveNumber /*aDrive*/, TSecureId /*aSID*/,
+                       							TBool& aDoEncrypt, TDes8& /*aKey*/,
+                       							TBool& aGotBuffer, TDes& /*aBuffer*/)
+    	{
+    	#ifdef __TEST_ENCRYPTION__
+    		_LIT(KTestBuffer, "TEST_BUFFER");
+    		
+    		aDoEncrypt = ETrue;
+    		aKey.AppendNum(aSID);
+    		aGotBuffer = ETrue;
+    		aBuffer = KTestBuffer;
+    	#else
+    		aDoEncrypt = EFalse;
+    		aGotBuffer = EFalse;
+    	#endif
+    	}
+    	
+	/**
+	See sbencrypt.h
+	*/
+    void CSecureBURKeySourceImpl::GetRestoreKeyL(TDriveNumber /*aDrive*/, TSecureId /*aSID*/, 
+                        						 TBool /*aGotBuffer*/, TDes& /*aBuffer*/,
+                        						 TBool &aGotKey, TDes8& /*aKey*/)
+    	{
+    	#ifdef __TEST_ENCRYPTION__
+    		aGotKey = ETrue;
+    		aKey.AppendNum(aSID);
+    	#else
+    		aGotKey = EFalse;
+    	#endif
+    	}
+
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sbeparserproxy.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,230 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implementation of CBackupRegistrationParser
+// 
+//
+
+/**
+ @file
+*/
+#include "sbeparserproxy.h"
+
+// System includes
+#include <charconv.h>
+
+// User includes
+#include "sbeparserdefs.h"
+#include "sblog.h"
+
+namespace conn
+	{
+	CSBEParserProxy::CSBEParserProxy( RFs& aFsSession )
+        : iFsSession( aFsSession )
+	/** Standard C++ constructor
+
+	@param aSID secure id of data owner
+	@param apDataOwnerManager data owner manager to access resources
+	*/
+		{
+		}
+
+	CSBEParserProxy::~CSBEParserProxy()
+	/** Standard C++ destructor
+	*/
+		{
+		delete iConverter;
+		delete iParser;
+		}
+
+	void CSBEParserProxy::ConstructL()
+	/** Symbian 2nd stage constructor */
+		{
+		iParser = CParser::NewL(KMimeType, *this);
+
+		// We only convert from UTF-8 to UTF-16
+		iConverter = CCnvCharacterSetConverter::NewL();
+		if  ( iConverter->PrepareToConvertToOrFromL( KCharacterSetIdentifierUtf8, iFsSession ) == CCnvCharacterSetConverter::ENotAvailable )
+			{
+			User::Leave(KErrNotFound);
+			}
+		}
+		
+	CSBEParserProxy* CSBEParserProxy::NewL( RFs& aFsSession )
+	/** Symbian OS static constructor
+
+	@param aSID secure id of data owner
+	@param apDataOwnerManager data owner manager to access resources
+	@return a CBackupRegistrationParser object
+	*/
+		{
+		CSBEParserProxy* self = new(ELeave) CSBEParserProxy( aFsSession );
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		CleanupStack::Pop(self);
+
+		return self;
+		}
+
+	void CSBEParserProxy::ParseL( const TDesC& aFileName, MContentHandler& aObserver )
+	/** Parsing API */
+        {
+        // Store transient observer (the entity that we will route callbacks to)
+        iTransientParsingError = KErrNone;
+        iTransientObserver = &aObserver;
+
+        // Do XML parsing of the specified file. Callbacks will occur to client via the XML
+        // callback API.
+		Xml::ParseL( *iParser, iFsSession, aFileName );
+
+        // Handle any errors received during callbacks
+		User::LeaveIfError( iTransientParsingError );
+        }
+
+	TInt CSBEParserProxy::ConvertToUnicodeL( TDes16& aUnicode, const TDesC8& aForeign )
+        {
+        const TInt error = iConverter->ConvertToUnicode( aUnicode, aForeign, iConverterState );
+
+#ifdef SBE_LOGGING_ENABLED
+        if  ( error != KErrNone )
+            {
+            HBufC* copy = HBufC::NewL( aForeign.Length() * 2 );
+            copy->Des().Copy( aForeign );
+			__LOG2("CSBEParserProxy::ConvertToUnicode() - error: %d when converting: %S", error, copy );
+            delete copy;
+            }
+#endif
+
+        return error;
+        }
+		
+	//	
+	//  MContentHandler Implementaion //
+	//
+
+	/** MContentHandler::OnStartDocumentL()
+	*/
+	void CSBEParserProxy::OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode)
+		{
+		if (aErrorCode != KErrNone)
+			{
+			__LOG1("CBackupRegistrationParser::OnStartDocumentL() - error = %d", aErrorCode);
+			User::Leave(aErrorCode);
+			}
+
+        iTransientObserver->OnStartDocumentL( aDocParam, aErrorCode );
+		}
+		
+	/** MContentHandler::OnEndDocumentL()
+	*/
+	void CSBEParserProxy::OnEndDocumentL(TInt aErrorCode)
+		{
+		if (aErrorCode != KErrNone)
+			{
+			// just to satifsy UREL compiler
+			(void) aErrorCode;
+			__LOG1("CBackupRegistrationParser::OnEndDocumentL() - error = %d", aErrorCode);
+			}
+
+        iTransientObserver->OnEndDocumentL( aErrorCode );
+		}
+		
+	/** MContentHandler::OnStartElementL()
+
+	@leave KErrUnknown an unknown element
+	*/		
+	void CSBEParserProxy::OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode)
+		{
+		if (aErrorCode != KErrNone)
+			{
+			__LOG1("CBackupRegistrationParser::OnStartElementL() - error = %d", aErrorCode);
+			User::LeaveIfError(aErrorCode);
+			}
+
+        iTransientObserver->OnStartElementL( aElement, aAttributes, aErrorCode );
+		}
+
+	/** MContentHandler::OnEndElementL()
+	*/
+	void CSBEParserProxy::OnEndElementL(const RTagInfo& aElement, TInt aErrorCode)
+		{
+		if (aErrorCode != KErrNone)
+			{
+			__LOG1("CBackupRegistrationParser::OnEndElementL() - error = %d", aErrorCode);
+			User::Leave(aErrorCode);
+			}
+
+        iTransientObserver->OnEndElementL( aElement, aErrorCode );
+		}
+
+	/** MContentHandler::OnContentL()
+	*/
+	void CSBEParserProxy::OnContentL(const TDesC8& aBytes, TInt aErrorCode)
+		{
+        iTransientObserver->OnContentL( aBytes, aErrorCode );
+		}
+
+	/** MContentHandler::OnStartPrefixMappingL()
+	*/
+	void CSBEParserProxy::OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode)
+		{
+        iTransientObserver->OnStartPrefixMappingL( aPrefix, aUri, aErrorCode );
+		}
+
+	/** MContentHandler::OnEndPrefixMappingL()
+	*/
+	void CSBEParserProxy::OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode)
+		{
+        iTransientObserver->OnEndPrefixMappingL( aPrefix, aErrorCode );
+		}
+
+	/** MContentHandler::OnIgnorableWhiteSpaceL()
+	*/
+	void CSBEParserProxy::OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode)
+		{
+        iTransientObserver->OnIgnorableWhiteSpaceL( aBytes, aErrorCode );
+		}
+
+	/** MContentHandler::OnSkippedEntityL()
+	*/
+	void CSBEParserProxy::OnSkippedEntityL(const RString& aName, TInt aErrorCode)
+		{
+        iTransientObserver->OnSkippedEntityL( aName, aErrorCode );
+		}
+
+	/** MContentHandler::OnProcessingInstructionL()
+	*/
+	void CSBEParserProxy::OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode)
+		{
+        iTransientObserver->OnProcessingInstructionL( aTarget, aData, aErrorCode );
+		}
+
+	/** MContentHandler::OnError()
+
+	@leave aErrorCode
+	*/
+	void CSBEParserProxy::OnError(TInt aErrorCode)
+		{
+		__LOG1("CBackupRegistrationParser::OnError() - error = %d", aErrorCode);
+		iTransientParsingError = aErrorCode;
+        iTransientObserver->OnError( aErrorCode );
+		}
+
+	/** MContentHandler::OnEndPrefixMappingL()
+	*/
+	TAny* CSBEParserProxy::GetExtendedInterface(const TInt32 aUid)
+		{
+        return iTransientObserver->GetExtendedInterface( aUid );
+		}
+
+    } // namespace conn
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sbeserver.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,260 @@
+// 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:
+// Implementation of CSBEServer class.
+// 
+//
+
+/**
+ @file
+*/
+
+#include <e32std.h>
+#include <e32base.h>
+#include "sbeclientserver.h"
+#include "sbeserver.h"
+#include "sbesession.h"
+#include <connect/panic.h>
+#include "sbedataownermanager.h"
+#include "sblog.h"
+//#include <stdlib.h>
+
+namespace conn
+	{
+
+
+	/** Secure Backup Engine security request ranges
+	
+	This is a breakdown of the SBE requests into ranges
+	for security checking purposes.
+
+	@internalComponent
+	*/
+	const TInt mySBERanges[] = {0,23};
+
+	/** Secure Backup Engine range count
+
+	The number of different security ranges for SBEs request numbers
+
+	@internalComponent
+	*/
+	const TUint mySBERangeCount = sizeof(mySBERanges)/sizeof(mySBERanges[0]);
+
+	/** Secure Backup Engine security action array
+
+	An array with a one-to-one mapping with the range array
+	specifiying what security action to take for each server request.
+
+	@internalComponent
+	*/
+	const TUint8 mySBEElementsIndex[mySBERangeCount] =
+		{
+		0,
+		CPolicyServer::ENotSupported,
+		};
+
+	/**
+	@internalComponent
+	*/
+	const CPolicyServer::TPolicyElement mySBEElements[] =
+		{
+			{_INIT_SECURITY_POLICY_C2(ECapabilityWriteDeviceData,ECapabilityReadDeviceData)
+				, CPolicyServer::EFailClient},
+		};
+
+	/**
+	@internalComponent
+	*/
+	const CPolicyServer::TPolicy mySBEPolicy =
+		{
+		0,
+		mySBERangeCount,
+		mySBERanges,
+		mySBEElementsIndex,
+		mySBEElements,
+		};
+
+	CSBEServer::CSBEServer(CDataOwnerManager* aDOM)
+		: CPolicyServer(EPriorityNormal,mySBEPolicy), iDOM(aDOM)
+    /** 
+    Class constructor
+    */
+		{
+		__ASSERT_DEBUG(aDOM, Panic(KErrArgument));
+		}
+
+	CSBEServer::~CSBEServer()
+    /**
+    Class destructor
+    */
+		{
+		iGlobalSharedHeap.Close();
+		delete iGSHInterface;
+		}
+		
+	CSBEServer* CSBEServer::NewLC(CDataOwnerManager* aDOM)
+	/**
+	Constructs a new instance of the CSBEServer, calls ConstructL, 
+	and returns it to the caller leaving it on the cleanup stack.
+
+	@return The new instance of CSBEServer.
+	*/
+		{
+		CSBEServer* pSelf = new (ELeave) CSBEServer(aDOM);
+		CleanupStack::PushL(pSelf);
+		pSelf->ConstructL();
+		return pSelf;
+		}
+
+	void CSBEServer::ConstructL()
+	/**
+	Construct this instance of CSBEServer.
+	*/
+		{
+		AllocateGlobalSharedHeapL();
+
+		iGSHInterface = CHeapWrapper::NewL();
+		
+		// Initialise the locked flag to be unlock
+		iGSHInterface->ResetHeap(iGlobalSharedHeap);
+		//
+		// Start the server and a timer to stop it if nothing happens.
+		StartL(KSBEServerName);
+		iShutdown.ConstructL();
+		#ifndef _DEBUG
+			iShutdown.Start();
+		#endif
+		}
+		
+	void CSBEServer::AllocateGlobalSharedHeapL()
+	/**
+	Attempts to allocate the GSH. If initial attempts fail, it tries to allocate with
+	progressively smaller chunk sizes
+	*/
+		{	
+		TInt attemptedSize;
+		TInt retryCount;
+		TInt redFactor;
+		iDOM->Config().HeapValues(attemptedSize, retryCount, redFactor);
+		
+		TInt result = KErrNone;
+		
+		for (; retryCount > 0; retryCount--)
+			{
+			result = iGlobalSharedHeap.CreateGlobal(KNullDesC, attemptedSize, attemptedSize);
+			
+			if (result == KErrNone)
+				{
+				// We have succesfully allocated a GSH
+				break;
+				}
+			else
+				{
+				// Reduce the size of the GSH by a scale factor
+				attemptedSize = attemptedSize / redFactor;
+				}
+			}
+			
+		User::LeaveIfError(result);
+		}
+
+	void CSBEServer::AddSession()
+	/** Increments the server session count.
+	
+	The server will shutdown when its 
+	session count drops to zero.
+	*/
+		{
+		++iSessionCount;
+		iShutdown.Cancel();
+		}
+
+	void CSBEServer::DropSession()
+	/** Decrements the server session count.  
+	
+	The server will shutdown when its 
+	session count drops to zero.
+	*/
+		{		
+		if(--iSessionCount == 0)
+			{
+			iShutdown.Start();
+			}
+		}
+
+
+	CSession2* CSBEServer::NewSessionL(const TVersion& aVersion,
+		const RMessage2& /*aMessage*/) const
+	/** Constructs a new SBE server session.
+	
+	Querys the supplied version infomation from the client
+	with that of this server, and leaves if they are incompatable.
+
+	@param aVersion The clients version information
+	@param aMessage Is ignored
+	@return A new instance of CSBESession
+	@leave KErrNotSupported if the version passed in aVersion is not the same as this one
+	*/
+		{
+		TVersion thisVersion(KSBEMajorVersionNumber, 
+								KSBEMinorVersionNumber,
+								KSBEBuildVersionNumber);
+		
+	    if (!User::QueryVersionSupported(thisVersion, aVersion))
+			{
+			User::Leave(KErrNotSupported);
+			}
+
+		return new (ELeave) CSBESession();
+		}
+
+	TInt CSBEServer::RunError(TInt aError)
+	/** Called when this active objects RunL leaves. 
+	
+	May be due to a bad client or the server itself.  In either 
+	case, complete the last outstanding message with the error 
+	code and continue handling client requests.
+
+    @param aError  Standard Symbian OS error code
+	@return The error code to be passed back to the active scheduler framework.
+	*/
+		{
+		//
+		// A Bad descriptor is a bad client - panic it.
+		if(aError == KErrBadDescriptor)
+			{
+			PanicClient(KErrBadDescriptor);
+			}
+
+		//
+		// Complete the message and continue handling requests.
+		Message().Complete(aError);
+		ReStart();
+		return KErrNone;
+		}
+
+
+	void CSBEServer::PanicClient(TInt aPanic) const
+	/** Panic a client.
+
+	@param aPanic The panic code.
+	*/
+		{
+		__DEBUGGER()
+		_LIT(KPanicCategory,"SBE Server");
+		RThread client;
+		Message().Client(client);
+		client.Panic(KPanicCategory, aPanic);
+		}
+
+	} // end namespace
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sbesession.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,838 @@
+// 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:
+// Implementation of CSBESession class.
+// 
+//
+
+/**
+ @file
+*/
+
+#include <e32std.h>
+#include <e32base.h>
+#include "sbeserver.h"
+#include "sbesession.h"
+#include "sbeclientserver.h"
+#include <connect/panic.h>
+#include "sbedataownermanager.h"
+#include <connect/sbtypes.h>
+#include "sblog.h"
+#include <apgcli.h>
+
+namespace conn
+	{
+	
+	/** This block size for the internal buffer
+	@internalTechnology
+	*/
+	const TInt KSBBufferBlockSize = 4096;
+	
+	CSBESession::CSBESession() : iTransferBuf(NULL), iTransferTextBuf(NULL), iArrayCount(0)
+    /**
+    Class Constructor
+    */
+		{
+		}
+
+	CSBESession::~CSBESession()
+    /**
+    Class destructor
+    */
+		{
+		//
+		// If the client has detached properly, they should
+		// have done this - but just in case.
+		Server().DropSession();
+		ResetTransferBuf();
+		delete iExtCurEntry;
+		}
+
+	void CSBESession::CreateL()
+	/**
+	Creates a connection between the Secure Backup Engine server and the Secure
+	Backup Engine session.  Increments the server's session count
+	*/
+		{
+		//
+		// Increase the servers session count.
+		Server().AddSession();
+		}
+
+	void CSBESession::ServiceL(const RMessage2& aMessage)
+	/**
+	Called by the client server framework to service a message request
+	from a client.
+
+    @param aMessage  Reference to a RMessage2 object
+	*/
+		{
+	#ifdef SBE_LOGGING_ENABLED
+		RThread thread;
+		aMessage.Client(thread);
+		const TFullName threadName( thread.FullName() );
+		thread.Close();
+	#endif		
+		
+		switch(aMessage.Function())
+			{
+			//
+			// Connection config getting/setting.
+			case ESBEMsgGetGSHHandle:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgGetGSHHandle for thread: %S", &threadName);
+				aMessage.Complete(Server().GlobalSharedHeap());
+				break;
+				}
+			case ESBEMsgPrepDataOwnerInfo:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgPrepDataOwnerInfo for thread: %S", &threadName);
+				PrepDataOwnerInfoL(aMessage);
+				break;
+				}
+			case ESBEMsgGetDataOwnerInfo:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgGetDataOwnerInfo for thread: %S", &threadName);
+				ReturnDataOwnerInfoL(aMessage);
+				break;
+				}
+			case ESBEMsgPrepPublicFiles:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgPrepPublicFiles for thread: %S", &threadName);
+				PrepPublicFileListL(aMessage);
+				break;
+				}
+			case ESBEMsgGetPublicFiles:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgGetPublicFiles for thread: %S", &threadName);
+				ReturnPublicFileListL(aMessage);
+				break;
+				}
+			case ESBEMsgPrepPublicFilesRaw:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgPrepPublicFilesRaw for thread: %S", &threadName);
+				PrepPublicFileListRawL(aMessage);
+				break;
+				}
+			case ESBEMsgGetPublicFilesRaw:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgGetPublicFilesRaw for thread: %S", &threadName);
+				ReturnPublicFileListRawL(aMessage);
+				break;
+				}
+			case ESBEMsgPrepPublicFilesXML:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgPrepPublicFilesXML for thread: %S", &threadName);
+				PrepPublicFileListXMLL(aMessage);
+				break;
+				}
+			case ESBEMsgGetPublicFilesXML:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgGetPublicFilesXML for thread: %S", &threadName);
+				ReturnPublicFileListXMLL(aMessage);
+				break;
+				}
+			case ESBEMsgSetBURMode:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgSetBURMode for thread: %S", &threadName);
+				SetBURModeL(aMessage);
+				break;
+				}
+			case ESBEMsgSetSIDListPartial:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgSetSIDListPartial for thread: %S", &threadName);
+				SetSIDListForPartialBURL(aMessage);
+				break;
+				}
+			case ESBEMsgPrepSIDStatus:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgPrepSIDStatus for thread: %S", &threadName);
+				PrepSIDStatusL(aMessage);
+				break;
+				}
+			case ESBEMsgGetSIDStatus:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgGetSIDStatus for thread: %S", &threadName);
+				ReturnSIDStatusL(aMessage);
+				break;
+				}
+			case ESBEMsgRequestDataSync:
+			case ESBEMsgRequestDataAsync:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgRequestDataSync / ESBEMsgRequestDataAsync for thread: %S", &threadName);
+				TRAPD(reqDataErr, RequestDataAsyncL(aMessage));
+				if (reqDataErr != KErrNone)
+					{
+					Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(EFalse);
+					User::Leave(reqDataErr);
+					}
+				break;
+				}
+			case ESBEMsgSupplyDataSync:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgSupplyDataSync for thread: %S", &threadName);
+				TRAPD(supDataErr, SupplyDataSyncL(aMessage));
+				if (supDataErr != KErrNone)
+					{
+					Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(EFalse);
+					User::Leave(supDataErr);
+					}
+				break;
+				}
+			case ESBEMsgAllSnapshotsSupplied:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgAllSnapshotsSupplied for thread: %S", &threadName);
+				AllSnapshotsSuppliedL(aMessage);
+				break;
+				}
+			case ESBEMsgGetExpectedDataSize:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgGetExpectedDataSize for thread: %S", &threadName);
+				GetExpectedDataSizeL(aMessage);
+				break;
+				}
+			case ESBEMsgAllSystemFilesRestored:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgAllSystemFilesRestored for thread: %S", &threadName);
+				AllSystemFilesRestoredL();
+				aMessage.Complete(KErrNone);
+				break;
+				}
+			case ESBEMsgPrepLargePublicFiles:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgPrepPublicFiles for thread: %S", &threadName);
+				PrepLargePublicFileListL(aMessage);
+				break;
+				}
+			case ESBEMsgGetLargePublicFiles:
+				{
+        		__LOG1("CSBESession::ServiceL() - ESBEMsgGetPublicFiles for thread: %S", &threadName);
+				ReturnLargePublicFileListL(aMessage);
+				break;
+				}
+			default:
+				{
+        		__LOG1("CSBESession::ServiceL() - UNKNOWN OP CODE for thread: %S", &threadName);
+				User::Leave(KErrNotSupported);
+				}
+			}
+
+		__LOG1("CSBESession::ServiceL() - Completed OK for thread: %S", &threadName);
+		}
+
+	inline CSBEServer& CSBESession::Server() const
+	/**
+	Returns a non-cost reference to this CServer object.
+
+	@return The non-const reference to this.
+	*/
+		{
+		return *static_cast<CSBEServer*>(const_cast<CServer2*>(CSession2::Server()));
+		}
+		
+	void CSBESession::PrepDataOwnerInfoL(const RMessage2& aMessage)
+	/**
+	Prepares the 
+	*/
+		{
+		TInt err = KErrNone;
+		ResetTransferBuf();
+		RPointerArray<CDataOwnerInfo> doiArray;
+		TRAP(err,
+			{
+			Server().DataOwnerManager().GetDataOwnersL(doiArray);
+
+			iTransferBuf = HBufC8::NewL(KSBBufferBlockSize);
+			TPtr8 transferBufPtr(iTransferBuf->Des());
+			
+			iArrayCount = doiArray.Count();
+			
+			HBufC8* dataOwnerBuffer = NULL;
+			for (TInt index = 0; index < iArrayCount; index++)
+				{
+				dataOwnerBuffer = doiArray[index]->ExternaliseLC();
+				
+				if (transferBufPtr.Size() + dataOwnerBuffer->Size() > transferBufPtr.MaxSize())
+					{
+					iTransferBuf = iTransferBuf->ReAllocL(transferBufPtr.MaxSize() + KSBBufferBlockSize);
+					transferBufPtr.Set(iTransferBuf->Des());
+					}
+					
+				// Append the flattened data owner to the IPC transfer buffer	
+				transferBufPtr.Append(*dataOwnerBuffer);
+				
+				CleanupStack::PopAndDestroy(dataOwnerBuffer);
+				}
+			}
+			); // TRAP
+		
+		doiArray.ResetAndDestroy();
+		doiArray.Close();
+
+		User::LeaveIfError(err);
+		
+		// complete the message with the total size of the buffer so that the 
+		// client can create the appropriate sized descriptor for receiving the data
+		aMessage.Complete(iTransferBuf->Des().Size());
+		}
+		
+	void CSBESession::ReturnDataOwnerInfoL(const RMessage2& aMessage)
+	/**
+	Return the previously populated buffer to the client
+	@param aMessage The message sent by the client to the server
+	*/
+		{
+		__ASSERT_DEBUG(iTransferBuf, Panic(KErrNotFound));
+		
+		// return the previously allocated transfer buffer
+		aMessage.WriteL(0, *iTransferBuf);		
+		aMessage.Complete(iArrayCount);
+		
+		ResetTransferBuf();
+		}
+		
+	void CSBESession::PrepPublicFileListL(const RMessage2& aMessage)
+	/**
+	Compile a list of public files owned by a particular SID to be backed up
+	@param aMessage The message sent by the client to the server
+	*/
+		{
+		RFileArray fileArray;
+		CleanupClosePushL(fileArray);
+		HBufC8* pGenericDataTypeBuffer = HBufC8::NewLC(aMessage.GetDesLengthL(1));
+		
+		TPtr8 genericDataTypeBuffer(pGenericDataTypeBuffer->Des());
+		aMessage.ReadL(1, genericDataTypeBuffer);
+		
+		TDriveNumber drive = static_cast<TDriveNumber>(aMessage.Int0());
+		
+		CSBGenericDataType* pGenericDataType = CSBGenericDataType::NewL(*pGenericDataTypeBuffer);
+		CleanupStack::PopAndDestroy(pGenericDataTypeBuffer);
+		CleanupStack::PushL(pGenericDataType);
+		Server().DataOwnerManager().GetPublicFileListL(pGenericDataType, drive, fileArray);
+		CleanupStack::PopAndDestroy(pGenericDataType);
+		
+		iTransferBuf = fileArray.ExternaliseL();
+
+		CleanupStack::PopAndDestroy(&fileArray);
+
+		// complete the message with the total size of the buffer so that the 
+		// client can create the appropriate sized descriptor for receiving the data
+		aMessage.Complete(iTransferBuf->Des().MaxSize());
+		}
+		
+	void CSBESession::ReturnPublicFileListL(const RMessage2& aMessage)
+	/** Return the previously populated buffer to the client
+	@param aMessage The message sent by the client to the server */
+		{
+		__ASSERT_DEBUG(iTransferBuf, Panic(KErrArgument));
+		
+		// return the previously allocated transfer buffer
+		aMessage.WriteL(0, *iTransferBuf);
+		
+		aMessage.Complete(KErrNone);
+		
+		ResetTransferBuf();
+		}
+
+	void CSBESession::PrepPublicFileListRawL(const RMessage2& aMessage)
+	/**
+	Compile a raw list of public files owned by a particular SID to be backed up
+	@param aMessage The message sent by the client to the server
+	*/
+		{
+		RRestoreFileFilterArray fileFilterArray;
+		CleanupClosePushL(fileFilterArray);
+		TPckgBuf<TDriveNumber> driveNumPkg;
+		HBufC8* pGenericDataTypeBuffer = HBufC8::NewLC(aMessage.GetDesLengthL(1));
+		
+		TPtr8 genericDataTypeBuffer(pGenericDataTypeBuffer->Des());
+		
+		aMessage.ReadL(0, driveNumPkg);
+		aMessage.ReadL(1, genericDataTypeBuffer);
+		
+		CSBGenericDataType* pGenericDataType = CSBGenericDataType::NewL(*pGenericDataTypeBuffer);
+		CleanupStack::PopAndDestroy(pGenericDataTypeBuffer);
+		CleanupStack::PushL(pGenericDataType);
+		
+		Server().DataOwnerManager().GetRawPublicFileListL(pGenericDataType, driveNumPkg(), fileFilterArray);
+		CleanupStack::PopAndDestroy(pGenericDataType);
+		
+		iTransferBuf = fileFilterArray.ExternaliseL();
+
+		CleanupStack::PopAndDestroy(&fileFilterArray);
+
+		// complete the message with the total size of the buffer so that the 
+		// client can create the appropriate sized descriptor for receiving the data
+		aMessage.Complete(iTransferBuf->Des().MaxSize());
+		}
+		
+	void CSBESession::ReturnPublicFileListRawL(const RMessage2& aMessage)
+	/** Return the previously populated buffer to the client
+	@param aMessage The message sent by the client to the server */
+		{
+		__ASSERT_DEBUG(iTransferBuf, Panic(KErrArgument));
+		
+		// return the previously allocated transfer buffer
+		aMessage.WriteL(0, *iTransferBuf);
+		
+		aMessage.Complete(KErrNone);
+		
+		ResetTransferBuf();
+		}
+
+	void CSBESession::PrepPublicFileListXMLL(const RMessage2& aMessage)
+	/**
+	*/
+		{
+		TPckgBuf<TDriveNumber> driveNumPkg;
+		TPckgBuf<TSecureId> sidPkg;
+
+		ResetTransferBuf();
+
+		iTransferTextBuf = HBufC::NewL(0);
+
+		Server().DataOwnerManager().GetXMLPublicFileListL(sidPkg(), driveNumPkg(), iTransferTextBuf);
+		
+		iTransferBuf = HBufC8::NewL(0);
+		
+		aMessage.Complete(iTransferBuf->Des().MaxSize());
+		}
+		
+	void CSBESession::ReturnPublicFileListXMLL(const RMessage2& aMessage)
+	/**
+	Return the previously populated buffer to the client
+	@param aMessage The message sent by the client to the server
+	*/
+		{
+		__ASSERT_DEBUG(iTransferBuf, Panic(KErrArgument));
+		
+		// return the previously allocated transfer buffer
+		aMessage.WriteL(0, *iTransferTextBuf);
+
+		aMessage.Complete(KErrNone);
+		
+		ResetTransferBuf();
+		}
+		
+	void CSBESession::SetBURModeL(const RMessage2& aMessage)
+	/**	
+	Set the Backup and Restore mode on/off and configure the BUR options
+
+	@param aMessage The message sent by the client to the server
+	*/
+		{
+		TDriveList driveList;
+		
+		aMessage.ReadL(0, driveList);
+		TBURPartType burType = static_cast<TBURPartType>(aMessage.Int1());
+		TBackupIncType incType = static_cast<TBackupIncType>(aMessage.Int2());
+		
+		
+		// Unlock the global heap
+		Server().GSHInterface().ResetHeap(Server().GlobalSharedHeap());
+
+		Server().DataOwnerManager().SetBURModeL(driveList, burType, incType);
+		
+		aMessage.Complete(KErrNone);
+		}
+
+	void CSBESession::SetSIDListForPartialBURL(const RMessage2& aMessage)
+	/**
+	Set a list of SID's that require base backup regardless of the device backup mode
+	
+	@param aMessage The message sent by the client to the server
+	*/
+		{
+		HBufC8* flatArray = HBufC8::NewLC(aMessage.GetDesLengthL(0));	
+		TPtr8 flatArrayPtr(flatArray->Des());
+		
+		aMessage.ReadL(0, flatArrayPtr);
+
+		Server().DataOwnerManager().SetSIDListForPartialBURL(flatArrayPtr);
+
+		CleanupStack::PopAndDestroy(flatArray);
+		
+		aMessage.Complete(KErrNone);
+		}
+
+	void CSBESession::PrepSIDStatusL(const RMessage2& aMessage)
+	/**
+	Extract the array of SID's of which the status is required
+	
+	@param aMessage The message sent from the client to the server
+	*/
+		{
+		ResetTransferBuf();
+		iTransferBuf = HBufC8::NewL(aMessage.GetDesLengthL(0));
+		
+		TPtr8 transBuf(iTransferBuf->Des());
+		// Copy the IPC'd buffer into our transfer buffer
+		aMessage.ReadL(0, transBuf);
+		
+		aMessage.Complete(KErrNone);
+		}
+		
+	void CSBESession::ReturnSIDStatusL(const RMessage2& aMessage)
+	/**
+	Populate and return the array of SID's complete with their statuses
+	
+	@param aMessage The message sent from the client to the server
+	*/
+		{
+		RSIDStatusArray* pStatusArray = RSIDStatusArray::InternaliseL(*iTransferBuf);
+		CleanupStack::PushL(pStatusArray);
+		CleanupClosePushL(*pStatusArray);
+		
+		// We're finished with the received externalised SIDStatusArray for now, delete it
+		ResetTransferBuf();
+		
+		// Ask DOM to populate the Statuses in the status array
+		Server().DataOwnerManager().SIDStatusL(*pStatusArray);
+		
+		iTransferBuf = pStatusArray->ExternaliseL();
+		
+		CleanupStack::PopAndDestroy(2, pStatusArray);
+		
+		aMessage.WriteL(0, *iTransferBuf);		
+		aMessage.Complete(KErrNone);
+
+		ResetTransferBuf();
+		}
+		
+	void CSBESession::RequestDataAsyncL(const RMessage2& aMessage)
+	/**
+	Handle the client's asynchronous request for data from the SBE
+	*/
+		{
+		iMessage = aMessage;
+		
+        __LOG("CSBESession::RequestDataAsyncL() - START");
+		TBool finished = EFalse;	// Set by DOM, initialised to eliminate warning
+		HBufC8* pTransferredBuf = HBufC8::NewLC(iMessage.GetDesLengthL(0));
+		
+		TPtr8 transBuf(pTransferredBuf->Des());
+		// Copy the IPC'd buffer into our transfer buffer
+		iMessage.ReadL(0, transBuf);
+		
+		// Extract the generic type from the client IPC request 
+		CSBGenericTransferType* pGenericType = CSBGenericTransferType::NewL(*pTransferredBuf);
+		CleanupStack::PopAndDestroy(pTransferredBuf);
+		CleanupStack::PushL(pGenericType);
+		
+		TPtr8& writeBuf = Server().GSHInterface().WriteBufferL(Server().GlobalSharedHeap());
+
+		Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(ETrue);
+		
+		Server().GSHInterface().Header(Server().GlobalSharedHeap()).GenericTransferTypeBuffer() = pGenericType->Externalise();
+		
+		// Call the DOM to populate the GSH with the data to return
+		Server().DataOwnerManager().RequestDataL(pGenericType, writeBuf, finished);
+		
+		CleanupStack::PopAndDestroy(pGenericType);
+		
+		Server().GSHInterface().Header(Server().GlobalSharedHeap()).iFinished = finished;
+        __LOG2("CSBESession::RequestDataAsyncL() - Server-side data length: %d, address: 0x%08x", writeBuf.Length(), writeBuf.Ptr());
+        //__LOGDATA("CSBESession::RequestDataAsyncL() -       %S", writeBuf.Ptr(), writeBuf.Length());
+
+		Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(EFalse);
+		
+		if (!iMessage.IsNull())
+			{
+			iMessage.Complete(KErrNone);
+			}
+		
+        __LOG("CSBESession::RequestDataAsyncL() - END");
+		}
+		
+	void CSBESession::RequestDataSyncL(const RMessage2& aMessage)
+	/**
+	Handle the client's synchronous request for data from the SBE
+	*/
+		{
+        __LOG("CSBESession::RequestDataSyncL() - START");
+		TBool finished = EFalse;	// Set by DOM, initialised to eliminate warning
+		HBufC8* pTransferredBuf = HBufC8::NewLC(aMessage.GetDesLengthL(0));
+		
+		TPtr8 transBuf(pTransferredBuf->Des());
+		// Copy the IPC'd buffer into our transfer buffer
+		aMessage.ReadL(0, transBuf);
+		
+		// Extract the generic type from the client IPC request 
+		CSBGenericTransferType* pGenericType = CSBGenericTransferType::NewL(*pTransferredBuf);
+		CleanupStack::PopAndDestroy(pTransferredBuf);
+		CleanupStack::PushL(pGenericType);
+		
+		TPtr8& writeBuf = Server().GSHInterface().WriteBufferL(Server().GlobalSharedHeap());
+
+		Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(ETrue);
+
+		Server().GSHInterface().Header(Server().GlobalSharedHeap()).GenericTransferTypeBuffer() = pGenericType->Externalise();
+		
+		// Call the DOM to populate the GSH with the data to return
+		Server().DataOwnerManager().RequestDataL(pGenericType, writeBuf, finished);
+		
+		CleanupStack::PopAndDestroy(pGenericType);
+		
+		Server().GSHInterface().Header(Server().GlobalSharedHeap()).iFinished = finished;
+
+		Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(EFalse);
+        __LOG2("CSBESession::RequestDataSyncL() - Server-side data length: %d, address: 0x%08x", writeBuf.Length(), writeBuf.Ptr());
+        //__LOGDATA("CSBESession::RequestDataSyncL()        - %S", writeBuf.Ptr(), writeBuf.Length());
+
+		aMessage.Complete(KErrNone);
+        __LOG("CSBESession::RequestDataSyncL() - END");
+		}
+	
+	void CSBESession::SupplyDataSyncL(const RMessage2& aMessage)
+	/**
+	Handle the client's synchronous request to supply data to the SBE
+	*/
+		{
+        __LOG("CSBESession::SupplyDataSyncL() - START");
+		TBool finished = aMessage.Int0();
+
+		CSBGenericTransferType* pGenericType = CSBGenericTransferType::NewL(
+			Server().GSHInterface().Header(Server().GlobalSharedHeap())
+			.GenericTransferTypeBuffer());
+		CleanupStack::PushL(pGenericType);
+
+		TPtrC8& readBuf = Server().GSHInterface().ReadBufferL(Server().GlobalSharedHeap());
+
+		Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(ETrue);
+        __LOG2("CSBESession::SupplyDataSyncL() - Server-side data length: %d, address: 0x%08x", readBuf.Length(), readBuf.Ptr());
+        //__LOGDATA("CSBESession::SupplyDataSyncL()         - %S", readBuf.Ptr(), readBuf.Length());
+
+		Server().DataOwnerManager().SupplyDataL(pGenericType, readBuf, finished);
+
+		
+		CleanupStack::PopAndDestroy(pGenericType);
+
+		Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(EFalse);
+
+		aMessage.Complete(KErrNone);
+        __LOG("CSBESession::SupplyDataSyncL() - END");
+		}
+		
+	void CSBESession::GetExpectedDataSizeL(const RMessage2& aMessage)
+	/**
+	Return the size of data that the DOM expects to send back to the PC
+	*/
+		{
+		TUint size;
+		TPckg<TUint> sizePkg(size);
+
+		TInt bufferLen = aMessage.GetDesLengthL(0);
+		HBufC8* transTypeBuf = HBufC8::NewL(bufferLen);
+		CleanupStack::PushL(transTypeBuf);
+
+		TPtr8 transTypeBufDes(transTypeBuf->Des());
+		aMessage.ReadL(0, transTypeBufDes);
+
+		CSBGenericTransferType* pGenericType = CSBGenericTransferType::NewL(transTypeBufDes);
+		CleanupStack::PopAndDestroy(transTypeBuf);
+		CleanupStack::PushL(pGenericType);
+		
+		aMessage.ReadL(1, sizePkg);
+		
+		Server().DataOwnerManager().GetExpectedDataSizeL(pGenericType, sizePkg());
+		CleanupStack::PopAndDestroy(pGenericType);	
+	
+		aMessage.WriteL(1, sizePkg);
+
+		aMessage.Complete(KErrNone);
+		}
+		
+	void CSBESession::AllSnapshotsSuppliedL(const RMessage2& aMessage)
+	/**
+	*/
+		{
+		Server().DataOwnerManager().AllSnapshotsSuppliedL();
+
+		aMessage.Complete(KErrNone);
+		}
+		
+	void CSBESession::AllSystemFilesRestoredL()
+	/**
+	Sent by the client to indicate that all registration files 
+	@param aMessage IPC message sent from the client
+	*/
+		{
+		Server().DataOwnerManager().AllSystemFilesRestoredL();
+		}
+
+	void CSBESession::PrepLargePublicFileListL(const RMessage2& aMessage)
+	/**
+	Compile a list of public files owned by a particular SID to be backed up
+	@param aMessage The message sent by the client to the server
+	*/
+		{
+		HBufC8* pGenericDataTypeBuffer = HBufC8::NewLC(aMessage.GetDesLengthL(1));		
+		TPtr8 genericDataTypeBuffer(pGenericDataTypeBuffer->Des());
+		
+		TDriveNumber drive = static_cast<TDriveNumber>(aMessage.Int0());
+		aMessage.ReadL(1, genericDataTypeBuffer);
+		TInt cursor = aMessage.Int2();
+		TInt maxSize = aMessage.Int3();
+		
+		CSBGenericDataType* pGenericDataType = CSBGenericDataType::NewL(*pGenericDataTypeBuffer);
+		CleanupStack::PopAndDestroy(pGenericDataTypeBuffer);
+		CleanupStack::PushL(pGenericDataType);
+		
+		// Create a transfer type (ignored by the client side, just here for future reference
+		CSBGenericTransferType* transType = NULL;
+		
+		switch (pGenericDataType->DerivedTypeL())
+			{
+			case ESIDDerivedType:
+				{
+				
+				CSBSecureId* sid = CSBSecureId::NewL(pGenericDataType);
+				CleanupStack::PushL(sid);
+				transType = CSBSIDTransferType::NewL(sid->SecureIdL(), drive, EPublicFileListing);
+				CleanupStack::PopAndDestroy(sid);
+				break;
+				}
+			case EPackageDerivedType:
+				{
+				CSBPackageId* pkg = CSBPackageId::NewL(pGenericDataType);
+				CleanupStack::PushL(pkg);
+				transType = CSBPackageTransferType::NewL(pkg->PackageIdL(), drive, ESystemData);
+				CleanupStack::PopAndDestroy(pkg);
+				break;
+				}
+			case EJavaDerivedType:
+				{
+				CSBJavaId* java = CSBJavaId::NewL(pGenericDataType);
+				CleanupStack::PushL(java);
+				transType = CSBJavaTransferType::NewL(java->SuiteHashL(), drive, EJavaMIDletData);
+				CleanupStack::PopAndDestroy(java);
+				break;
+				}
+			default:
+				{
+				__LOG1("Unknown generic data type supplied, leaving with KErrUnknown (%d)", KErrUnknown);
+				User::Leave(KErrUnknown);
+				}
+			}
+		CleanupStack::PushL(transType);
+		
+		// Get a writeable buffer from the global shared heap
+		TPtr8& writeBuf = Server().GSHInterface().WriteBufferL(Server().GlobalSharedHeap());
+		Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(ETrue);
+		Server().GSHInterface().Header(Server().GlobalSharedHeap()).GenericTransferTypeBuffer() = transType->Externalise();
+
+		// This is required to look up the MIME type of the file entry and convert it into a textual representation	
+		RApaLsSession apaSession;
+		User::LeaveIfError(apaSession.Connect());
+		CleanupClosePushL(apaSession);
+
+		// Copy file entries from the cursor until either the end of the list is reached or the 
+		// max response size ceiling is reached. Store the number added for the call to ReturnLargePublicFileListL
+		iFinished = EFalse;
+		TInt currentIndex = cursor;
+		TInt currentSize = 0;
+		iTotalEntries = 0;
+
+		if (currentIndex == 0)
+			{
+			// Starting from the beginning, remove previously saved entry
+			delete iExtCurEntry;
+			iExtCurEntry = 0;
+			}
+
+		while (currentSize < maxSize)
+			{
+			if (!iExtCurEntry)
+				{
+				TEntry entry;
+				Server().DataOwnerManager().GetNextPublicFileL(pGenericDataType, (currentIndex == 0), drive, entry);
+				if (entry.iName.Length())
+					{
+					++currentIndex;
+								
+					// Pull the next entry out of the list and translate into CSBEFileEntry
+					CSBEFileEntry* pEntry = CSBEFileEntry::NewLC(entry, apaSession);
+					
+					// Pack it into the GSH
+					iExtCurEntry = pEntry->ExternaliseLC();
+					CleanupStack::Pop(iExtCurEntry);
+		
+					CleanupStack::PopAndDestroy(pEntry);
+					}
+				}
+			// else - use the remaining entry from the previous call
+			
+			if (iExtCurEntry)
+				{
+				// If this entry isn't going to bust our max RAM parameter, then pack it in
+				currentSize += iExtCurEntry->Size();
+				if (currentSize <= maxSize)
+					{
+					writeBuf.Append(*iExtCurEntry);
+					delete iExtCurEntry;
+					iExtCurEntry = 0;
+					++iTotalEntries;
+					}
+				// else - leave iExtCurEntry until the next call
+				}
+			else
+				{
+				// No more entries left, must have reached the end of the list
+				iFinished = ETrue;
+				break;					
+				}
+			}
+		CleanupStack::PopAndDestroy(&apaSession);
+        __LOG2("CSBESession::PrepLargePublicFileListL() - Server-side data length: %d, address: 0x%08x", writeBuf.Length(), writeBuf.Ptr());
+		
+		Server().GSHInterface().Header(Server().GlobalSharedHeap()).iFinished = iFinished;
+
+		Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(EFalse);
+
+		CleanupStack::PopAndDestroy(transType);
+		CleanupStack::PopAndDestroy(pGenericDataType);
+
+		aMessage.Complete(KErrNone);
+		}
+		
+	void CSBESession::ReturnLargePublicFileListL(const RMessage2& aMessage)
+	/** Return the previously populated buffer to the client
+	@param aMessage The message sent by the client to the server */
+		{
+		TPckg<TBool> finPkg(iFinished);
+		TPckg<TInt> totalPkg(iTotalEntries);
+		aMessage.WriteL(0, finPkg);
+		aMessage.WriteL(1, totalPkg);
+		aMessage.Complete(KErrNone);
+		}
+				
+	void CSBESession::ResetTransferBuf()
+	/**
+	*/
+		{
+		if (iTransferBuf != NULL)
+			{
+			delete iTransferBuf;
+			iTransferBuf = NULL;
+			}
+
+		if (iTransferTextBuf != NULL)
+			{
+			delete iTransferTextBuf;
+			iTransferTextBuf = NULL;	
+			}
+			
+		iArrayCount = 0;
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sbheapwrapper.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,147 @@
+// 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:
+// CHeapWrapper implementation
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include "sbheapwrapper.h"
+#include <connect/panic.h>
+
+namespace conn
+	{
+	CHeapWrapper* CHeapWrapper::NewL()
+	/**
+	Symbian 1st phase constructor
+	
+	@return pointer to a newly created CHeapWrapper object
+	*/
+		{
+		CHeapWrapper* self = new (ELeave) CHeapWrapper();
+		
+		return self;
+		}
+	
+	TPtrC8& CHeapWrapper::ReadBufferL(const RChunk& aChunk)
+	/**
+	Getter for the GSH descriptor
+	
+	@param aChunk The RChunk to interrogate for the heap information
+	@return reference to the descriptor stored on the global shared heap
+	*/
+		{
+		if (Header(aChunk).LockedFlag())
+			{
+			User::Leave(KErrInUse);
+			}
+
+		CleanReadBuffer();
+			
+		iReadBuf = new (ELeave) TPtrC8(Buffer(aChunk));
+
+		return *iReadBuf;
+		}
+		
+	TPtr8& CHeapWrapper::WriteBufferL(const RChunk& aChunk)
+	/**
+	Lock the heap and return a reference to the descriptor on the GSH
+	
+	@param aChunk The RChunk to interrogate for the heap information
+	@return reference to the descriptor stored on the global shared heap
+	*/
+		{
+		if (Header(aChunk).LockedFlag())
+			{
+			User::Leave(KErrInUse);
+			}
+
+		CleanReadBuffer();
+
+		TPtr8& des = Buffer(aChunk);
+		
+		// Blank the descriptor as it's a write buffer
+		des.Zero();
+		
+		return des;
+		}
+		
+	THeapWrapperHeader& CHeapWrapper::Header(const RChunk& aChunk) const
+	/**
+	Getter for the protocol structure
+	
+	@param aChunk The RChunk to interrogate for the heap information
+	@return Pointer to the header structure containing heap protocol information
+	*/
+		{
+		return *reinterpret_cast<THeapWrapperHeader*>(aChunk.Base() + KHeaderOffset);
+		}
+		
+	TInt CHeapWrapper::ResetHeap(const RChunk& aChunk)
+	/**
+	Reset all of the protocol data in the stack if we're the first users
+	
+	@param aChunk The RChunk to interrogate for the heap information
+	@return KErrNone always.
+	*/
+		{
+		TInt err = KErrNone;
+		TUint8* heapPtr = aChunk.Base();
+		
+		new (&Header(aChunk)) THeapWrapperHeader;
+		
+		THeapWrapperHeader& header = Header(aChunk);
+		header.iFinished = ETrue;
+		header.SetLockedFlag(EFalse);
+		
+		// placement new a new descriptor on the heap to initialise it
+		new (heapPtr + KDescriptorOffset) TPtr8(heapPtr + KDataOffset, 0, aChunk.Size() - KDataOffset);
+
+		return err;
+		}
+
+	TPtr8& CHeapWrapper::Buffer(const RChunk& aChunk)
+ 	/**
+ 	@param aChunk The RChunk to interrogate for the heap information
+ 	@return reference to the descriptor stored on the global shared heap
+ 	*/
+  		{
+  		TUint8* heapPtr = aChunk.Base();
+		
+		// Set the descriptor
+		TPtr8* descriptor = reinterpret_cast<TPtr8*>(heapPtr + KDescriptorOffset);
+		const TInt length = descriptor->Length();
+		const TInt maxLength = descriptor->MaxLength();
+		descriptor->Set(heapPtr + KDataOffset, length, maxLength);
+
+		return *descriptor;
+		}
+		
+	void CHeapWrapper::CleanReadBuffer()
+	/**
+	Delete and NULL the read buffer if necessary
+	*/
+		{
+		delete iReadBuf;
+		iReadBuf = NULL;
+		}
+		
+	CHeapWrapper::~CHeapWrapper()
+		{
+		CleanReadBuffer();
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sblog.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,157 @@
+// 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:
+// Implementation of logging functions
+// 
+//
+
+/**
+ @file
+*/
+
+#include "sblog.h"
+
+namespace conn
+	{
+	
+	namespace securebackuplog 
+		{
+        #if (defined(SBE_LOGGING_DEBUG_ONLY) && defined(_DEBUG)) || defined(SBE_LOGGING_DEBUG_AND_RELEASE)
+
+        /** The flogger directory
+    	@internalComponent */    
+    	_LIT(KLogDirectory,"connect");
+
+    	/** The flogger file
+    	 @internalComponent */
+        _LIT(KLogFile, "securebackup.txt");
+
+        /** The maximum length of text that can be logged
+    	 @internalComponent */
+    	const TInt KMaxLogData = 0x200;
+    
+        void __LogRaw( TDes& aData )
+        /** Performs the logging operation based upon SBEngine.mmh macro configuration
+		@param aData The data to be logged
+        */
+            {
+		    #if defined(SBE_LOGGING_METHOD_FLOGGER)
+	        	RFileLogger::Write(KLogDirectory, KLogFile, EFileLoggingModeAppend, aData);
+	    	#endif    
+
+            #if defined(SBE_LOGGING_METHOD_RDEBUG) || defined(SBE_LOGGING_METHOD_UI)
+            
+            /** The logging component name
+    		 @internalComponent */
+        	_LIT(KLogComponentName, "[SBE] ");
+        	
+                aData.Insert( 0, KLogComponentName );
+
+                #if defined( SBE_LOGGING_METHOD_UI )
+                    User::InfoPrint( aData );
+                #endif
+            	#if defined( SBE_LOGGING_METHOD_RDEBUG )
+                	RDebug::Print( _L("%S"), &aData );
+            	#endif
+            #endif
+            }
+
+
+
+
+		void __Log( TRefByValue<const TDesC> aFmt, ... )	
+	 	/** Logs a message to FLOGGER and to the UI depending on
+	 	controlling macros.
+	 	
+	 	Note that FLOG macros are probably disabled in release builds, 
+	 	so we might need to use something else for logging to files
+
+		@internalComponent
+		@param aFmt The formatting codes
+        */
+			{
+			VA_LIST list;
+		    VA_START(list,aFmt);
+		    
+		    TBuf< KMaxLogData > buf;
+		    buf.FormatList(aFmt,list); 
+		    
+            __LogRaw( buf );
+			}
+
+
+        void __DebugDump( const TDesC& aFormat, const TUint8* aAddress, TInt aLength )
+        /** Logs binary data as ASCII (hex encoded). Useful for debugging data transfer
+        @param aFormat The format specifier, must always include a string format identifer, i.e. <code>%S</code>
+        @param aAddress The starting memory address containing data that is to be logged
+        @param aLength The amount of data (in bytes) to log, starting at <code>aAddress</code>
+        */
+            {
+        	_LIT( KEndOfAddressText, ": ");
+            _LIT( KDoubleSpace, "  " );
+            _LIT( KSingleSpace, " " );
+
+            TInt len = aLength;
+            const TInt maxLen = aLength;
+            const TUint8* pDataAddr = aAddress;
+
+            TBuf<KMaxLogData> formatBuffer;
+        	TBuf<81> out;
+        	TBuf<20> ascii;
+        	TInt offset = 0;
+        	const TUint8* a = pDataAddr;
+            //
+        	while(len>0)
+        		{
+        		out.Zero();
+        		ascii.Zero();
+        		out.AppendNumFixedWidth((TUint) a, EHex, 8);
+        		out.Append( KEndOfAddressText );
+
+                TUint b;
+        		for (b=0; b<16; b++)
+        			{
+                    TUint8 c = ' ';
+                    if	((pDataAddr + offset + b) < pDataAddr + maxLen)
+        	            {
+        	            c = *(pDataAddr + offset + b);
+        				out.AppendNumFixedWidth(c, EHex, 2);
+        	            }
+                    else
+        	            {
+        				out.Append( KDoubleSpace );
+        	            }
+
+                    out.Append( KSingleSpace );
+
+                    if (c<0x20 || c>=0x7f || c=='%')
+        				c=0x2e;
+
+                    ascii.Append(TChar(c));
+        			}
+        		
+                out.Append(ascii);
+                out.ZeroTerminate();
+
+                formatBuffer.Format( aFormat, &out );
+                __LogRaw( formatBuffer );
+
+                a += 16;
+        		offset += 16;
+        		len -= 16;
+                }
+            }
+			
+        #endif
+		}//securebackuplog
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sbmain.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,169 @@
+// 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:
+// Main entry point in the process
+// 
+//
+
+/**
+ @file
+*/
+
+#include "sbmain.h"
+#include "sblog.h"
+#include "sbeserver.h"
+#include "abserver.h"
+#include <connect/tserverstart.h>
+#include "sbedataownermanager.h"
+#include "ecom/ecom.h"
+
+namespace conn
+	{
+	
+	void CSBActiveScheduler::Error(TInt aError) const
+	/**
+	Executed by the active scheduler when an error occurs. Ideally errors 
+	should be handled in the RunError() method of active objects and 
+	not in here. 
+	
+	It logs an error and stops the active scheduler, which will cause
+	execution to terminate.
+	
+	@param aError The error code
+	*/
+		{
+		RDebug::Print(_L("Secure Backup unhandled error %d"), aError);
+		Stop();
+		}
+	}
+
+
+using namespace conn;
+
+//
+// EKA1 server startup code - platform unspecific.
+
+
+static void RunServerL()
+	/**
+	Installs active scheduler, creates the CSBEServer and CABServer objects,
+	signals the client, and begins to handle client requests..
+
+	@param aStart A TServerStart object passed in by the client
+	@leave RThread::Rename() If an error is returned
+	*/
+	{
+	//
+	// Create and install an active scheduler.
+    CSBActiveScheduler* pScheduler = new (ELeave) CSBActiveScheduler();
+	CleanupStack::PushL(pScheduler);
+	CActiveScheduler::Install(pScheduler);
+	
+	CDataOwnerManager* pDOM = CDataOwnerManager::NewLC();
+
+	// create the two servers to run in this process
+	CSBEServer* pSBEServer = CSBEServer::NewLC(pDOM);
+    CABServer* pABServer = CABServer::NewLC(pDOM);
+    
+    // register the AB Server with the DOM
+    pDOM->SetActiveBackupServer(pABServer);
+
+	// Rename the thread (for debugging)
+	User::RenameThread(KSBImageName);
+
+    RProcess::Rendezvous(KErrNone);
+
+	//
+	// Start the AS.  Will return after 2 seconds
+	// of inactivity on the server.
+	CSBActiveScheduler::Start();
+	
+	TDriveList driveList;
+	TBURPartType burPartType = EBURUnset;
+	TBackupIncType buIncType = ENoBackup;
+	driveList.FillZ();
+	
+	// Ensure that the device is put back into normal mode, in case a disconnection has ocurred
+	pDOM->SetBURModeL(driveList, burPartType, buIncType);
+
+	CleanupStack::PopAndDestroy(pABServer);
+	CleanupStack::PopAndDestroy(pSBEServer);
+	CleanupStack::PopAndDestroy(pDOM);
+	CleanupStack::PopAndDestroy(pScheduler);
+	}
+
+
+static TInt RunServer()
+/**
+Creates cleanup framework and call leaving variant of RunServer
+
+@param aStart A TServerStart object 
+@return Any error trapped by RunServerL
+*/
+	{
+	__UHEAP_MARK;
+	CTrapCleanup* pCleanup = CTrapCleanup::New();
+	TInt nRet = KErrNoMemory;
+
+	if(pCleanup != NULL)
+		{
+#ifdef __OOM_TESTING__
+	    TInt i = 0;
+	    while (nRet == KErrNoMemory || nRet == KErrNone)
+		    {
+		    __UHEAP_SETFAIL(RHeap::EDeterministic,i++);
+		    __UHEAP_MARK;
+
+		    TRAP(nRet, RunServerL());
+		    // required because we have an indirect
+		    // dependency on ecom, we apparently need
+		    // need to clean up after our dependencies
+		    REComSession::FinalClose();
+
+		    __UHEAP_MARKEND;
+		    __UHEAP_RESET;
+		    }
+#else
+		TRAP(nRet, RunServerL());
+#endif			
+	    delete pCleanup;
+	    }
+
+    // required because we have an indirect
+    // dependency on ecom, we apparently need
+    // need to clean up after our dependencies
+    REComSession::FinalClose();
+
+    __UHEAP_MARKEND;
+    return nRet;
+    }
+
+
+
+
+  
+TInt E32Main()
+/**
+Standard Symbian OS entry point
+
+@return Symbian OS internal value.
+*/
+	{
+	TInt nRet = KErrNone;
+	
+    nRet = RunServer();
+    
+	return nRet;
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sbpackagedatatransfer.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1808 @@
+
+// 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:
+// Implementation of CPackageDataTransfer
+// 
+//
+
+/**
+ @file
+*/
+#include "sbedataowner.h"
+#include "sbebufferhandler.h"
+#include "sbpackagedatatransfer.h"
+#include "sblog.h"
+
+#include <babackup.h>
+#include <swi/backuprestore.h>
+#include <swi/sisregistryentry.h>
+#include <swi/sisregistrypackage.h>
+
+#include "sbeparserdefs.h"
+
+namespace conn
+	{
+	_LIT(KSys, "?:\\sys\\*");
+	_LIT(KResource, "?:\\resource\\*");
+	_LIT(KPrivateMatch, "?:\\private\\*");
+	_LIT(KImport, "*\\import\\*");
+	_LIT(KTempPath, ":\\system\\temp\\");
+	
+	CPackageDataTransfer* CPackageDataTransfer::NewL(TUid aPid, CDataOwnerManager* aDOM)
+	/** Standard Symbian Constructor
+	
+	@param aPid Package Id
+	@return a CPackageDataTransfer object
+	*/
+		{
+		CPackageDataTransfer* self = CPackageDataTransfer::NewLC(aPid, aDOM);
+		CleanupStack::Pop(self);
+		return self;
+		}
+	
+	CPackageDataTransfer* CPackageDataTransfer::NewLC(TUid aPid, CDataOwnerManager* aDOM)
+	/** Standard Symbian Constructor
+	
+	@param aPid Package Id
+	@return a CPackageDataTransfer object
+	*/
+		{
+		CPackageDataTransfer *self = new(ELeave) CPackageDataTransfer(aPid, aDOM);
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		return self;
+		}
+
+	CPackageDataTransfer::CPackageDataTransfer(TUid aPid, CDataOwnerManager* aDOM) : 
+	/** Standard C++ Constructor
+	
+	@param aPid Package Id
+	*/
+		iBufferSnapshotReader(NULL), 
+		iBufferFileWriter(NULL), iBufferSnapshotWriter(NULL), 
+		iPackageID(aPid), iSnapshot(NULL), iMetaData(NULL), ipDataOwnerManager(aDOM), iRestored(EFalse)
+	  	{
+	  	// needed for intiliazion
+	  	iDriveList.SetLength(KMaxDrives);
+	  	iDriveList.FillZ();
+	  	// needed for hashes in registry on drive C (i.e. MMC card app's hash)
+	  	iDriveList[EDriveC] = ETrue;
+		}
+		
+	void CPackageDataTransfer::ConstructL()
+	/** Standard Symbian second phase constructor
+	*/
+		{
+		User::LeaveIfError(iSWIRestore.Connect());
+		User::LeaveIfError(iSWIBackup.Connect());
+		User::LeaveIfError(iFs.Connect());
+		User::LeaveIfError(iFs.ShareProtected());
+		iRegistrationFile = HBufC::NewL(0);
+		iFileName = HBufC::NewL(KMaxFileName);
+		iTempFileName = HBufC::NewL(KMaxFileName);
+		}
+
+	CPackageDataTransfer::~CPackageDataTransfer()
+	/** Standard C++ Destructor
+	*/
+	  	{
+		iSWIRestore.Close();
+		iSWIBackup.Close();
+		iFileHandle.Close();
+		iFiles.ResetAndDestroy();
+		iPublicSelections.ResetAndDestroy();
+		
+		delete iRegistrationFile;
+		delete iBufferFileWriter;
+		delete iBufferSnapshotReader;
+		delete iBufferSnapshotWriter;
+		delete iSnapshot;
+		delete iMetaData;
+		delete iFileName;
+		delete iTempFileName;
+		iFs.Close();
+		}
+
+	
+	void CPackageDataTransfer::WriteData(TAny* aItem, TPtr8& aBuffer, 
+										 TInt aSize)
+	/** Used to write data to a buffer
+	
+	@param aItem Item to write
+	@param aBuffer Buffer to write aItem to
+	@param aSize Size of the aItem
+	*/										 
+		{
+		TUint8 *pos = reinterpret_cast<TUint8*>(aItem);
+		for (TInt i = 0; i < aSize; ++i)
+			{
+			aBuffer.Append(pos[i]);
+			}
+		}
+
+	TUid CPackageDataTransfer::PackageId() const
+	/** Returns the package Id
+	
+	@return the package Id
+	*/
+		{
+		return iPackageID;
+		}
+
+	void CPackageDataTransfer::BuildPackageFileList()
+	/** Builds the file list of all files in the package on the given drive
+	
+	@param aDriveNumber drive the files must be on to be included in the list
+	@param apSnapshot (OPTIONAL)A file will only be included if the file is not 
+					  in the snapshot is newer than the file in the snapshot
+	@param aFileNames on return the list of files
+	*/
+		{
+		__LOG("CPackageDataTransfer::BuildPackageFileListL() - START");
+		// Establish a connection to the registry and read the list of
+		// filenames into array.
+		// 
+		
+		iDriveList.SetLength(KMaxDrives);
+		iDriveList.FillZ();
+		// also set EDriveC to True for hashesh of the registry
+		iDriveList[EDriveC] = ETrue;
+		
+		TUint count = iFiles.Count();
+		__LOG1("CPackageDataTransfer::BuildPackageFileListL() - No of files: %d", count);
+		while (count > 0)
+			{
+			count--;
+			TBool remove = EFalse;
+			TFileName fileName (*iFiles[count]);
+			 
+			if ((fileName.FindC(KPrimaryBackupRegistrationFile) < 0) &&
+				(fileName.MatchC(KSys) < 0) &&
+				(fileName.MatchC(KResource) < 0) && 
+  				(fileName.MatchC(KImport) < 0 ))
+				{
+				remove = ETrue;	
+				}
+			
+			// check read only media
+			if (!remove && (NULL != iFs.IsFileInRom(fileName)))
+				{
+				remove = ETrue;
+				}
+				
+			// check if real entry
+			if (!remove)
+				{
+				TEntry entry;
+				TInt err = iFs.Entry(fileName, entry);
+				if (err != KErrNone)
+					{
+					remove = ETrue;
+					}
+				}
+			
+			// remove?
+			if (remove)
+				{
+				delete iFiles[count];
+				iFiles[count] = NULL;
+				iFiles.Remove(count);
+				}
+			else
+				{
+				// append to drive list
+				TInt num;
+				TChar ch = fileName[0];
+				TInt err = iFs.CharToDrive(ch, num);
+				if (err == KErrNone)
+					{
+					iDriveList[num] = ETrue;
+					}
+				}
+			} // for
+			
+		
+		#ifdef SBE_LOGGING_ENABLED
+			const TUint fNameCount = iFiles.Count();
+	        if  (fNameCount)
+	            {
+	            for(TUint k=0; k<fNameCount; k++)
+	                {
+	                const TDesC& file = *iFiles[k];
+	                __LOG2("CPackageDataTransfer::BuildPackageFileListL() - Files Added - file entry[%03d] %S", k, &file);
+	                }
+	            }
+		#endif
+		
+		
+		__LOG("CPackageDataTransfer::BuildPackageFileListL() - END");		
+		}
+
+	
+	void CPackageDataTransfer::GetExpectedDataSizeL(TPackageDataType aTransferType, TDriveNumber aDriveNumber, TUint& aSize)
+	/** Get the expected data size of a request for data
+	
+	@param aTransferType the type of data to check the size of
+	@param aDriveNumber the drive to check
+	@param aSize on return the size of the data
+	*/
+		{
+		__LOG("CPackageDataTransfer::GetExpectedDataSizeL - Begin getmetadata");
+		if (iMetaData == NULL)
+			{
+			TRAPD(err, iMetaData = iSWIBackup.GetMetaDataL(iPackageID, iFiles));
+			
+			if(KErrNotSupported == err)
+			    {//Non-Removable package, nothing to backup
+			    aSize = 0;
+			    __LOG("CPackageDataTransfer::GetExpectedDataSizeL - GetMetaDataL - KErrNotSupported");
+			    return;
+			    }
+			else if(KErrNone != err)
+			    {
+			    __LOG1("CPackageDataTransfer::GetExpectedDataSizeL - GetMetaDataL leave with %d", err);
+			    User::Leave(err);
+			    }
+			
+			iMetaDataSize = iMetaData->Size();
+			BuildPackageFileList();
+			}
+		__LOG("CPackageDataTransfer::GetExpectedDataSizeL - End getmetadata");
+		
+		if (!IsDataOnDrive(aDriveNumber))
+			{
+			// no data on drive
+			aSize = 0;
+			return;
+			}
+		
+		aSize = iMetaData->Size();
+		TUint count = iFiles.Count();
+		
+		switch (aTransferType)
+			{
+			case ESystemSnapshotData:
+				{
+				__LOG1("CPackageDataTransfer::GetExpectedDataSizeL() - START - ESystemSnapshotData - aDriveNumber: %c", aDriveNumber + 'A');
+				// Find all files
+				aSize = (count * sizeof(TSnapshot));
+				__LOG1("CPackageDataTransfer::GetExpectedDataSizeL() - passive snapshot count: %d", count);
+				for (TUint x = 0; x < count; x++)
+					{
+					const TDesC& fileName = *iFiles[x];
+                	const TInt fileSize = fileName.Length();;
+                	__LOG2("CPackageDataTransfer::GetExpectedDataSizeL() - passive snapshot file: %S, size: %d", &fileName, fileSize);
+					aSize += fileSize;
+					} // for x
+					
+				break;
+				}
+			case ESystemData:
+				{
+				__LOG1("CPackageDataTransfer::GetExpectedDataSizeL() - START - ESystemData - aDriveNumber: %c", aDriveNumber + 'A');
+				
+				aSize += sizeof(TInt);
+			
+				TEntry entry;
+				__LOG1("CPackageDataTransfer::GetExpectedDataSizeL() - passive file count: %d", count);
+				for (TUint x = 0; x < count; x++)
+					{
+					const TDesC& fileName = *iFiles[x];
+					TInt err = iFs.Entry(fileName, entry);
+					TUint fileSize = entry.iSize;
+					__LOG2("CPackageDataTransfer::GetExpectedDataSizeL() - passive file: %S, size: %d", &fileName, fileSize);
+					switch(err)
+						{
+					case KErrNone:
+						aSize += fileSize;
+						break;
+					case KErrNotFound:
+					case KErrPathNotFound:
+					case KErrBadName:
+						__LOG2("CPackageDataTransfer::GetExpectedDataSizeL() - error getting passive file: %S, error: %d", &fileName, err);
+						break;
+					default:
+						User::Leave(err);
+						}
+					}
+					
+				break;
+				}
+			default:
+				{
+				__LOG2("CPackageDataTransfer::GetExpectedDataSizeL() - No case for TransferType: %d, data owner 0x%08x", aTransferType, iPackageID.iUid);
+				User::Leave(KErrNotSupported);
+				}
+			} // switch
+		__LOG2("CPackageDataTransfer::GetExpectedDataSizeL() - END - size is: %d, data owner 0x%08x", aSize, iPackageID.iUid);
+		}
+	
+	void CPackageDataTransfer::RequestDataL(TDriveNumber aDriveNumber, 
+	    									TPackageDataType aTransferType, 
+	    									TPtr8& aBuffer,
+	    									TBool& aLastSection)
+		/** Request data
+		
+		@param aDriveNumber the drive you want data from
+		@param aTransferType the type of data you require
+		@param aBuffer the buffer to write the data
+		@param aLastSection has all the data been supplied. If all data is not
+			   supplied a further calls to the function will return the extra
+			   data.
+		*/
+		{
+		__LOG6("CPackageDataTransfer::RequestDataL() - START - aDrive: %c, aTransferType: %d, iSecureId: 0x%08x, iState.iState: %d, iState.iTransferType: %d, aBuffer.Length(): %d", aDriveNumber + 'A', aTransferType, iPackageID.iUid, iState.iState, iState.iTransferType, aBuffer.Length());
+        //__LOGDATA("CPackageDataTransfer::RequestDataL() - %S", aBuffer.Ptr(), aBuffer.Length() );
+		
+		TInt err = KErrNone;
+		
+		if (iMetaData == NULL)
+			{
+			TRAPD(err, iMetaData = iSWIBackup.GetMetaDataL(iPackageID, iFiles));
+			            
+            if(KErrNotSupported == err)
+                {//Non-Removable package, nothing to backup
+                iState.iState = ENone;
+                Cleanup();
+                return;
+                }
+            else if(KErrNone != err)
+                {
+                iState.iState = ENone;
+                Cleanup();
+                User::Leave(err);
+                }
+            
+			iMetaDataSize = iMetaData->Size();
+			BuildPackageFileList();
+			}
+		
+		// Check our state
+		if (!((iState.iState == ENone) || (iState.iState == EBuffer) ||
+		     ((iState.iState == ERequest) && (iState.iDriveNumber == aDriveNumber) && 
+		      (iState.iTransferType == aTransferType))))
+			{
+		    __LOG("CPackageDataTransfer::RequestDataL() - bad state => ERROR => KErrNotReady");
+			User::Leave(KErrNotReady);			
+			}
+			
+		// Set the state?
+		if (iState.iState == ENone)
+			{
+			iState.iDriveNumber = aDriveNumber;
+			iState.iTransferType = aTransferType;
+			}
+			
+		switch (aTransferType)
+			{
+			case ESystemSnapshotData:
+				{
+				TRAP(err, RequestSnapshotL(aDriveNumber, aBuffer, aLastSection));
+				break;
+				}
+			case ESystemData:
+				{
+				TRAP(err, DoRequestDataL(aDriveNumber, aBuffer, aLastSection));
+				break;
+				}
+			default:
+				{
+				err = KErrNotSupported;
+				}
+			} // switch
+		
+		if (err != KErrNone)
+			{
+			iState.iState = ENone;
+			Cleanup();
+			__LOG1("CPackageDataTransfer::RequestDataL() - Left with error: %d", err);
+			User::Leave(err);
+			} // if
+		__LOG("CPackageDataTransfer::RequestDataL() - END");
+		}
+
+
+	void CPackageDataTransfer::ReadData(TAny* aDestinationAddress, const TDesC8& aBuffer, TInt aSize)
+	/** Read data from the given buffer
+	
+	@param aItem the item to fill
+	@param aBuffer the buffer to read the data from
+	@param aSize the size of the item to fill
+	*/
+		{
+        TUint8* pos = reinterpret_cast<TUint8*>(aDestinationAddress);
+		for (TInt i = 0; i < aSize; ++i)
+			{
+			pos[i] = aBuffer[i];
+			}
+		}
+
+	void CPackageDataTransfer::SupplyFileDataL( const TDesC8& aBuffer, TBool aLastSection)
+	/** Restores files from the buffer to the package.
+	
+	@param aBuffer the buffer to read data from
+	@param aLastSection has all data been supplied
+	*/
+		{
+		__LOG1("CPackageDataTransfer::SupplyFileDataL() - START - aLastSection: %d", aLastSection);
+		TUint8* current = const_cast<TUint8*>(aBuffer.Ptr());
+		const TUint8* end = current + aBuffer.Size();
+		while (current < end)
+			{
+			if (!iFixedHeaderRead)
+				{
+				if (ReadFromBufferF(iFixedHeader, current, end) == EFalse)
+					{
+					__LOG("CPackageDataTransfer::SupplyFileDataL() - ReadFromBufferF() returned False so breaking!");
+					break;
+					} // if
+				
+				__LOG1("CPackageDataTransfer::SupplyFileDataL() - fixed header - iFileNameLength:  %d", iFixedHeader.iFileNameLength);
+                __LOG1("CPackageDataTransfer::SupplyFileDataL() - fixed header - iFileSize:        %d", iFixedHeader.iFileSize);
+                __LOG1("CPackageDataTransfer::SupplyFileDataL() - fixed header - iAttributes:      %d", iFixedHeader.iAttributes);
+                
+                if ((iFixedHeader.iFileNameLength > KMaxFileName) || (!iFixedHeader.iFileNameLength))
+					{
+					__LOG1("CBufferFileReader::SupplyFileDataL() - Leaving - iFileNameLength: %d more then MaxLength", iFixedHeader.iFileNameLength);
+					User::Leave(KErrOverflow);
+					}
+                
+				iFixedHeaderRead = ETrue;
+				} //if
+			if (!iFileNameRead)
+				{
+				TPtr8 ptr(reinterpret_cast<TUint8*>(const_cast<TUint16*>(iFileName->Des().Ptr())), iBytesRead,iFixedHeader.iFileNameLength * KCharWidthInBytes);
+				
+				if (ReadFromBufferV(ptr, iFixedHeader.iFileNameLength * KCharWidthInBytes, current, end) == EFalse)
+					{
+					iBytesRead = ptr.Size();
+					__LOG1("CPackageDataTransfer::SupplyFileDataL() - ReadFromBufferV() returned False - Filename bytes read: %d", iBytesRead);
+					break;
+					} // if
+				
+				if (iFixedHeader.iFileNameLength > KMaxFileName)
+					{
+					__LOG("CBufferFileReader::SupplyFileDataL() - Leave with KErrOverflow");
+					User::Leave(KErrOverflow);
+					}
+				
+				iFileName->Des().SetLength(iFixedHeader.iFileNameLength);
+				iFileNameRead = ETrue;
+				
+				__LOG1("CPackageDataTransfer::SupplyFileDataL() - FileName: %S", iFileName);
+				}
+				
+				if (!iFileOpen)
+					{
+					TFileName tempPath;
+					// 0 is first character which will reperesent a drive
+					tempPath.Append((*iFileName)[0]);
+					tempPath.Append(KTempPath);
+					// Create file on the drive
+					TInt tempErr = iFs.MkDirAll(tempPath);
+					if (tempErr == KErrNone || tempErr == KErrAlreadyExists)
+						{
+						TFileName tempFile;
+						tempErr = iFileHandle.Temp(iFs, tempPath, tempFile, EFileWrite);
+						if (iTempFileName)
+							{
+							delete iTempFileName;
+							}
+						iTempFileName = tempFile.AllocL();
+						}
+					
+					if (tempErr != KErrNone)
+						{
+						__LOG2("CPackageDataTransfer::SupplyFileDataL() - Left creating temp file in: %S , with %d", &tempPath, tempErr);
+						User::Leave(tempErr);
+						}
+					
+					
+					iFileOpen = ETrue;
+					}
+				
+			// Write to the file
+			TInt filesize;
+			iFileHandle.Size(filesize);
+			
+			if ((end - current) >= (iFixedHeader.iFileSize - filesize))
+				{
+				TPtr8 ptr(current, iFixedHeader.iFileSize - filesize, iFixedHeader.iFileSize - filesize);
+				User::LeaveIfError(iFileHandle.Write(ptr));
+				
+				// Write the attributes & modified time
+				User::LeaveIfError(iFileHandle.Set(iFixedHeader.iModified, iFixedHeader.iAttributes, KEntryAttNormal));
+				
+				TInt err = KErrNone;
+				if (((*iFileName).FindC(KPrimaryBackupRegistrationFile) >= 0) ||
+					((*iFileName).MatchC(KSys) >= 0) ||
+					((*iFileName).MatchC(KResource) >= 0) ||
+  					((*iFileName).MatchC(KImport) >= 0) )
+					{
+					__LOG("CPackageDataTransfer::SupplyFileDataL() - about to call RestoreFileL()");		
+					TRAP(err, iSWIRestore.RestoreFileL(iFileHandle, *iFileName));
+					__LOG1("CPackageDataTransfer::SupplyFileDataL() - RestoreFileL() - err :%d", err);		
+					}
+				else if ((*iFileName).MatchC(KPrivateMatch) >= 0)
+					{
+					User::LeaveIfError(iFs.MkDirAll((*iFileName)));
+					User::LeaveIfError(iFileHandle.Rename((*iFileName)));
+					}
+				
+								
+				// Finished reset state
+				iFileHandle.Close();
+				// Delete temp file
+				if (iTempFileName)
+					{
+					// don't care if there is error
+					iFs.Delete(*iTempFileName);
+					delete iTempFileName;
+					iTempFileName = NULL;
+					}
+				iFileOpen = EFalse;
+				iFileNameRead = EFalse;
+				iFileName->Des().SetLength(0);
+				iFixedHeaderRead = EFalse;
+				iBytesRead = 0;
+				
+				// Move current along
+				current += iFixedHeader.iFileSize - filesize;
+				}
+			else
+				{	
+				TInt fsize = end - current;
+				TPtr8 ptr(current, fsize, fsize);
+				User::LeaveIfError(iFileHandle.Write(ptr));
+				break;
+				}
+			} // while
+			
+		if (aLastSection && iFileOpen)
+			{
+			User::Leave(KErrUnderflow);
+			} // if
+		__LOG("CPackageDataTransfer::SupplyFileDataL() - END");
+		} // SupplyFileDataL
+			
+	void CPackageDataTransfer::SupplyDataL(TDriveNumber aDriveNumber, 
+    									   TPackageDataType aTransferType, 
+    									   TDesC8& aBuffer,
+    									   TBool aLastSection)
+		/** Request data
+		
+		@param aDriveNumber the drive you want data from
+		@param aTransferType the type of data you require
+		@param aBuffer the buffer to write the data
+		@param aLastSection is this the last section
+		*/
+		{
+		__LOG5("CPackageDataTransfer::SupplyDataL() - START - aDrive: %c, aTransferType: %d, iSecureId: 0x%08x, iState.iState: %d, iState.iTransferType: %d", aDriveNumber + 'A', aTransferType, iPackageID.iUid, iState.iState, iState.iTransferType);
+	
+		if (!iRestored)
+			{
+			TInt err = KErrNone;
+			if (!((iState.iState == ENone) ||
+			     ((iState.iState == ESupply || iState.iState == EBuffer) && (iState.iDriveNumber == aDriveNumber) && 
+			      (iState.iTransferType == aTransferType))))
+				{
+				__LOG("CPackageDataTransfer::SupplyDataL() - bad state => ERROR => KErrNotReady");
+				User::Leave(KErrNotReady);			
+				}
+				
+			// Set the state?
+			if (iState.iState == ENone)
+				{
+				iState.iDriveNumber = aDriveNumber;
+				iState.iTransferType = aTransferType;
+				} // if
+				
+			switch (aTransferType)
+				{
+				case ESystemSnapshotData:
+					{
+					TRAP(err, SupplySnapshotL(aDriveNumber, aBuffer, aLastSection));
+					break;
+					}
+				case ESystemData:
+					{
+					TRAP(err, DoSupplyDataL(aDriveNumber, aBuffer, aLastSection));
+					break;
+					}
+				default:
+					{
+					err = KErrNotSupported;
+					}
+				} // switch
+				
+			if (err != KErrNone) // Must reset state on error
+				{
+				iState.iState = ENone;
+				if (err != KErrAlreadyExists)
+					{
+					Cleanup();
+					iSWIRestore.Close();
+					User::LeaveIfError(iSWIRestore.Connect());
+					}
+				__LOG1("CPackageDataTransfer::SupplyDataL() - Left with error: %d", err);
+				User::Leave(err);
+				} //else
+			}
+		
+		__LOG("CPackageDataTransfer::SupplyDataL() - END");
+		
+		}
+
+    void CPackageDataTransfer::DoSupplyDataL(TDriveNumber /*aDriveNumber*/, const TDesC8& aBuffer, TBool aLastSection)
+	/** Handles the actual supply of package data
+	
+	@param aDriveNumber not used.
+	@param aBuffer the data that was supplied
+	@param aLastSection was this the last section of data
+	*/
+    	{
+    	__LOG3("CPackageDataTransfer::DoSupplyDataL() - START - aBuffer length: %d, aLastSection: %d, iState: %d", aBuffer.Length(), aLastSection, iState.iState);
+        //__LOGDATA("CPackageDataTransfer::DoSupplyDataL() -       %S", aBuffer.Ptr(), Min( aBuffer.Length(), 1024 ));
+
+		TInt currentPos = 0;
+        const TInt sourceBufferLength = aBuffer.Length();
+
+        if  ( iState.iState != ESupply )
+            {
+		    if (iState.iState == ENone )
+			    {
+			    __LOG("CPackageDataTransfer::DoSupplyDataL() - iState == ENone - set up for initial meta data read...");
+
+                // Retrieve metadata and file list from the buffer
+			    ReadData(&iMetaDataSize, aBuffer, sizeof(TInt));
+			    __LOG1("CPackageDataTransfer::DoSupplyDataL() - meta data size: %d", iMetaDataSize);
+			    currentPos += sizeof(TInt);
+			    
+			    if (iMetaDataSize >= (KMaxTInt/2) || iMetaDataSize < 0)
+				    {
+				    __LOG("CPackageDataTransfer::DoSupplyDataL() - size read is too big");
+				    User::Leave(KErrCorrupt);
+				    }
+			    
+			    __LOG1("CPackageDataTransfer::DoSupplyDataL() - creating meta data buffer of length: %d bytes", iMetaDataSize);
+			    HBufC8* metaDataBuffer = HBufC8::NewL(iMetaDataSize);
+                delete iMetaData;
+			    iMetaData = metaDataBuffer;
+                TPtr8 data(iMetaData->Des());
+
+                if (iMetaDataSize > sourceBufferLength )
+				    {
+				    __LOG("CPackageDataTransfer::DoSupplyDataL() - not enough source data to obtain entire meta data in one pass...");
+
+                    if (aLastSection)
+					    {
+					    __LOG("CPackageDataTransfer::DoSupplyDataL() - Underflow1");
+					    User::Leave(KErrUnderflow);
+					    }
+                    else
+                        {
+                        data.Append(aBuffer.Mid(currentPos));
+				        iState.iState = EBuffer;
+				        __LOG2("CPackageDataTransfer::DoSupplyDataL() - got %d bytes of meta data (%d bytes remaining) => changing state to EBuffer", data.Length(), iMetaDataSize - data.Length() );
+                        }
+				    }
+			    else
+				    {
+				    __LOG("CPackageDataTransfer::DoSupplyDataL() - able to read entire meta data buffer in a single pass... ");
+				    data.Append(aBuffer.Mid(currentPos, iMetaDataSize));
+				    currentPos += iMetaDataSize;
+				    }
+			    }
+		    else if (iState.iState == EBuffer)
+			    {
+			    __LOG1("CPackageDataTransfer::DoSupplyDataL() - iState == EBuffer, iMetaData length: %d", iMetaData->Length());
+			    TPtr8 ptr( iMetaData->Des() );
+			    const TInt leftToRead = iMetaDataSize - ptr.Length();
+                __LOG1("CPackageDataTransfer::DoSupplyDataL() - meta data buffer left to read: %d", leftToRead);
+
+                if (sourceBufferLength < leftToRead)
+				    {
+				    __LOG("CPackageDataTransfer::DoSupplyDataL() - not enough source data to obtain remaining required meta data in this pass...");
+
+                    if (aLastSection)
+					    {
+					    __LOG("CPackageDataTransfer::DoSupplyDataL() - Underflow2");
+					    User::Leave(KErrUnderflow);
+					    }
+					    
+				    ptr.Append(aBuffer);
+				    __LOG1("CPackageDataTransfer::DoSupplyDataL() - meta data buffered again: %d", ptr.Length());
+				    iState.iState = EBuffer;
+				    return;
+				    }
+			    else
+				    {
+				    __LOG("CPackageDataTransfer::DoSupplyDataL() - able to complete meta data read in this pass...");
+                    ptr.Append( aBuffer.Left(leftToRead) );
+                    __LOG1("CPackageDataTransfer::DoSupplyDataL() - meta data finished buffering, meta data size is now: %d", ptr.Length());
+				    currentPos += leftToRead;
+				    }
+			    }
+		    
+            const TBool metaDataComplete = ( iMetaData->Length() == iMetaDataSize );
+    	    __LOG4("CPackageDataTransfer::DoSupplyDataL() - meta data complete?: %d ( %d bytes remaining out of total: %d with current length of: %d)", metaDataComplete, iMetaDataSize - iMetaData->Length(), iMetaDataSize, iMetaData->Length() );
+
+            if  ( metaDataComplete )
+                {
+    	        __LOG("CPackageDataTransfer::DoSupplyDataL() - Asking SWI to start a package...");
+		        iState.iState = ESupply;
+		        iSWIRestore.StartPackageL(iPackageID, *iMetaData);
+		        __LOG("CPackageDataTransfer::DoSupplyDataL() - SWI StartPackageL() completed OK");
+                }
+            }
+		
+        if  ( iState.iState == ESupply )
+            {
+			__LOG1("CPackageDataTransfer::DoSupplyDataL() - iState == ESupply, currentPos: %d", currentPos);
+
+            // Now restore each file and commit the changes 
+            const TPtrC8 ptr( aBuffer.Mid( currentPos ) );
+            //__LOGDATA("CPackageDataTransfer::DoSupplyDataL() - for supplyFileData   %S", ptr.Ptr(), Min( ptr.Length(), 1024 ));
+		    
+		    SupplyFileDataL(ptr, aLastSection);
+		    __LOG("CPackageDataTransfer::DoSupplyDataL() - SupplyFileDataL() completed OK");
+		    
+		    if (aLastSection)
+			    {
+			    __LOG("CPackageDataTransfer::DoSupplyDataL() - aLastSection - asking SWI to commit package...");
+			    // now we can finalise the restore
+			    iSWIRestore.CommitPackageL();
+			    __LOG("CPackageDataTransfer::DoSupplyDataL() - Package commited OK");
+			    iRestored = ETrue;
+			    iState.iState = ENone;
+			    
+			    Cleanup();
+			    iSWIRestore.Close();
+			    User::LeaveIfError(iSWIRestore.Connect());
+			    }
+            }
+
+		__LOG("CPackageDataTransfer::DoSupplyDataL() - END");
+    	} // SupplyDataL
+		
+	void CPackageDataTransfer::SupplySnapshotL(TDriveNumber aDriveNumber, const TDesC8& aBuffer, TBool aLastSection)
+	/** Handles the actual supply of snapshot data
+	
+	@param aDriveNumber the drive the snapshot is for
+	@param aBuffer the data that was supplied
+	@param aLastSection was this the last section of data
+	*/
+		{
+		__LOG("CPackageDataTransfer::SupplySnapshotL() - START");
+		TInt err = KErrNone;
+		if (iBufferSnapshotReader == NULL)
+			{
+			CSnapshotHolder* snapshot = CSnapshotHolder::NewL();
+			delete iSnapshot;
+			iSnapshot = snapshot;
+			iSnapshot->iDriveNumber = aDriveNumber;
+			iBufferSnapshotReader = CBufferSnapshotReader::NewL(iSnapshot->iSnapshots);
+			
+			TRAP(err, iBufferSnapshotReader->StartL(aBuffer, aLastSection));
+			} // if
+		else 
+			{
+			TRAP(err, iBufferSnapshotReader->ContinueL(aBuffer, aLastSection));
+			}
+			
+		if ((err != KErrNone) || aLastSection)
+			{
+			delete iBufferSnapshotReader;
+			iBufferSnapshotReader = NULL;
+			
+			User::LeaveIfError(err);
+			} // if
+		__LOG("CPackageDataTransfer::SupplySnapshotL() - END");
+		}
+	    
+    void CPackageDataTransfer::DoRequestDataL(TDriveNumber aDriveNumber, TPtr8& aBuffer, TBool& aLastSection)
+	/** Handles the actual request for package data
+	
+	@param aDriveNumber the drive the data is from
+	@param aBuffer the buffer to put the supplied data
+	@param aLastSection has all the data been supplied. If all data is not
+		   supplied a further calls to the function will return the extra
+		   data.
+	*/
+    	{
+    	__LOG3("CPackageDataTransfer::DoRequestDataL() - START - iState: %d, iMetaData length: %d, iMetaDataSize: %d", iState.iState, iMetaData->Length(), iMetaDataSize);
+	
+        if (iState.iState == ENone || iState.iState == EBuffer)
+			{
+			if (!IsDataOnDrive(aDriveNumber))
+				{
+				aLastSection = ETrue;
+    	        __LOG("CPackageDataTransfer::DoRequestDataL() - END - no data on drive");
+                //__LOGDATA("CPackageDataTransfer::DoRequestDataL() -       %S", aBuffer.Ptr(), aBuffer.Length());
+				return;
+				}
+			
+
+            // Now write the meta data to the buffer. 
+			const TInt KSizeOfTInt = sizeof(TInt);
+			const TInt availableBuffer = aBuffer.MaxSize() - aBuffer.Size();
+			__LOG1("CPackageDataTransfer::DoRequestDataL() - available Buffer %d", availableBuffer);
+			
+			if (iState.iState == ENone)
+				{		
+				if ((availableBuffer - KSizeOfTInt) >= iMetaDataSize)
+					{
+					__LOG("CPackageDataTransfer::DoRequestDataL() - iState = ENone - can write entire meta data in single pass...");
+
+                    WriteData(&iMetaDataSize, aBuffer, KSizeOfTInt);
+					aBuffer.Append(*iMetaData);
+
+                    __LOG1("CPackageDataTransfer::DoRequestDataL() - iState = ENone - Written Meta Data, size %d", iMetaDataSize);
+					}
+				else if (availableBuffer - KSizeOfTInt > 0)
+					{
+				    // can we write metasize and something else?
+					__LOG("CPackageDataTransfer::DoRequestDataL() - iState = ENone - have room for some meta data (not all)...");
+
+                    WriteData(&iMetaDataSize, aBuffer, KSizeOfTInt);
+					
+                    // Write as much meta data as we can (allowing for buffer size) in this pass.
+                    const TInt amountOfMetaDataToWrite = availableBuffer - KSizeOfTInt;
+					aBuffer.Append(iMetaData->Left(amountOfMetaDataToWrite));
+
+                    // need to get rid of KSizeOfTInt
+					iMetaDataLeft = iMetaDataSize - amountOfMetaDataToWrite;
+					aLastSection = EFalse;
+					
+                    iState.iState = EBuffer;
+                    __LOG2("CPackageDataTransfer::DoRequestDataL() - END - iState = ENone - Written MetaData %d, left %d", amountOfMetaDataToWrite, iMetaDataLeft);
+					return;
+					}
+				else
+					{
+					__LOG("CPackageDataTransfer::DoRequestDataL() - END - iState = ENone - not enough space to write MetaData, Return for more");
+					return;
+					}
+				}// if
+			else if (iState.iState == EBuffer)
+				{
+				if (availableBuffer - iMetaDataLeft >= 0)
+					{
+                    const TInt readPosition = iMetaDataSize - iMetaDataLeft;
+					__LOG2("CPackageDataTransfer::DoRequestDataL() - iState = EBuffer - enough space for remaining meta data in this pass, size %d, readPos: %d", iMetaDataLeft, readPosition);
+					aBuffer.Append(iMetaData->Mid(readPosition));
+					}
+				else 
+					{
+				    // continute buffer
+					const TInt readPosition = iMetaDataSize - iMetaDataLeft;
+                    __LOG2("CPackageDataTransfer::DoRequestDataL() - iState = EBuffer - Still buffering Meta Data, Left to write %d, readPos: %d", iMetaDataLeft, readPosition);
+
+					aBuffer.Append(iMetaData->Mid(readPosition, availableBuffer));
+					iMetaDataLeft -= availableBuffer;
+					aLastSection = EFalse;
+
+                    __LOG1("CPackageDataTransfer::DoRequestDataL() - iState = EBuffer - END - Still buffering Meta Data, Left to write %d", iMetaDataLeft);
+					return;
+					}
+				}
+			
+			TUint count = iFiles.Count();			
+			__LOG1("CPackageDataTransfer::DoRequestDataL() - No of fileNames: %d", count);
+			
+			if (count == 0)
+				{
+				aLastSection = ETrue;
+    	        __LOG("CPackageDataTransfer::DoRequestDataL() - END - no files");
+				return;
+				}
+			
+			CDesCArray* files = new (ELeave) CDesCArrayFlat(KDesCArrayGranularity);
+			CleanupStack::PushL(files);
+			for (TUint i = 0; i < count; i++)
+				{
+				files->AppendL(*iFiles[i]);
+				}
+			
+			
+			__LOG("CPackageDataTransfer::DoRequestDataL() - starting buffer file writer...");
+			CBufferFileWriter* bufferFileWriter = CBufferFileWriter::NewL(iFs, files);
+   			delete iBufferFileWriter;  
+   			iBufferFileWriter = bufferFileWriter;
+			
+			iBufferFileWriter->StartL(aBuffer, aLastSection);
+			iState.iState = ERequest;
+			__LOG("CPackageDataTransfer::DoRequestDataL() - iState is now ERequest");
+			
+			if (aLastSection)
+				{
+				delete iBufferFileWriter;
+				iBufferFileWriter = NULL;
+				iState.iState = ENone;
+				} // if
+
+            CleanupStack::Pop(files);
+			}
+		else if (iBufferFileWriter != NULL)
+			{
+			__LOG("CPackageDataTransfer::DoRequestDataL() - continuing buffer file writer from last time...");
+			iBufferFileWriter->ContinueL(aBuffer, aLastSection);
+			if (aLastSection)
+				{
+				delete iBufferFileWriter;
+				iBufferFileWriter = NULL;
+				iState.iState = ENone;
+				}
+			}
+
+        //__LOGDATA("CPackageDataTransfer::DoRequestDataL() -       %S", aBuffer.Ptr(), aBuffer.Length());
+		__LOG("CPackageDataTransfer::DoRequestDataL() - END");			
+    	} // RequestDataL
+		
+	void CPackageDataTransfer::RequestSnapshotL(TDriveNumber aDriveNumber, TPtr8& aBuffer, TBool& aLastSection)
+	/** Handles the request for snapshot data
+	
+	@param aDriveNumber the drive the data is from
+	@param aBuffer the buffer to put the supplied data
+	@param aLastSection has all the data been supplied. If all data is not
+		   supplied a further calls to the function will return the extra
+		   data.
+	*/
+		{
+		__LOG("CPackageDataTransfer::RequestSnapshotL() - START");
+		if (iBufferSnapshotWriter == NULL)
+			{
+			if (!IsDataOnDrive(aDriveNumber))
+				{
+				aLastSection = ETrue;
+				return;
+				}
+			
+			TUint count = iFiles.Count();
+			__LOG1("CPackageDataTransfer::RequestSnapshotL() - No of fileNames: %d", count);
+			if (count > 0)
+				{
+				RSnapshots* snapshots = new(ELeave) RSnapshots();
+				TCleanupItem cleanup(CleanupRPointerArray, snapshots);
+				CleanupStack::PushL(cleanup);
+				
+				while (count--)
+					{
+					TEntry entry;
+					const TDesC& fileName = *(iFiles[count]);
+					TInt err = iFs.Entry(fileName, entry);
+					if (err != KErrNone)
+						{
+						continue;
+						}
+					CSnapshot* snapshot = CSnapshot::NewLC(entry.iModified.Int64(), fileName);	
+					snapshots->AppendL(snapshot);
+					CleanupStack::Pop(snapshot);
+					}
+				
+				// Create a buffer writer
+				// Convert entries into RSnapshots
+				// ownership transfer
+				CBufferSnapshotWriter* bufferSnapshotWriter = CBufferSnapshotWriter::NewL(snapshots);
+   				CleanupStack::Pop(snapshots);
+   				delete iBufferSnapshotWriter;  
+   				iBufferSnapshotWriter = bufferSnapshotWriter;
+   				
+				
+				iBufferSnapshotWriter->StartL(aBuffer, aLastSection);
+	
+				} // if
+			else
+				{
+				aLastSection = ETrue;
+				} // else
+			
+			} // if
+		else
+			{
+			iBufferSnapshotWriter->ContinueL(aBuffer, aLastSection);
+			} // else
+		
+		if (aLastSection)
+			{
+			delete iBufferSnapshotWriter;
+			iBufferSnapshotWriter = NULL;
+			}
+		__LOG("CPackageDataTransfer::RequestSnapshotL() - END");
+		}
+		
+	
+	/** Cleanup of the internal data
+	*/
+	void CPackageDataTransfer::Cleanup()
+		{
+		delete iBufferFileWriter;
+  		iBufferFileWriter = NULL;
+   		delete iBufferSnapshotReader;
+  		iBufferSnapshotReader = NULL;
+   		delete iBufferSnapshotWriter;
+  		iBufferSnapshotWriter = NULL;
+   		delete iSnapshot;
+  		iSnapshot = NULL;
+  		delete iMetaData;
+  		iMetaData = NULL;
+		}
+		
+	/**
+	Checks if there is any data on the specified drive
+	
+	@param aDrive the drive to check on
+	@return ETrue if there is any data
+	*/
+	TBool CPackageDataTransfer::IsDataOnDrive(TDriveNumber aDrive)
+		{
+		if (!iDriveList[aDrive])
+			{
+			return EFalse;
+			}
+		else
+			{
+			return ETrue;
+			}
+		
+		}
+		
+	TCommonBURSettings CPackageDataTransfer::CommonSettingsL()
+	/** Get the common settings of the data owner
+
+	@pre CPackageDataTransfer::ParseFilesL() must have been called
+	@return the common settings of the data owner
+	@leave KErrNotReady if CPackageDataTransfer::ParseFilesL() not called
+	*/
+		{
+		TCommonBURSettings settings = ENoOptions;
+
+		__LOG1("CPackageDataTransfer::CommonSettingsL() - System Supported: %d", iSystemInformation.iSupported);
+		if (iSystemInformation.iSupported)
+			{
+			settings |= EHasSystemFiles;
+			}		
+
+		return settings;
+		}
+
+	TPassiveBURSettings CPackageDataTransfer::PassiveSettingsL()
+	/** Get the passive settings of the data owner
+
+	@pre CPackageDataTransfer::ParseFilesL() must have been called
+	@return the passive settings of the data owner
+	@leave KErrNotReady if CPackageDataTransfer::ParseFilesL() not called
+	*/
+		{
+		__LOG1("CPackageDataTransfer::CommonSettingsL() - Public Supported: %d", iPublicInformation.iSupported);
+		
+		TPassiveBURSettings settings = ENoPassiveOptions;
+		
+		if (iPublicInformation.iSupported)
+			{
+			settings |= EHasPublicFiles;
+			} // if
+			
+			
+		return settings;
+		}
+
+	TActiveBURSettings CPackageDataTransfer::ActiveSettingsL()
+	/** Get the active settings of the data owner
+
+	@pre CPackageDataTransfer::ParseFilesL() must have been called
+	@return the active settings of the data owner
+	@leave KErrNotReady if CPackageDataTransfer::ParseFilesL() not called
+	*/
+		{
+		TActiveBURSettings settings = ENoActiveOptions;
+		
+		return settings;
+		}
+		
+	/** Set the registration file for the package
+	@param aFileName path including filename of the registration file
+	*/
+	void CPackageDataTransfer::SetRegistrationFileL(const TDesC& aFileName)
+		{
+		delete iRegistrationFile;
+		iRegistrationFile = aFileName.AllocL();
+		}
+		
+	/** Parses the package registration file
+	@pre CPackageDataTransfer::SetRegistrationFile() must have been called
+	*/
+	void CPackageDataTransfer::ParseL()
+		{
+		if ((*iRegistrationFile).FindF(KPrimaryBackupRegistrationFile) == KErrNotFound)
+			{
+			User::Leave(KErrNotReady);
+			}
+			
+		ipDataOwnerManager->ParserProxy().ParseL(*iRegistrationFile, *this);
+		}
+		
+		
+	void CPackageDataTransfer::GetRawPublicFileListL(TDriveNumber aDriveNumber, 
+										   RRestoreFileFilterArray& aRestoreFileFilter)
+	/** Gets the raw public file list 
+	
+	@param aDriveNumber the drive to return the list for
+	@param aRestoreFileFilter on return the file filter
+	*/
+		{
+		// Convert drive number to letter
+		TChar drive;
+		User::LeaveIfError(iFs.DriveToChar(aDriveNumber, drive));
+		
+		const TInt count = iPublicSelections.Count();
+		for (TInt x = 0; x < count; x++)
+			{
+			CSelection* selection = iPublicSelections[x];
+			TBool include = (selection->SelectionType() == EInclude);
+			TFileName filename;
+			
+			const TDesC& selectionName = selection->SelectionName();
+			// Name
+			TBool add = false;
+			if ((selectionName.Length() > 1) && (selectionName[1] == KColon()[0]))
+				{
+				// It has a drive specified
+				TInt drive;
+				iFs.CharToDrive(selectionName[0], drive);
+				if (static_cast<TDriveNumber>(drive) == aDriveNumber)
+					{
+					add = true;
+					filename.Append(selectionName);
+					} // if
+				} // if
+			else if (selectionName[0] == KBackSlash()[0])
+				{
+				add = true;
+				filename.Append(drive);
+				filename.Append(KColon);
+				filename.Append(selectionName);
+				} // if
+			else
+				{
+				filename.Append(drive);
+				filename.Append(KColon);
+				filename.Append(KBackSlash);
+				filename.Append(selectionName);
+				} // else
+			
+			if (add)
+				{
+				aRestoreFileFilter.AppendL(TRestoreFileFilter(include, filename));
+				} // if
+			} // for x
+		}
+		
+	
+	void CPackageDataTransfer::GetPublicFileListL(TDriveNumber aDriveNumber, RFileArray& aFiles)
+	/** Gets the public file list
+
+	Gets the public file list for the given drive
+	@param aDriveNumber the drive to retrieve the public files for
+	@param aFiles on return a list of public files
+	*/
+		{
+		_LIT(KDrive, "?:");
+		_LIT(KDriveAndSlash, "?:\\");
+		_LIT( KExclamationAsDrive, "!"); // Used to generic drives for public data as in .SIS file package
+		
+		// Split selections into include and exclude
+		RArray<TPtrC> include;
+		CleanupClosePushL(include);
+		RArray<TPtrC> exclude;
+		CleanupClosePushL(exclude);
+		TInt count = iPublicSelections.Count();
+
+        
+        __LOG("CPackageDataTransfer::GetPublicFileListL() - file selection listing...:");
+		for (TInt x = 0; x < count; x++)
+			{
+            const TDesC& selectionName = iPublicSelections[x]->SelectionName();
+            __LOG3("CPackageDataTransfer::GetPublicFileListL() - selection[%03d]: %S, type: %d", x, &selectionName, iPublicSelections[x]->SelectionType());
+			if (iPublicSelections[x]->SelectionType() == EInclude)
+				{
+				include.AppendL(selectionName);
+				} // if
+			else
+				{
+				exclude.AppendL(selectionName);
+				} // else
+			} // for x
+			
+		// Loop through all includes
+		count = include.Count();
+        __LOG("CPackageDataTransfer::GetPublicFileListL() - include listing...:");
+		for (TInt x = 0; x < count; x++)
+			{
+			TFileName fileName;
+			TChar drive;
+			User::LeaveIfError(iFs.DriveToChar(aDriveNumber, drive));
+
+            const TPtrC includeEntry( include[x] );
+            __LOG2("CPackageDataTransfer::GetPublicFileListL() - entry[%03d] is: %S", x, &includeEntry);
+            
+            // See if the drive is specified
+			if (include[x][0] == KBackSlash()[0])
+				{
+				// Add the drive
+				fileName.Append(drive);
+				fileName.Append(KColon);
+				fileName.Append(include[x]);
+				}
+			else
+				{
+				// Handle the Exclamation (!) in Public data paths, if any.  
+				// Exclamation mark in place of drive letter means that the path is to be checked in all available drives.
+				// And any dataowner can keep their public files in any drive and it can be mentioned in backup_registration file as below.
+				// <public_backup>
+				// <include_directory name="!:\mydatabases\" />
+				// </public_backup>				
+				
+				if ( includeEntry[0] == KExclamationAsDrive()[0])
+					{	
+					// Map public data path using current drive being backed up.
+					fileName.Zero();
+					fileName.Append(drive);
+					fileName.Append( includeEntry.Mid(1) );
+					}
+				else
+					if (static_cast<TChar>(includeEntry[0]).GetUpperCase() == drive.GetUpperCase())
+					{								
+					fileName.Copy(includeEntry);
+					} // else
+				
+				} // else
+
+            __LOG2("CPackageDataTransfer::GetPublicFileListL() - entry[%03d] filename is therefore: %S", x, &fileName);
+			if (fileName.Length() > 0)
+				{
+				
+				// Check to see if fileName is just a drive(we cant get an entry)
+				TBool isDrive = EFalse;
+				if ((fileName.MatchF(KDrive) != KErrNotFound) ||
+				    (fileName.MatchF(KDriveAndSlash) != KErrNotFound))
+					{
+					isDrive = ETrue;
+                    __LOG("CPackageDataTransfer::GetPublicFileListL() - filename is a drive");
+					} // if
+					
+				TEntry entry;
+				TBool isEntry = EFalse;
+				if (!isDrive)
+					{
+					TInt err = iFs.Entry(fileName, entry);
+                    __LOG1("CPackageDataTransfer::GetPublicFileListL() - get entry error: %d", err);
+					entry.iName = fileName;
+					switch (err)
+						{
+					case KErrNone:
+						isEntry = ETrue;
+						break;
+					case KErrNotFound:
+					case KErrPathNotFound:
+					case KErrBadName:
+						break;
+					default:
+						User::Leave(err);
+						} // switch
+					} // if
+					
+				if (isDrive || (isEntry && entry.IsDir()))
+					{
+                    __LOG("CPackageDataTransfer::GetPublicFileListL() - parsing directory...");
+					ParseDirL(fileName, exclude, aFiles);
+
+				#ifdef SBE_LOGGING_ENABLED
+					const TInt fNameCount = aFiles.Count();
+                    if  (fNameCount)
+                        {
+                        for(TInt k=0; k<fNameCount; k++)
+                            {
+                            const TDesC& fileName = aFiles[k].iName;
+                            __LOG2("CPackageDataTransfer::GetPublicFileListL() - directory entry[%03d] %S", k, &fileName);
+                            }
+                        }
+
+                    __LOG("CPackageDataTransfer::GetPublicFileListL() - end of parsing directory");
+				#endif
+					} // if
+				else
+					{
+					if (isEntry)
+						{
+                        const TBool isExcluded = IsExcluded(ETrue, fileName, exclude);
+						if (!isExcluded)
+							{
+						    __LOG1("CPackageDataTransfer::GetPublicFileListL() - adding fully verified file: %S", &fileName);
+							// Add to list of files
+							aFiles.AppendL(entry);
+							} // if
+                        else
+                            {
+                            __LOG("CPackageDataTransfer::GetPublicFileListL() - file is excluded!");
+                            }
+						} // if
+					} // else
+				} // if
+			} // for x
+			
+		CleanupStack::PopAndDestroy(&exclude);
+		CleanupStack::PopAndDestroy(&include);
+        __LOG("CPackageDataTransfer::GetPublicFileListL() - END");
+		}
+		
+	void CPackageDataTransfer::ParseDirL(const TDesC& aDirName, const RArray<TPtrC>& aExclude, RFileArray& apFileEntries)
+	/** Parses a directory for files.
+	
+	Parses the given directory for files. The function is called recursivily if a directory is found.
+	
+	@param aDirName the directory to search
+	@param aExclude a list of directories or files to exclude
+	@param apFileEntries Array of file entries to populate
+	*/							   
+		{
+		CDir* pFiles = NULL;
+		
+		// This function requires a / on the end otherwise it does not work!
+		TFileName path = aDirName;
+		if (path[path.Length() - 1] != KBackSlash()[0])
+			path.Append(KBackSlash);
+		
+		TInt err = iFs.GetDir(path, KEntryAttMatchMask, ESortNone, pFiles);
+		CleanupStack::PushL(pFiles); // Add to cleanup stack
+		
+		if ((err != KErrNone) && (err != KErrNotFound)) // Do we need to leave?
+			{
+			User::Leave(err);
+			} // if
+
+		TUint count = pFiles->Count();
+		while(count--)
+			{
+			TEntry entry = (*pFiles)[count]; 
+			
+			// Build full path
+			TFileName filename = path;
+			filename.Append(entry.iName);
+			entry.iName = filename;
+			
+			if (!IsExcluded(ETrue, filename, aExclude))
+				{
+				if (entry.IsDir())
+					{
+					ParseDirL(filename, aExclude, apFileEntries);
+					} // if
+				else
+					{
+					// Add to list of files
+					apFileEntries.AppendL(entry);
+					} // else
+				} // if
+			} // for x
+			
+		// Cleanup
+		CleanupStack::PopAndDestroy(pFiles);
+		}
+
+	void CPackageDataTransfer::GetDriveListL(TDriveList& aDriveList)
+	/** Get the drive list for the data owner
+
+	@pre CDataOwner::ParseFilesL() must have been called
+	@return the active settings of the data owner
+	@leave KErrNotReady if CDataOwner::ParseFilesL() not called
+	*/
+		{
+        __LOG1("CPackageDataTransfer::GetDriveListL() - Begin - SID: 0x%08x", iPackageID.iUid);
+        
+		// We now no longer return the Z drive, it has been decided that the Z drive will always be the
+		// ROM. Backing up and restoring the ROM drive should not be possible, as what is the point
+		
+		// build package files
+		if (iMetaData == NULL)
+			{
+			iMetaData = iSWIBackup.GetMetaDataL(iPackageID, iFiles);
+			iMetaDataSize = iMetaData->Size();
+			BuildPackageFileList();
+			}
+		
+		TDriveList notToBackup = ipDataOwnerManager->Config().ExcludeDriveList();
+		
+		for (TInt i = 0; i < KMaxDrives; i++)
+			{
+			if (notToBackup[i]) // if this drive is set
+				{
+				// don't include this drive
+				iDriveList[i] = EFalse;
+				}
+			}
+		
+		aDriveList = iDriveList;
+		__LOG1("CPackageDataTransfer::GetDriveListL() - end - SID: 0x%08x", iPackageID.iUid);
+		}
+
+	TBool CPackageDataTransfer::IsExcluded(const TBool aIsPublic, const TDesC& aFileName, const RArray<TPtrC>& aExclude)
+	/** Checks to see if a given file is excluded
+	
+	Checks to see if the given file is not in a private directory or in the exclude list.
+	
+	@param aFileName file to check
+	@param aExclude list of excluded files
+	@return ETrue if excluded otherwise EFalse
+	*/
+		{
+		_LIT(KPrivateMatch, "?:\\private\\*");
+		_LIT(KSystem, "?:\\system\\*");
+		_LIT(KResource, "?:\\resource\\*");
+		_LIT(KOther, "*\\..\\*");
+		TBool ret = EFalse;
+		
+		// Check it is not in sys, resource, system or backwards path
+		ret = (!((aFileName.MatchF(KSystem) == KErrNotFound) &&
+			     (aFileName.MatchF(KResource) == KErrNotFound) &&
+			     (aFileName.MatchF(KSys) == KErrNotFound) && 
+			     (aFileName.MatchF(KOther) == KErrNotFound)
+			    )
+			  );
+			
+		// If this is public backup remove the private directory
+		if (!ret && aIsPublic)
+			{
+		    ret = (!(aFileName.MatchF(KPrivateMatch) == KErrNotFound));
+			}
+			
+		if (!ret)
+			{
+			// Is the file in the exclude list?
+			const TInt count = aExclude.Count();
+			for (TInt x = 0; !ret && x < count; x++)
+				{
+				if (aExclude[x][0] == KBackSlash()[0])
+					{
+					// Compare with out drive
+					_LIT(KQuestionMark, "?");
+					TFileName compare = KQuestionMark();
+					compare.Append(aExclude[x]);
+					ret = (!(aFileName.MatchF(compare) == KErrNotFound));
+					} // if
+				else
+					{
+					// Normal compare
+					ret = (aFileName.CompareF(aExclude[x]) == 0);
+					} // else
+				} // for x
+			} // if
+		
+        __LOG2("CDataOwner::IsExcluded() - END - returns excluded: %d for file: %S", ret, &aFileName);
+		return ret;
+		}
+		
+		/**
+	Method will be used for Sort on RPointerArray
+	
+	@param aFirst CPackageDataTransfer& package id to compare
+	@param aSecond CPackageDataTransfer& package id to compare
+	
+	@see RArray::Sort()
+	*/
+	TInt CPackageDataTransfer::Compare(const CPackageDataTransfer& aFirst, const CPackageDataTransfer& aSecond)
+		{
+		if (aFirst.PackageId().iUid < aSecond.PackageId().iUid)
+			{
+			return -1;
+			}
+ 		else if (aFirst.PackageId().iUid > aSecond.PackageId().iUid)
+ 			{
+ 			return 1;
+ 			}
+ 		else 
+ 			{
+ 			return 0;
+ 			}
+		}
+		
+	/**
+	Method will be used for Find on RPointerArray
+	
+	@param aFirst CPackageDataTransfer& package id to match
+	@param aSecond CPackageDataTransfer& package id to match
+	
+	@see RArray::Find()
+	*/
+	TBool CPackageDataTransfer::Match(const CPackageDataTransfer& aFirst, const CPackageDataTransfer& aSecond)
+		{
+		return (aFirst.PackageId().iUid == aSecond.PackageId().iUid);
+		}
+
+		
+	//	
+	//  MContentHandler Implementaion //
+	//
+	
+
+
+	void CPackageDataTransfer::OnStartDocumentL(const RDocumentParameters& /*aDocParam*/, TInt aErrorCode)
+	/** MContentHandler::OnStartDocumentL()
+	*/
+		{
+		if (aErrorCode != KErrNone)
+			{
+			__LOG1("CPackageDataTransfer::OnStartDocumentL() - error = %d", aErrorCode);
+			User::Leave(aErrorCode);
+			}
+		}
+		
+	void CPackageDataTransfer::OnEndDocumentL(TInt aErrorCode)
+	/** MContentHandler::OnEndDocumentL()
+	*/
+		{
+		// just to satisfy UREL compiler
+		(void) aErrorCode;
+		__LOG1("CPackageDataTransfer::OnEndDocumentL() - error = %d", aErrorCode);
+		}
+		
+	void CPackageDataTransfer::OnStartElementL(const RTagInfo& aElement, 
+									  const RAttributeArray& aAttributes, 
+									  TInt aErrorCode)
+	/** MContentHandler::OnStartElementL()
+
+	@leave KErrUnknown an unknown element
+	*/
+		{
+		if (aErrorCode != KErrNone)
+			{
+			__LOG1("CPackageDataTransfer::OnStartElementL() - error = %d", aErrorCode);
+			User::Leave(aErrorCode);
+			}
+		
+		TPtrC8 localName = aElement.LocalName().DesC();
+		if (localName == KIncludeFile) 
+			{
+			HandlePathL(EInclude, aAttributes, EFalse);
+			}
+		else if (!localName.CompareF(KIncludeDirectory))
+			{
+			HandlePathL(EInclude, aAttributes, ETrue);
+			}
+		else if (!localName.CompareF(KExclude))
+			{
+			HandlePathL(EExclude, aAttributes, EFalse);
+			}
+		else if (!localName.CompareF(KBackupRegistration))
+			{
+			HandleBackupRegistrationL(aAttributes);
+			}
+		else if (!localName.CompareF(KPublicBackup))
+			{
+			User::LeaveIfError(HandlePublicBackup(aAttributes));
+			}
+		else if (!localName.CompareF(KSystemBackup))
+			{
+			User::LeaveIfError(HandleSystemBackup(aAttributes));
+			}
+		else
+			{
+			__LOG1("CPackageDataTransfer::OnStartElementL() - Unknown element while parsing 0x%08x", iPackageID.iUid);
+			}
+			
+		}
+
+	
+	void CPackageDataTransfer::OnEndElementL(const RTagInfo& aElement, TInt aErrorCode)
+	/** MContentHandler::OnEndElementL()
+	*/
+		{
+		if (aErrorCode != KErrNone)
+			{
+			__LOG1("CPackageDataTransfer::OnEndElementL() - error = %d", aErrorCode);
+			User::Leave(aErrorCode);
+			}
+		
+		TPtrC8 localName = aElement.LocalName().DesC();
+		if (!localName.CompareF(KPublicBackup))
+			{
+			iCurrentElement = ENoElement;
+			} // if
+		}
+
+	void CPackageDataTransfer::OnContentL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/)
+	/** MContentHandler::OnContentL()
+	*/
+		{
+		// Not handled
+		}
+
+	void CPackageDataTransfer::OnStartPrefixMappingL(const RString& /*aPrefix*/, 
+											const RString& /*aUri*/, TInt /*aErrorCode*/)
+	/** MContentHandler::OnStartPrefixMappingL()
+	*/
+		{
+		// Not handled
+		}
+
+	void CPackageDataTransfer::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt /*aErrorCode*/)
+	/** MContentHandler::OnEndPrefixMappingL()
+	*/
+		{
+		// Not handled
+		}
+
+	void CPackageDataTransfer::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/)
+	/** MContentHandler::OnIgnorableWhiteSpaceL()
+	*/
+		{
+		// Not handled
+		}
+
+	void CPackageDataTransfer::OnSkippedEntityL(const RString& /*aName*/, TInt /*aErrorCode*/)
+	/** MContentHandler::OnSkippedEntityL()
+	*/
+		{
+		// Not handled
+		}
+
+	void CPackageDataTransfer::OnProcessingInstructionL(const TDesC8& /*aTarget*/, 
+											   const TDesC8& /*aData*/, 
+											   TInt /*aErrorCode*/)
+	/** MContentHandler::OnProcessingInstructionL()
+	*/
+		{
+		// Not handled
+		}
+
+	void CPackageDataTransfer::OnError(TInt aErrorCode)
+	/** MContentHandler::OnError()
+
+	@leave aErrorCode
+	*/
+		{
+		(void)aErrorCode;
+		__LOG1("CPackageDataTransfer::OnError() - error = %d", aErrorCode);
+		}
+
+	TAny* CPackageDataTransfer::GetExtendedInterface(const TInt32 /*aUid*/)
+	/** MContentHandler::OnEndPrefixMappingL()
+	*/
+		{
+		return NULL;
+		}
+
+	void CPackageDataTransfer::HandleBackupRegistrationL(const RAttributeArray& aAttributes)
+	/** Handles the "backup_registration" element
+
+	@param aAttributes the attributes for the element
+	@return KErrNone no errors
+	@return KErrUnknown unknown version
+	*/
+		{
+		_LIT8(KVersion, "1.0");
+		
+		if (aAttributes.Count() == 1)
+			{
+			// Check the version is correct.
+			if (aAttributes[0].Value().DesC() != KVersion()) // Only version we know about
+				{
+				__LOG1("CDataOwner::HandleBackupRegistrationL() - Unknown version at SID(0x%08x)", iPackageID.iUid);
+				User::Leave(KErrNotSupported);
+				} // else
+			} // if
+		}
+
+
+	TInt CPackageDataTransfer::HandlePublicBackup(const RAttributeArray& aAttributes)
+	/** Handles the "public_backup" element
+
+	@param aAttributes the attributes for the element
+	@return KErrNone
+	*/
+		{
+		iPublicInformation.iSupported = ETrue;
+		
+		if (aAttributes.Count() > 0)
+			{
+            const TBool deleteBeforeRestore = ( aAttributes[0].Value().DesC().CompareF(KYes) == 0 );
+			iPublicInformation.iDeleteBeforeRestore = deleteBeforeRestore;
+			__LOG2("CPackageDataTransfer::HandlePublicBackup(0x%08x) - iPublicInformation.iDeleteBeforeRestore: %d", iPackageID.iUid, deleteBeforeRestore);
+			} // if
+		
+		iCurrentElement = EPublic;
+		
+		return KErrNone;
+		}
+
+	TInt CPackageDataTransfer::HandleSystemBackup(const RAttributeArray& /*aAttributes*/)
+	/** Handles the "system_backup" element
+
+	@param aAttributes the attributes for the element
+	@return KErrNone
+	*/
+		{
+		iSystemInformation.iSupported = ETrue;
+		__LOG2("CPackageDataTransfer::HandlePublicBackup(0x%08x) - iSystemInformation.iSupported: %d", iPackageID.iUid, iSystemInformation.iSupported);
+
+		return KErrNone;	
+		}
+
+
+	void CPackageDataTransfer::HandlePathL(const TSelectionType aType, 
+								  const RAttributeArray& aAttributes,
+								  const TBool aDir)
+	/** Handles the "include_file", "include_directory" and "exclude" elements
+
+	@param aType The selection type 
+	@param aAttributes The attributes for the element
+	@param aDir The element was found in an <include_dir/> element?
+	*/
+		{
+		// Check we dont have a NULL string
+		if (aAttributes[0].Value().DesC().Length() > 0)
+			{
+			switch (iCurrentElement)
+				{
+			case EPublic:
+					{
+					TFileName selectionName;
+					if (KErrNone == ipDataOwnerManager->ParserProxy().ConvertToUnicodeL(selectionName, aAttributes[0].Value().DesC()))
+						{
+						// 2 because we expect drive leter and semicollon
+						if (selectionName.Length() > 2)
+							{
+							// Should we add a backslash
+							if (aDir &&
+							(selectionName[selectionName.Length() - 1] != '\\'))
+								{
+								selectionName.Append(KBackSlash);
+								} // if
+						
+							if (selectionName[1] == ':')
+								{
+								CSelection* selection = CSelection::NewLC(aType, selectionName);
+								iPublicSelections.AppendL(selection);
+								CleanupStack::Pop(selection);
+								__LOG3("CPackageDataTransfer::HandlePathL(0x%08x) - Added selection: %S [type: %d]", iPackageID.iUid, &selectionName, aType);
+								} //if 
+							}// if
+						else
+							{
+							__LOG3("CPackageDataTransfer::HandlePathL(0x%08x) - Wrong format: %S [type: %d]", iPackageID.iUid, &selectionName, aType);
+							}
+						} // if
+					else
+						{
+						__LOG1("CPackageDataTransfer::HandlePathL(0x%08x) - EPublic - Could not convert filename", iPackageID.iUid);
+						} // else
+					break;
+					};
+			default:
+					{
+					__LOG1("CPackageDataTransfer::HandlePathL(0x%08x) - Private data is Not Supported", iPackageID.iUid);		
+					}
+				break;
+				} // switch
+			} // if
+		else
+			{
+			__LOG1("CPackageDataTransfer::HandlePathL(0x%08x) - Path attribute error", iPackageID.iUid);
+			} // else
+		}
+//					// 
+// MContentHandler //
+//
+	
+		
+	} // namespace
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sbshutdown.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,64 @@
+// 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:
+// Implementation of CSBShutdown class.
+// 
+//
+
+/**
+ @file
+*/
+
+#include <e32std.h>
+#include <e32base.h>
+#include "sbshutdown.h"
+
+namespace conn
+	{
+
+	/** Shutdown delay, in microseconds.
+	 @internalComponent */
+	const TUint KShutdownDelay = 0x200000;
+	
+	CSBShutdown::CSBShutdown() : 
+	CTimer(EPriorityNormal)
+    /**
+    Class Constructor
+    */
+		{
+		}
+
+	void CSBShutdown::ConstructL()
+	/**
+	Construct this instance of CSBShutdown.
+	*/
+		{
+		CTimer::ConstructL();
+		CActiveScheduler::Add(this);
+		}
+
+	void CSBShutdown::Start()
+	/** Starts the timer. */
+		{
+		After(KShutdownDelay);
+		}
+
+	void CSBShutdown::RunL()
+	/** Called after the timer has expired.
+	
+	Stop the active scheduler and shutdown the server.
+	*/
+		{
+		CActiveScheduler::Stop();
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backupengine/src/sbtypes.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1873 @@
+// 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:
+// Implementation of sbtypes
+// 
+//
+
+/**
+ @file
+*/
+#include <e32std.h>
+#include <connect/panic.h>
+#include "sbtypes.h"
+#include <s32mem.h>
+#include <apgcli.h>
+#include <apmstd.h>
+
+namespace conn
+	{
+	
+	EXPORT_C CDataOwnerInfo* CDataOwnerInfo::NewL( CSBGenericDataType* aGenericDataType,
+										  TCommonBURSettings aCommonSettings,
+										  TPassiveBURSettings aPassiveSettings,
+										  TActiveBURSettings aActiveSettings,
+										  const TDriveList& aDriveList )
+	/**
+	Symbian constructor. This constructor is used to create a CDataOwnerInfo from it's 
+	constituent parts, rather than from an externalised class etc.
+
+	@param aGenericDataType pointer to CSBGenericDataType object
+	@param aCommonSettings flags for storing common backup and restore settings
+	@param aPassiveSettings flags for storing passive backup and restore settings
+	@param aActiveSettings flags for storing active backup and restore settings
+	@param aDriveList the array of drives the data owner has data on
+	@return A pointer to the CDataOwnerInfo object
+	*/
+		{
+		CDataOwnerInfo* self = new(ELeave) CDataOwnerInfo();
+		CleanupStack::PushL(self);
+		self->ConstructL(aGenericDataType, aCommonSettings, aPassiveSettings, aActiveSettings, aDriveList);
+		CleanupStack::Pop(self);
+		return self;
+		}
+
+	EXPORT_C CDataOwnerInfo* CDataOwnerInfo::NewL( const TDesC8& aFlatDataOwnerInfo )
+	/**
+	Symbian constructor for constructing a CDataOwnerInfo object from an externalised CDataOwnerInfo 
+	object. This may be used when taking an externalised class out of a PC message or over IPC.
+
+	@param aFlatDataOwnerInfo a flat data owner info returned from IPC
+	@return A pointer to the CDataOwnerInfo object
+	*/
+		{
+		CDataOwnerInfo* self = new(ELeave) CDataOwnerInfo();
+		CleanupStack::PushL(self);
+		self->ConstructL(aFlatDataOwnerInfo);
+		CleanupStack::Pop(self);
+		return self;
+		}
+	
+	CDataOwnerInfo::CDataOwnerInfo()
+	/**
+	C++ Constructor 
+	*/
+		{
+		}
+
+	EXPORT_C CDataOwnerInfo::~CDataOwnerInfo()
+	/**
+	C++ Destructor
+	*/
+		{
+		delete iGenericDataType;
+		}
+
+	void CDataOwnerInfo::ConstructL(CSBGenericDataType* aGenericDataType,
+									TCommonBURSettings aCommonSettings,
+									TPassiveBURSettings aPassiveSettings,
+									TActiveBURSettings aActiveSettings,
+									const TDriveList& aDriveList)
+	/**
+	Symbian OS 2nd phase constructor.
+
+	@param aGenericDataType pointer to CSBGenericDataType object
+	@param aCommonSettings flags for storing common backup and restore settings
+	@param aPassiveSettings flags for storing passive backup and restore settings
+	@param aActiveSettings flags for storing active backup and restore settings
+	@param aDriveList the array of drives the data owner has data on
+	*/
+		{
+		if (aGenericDataType == NULL)
+			{
+			User::Leave(KErrArgument);
+			}
+		iGenericDataType = aGenericDataType;
+		iCommonBURSettings = aCommonSettings;
+		iPassiveBURSettings = aPassiveSettings;
+		iActiveBURSettings = aActiveSettings;
+		iDriveList = aDriveList;
+		}
+
+	void CDataOwnerInfo::ConstructL(const TDesC8& aFlatDataOwnerInfo)
+	/**
+	Symbian OS 2nd phase constructor. Internalise a descriptor containing a flattened 
+	object of this type
+
+	@param aFlatDataOwnerInfo a flat data owner info returned from IPC
+	*/
+		{
+		// TPtr8 that points to aFlatDataOwnerInfo (which remains const)
+		TPtr8 pSource(const_cast<TUint8*>(aFlatDataOwnerInfo.Ptr()), aFlatDataOwnerInfo.Size());
+		pSource.SetMax();
+		
+		// Position that we've read up to in the externalised class buffer
+		TInt sourcePos = 0;
+		
+		TInt32 genericDataTypeSize;
+		
+		// Extract the CSBGenericDataType's size
+		UnpackTypeAdvance(genericDataTypeSize, pSource, sourcePos);
+
+		// Construct a new CSBGenericDataType from the message
+		iGenericDataType = CSBGenericDataType::NewL(pSource.MidTPtr(sourcePos, genericDataTypeSize));
+		sourcePos += genericDataTypeSize;
+
+		UnpackTypeAdvance(iCommonBURSettings, pSource, sourcePos);
+		UnpackTypeAdvance(iPassiveBURSettings, pSource, sourcePos);
+		UnpackTypeAdvance(iActiveBURSettings, pSource, sourcePos);
+		UnpackTypeAdvance(iDriveList, pSource, sourcePos);
+		}
+		
+	EXPORT_C CSBGenericDataType& CDataOwnerInfo::Identifier()
+	/**
+	Getter method for returning a reference to the CSBGenericDataType
+	object
+	
+	@return Reference to the CSBGenericDataType object
+	*/
+		{
+		return *iGenericDataType;
+		}
+		
+	EXPORT_C const CSBGenericDataType& CDataOwnerInfo::Identifier() const
+	/**
+	Getter method for returning a reference to a const CSBGenericDataType
+	object, containing information including 
+	
+	@return Reference to the const CSBGenericDataType object
+	*/
+		{
+		return *iGenericDataType;
+		}
+		
+	EXPORT_C TCommonBURSettings CDataOwnerInfo::CommonSettings() const
+	/**
+	Getter method for returning the Backup and Restore flags that
+	the were specified in the Data Owner's backup registration file
+	that relate to both Active and Passive backup
+	
+	@return The Common backup and restore settings of the Data Owner
+	*/
+		{
+		return iCommonBURSettings;
+		}
+		
+	EXPORT_C TPassiveBURSettings CDataOwnerInfo::PassiveSettings() const
+	/**
+	Getter method for returning the Passive Backup and Restore flags that
+	the were specified in the Data Owner's backup registration file
+	
+	@return The passive backup and restore settings of the data owner
+	*/
+		{
+		return iPassiveBURSettings;
+		}
+		
+	EXPORT_C TActiveBURSettings CDataOwnerInfo::ActiveSettings() const
+	/**
+	Getter method for returning the Active Backup and Restore flags that
+	the were specified in the Data Owner's backup registration file
+	
+	@return The active backup and restore settings of the data owner
+	*/
+		{
+		return iActiveBURSettings;
+		}
+		
+	EXPORT_C TDriveList& CDataOwnerInfo::DriveList()
+	/**
+	Getter method for returning the list of drives on which the Data Owner stores
+	data to be backed up
+	
+	@return The drive list of the data owner
+	*/
+		{
+		return iDriveList;
+		}
+		
+	EXPORT_C const TDriveList& CDataOwnerInfo::DriveList() const
+	/**
+	Const getter method for returning the list of drives on which the Data Owner stores
+	data to be backed up
+	
+	@return The drive list of the data owner
+	*/
+		{
+		return iDriveList;
+		}
+		
+	EXPORT_C HBufC8* CDataOwnerInfo::ExternaliseL()
+	/**
+	Method to externalise the data owner so that it can be passed flat over the IPC interface 
+	or appended to a PC bound message, pops the pointer off the cleanup stack before it is
+	returned
+	
+	@return The externalised buffer
+	*/
+		{
+		HBufC8* dataOwnerBuffer = ExternaliseLC();
+		CleanupStack::Pop(dataOwnerBuffer);
+		
+		return dataOwnerBuffer;
+		}
+		
+	EXPORT_C HBufC8* CDataOwnerInfo::ExternaliseLC()
+	/**
+	Method to externalise the data owner so that it can be passed flat over the IPC interface 
+	or appended to a PC bound message, leaves the pointer on the cleanup stack.
+	
+	@return The externalised buffer
+	*/
+		{
+		HBufC8* dataBuffer = HBufC8::NewLC(Size());				
+		TPtr8 bufferPtr(dataBuffer->Des());
+						
+		iDriveList.SetMax();	// Ensure that the drivelist array is set to max
+		const TDesC8& dataType = iGenericDataType->Externalise();
+		TInt32 typeSize = dataType.Size();
+		
+		bufferPtr.Append(reinterpret_cast<TUint8*>(&typeSize),sizeof(TInt32));
+		bufferPtr.Append(dataType);
+		bufferPtr.Append(reinterpret_cast<TUint8*>(&iCommonBURSettings), sizeof(TCommonBURSettings));
+		bufferPtr.Append(reinterpret_cast<TUint8*>(&iPassiveBURSettings), sizeof(TPassiveBURSettings));
+		bufferPtr.Append(reinterpret_cast<TUint8*>(&iActiveBURSettings), sizeof(TActiveBURSettings));
+		bufferPtr.Append(iDriveList);
+		
+		return dataBuffer;
+		}
+		
+	EXPORT_C TInt CDataOwnerInfo::Size() const
+	/**
+	Getter for returning the total flattened size of the object. Used for calculating the 
+	size of a descriptor to fit the externalised instance of this object
+	
+	@return Size of class in bytes once flattened
+	*/
+		{
+		TInt size = 	sizeof(TCommonBURSettings) +
+						sizeof(TPassiveBURSettings) +
+						sizeof(TActiveBURSettings) +
+						sizeof(TInt32) + 	// Buffer size is stored as a TInt32
+						iGenericDataType->Externalise().Size() +
+						iDriveList.Size();
+						
+		return size;
+		}
+		
+	// CSBGenericDataType			
+	EXPORT_C CSBGenericDataType* CSBGenericDataType::NewL(const TDesC8& aDes)
+	/**
+	Symbian constructor. A base CSBGenericDataType may only be instantiated from a previously 
+	externalised data type. This is the method that is used to take a generic data type from 
+	either an IPC response or from a message sent by the PC. This method will not take ownership 
+	of the descriptor aDes
+
+	@param aDes descriptor containing the buffer of data
+	@return A pointer to the CSBGenericDataType object
+	*/
+		{
+		CSBGenericDataType* self = new(ELeave) CSBGenericDataType();
+		CleanupStack::PushL(self);
+		self->ConstructL(aDes);
+		CleanupStack::Pop(self);
+		return self;
+		}
+	
+	CSBGenericDataType::CSBGenericDataType(): iDataBuffer(NULL)
+	/**
+	C++ Constructor. Any derived types must increment iSize in their C++ constructors in order 
+	that when CSBGenericDataType::BaseConstructL() is called, the data buffer is initialised 
+	to be large enough to accomodate the data stored by the derived type
+	*/
+		{
+		// Initialise iSize
+		iSize = sizeof(TSBDerivedType);
+		}
+
+	EXPORT_C CSBGenericDataType::~CSBGenericDataType()
+	/**
+	C++ Destructor
+	*/
+		{
+		delete iDataBuffer;
+		}
+
+	void CSBGenericDataType::ConstructL(const TDesC8& aDes)
+	/**
+	Symbian OS 2nd phase constructor. Called when creating a base class from raw data
+	i.e. off the wire/IPC. Creates the base type data buffer to store object data in
+
+	@param aDes descriptor containing the buffer of data
+	*/
+		{
+		// Store the length of the descriptor as our max length
+		iSize = aDes.Size();
+			
+		// Create a new buffer and copy the passed one into it
+		iDataBuffer = HBufC8::NewL(iSize);
+		*iDataBuffer = aDes;
+
+		TInt offset = 0;
+		
+		// Initialise member pointers of all classes in the inheritence tree
+		InitialiseL(offset);
+		
+		// The base type should be as long as the des passed in (more info in a derived)
+		iDataBuffer->Des().SetLength(iSize);
+		}
+		
+	void CSBGenericDataType::InitialiseL(TInt& aOffset)
+	/**
+	Initialise all of member data offsets inside the base and derived classes
+	
+	@param 	aOffset The running offset indicating the position in the descriptor that has 
+			been parsed up to
+	*/
+		{
+		if (iSize < sizeof(TSBDerivedType))
+			{
+			User::Leave(KErrCorrupt);
+			}
+		
+		// Throwaway type used to determine the offset advance
+		TSBDerivedType derivedType;
+
+		iDerivedTypeOffset = aOffset;
+		UnpackTypeAdvance(derivedType, *iDataBuffer, aOffset);
+		
+		if (derivedType < 0 || derivedType > KMaxDerivedTypes)
+			{
+			User::Leave(KErrCorrupt);
+			}
+				
+		iDataBuffer->Des().SetLength(aOffset);
+		
+		}
+	
+	void CSBGenericDataType::BaseConstructL()
+	/**
+	Symbian OS 2nd phase constructor. Called by derived classes when creating an end 
+	derived class i.e. CSBSecureId. Constructs base class data buffer to store object
+	data in. Size of buffer has been determined by C++ constructors of all classes 
+	in inheritence tree incrementing iSize member so that a buffer big enough to store
+	the data of all classes is created.
+	*/
+		{
+		// All derived classes should += their size to iSize
+		iDataBuffer = HBufC8::NewL(iSize);
+		}
+		
+	EXPORT_C const TDesC8& CSBGenericDataType::Externalise() const
+	/**
+	Getter for a reference to the buffer containing the data
+		
+	@return  Reference to the buffer containing the data
+	*/
+		{
+		return *iDataBuffer;
+		}
+		
+	EXPORT_C TSBDerivedType CSBGenericDataType::DerivedTypeL() const
+	/**
+	Getter method for returning the type of the derived object. Used to determine at run time 
+	which derived type this base type contains
+	
+	@return The type of the derived object
+	*/
+		{
+		TSBDerivedType derivedType;
+		
+		UnpackType(derivedType, *iDataBuffer, iDerivedTypeOffset);
+		
+		return derivedType;
+		}
+
+	void CSBGenericDataType::UnpackDescriptorTypeAdvance(TDesC16& aDes, TInt& aOffset)
+		/**
+		Function to copy a simple type from a specified position in aDes
+		defined by aOffset. aOffset is advanced so that on return, the new 
+		offset is stored enabling the next call to UnpackType() to point at the position 
+		following this type.
+		
+		@param aDes The buffer that contains the type T pointed to by aPtr
+		@param aOffset The running index of where the following type begins. Updated by ExtractPointer
+		*/
+		{
+		// Set length of the unicode string in characters
+		TUint32 length;
+	
+		UnpackTypeAdvance(length, *iDataBuffer, aOffset);
+		
+		TUint8* pRawSource = reinterpret_cast<TUint8*>(const_cast<TUint16*>(aDes.Ptr()));
+		TUint8* pRawTarget = const_cast<TUint8*>(static_cast<const TUint8*>(iDataBuffer->Ptr() + aOffset));
+		
+		for (TInt32 index = 0; index < (length * KCharWidthInBytes) ; index++)
+			{
+			*pRawTarget++ = *pRawSource++;
+			aOffset++;
+			}
+		}
+
+	void CSBGenericDataType::UnpackDescriptorTypeAdvance(TDesC8& aDes, TInt& aOffset)
+		/**
+		Function to copy a simple type from a specified position in aDes
+		defined by aOffset. aOffset is advanced so that on return, the new 
+		offset is stored enabling the next call to UnpackType() to point at the position 
+		following this type.
+		
+		@param aDes The buffer that contains the descriptor to copy from
+		@param aOffset The running index of where the following type begins. Updated by ExtractPointer
+		*/
+		{
+		// Set length of the string in 8-bit byte characters
+		TUint32 length;
+	
+		UnpackTypeAdvance(length, *iDataBuffer, aOffset);
+		
+		TUint8* pRawSource = const_cast<TUint8*>(aDes.Ptr());
+		TUint8* pRawTarget = const_cast<TUint8*>(iDataBuffer->Ptr() + aOffset);
+		
+		for (TInt32 index = 0; index < length ; index++)
+			{
+			*pRawTarget++ = *pRawSource++;
+			aOffset++;
+			}
+		}
+
+	void CSBGenericDataType::UnpackTPtrAdvance(TPtrC16& aDes, TInt& aOffset)
+		/**
+		Function to copy a simple type from a specified position in aDes
+		defined by aOffset. aOffset is advanced so that on return, the new 
+		offset is stored enabling the next call to UnpackType() to point at the position 
+		following this type.
+		
+		@param aDes The buffer that contains the type T pointed to by aPtr
+		@param aOffset The running index of where the following type begins. Updated by ExtractPointer
+		*/
+		{
+		// Set length of the unicode string in characters
+		TInt32 length;
+	
+		UnpackTypeAdvance(length, *iDataBuffer, aOffset);
+		
+		aDes.Set(reinterpret_cast<const TUint16*>(iDataBuffer->Ptr() + aOffset), length);
+
+		aOffset += aDes.Size();
+		}
+
+	void CSBGenericDataType::UnpackTPtrAdvance(TPtrC8& aDes, TInt& aOffset)
+		/**
+		Function to copy a simple type from a specified position in aDes
+		defined by aOffset. aOffset is advanced so that on return, the new 
+		offset is stored enabling the next call to UnpackType() to point at the position 
+		following this type.
+		
+		@param aDes The buffer that contains the descriptor to copy from
+		@param aOffset The running index of where the following type begins. Updated by ExtractPointer
+		*/
+		{
+		// Set length of the string in 8-bit byte characters
+		TInt32 length;
+	
+		UnpackTypeAdvance(length, *iDataBuffer, aOffset);
+		
+		aDes.Set(iDataBuffer->Ptr() + aOffset, length);
+
+		aOffset += aDes.Size();
+		}
+
+	void CSBGenericDataType::PackDescriptorTypeAdvance(const TDesC16& aDes, TInt& aOffset)
+		/**
+		Templated function to copy a simple type into a specified position in aDes
+		defined by aOffset. aOffset is not advanced as a result of this operation
+		
+		@param aDes The buffer to copy from
+		@param aOffset The running index of where the following type begins. Updated by ExtractPointer
+		*/
+		{
+		TInt32 length = aDes.Length();
+
+		PackTypeAdvance(length, *iDataBuffer, aOffset);
+
+ 		TUint8* pRawSource = const_cast<TUint8*>(reinterpret_cast<const TUint8*>(aDes.Ptr()));
+		TUint8* pRawTarget = const_cast<TUint8*>(reinterpret_cast<const TUint8*>(iDataBuffer->Ptr())) + aOffset;
+		
+		for (TInt32 index = 0; index < (length * KCharWidthInBytes); index++)
+			{
+			*pRawTarget++ = *pRawSource++;
+			aOffset++;
+			}
+		}
+
+	void CSBGenericDataType::PackDescriptorTypeAdvance(const TDesC8& aDes, TInt& aOffset)
+		/**
+		Templated function to copy a simple type into a specified position in aDes
+		defined by aOffset. aOffset is not advanced as a result of this operation
+		
+		@param aDes The buffer to copy from
+		@param aOffset The running index of where the following type begins. Updated by ExtractPointer
+		*/
+		{
+		TInt32 length = aDes.Size();
+
+		PackTypeAdvance(length, *iDataBuffer, aOffset);
+
+		TUint8* pRawSource = const_cast<TUint8*>(reinterpret_cast<const TUint8*>(aDes.Ptr()));
+		TUint8* pRawTarget = const_cast<TUint8*>(iDataBuffer->Ptr() + aOffset);
+		
+		for (TInt32 index = 0; index < length; index++)
+			{
+			*pRawTarget++ = *pRawSource++;
+			aOffset++;
+			}
+		}
+		
+		
+// CSBSecureId
+	EXPORT_C CSBSecureId* CSBSecureId::NewL(TSecureId aSecureId)
+	/**
+	Symbian constructor used for creating a derived class from it's constituent parameters. Used 
+	for example when creating a derived type from scratch
+
+	@param aSecureId the secure identifier
+	@return A pointer to the CSBSecureId object
+	*/
+		{
+		CSBSecureId* self = new(ELeave) CSBSecureId();
+		CleanupStack::PushL(self);
+		self->ConstructL(aSecureId);
+		CleanupStack::Pop(self);
+		return self;
+		}
+	
+	EXPORT_C CSBSecureId* CSBSecureId::NewL(CSBGenericDataType* aGenericDataType)
+	/**
+	Symbian constructor used when creating a derived type from a base type, typically used 
+	post-IPC in SBEngine to create a derived type from a generic type originally passed from 
+	the PC
+
+	@param aGenericDataType pointer to a CSBGenericDataType object
+	@return A pointer to the CSBSecureId object
+	*/
+		{
+		CSBSecureId* self = new(ELeave) CSBSecureId();
+		CleanupStack::PushL(self);
+		self->ConstructL(aGenericDataType);
+		CleanupStack::Pop(self);
+		return self;
+		}
+		
+	CSBSecureId::CSBSecureId()
+	/**
+	C++ Constructor. Any derived types must increment iSize in their C++ constructors in order 
+	that when CSBGenericDataType::BaseConstructL() is called, the data buffer is initialised 
+	to be large enough to accomodate the data stored by the derived type
+	*/
+		{
+		iSize += sizeof(TSecureId);
+		}
+
+	EXPORT_C CSBSecureId::~CSBSecureId()
+	/**
+	C++ Destructor
+	*/
+		{
+		}
+
+	void CSBSecureId::InitialiseL(TInt& aOffset)
+	/**
+	Initialise all member pointers to data
+	
+	@param aOffset The running offset of where the descriptor has been parsed up to
+	*/
+		{
+		// Throwaway type used for sizeof information only
+		TSecureId sid;
+		
+		CSBGenericDataType::InitialiseL(aOffset);
+		iSecureIdOffset = aOffset;
+
+		UnpackTypeAdvance(sid, *iDataBuffer, aOffset);
+		
+		// Increment the size of the data buffer
+		iDataBuffer->Des().SetLength(aOffset);
+		}
+
+	void CSBSecureId::ConstructL(TSecureId aSecureId)
+	/**
+	Symbian OS 2nd phase constructor.
+
+	@param aSecureId the secure identifier
+	*/
+		{
+		TInt offset = 0;
+		// Call the Base ConstructL in order to allocate the buffer
+		BaseConstructL();
+		
+		TSBDerivedType derivedType = ESIDDerivedType;
+		PackType(derivedType, *iDataBuffer, offset);
+		
+		InitialiseL(offset);
+		
+		TSecureId sid = aSecureId;
+		
+		PackType(sid, *iDataBuffer, iSecureIdOffset);
+		}
+		
+	void CSBSecureId::ConstructL(CSBGenericDataType* aGenericDataType)
+	/**
+	Symbian 2nd phase constructor. Validates the externalised type, then passes it to the base ConstructL
+
+	@param aGenericDataType pointer to a CSBGenericDataType object
+	*/
+		{
+		if (aGenericDataType == NULL)
+			{
+			User::Leave(KErrArgument);
+			}
+		if (ESIDDerivedType != aGenericDataType->DerivedTypeL())
+			{
+			User::Leave(KErrArgument);
+			}
+		// If the descriptor is different to the size we're expecting then it's not correct
+		const TDesC8& des = aGenericDataType->Externalise();
+		if (des.Size() != iSize)
+			{
+			User::Leave(KErrArgument);
+			}
+		
+		// Call the base class ConstructL
+		CSBGenericDataType::ConstructL(des);
+		}
+		
+	EXPORT_C TSecureId CSBSecureId::SecureIdL() const
+	/**
+	Getter for the secure identifier
+		
+	@return  The secure identifier
+	*/
+		{
+		TSecureId sid;
+		
+		UnpackType(sid, *iDataBuffer, iSecureIdOffset);
+		
+		return sid;
+		}
+	
+	
+	// CSBPackageId
+	EXPORT_C CSBPackageId* CSBPackageId::NewL(TUid aPackageId, TSecureId aSecureId, const TDesC& aPackageName)
+	/**
+	Symbian constructor used for creating a derived class from it's constituent parameters. Used 
+	for example when creating a derived type from scratch
+
+	@param aPackageId  the package identifier
+	@param aSecureId  the secure identifier
+	@param aPackageName  the name of the package
+	@return A pointer to the CSBPackageId object
+	*/
+		{
+		CSBPackageId* self = new(ELeave) CSBPackageId();
+		CleanupStack::PushL(self);
+		self->ConstructL(aPackageId, aSecureId, aPackageName);
+		CleanupStack::Pop(self);
+		return self;
+		}
+	
+	EXPORT_C CSBPackageId* CSBPackageId::NewL(CSBGenericDataType* aGenericDataType)
+	/**
+	Symbian constructor used when creating a derived type from a base type, typically used 
+	post-IPC in SBEngine to create a derived type from a generic type originally passed from 
+	the PC
+
+	@param aGenericDataType  pointer to a CSBGenericDataType object
+	@return A pointer to the CSBPackageId object
+	*/
+		{
+		CSBPackageId* self = new(ELeave) CSBPackageId();
+		CleanupStack::PushL(self);
+		self->ConstructL(aGenericDataType);
+		CleanupStack::Pop(self);
+		return self;
+		}	
+	
+	CSBPackageId::CSBPackageId()
+	/**
+	C++ Constructor. Any derived types must increment iSize in their C++ constructors in order 
+	that when CSBGenericDataType::BaseConstructL() is called, the data buffer is initialised 
+	to be large enough to accomodate the data stored by the derived type
+	*/
+		{
+		iSize += (sizeof(TUid) + sizeof(TSecureId) + sizeof(TPackageName));
+		}
+
+	EXPORT_C CSBPackageId::~CSBPackageId()
+	/**
+	C++ Destructor
+	*/
+		{
+		}
+
+
+	void CSBPackageId::InitialiseL(TInt& aOffset, TInt aPackageNameLength)
+	/**
+	Initialise all member pointers to data
+	
+	@param aOffset The running offset of where the descriptor has been parsed up to
+	@param aPackageNameLength The lenght of the package name
+	*/
+		{
+		TUid pkgId;
+		TSecureId sid;
+		TPackageName pkgName;
+		
+		CSBGenericDataType::InitialiseL(aOffset);
+
+		iPackageIdOffset = aOffset;
+		// Assign the pointer to the package Id position in the buffer
+		UnpackTypeAdvance(pkgId, *iDataBuffer, aOffset);
+
+		iSecureIdOffset = aOffset;
+		// Assign the pointer to the secure Id position in the buffer
+		UnpackTypeAdvance(sid, *iDataBuffer, aOffset);
+		
+		iPackageNameOffset = aOffset;
+		aOffset += sizeof(TInt);
+		aOffset += aPackageNameLength * KCharWidthInBytes;
+		
+		// Increment the size of the data buffer
+		iDataBuffer->Des().SetLength(aOffset);
+		}
+		
+	void CSBPackageId::InitialiseL(TInt& aOffset)
+	/**
+	Initialise all member pointers to data
+	
+	@param aOffset The running offset of where the descriptor has been parsed up to
+	*/
+		{
+		TUid pkgId;
+		TSecureId sid;
+		TPackageName pkgName;
+		
+		CSBGenericDataType::InitialiseL(aOffset);
+
+		iPackageIdOffset = aOffset;
+		// Assign the pointer to the package Id position in the buffer
+		UnpackTypeAdvance(pkgId, *iDataBuffer, aOffset);
+
+		iSecureIdOffset = aOffset;
+		// Assign the pointer to the secure Id position in the buffer
+		UnpackTypeAdvance(sid, *iDataBuffer, aOffset);
+		
+		iPackageNameOffset = aOffset;
+		// Assign the pointer to the package name position
+		
+		TInt size = *(const_cast<TUint8*>(iDataBuffer->Des().Ptr()) + aOffset);
+		aOffset += 4;
+		aOffset += size * KCharWidthInBytes;
+		
+		// Increment the size of the data buffer
+		iDataBuffer->Des().SetLength(aOffset);
+		}
+		
+
+	void CSBPackageId::ConstructL(TUid aPackageId, TSecureId aSecureId,
+								  const TDesC& aPackageName)
+	/**
+	Symbian OS 2nd phase constructor.
+
+	@param aPackageId  the package identifier
+	@param aSecureId  the secure identifier
+	@param aPackageName  the name of the package
+	*/
+		{
+		// Call the Base ConstructL in order to allocate the buffer
+		BaseConstructL();
+		
+		TInt offset = 0;
+		
+		TSBDerivedType derivedType = EPackageDerivedType;
+		PackType(derivedType, *iDataBuffer, offset);
+		
+		// Initialise all member pointers right up the inheritence tree
+		InitialiseL(offset, aPackageName.Length());
+
+		// Set the passed in data into the data buffer
+		TUid packageId = aPackageId;
+		TSecureId secureId = aSecureId;
+		TPackageName packageName(aPackageName);
+		
+		PackType(packageId, *iDataBuffer, iPackageIdOffset);
+		PackType(secureId, *iDataBuffer, iSecureIdOffset);
+		PackType(packageName, *iDataBuffer, iPackageNameOffset);
+		}
+
+	void CSBPackageId::ConstructL(CSBGenericDataType* aGenericDataType)
+	/**
+	Symbian 2nd phase constructor. Validates the externalised type, then passes it to the base ConstructL
+
+	@param aGenericDataType  pointer to a CSBGenericDataType object
+	*/
+		{
+		if (aGenericDataType == NULL)
+			{
+			User::Leave(KErrArgument);
+			}
+		if (EPackageDerivedType != aGenericDataType->DerivedTypeL())
+			{
+			User::Leave(KErrArgument);
+			}
+		const TDesC8& des = aGenericDataType->Externalise();
+		
+		if (des.Size() > iSize)
+			{
+			User::Leave(KErrArgument);
+			}
+		// Call the base class ConstructL
+		CSBGenericDataType::ConstructL(des);
+		}
+		
+	EXPORT_C TUid CSBPackageId::PackageIdL() const
+	/**
+	Getter for the package identifier
+		
+	@return  The package identifier
+	*/
+		{
+		TUid pkgId;
+		
+		UnpackType(pkgId, *iDataBuffer, iPackageIdOffset);
+		
+		return pkgId;
+		}
+		
+	EXPORT_C TSecureId CSBPackageId::SecureIdL() const
+	/**
+	Getter for the secure identifier
+		
+	@return  The secure identifier
+	*/
+		{
+		TSecureId secureId;
+		
+		UnpackType(secureId, *iDataBuffer, iSecureIdOffset);
+		
+		return secureId;
+		}
+
+	EXPORT_C TPackageName CSBPackageId::PackageNameL() const
+	/**
+	Getter for the package name
+		
+	@return  Reference to the package name
+	*/
+		{
+		TPackageName pkgName;
+		
+		UnpackType(pkgName, *iDataBuffer, iPackageNameOffset);
+		
+		return pkgName;
+		}
+
+
+	// CSBGenericDataType
+	EXPORT_C CSBGenericTransferType* CSBGenericTransferType::NewL(const TDesC8& aDes)
+	/**
+	Symbian constructor
+
+	@param aDes descriptor containing the buffer of data
+	@return A pointer to the CSBGenericTransferType object
+	*/
+		{
+		CSBGenericTransferType* self = new(ELeave) CSBGenericTransferType();
+		CleanupStack::PushL(self);
+		self->CSBGenericDataType::ConstructL(aDes);
+		CleanupStack::Pop(self);
+		return self;
+		}
+
+	void CSBGenericTransferType::InitialiseL(TInt& aOffset)
+	/**
+	Initialise all member pointers to data
+	
+	@param aOffset The running offset of where the descriptor has been parsed up to
+	*/
+		{
+		CSBGenericDataType::InitialiseL(aOffset);
+		
+		if (iSize < (aOffset + sizeof(TDriveNumber)))
+			{
+			User::Leave(KErrCorrupt);
+			}
+		
+		// Dummy data to get sizeof information from
+		TDriveNumber driveNum;
+		
+		iDriveNumberOffset = aOffset;
+		UnpackTypeAdvance(driveNum, *iDataBuffer, aOffset);
+		
+		// Increment the size of the data buffer
+		iDataBuffer->Des().SetLength(aOffset);
+		}
+	
+	CSBGenericTransferType::CSBGenericTransferType()
+	/**
+	C++ Constructor. Any derived types must increment iSize in their C++ constructors in order 
+	that when CSBGenericDataType::BaseConstructL() is called, the data buffer is initialised 
+	to be large enough to accomodate the data stored by the derived type
+	*/
+		{
+		iSize += sizeof(TDriveNumber);
+		}
+
+	EXPORT_C CSBGenericTransferType::~CSBGenericTransferType()
+	/**
+	C++ Destructor
+	*/
+		{
+		}
+
+	EXPORT_C TDriveNumber CSBGenericTransferType::DriveNumberL() const
+	/**
+	Getter method for returning the drive number
+	
+	@return The drive number
+	*/
+		{
+		TDriveNumber driveNum;
+		
+		UnpackType(driveNum, *iDataBuffer, iDriveNumberOffset);
+		
+		return driveNum;
+		}
+		
+	// CSBSIDTransferType
+	EXPORT_C CSBSIDTransferType* CSBSIDTransferType::NewL(TSecureId aSecureId, TDriveNumber aDriveNumber, TTransferDataType aTransferDataType)
+	/**
+	Symbian constructor used for creating a derived class from it's constituent parameters. Used 
+	for example when creating a derived type from scratch
+
+	@param aSecureId the secure identifier
+	@param aDriveNumber the drive that contains the data
+	@param aTransferDataType the type of the data you wish to transfer
+	@return A pointer to the CSBSIDTransferType object
+	*/
+		{
+		CSBSIDTransferType* self = new(ELeave) CSBSIDTransferType();
+		CleanupStack::PushL(self);
+		self->ConstructL(aSecureId, aDriveNumber, aTransferDataType);
+		CleanupStack::Pop(self);
+		return self;
+		}
+	
+	EXPORT_C CSBSIDTransferType* CSBSIDTransferType::NewL(CSBGenericTransferType* aGenericTransferType)
+	/**
+	Symbian constructor used when creating a derived type from a base type, typically used 
+	post-IPC in SBEngine to create a derived type from a generic type originally passed from 
+	the PC
+
+	@param aGenericTransferType pointer to a CSBGenericTransferType object
+	@return A pointer to the CSBSIDTransferType object
+	*/
+		{
+		CSBSIDTransferType* self = new(ELeave) CSBSIDTransferType();
+		CleanupStack::PushL(self);
+		self->ConstructL(aGenericTransferType);
+		CleanupStack::Pop(self);
+		return self;
+		}	
+	
+	CSBSIDTransferType::CSBSIDTransferType()
+	/**
+	C++ Constructor. Any derived types must increment iSize in their C++ constructors in order 
+	that when CSBGenericDataType::BaseConstructL() is called, the data buffer is initialised 
+	to be large enough to accomodate the data stored by the derived type
+	*/
+		{
+		iSize += (sizeof(TSecureId) + sizeof(TTransferDataType));
+		}
+
+	EXPORT_C CSBSIDTransferType::~CSBSIDTransferType()
+	/**
+	C++ Destructor
+	*/
+		{
+		}
+
+	void CSBSIDTransferType::InitialiseL(TInt& aOffset)
+	/**
+	Initialise all member pointers to data
+	
+	@param aOffset The running offset of where the descriptor has been parsed up to
+	*/
+		{
+		CSBGenericTransferType::InitialiseL(aOffset);
+
+		TSecureId sid;
+		TTransferDataType transType;
+
+		iSecureIdOffset = aOffset;
+		UnpackTypeAdvance(sid, *iDataBuffer, aOffset);
+		
+		iTransferDataTypeOffset = aOffset;
+		UnpackTypeAdvance(transType, *iDataBuffer, aOffset);
+		
+		// Increment the size of the data buffer
+		iDataBuffer->Des().SetLength(aOffset);
+		}
+
+	void CSBSIDTransferType::ConstructL(TSecureId aSecureId, TDriveNumber aDriveNumber,
+										TTransferDataType aTransferDataType)
+	/**
+	Symbian OS 2nd phase constructor.
+
+	@param aSecureId the secure identifier
+	@param aDriveNumber the drive that contains the data
+	@param aTransferDataType the type of the data you wish to transfer
+	*/
+		{
+		TInt offset = 0;
+
+		BaseConstructL();
+
+		TSBDerivedType derivedType = ESIDTransferDerivedType;
+		PackType(derivedType, *iDataBuffer, offset);
+				
+		InitialiseL(offset);
+
+		TDriveNumber driveNum = aDriveNumber;
+		TSecureId sid = aSecureId;
+		TTransferDataType transType = aTransferDataType;
+
+		PackType(driveNum, *iDataBuffer, iDriveNumberOffset);
+		PackType(sid, *iDataBuffer, iSecureIdOffset);
+		PackType(transType, *iDataBuffer, iTransferDataTypeOffset);
+		}
+
+	void CSBSIDTransferType::ConstructL(CSBGenericTransferType* aGenericTransferType)
+	/**
+	Symbian 2nd phase constructor. Validates the externalised type, then passes it to the base ConstructL
+
+	@param aGenericTransferType pointer to a CSBGenericTransferType object
+	*/
+		{
+		if (aGenericTransferType == NULL)
+			{
+			User::Leave(KErrArgument);
+			}
+		if (ESIDTransferDerivedType != aGenericTransferType->DerivedTypeL())
+			{
+			User::Leave(KErrArgument);
+			}
+		// If the descriptor is different to the size we're expecting then it's not correct
+		const TDesC8& des = aGenericTransferType->Externalise();
+		if (des.Size() != iSize)
+			{
+			User::Leave(KErrArgument);
+			}
+		
+		// Call the base class ConstructL
+		CSBGenericDataType::ConstructL(des);
+		}
+		
+	EXPORT_C TSecureId CSBSIDTransferType::SecureIdL() const
+	/**
+	Getter for the secure identifier
+		
+	@return  The secure identifier
+	*/
+		{
+		TSecureId sid;
+		
+		UnpackType(sid, *iDataBuffer, iSecureIdOffset);
+		
+		return sid;
+		}
+
+	EXPORT_C TTransferDataType CSBSIDTransferType::DataTypeL() const
+	/**
+	Getter for the transfer data type
+		
+	@return  The transfer data type
+	*/
+		{
+		TTransferDataType transType;
+		
+		UnpackType(transType, *iDataBuffer, iTransferDataTypeOffset);
+
+		return transType;
+		}
+		
+		
+	// CSBPackageTransferType
+	EXPORT_C CSBPackageTransferType* CSBPackageTransferType::NewL(TUid aPackageId, TDriveNumber aDriveNumber,
+																  TPackageDataType aPackageDataType)
+	/**
+	Symbian constructor used for creating a derived class from it's constituent parameters. Used 
+	for example when creating a derived type from scratch
+
+	@param aPackageId the package identifier
+	@param aDriveNumber the drive that contains the data
+	@param aPackageDataType the type of the package data
+	@return A pointer to the CSBPackageTransferType object
+	*/
+		{
+		CSBPackageTransferType* self = new(ELeave) CSBPackageTransferType();
+		CleanupStack::PushL(self);
+		self->ConstructL(aPackageId, aDriveNumber, aPackageDataType);
+		CleanupStack::Pop(self);
+		return self;
+		}
+	
+	EXPORT_C CSBPackageTransferType* CSBPackageTransferType::NewL(CSBGenericTransferType* aGenericTransferType)
+	/**
+	Symbian constructor used when creating a derived type from a base type, typically used 
+	post-IPC in SBEngine to create a derived type from a generic type originally passed from 
+	the PC
+
+	@param aGenericTransferType pointer to a CSBGenericTransferType object
+	@return A pointer to the CSBPackageTransferType object
+	*/
+		{
+		CSBPackageTransferType* self = new(ELeave) CSBPackageTransferType();
+		CleanupStack::PushL(self);
+		self->ConstructL(aGenericTransferType);
+		CleanupStack::Pop(self);
+		return self;
+		}	
+	
+	CSBPackageTransferType::CSBPackageTransferType()
+	/**
+	C++ Constructor. Any derived types must increment iSize in their C++ constructors in order 
+	that when CSBGenericDataType::BaseConstructL() is called, the data buffer is initialised 
+	to be large enough to accomodate the data stored by the derived type
+	*/
+		{
+		iSize += (sizeof(TUid) + sizeof(TPackageDataType));
+		}
+
+	void CSBPackageTransferType::InitialiseL(TInt& aOffset)
+	/**
+	Initialise all member pointers to data
+	
+	@param aOffset The running offset of where the descriptor has been parsed up to
+	*/
+		{
+		CSBGenericTransferType::InitialiseL(aOffset);
+
+		TUid pkgId;
+		TPackageDataType pkgDataType;
+		
+		iPackageIdOffset = aOffset;
+		UnpackTypeAdvance(pkgId, *iDataBuffer, aOffset);
+		
+		iPackageDataTypeOffset = aOffset;
+		UnpackTypeAdvance(pkgDataType, *iDataBuffer, aOffset);
+		
+		// Increment the size of the data buffer
+		iDataBuffer->Des().SetLength(aOffset);
+		}
+
+	EXPORT_C CSBPackageTransferType::~CSBPackageTransferType()
+	/**
+	C++ Destructor
+	*/
+		{
+		}
+
+	void CSBPackageTransferType::ConstructL(TUid aPackageId, TDriveNumber aDriveNumber,
+										TPackageDataType aPackageDataType)
+	/**
+	Symbian OS 2nd phase constructor.
+
+	@param aPackageId the secure identifier
+	@param aDriveNumber the drive that contains the data
+	@param aPackageDataType the type of the data you wish to transfer
+	*/
+		{
+		TInt offset = 0;
+
+		BaseConstructL();
+
+		TSBDerivedType derivedType = EPackageTransferDerivedType;
+		PackType(derivedType, *iDataBuffer, offset);
+				
+		InitialiseL(offset);
+
+		TPackageDataType pkgDataType = aPackageDataType;
+		TDriveNumber driveNum = aDriveNumber;
+		TUid pkgId = aPackageId;
+		
+		PackType(driveNum, *iDataBuffer, iDriveNumberOffset);
+		PackType(pkgId, *iDataBuffer, iPackageIdOffset);
+		PackType(pkgDataType, *iDataBuffer, iPackageDataTypeOffset);
+		}
+
+	void CSBPackageTransferType::ConstructL(CSBGenericTransferType* aGenericTransferType)
+	/**
+	Symbian 2nd phase constructor. Validates the externalised type, then passes it to the base ConstructL
+
+	@param aGenericTransferType pointer to a CSBGenericTransferType object
+	*/
+		{
+		if (aGenericTransferType == NULL)
+			{
+			User::Leave(KErrArgument);
+			}
+		if (EPackageTransferDerivedType != aGenericTransferType->DerivedTypeL())
+			{
+			User::Leave(KErrArgument);
+			}
+		// If the descriptor is different to the size we're expecting then it's not correct
+		const TDesC8& des = aGenericTransferType->Externalise();
+		
+		if (des.Size() != iSize)
+			{
+			User::Leave(KErrArgument);
+			}
+		
+		// Call the base class ConstructL
+		CSBGenericDataType::ConstructL(des);
+		}
+		
+	EXPORT_C TUid CSBPackageTransferType::PackageIdL() const
+	/**
+	Getter for the package identifier
+		
+	@return  The package identifier
+	*/
+		{
+		TUid pkgId;
+		
+		UnpackType(pkgId, *iDataBuffer, iPackageIdOffset);
+		
+		return pkgId;
+		}
+
+	EXPORT_C TPackageDataType CSBPackageTransferType::DataTypeL() const
+	/**
+	Getter for the package data type
+		
+	@return  The package data type
+	*/
+		{
+		TPackageDataType pkgDataType;
+		
+		UnpackType(pkgDataType, *iDataBuffer, iPackageDataTypeOffset);
+		
+		return pkgDataType;
+		}
+		
+// JavaID
+
+	EXPORT_C CSBJavaId* CSBJavaId::NewL(const TDesC& aSuiteName, const TDesC& aSuiteVendor,
+		const TDesC& aSuiteVersion, const TDesC& aSuiteHash)
+	/**
+	Symbian constructor used for creating a derived class from it's constituent parameters. Used 
+	for example when creating a derived type from scratch
+
+	@param aSuiteName  the name of the java suite
+	@param aSuiteVendor  the suite vendor
+	@param aSuiteVersion  the version of the java suite
+	@param aSuiteHash the hash of the java suite
+	@return A pointer to the CSBJavaId object
+	*/
+		{
+		CSBJavaId* self = new(ELeave) CSBJavaId(aSuiteName, aSuiteVendor, aSuiteVersion, aSuiteHash);
+		CleanupStack::PushL(self);
+		self->ConstructL(aSuiteName, aSuiteVendor, aSuiteVersion, aSuiteHash);
+		CleanupStack::Pop(self);
+		return self;
+		}
+	
+	EXPORT_C CSBJavaId* CSBJavaId::NewL(CSBGenericDataType* aGenericDataType)
+	/**
+	Symbian constructor used when creating a derived type from a base type, typically used 
+	post-IPC in SBEngine to create a derived type from a generic type originally passed from 
+	the PC
+
+	@param aGenericDataType  pointer to a CSBGenericDataType object
+	@return A pointer to the CSBJavaId object
+	*/
+		{
+		CSBJavaId* self = new(ELeave) CSBJavaId;
+		CleanupStack::PushL(self);
+		self->ConstructFromExistingL(aGenericDataType);
+		CleanupStack::Pop(self);
+		return self;
+		}	
+		
+	CSBJavaId::CSBJavaId()
+		{
+		}
+	
+	CSBJavaId::CSBJavaId(const TDesC& aSuiteName, const TDesC& aSuiteVendor,
+		const TDesC& aSuiteVersion, const TDesC& aSuiteHash)
+	/**
+	C++ Constructor. Any derived types must increment iSize in their C++ constructors in order 
+	that when CSBGenericDataType::BaseConstructL() is called, the data buffer is initialised 
+	to be large enough to accomodate the data stored by the derived type
+	
+	@param aSuiteName The name of the MIDlet suite
+	@param aSuiteVendor The name of the vendor of the MIDlet suiet
+	@param aSuiteHash The Java MIDlet suite hash
+	@param aSuiteVersion The version of the MIDlet suite
+	*/
+		{
+		iSize += (4 * sizeof(TUint32)) + aSuiteName.Size() + aSuiteVendor.Size() + aSuiteVersion.Size() 
+			+ aSuiteHash.Size();
+		}
+
+	EXPORT_C CSBJavaId::~CSBJavaId()
+	/**
+	C++ Destructor
+	*/
+		{
+		}
+
+	void CSBJavaId::InitialiseL(TInt& aOffset)
+	/**
+	Initialise all member pointers to data
+	
+	@param aOffset The running offset of where the descriptor has been parsed up to
+	*/
+		{
+		CSBGenericDataType::InitialiseL(aOffset);
+		
+		UnpackTPtrAdvance(iSuiteName, aOffset);
+		UnpackTPtrAdvance(iSuiteVendor, aOffset);
+		UnpackTPtrAdvance(iSuiteVersion, aOffset);
+		UnpackTPtrAdvance(iSuiteHash, aOffset);
+
+		// Increment the size of the data buffer
+		iDataBuffer->Des().SetLength(aOffset);
+		}
+
+	void CSBJavaId::InitialiseL(TInt& aOffset, const TDesC& aSuiteName, const TDesC& aSuiteVendor,
+		const TDesC& aSuiteVersion, const TDesC& aSuiteHash)
+	/**
+	Initialise all member pointers to data
+	
+	@param aOffset The running offset of where the descriptor has been parsed up to
+	@param aSuiteName The name of the MIDlet suite
+	@param aSuiteVendor The name of the vendor of the MIDlet suiet
+	@param aSuiteHash The Java MIDlet suite hash
+	@param aSuiteVersion The version of the MIDlet suite
+	*/
+		{
+		TSBDerivedType derivedType = EJavaDerivedType;
+		
+		PackType(derivedType, *iDataBuffer, aOffset);
+		
+		CSBGenericDataType::InitialiseL(aOffset);
+
+		// Set the derived type in the buffer
+		
+		TInt ptrOffset = aOffset;
+
+		PackDescriptorTypeAdvance(aSuiteName, aOffset);
+		PackDescriptorTypeAdvance(aSuiteVendor, aOffset);
+		PackDescriptorTypeAdvance(aSuiteVersion, aOffset);
+		PackDescriptorTypeAdvance(aSuiteHash, aOffset);
+		
+		UnpackTPtrAdvance(iSuiteName, ptrOffset);
+		UnpackTPtrAdvance(iSuiteVendor, ptrOffset);
+		UnpackTPtrAdvance(iSuiteVersion, ptrOffset);
+		UnpackTPtrAdvance(iSuiteHash, ptrOffset);
+		
+		// Increment the size of the data buffer
+		iDataBuffer->Des().SetLength(aOffset);
+		}
+		
+	void CSBJavaId::ConstructL(const TDesC& aSuiteName, const TDesC& aSuiteVendor, 
+		const TDesC& aSuiteVersion, const TDesC& aSuiteHash)
+	/**
+	Symbian OS 2nd phase constructor.
+
+	@param aSuiteName The name of the MIDlet suite
+	@param aSuiteVendor The name of the vendor of the MIDlet suiet
+	@param aSuiteHash The Java MIDlet suite hash
+	@param aSuiteVersion The version of the MIDlet suite
+	*/
+		{
+		// Call the Base ConstructL in order to allocate the buffer
+		BaseConstructL();
+		
+		TInt offset = 0;
+		
+		// Initialise all member pointers right up the inheritence tree
+		InitialiseL(offset, aSuiteName, aSuiteVendor, aSuiteVersion, aSuiteHash);
+		}
+
+	void CSBJavaId::ConstructFromExistingL(CSBGenericDataType* aGenericDataType)
+	/**
+	Symbian 2nd phase constructor. Validates the externalised type, then passes it to the base ConstructL
+
+	@param aGenericDataType  pointer to a CSBGenericDataType object
+	*/
+		{
+		if (aGenericDataType == NULL)
+			{
+			User::Leave(KErrArgument);
+			}
+		if (EJavaDerivedType != aGenericDataType->DerivedTypeL())
+			{
+			User::Leave(KErrArgument);
+			}
+		// Call the base class ConstructL
+		CSBGenericDataType::ConstructL(aGenericDataType->Externalise());
+		}
+		
+	EXPORT_C const TDesC& CSBJavaId::SuiteNameL() const
+	/**
+	Getter for the MIDlet suite name
+		
+	@return  The package identifier
+	*/
+		{
+		return iSuiteName;
+		}
+
+	EXPORT_C const TDesC& CSBJavaId::SuiteVendorL() const
+	/**
+	Getter for the MIDlet suite vendor
+		
+	@return  The package identifier
+	*/
+		{
+		return iSuiteVendor;
+		}
+
+	EXPORT_C const TDesC& CSBJavaId::SuiteVersionL() const
+	/**
+	Getter for the MIDlet suite version
+		
+	@return  The package identifier
+	*/
+		{
+		return iSuiteVersion;
+		}
+
+	EXPORT_C const TDesC& CSBJavaId::SuiteHashL() const
+	/**
+	Getter for the MIDlet suite hash
+		
+	@return  The package identifier
+	*/
+		{
+		return iSuiteHash;
+		}
+
+// CSBJavaTransferType
+	EXPORT_C CSBJavaTransferType* CSBJavaTransferType::NewL(const TDesC& aSuiteHash, TDriveNumber aDriveNumber, TJavaTransferType aTransferDataType)
+	/**
+	Symbian constructor used for creating a derived class from it's constituent parameters. Used 
+	for example when creating a derived type from scratch
+
+	@param aSecureId the secure identifier
+	@param aDriveNumber the drive that contains the data
+	@param aTransferDataType the type of the data you wish to transfer
+	@return A pointer to the CSBJavaTransferType object
+	*/
+		{
+		CSBJavaTransferType* self = new(ELeave) CSBJavaTransferType(aSuiteHash);
+		CleanupStack::PushL(self);
+		self->ConstructL(aSuiteHash, aDriveNumber, aTransferDataType);
+		CleanupStack::Pop(self);
+		return self;
+		}
+	
+	EXPORT_C CSBJavaTransferType* CSBJavaTransferType::NewL(CSBGenericTransferType* aGenericTransferType)
+	/**
+	Symbian constructor used when creating a derived type from a base type, typically used 
+	post-IPC in SBEngine to create a derived type from a generic type originally passed from 
+	the PC
+
+	@param aGenericTransferType pointer to a CSBGenericTransferType object
+	@return A pointer to the CSBJavaTransferType object
+	*/
+		{
+		CSBJavaTransferType* self = new(ELeave) CSBJavaTransferType;
+		CleanupStack::PushL(self);
+		self->ConstructL(aGenericTransferType);
+		CleanupStack::Pop(self);
+		return self;
+		}
+		
+	CSBJavaTransferType::CSBJavaTransferType()
+	/**
+	C++ Constructor
+	*/
+		{
+		}
+	
+	CSBJavaTransferType::CSBJavaTransferType(const TDesC& aSuiteHash)
+	/**
+	C++ Constructor. Any derived types must increment iSize in their C++ constructors in order 
+	that when CSBGenericDataType::BaseConstructL() is called, the data buffer is initialised 
+	to be large enough to accomodate the data stored by the derived type
+	*/
+		{
+		iSize += aSuiteHash.Size() + sizeof(TUint32) + sizeof(TJavaTransferType);
+		}
+
+	EXPORT_C CSBJavaTransferType::~CSBJavaTransferType()
+	/**
+	C++ Destructor
+	*/
+		{
+		}
+
+	void CSBJavaTransferType::InitialiseL(TInt& aOffset)
+	/**
+	Initialise all member pointers to data
+	
+	@param aOffset The running offset of where the descriptor has been parsed up to
+	*/
+		{
+		CSBGenericTransferType::InitialiseL(aOffset);
+		
+		iTransferDataTypeOffset = aOffset;
+		TJavaTransferType transType;
+		UnpackTypeAdvance(transType, *iDataBuffer, aOffset);
+		
+		UnpackTPtrAdvance(iSuiteHash, aOffset);
+
+		// Increment the size of the data buffer
+		iDataBuffer->Des().SetLength(aOffset);
+		}
+
+	void CSBJavaTransferType::InitialiseL(TInt& aOffset, const TDesC& aSuiteHash, TDriveNumber aDriveNumber,
+										TJavaTransferType aTransferDataType)
+	/**
+	Initialise all member pointers to data
+	
+	@param aOffset The running offset of where the descriptor has been parsed up to
+	@param aSuiteHash The Java MIDlet suite hash
+	@param aSuiteVersion The version of the MIDlet suite
+	*/
+		{
+		TSBDerivedType derivedType = EJavaTransferDerivedType;
+		PackType(derivedType, *iDataBuffer, aOffset);
+		
+		CSBGenericTransferType::InitialiseL(aOffset);
+
+		// Set the derived type in the buffer
+		TDriveNumber driveNum = aDriveNumber;
+		TJavaTransferType transType = aTransferDataType;
+
+		PackType(driveNum, *iDataBuffer, iDriveNumberOffset);
+		iTransferDataTypeOffset = aOffset;
+
+		PackTypeAdvance(transType, *iDataBuffer, aOffset);
+
+		TInt ptrOffset = aOffset;
+		
+		// Pack the descriptor in raw
+		PackDescriptorTypeAdvance(aSuiteHash, aOffset);
+		
+		// Make the member TPtr point to it
+		UnpackTPtrAdvance(iSuiteHash, ptrOffset);
+		
+		// Increment the size of the data buffer
+		iDataBuffer->Des().SetLength(aOffset);
+		}
+
+	void CSBJavaTransferType::ConstructL(const TDesC& aSuiteHash, TDriveNumber aDriveNumber,
+										TJavaTransferType aTransferDataType)
+	/**
+	Symbian OS 2nd phase constructor.
+
+	@param aJavaId the Java MIDlet suite hash
+	@param aDriveNumber the drive that contains the data
+	@param aTransferDataType the type of the data you wish to transfer
+	*/
+		{
+		TInt offset = 0;
+
+		BaseConstructL();
+
+		InitialiseL(offset, aSuiteHash, aDriveNumber, aTransferDataType);
+		}
+
+	void CSBJavaTransferType::ConstructL(CSBGenericTransferType* aGenericTransferType)
+	/**
+	Symbian 2nd phase constructor. Validates the externalised type, then passes it to the base ConstructL
+
+	@param aGenericTransferType pointer to a CSBGenericTransferType object
+	*/
+		{
+		if (aGenericTransferType == NULL)
+			{
+			User::Leave(KErrArgument);
+			}
+		if (EJavaTransferDerivedType != aGenericTransferType->DerivedTypeL())
+			{
+			User::Leave(KErrArgument);
+			}
+		// Call the base class ConstructL
+		CSBGenericDataType::ConstructL(aGenericTransferType->Externalise());
+		}
+		
+	EXPORT_C const TDesC& CSBJavaTransferType::SuiteHashL() const
+	/**
+	Getter for the secure identifier
+		
+	@return  The Java MIDlet suite hash
+	*/
+		{
+		return iSuiteHash;
+		}
+
+	EXPORT_C TJavaTransferType CSBJavaTransferType::DataTypeL() const
+	/**
+	Getter for the transfer data type
+		
+	@return  The transfer data type
+	*/
+		{
+		TJavaTransferType transType;
+		
+		UnpackType(transType, *iDataBuffer, iTransferDataTypeOffset);
+
+		return transType;
+		}
+		
+		
+		
+	EXPORT_C CSBEFileEntry* CSBEFileEntry::NewLC(const TEntry& aEntry, RApaLsSession& aSession)
+	/** Constructor for creating a CSBEFileEntry from an existing TEntry (as returned
+	from RFs' directory listing mechanisms)
+	
+	@param aEntry Information about the file that this object will represent
+	@param aSession Required to map from TEntry's UID MIME type into a textual representation
+	@return Instance of CSBEFileEntry created from data supplied in aEntry
+	*/
+		{
+		CSBEFileEntry* self = new (ELeave) CSBEFileEntry(aEntry);
+		CleanupStack::PushL(self);
+		self->ConstructL(aEntry, aSession);
+		return self;
+		}
+		
+	EXPORT_C CSBEFileEntry* CSBEFileEntry::NewLC(const TDesC8& aStream, TInt& aBytesRead)
+	/** Constructor designed to internalise an instance of CSBEFileEntry from a previously 
+	ExternaliseL'd version.
+	@param aStream The descriptor containing the internalised version of this object
+	@param aBytesRead Upon return from this function, this contains the number of bytes read 
+						from the descriptor for use in streaming multiple objects from one 
+						stream
+	@return Instance of CSBEFileEntry containing the information previously packed into aStream
+	*/
+		{
+		CSBEFileEntry* self = new (ELeave) CSBEFileEntry;
+		CleanupStack::PushL(self);
+		self->InternaliseL(aStream, aBytesRead);
+		return self;
+		}
+		
+	CSBEFileEntry::CSBEFileEntry()
+	/** C++ ctor */
+		{
+		}
+
+	CSBEFileEntry::CSBEFileEntry(const TEntry& aEntry)
+	/** C++ ctor that copies out the parts of aEntry that don't require heap allocation 
+	@param aEntry The entry to copy most of the settings from
+	*/
+		: iAtt(aEntry.iAtt), iSize(aEntry.iSize), iModified(aEntry.iModified), iUidType(aEntry.iType)
+		{
+		}
+		
+	EXPORT_C CSBEFileEntry::~CSBEFileEntry()
+	/** C++ dtor */
+		{
+		delete iType;
+		delete iFilename;
+		}
+		
+	void CSBEFileEntry::ConstructL(const TEntry& aEntry, RApaLsSession& aSession)
+	/** Symbian 2nd phase constructor used when instantiating an instance from component parts
+	rather than from a previously externalised stream
+	@param aEntry Information about the file that this object will represent
+	@param aSession Required to map from TEntry's UID MIME type into a textual representation
+	*/
+		{
+		// Look up the textual mime type of the file instead of the numerical one given by TEntry
+		TUid uidForType;
+		TDataType appDataType;
+		aSession.AppForDocument(aEntry.iName,uidForType,appDataType);
+		iType = appDataType.Des().AllocL();
+		iFilename = aEntry.iName.AllocL();
+		}
+		
+	void CSBEFileEntry::InternaliseL(const TDesC8& aStream, TInt& aBytesRead)
+	/** Symbian 2nd phase constructor used when instantiating an instance from a previously 
+	externalised stream of bytes. aStream must begin at the beginning of the internalised
+	form of this object and upon return, aBytesRead will contain the number of bytes read from
+	that stream which allows multiple objects to be packed into a stream and read sequentially
+	@param aStream The stream containing at least one instance of CSBEFileEntry
+	@param aBytesRead Upon return, this will contain the number of bytes read from aStream
+						in order to internalise this single instance of CSBEFileEntry
+	*/
+		{
+		RDesReadStream stream(aStream);
+		CleanupClosePushL(stream);
+		
+		// Unpack the trivial types
+		iAtt = stream.ReadUint32L();
+		iSize = stream.ReadInt32L();
+		iModified = MAKE_TINT64(stream.ReadUint32L(), stream.ReadUint32L());
+		
+		// TUidType is a C style array
+		iUidType = TUidType(TUid::Uid(stream.ReadUint32L()),
+							TUid::Uid(stream.ReadUint32L()),
+							TUid::Uid(stream.ReadUint32L()));
+
+		// Unpack the strings
+		delete iType;
+		iType = NULL;
+		delete iFilename;
+		iFilename = NULL;
+		
+		TInt typeLength = stream.ReadUint16L();
+		iType = HBufC::NewL(typeLength);
+		TPtr typeBuf(iType->Des());
+		stream.ReadL(typeBuf, typeLength);
+		
+		TInt filenameLength = stream.ReadUint16L();
+		iFilename = HBufC::NewL(filenameLength);
+		TPtr filenameBuf(iFilename->Des());
+		stream.ReadL(filenameBuf, filenameLength);
+		
+		aBytesRead = CalculatePackedSize();
+		CleanupStack::PopAndDestroy(&stream);
+		}
+		
+	TUint16 CSBEFileEntry::CalculatePackedSize() const
+	/** calculate the size of this object when externalised
+	@return the size in bytes of the externalised representation of this object
+	*/
+		{
+		TInt total = 
+			sizeof(TUint32) +		// Length of attribute field
+			sizeof(TInt32) +		// Length of file size
+			8 +	// Length of last modified time
+			sizeof(TUidType) +	// Length of MIME type uids
+			sizeof(TUint16) + 	// Text MIME type length
+			iType->Size() +		// Text MIME type data
+			sizeof(TUint16) + 	// Filename length
+			iFilename->Size();	// Filename data
+		return total;
+		}
+
+	EXPORT_C HBufC8* CSBEFileEntry::ExternaliseLC() const
+	/** Return a pointer to a buffer descriptor containing an externalised representation of
+	the data stored by this object. The returned stream is suitable for unpacking an identical 
+	instance of this object by using the NewLC that accepts a descriptor as an argument
+	@return An externalised instance of this object suitable for Internalising
+	*/
+		{
+		TUint16 packedSize = CalculatePackedSize();
+		HBufC8* pBuf = HBufC8::NewLC(packedSize);
+		TPtr8 buf(pBuf->Des());
+		RDesWriteStream stream(buf);
+		CleanupClosePushL(stream);
+		
+		stream.WriteUint32L(iAtt);
+		stream.WriteInt32L(iSize);
+		stream.WriteUint32L(I64HIGH(iModified.Int64()));
+		stream.WriteUint32L(I64LOW(iModified.Int64()));
+		stream.WriteUint32L(iUidType[0].iUid);
+		stream.WriteUint32L(iUidType[1].iUid);
+		stream.WriteUint32L(iUidType[2].iUid);
+		stream.WriteUint16L(iType->Length());
+		stream.WriteL(*iType);
+		stream.WriteUint16L(iFilename->Length());
+		stream.WriteL(*iFilename);
+		
+		CleanupStack::PopAndDestroy(&stream);
+		return pBuf;
+		}
+		
+	EXPORT_C TUint CSBEFileEntry::FileAttributes() const
+	/** Accessor function returning the packed bitmask representing the attributes
+	of the file that this object represents in the format defined by TEntry
+	@return Packed bits representing the file attributes of the file represented by this object
+	@see TEntry::iAtt
+	*/
+		{
+		return iAtt;
+		}
+		
+	EXPORT_C TInt CSBEFileEntry::FileSize() const
+	/** Accessor function returning the size in bytes of the file represented by this 
+	object
+	@return Size in bytes of the file represented by this object
+	@see TEntry::iSize
+	*/
+		{
+		return iSize;
+		}
+		
+	EXPORT_C TTime CSBEFileEntry::LastModified() const
+	/** Accessor function returning the time that the file represented by this object#
+	was last modified
+	@return Time of last modification of this file
+	@see TEntry::iModified
+	*/
+		{
+		return iModified;
+		}
+		
+	EXPORT_C TDesC16& CSBEFileEntry::Filename() const
+	/** Accessor function returning the path an name of the file represented by this object.
+	@return Filename including path of the file represented by this object
+	@see TEntry::iName
+	*/
+		{
+		return *iFilename;
+		}
+		
+	EXPORT_C TDesC16& CSBEFileEntry::MIMEType() const
+	/** Accessor function returning a textual representation of the MIME type
+	of the file represented by this object.
+	@return textual representation of the MIME type	of the file represented by this object
+	*/
+		{
+		return *iType;
+		}
+		
+	EXPORT_C TUidType& CSBEFileEntry::MIMEUid()
+	/** Accessor function returning the UID of the MIME type of the file represented 
+	by this object.
+	@return textual representation of the MIME type	of the file represented by this object
+	@see TEntry::iType
+	*/
+		{
+		return iUidType;
+		}
+		
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/ABTester/group/abtestclient.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+@file
+
+@SYMPurpose ABTESTCLIENT.EXE Connect BAL Server
+*/
+
+#include "abtester.mmh"
+
+TARGET abtestclient.exe
+#ifdef EKA2
+	TARGETTYPE EXE
+#else
+	TARGETTYPE EPOCEXE
+#endif
+UID 0 0x0AB7E57C	// Assigned UID
+VENDORID 0x70000001
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+USERINCLUDE ../inc
+SOURCEPATH ../src
+SOURCE abdataowner.cpp
+SOURCE abtesterlog.cpp
+LIBRARY euser.lib abclient.lib
+
+#ifdef __ABT_DISABLE_RELEASE_LOGGING
+
+    // Flogger will not be linked do this binary in UREL builds
+    DEBUGLIBRARY flogger.lib
+
+#else
+
+    // Flogger always statically linked to this binary.
+    LIBRARY flogger.lib
+
+#endif
+ 
+CAPABILITY All -TCB
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/ABTester/group/abtestclient2.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+@file
+
+@SYMPurpose ABTESTCLIENT.EXE Connect BAL Server
+*/
+
+#include "abtester.mmh"
+
+TARGET abtestclient2.exe
+#ifdef EKA2
+	TARGETTYPE EXE
+#else
+	TARGETTYPE EPOCEXE
+#endif
+UID 0 0x0AB7E57E	// Assigned UID
+VENDORID 0x70000001
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+USERINCLUDE ../inc
+SOURCEPATH ../src
+SOURCE abdataowner.cpp
+SOURCE abtesterlog.cpp
+LIBRARY euser.lib abclient.lib
+
+#ifdef __ABT_DISABLE_RELEASE_LOGGING
+
+    // Flogger will not be linked do this binary in UREL builds
+    DEBUGLIBRARY flogger.lib
+
+#else
+
+    // Flogger always statically linked to this binary.
+    LIBRARY flogger.lib
+
+#endif
+
+CAPABILITY All -TCB
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/ABTester/group/abtestclient3.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+@file
+
+@SYMPurpose ABTESTCLIENT.EXE Connect BAL Server
+*/
+
+#include "abtester.mmh"
+
+TARGET abtestclient3.exe
+#ifdef EKA2
+	TARGETTYPE EXE
+#else
+	TARGETTYPE EPOCEXE
+#endif
+UID 0 0x0AB7E58A	// Assigned UID
+VENDORID 0x70000001
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+USERINCLUDE ../inc
+SOURCEPATH ../src
+SOURCE abdataowner.cpp
+SOURCE abtesterlog.cpp
+LIBRARY euser.lib abclient.lib
+
+#ifdef __ABT_DISABLE_RELEASE_LOGGING
+
+    // Flogger will not be linked do this binary in UREL builds
+    DEBUGLIBRARY flogger.lib
+
+#else
+
+    // Flogger always statically linked to this binary.
+    LIBRARY flogger.lib
+
+#endif
+
+CAPABILITY All -TCB
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/ABTester/group/abtestclient4.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+@file
+
+@SYMPurpose ABTESTCLIENT.EXE Connect BAL Server
+*/
+
+#include "abtester.mmh"
+
+TARGET abtestclient4.exe
+#ifdef EKA2
+	TARGETTYPE EXE
+#else
+	TARGETTYPE EPOCEXE
+#endif
+UID 0 0x0AB7E58B	// Assigned UID
+VENDORID 0x70000001
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+USERINCLUDE ../inc
+SOURCEPATH ../src
+SOURCE abdataowner.cpp
+SOURCE abtesterlog.cpp
+LIBRARY euser.lib abclient.lib
+
+#ifdef __ABT_DISABLE_RELEASE_LOGGING
+
+    // Flogger will not be linked do this binary in UREL builds
+    DEBUGLIBRARY flogger.lib
+
+#else
+
+    // Flogger always statically linked to this binary.
+    LIBRARY flogger.lib
+
+#endif
+
+CAPABILITY All -TCB
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/ABTester/group/abtester.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -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 __ABTESTER_IBY__
+#define __ABTESTER_IBY__
+
+file=ABI_DIR\BUILD_DIR\abtestclient.EXE	    		System\programs\abtestclient.EXE
+file=ABI_DIR\BUILD_DIR\abtestclient2.EXE	    	System\programs\abtestclient2.EXE
+file=ABI_DIR\BUILD_DIR\abtestclient3.EXE	    	System\programs\abtestclient3.EXE
+file=ABI_DIR\BUILD_DIR\abtestclient4.EXE	    	System\programs\abtestclient4.EXE
+
+data=DATAZ_\private\0AB7E57C\backup_registration.xml  private\0AB7E57C\backup_registration.xml
+data=DATAZ_\private\0AB7E57D\backup_registration.xml  private\0AB7E57D\backup_registration.xml
+data=DATAZ_\private\0AB7E57E\backup_registration.xml  private\0AB7E57E\backup_registration.xml
+data=DATAZ_\private\0AB7E58A\backup_registration.xml  private\0AB7E58A\backup_registration.xml
+data=DATAZ_\private\0AB7E58B\backup_registration.xml  private\0AB7E58B\backup_registration.xml
+data=DATAZ_\private\0AB7E58C\backup_registration.xml  private\0AB7E58C\backup_registration.xml
+
+data=DATAZ_\private\0FA00001\backup_registration.xml  private\0FA00001\backup_registration.xml
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/ABTester/group/abtester.mmh	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,59 @@
+// 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:
+// ABTester MMP Configuration Header File
+// 
+//
+
+/**
+ @file
+*/
+
+#ifndef __ABTESTER_MMH__
+#define __ABTESTER_MMH__
+
+
+/** By default, the SBE logs only in DEBUG builds. If you want
+ both release and debug logging, then comment this line out */
+#define __SBE_DISABLE_RELEASE_LOGGING
+
+
+#if defined(__ABT_DISABLE_RELEASE_LOGGING)
+    
+    MACRO ABT_LOGGING_DEBUG_ONLY
+
+#else
+
+    MACRO ABT_LOGGING_DEBUG_AND_RELEASE
+
+#endif
+
+
+/** The following macros are used (when logging is enabled) to
+ configure the type of logging to perform */
+
+
+/** Uncomment this line to enable FLOGGER (File) logging */
+MACRO ABT_LOGGING_METHOD_FLOGGER
+
+/** Uncomment this line to enable RDEBUG logging */
+//MACRO ABT_LOGGING_METHOD_RDEBUG
+
+/** Uncomment this line to enable UI (User::InfoPrint) logging. This
+ can cause UI deadlock in some UI systems. */
+//MACRO ABT_LOGGING_METHOD_UI
+
+
+
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/ABTester/group/abtester.oby	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#ifndef __ABTESTER_OBY__
+#define __ABTESTER_OBY__
+
+#include <ABTester.iby>
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/ABTester/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+@file
+
+@SYMPurpose Secure Backup Engine
+*/
+
+PRJ_MMPFILES
+abtestclient.mmp
+abtestclient2.mmp
+abtestclient3.mmp
+abtestclient4.mmp
+
+PRJ_TESTMMPFILES
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+   ./abtester.oby		/epoc32/rom/include/abtester.oby
+   ./abtester.iby		/epoc32/rom/include/abtester.iby
+
+   ../data/incremental_active_backup_registration.xml   z:/private/0AB7E57C/backup_registration.xml
+   ../data/proxy_active_backup_registration.xml         z:/private/0AB7E57D/backup_registration.xml
+   ../data/base_active_backup_registration.xml          z:/private/0AB7E57E/backup_registration.xml
+   ../data/base_active_backup_registration2.xml         z:/private/0AB7E58A/backup_registration.xml
+   ../data/base_active_backup_registration3.xml         z:/private/0AB7E58B/backup_registration.xml
+   ../data/passive_backup_registration.xml              z:/private/0AB7E58C/backup_registration.xml
+   ../data/backup_public_files_registration.xml         z:/private/0FA00001/backup_registration.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/ABTester/inc/abdataowner.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,184 @@
+// 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
+
+ABTester is both a client of the SBEngine and ABServer only for test purposes
+*/
+
+#ifndef __ABDATAOWNER_H__
+#define __ABDATAOWNER_H__
+
+#include <connect/abclient.h>
+#include <e32std.h>
+#include <e32property.h>
+
+void RunActiveBackupClientL();
+
+namespace conn
+	{
+	//TUid KSBEngineUid = TUid::Uid(0x10202D56);
+
+	class CABTester;
+
+	// The simulated file that this test DO will backup/have restored
+	_LIT8(KABTestData, "Active Backup Test Base Data");
+
+	// The simulated file that this test DO will backup/have restored
+	_LIT8(KABTestProxyData, "Active Backup Test Proxy Data");
+
+	// The simulated file that this test DO will backup/have restored
+	_LIT8(KABTestDataIncrement, ":Active Backup Test Increment Data");
+	
+	// The simulated snapshot that this tets DO will backup/use to restore
+	_LIT8(KABTestSnapshot, "Active Backup Test Snapshot");
+	
+	// Simulated time for initialisation of the ABDO
+	const TInt KABInitTime = 5000;
+	
+	class CABData : public CBase
+		{
+	public:
+		static CABData* NewL(TDriveNumber aDriveNum)
+			{
+			CABData* self = new (ELeave) CABData(aDriveNum);
+			return self;
+			}
+			
+		void AddDataL(TDesC8& aData)
+			{
+			if (!iData)
+				{
+				iData = HBufC8::NewL(aData.Size());
+				}
+			else
+				{
+				// Add the data to the existing buffer
+				iData = iData->ReAllocL(iData->Size() + aData.Size());
+				}
+				
+			iData->Des().Append(aData);
+			}
+			
+		TDesC8& operator()()
+			{
+			return *iData;
+			}
+
+		~CABData()
+			{
+			delete iData;
+			}
+
+	private:		
+		CABData(TDriveNumber aDriveNum) : iDriveNum(aDriveNum)	{}
+
+	private:
+		HBufC8* iData;
+		TDriveNumber iDriveNum;
+		};
+
+
+
+	/**
+	This class implements the callbacks defined by MActiveBackupDataClient which are used by the SBEngine 
+	to request information about the backup or restore operation for this data owner
+	*/		
+	class CABDataOwnerCallbackImplementation : public CBase, public MActiveBackupDataClient
+		{
+	public:
+		static CABDataOwnerCallbackImplementation* NewL(TSecureId aID);
+		~CABDataOwnerCallbackImplementation();
+		TBool ValidateRestoredData();
+		TBool ValidateRestoredSnapshot();
+		
+	// MActiveBackupDataClient implementation
+		void AllSnapshotsSuppliedL();
+		void ReceiveSnapshotDataL(TDriveNumber aDrive, TDesC8& aBuffer, TBool aLastSection);
+		TUint GetExpectedDataSize(TDriveNumber aDrive);
+		void GetSnapshotDataL(TDriveNumber aDrive, TPtr8& aBuffer, TBool& aFinished);
+		void InitialiseGetBackupDataL(TDriveNumber aDrive);
+		void GetBackupDataSectionL(TPtr8& aBuffer, TBool& aFinished);
+		void InitialiseRestoreBaseDataL(TDriveNumber aDrive);
+		void RestoreBaseDataSectionL(TDesC8& aBuffer, TBool aFinished);
+		void InitialiseRestoreIncrementDataL(TDriveNumber aDrive);
+		void RestoreIncrementDataSectionL(TDesC8& aBuffer, TBool aFinished);
+		void RestoreComplete(TDriveNumber aDrive);
+		void TerminateMultiStageOperation();
+		TUint GetDataChecksum(TDriveNumber aDrive);
+		void SetABClient(CActiveBackupClient* aABClient);
+		void InitialiseGetProxyBackupDataL(TSecureId aSID, TDriveNumber aDrive);
+		void InitialiseRestoreProxyBaseDataL(TSecureId aSID, TDriveNumber aDrive);
+		
+	private:
+		CABDataOwnerCallbackImplementation(TSecureId aID);
+
+		void WaitForMillisecondsL(TInt aMilliseconds);
+		void FillBuffer(TDes8& aDes, TBool& aFinished);
+		
+	private:
+		CActiveBackupClient* iABClient;
+		TBackupIncType iBackupIncType;
+		TVersion iVersion;
+		CABData* iSnapshot;
+		CABData* iData;
+		TBool iProxy;
+		TInt iOffset;
+		TInt iSourceSize;
+		TUint iFillChar;
+		TSecureId iID;
+		};
+
+
+	/**
+	This class is the actual data owner that prepares data to send to the sbengine. It owns the CABClient 
+	and passes in the callback interface implementation object
+	*/	
+	class CABDataOwner : public CActive
+		{
+		
+	public:
+		static CABDataOwner* NewL();
+		void StartL();
+		void RunL();
+		TInt RunError(TInt aError);
+		void DoCancel();
+		~CABDataOwner();
+
+	private:
+		void CheckStatusL();
+		CABDataOwner() : CActive(EPriorityNormal) {}
+		
+		void ConstructL();
+		void Subscribe();
+	
+	private:
+		/** P&S */
+		RProperty iProperty;
+		
+		/** Callback implementation */
+		CActiveBackupClient* iABClient;
+		
+		/** Callback implementation */
+		CABDataOwnerCallbackImplementation* iCallback;
+		
+		/** Secure ID of the process */
+		TSecureId iID;
+		};
+	
+	}
+
+#endif //__ABDATAOWNER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/ABTester/inc/abtester.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,101 @@
+// 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
+
+ABTester is both a client of the SBEngine and ABServer only for test purposes
+*/
+
+#ifndef __ABTESTER_H__
+#define __ABTESTER_H__
+
+#include <sbeclient.h>
+#include <abclient.h>
+
+namespace conn
+	{
+	class CABDataOwner;
+	class CABData;
+	
+	const TInt KABTestABSID = 0x0AB7E57E;
+	_LIT(KABTestPanicText, "ABTester");
+	
+	enum TABTestStep
+		{
+		EABGetListOfDataOwners,
+		EABSetBackupMode,
+		EABSetBaseBackupOwners,
+		EABGetExpectedDataSize,
+		EABGetBackupRegFile,
+		EABGetABDOState,
+		EABGetActiveSnapshot,
+		EABGetActiveData,
+		EABSetNormalMode,
+		EABSetRestoreMode,
+		EABSupplyRegData,
+		EABSupplyActiveSnapshot,
+		EABSupplyActiveData
+		};
+	
+	/**
+	This class owns the SBEClient and also owns the test ABClient
+	
+	It's responsible for running the test steps and storing the results
+	*/
+	class CABTester : public CActive
+		{
+	public:
+		static CABTester* NewLC();
+		void Run();
+		~CABTester();
+		
+	// CActive
+	protected:
+		void DoCancel();
+		void RunL();
+		TInt RunError(TInt aError);
+	
+	private:
+		CABTester() : CActive(EPriorityNormal), iSBEClient(NULL), iStepNumber(0), 
+			iABSID(KABTestABSID), iTestDOI(NULL), iTestDOISID(NULL), iBackupRegFile(NULL),
+			iActiveSnapshot(NULL), iActiveData(NULL), iABDOStatus(EUnset)
+			{}
+		void ConstructL();
+		
+	// The test steps
+		void InitTestStepArray();
+		void DoTestStepL(TABTestStep aStepId);
+		void StepGetListOfDataOwnersL();
+		void StepSetBaseBackupOwnersL();
+		void Pass();
+		void Fail(TInt aCode = KErrAbort);
+		void GetABDOStateL();
+
+	private:
+		CSBEClient* iSBEClient;
+		RArray<TABTestStep> iTestSteps;
+		TInt iStepNumber;
+		TSecureId iABSID;
+		CDataOwnerInfo* iTestDOI;
+		CSBSecureId* iTestDOISID;
+		HBufC8* iBackupRegFile;
+		HBufC8* iActiveSnapshot;
+		HBufC8* iActiveData;
+		TDataOwnerStatus iABDOStatus;
+		};
+	}
+
+#endif //__ABTESTER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/ABTester/inc/abtesterlog.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,118 @@
+/**
+* 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:
+* Logging utilities
+* 
+*
+*/
+
+
+
+/**
+ @file
+*/
+
+#ifndef __ABTESTERLOG_H__
+#define __ABTESTERLOG_H__
+
+#ifndef __FLOGGER_H__
+#include <flogger.h>
+#endif
+
+#ifndef __E32STD_H__
+#include <e32std.h>
+#endif
+
+namespace conn
+	{
+    /**
+    @defgroup Log Log
+
+    This module implements logging utilities. Information is currently
+    logged via flogger, but this can be easily changed as logging is
+    hidden by global macros.
+
+    The log control macros allow enabling or disabling of the following
+    type of logging:-
+
+    @li UI logging (a message is displayed top right of the screen) see
+    __DISPLAY_LOG_MESSAGES.
+
+    @li flogger logging (a message is displayed in the flogger log file) see
+    __DISPLAY_FLOG_MESSAGES.
+
+    A nested namespace, SBServerLog, contains the class and global function that
+    performs the logging operations: TLog, OpenLog(), CloseLog() and TLog
+    operator() - which accepts a variable number of arguments. There is
+    macro for each of these functions.
+
+    OpenLog() and CloseLog() must be called only once and this is done by
+    MainL().
+    */ 
+    
+	/** LOG CONTROL MACROS */
+
+    /** @{ */
+	
+	#if (defined(ABT_LOGGING_DEBUG_ONLY) && defined(_DEBUG)) || defined(ABT_LOGGING_DEBUG_AND_RELEASE)
+
+        #define ABT_LOGGING_ENABLED
+		
+		namespace ABTesterLog
+    	/**
+    	@ingroup Log
+        	This namespace hides the internal of logging from the rest of the system.
+	    */
+    	    {
+			void __Log(TRefByValue<const TDesC> aFmt,...);	
+	    	}//ABTesterLog
+	    	
+	    /** Logs a message */
+		#define __LOG(TXT) {_LIT(__KText,TXT); ABTesterLog::__Log(__KText);}	
+
+	    /** Logs a message plus an additional value. The text must
+	     contain an appropriate printf alike indication, e.g. %d if the additional
+	    value is an integer. */
+	    #define __LOG1(TXT, A) {_LIT(__KText,TXT); ABTesterLog::__Log(__KText, A);}	
+
+	    /** Logs a message plus two additional values. The text must
+	     contain two appropriate printf alike indications.*/
+	    #define __LOG2(TXT, A, B) {_LIT(__KText,TXT); ABTesterLog::__Log(__KText, A, B);}
+	    
+	    /** Logs a message plus two additional values. The text must
+	     contain two appropriate printf alike indications.*/
+	    #define __LOG3(TXT, A, B, C) {_LIT(__KText,TXT); ABTesterLog::__Log(__KText, A, B, C);}	
+
+		
+		/** Log Utility macro. 
+		Executes the function specified under a trap and if the
+		error code is not KErrNone logs the message specified before
+		leaving. Note that the message must have a '%d' in it!*/
+		#define __EXECLOGL(F, STR) 	TRAPD(__r, F);\
+			if (__r != KErrNone) { __LOG1(STR, __r); User::Leave(__r); }
+			
+	#else
+		
+		#define __LOG(TXT)
+        #define __LOG1(TXT, A)
+        #define __LOG2(TXT, A, B)
+        #define __LOG3(TXT, A, B, C )
+        
+	#endif
+    /** @} */
+
+	
+	}//conn
+		
+#endif //__SBSSLOG_H__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/ABTester/src/abdataowner.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,443 @@
+// 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
+
+CABDataOwnerCallbackImplementation implementation
+*/
+
+#include "abdataowner.h"
+#include "abtesterlog.h"
+#include <connect/sbdefs.h>
+
+namespace conn
+	{
+	const TInt KSourceSize = 8000;
+	
+	CABDataOwnerCallbackImplementation* CABDataOwnerCallbackImplementation::NewL(TSecureId aID)
+		{
+		CABDataOwnerCallbackImplementation* self = new (ELeave) CABDataOwnerCallbackImplementation(aID);
+		//CleanupStack::PushL(self);
+		//self->ConstructL();
+		//CleanupStack::Pop(self);
+		return self;
+		}
+		
+	
+		
+	CABDataOwnerCallbackImplementation::CABDataOwnerCallbackImplementation(TSecureId aID) : iABClient(NULL), iVersion(1,0,0), iProxy(EFalse), iSourceSize(KSourceSize), iID(aID)
+		{
+		}	
+		
+	void CABDataOwnerCallbackImplementation::SetABClient(CActiveBackupClient* aABClient)
+		{
+		iABClient = aABClient;
+		}
+		
+	CABDataOwnerCallbackImplementation::~CABDataOwnerCallbackImplementation()
+		{
+		delete iABClient;
+		delete iSnapshot;
+		delete iData;
+		}
+		
+	// from MActiveBackupDataClient - callbacks
+	void CABDataOwnerCallbackImplementation::AllSnapshotsSuppliedL()
+		{
+		__LOG1("[0x%08x]: CABDataOwnerCallbackImplementation::AllSnapshotsSuppliedL()", iID.iId);
+		}
+		
+	void CABDataOwnerCallbackImplementation::ReceiveSnapshotDataL(TDriveNumber aDrive, TDesC8& aBuffer, TBool /*aLastSection*/)
+		{
+		__LOG1("[0x%08x]: CABDataOwnerCallbackImplementation::ReceiveSnapshotDataL()", iID.iId);
+		// Create or append a buffer containing the snapshot
+		if (!iSnapshot)
+			{
+			iSnapshot = CABData::NewL(aDrive);
+			}
+
+		iSnapshot->AddDataL(aBuffer);
+		}
+		
+	TUint CABDataOwnerCallbackImplementation::GetExpectedDataSize(TDriveNumber /*aDrive*/)
+		{
+		__LOG1("[0x%08x]: CABDataOwnerCallbackImplementation::GetExpectedDataSize()", iID.iId);
+			
+		return iSourceSize;
+		}
+		
+	void CABDataOwnerCallbackImplementation::GetSnapshotDataL(TDriveNumber /*aDrive*/, TPtr8& aBuffer, TBool& aFinished)
+		{
+		__LOG1("[0x%08x]: CABDataOwnerCallbackImplementation::GetSnapshotDataL()", iID.iId);
+		aBuffer.Append(KABTestSnapshot());
+		
+		aFinished = ETrue;
+		}
+		
+	void CABDataOwnerCallbackImplementation::InitialiseGetBackupDataL(TDriveNumber /*aDrive*/)
+		{
+		__LOG1("[0x%08x]: CABDataOwnerCallbackImplementation::InitialiseGetBackupData()", iID.iId);
+		iOffset = 0;
+
+		if (!iSnapshot)
+			{
+			iFillChar = 66;
+			}
+		else
+			{
+			iFillChar = 73;
+			}
+		}
+		
+	void CABDataOwnerCallbackImplementation::GetBackupDataSectionL(TPtr8& aBuffer, TBool& aFinished)
+		{
+		__LOG1("[0x%08x]: CABDataOwnerCallbackImplementation::GetBackupDataSectionL()", iID.iId);
+		
+		FillBuffer(aBuffer, aFinished);
+		}
+		
+	void CABDataOwnerCallbackImplementation::InitialiseRestoreBaseDataL(TDriveNumber aDrive)
+		{
+		__LOG("CABDataOwnerCallbackImplementation::InitialiseRestoreBaseDataL()");
+//		WaitForMillisecondsL(KABInitTime);
+
+		iData = CABData::NewL(aDrive);
+		}
+		
+	void CABDataOwnerCallbackImplementation::RestoreBaseDataSectionL(TDesC8& aBuffer, TBool aFinished)
+		{
+		__LOG1("[0x%08x]: CABDataOwnerCallbackImplementation::RestoreBaseDataSectionL()", iID.iId);
+
+		// append a buffer containing the base data
+		iData->AddDataL(aBuffer);
+		
+		if (aFinished)
+			{
+			ValidateRestoredData();
+		
+			delete iData;
+			iData = NULL;
+			}
+		}
+		
+	void CABDataOwnerCallbackImplementation::InitialiseRestoreIncrementDataL(TDriveNumber aDrive)
+		{
+		__LOG1("[0x%08x]: CABDataOwnerCallbackImplementation::InitialiseRestoreIncrementDataL()", iID.iId);
+		if (!iSnapshot)
+			{
+			User::Leave(KErrCorrupt);
+			}
+
+		if (!iData)
+			{
+			iData = CABData::NewL(aDrive);
+			}
+		}
+		
+	void CABDataOwnerCallbackImplementation::RestoreIncrementDataSectionL(TDesC8& aBuffer, TBool aFinished)
+		{
+		__LOG1("[0x%08x]: CABDataOwnerCallbackImplementation::RestoreIncrementDataSectionL()", iID.iId);
+
+		iData->AddDataL(aBuffer);
+		
+		if (aFinished)
+			{
+			ValidateRestoredData();
+		
+			delete iData;
+			iData = NULL;
+			}
+		}
+		
+	void CABDataOwnerCallbackImplementation::RestoreComplete(TDriveNumber /*aDrive*/)
+		{
+		__LOG1("[0x%08x]: CABDataOwnerCallbackImplementation::RestoreComplete()", iID.iId);
+		}
+		
+	void CABDataOwnerCallbackImplementation::TerminateMultiStageOperation()
+		{
+		__LOG1("[0x%08x]: CABDataOwnerCallbackImplementation::TerminateMultiStageOperation()", iID.iId);
+		// We also don't do anything here until we start testing multipart?
+		}
+		
+	TUint CABDataOwnerCallbackImplementation::GetDataChecksum(TDriveNumber /*aDrive*/)
+		{
+		__LOG1("[0x%08x]: CABDataOwnerCallbackImplementation::GetDataChecksum()", iID.iId);
+		return 0;
+		}
+
+	void CABDataOwnerCallbackImplementation::WaitForMillisecondsL(TInt aMilliseconds)
+		{
+		RTimer timer;
+		TRequestStatus status;
+		
+		User::LeaveIfError(timer.CreateLocal());
+		
+		timer.After(status, aMilliseconds);
+		User::WaitForRequest(status);
+		}
+
+	TBool CABDataOwnerCallbackImplementation::ValidateRestoredData()
+		{
+		TBool result = ETrue;
+
+		__LOG3("[0x%08x]: Received data : %d %c's", iID.iId, (*iData)().Size(), (*iData)()[0]);
+
+		return result;
+		}
+		
+	TBool CABDataOwnerCallbackImplementation::ValidateRestoredSnapshot()
+		{
+		TBool result = ETrue;
+		
+		if ((*iSnapshot)() != KABTestSnapshot())
+			{
+			__LOG1("[0x%08x]: Snapshot was NOT received correctly", iID.iId);
+			result = EFalse;
+			}
+		else
+			{
+			__LOG1("[0x%08x]: Snapshot was received correctly", iID.iId);
+			}
+			
+		return result;
+		}
+		
+	void CABDataOwnerCallbackImplementation::InitialiseGetProxyBackupDataL(TSecureId aSID, TDriveNumber /*aDrive*/)
+		{
+		__LOG1("[0x%08x]: CABDataOwnerCallbackImplementation::InitialiseGetProxyBackupDataL()", iID.iId);
+		__LOG2("[0x%08x]: Proxy data about to be requested for SID 0x%08x", iID.iId, aSID.iId);
+		iProxy = ETrue;
+		iOffset = 0;
+		
+		iFillChar = 80;		// 'P'
+		}
+
+	void CABDataOwnerCallbackImplementation::InitialiseRestoreProxyBaseDataL(TSecureId aSID, TDriveNumber aDrive)
+		{
+		__LOG1("[0x%08x]: CABDataOwnerCallbackImplementation::InitialiseRestoreProxyBaseDataL()", iID.iId);
+		__LOG2("[0x%08x]: Proxy data about to be restored for SID 0x%08x", iID.iId, aSID.iId);
+		iProxy = ETrue;
+		iData = CABData::NewL(aDrive);
+		}
+		
+	void CABDataOwnerCallbackImplementation::FillBuffer(TDes8& aDes, TBool& aFinished)
+		{
+		TInt bytesToAdd;
+		TChar fillChar(iFillChar);
+		
+		if ((iOffset + aDes.MaxSize()) < iSourceSize)
+			{
+			aFinished = EFalse;
+			bytesToAdd = aDes.MaxSize();
+			}
+		else
+			{
+			aFinished = ETrue;
+			bytesToAdd = iSourceSize - iOffset;
+			}
+
+		aDes.Fill(fillChar, bytesToAdd);
+
+		iOffset += bytesToAdd;
+		}
+
+
+
+
+
+
+	CABDataOwner* CABDataOwner::NewL()
+		{
+		CABDataOwner* self = new (ELeave) CABDataOwner;
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		CleanupStack::Pop(self);
+		return self;
+		}
+			
+	void CABDataOwner::StartL()
+		{
+		CActiveScheduler::Add(this);
+		Subscribe();
+		CActiveScheduler::Start();
+		}
+
+	void CABDataOwner::RunL()
+		{
+		if (iStatus == KErrNone)
+			{
+			__LOG1("[0x%08x]: ABTester RunL", iID.iId);				
+			Subscribe();
+			CheckStatusL();
+			}
+		else
+			{
+			__LOG2("[0x%08x]: RunL leaves with code %d", iID.iId, iStatus.Int());
+			User::Leave(iStatus.Int());
+			}
+		}
+		
+	void CABDataOwner::Subscribe()
+		{
+		__LOG1("[0x%08x]: Subscibe", iID.iId);
+		iProperty.Subscribe(iStatus);	// Wait until SBE tells us that we're in normal mode again
+		SetActive();
+		}
+	
+	TInt CABDataOwner::RunError(TInt aError)
+		{
+		__LOG2("ABDataOwner [0x%08x] Panic'd with error code %d", iID.iId, aError);
+		
+		Subscribe();
+		
+		return KErrNone;
+		}
+		
+	void CABDataOwner::CheckStatusL()
+		{
+		TInt backupInfo =0;
+		iProperty.Get(backupInfo);
+		__LOG1("[0x%08x]: CABDataOwner::CheckStatus", iID.iId);
+		if ((backupInfo & KBURPartTypeMask) == EBURNormal || (backupInfo & KBURPartTypeMask) == EBURUnset)
+			{
+			delete iABClient;
+			iABClient = NULL;
+			__LOG2("[0x%08x]: Backup Mode Normal or Unset, deleting client", iID.iId, backupInfo);
+			}
+		else 
+			{
+			if (iABClient == NULL)
+				{
+				iABClient = CActiveBackupClient::NewL(iCallback);
+				iCallback->SetABClient(iABClient);
+				// do nothing
+				__LOG1("[0x%08x]: In Backup/Restore: ConfirmReadyForBUR", iID.iId);
+				}
+			
+			TDriveList driveList;
+			TBURPartType partType;
+			TBackupIncType incType;
+			TInt err;
+			TRAP(err, iABClient->BURModeInfoL(driveList, partType, incType));
+			if (err != KErrNone)
+				{
+				__LOG2("[0x%08x]: BURModeInfoL error %d", iID.iId, err);
+				}
+			
+			TBool amIaffected = ETrue;
+			
+			if (partType == EBURRestorePartial || partType == EBURBackupPartial)
+				{
+				TRAP(err, amIaffected = iABClient->DoesPartialBURAffectMeL());
+				if (err == KErrNone)
+					{
+					if (amIaffected)
+						{
+						__LOG1("[0x%08x]: RunL: Partial Affects me!", iID.iId);
+						}
+					else 
+						{
+						__LOG1("[0x%08x]: RunL: Partial Does NOT Affect me!", iID.iId);
+						}
+					}
+				else 
+					{
+					__LOG2("[0x%08x]: Error calling DoesPartialBURAffectMeL()", iID.iId, err);
+					
+					User::After(5000000);
+					TRAP(err, amIaffected = iABClient->DoesPartialBURAffectMeL());
+					__LOG2("[0x%08x]: Called DoesPartialBURAffectMeL() again after 5sec: ", iID.iId, err);
+					}
+				}
+			
+			if (amIaffected)
+				{
+				// Confirm that this data owner is ready for backup/restore operations
+				iABClient->ConfirmReadyForBURL(KErrNone);
+				}
+			}
+		}
+
+	void CABDataOwner::DoCancel()
+		{
+		}
+		
+	CABDataOwner::~CABDataOwner()
+		{
+		if (IsActive())
+			{
+			Cancel();
+			}
+		delete iCallback;
+		delete iABClient;
+		}
+
+	void CABDataOwner::ConstructL()
+		{
+		RProcess process;
+		iID = process.SecureId();
+		process.Close();
+		iABClient = NULL;
+		
+		iCallback = CABDataOwnerCallbackImplementation::NewL(iID);
+		
+		iProperty.Attach(TUid::Uid(KUidSystemCategoryValue), KUidBackupRestoreKey);
+		TInt backupInfo = 0;
+		iProperty.Get(backupInfo);
+		if ((backupInfo & KBURPartTypeMask) != EBURNormal || (backupInfo & KBURPartTypeMask) != EBURUnset)
+			{
+			iABClient = CActiveBackupClient::NewL(iCallback);
+			iCallback->SetABClient(iABClient);
+				
+			// Confirm that this data owner is ready for backup/restore operations
+			iABClient->ConfirmReadyForBURL(KErrNone);
+			// do nothing
+			__LOG1("[0x%08x]: In Backup/Restore: ConfirmReadyForBUR", iID.iId);
+			}
+		__LOG1("[0x%08x]: ABTester ConstructL", iID.iId);
+		}
+	}
+				
+void RunActiveBackupClientL()
+	{
+    CActiveScheduler* pScheduler = new (ELeave) CActiveScheduler();
+	CleanupStack::PushL(pScheduler);
+	CActiveScheduler::Install(pScheduler);
+	conn::CABDataOwner* pDO = conn::CABDataOwner::NewL();
+	CleanupStack::PushL(pDO);
+
+	pDO->StartL();
+	
+	CleanupStack::PopAndDestroy(pDO);
+	CleanupStack::PopAndDestroy(pScheduler);
+	}
+
+TInt E32Main()
+	{
+	__UHEAP_MARK;
+	CTrapCleanup* pCleanup = CTrapCleanup::New();
+	TInt nRet = KErrNone;
+
+	if(pCleanup != NULL)
+		{
+		TRAP(nRet, RunActiveBackupClientL());
+	    delete pCleanup;
+	    }
+
+    __UHEAP_MARKEND;
+    return nRet;	
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/ABTester/src/abtesterlog.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,79 @@
+// 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:
+// Logging utilities
+// 
+//
+
+/**
+ @file
+*/
+#include "abtesterlog.h"
+
+namespace conn
+	{
+	
+	namespace ABTesterLog 
+		{
+		#if (defined(ABT_LOGGING_DEBUG_ONLY) && defined(_DEBUG)) || defined(ABT_LOGGING_DEBUG_AND_RELEASE)
+		
+        /** The flogger subsystem name 
+		@internalComponent*/    
+		_LIT(KLogDirectory,"connect");
+
+		/** The component name 
+		@internalComponent*/
+        _LIT(KLogComponentName, "ABTestClient.txt");
+
+        /** The maximum length of text that can be logged 
+		@internalComponent*/                
+		const TInt KMaxLogText = 0x100;
+			
+		
+		void __Log(TRefByValue<const TDesC> aFmt,...)	
+	 	/**	Logs a message to FLOGGER and to the UI depending on
+	 	controlling macros.
+	 	
+	 	Note that FLOG macros are probably disabled in release builds, 
+	 	so we might need to use something else for logging to files
+		@internalComponent
+	 	@param aFmt Buffer for logging
+	 	*/
+			{
+			VA_LIST list;
+		    VA_START(list,aFmt);
+		    
+		    TBuf<KMaxLogText> buf;
+		    buf.FormatList(aFmt,list);   
+		    
+		#if defined(ABT_LOGGING_METHOD_FLOGGER)   
+			RFileLogger::Write(KLogDirectory,KLogComponentName, EFileLoggingModeAppend,buf);
+		#endif    
+		    
+		#if defined(ABT_LOGGING_METHOD_RDEBUG) || defined(ABT_LOGGING_METHOD_UI)
+            
+        	
+            aData.Insert( 0, KLogComponentName );
+
+            #if defined( ABT_LOGGING_METHOD_UI )
+                User::InfoPrint( buf );
+            #endif
+        	#if defined( SBE_LOGGING_METHOD_RDEBUG )
+            	RDebug::Print( buf );
+        	#endif
+    	#endif
+			}
+		}
+		#endif
+	}
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/burtestserver/Group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+
+bld.inf for BURTestServer
+
+*/
+
+PRJ_TESTEXPORTS
+burtestserver.iby              /epoc32/rom/include/burtestserver.iby
+../testscripts/test.ini        z:/testdata/scripts/sbetestdata/test.ini
+../testscripts/sbeconfig.xml   z:/testdata/scripts/sbetestdata/sbeconfig.xml
+../testscripts/backup_registration.xml   z:/testdata/scripts/sbetestdata/backup_registration.xml
+../testscripts/increamenttest.xml        z:/testdata/scripts/sbetestdata/increamenttest.xml
+../testscripts/test_registration.xml     z:/testdata/scripts/sbetestdata/test_registration.xml
+../testscripts/public_file1.dat          z:/testdata/scripts/sbetestdata/public_file1.dat
+../testscripts/public_file2.dat          z:/testdata/scripts/sbetestdata/public_file2.dat
+../testscripts/private_file1.dat         z:/testdata/scripts/sbetestdata/private_file1.dat
+../testscripts/invalidproxymgr.xml       z:/testdata/scripts/sbetestdata/invalidproxymgr.xml
+../testscripts/testbigfile.dat           z:/testdata/scripts/sbetestdata/testbigfile.dat
+
+../testscripts/test_backuprestore.script        z:/testdata/scripts/sbetestdata/test_backuprestore.script
+../testscripts/test_backuprestoreasync.script   z:/testdata/scripts/sbetestdata/test_backuprestoreasync.script
+../testscripts/test_backupinvalid.script        z:/testdata/scripts/sbetestdata/test_backupinvalid.script
+../testscripts/test_activebackuprestore.script  z:/testdata/scripts/sbetestdata/test_activebackuprestore.script
+../testscripts/test_backuppackage.script        z:/testdata/scripts/sbetestdata/test_backuppackage.script
+../testscripts/test_restorepackage.script       z:/testdata/scripts/sbetestdata/test_restorepackage.script
+../testscripts/test_increament.script           z:/testdata/scripts/sbetestdata/test_increament.script
+
+../testscripts/sbeconfig.xml                /epoc32/release/winscw/udeb/z/private/10202d56/sbeconfig.xml
+../testscripts/sbeconfig.xml                /epoc32/release/winscw/urel/z/private/10202d56/sbeconfig.xml
+
+PRJ_TESTMMPFILES
+    burtestserver.mmp
+
+PRJ_PLATFORMS
+    DEFAULT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/burtestserver/Group/burtestserver.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -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 __BUR_TEST_SERVER_IBY__
+#define __BUR_TEST_SERVER_IBY__
+
+file=ABI_DIR\BUILD_DIR\burtestserver.exe                            Sys\bin\burtestserver.exe
+data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\test.ini                         testdata\scripts\sbetestdata\test.ini
+data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\sbeconfig.xml                    private\10202d56\sbeconfig.xml
+data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\backup_registration.xml          testdata\scripts\sbetestdata\backup_registration.xml
+data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\increamenttest.xml               testdata\scripts\sbetestdata\increamenttest.xml
+data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\test_registration.xml            testdata\scripts\sbetestdata\test_registration.xml
+data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\public_file1.dat                 testdata\scripts\sbetestdata\public_file1.dat
+data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\public_file2.dat                 testdata\scripts\sbetestdata\public_file2.dat
+data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\private_file1.dat                testdata\scripts\sbetestdata\private_file1.dat
+data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\invalidproxymgr.xml              testdata\scripts\sbetestdata\invalidproxymgr.xml
+data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\testbigfile.dat                  testdata\scripts\sbetestdata\testbigfile.dat
+
+data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\test_backuprestore.script        testdata\scripts\sbetestdata\test_backuprestore.script
+data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\test_backuprestoreasync.script   testdata\scripts\sbetestdata\test_backuprestoreasync.script
+data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\test_backupinvalid.script        testdata\scripts\sbetestdata\test_backupinvalid.script
+data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\test_restorepackage.script       testdata\scripts\sbetestdata\test_restorepackage.script
+data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\test_backuppackage.script        testdata\scripts\sbetestdata\test_backuppackage.script
+data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\test_activebackuprestore.script  testdata\scripts\sbetestdata\test_activebackuprestore.script
+data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\test_increament.script           testdata\scripts\sbetestdata\test_increament.script
+
+#endif // __BUR_TEST_SERVER_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/burtestserver/Group/burtestserver.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -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 t_teststepbackup2.cpp
+
+USERINCLUDE		../TestServer/inc
+USERINCLUDE		../TestSteps/inc
+
+OS_LAYER_ESTLIB_SYSTEMINCLUDE
+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 apgrfx.lib
+
+//EPOCHEAPSIZE 1024    1024000
+//EPOCSTACKSIZE 65536
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/burtestserver/Group/testtools_burtestserver.history.xml	Tue Feb 02 01:11:40 2010 +0200
@@ -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/backupandrestore/backuptest/burtestserver/TestServer/inc/t_asyncbackuptransferhandler.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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/backupandrestore/backuptest/burtestserver/TestServer/inc/t_burcommon.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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/backupandrestore/backuptest/burtestserver/TestServer/inc/t_burtestserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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/backupandrestore/backuptest/burtestserver/TestServer/inc/t_storagemanager.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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/backupandrestore/backuptest/burtestserver/TestServer/src/t_asyncbackuptransferhandler.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,325 @@
+// 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;
+		delete iActiveScheduler;
+		}
+	
+	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;
+		if ((iTestStep->ExpectStatus() <= 0 && aError == iTestStep->ExpectStatus())||
+				(iTestStep->ExpectStatus2() <= 0 && aError == iTestStep->ExpectStatus2()))
+			{
+			_LIT(KSetSuccess, "Match expected,set result to success on error:");
+			iTestStep->LogWithNum(LOG_LEVEL4, KSetSuccess, aError);
+		 	iSuccess = ETrue;
+			} else {
+			_LIT(KSetFail, "Unexpected error:");
+			iTestStep->LogWithNum(LOG_LEVEL4, KSetFail, aError);
+			}
+		TRAPD(err, ContinueL());
+		if (err != KErrNone)
+			{
+			_LIT(KErrorText1, "Error trying to issue another request : ");
+			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/backupandrestore/backuptest/burtestserver/TestServer/src/t_burtestserver.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,179 @@
+// 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_teststepbackup2.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 == KBURTestBackup2)
+			{
+			TRAP(error, testStep = CBURTestStepBackup2::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/backupandrestore/backuptest/burtestserver/TestServer/src/t_storagemanager.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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/backupandrestore/backuptest/burtestserver/TestSteps/inc/t_burteststepbase.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,303 @@
+/**
+* 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;
+		inline TInt ExpectStatus() const;
+		inline TInt ExpectStatus2() 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);
+		
+		void ReadListIntoStringArray(const TDesC& aSectionName, const TChar& aDelimiter, RArray<TPtrC>& aResultList);
+		
+		void ReadListIntoIntArray(const TDesC& aSectionName, const TChar& aDelimiter, RArray<TInt>& aResultList);
+		
+	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;
+		TInt  iExpectStatus;
+		TInt  iExpectStatus2;
+		
+		/** 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;
+		
+		/** Name array of public files  */
+		RArray<TPtrC> iPublicFileNames;
+		
+		/** Name array of private files */
+		RArray<TPtrC> iPrivateFileNames;
+		
+		/** File size array of private files */
+		RArray<TInt> iPrivateFileSizes;
+		};
+		
+	// 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;
+		}
+
+	inline TInt CBURTestStepBase::ExpectStatus() const
+		/**
+		Provides access to the ExpectStatus 'iExpectStatus'.
+		
+		@released
+		@internalComponent
+		
+		@return expectstatus value.
+		*/
+		{
+		return iExpectStatus;
+		}
+
+	inline TInt CBURTestStepBase::ExpectStatus2() const
+		/**
+		Provides access to the ExpectStatus 'iExpectStatus2'.
+				
+		@released
+		@internalComponent
+				
+		@return expectstatus value.
+		*/
+		{
+		return iExpectStatus2;
+		}
+
+	/**
+	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/backupandrestore/backuptest/burtestserver/TestSteps/inc/t_teststepbackup.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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/backupandrestore/backuptest/burtestserver/TestSteps/inc/t_teststepbackup2.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,105 @@
+/**
+* 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_BACKUP2_H__
+#define __T_BUR_TEST_STEP_BACKUP2_H__
+
+#include "t_burteststepbase.h"
+#include "t_asyncbackuptransferhandler.h"
+
+_LIT(KBURTestBackup2, "TestBackup2");
+
+namespace bur_ts
+	{
+	// Forward declaration
+	class CAsyncBackupTransferHandler;
+	
+	class CBURTestStepBackup2 : public CBURTestStepBase
+		/**
+		Implements the backup operation. 
+		
+		@released
+		@internalComponent
+		*/
+		{
+	public:
+		static CBURTestStepBackup2* NewL(CBURTestServer& aTestServer);
+		~CBURTestStepBackup2();
+		
+		// Inherited from CTestStep
+		virtual TVerdict doTestStepPreambleL();
+		virtual TVerdict doTestStepPostambleL();
+		virtual TVerdict doTestStepL();
+		
+	private:
+		CBURTestStepBackup2(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);
+	
+		void SupplyDataL(RTransferTypeArray& aTransferTypes, TRequestStatus& aStatus);
+		void GetLargePublicFileListL();
+				
+		void TestSetBURMode();
+	private:
+		/** Handler for async data requests */
+		CAsyncBackupTransferHandler* iDataTransferHandler;
+		};
+	}
+#endif // __T_BUR_TEST_STEP_BACKUP2_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/burtestserver/TestSteps/inc/t_teststepbackupasync.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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/backupandrestore/backuptest/burtestserver/TestSteps/inc/t_teststeprestore.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,86 @@
+/**
+* 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();
+		
+		// Verify restore result is correct
+		void VerifyRestoreResultL();
+		};
+	}
+
+#endif // __T_BUR_TEST_STEP_RESTORE_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/burtestserver/TestSteps/inc/t_teststeprestoreasync.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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/backupandrestore/backuptest/burtestserver/TestSteps/src/t_burteststepbase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1498 @@
+// 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),
+	 	iExpectStatus(1),
+	 	iExpectStatus2(1),
+		iFailures(KErrNone),
+		iStorageManager(NULL),
+		iMode(EBackupMode),
+		iWaitedForActive(EFalse)
+		{}
+	
+	CBURTestStepBase::~CBURTestStepBase()
+		/**
+		C++ Destructor
+		@internalComponent
+		@released
+		*/
+		{
+		iDataOwners.ResetAndDestroy();
+		iDataOwners.Close();
+			
+		iSidArray.Close();
+		iJidArray.Close();
+		iPublicFileNames.Close();
+		iPrivateFileNames.Close();
+		iPrivateFileSizes.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();
+		
+		_LIT(KExpectStatusText1, "ExpectStatus");
+		GetIntFromConfig(ConfigSection(), KExpectStatusText1, iExpectStatus);
+		
+		_LIT(KExpectStatusText2, "ExpectStatus: ");
+		LogWithNum(LOG_LEVEL3, KExpectStatusText2, iExpectStatus);		
+		
+		_LIT(KExpectStatusText3, "ExpectStatus2");
+		GetIntFromConfig(ConfigSection(), KExpectStatusText3, iExpectStatus2);
+		
+		_LIT(KExpectStatusText4, "ExpectStatus2: ");
+		LogWithNum(LOG_LEVEL3, KExpectStatusText4, iExpectStatus2);			
+
+		// 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);
+			}
+		
+		TChar delimiter(',');
+		
+		/** Read public files into array */
+		_LIT(KExpectPublicFiles, "ExpectPublicFiles");
+		ReadListIntoStringArray(KExpectPublicFiles, delimiter, iPublicFileNames);
+		
+		/** Read private files into array */
+		_LIT(KExpectPrivateFiles, "ExpectPrivateFiles");
+		ReadListIntoStringArray(KExpectPrivateFiles, delimiter, iPrivateFileNames);		
+		
+		/** Read private file sizes into array */
+		_LIT(KExpectPrivateFileSizes, "ExpectPrivateFileSizes");
+		ReadListIntoIntArray(KExpectPrivateFileSizes, delimiter, iPrivateFileSizes);
+		}
+		
+	void CBURTestStepBase::ReadListIntoStringArray(const TDesC& aSectionName, const TChar& aDelimiter, RArray<TPtrC>& aResultList)
+		{
+		TChar ch;
+		TPtrC list;
+		GetStringFromConfig(ConfigSection(), aSectionName, list);
+		TLex strLex(list);
+		
+		while (!strLex.Eos())
+			{
+			strLex.Mark();
+        	ch=strLex.Peek();
+
+	    	while( ( !strLex.Eos() ) && 
+	    		   ((ch=strLex.Peek()) != aDelimiter) )
+	    		{
+	    		strLex.Inc();
+	    		}
+
+    		if(!strLex.TokenLength())
+    			continue;
+    		
+    		TPtrC pToken = strLex.MarkedToken();
+    		aResultList.Append(pToken);
+			
+    		if(ch == aDelimiter)
+    			strLex.Inc();
+    		
+    		strLex.SkipSpace();    
+			} //while		
+		}
+	
+	void CBURTestStepBase::ReadListIntoIntArray(const TDesC& aSectionName, const TChar& aDelimiter, RArray<TInt>& aResultList)
+		{
+		RArray<TPtrC> strList;
+		CleanupClosePushL(strList);
+		ReadListIntoStringArray(aSectionName, aDelimiter, strList);
+		
+		TInt count = strList.Count();
+		for (TInt i=0; i<count; ++i)
+			{
+			TInt num = 0;
+			TLex token(strList[i]);
+			if (token.Val(num) == KErrNone)
+				{
+				aResultList.Append(num);
+				}
+			}
+		CleanupStack::PopAndDestroy(&strList); // strList
+		}	
+	
+	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) &&
+					     (iDataOwners[i]->DriveList()[driveCount]) )
+						{
+						CSBSecureId* secureId = CSBSecureId::NewL(&(iDataOwners[i]->Identifier()));
+						CleanupStack::PushL(secureId);
+						
+						sid = secureId->SecureIdL();
+						
+						CleanupStack::PopAndDestroy(secureId);
+						}
+					else if ( (iDataOwners[i]->Identifier().DerivedTypeL() == EPackageDerivedType) &&
+					          (iDataOwners[i]->DriveList()[driveCount]) )
+						{						
+						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++)
+					{
+					if ( (iDataOwners[i]->Identifier().DerivedTypeL() == EPackageDerivedType) &&
+					     (iDataOwners[i]->DriveList()[driveCount]) )
+					    {
+					    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); 					    
+					    }
+					} //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++)
+					{
+					if ( (iDataOwners[i]->Identifier().DerivedTypeL() == EJavaDerivedType) &&
+					     (iDataOwners[i]->DriveList()[driveCount]) )
+					    {
+					    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					    
+					    }
+					} //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);
+						if (iExpectStatus != error && iExpectStatus2 != error)
+							{
+							iFailures++;
+							_LIT(KErrorText3, "Expect Error is: ");
+							LogWithNum(LOG_LEVEL4, KErrorText3, iExpectStatus);
+							}			
+						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)
+					{
+					LogWithSID(LOG_LEVEL3, _L("Data Owner ready: "),statusArray[j].iSID.iId);
+					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--;
+					}
+				else if(statusArray[j].iStatus == EDataOwnerNotConnected && EDataOwnerNotConnected == iExpectStatus)
+					{//ignore this error
+					LogWithSID(LOG_LEVEL3, _L("Data Owner not ready: "),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/backupandrestore/backuptest/burtestserver/TestSteps/src/t_teststepbackup.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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);
+		RRestoreFileFilterArray rawFileList;		
+		CleanupClosePushL(rawFileList);	
+		
+		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->RawPublicFileListL(TDriveNumber(driveCount), *aTransferTypes[i], rawFileList);
+					iBackupClient->PublicFileListL(TDriveNumber(driveCount), *aTransferTypes[i], array);
+					
+					TInt fileCount = array.Count();
+					_LIT(KFoundCount, "Found number of files: ");
+					LogWithNum(LOG_LEVEL3, KFoundCount, fileCount);
+					
+					for (TInt j = 0; j < fileCount; j++)
+						{
+						_LIT(KFile, "Public File: ");
+						LogWithText(LOG_LEVEL4, KFile, array[j].iName);
+						}					
+					
+					for (TInt j = 0; j < rawFileList.Count(); j++)
+						{
+						_LIT(KFile, "Raw Public File: ");
+						LogWithText(LOG_LEVEL4, KFile, rawFileList[j].iName);
+						}						
+
+					/** Only for one partial backup */
+					if (iPublicFileNames.Count() > 0)
+						{
+						if (fileCount != iPublicFileNames.Count())
+							{
+							iFailures++;
+							_LIT(KLogCount, "Backup count of public files don't match ");
+							Log(LOG_LEVEL3, KLogCount);
+							SetTestStepResult(TVerdict(EFail));				
+							}
+						
+						for (TInt k=0; k<fileCount; ++k)
+							{
+							if (iPublicFileNames.Find(array[k].iName) == KErrNotFound) 
+								{
+								iFailures++;
+								_LIT(KLogName, "Backup name of public files don't match ");
+								Log(LOG_LEVEL3, KLogName);
+								SetTestStepResult(TVerdict(EFail));										
+								}
+							}
+						}			
+
+					array.Reset();
+					rawFileList.Reset();
+					}
+				}
+			}
+		CleanupStack::PopAndDestroy(&rawFileList);
+		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/backupandrestore/backuptest/burtestserver/TestSteps/src/t_teststepbackup2.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,869 @@
+// 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 <connect/sbtypes.h>
+#include "t_teststepbackup2.h"
+#include <apgcli.h>
+
+namespace bur_ts
+	{	
+		
+	CBURTestStepBackup2* CBURTestStepBackup2::NewL(CBURTestServer& aTestServer)
+		/**
+		Symbian OS Constructor
+		
+		@internalComponent
+		@released
+		
+		@param aParent - The parent CBURTestServer of this child test step.
+		@return Pointer to a newly created CBURTestStepBackup2 object.
+		*/
+		{
+		CBURTestStepBackup2* self = new (ELeave) CBURTestStepBackup2(aTestServer);
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		CleanupStack::Pop();
+		return self;
+		}
+
+	CBURTestStepBackup2::CBURTestStepBackup2(CBURTestServer& aTestServer)
+		/**
+		C++ Constructor
+		
+		@internalComponent
+		@released
+		
+		@param aParent - The parent CBURTestServer of this child test step.
+		*/
+		: CBURTestStepBase(aTestServer), iDataTransferHandler(NULL)
+		{}
+	
+	void CBURTestStepBackup2::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(KBURTestBackup2);
+		}
+	
+	CBURTestStepBackup2::~CBURTestStepBackup2()
+		/**
+		C++ Destructor
+		
+		@internalComponent
+		@released
+		*/
+		{
+		delete iDataTransferHandler;
+		}
+
+	TVerdict CBURTestStepBackup2::doTestStepPreambleL()
+		/**
+		Override of base class virtual function
+		
+		@internalComponent
+		@released
+		
+		@return TVerdict code
+		*/
+		{
+		SetTestStepResult(EPass);
+		return TestStepResult();
+		}
+
+	TVerdict CBURTestStepBackup2::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();
+			}
+		GetLargePublicFileListL();
+		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);
+			}
+		
+		TestSetBURMode();
+		
+		return TestStepResult();
+		}
+	
+	void CBURTestStepBackup2::BaseBackupL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		// system data
+		BackupSystemBaseDataL();
+		BackupSystemSnapshotDataL();
+		
+		//active
+		BackupActiveBaseDataL();
+		BackupActiveSnapshotDataL();
+		
+		//passive
+		BackupPassiveBaseDataL();
+		BackupPassiveSnapshotDataL();
+		}
+	
+	void CBURTestStepBackup2::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 CBURTestStepBackup2::BackupSystemBaseDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KLog, "Backup System Data ...");
+		Log(LOG_LEVEL2, KLog);
+		GeneratePIDTransferTypesL(iTransferTypes, ESystemData);
+		DoBackupL();
+		}
+
+	void CBURTestStepBackup2::SupplyDataL(RTransferTypeArray& aTransferTypes, TRequestStatus& aStatus)
+		{//added for coverage test
+		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, aStatus));
+					if (error != KErrNone)
+						{
+						_LIT(KErrorText2, "Error supplying data to backup server: ");
+						LogWithNum(LOG_LEVEL4, KErrorText2, error);
+						if (iExpectStatus != 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
+		}
+	
+	void CBURTestStepBackup2::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);
+			
+			TRequestStatus status;
+			SupplyDataL(iTransferTypes, status);
+			}
+		}
+		
+	void CBURTestStepBackup2::BackupSystemSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KLog, "Backup System Snapshot Data ...");
+		Log(LOG_LEVEL2, KLog);
+		GeneratePIDTransferTypesL(iTransferTypes, ESystemSnapshotData);
+		DoBackupL();
+		}
+	
+	
+	void CBURTestStepBackup2::BackupRegistrationDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KReg, "Backup registration data...");
+		Log(LOG_LEVEL2, KReg);
+		GenerateSIDTransferTypesL(iTransferTypes, ERegistrationData);
+		DoBackupL();
+		}
+	
+	void CBURTestStepBackup2::BackupPassiveSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KPassSnap, "Backup passive snapshot data...");
+		Log(LOG_LEVEL2, KPassSnap);
+		GenerateSIDTransferTypesL(iTransferTypes, EPassiveSnapshotData);
+		DoBackupL();
+		}
+	
+	void CBURTestStepBackup2::SupplyPassiveSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KSupp, "Supplying passive snapshot data...");
+		Log(LOG_LEVEL2, KSupp);
+		DoSupplyL(EPassiveSnapshotData);
+		}
+
+	void CBURTestStepBackup2::BackupPassiveBaseDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KPassBase, "Backup passive base data...");
+		Log(LOG_LEVEL2, KPassBase);
+		GenerateSIDTransferTypesL(iTransferTypes, EPassiveBaseData);
+		DoBackupL();
+		}
+	
+	void CBURTestStepBackup2::BackupPassiveIncDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KPassInc, "Backup passive incremental data...");
+		Log(LOG_LEVEL2, KPassInc);
+		GenerateSIDTransferTypesL(iTransferTypes, EPassiveIncrementalData);
+		DoBackupL();
+		}
+	
+	void CBURTestStepBackup2::BackupActiveSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KActSnap, "Backup active snapshot data...");
+		Log(LOG_LEVEL2, KActSnap);
+		DoActiveBackupL(EActiveSnapshotData);
+		}
+	
+	void CBURTestStepBackup2::SupplyActiveSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KSuppActSnap,"Supplying active snapshot data...");
+		Log(LOG_LEVEL2, KSuppActSnap);
+		DoSupplyL(EActiveSnapshotData);
+		}
+	
+	void CBURTestStepBackup2::BackupActiveBaseDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KActBase, "Backup active base data...");
+		Log(LOG_LEVEL2, KActBase);
+		DoActiveBackupL(EActiveBaseData);
+		}
+
+	void CBURTestStepBackup2::BackupActiveIncDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KActInc, "Backup active incremental data...");
+		Log(LOG_LEVEL2, KActInc);
+		DoActiveBackupL(EActiveIncrementalData);
+		}
+		
+	void CBURTestStepBackup2::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 CBURTestStepBackup2::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);
+					
+					TInt fileCount = array.Count();
+					_LIT(KFoundCount, "Found number of files: ");
+					LogWithNum(LOG_LEVEL3, KFoundCount, fileCount);
+					
+					for (TInt j = 0; j < fileCount; j++)
+						{
+						_LIT(KFile, "Public File: ");
+						LogWithText(LOG_LEVEL4, KFile, array[j].iName);
+						}
+					
+					/** Only for one partial backup */
+					if (iPublicFileNames.Count() > 0)
+						{
+						if (fileCount != iPublicFileNames.Count())
+							{
+							iFailures++;
+							_LIT(KLogCount, "Backup count of public files don't match ");
+							Log(LOG_LEVEL3, KLogCount);
+							SetTestStepResult(TVerdict(EFail));				
+							}
+						
+						for (TInt k=0; k<fileCount; ++k)
+							{
+							if (iPublicFileNames.Find(array[k].iName) == KErrNotFound) 
+								{
+								iFailures++;
+								_LIT(KLogName, "Backup name of public files don't match ");
+								Log(LOG_LEVEL3, KLogName);
+								SetTestStepResult(TVerdict(EFail));										
+								}
+							}						
+						}
+					array.Reset();
+					}
+				}
+			}
+		CleanupStack::PopAndDestroy(&array);
+		}
+	
+	void CBURTestStepBackup2::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 CBURTestStepBackup2::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 CBURTestStepBackup2::BackupJavaMidletsL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KMidlet, "Backup midlets...");
+		Log(LOG_LEVEL2, KMidlet);
+		GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDlet);
+		DoBackupL();
+		}
+		
+	void CBURTestStepBackup2::BackupJavaMidletsDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KMidletData, "Backup midlets data...");
+		Log(LOG_LEVEL2, KMidletData);
+		GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDletData);
+		DoBackupL();
+		}
+	
+	TVerdict CBURTestStepBackup2::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();
+		}
+	void CBURTestStepBackup2::GetLargePublicFileListL()
+		{
+		//Coverage test get large public file list
+		RPointerArray<CSBGenericDataType> transferTypes;
+		CleanupClosePushL(transferTypes);
+		TRAP_IGNORE(GeneratePublicTransferTypesL(transferTypes));
+		RFileArray array;
+		CleanupClosePushL(array);
+		TInt length = iDriveList.Length();
+		TInt count = transferTypes.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);					
+					RPointerArray<CSBEFileEntry> fileEntry;
+					TBool bFinish;
+					CleanupClosePushL(fileEntry);
+					iBackupClient->PublicFileListL(TDriveNumber(driveCount), *transferTypes[i], 
+							fileEntry,
+							bFinish,
+							0,
+							1024,
+							active->iStatus);
+					active->StartL();
+					User::LeaveIfError(active->Error());
+					TInt fileCount = fileEntry.Count();
+					for (TInt j = 0; j < fileCount; j++)
+						{
+						_LIT(KFile, "File: ");
+						LogWithText(LOG_LEVEL4, KFile, fileEntry[j]->Filename());
+						}
+					CleanupStack::PopAndDestroy(&fileEntry);
+					CleanupStack::PopAndDestroy(active);
+
+					_LIT(KFoundCount, "Get large file list and found number of files: ");
+					LogWithNum(LOG_LEVEL3, KFoundCount, fileCount);
+					array.Reset();
+					}
+				}
+			}		
+		CleanupStack::PopAndDestroy(&array);
+		CleanupStack::PopAndDestroy(&transferTypes);
+		
+		//added for coverage test: test sbtypes
+		if(iDataOwners.Count() > 0)
+			{
+			TDriveList& ref1 = iDataOwners[0]->DriveList();			
+			HBufC8* hbuf = iDataOwners[0]->ExternaliseL();
+			CSBGenericDataType& genDataType = iDataOwners[0]->Identifier();
+			
+			const CDataOwnerInfo& refDataOwner = *iDataOwners[0];
+			const CSBGenericDataType& genDataType2 =refDataOwner.Identifier();
+			const TDriveList& ref2 = refDataOwner.DriveList();
+			
+			_LIT(fname, "test.txt");
+			TEntry entry;
+			entry.iName = fname;
+			
+			RApaLsSession apaSession;
+			User::LeaveIfError(apaSession.Connect());
+			CleanupClosePushL(apaSession);
+			CSBEFileEntry* sbeFile = CSBEFileEntry::NewLC(entry, apaSession);
+			HBufC8* tmpBuf =sbeFile->ExternaliseLC();
+			
+			sbeFile->FileAttributes();
+			sbeFile->Filename();
+			sbeFile->FileSize();
+			sbeFile->LastModified();
+			sbeFile->MIMEType();
+			sbeFile->MIMEUid();			
+			
+			TInt count;
+			CSBEFileEntry* sbeFile2= CSBEFileEntry::NewLC(*tmpBuf, count);
+						
+			CleanupStack::PopAndDestroy(sbeFile2);
+			CleanupStack::PopAndDestroy(tmpBuf);
+			CleanupStack::PopAndDestroy(sbeFile);
+			CleanupStack::PopAndDestroy(&apaSession);
+			}		
+		}
+	
+	void CBURTestStepBackup2::TestSetBURMode()
+		{
+		TRAPD(err, SetBURModeL(EBURUnset, EBackupBase));
+		TRAP(err, SetBURModeL(EBURUnset, EBackupBase));
+		TRAP(err, SetBURModeL(EBURNormal, EBackupBase));
+		TRAP(err, SetBURModeL(EBURNormal, EBackupBase));
+		TRAP(err, SetBURModeL(EBURUnset, EBackupBase));
+		TRAP(err, SetBURModeL(EBURUnset, EBackupBase));
+		
+		TSecureId sid(0x10202BE9);
+		HBufC* hbuf = NULL;
+		
+		//this method is not implemented at server side
+		TRAP(err, iBackupClient->PublicFileListXMLL(EDriveC, sid, hbuf));
+		
+		TRAP(err, SetBURModeL(EBURBackupFull, EBackupBase));
+		
+		//this method is not implemented at server side
+		TRAP(err, iBackupClient->PublicFileListXMLL(EDriveC, sid, hbuf));
+		
+		TRAP(err, SetBURModeL(EBURBackupFull, EBackupBase));
+		TRAP(err, SetBURModeL(EBURBackupPartial, EBackupBase));
+				
+		TRAP(err, SetBURModeL(EBURBackupPartial, EBackupIncrement));
+		TRAP(err, SetBURModeL(EBURBackupFull, EBackupIncrement));		
+		
+		{//this operation is expected to fail
+			TRAP(err, PopulateListOfDataOwnersL());
+			iFailures--;
+		}
+		
+		TRAP(err, SetBURModeL(EBURBackupPartial, ENoBackup));
+		TRAP(err, SetBURModeL(EBURBackupFull, ENoBackup));		
+		
+		TRAP(err, SetBURModeL(EBURRestoreFull, EBackupBase));
+		TRAP(err, SetBURModeL(EBURRestorePartial, EBackupBase));
+				
+		TRAP(err, SetBURModeL(EBURRestoreFull, EBackupIncrement));
+		TRAP(err, SetBURModeL(EBURRestorePartial, EBackupIncrement));
+		
+		TRAP(err, SetBURModeL(EBURRestoreFull, ENoBackup));
+		TRAP(err, SetBURModeL(EBURRestorePartial, ENoBackup));
+		TRAP(err, SetBURModeL(EBURNormal, EBackupBase));
+		
+		//this method is not implemented at server side
+		TRAP(err, iBackupClient->PublicFileListXMLL(EDriveC, sid, hbuf));
+		}
+	}	// end namespace
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/burtestserver/TestSteps/src/t_teststepbackupasync.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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/backupandrestore/backuptest/burtestserver/TestSteps/src/t_teststeprestore.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,425 @@
+// 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);
+			}
+		
+		VerifyRestoreResultL();
+		
+		return TestStepResult();
+		}
+	
+	void CBURTestStepRestore::VerifyRestoreResultL()
+		{		
+		if (iPrivateFileNames.Count() != iPrivateFileSizes.Count())
+			{
+			iFailures++;
+			_LIT(KLogCount, "Restore name and size count of private files don't match");
+			Log(LOG_LEVEL3, KLogCount);
+			SetTestStepResult(TVerdict(EFail));
+			return;
+			}
+		
+		/** if we have configure name list of private file and then we check it. */
+		if (iPrivateFileNames.Count() > 0)
+			{			
+			TInt count = iPrivateFileNames.Count();
+			for (TInt i=0; i<count; ++i)
+				{
+				RFile file;
+				CleanupClosePushL(file);				
+				TInt err = file.Open(Fs(), iPrivateFileNames[i], EFileRead);
+				if (err != KErrNone)
+					{
+					CleanupStack::PopAndDestroy(&file);
+					User::Leave(err);
+					}
+				
+				TInt size;
+				file.Size(size);
+				
+				if (size != iPrivateFileSizes[i])
+					{
+					iFailures++;
+					_LIT(KLogRestore, "Restore private files error ");
+					Log(LOG_LEVEL3, KLogRestore);
+					SetTestStepResult(TVerdict(EFail));						
+					}
+				CleanupStack::PopAndDestroy(&file); // file
+				}// end for	
+			}// end if
+		}
+	
+	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/backupandrestore/backuptest/burtestserver/TestSteps/src/t_teststeprestoreasync.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,31 @@
+// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Sub-system bld.inf file for PC-Connectivity
+// Symbian PC Connectivity
+// 
+//
+
+/**
+ @file
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+
+#include "../ABTester/group/bld.inf"
+#include "../burtestserver/Group/bld.inf"
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backupandrestore/backuptest/group/connectivity_backuptest.mrp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,31 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	connectivity_backuptest
+source \sf\mw\remoteconn\backupandrestore\backuptest\ABTester
+source \sf\mw\remoteconn\backupandrestore\backuptest\burtestserver
+source \sf\mw\remoteconn\backupandrestore\backuptest\testdata
+source \sf\mw\remoteconn\backupandrestore\backuptest\group
+
+binary	\sf\mw\remoteconn\backupandrestore\backuptest\group all
+exports	\sf\mw\remoteconn\backupandrestore\backuptest\group
+
+
+notes_source	\component_defs\release.src
+
+
+ipr T 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/apple/S60_RnD_32.phoneplugin/Contents/Info.plist	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleGetInfoString</key>
+	<string>Nokia S60-32 v1.0, © Nokia</string>
+	<key>CFBundleIdentifier</key>
+	<string>nokia.com.phoneplugin.com.nokia.S6032</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>Nokia S60-32</string>
+	<key>CFBundlePackageType</key>
+	<string>BNDL</string>
+	<key>CFBundleShortVersionString</key>
+	<string>1.0</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>556</string>
+	<key>IPHPhoneConduitVersion</key>
+	<string>597.0</string>
+	<key>IPHPhonePluginUID</key>
+	<string>367C0F5C-1E53-44A3-AEA5-54D1EEE12F29</string>
+	<key>IPHPluginProviderName</key>
+	<string>Nokia</string>
+	<key>IPHPluginSupportURL</key>
+	<string>http://www.nokia.com/support</string>
+	<key>IPHPublicPluginVersion</key>
+	<string>2.0</string>
+</dict>
+</plist>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/apple/S60_RnD_32.phoneplugin/Contents/Resources/MetaClasses.plist	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,329 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<dict>
+    <key>family.com.nokia.S6032</key>
+    <dict>
+        <key>InheritsFrom</key>
+        <array>
+            <string>family.com.apple.external.all-phones.usb-bt</string>
+        </array>
+        <key>Services</key>
+        <array>
+            <dict>
+                <key>ServiceName</key>
+                <string>com.apple.synchro</string>
+                <key>ServiceClass</key>
+                <string>IPHSyncMLSyncTransportServiceObexClient</string>
+                <key>ServiceProperties</key>
+                <dict>
+                    <key>IPHEnginePlist</key>
+                    <string>SyncEngine.plist</string>
+                    <key>SyncProperties2</key>
+                    <string>PhoneConduit.plist</string>
+                    <key>SyncMLVersion</key>
+                    <string>SyncML11</string>
+                    <key>SyncMLLargeObjectSupport</key>
+                    <true/>
+                    <key>SyncMLNumberOfChangesSupport</key>
+                    <true/>
+                    <key>SyncMLRefreshFromServerSupport</key>
+                    <true/>
+                    <key>SyncMLRemoteNeedsRelativePaths</key>
+                    <false/>
+                    <key>SyncMLBusySignalingSupport</key>
+                    <true/>
+                    <key>SyncMLOnlyOneBusySignaling</key>
+                    <false/>
+                    <key>SyncMLBusySignalingInterval</key>
+                    <integer>60</integer>
+                    <key>SyncMLSimulateBusySignalingWithEmptySync</key>
+                    <false/>
+                    <key>SyncDataClasses</key>
+                    <plist>
+                        <array>
+                            <string>com.apple.pimsync.contacts</string>
+                            <string>com.apple.pimsync.calendars</string>
+                        </array>
+                    </plist>
+                    <key>DontSyncEventsAfterDateValue.visible</key>
+                    <true/>
+                    <key>DontSyncEventsAfterDateValue.default-value</key>
+                    <string>1month</string>
+                    <key>OnlySyncContactsWithPhoneNumber.visible</key>
+                    <true/>
+                    <key>OnlySyncContactsWithPhoneNumber.default-value</key>
+                    <false/>
+                    <key>SyncAllDayEventsKey.visible</key>
+                    <false/>
+                    <key>SyncAllDayEventsKey.default-value</key>
+                    <true/>
+                    <key>DontSyncEventsPriorToDateValue.visible</key>
+                    <true/>
+                    <key>DontSyncEventsPriorToDateValue.default-value</key>
+                    <string>1week</string>
+                    <key>DontSyncEventsPriorToDateIsEnabled.visible</key>
+                    <false/>
+                    <key>DontSyncEventsPriorToDateIsEnabled.default-value</key>
+                    <true/>
+                    <key>DontSyncEventsAfterDateIsEnabled.visible</key>
+                    <true/>
+                    <key>DontSyncEventsAfterDateIsEnabled.default-value</key>
+                    <true/>
+                    <key>SyncMLLocalSource</key>
+                    <string>iSync</string>
+                    <key>SyncMLCodec</key>
+                    <string>SyncMLCodecLibWBXML</string>
+                    <key>SyncMLMsgTemporization</key>
+                    <integer>500000</integer>
+                    <key>SyncMLMaxObjSize</key>
+                    <integer>786432</integer>
+                    <key>SyncMLMaxMsgSize</key>
+                    <integer>65535</integer>
+                    <key>BTProtocolService</key>
+                    <string>com.nokia.S6032.protocol.bt.obex.syncml</string>
+                    <key>USBProtocolService</key>
+                    <string>com.nokia.S6032.protocol.usb.obex.syncml</string>
+                </dict>
+            </dict>
+            <dict>
+                <key>ServiceName</key>
+                <string>com.nokia.S6032.protocol.usb.obex.syncml</string>
+                <key>ServiceClass</key>
+                <string>IPHObexService</string>
+                <key>ServiceProperties</key>
+                <dict>
+                    <key>ObexTargetUUID</key>
+                    <string>53 59 4e 43 4d 4c 2d 53 59 4e 43</string>
+                    <key>ObexTimeOut</key>
+                    <integer>60</integer>
+                    <key>TransportService</key>
+                    <string>com.nokia.S6032.transport.usb.syncml</string>
+                </dict>
+            </dict>
+            <dict>
+                <key>ServiceName</key>
+                <string>com.nokia.S6032.protocol.bt.obex.syncml</string>
+                <key>ServiceClass</key>
+                <string>IPHObexService</string>
+                <key>ServiceProperties</key>
+                <dict>
+                    <key>ObexTargetUUID</key>
+                    <string>53 59 4e 43 4d 4c 2d 53 59 4e 43</string>
+                    <key>ObexTimeOut</key>
+                    <integer>60</integer>
+                    <key>TransportService</key>
+                    <string>com.nokia.S6032.transport.rfcomm.syncml</string>
+                </dict>
+            </dict>
+            <dict>
+                <key>ServiceName</key>
+                <string>com.apple.protocol.usb.AT</string>
+                <key>ServiceClass</key>
+                <string>IPHSerialATService</string>
+                <key>ServiceProperties</key>
+                <dict/>
+            </dict>
+            <dict>
+                <key>ServiceName</key>
+                <string>com.nokia.S6032.transport.rfcomm.syncml</string>
+                <key>ServiceClass</key>
+                <string>IPHRFCOMMChannelService</string>
+                <key>ServiceProperties</key>
+                <dict>
+                    <key>RFCOMMChannelUUID</key>
+                    <string>000000020000100080000002ee000002</string>
+                </dict>
+            </dict>
+            <dict>
+                <key>ServiceName</key>
+                <string>com.apple.transport.usb.modem</string>
+                <key>ServiceClass</key>
+                <string>IPHUSBCDCChannelService</string>
+                <key>ServiceProperties</key>
+                <dict/>
+            </dict>
+            <dict>
+                <key>ServiceName</key>
+                <string>com.nokia.S6032.transport.usb.syncml</string>
+                <key>ServiceClass</key>
+                <string>IPHUSBObexChannelService</string>
+                <key>ServiceProperties</key>
+                <dict/>
+            </dict>
+            <dict>
+                <key>ServiceName</key>
+                <string>com.apple.pimsync.parser.vCal</string>
+                <key>ServiceClass</key>
+                <string>IPHSyncParserService</string>
+                <key>ServiceProperties</key>
+                <dict>
+                    <key>ParserType</key>
+                    <string>vCal</string>
+                    <key>Encoding</key>
+                    <string>QUOTED-PRINTABLE</string>
+                    <key>FoldingStyle</key>
+                    <string>FoldingNG</string>
+                    <key>Charset</key>
+                    <string>UTF-8</string>
+                    <key>AllDayEventFormat</key>
+                    <string>AllDayEventFromMidnightTo235900</string>
+                    <key>vCalRecDropIfUseless</key>
+                    <true/>
+                    <key>EscapeSemicolonInNotComponedValues</key>
+                    <true/>
+                    <key>EscapeBackslash</key>
+                    <true/>
+                    <key>IgnoreProperties</key>
+                    <array>
+                        <string>X-IRMC-LUID</string>
+                    </array>
+                    <key>UntilDateInLocal</key>
+                    <true/>
+                    <key>SetUntilTimeWithStartTime</key>
+                    <true/>
+                </dict>
+            </dict>
+            <dict>
+                <key>ServiceName</key>
+                <string>com.apple.pimsync.parser.vCard</string>
+                <key>ServiceClass</key>
+                <string>IPHSyncParserService</string>
+                <key>ServiceProperties</key>
+                <dict>
+                    <key>ParserType</key>
+                    <string>vCard</string>
+                    <key>Encoding</key>
+                    <string>QUOTED-PRINTABLE</string>
+                    <key>FoldingStyle</key>
+                    <string>FoldingNG</string>
+                    <key>Charset</key>
+                    <string>UTF-8</string>
+                    <key>EscapeSemicolonInNotComponedValues</key>
+                    <true/>
+                    <key>EscapeBackslash</key>
+                    <true/>
+                    <key>IgnoreProperties</key>
+                    <array>
+                        <string>X-IRMC-LUID</string>
+                    </array>
+                    <key>PropertyNameMapping</key>
+                    <dict>
+                        <key>X-NICKNAME</key>
+                        <string>X-EPOCSECONDNAME</string>
+                    </dict>
+                    <key>AddCRLFAfterBase64Folding</key>
+                    <true/>
+                    <key>IgnoreSubTypesForThisMainTypes</key>
+                    <array>
+                        <string>CELL</string>
+                    </array>
+                </dict>
+            </dict>
+            <dict>
+                <key>ServiceName</key>
+                <string>com.apple.pimsync.contacts</string>
+                <key>ServiceClass</key>
+                <string>IPHSyncDataClassService</string>
+                <key>ServiceProperties</key>
+                <dict>
+                    <key>MimeType</key>
+                    <string>text/x-vcard</string>
+                    <key>ParserService</key>
+                    <string>com.apple.pimsync.parser.vCard</string>
+                    <key>RemoteName</key>
+                    <string></string>
+                    <key>needsCompanyNameInFirstName</key>
+                    <false/>
+                    <key>needsFullAddressInStreetField</key>
+                    <false/>
+                    <key>DataClassName</key>
+                    <string>Contacts</string>
+                    <key>needsDeleteAddOnModify</key>
+                    <true/>
+                    <key>MaxSyncCmd</key>
+                    <integer>1</integer>
+                </dict>
+            </dict>
+            <dict>
+                <key>ServiceName</key>
+                <string>com.apple.pimsync.calendars</string>
+                <key>ServiceClass</key>
+                <string>IPHSyncDataClassService</string>
+                <key>ServiceProperties</key>
+                <dict>
+                    <key>MimeType</key>
+                    <string>text/x-vcalendar</string>
+                    <key>ParserService</key>
+                    <string>com.apple.pimsync.parser.vCal</string>
+                    <key>hasEvent</key>
+                    <true/>
+                    <key>RemoteName</key>
+                    <string></string>
+                    <key>hasAllDayEvents</key>
+                    <false/>
+                    <key>hasAllDayFromMidnightTo235900</key>
+                    <true/>
+                    <key>hasVCalRecurrence</key>
+                    <true/>
+                    <key>needsToFormatCountToUntilDate</key>
+                    <true/>
+                    <key>needsToFormatUntilDateToCount</key>
+                    <false/>
+                    <key>hasOneAlarmType</key>
+                    <true/>
+                    <key>alarmTypeIsDisplay</key>
+                    <false/>
+                    <key>hasTimeZone</key>
+                    <true/>
+                    <key>hasTask</key>
+                    <true/>
+                    <key>handleAllDayRecurrent</key>
+                    <true/>
+                    <key>doNotSyncAlarmIfAfterStartDateTime</key>
+                    <true/>
+                    <key>DataClassName</key>
+                    <string>Calendar</string>
+                    <key>allDayInLocalDateTime</key>
+                    <true/>
+                    <key>untilDateIsDateOnly</key>
+                    <true/>
+                    <key>exDatesAreDateOnly</key>
+                    <false/>
+                    <key>doNotSyncAlarmIfCompleted</key>
+                    <true/>
+                    <key>dueDateIsDateOnly</key>
+                    <false/>
+                </dict>
+            </dict>
+        </array>
+    </dict>
+    <key>com.nokia.S6032</key>
+    <dict>
+        <key>Identification</key>
+        <dict>
+            <key>com.apple.usb.vendorid-modelid</key>
+            <string>0x0421/0x0500</string>
+            <key>com.apple.gmi+gmm</key>
+            <string>Nokia+Nokia 6290</string>
+        </dict>
+        <key>InheritsFrom</key>
+        <array>
+            <string>family.com.nokia.S6032</string>
+        </array>
+        <key>Services</key>
+        <array>
+            <dict>
+                <key>ServiceName</key>
+                <string>com.apple.model</string>
+                <key>ServiceProperties</key>
+                <dict>
+                    <key>ModelName</key>
+                    <string>S60-32</string>
+                    <key>CompanyName</key>
+                    <string>Nokia</string>
+                    <key>ModelIcon</key>
+                    <string>com.nokia.S6032.tiff</string>
+                </dict>
+            </dict>
+        </array>
+    </dict>
+</dict>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/apple/S60_RnD_32.phoneplugin/Contents/Resources/PhoneConduit.plist	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,534 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>Formatting</key>
+	<dict>
+		<key>com.apple.calendars.Event</key>
+		<dict>
+			<key>classification</key>
+			<dict>
+				<key>mappings</key>
+				<array>
+					<dict>
+						<key>mappedValue</key>
+						<string>PUBLIC</string>
+						<key>originalValue</key>
+						<string>public</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>PRIVATE</string>
+						<key>originalValue</key>
+						<string>private</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>PRIVATE</string>
+						<key>originalValue</key>
+						<string>confidential</string>
+					</dict>
+				</array>
+			</dict>
+			<key>description</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>500</integer>
+			</dict>
+			<key>end date</key>
+			<dict/>
+			<key>location</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+			<key>start date</key>
+			<dict/>
+			<key>summary</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>500</integer>
+			</dict>
+		</dict>
+		<key>com.apple.calendars.Task</key>
+		<dict>
+			<key>classification</key>
+			<dict>
+				<key>mappings</key>
+				<array>
+					<dict>
+						<key>mappedValue</key>
+						<string>PUBLIC</string>
+						<key>originalValue</key>
+						<string>public</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>PRIVATE</string>
+						<key>originalValue</key>
+						<string>private</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>PRIVATE</string>
+						<key>originalValue</key>
+						<string>confidential</string>
+					</dict>
+				</array>
+			</dict>
+			<key>completion date</key>
+			<dict/>
+			<key>description</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+			<key>due date</key>
+			<dict/>
+			<key>priority</key>
+			<dict>
+				<key>mappings</key>
+				<array>
+					<dict>
+						<key>mappedValue</key>
+						<string></string>
+						<key>originalValue</key>
+						<integer>0</integer>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>1</string>
+						<key>originalValue</key>
+						<integer>1</integer>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>2</string>
+						<key>originalValue</key>
+						<integer>2</integer>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>3</string>
+						<key>originalValue</key>
+						<integer>3</integer>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>4</string>
+						<key>originalValue</key>
+						<integer>4</integer>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>5</string>
+						<key>originalValue</key>
+						<integer>5</integer>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>6</string>
+						<key>originalValue</key>
+						<integer>6</integer>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>7</string>
+						<key>originalValue</key>
+						<integer>7</integer>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>8</string>
+						<key>originalValue</key>
+						<integer>8</integer>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>9</string>
+						<key>originalValue</key>
+						<integer>9</integer>
+					</dict>
+				</array>
+			</dict>
+			<key>status</key>
+			<dict>
+				<key>mappings</key>
+				<array>
+					<dict>
+						<key>mappedValue</key>
+						<string>DECLINED</string>
+						<key>originalValue</key>
+						<string>cancelled</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>NEEDS ACTION</string>
+						<key>originalValue</key>
+						<string>needsaction</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>COMPLETED</string>
+						<key>originalValue</key>
+						<string>completed</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>ACCEPTED</string>
+						<key>originalValue</key>
+						<string>inprocess</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string></string>
+						<key>originalValue</key>
+						<string>none</string>
+					</dict>
+				</array>
+			</dict>
+			<key>summary</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+		</dict>
+		<key>com.apple.contacts.Contact</key>
+		<dict>
+			<key>birthday</key>
+			<dict/>
+			<key>company name</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+			<key>department</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+			<key>first name</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+			<key>image</key>
+			<dict>
+				<key>maxLength</key>
+				<integer>0</integer>
+			</dict>
+			<key>job title</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+			<key>last name</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+			<key>middle name</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+			<key>nickname</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+			<key>notes</key>
+			<dict>
+				<key>maxLength</key>
+				<integer>1000</integer>
+			</dict>
+			<key>suffix</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+			<key>title</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+		</dict>
+		<key>com.apple.contacts.Date</key>
+		<dict>
+			<key>type</key>
+			<dict>
+				<key>mappings</key>
+				<array/>
+			</dict>
+			<key>value</key>
+			<dict/>
+		</dict>
+		<key>com.apple.contacts.Email Address</key>
+		<dict>
+			<key>type</key>
+			<dict>
+				<key>mappings</key>
+				<array>
+					<dict>
+						<key>mappedValue</key>
+						<string>WORK</string>
+						<key>originalValue</key>
+						<string>work</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>HOME</string>
+						<key>originalValue</key>
+						<string>home</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>INTERNET</string>
+						<key>originalValue</key>
+						<string>other</string>
+					</dict>
+				</array>
+			</dict>
+			<key>value</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+		</dict>
+		<key>com.apple.contacts.Phone Number</key>
+		<dict>
+			<key>type</key>
+			<dict>
+				<key>mappings</key>
+				<array>
+					<dict>
+						<key>mappedValue</key>
+						<string>WORK</string>
+						<key>originalValue</key>
+						<string>work</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>HOME</string>
+						<key>originalValue</key>
+						<string>home</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>CELL</string>
+						<key>originalValue</key>
+						<string>mobile</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>FAX</string>
+						<key>originalValue</key>
+						<string>work fax</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>FAX</string>
+						<key>originalValue</key>
+						<string>home fax</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string></string>
+						<key>originalValue</key>
+						<string>other</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string></string>
+						<key>originalValue</key>
+						<string>main</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>PAGER</string>
+						<key>originalValue</key>
+						<string>pager</string>
+					</dict>
+				</array>
+			</dict>
+			<key>value</key>
+			<dict>
+				<key>charsToKeep</key>
+				<string>0123456789+#*pw</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+		</dict>
+		<key>com.apple.contacts.Related Name</key>
+		<dict>
+			<key>type</key>
+			<dict>
+				<key>mappings</key>
+				<array>
+					<dict>
+						<key>mappedValue</key>
+						<string>X-CHILDREN</string>
+						<key>originalValue</key>
+						<string>child</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>X-SPOUSE</string>
+						<key>originalValue</key>
+						<string>spouse</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>X-ASSISTANT</string>
+						<key>originalValue</key>
+						<string>assistant</string>
+					</dict>
+				</array>
+			</dict>
+			<key>value</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+		</dict>
+		<key>com.apple.contacts.Street Address</key>
+		<dict>
+			<key>city</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+			<key>country</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+			<key>postal code</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+			<key>state</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+			<key>street</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>255</integer>
+			</dict>
+			<key>type</key>
+			<dict>
+				<key>mappings</key>
+				<array>
+					<dict>
+						<key>mappedValue</key>
+						<string>WORK</string>
+						<key>originalValue</key>
+						<string>work</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>HOME</string>
+						<key>originalValue</key>
+						<string>home</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string></string>
+						<key>originalValue</key>
+						<string>other</string>
+					</dict>
+				</array>
+				<key>relationshipConstraint</key>
+				<string>perSubType</string>
+				<key>relationshipSize</key>
+				<integer>1</integer>
+			</dict>
+		</dict>
+		<key>com.apple.contacts.URL</key>
+		<dict>
+			<key>type</key>
+			<dict>
+				<key>mappings</key>
+				<array>
+					<dict>
+						<key>mappedValue</key>
+						<string>WORK</string>
+						<key>originalValue</key>
+						<string>work</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>HOME</string>
+						<key>originalValue</key>
+						<string>home page</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string>HOME</string>
+						<key>originalValue</key>
+						<string>home</string>
+					</dict>
+					<dict>
+						<key>mappedValue</key>
+						<string></string>
+						<key>originalValue</key>
+						<string>other</string>
+					</dict>
+				</array>
+			</dict>
+			<key>value</key>
+			<dict>
+				<key>charsToStrip</key>
+				<string>\r,\n</string>
+				<key>maxLength</key>
+				<integer>500</integer>
+			</dict>
+		</dict>
+	</dict>
+</dict>
+</plist>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/apple/S60_RnD_32.phoneplugin/Contents/Resources/SyncEngine.plist	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>Entities</key>
+	<dict>
+		<key>com.apple.calendars.AudioAlarm</key>
+		<array>
+			<string>com.apple.syncservices.RecordEntityName</string>
+			<string>triggerdate</string>
+			<string>triggerduration</string>
+			<string>owner</string>
+		</array>
+		<key>com.apple.calendars.Calendar</key>
+		<array>
+			<string>com.apple.syncservices.RecordEntityName</string>
+			<string>title</string>
+			<string>read only</string>
+			<string>com.apple.PhoneConduitExtension.uid</string>
+		</array>
+		<key>com.apple.calendars.DisplayAlarm</key>
+		<array>
+			<string>com.apple.syncservices.RecordEntityName</string>
+			<string>triggerdate</string>
+			<string>triggerduration</string>
+			<string>owner</string>
+		</array>
+		<key>com.apple.calendars.Event</key>
+		<array>
+			<string>com.apple.syncservices.RecordEntityName</string>
+			<string>original date</string>
+			<string>all day</string>
+			<string>exception dates</string>
+			<string>calendar</string>
+			<string>recurrences</string>
+			<string>main event</string>
+			<string>detached events</string>
+			<string>audio alarms</string>
+			<string>display alarms</string>
+			<string>start date</string>
+			<string>location</string>
+			<string>summary</string>
+			<string>end date</string>
+			<string>description</string>
+			<string>classification</string>
+		</array>
+		<key>com.apple.calendars.Recurrence</key>
+		<array>
+			<string>com.apple.syncservices.RecordEntityName</string>
+			<string>frequency</string>
+			<string>count</string>
+			<string>until</string>
+			<string>interval</string>
+			<string>bymonth</string>
+			<string>byweeknumber</string>
+			<string>byyearday</string>
+			<string>bymonthday</string>
+			<string>bydayfreq</string>
+			<string>bydaydays</string>
+			<string>bysetpos</string>
+			<string>weekstartday</string>
+			<string>owner</string>
+		</array>
+		<key>com.apple.calendars.Task</key>
+		<array>
+			<string>com.apple.syncservices.RecordEntityName</string>
+			<string>due date is date only</string>
+			<string>calendar</string>
+			<string>audio alarms</string>
+			<string>display alarms</string>
+			<string>status</string>
+			<string>summary</string>
+			<string>completion date</string>
+			<string>description</string>
+			<string>due date</string>
+			<string>classification</string>
+			<string>priority</string>
+		</array>
+		<key>com.apple.contacts.Contact</key>
+		<array>
+			<string>com.apple.syncservices.RecordEntityName</string>
+			<string>title</string>
+			<string>suffix</string>
+			<string>image</string>
+			<string>last name</string>
+			<string>company name</string>
+			<string>first name</string>
+			<string>middle name</string>
+			<string>job title</string>
+			<string>nickname</string>
+			<string>notes</string>
+			<string>department</string>
+			<string>birthday</string>
+			<string>email addresses</string>
+			<string>phone numbers</string>
+			<string>URLs</string>
+			<string>street addresses</string>
+			<string>related names</string>
+			<string>dates</string>
+		</array>
+		<key>com.apple.contacts.Date</key>
+		<array>
+			<string>com.apple.syncservices.RecordEntityName</string>
+			<string>contact</string>
+			<string>value</string>
+			<string>type</string>
+		</array>
+		<key>com.apple.contacts.Email Address</key>
+		<array>
+			<string>com.apple.syncservices.RecordEntityName</string>
+			<string>contact</string>
+			<string>value</string>
+			<string>type</string>
+		</array>
+		<key>com.apple.contacts.Phone Number</key>
+		<array>
+			<string>com.apple.syncservices.RecordEntityName</string>
+			<string>contact</string>
+			<string>value</string>
+			<string>type</string>
+		</array>
+		<key>com.apple.contacts.Related Name</key>
+		<array>
+			<string>com.apple.syncservices.RecordEntityName</string>
+			<string>contact</string>
+			<string>value</string>
+			<string>type</string>
+		</array>
+		<key>com.apple.contacts.Street Address</key>
+		<array>
+			<string>com.apple.syncservices.RecordEntityName</string>
+			<string>contact</string>
+			<string>city</string>
+			<string>state</string>
+			<string>street</string>
+			<string>country</string>
+			<string>type</string>
+			<string>postal code</string>
+		</array>
+		<key>com.apple.contacts.URL</key>
+		<array>
+			<string>com.apple.syncservices.RecordEntityName</string>
+			<string>contact</string>
+			<string>value</string>
+			<string>type</string>
+		</array>
+	</dict>
+	<key>Type</key>
+	<string>device</string>
+</dict>
+</plist>
Binary file connectivitymodules/SeCon/apple/S60_RnD_32.phoneplugin/Contents/Resources/com.nokia.S6032.tiff has changed
Binary file connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Archive.bom has changed
Binary file connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Archive.pax.gz has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Info.plist	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleGetInfoString</key>
+	<string>0.0, Copyright 2006 Apple Computer, Inc.</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.apple.isyncpluginmaker.phoneplugin</string>
+	<key>CFBundleShortVersionString</key>
+	<string>0.0</string>
+	<key>IFMajorVersion</key>
+	<integer>1</integer>
+	<key>IFMinorVersion</key>
+	<integer>0</integer>
+	<key>IFPkgFlagAllowBackRev</key>
+	<false/>
+	<key>IFPkgFlagAuthorizationAction</key>
+	<string>AdminAuthorization</string>
+	<key>IFPkgFlagBackgroundAlignment</key>
+	<string>topleft</string>
+	<key>IFPkgFlagBackgroundScaling</key>
+	<string>none</string>
+	<key>IFPkgFlagDefaultLocation</key>
+	<string>/</string>
+	<key>IFPkgFlagFollowLinks</key>
+	<true/>
+	<key>IFPkgFlagInstallFat</key>
+	<false/>
+	<key>IFPkgFlagInstalledSize</key>
+	<integer>156</integer>
+	<key>IFPkgFlagIsRequired</key>
+	<false/>
+	<key>IFPkgFlagOverwritePermissions</key>
+	<false/>
+	<key>IFPkgFlagRelocatable</key>
+	<false/>
+	<key>IFPkgFlagRestartAction</key>
+	<string>NoRestart</string>
+	<key>IFPkgFlagRootVolumeOnly</key>
+	<true/>
+	<key>IFPkgFlagUpdateInstalledLanguages</key>
+	<false/>
+	<key>IFPkgFormatVersion</key>
+	<real>0.10000000149011612</real>
+	<key>IFRequirementDicts</key>
+	<array>
+		<dict>
+			<key>LabelKey</key>
+			<string>iSync24Label</string>
+			<key>MessageKey</key>
+			<string>iSync2XMessage</string>
+			<key>SpecArgument</key>
+			<string>/Applications/iSync.app/Contents/Info.plist</string>
+			<key>SpecProperty</key>
+			<string>CFBundleVersion</string>
+			<key>SpecType</key>
+			<string>plist</string>
+			<key>TestObject</key>
+			<string>500.134</string>
+			<key>TestOperator</key>
+			<string>ge</string>
+			<key>TitleKey</key>
+			<string>iSync24Title</string>
+		</dict>
+	</array>
+</dict>
+</plist>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/PkgInfo	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1 @@
+pkmkrpkg1
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Resources/Description.plist	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IFPkgDescriptionDescription</key>
+	<string>Description of a Phone Plug-in</string>
+	<key>IFPkgDescriptionTitle</key>
+	<string>the phone plug-in</string>
+</dict>
+</plist>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Resources/English.lproj/ReadMe.rtf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,6 @@
+{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410
+{\fonttbl\f0\fswiss\fcharset77 Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f0\fs24 \cf0 This package has been built by Nokia Corporation. It will install a phone plugin to enable iSync support for your phone E60}
\ No newline at end of file
Binary file connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Resources/IFRequirement.strings has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Resources/PhonePlugin.info	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,17 @@
+Title Phone Plug-in
+Version 
+Description 
+DefaultLocation /Library/PhonePlugins
+DeleteWarning 
+
+### Package Flags
+
+NeedsAuthorization NO
+Required YES
+Relocatable YES
+RequiresReboot NO
+UseUserMask NO
+OverwritePermissions NO
+InstallFat NO
+RootVolumeOnly YES
+OnlyUpdateInstalledLanguages NO
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Resources/TokenDefinitions.plist	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+    <key>iSyncToken</key>
+    <array>
+        <dict>
+            <key>searchPlugin</key>
+            <string>CommonAppSearch</string>
+            <key>path</key>
+            <string>/Applications/iSync.app</string>
+            <key>identifier</key>
+            <string>com.apple.isync</string>
+        </dict>
+    </array>
+</dict>
+</plist>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Resources/Welcome.rtf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,17 @@
+{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf380
+{\fonttbl\f0\fnil\fcharset77 LucidaGrande-Bold;\f1\fswiss\fcharset77 Helvetica;\f2\fnil\fcharset77 LucidaGrande;
+}
+{\colortbl;\red255\green255\blue255;\red1\green1\blue1;}
+\vieww9000\viewh8400\viewkind0
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f0\b\fs24 \cf0 Welcome to the iSync Phone Plug-in for Mac OS X Installer
+\f1\b0 \
+\
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f2\fs22 \cf0 iSync for Mac OS X is synchronization software that keeps your Address Book contacts and iCal calendar and to-do information in sync between your Mac OS computers and iSync-compatible mobile phones.\
+\
+This installer guides you through the steps necessary to install an iSync Phone Plug-in for Mac OS X. To get started, click Continue.
+\f1\fs24 \cf2 \
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Resources/en.lproj/Description.plist	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IFPkgDescriptionDescription</key>
+	<string></string>
+	<key>IFPkgDescriptionTitle</key>
+	<string>367C0F5C-1E53-44A3-AEA5-54D1EEE12F29-installerRoot</string>
+</dict>
+</plist>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/apple/S60_RnD_32.pkg/Contents/Resources/package_version	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,2 @@
+major: 1
+minor: 0
\ No newline at end of file
Binary file connectivitymodules/SeCon/apple/S60_RnD_32.ppdoc/Icon.tiff has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/apple/S60_RnD_32.ppdoc/InstallerReadMe-en.rtf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,6 @@
+{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410
+{\fonttbl\f0\fswiss\fcharset77 Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f0\fs24 \cf0 This package has been built by Nokia Corporation. It will install a phone plugin to enable iSync support for your phone E60}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/apple/S60_RnD_32.ppdoc/Properties.plist	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1358 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>TramontaneVersion</key>
+	<string>597.0</string>
+	<key>UUID</key>
+	<string>367C0F5C-1E53-44A3-AEA5-54D1EEE12F29</string>
+	<key>properties</key>
+	<dict>
+		<key>BTOptionsDict</key>
+		<dict>
+			<key>OBEXTimeout</key>
+			<string>60</string>
+			<key>TransportType</key>
+			<integer>0</integer>
+			<key>synchroScriptConnect</key>
+			<false/>
+			<key>synchroScriptDisconnect</key>
+			<false/>
+		</dict>
+		<key>UISettingsOptionsDict</key>
+		<dict>
+			<key>DontSyncEventsAfterDateIsEnabled</key>
+			<dict>
+				<key>default</key>
+				<integer>0</integer>
+				<key>visible</key>
+				<true/>
+			</dict>
+			<key>DontSyncEventsAfterDateValue</key>
+			<dict>
+				<key>default</key>
+				<string>1month</string>
+				<key>visible</key>
+				<true/>
+			</dict>
+			<key>DontSyncEventsPriorToDateIsEnabled</key>
+			<dict>
+				<key>default</key>
+				<integer>0</integer>
+				<key>visible</key>
+				<false/>
+			</dict>
+			<key>DontSyncEventsPriorToDateValue</key>
+			<dict>
+				<key>default</key>
+				<string>1week</string>
+				<key>visible</key>
+				<true/>
+			</dict>
+			<key>OnlySyncContactsWithPhoneNumber</key>
+			<dict>
+				<key>default</key>
+				<integer>1</integer>
+				<key>visible</key>
+				<true/>
+			</dict>
+			<key>SyncAllDayEventsKey</key>
+			<dict>
+				<key>default</key>
+				<integer>0</integer>
+				<key>visible</key>
+				<false/>
+			</dict>
+		</dict>
+		<key>USBOptionsDict</key>
+		<dict>
+			<key>OBEXTimeout</key>
+			<string>60</string>
+			<key>identificationCDCChannel</key>
+			<integer>0</integer>
+			<key>identificationScriptConnect</key>
+			<false/>
+			<key>identificationScriptDisconnect</key>
+			<false/>
+			<key>synchroCDCChannel</key>
+			<integer>1</integer>
+			<key>synchroOBEXChannel</key>
+			<integer>0</integer>
+			<key>synchroScriptConnect</key>
+			<false/>
+			<key>synchroScriptDisconnect</key>
+			<false/>
+			<key>useOBEX</key>
+			<true/>
+			<key>useOtherCDC</key>
+			<false/>
+			<key>useSameCDC</key>
+			<false/>
+		</dict>
+		<key>advancedOptionsSettings</key>
+		<dict>
+			<key>com_apple_pimsync_contacts</key>
+			<dict>
+				<key>DataClassName</key>
+				<string>Contacts</string>
+				<key>MaxAddAndReplaceCmd</key>
+				<integer>0</integer>
+				<key>MaxDeleteCmd</key>
+				<integer>0</integer>
+				<key>MaxSyncCmd</key>
+				<real>1</real>
+				<key>needsDeleteAddOnModify</key>
+				<integer>1</integer>
+			</dict>
+			<key>com_apple_pimsync_events</key>
+			<dict>
+				<key>DataClassName</key>
+				<string>Calendar</string>
+				<key>MaxAddAndReplaceCmd</key>
+				<integer>0</integer>
+				<key>MaxDeleteCmd</key>
+				<integer>0</integer>
+				<key>MaxSyncCmd</key>
+				<integer>0</integer>
+				<key>allDayInLocalDateTime</key>
+				<integer>1</integer>
+				<key>allowedAlarmRelativeValues</key>
+				<string></string>
+				<key>countValueWhenMissing</key>
+				<integer>0</integer>
+				<key>defaultUntilDateWhenMissing</key>
+				<string></string>
+				<key>doNotSyncAlarmForADE</key>
+				<false/>
+				<key>doNotSyncAlarmIfAfterStartDateTime</key>
+				<integer>1</integer>
+				<key>dontSyncEventBeforeDate</key>
+				<string></string>
+				<key>exDatesAreDateOnly</key>
+				<false/>
+				<key>handleMultiDayRecurrent</key>
+				<true/>
+				<key>hasAllDayMultiDay</key>
+				<true/>
+				<key>maxMinutesNbDeltaForAlarm</key>
+				<integer>0</integer>
+				<key>needsDeleteAddOnModify</key>
+				<integer>0</integer>
+				<key>noNewLines</key>
+				<integer>0</integer>
+				<key>onlyAsciiCharacters</key>
+				<false/>
+				<key>syncAlarmOnlyIfSameDayAsADEStartDate</key>
+				<false/>
+				<key>untilDateIsDateOnly</key>
+				<integer>1</integer>
+			</dict>
+			<key>com_apple_pimsync_parser_vCal</key>
+			<dict>
+				<key>AllDayCategories</key>
+				<string>REMINDER</string>
+				<key>EscapeBackslash</key>
+				<integer>1</integer>
+				<key>EscapeSemicolonInNotComponedValues</key>
+				<integer>1</integer>
+				<key>EscapeStrings</key>
+				<string></string>
+				<key>ExDatesInLocal</key>
+				<false/>
+				<key>IgnoreProperties</key>
+				<string>X-IRMC-LUID</string>
+				<key>PropertyNameMapping</key>
+				<array/>
+				<key>SetExDateTimeWithEndTime</key>
+				<false/>
+				<key>SetExDateTimeWithStartTime</key>
+				<false/>
+				<key>SetUntilTimeWithEndTime</key>
+				<integer>0</integer>
+				<key>SetUntilTimeWithStartTime</key>
+				<integer>1</integer>
+				<key>TimedCategories</key>
+				<string>MEETING</string>
+				<key>UntilDateInLocal</key>
+				<integer>1</integer>
+			</dict>
+			<key>com_apple_pimsync_parser_vCard</key>
+			<dict>
+				<key>AddCRLFAfterBase64Folding</key>
+				<integer>1</integer>
+				<key>IgnoreSubTypesForThisMainTypes</key>
+				<string>CELL</string>
+				<key>PropertyNameMapping</key>
+				<array>
+					<dict>
+						<key>key</key>
+						<string>X-NICKNAME</string>
+						<key>value</key>
+						<string>X-EPOCSECONDNAME</string>
+					</dict>
+				</array>
+			</dict>
+			<key>com_apple_pimsync_tasks</key>
+			<dict>
+				<key>DataClassName</key>
+				<string>Tasks</string>
+				<key>MaxAddAndReplaceCmd</key>
+				<integer>0</integer>
+				<key>MaxDeleteCmd</key>
+				<integer>0</integer>
+				<key>MaxSyncCmd</key>
+				<integer>0</integer>
+				<key>completionDateIsDateOnly</key>
+				<false/>
+				<key>defaultDueDateValueWhenMissing</key>
+				<string></string>
+				<key>defaultDueDateWhenMissing</key>
+				<string></string>
+				<key>doNotSyncAlarmForTask</key>
+				<false/>
+				<key>doNotSyncAlarmIfCompleted</key>
+				<integer>1</integer>
+				<key>dueDateIsDateOnly</key>
+				<false/>
+				<key>needsDeleteAddOnModify</key>
+				<false/>
+				<key>setDueDateToCompletionDateIfCompleted</key>
+				<false/>
+			</dict>
+			<key>com_apple_synchro</key>
+			<dict>
+				<key>SyncMLCodec</key>
+				<integer>0</integer>
+				<key>SyncMLDoNotTryToDetectPhoneDBReset</key>
+				<false/>
+				<key>SyncMLLocalSource</key>
+				<string>iSync</string>
+				<key>SyncMLMaxMsgSize</key>
+				<real>65535</real>
+				<key>SyncMLMaxObjSize</key>
+				<real>786432</real>
+				<key>SyncMLMsgTemporization</key>
+				<real>500000</real>
+				<key>SyncMLNoPropertiesCapabilitiesInDevInf</key>
+				<false/>
+				<key>SyncMLSendDevInfIntoPutIfNoGetReceived</key>
+				<integer>0</integer>
+				<key>SyncMLUseBinaryWBXMLPublicID</key>
+				<false/>
+			</dict>
+		</dict>
+		<key>calendarsOptionsDict</key>
+		<dict>
+			<key>Charset</key>
+			<string>UTF-8</string>
+			<key>FoldingStyle</key>
+			<string>FoldingNG</string>
+			<key>RemoteName</key>
+			<string>/</string>
+			<key>allDayFormat</key>
+			<integer>3</integer>
+			<key>eventRecurrenceEndType</key>
+			<integer>1</integer>
+			<key>hasAudioAlarm</key>
+			<true/>
+			<key>hasDisplayAlarm</key>
+			<false/>
+			<key>hasEvent</key>
+			<true/>
+			<key>hasTimeZone</key>
+			<integer>1</integer>
+			<key>hasVCalRecurrence</key>
+			<true/>
+		</dict>
+		<key>contactsOptionsDict</key>
+		<dict>
+			<key>RemoteName</key>
+			<string>/</string>
+			<key>firstAndLastNameInSameField</key>
+			<false/>
+			<key>needsCompanyNameInFirstName</key>
+			<integer>0</integer>
+			<key>needsFullAddressInStreetField</key>
+			<false/>
+		</dict>
+		<key>documentVersion</key>
+		<integer>556</integer>
+		<key>extraOptionsSettings</key>
+		<dict/>
+		<key>familyOptionsDict</key>
+		<dict>
+			<key>BTAvailable</key>
+			<true/>
+			<key>BluetoothAvailable</key>
+			<true/>
+			<key>CGMI</key>
+			<string>Nokia</string>
+			<key>CGMM</key>
+			<string>Nokia 6290</string>
+			<key>GMI</key>
+			<string>Nokia</string>
+			<key>GMM</key>
+			<string>Nokia 6290</string>
+			<key>ModelID</key>
+			<string>com.nokia.S6032</string>
+			<key>Name</key>
+			<string>S60-32</string>
+			<key>PluginProviderName</key>
+			<string>Nokia</string>
+			<key>ProductID</key>
+			<string>0x0500</string>
+			<key>USBAvailable</key>
+			<true/>
+			<key>VendorID</key>
+			<string>0x0421</string>
+			<key>connection</key>
+			<integer>2</integer>
+			<key>constructorName</key>
+			<string>Nokia</string>
+			<key>domainName</key>
+			<string>nokia.com</string>
+			<key>fixedDatabasesNames</key>
+			<integer>0</integer>
+			<key>pluginVersion</key>
+			<string>1.0</string>
+			<key>supportURL</key>
+			<string>http://www.nokia.com/support</string>
+			<key>useCGMICGMM</key>
+			<false/>
+		</dict>
+		<key>javaScriptDict</key>
+		<dict>
+			<key>btObexConnection</key>
+			<dict>
+				<key>Value</key>
+				<string>function prepareChannelForProtocol()
+{
+    // You can customize this function but do NOT change the signature
+}</string>
+			</dict>
+			<key>btObexDisconnection</key>
+			<dict>
+				<key>Value</key>
+				<string>function unprepareChannelForProtocol()
+{
+    // You can customize this function but do NOT change the signature
+}</string>
+			</dict>
+			<key>usbCdcConnection</key>
+			<dict>
+				<key>Value</key>
+				<string>function prepareChannelForProtocol()
+{
+    // You can customize this function but do NOT change the signature
+}</string>
+			</dict>
+			<key>usbCdcDisconnection</key>
+			<dict>
+				<key>Value</key>
+				<string>function unprepareChannelForProtocol()
+{
+    // You can customize this function but do NOT change the signature
+}</string>
+			</dict>
+			<key>usbObexConnection</key>
+			<dict>
+				<key>Value</key>
+				<string>function prepareChannelForProtocol()
+{
+    // You can customize this function but do NOT change the signature
+}</string>
+			</dict>
+			<key>usbObexDisconnection</key>
+			<dict>
+				<key>Value</key>
+				<string>function unprepareChannelForProtocol()
+{
+    // You can customize this function but do NOT change the signature
+}</string>
+			</dict>
+		</dict>
+		<key>notes</key>
+		<data>
+		WW91IGNhbiBzYXZlIGFueSBraW5kIG9mIGluZm9ybWF0aW9uIG9uIHRoZSBw
+		bHVnaW4gaGVyZS4KVGhleSB3b24ndCBiZSBleHBvcnRlZCBpbiB0aGUgcGx1
+		Z2luLg==
+		</data>
+		<key>syncFieldsSettings</key>
+		<dict>
+			<key>com_apple_calendars_Event</key>
+			<dict>
+				<key>classification</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>mappings</key>
+					<array>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>PUBLIC</string>
+							<key>originalValue</key>
+							<string>public</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>PRIVATE</string>
+							<key>originalValue</key>
+							<string>private</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>PRIVATE</string>
+							<key>originalValue</key>
+							<string>confidential</string>
+						</dict>
+					</array>
+				</dict>
+				<key>description</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>500</real>
+				</dict>
+				<key>end date</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+				</dict>
+				<key>location</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+				<key>start date</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+				</dict>
+				<key>summary</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>DontNeedCheckBox</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>500</real>
+				</dict>
+			</dict>
+			<key>com_apple_calendars_Task</key>
+			<dict>
+				<key>classification</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>mappings</key>
+					<array>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>PUBLIC</string>
+							<key>originalValue</key>
+							<string>public</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>PRIVATE</string>
+							<key>originalValue</key>
+							<string>private</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>PRIVATE</string>
+							<key>originalValue</key>
+							<string>confidential</string>
+						</dict>
+					</array>
+				</dict>
+				<key>completion date</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+				</dict>
+				<key>description</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+				<key>due date</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+				</dict>
+				<key>priority</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>mappings</key>
+					<array>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>originalValue</key>
+							<integer>0</integer>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>1</string>
+							<key>originalValue</key>
+							<integer>1</integer>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>2</string>
+							<key>originalValue</key>
+							<integer>2</integer>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>3</string>
+							<key>originalValue</key>
+							<integer>3</integer>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>4</string>
+							<key>originalValue</key>
+							<integer>4</integer>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>5</string>
+							<key>originalValue</key>
+							<integer>5</integer>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>6</string>
+							<key>originalValue</key>
+							<integer>6</integer>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>7</string>
+							<key>originalValue</key>
+							<integer>7</integer>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>8</string>
+							<key>originalValue</key>
+							<integer>8</integer>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>9</string>
+							<key>originalValue</key>
+							<integer>9</integer>
+						</dict>
+					</array>
+				</dict>
+				<key>status</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>mappings</key>
+					<array>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>DECLINED</string>
+							<key>originalValue</key>
+							<string>cancelled</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>NEEDS ACTION</string>
+							<key>originalValue</key>
+							<string>needsaction</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>COMPLETED</string>
+							<key>originalValue</key>
+							<string>completed</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>ACCEPTED</string>
+							<key>originalValue</key>
+							<string>inprocess</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string></string>
+							<key>originalValue</key>
+							<string>none</string>
+						</dict>
+					</array>
+				</dict>
+				<key>summary</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>DontNeedCheckBox</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+			</dict>
+			<key>com_apple_contacts_Contact</key>
+			<dict>
+				<key>birthday</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+				</dict>
+				<key>company name</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>DontNeedCheckBox</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+				<key>department</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+				<key>first name</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>DontNeedCheckBox</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+				<key>image</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>maxLength</key>
+					<integer>0</integer>
+				</dict>
+				<key>job title</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+				<key>last name</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>DontNeedCheckBox</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+				<key>middle name</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+				<key>nickname</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+				<key>notes</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>maxLength</key>
+					<real>1000</real>
+				</dict>
+				<key>suffix</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+				<key>title</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+			</dict>
+			<key>com_apple_contacts_Date</key>
+			<dict>
+				<key>IPSGlobalEntity</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+				</dict>
+				<key>type</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>mappings</key>
+					<array>
+						<dict>
+							<key>activated</key>
+							<false/>
+							<key>mappedValue</key>
+							<string>X-ANNIVERSARY</string>
+							<key>originalValue</key>
+							<string>anniversary</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<false/>
+							<key>mappedValue</key>
+							<string>X-DATE</string>
+							<key>originalValue</key>
+							<string>other</string>
+						</dict>
+					</array>
+				</dict>
+				<key>value</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+				</dict>
+			</dict>
+			<key>com_apple_contacts_Email Address</key>
+			<dict>
+				<key>IPSGlobalEntity</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+				</dict>
+				<key>type</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>mappings</key>
+					<array>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>WORK</string>
+							<key>originalValue</key>
+							<string>work</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>HOME</string>
+							<key>originalValue</key>
+							<string>home</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>INTERNET</string>
+							<key>originalValue</key>
+							<string>other</string>
+						</dict>
+					</array>
+				</dict>
+				<key>value</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>DontNeedCheckBox</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+			</dict>
+			<key>com_apple_contacts_Phone Number</key>
+			<dict>
+				<key>IPSGlobalEntity</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+				</dict>
+				<key>type</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>mappings</key>
+					<array>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>WORK</string>
+							<key>originalValue</key>
+							<string>work</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>HOME</string>
+							<key>originalValue</key>
+							<string>home</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>CELL</string>
+							<key>originalValue</key>
+							<string>mobile</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>FAX</string>
+							<key>originalValue</key>
+							<string>work fax</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>FAX</string>
+							<key>originalValue</key>
+							<string>home fax</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string></string>
+							<key>originalValue</key>
+							<string>other</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string></string>
+							<key>originalValue</key>
+							<string>main</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>PAGER</string>
+							<key>originalValue</key>
+							<string>pager</string>
+						</dict>
+					</array>
+				</dict>
+				<key>value</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>DontNeedCheckBox</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>2</integer>
+					<key>charsToKeep</key>
+					<string>0123456789+#*pw</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+			</dict>
+			<key>com_apple_contacts_Related Name</key>
+			<dict>
+				<key>IPSGlobalEntity</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+				</dict>
+				<key>type</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>mappings</key>
+					<array>
+						<dict>
+							<key>activated</key>
+							<false/>
+							<key>mappedValue</key>
+							<string>X-FATHER</string>
+							<key>originalValue</key>
+							<string>father</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<false/>
+							<key>mappedValue</key>
+							<string>X-MOTHER</string>
+							<key>originalValue</key>
+							<string>mother</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<false/>
+							<key>mappedValue</key>
+							<string>X-PARENT</string>
+							<key>originalValue</key>
+							<string>parent</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>X-CHILDREN</string>
+							<key>originalValue</key>
+							<string>child</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<false/>
+							<key>mappedValue</key>
+							<string>X-BROTHER</string>
+							<key>originalValue</key>
+							<string>brother</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<false/>
+							<key>mappedValue</key>
+							<string>X-SISTER</string>
+							<key>originalValue</key>
+							<string>sister</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<false/>
+							<key>mappedValue</key>
+							<string>X-FRIEND</string>
+							<key>originalValue</key>
+							<string>friend</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>X-SPOUSE</string>
+							<key>originalValue</key>
+							<string>spouse</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<false/>
+							<key>mappedValue</key>
+							<string>X-PARTNER</string>
+							<key>originalValue</key>
+							<string>partner</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>X-ASSISTANT</string>
+							<key>originalValue</key>
+							<string>assistant</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<false/>
+							<key>mappedValue</key>
+							<string>X-MANAGER</string>
+							<key>originalValue</key>
+							<string>manager</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<false/>
+							<key>mappedValue</key>
+							<string>X-NAME</string>
+							<key>originalValue</key>
+							<string>other</string>
+						</dict>
+					</array>
+				</dict>
+				<key>value</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>DontNeedCheckBox</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+			</dict>
+			<key>com_apple_contacts_Street Address</key>
+			<dict>
+				<key>IPSGlobalEntity</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+				</dict>
+				<key>city</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+				<key>country</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+				<key>postal code</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+				<key>state</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+				<key>street</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>DontNeedCheckBox</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>255</real>
+				</dict>
+				<key>type</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>mappings</key>
+					<array>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>WORK</string>
+							<key>originalValue</key>
+							<string>work</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>HOME</string>
+							<key>originalValue</key>
+							<string>home</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string></string>
+							<key>originalValue</key>
+							<string>other</string>
+						</dict>
+					</array>
+					<key>relationshipLimitKind</key>
+					<integer>2</integer>
+				</dict>
+			</dict>
+			<key>com_apple_contacts_URL</key>
+			<dict>
+				<key>IPSGlobalEntity</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+				</dict>
+				<key>type</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>mappings</key>
+					<array>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>WORK</string>
+							<key>originalValue</key>
+							<string>work</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>HOME</string>
+							<key>originalValue</key>
+							<string>home page</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string>HOME</string>
+							<key>originalValue</key>
+							<string>home</string>
+						</dict>
+						<dict>
+							<key>activated</key>
+							<true/>
+							<key>mappedValue</key>
+							<string></string>
+							<key>originalValue</key>
+							<string>other</string>
+						</dict>
+					</array>
+				</dict>
+				<key>value</key>
+				<dict>
+					<key>Activated</key>
+					<true/>
+					<key>DontNeedCheckBox</key>
+					<true/>
+					<key>charsFiltering</key>
+					<integer>1</integer>
+					<key>charsToStrip</key>
+					<string>\r,\n</string>
+					<key>maxLength</key>
+					<real>500</real>
+				</dict>
+			</dict>
+		</dict>
+		<key>syncMLOptionsDict</key>
+		<dict>
+			<key>SyncMLBusySignalingInterval</key>
+			<real>60</real>
+			<key>SyncMLBusySignalingSupport</key>
+			<true/>
+			<key>SyncMLLargeObjectSupport</key>
+			<true/>
+			<key>SyncMLMaxSyncCmdNbInEncodedMsg</key>
+			<real>30</real>
+			<key>SyncMLNumberOfChangesSupport</key>
+			<true/>
+			<key>SyncMLOnlyOneBusySignaling</key>
+			<false/>
+			<key>SyncMLRefreshFromServerSupport</key>
+			<true/>
+			<key>SyncMLRemoteNeedsRelativePaths</key>
+			<false/>
+			<key>SyncMLSimulateBusySignalingWithEmptySync</key>
+			<false/>
+			<key>SyncMLVersion</key>
+			<string>SyncML11</string>
+			<key>limitSyncCmd</key>
+			<false/>
+		</dict>
+		<key>tasksOptionsDict</key>
+		<dict>
+			<key>RemoteName</key>
+			<string>Tasks</string>
+			<key>hasDifferentDataclassesForTasksAndEvents</key>
+			<false/>
+			<key>hasTasks</key>
+			<true/>
+		</dict>
+		<key>vCalRecSettings</key>
+		<dict>
+			<key>com_apple_pimsync_events</key>
+			<dict>
+				<key>handleAllDayRecurrent</key>
+				<true/>
+			</dict>
+			<key>com_apple_pimsync_parser_vCal</key>
+			<dict>
+				<key>vCalExDatesSupport</key>
+				<true/>
+				<key>vCalRecDaily</key>
+				<true/>
+				<key>vCalRecDailyInterval</key>
+				<string></string>
+				<key>vCalRecDropIfUseless</key>
+				<integer>1</integer>
+				<key>vCalRecMaxExDatesNb</key>
+				<integer>0</integer>
+				<key>vCalRecMonthlyByDay</key>
+				<true/>
+				<key>vCalRecMonthlyByDayOnlyOnStartDateMonthDay</key>
+				<false/>
+				<key>vCalRecMonthlyByDayOnlyOneMonthDay</key>
+				<false/>
+				<key>vCalRecMonthlyByDayWithMonthDay</key>
+				<true/>
+				<key>vCalRecMonthlyByPos</key>
+				<true/>
+				<key>vCalRecMonthlyByPosOnlyOnStartDateWeekDay</key>
+				<false/>
+				<key>vCalRecMonthlyByPosOnlyOneWeekDay</key>
+				<false/>
+				<key>vCalRecMonthlyInterval</key>
+				<string></string>
+				<key>vCalRecOnlyForever</key>
+				<false/>
+				<key>vCalRecWeekly</key>
+				<true/>
+				<key>vCalRecWeeklyInterval</key>
+				<string></string>
+				<key>vCalRecWeeklyOnlyOnStartDateWeekDay</key>
+				<false/>
+				<key>vCalRecWeeklyOnlyOneWeekDay</key>
+				<false/>
+				<key>vCalRecWeeklyWithWeekDay</key>
+				<true/>
+				<key>vCalRecYearlyByMonth</key>
+				<true/>
+				<key>vCalRecYearlyByMonthInterval</key>
+				<string></string>
+				<key>vCalRecYearlyByMonthOnlyOnStartDateMonthNumber</key>
+				<false/>
+				<key>vCalRecYearlyByMonthOnlyOneMonthNumber</key>
+				<false/>
+				<key>vCalRecYearlyByMonthWithMonthNumber</key>
+				<true/>
+			</dict>
+		</dict>
+	</dict>
+	<key>version</key>
+	<integer>0</integer>
+</dict>
+</plist>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/catalogspcconnectivityplugin/bwins/catalogspcconnectivitypluginu.def	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,10 @@
+EXPORTS
+	??1CCatalogsPCConnectivityPlugin@@UAE@XZ @ 1 NONAME ; CCatalogsPCConnectivityPlugin::~CCatalogsPCConnectivityPlugin(void)
+	?Close@CCatalogsPCConnectivityPlugin@@QAEXXZ @ 2 NONAME ; void CCatalogsPCConnectivityPlugin::Close(void)
+	?Connect@CCatalogsPCConnectivityPlugin@@QAEHXZ @ 3 NONAME ; int CCatalogsPCConnectivityPlugin::Connect(void)
+	?GetDataL@CCatalogsPCConnectivityPlugin@@QAEXAAVTDataType@@AAVCBufFlat@@@Z @ 4 NONAME ; void CCatalogsPCConnectivityPlugin::GetDataL(class TDataType &, class CBufFlat &)
+	?NewL@CCatalogsPCConnectivityPlugin@@SAPAV1@XZ @ 5 NONAME ; class CCatalogsPCConnectivityPlugin * CCatalogsPCConnectivityPlugin::NewL(void)
+	?NewLC@CCatalogsPCConnectivityPlugin@@SAPAV1@XZ @ 6 NONAME ; class CCatalogsPCConnectivityPlugin * CCatalogsPCConnectivityPlugin::NewLC(void)
+	?PutDataL@CCatalogsPCConnectivityPlugin@@QAEXABVTDataType@@ABVCBufFlat@@@Z @ 7 NONAME ; void CCatalogsPCConnectivityPlugin::PutDataL(class TDataType const &, class CBufFlat const &)
+	?SupportedMimeTypesL@CCatalogsPCConnectivityPlugin@@QAE?AV?$RPointerArray@VTDataType@@@@XZ @ 8 NONAME ; class RPointerArray<class TDataType> CCatalogsPCConnectivityPlugin::SupportedMimeTypesL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/catalogspcconnectivityplugin/eabi/catalogspcconnectivitypluginu.def	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,14 @@
+EXPORTS
+	_ZN29CCatalogsPCConnectivityPlugin19SupportedMimeTypesLEv @ 1 NONAME
+	_ZN29CCatalogsPCConnectivityPlugin4NewLEv @ 2 NONAME
+	_ZN29CCatalogsPCConnectivityPlugin5CloseEv @ 3 NONAME
+	_ZN29CCatalogsPCConnectivityPlugin5NewLCEv @ 4 NONAME
+	_ZN29CCatalogsPCConnectivityPlugin7ConnectEv @ 5 NONAME
+	_ZN29CCatalogsPCConnectivityPlugin8GetDataLER9TDataTypeR8CBufFlat @ 6 NONAME
+	_ZN29CCatalogsPCConnectivityPlugin8PutDataLERK9TDataTypeRK8CBufFlat @ 7 NONAME
+	_ZN29CCatalogsPCConnectivityPluginD0Ev @ 8 NONAME
+	_ZN29CCatalogsPCConnectivityPluginD1Ev @ 9 NONAME
+	_ZN29CCatalogsPCConnectivityPluginD2Ev @ 10 NONAME
+	_ZTI29CCatalogsPCConnectivityPlugin @ 11 NONAME ; #<TI>#
+	_ZTV29CCatalogsPCConnectivityPlugin @ 12 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/catalogspcconnectivityplugin/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build info file for Catalogs PC Connectivity Plugin
+*
+*/
+
+
+PRJ_MMPFILES
+
+catalogspcconnectivityplugin.mmp
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/catalogspcconnectivityplugin/group/catalogspcconnectivityplugin.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project Catalogs PC Connectivity
+*                Plugin
+*
+*/
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET                  catalogspcconnectivityplugin.dll
+TARGETTYPE              dll
+UID                     0x1000008D 0x10207E73
+
+CAPABILITY              CAP_ECOM_PLUGIN
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+SOURCE                  catalogspcconnectivityplugin.cpp
+SOURCE                  catalogspcconnectivityclient.cpp
+
+USERINCLUDE             ../inc
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY                 euser.lib
+LIBRARY                 apmime.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/catalogspcconnectivityplugin/inc/catalogspcconnectivityclient.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,145 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is a client which communicate with the server 
+*                CatalogsEnginePCClientFrontEnd 
+*
+*/
+
+
+#ifndef R_CATALOGSPCCONNECTIVITYCLIENT_H
+#define R_CATALOGSPCCONNECTIVITYCLIENT_H
+
+#include <e32base.h>
+#include <apmstd.h>
+
+/**
+ *  This client communicate with the server CatalogsEnginePCClientFrontEnd
+ *
+ *  This class get requests from CatalogsPCConnectivityPlugin. 
+ *  Class itself is client in client-server solution. When request 
+ *  is received it will start the server (CatalogsEnginePCClientFrontEnd). 
+ *  This client class is dummy, the server have all the functionality.
+ *
+ *  @lib catalogspcconnectivityplugin
+ *  @since S60 v3.1
+ */
+class RCatalogsPCConnectivityClient : public RSessionBase
+    {
+public:
+
+    /**
+     * Constructor
+     *
+     * @since S60 v3.1
+     */
+    RCatalogsPCConnectivityClient();
+
+    /**
+     * Destructor
+     *
+     * @since S60 v3.1
+     */
+    ~RCatalogsPCConnectivityClient();
+
+    /**
+     * A connection is formed to the Catalogs engine pc client front-end.
+     * This will start up the front-end server and connect to it 
+     *
+     * @since S60 v3.1
+     * @return TInt Standard error code, KErrNone if connection is formed
+     *         or the connection was formed already     
+     */
+    TInt Connect();
+
+    /**
+     * The connection to the Catalogs engine front-end is closed
+     *
+     * @since S60 v3.1
+     */
+    void Close();
+
+    /**
+     * All MIME types supported by this component can be asked using this method
+     *
+     * @since S60 v3.1
+     * @return RPointerArray< TDataType > contain all supported MIME types
+     *         RPointerArray TDataTypes have allocated using new, caller
+     *         have to remember to delete them properly
+     * @exeption Leaves with standard error codes
+     */
+    RPointerArray<TDataType> SupportedMimeTypesL();
+
+    /**
+     * A data packet of max length 65535 (0xFFFF) bytes is synchronously
+     * sent to the Catalogs engine front-end
+     * Usage: After PutDataL have been called, you have to call GetDataL
+     *        before you can call PutDataL again
+     *
+     * @since S60 v3.1
+     * @param aMimeType data packet MIME type
+     * @param aData data buffer to read from
+     * @exeption Leaves with standard error codes
+     */
+    void PutDataL( const TDataType& aMimeType, 
+        const CBufFlat& aData );
+
+    /**
+     * A data packet is synchronously transfered from the Catalogs front-end
+     * and returned to caller 
+     * Usage: Everytime before calling GetDataL, you have to call PutDataL.
+     *        So you can't call GetData in sequentially.
+     *
+     * @since S60 v3.1
+     * @param aMimeType data packet MIME type
+     * @param aData data buffer to write to. Will call ExpandL function
+     *        for aData, but never more than max length 65535 (OxFFFF)
+     * @return nothing, but parameter aData work as return buffer
+     * @exeption Leaves with standard error codes
+     */                                                          
+    void GetDataL( TDataType& aMimeType, CBufFlat& aData );
+
+    
+private:
+
+// private functions
+
+    /**
+     * Returns the earliest version number of the server that we can talk to
+     *
+     * @since S60 v3.1
+     * @return TVersion Earliest version number we can talk to
+     */
+    TVersion Version() const;
+
+    /**
+     * Start server if it isn't running already
+     *
+     * @since S60 v3.1
+     * @return TInt Standard error code, KErrNone if server was running
+     *         already or start was succesfull     
+     */
+    TInt StartServer();
+
+    /**
+     * Create server process
+     *
+     * @since S60 v3.1
+     * @return TInt standard error code, KErrNone when creation was success
+     */
+    TInt CreateServerProcess();
+
+    };
+
+#endif // R_CATALOGSPCCONNECTIVITYCLIENT_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/catalogspcconnectivityplugin/inc/catalogspcconnectivitydefines.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Server information that the client needs
+*
+*/
+
+
+#include <e32base.h>
+
+/**  Server name */
+_LIT( KCatalogsPCConnectivityServerName, 
+    "CatalogsPCConnectivityServer" );
+
+/** Semaphore that is used when creating a new server */
+_LIT( KCatalogsPCConnectivityServerSemaphoreName, 
+    "CATALOGSPCCONNECTIVITYSemaphore" );
+
+/** File that is passed to the new server-process for execution */
+_LIT( KCatalogsPCConnectivityServerFilename, 
+    "catalogsenginepcclientfrontend" );
+
+// Default message slot amount in a session
+const TUint KCatalogsPCConnectivityDefaultMessageSlots = 255;
+
+/**  Version numbers */
+const TUint KCatalogsPCConnectivityMajorVersionNumber=1;
+const TUint KCatalogsPCConnectivityMinorVersionNumber=0;
+const TUint KCatalogsPCConnectivityBuildVersionNumber=0;
+
+/**  Function opcodes used in message passing between client and server */
+enum TCatalogsPCConnectivityServRqst
+    {
+    ECatalogsPCConnectivitySupportedMimeTypes = 1,
+    ECatalogsPCConnectivityPutData,
+    ECatalogsPCConnectivityGetData,
+    ECatalogsPCConnectivityGetSize
+    };
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/catalogspcconnectivityplugin/inc/catalogspcconnectivityplugin.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,147 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This plugin enables the Catalogs PC client to communicate 
+*                with the Catalogs engine
+*
+*/
+
+
+#ifndef C_CATALOGSPCCONNECTIVITYPLUGIN_H
+#define C_CATALOGSPCCONNECTIVITYPLUGIN_H
+
+#include "catalogspcconnectivityclient.h"
+
+/**
+ *  Plugin enables Catalogs PC client to communicate with the Catalogs engine
+ *
+ *  This class get requests from Catalogs PC client. It passes the requests
+ *  to client CatalogsPCConnectivityClient
+ *
+ *  @lib catalogspcconnectivityplugin
+ *  @since S60 v3.1
+ */
+class CCatalogsPCConnectivityPlugin : public CBase
+    {
+public:
+
+    /**
+     * Standard symbian object construction first phase
+     *
+     * @since S60 v3.1
+     * @return CCatalogsPCConnectivityPlugin pointer
+     */
+    IMPORT_C static  CCatalogsPCConnectivityPlugin* NewL();
+
+    /**
+     * Standard symbian object constructing first phase
+     *
+     * @since S60 v3.1
+     * @return CCatalogsPCConnectivityPlugin pointer
+     */
+    IMPORT_C static  CCatalogsPCConnectivityPlugin* NewLC();
+
+    /**
+     * Destructor
+     *
+     * @since S60 v3.1
+     */
+    IMPORT_C virtual ~CCatalogsPCConnectivityPlugin();
+
+    /**
+     * A connection is formed to the Catalogs engine pc client front-end.
+     * This will start up the front-end server and connect to it 
+     *
+     * @return TInt Standard error code, KErrNone if connection is formed
+     * @since S60 v3.1
+     */
+    IMPORT_C TInt Connect();
+
+    /**
+     * The connection to the Catalogs engine front-end is closed
+     *
+     * @since S60 v3.1
+     */
+    IMPORT_C void Close();
+
+    /**
+     * All MIME types supported by this component can be asked using this method
+     *
+     * @return RPointerArray<TDataType> contains all supported MIME types. 
+     *         The ownership is transferred to the caller.
+     *         Use ResetAndDestroy method to free all allocated memory
+     * @exeption Leaves with standard error codes
+     * @since S60 v3.1
+     */
+    IMPORT_C RPointerArray<TDataType> SupportedMimeTypesL();
+
+    /**
+     * A Data packet of max length 65535 (0xFFFF) bytes is synchronously
+     * sent to the Catalogs engine front-end.
+     * Usage: After PutDataL has been called, you must call GetDataL
+     *        before you can call PutDataL again
+     *
+     * @param aMimeType Data packet MIME type
+     * @param aData Data buffer to read from
+     * @exeption Leaves with standard error codes
+     *           KErrNotSupported if not supported MIME type
+     * @since S60 v3.1
+     */
+    IMPORT_C void PutDataL( const TDataType& aMimeType, 
+                            const CBufFlat& aData );
+
+    /**
+     * A data packet is synchronously transfered from the Catalogs front-end
+     * and returned to caller
+     * Usage: Everytime before calling GetDataL, you have to call PutDataL.
+     *        You may not call GetData in sequentially.
+     *
+     * @since S60 v3.1
+     * @param aMimeType MIME type of the received data packet
+     * @param aData Data buffer to write to. ExpandL function will be called
+     *        with the correct size for aData, but not more than max length
+     *        65535 (OxFFFF)
+     * @return The reference parameters contain the return data
+     * @exeption Leaves with standard error codes
+     */                                                          
+    IMPORT_C void GetDataL( TDataType& aMimeType, CBufFlat& aData );
+    
+    
+private:
+
+// private functions
+
+
+    /**
+     * Constructor
+     *
+     * @since S60 v3.1
+     */
+    CCatalogsPCConnectivityPlugin();
+
+    /**
+     * Standard symbian object construction second phase
+     */
+    void ConstructL();
+
+
+private: // data
+
+    /**
+     * Client that communicate with the CatalogsEnginePCClientFrontEnd
+     */
+    RCatalogsPCConnectivityClient iClient;
+    
+    };
+
+#endif // C_CATALOGSPCCONNECTIVITYPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/catalogspcconnectivityplugin/src/catalogspcconnectivityclient.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,229 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client that communicate with CatalogsEnginePCClientFrontEnd
+*
+*/
+
+
+#include "catalogspcconnectivityclient.h"
+#include "catalogspcconnectivitydefines.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+RCatalogsPCConnectivityClient::RCatalogsPCConnectivityClient()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+RCatalogsPCConnectivityClient::~RCatalogsPCConnectivityClient()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Start server and create session with server
+// ---------------------------------------------------------------------------
+//
+TInt RCatalogsPCConnectivityClient::Connect()
+    {
+    TInt err = StartServer();
+        
+    if ( err == KErrNone )
+        {
+        err = CreateSession( 
+            KCatalogsPCConnectivityServerName,
+            Version(), 
+            KCatalogsPCConnectivityDefaultMessageSlots );
+        }
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+// Close session (After session is closed will server be closed too)
+// ---------------------------------------------------------------------------
+//
+void RCatalogsPCConnectivityClient::Close()
+    {
+    RHandleBase::Close();
+    }
+
+// ---------------------------------------------------------------------------
+// Give MIME types supported by this Module
+// ---------------------------------------------------------------------------
+//
+RPointerArray<TDataType> RCatalogsPCConnectivityClient::
+SupportedMimeTypesL()
+    {
+    RPointerArray<TDataType> supportedMIMEs;
+    TBool isThereMore = ETrue;
+    TPckgBuf<TBool> pckgIsThereMore;
+    TDataType* tempMIME = 0;
+    TPckgBuf<TDataType> pckgMIME;
+    
+    while( isThereMore )
+        {
+        User::LeaveIfError( SendReceive( 
+                ECatalogsPCConnectivitySupportedMimeTypes, 
+                TIpcArgs( &pckgMIME, &pckgIsThereMore ) ) );
+        isThereMore = pckgIsThereMore();
+        tempMIME = new( ELeave ) TDataType( pckgMIME() );
+        User::LeaveIfError( supportedMIMEs.Append( tempMIME ) );
+        }
+
+    return supportedMIMEs;
+    }
+
+// ---------------------------------------------------------------------------
+// Data package from CatalogsPCConnectivityPlugin
+// ---------------------------------------------------------------------------
+//
+void RCatalogsPCConnectivityClient::PutDataL( 
+    const TDataType& aMimeType, const CBufFlat& aData )
+    {
+    TInt size = aData.Size();
+    
+    RBuf8 desData;
+    desData.CreateL( size );
+    desData.CleanupClosePushL();
+    aData.Read( 0, desData, size );
+    TPckgBuf<TDataType> pckgMIME( aMimeType );
+
+    User::LeaveIfError( SendReceive( 
+            ECatalogsPCConnectivityPutData, 
+            TIpcArgs( &pckgMIME, &desData, size ) ) );
+
+    CleanupStack::Pop(); //desData
+    desData.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// Data request from CatalogsPCConnectivityPlugin
+// First ask the size from server, then give correct size CBufFlat
+// ---------------------------------------------------------------------------
+//
+void RCatalogsPCConnectivityClient::GetDataL( 
+    TDataType& aMimeType, CBufFlat& aData )
+    {
+    TPckgBuf<TInt> pckgSize;
+    TPckgBuf<TDataType> pckgMIME;
+    
+    User::LeaveIfError( SendReceive( 
+            ECatalogsPCConnectivityGetSize, 
+            TIpcArgs( &pckgMIME, &pckgSize ) ) );
+    
+    TInt size = pckgSize();
+    aMimeType = pckgMIME();
+    
+    RBuf8 desData;
+    desData.CreateL( size );
+    desData.CleanupClosePushL();
+    
+    User::LeaveIfError( SendReceive( 
+            ECatalogsPCConnectivityGetData, 
+            TIpcArgs( &desData ) ) );
+    
+    aData.Reset();
+    aData.ExpandL( 0, size );
+    aData.Write( 0, desData, size );        
+            
+    CleanupStack::Pop(); //desData
+    desData.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// Return version number
+// ---------------------------------------------------------------------------
+//
+TVersion RCatalogsPCConnectivityClient::Version() const
+    {
+    return( TVersion( KCatalogsPCConnectivityMajorVersionNumber,
+            KCatalogsPCConnectivityMinorVersionNumber,
+            KCatalogsPCConnectivityBuildVersionNumber ) );
+    }
+
+// ---------------------------------------------------------------------------
+// Start server if it isn't running already
+// ---------------------------------------------------------------------------
+//
+TInt RCatalogsPCConnectivityClient::StartServer()
+    {
+    // Check if the server is already running
+    TFindServer findServer( KCatalogsPCConnectivityServerName );
+    TFullName name;
+
+    TInt result = findServer.Next( name );
+    if ( result == KErrNone )
+        {
+        // Server is running
+        return KErrNone;
+        }
+
+    // Create a semaphore so we can wait while the server starts
+    RSemaphore semaphore;
+    result = semaphore.CreateGlobal( 
+    	KCatalogsPCConnectivityServerSemaphoreName, 0 );
+    if ( result != KErrNone )
+        {
+        return result;
+        }
+
+    // Create new Engine service process 
+    result = CreateServerProcess();
+    if ( result != KErrNone )
+        {
+        semaphore.Close();
+        return result;
+        }
+
+    // Wait while the server starts
+    semaphore.Wait();
+
+    // Semaphore has been signaled, close and return
+    semaphore.Close();
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Create server process
+// ---------------------------------------------------------------------------
+//
+TInt RCatalogsPCConnectivityClient::CreateServerProcess()
+    {
+
+    RProcess server;
+
+    TInt result = server.Create( 
+        KCatalogsPCConnectivityServerFilename, KNullDesC );
+    if ( result != KErrNone )
+        {
+        return result;
+        }
+    
+    // Resume server thread and close handle
+    server.Resume();
+    server.Close();  
+
+    return KErrNone;
+    }
+
+
+//end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/catalogspcconnectivityplugin/src/catalogspcconnectivityplugin.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,139 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This plugin enables the Catalogs PC client to communicate 
+*                with the Catalogs engine
+*
+*/
+
+
+
+#include "catalogspcconnectivityplugin.h"
+
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CCatalogsPCConnectivityPlugin::CCatalogsPCConnectivityPlugin()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Empty
+// ---------------------------------------------------------------------------
+//
+void CCatalogsPCConnectivityPlugin::ConstructL()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// Standard symbian object constructing first phase
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CCatalogsPCConnectivityPlugin* CCatalogsPCConnectivityPlugin::NewL()
+    {
+    CCatalogsPCConnectivityPlugin* self = 
+        CCatalogsPCConnectivityPlugin::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// Standard symbian object constructing first phase
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CCatalogsPCConnectivityPlugin* CCatalogsPCConnectivityPlugin::NewLC()
+    {
+    CCatalogsPCConnectivityPlugin* self = 
+        new( ELeave ) CCatalogsPCConnectivityPlugin;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CCatalogsPCConnectivityPlugin::~CCatalogsPCConnectivityPlugin()
+    {
+    iClient.Close();
+    }
+
+
+// ---------------------------------------------------------------------------
+// Connect to Catalogs engine pc client front-end
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CCatalogsPCConnectivityPlugin::Connect()
+    {
+    return iClient.Connect();
+    }
+
+// ---------------------------------------------------------------------------
+// Close the connection to Catalogs engine pc client front-end
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CCatalogsPCConnectivityPlugin::Close()
+    {
+    iClient.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// Give all MIME types supported by this component
+// ---------------------------------------------------------------------------
+//
+EXPORT_C RPointerArray<TDataType> CCatalogsPCConnectivityPlugin::
+    SupportedMimeTypesL()
+    {
+    return iClient.SupportedMimeTypesL();
+    }
+
+// ---------------------------------------------------------------------------
+// Data package from PC Client
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CCatalogsPCConnectivityPlugin::PutDataL( 
+    const TDataType& aMimeType, const CBufFlat& aData )
+    {
+    iClient.PutDataL( aMimeType, aData );
+    }
+
+// ---------------------------------------------------------------------------
+// Data request from PC Client
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CCatalogsPCConnectivityPlugin::GetDataL( 
+    TDataType& aMimeType, CBufFlat& aData )
+    {
+    iClient.GetDataL( aMimeType, aData );
+    }
+
+
+// ======== GLOBAL FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Dll entry point
+// ---------------------------------------------------------------------------
+//
+GLDEF_C TInt E32Dll()
+    {
+    return( KErrNone );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/clients/pcconn/bld/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*	 This file provides the information required for building the
+*    whole of SConPCConnClient
+*
+*/
+
+
+PRJ_PLATFORMS  
+DEFAULT
+
+PRJ_MMPFILES
+../bld/sconpcconnclient.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/clients/pcconn/bld/def/bwinscwu.def	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,9 @@
+EXPORTS
+	??0RSConPCConnSession@@QAE@XZ @ 1 NONAME ; RSConPCConnSession::RSConPCConnSession(void)
+	??1RSConPCConnSession@@QAE@XZ @ 2 NONAME ; RSConPCConnSession::~RSConPCConnSession(void)
+	?Close@RSConPCConnSession@@QAEXXZ @ 3 NONAME ; void RSConPCConnSession::Close(void)
+	?Connect@RSConPCConnSession@@QAEHXZ @ 4 NONAME ; int RSConPCConnSession::Connect(void)
+	?GetPacketL@RSConPCConnSession@@QAEHABVTDesC16@@ABVTDesC8@@AAPAVCBufFlat@@@Z @ 5 NONAME ; int RSConPCConnSession::GetPacketL(class TDesC16 const &, class TDesC8 const &, class CBufFlat * &)
+	?PutPacketL@RSConPCConnSession@@QAEHABVTDesC16@@ABVTDesC8@@AAPAVCBufFlat@@@Z @ 6 NONAME ; int RSConPCConnSession::PutPacketL(class TDesC16 const &, class TDesC8 const &, class CBufFlat * &)
+	?ResetServer@RSConPCConnSession@@QAEHXZ @ 7 NONAME ; int RSConPCConnSession::ResetServer(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/clients/pcconn/bld/def/eabiuu.def	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,11 @@
+EXPORTS
+	_ZN18RSConPCConnSession10GetPacketLERK7TDesC16RK6TDesC8RP8CBufFlat @ 1 NONAME
+	_ZN18RSConPCConnSession10PutPacketLERK7TDesC16RK6TDesC8RP8CBufFlat @ 2 NONAME
+	_ZN18RSConPCConnSession11ResetServerEv @ 3 NONAME
+	_ZN18RSConPCConnSession5CloseEv @ 4 NONAME
+	_ZN18RSConPCConnSession7ConnectEv @ 5 NONAME
+	_ZN18RSConPCConnSessionC1Ev @ 6 NONAME
+	_ZN18RSConPCConnSessionC2Ev @ 7 NONAME
+	_ZN18RSConPCConnSessionD1Ev @ 8 NONAME
+	_ZN18RSConPCConnSessionD2Ev @ 9 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/clients/pcconn/bld/sconpcconnclient.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client side of PC Connectivity Server-Client
+*
+*/
+
+
+// To get the MW_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_CLIENT_DLL
+
+TARGET          sconpcconnclient.dll
+TARGETTYPE      dll
+
+UID             0x10009D8D 0x101F99F7
+
+TARGETPATH      sys/bin
+
+#if defined(ARMCC)
+DEFFILE	./def/eabiu
+#elif defined(WINSCW) 
+DEFFILE	./def/bwinscw
+#elif defined(WINS)
+DEFFILE	./def/bwins
+#elif defined(ARM)
+DEFFILE	./def/bmarm
+#endif
+
+
+SOURCEPATH      ../src
+
+SOURCE          sconpcconnclient.cpp
+
+// Client
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc
+
+// Server
+USERINCLUDE     ../../../servers/pcconn/inc
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         estor.lib   // RMemWriteStream
+LIBRARY         efsrv.lib   // Rfs, RFile
+DEBUGLIBRARY    flogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/clients/pcconn/inc/sconpcconnclient.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  PC Connectivity client
+*
+*/
+
+
+#ifndef __SCONPCCONNCLIENT_H__
+#define __SCONPCCONNCLIENT_H__
+
+// -----------------------------------------------------------------------------
+// class RSConPCConnSession - the client session
+// -----------------------------------------------------------------------------
+class RSConPCConnSession : public RSessionBase
+	{
+public:
+	IMPORT_C RSConPCConnSession();
+	IMPORT_C ~RSConPCConnSession();
+
+        /**
+        * Starts the server and connects to it
+        * @param none
+        * @return KerrNone or an error code
+        */
+	IMPORT_C TInt Connect();
+	
+	/**
+        *  Disconnects from the server and terminates the server
+        * @param none
+        * @return none
+        */
+	IMPORT_C void Close();
+	
+	/**
+        *  Passes an OBEX Put -message to the server
+        * @param none
+        * @return none
+        */
+	IMPORT_C TInt PutPacketL( const TDesC& aNameHeader, 
+	                          const TDesC8& aTypeHeader, 
+	                          CBufFlat*& aBuffer );
+	
+	/**
+        *  Passes an OBEX Get -message to the server
+        * @param none
+        * @return none
+        */
+	IMPORT_C TInt GetPacketL( const TDesC& aNameHeader, 
+	                          const TDesC8& aTypeHeader, 
+	                          CBufFlat*& aBuffer );
+	
+	/**
+        *  Passes an reset -message to the server
+        * @param none
+        * @return none
+        */
+	IMPORT_C TInt ResetServer();	
+
+private:
+	TVersion Version() const;
+	TInt LaunchServer();
+	TInt CreateAndSendChunkHandle();
+
+private:
+	RChunk iChunk;
+	};
+	
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/clients/pcconn/src/sconpcconnclient.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,304 @@
+/*
+* 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:  PC Connectivity client
+*
+*/
+
+
+
+// -----------------------------------------------------------------------------
+// Includes
+// -----------------------------------------------------------------------------
+#include <e32base.h>
+#include <s32mem.h>
+
+// Client - server 
+#include "sconpcconnclient.h"
+#include "sconpcconnclientserver.h"
+#include "debug.h"
+
+// -----------------------------------------------------------------------------
+// RSConPCConnSession::RSConPCConnSession()
+// Default constructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C RSConPCConnSession::RSConPCConnSession()
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// RSConPCConnSession::~RSConPCConnSession()
+// Default destructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C RSConPCConnSession::~RSConPCConnSession()
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// RSConPCConnSession::Connect()
+// Creates a chunk and server, starts the server connection
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSConPCConnSession::Connect()
+    {
+    TRACE_FUNC_ENTRY;
+ 	
+    TInt ret ( KErrNone );
+
+    ret = CreateSession(KSConPCConnServerName,Version());
+    
+    if ( ret == KErrNotFound || ret == KErrServerTerminated )
+    	{
+    	ret = LaunchServer();
+    	
+    	if ( ret == KErrNone || ret == KErrAlreadyExists )
+    		{
+    		ret = CreateSession( KSConPCConnServerName, Version() );
+    		}
+    	}
+    	
+    if ( ret == KErrNone )
+    	{
+    	ret = CreateAndSendChunkHandle();
+    	if ( ret != KErrNone )
+    	    {
+    	    LOGGER_WRITE("CreateAndSendChunkHandle failed, close session");
+    	    Close();
+    	    }
+    	}
+    
+    LOGGER_WRITE_1( "RSConPCConnSession::Connect() : returned %d", ret );
+    return ret; 
+    }
+
+// -----------------------------------------------------------------------------
+// RSConPCConnSession::Close()
+// Closes the server connection
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RSConPCConnSession::Close()
+    {
+    TRACE_FUNC_ENTRY;
+    iChunk.Close();
+    RSessionBase::Close();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// RSConPCConnSession::Version()
+// Returns the version of the client
+// -----------------------------------------------------------------------------
+//	
+TVersion RSConPCConnSession::Version(void) const
+    {
+    return (TVersion(KSConPCConnServerVersionMajor, 
+                               KSConPCConnServerVersionMinor, 
+                               KSConPCConnServerVersionBuild));
+    }
+
+// -----------------------------------------------------------------------------
+// RSConPCConnSession::Version()
+// Forwards a PUT -message to the server
+// -----------------------------------------------------------------------------
+//	
+EXPORT_C TInt RSConPCConnSession::PutPacketL( 
+    const TDesC& aNameHeader, const TDesC8& aTypeHeader, CBufFlat*& aBuffer )
+    {
+    TRACE_FUNC_ENTRY;
+
+    if ( !aBuffer )
+        {
+        return KErrArgument;
+        }
+
+    if ((aBuffer->Size() + aTypeHeader.Size() + 
+         aNameHeader.Size()) > KSConPCConnChunkMaxSize)
+        {
+        LOGGER_WRITE( "RSConPCConnSession::PutPacketL() :\
+         WBXML document too big" );
+        return KErrTooBig;
+        }
+	
+    TInt ret (KErrNone);
+    iChunk.Adjust( KSConPCConnChunkMaxSize );
+    RMemWriteStream buf( iChunk.Base(), iChunk.Size() );
+	
+    buf.WriteInt32L( aNameHeader.Size() );
+    buf.WriteL( aNameHeader );
+
+    buf.WriteInt32L( aTypeHeader.Size() );
+    buf.WriteL( aTypeHeader );
+	
+    // WBXML document	
+    buf.WriteInt32L( aBuffer->Size() );
+    buf.WriteL( aBuffer->Ptr(0) );
+    buf.CommitL();
+    buf.Close();
+    
+    TIpcArgs args;
+    ret = SendReceive ( EPutMessage, args );
+
+    LOGGER_WRITE_1( "RSConPCConnSession::PutPacketL() : returned %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RSConPCConnSession::Version()
+// Forwards a GET -message to the server
+// -----------------------------------------------------------------------------
+//	
+EXPORT_C TInt RSConPCConnSession::GetPacketL( 
+    const TDesC& aNameHeader, const TDesC8& aTypeHeader, CBufFlat*& aBuffer )
+    {
+    TRACE_FUNC_ENTRY;
+
+    if ( !aBuffer )
+        {
+        return KErrArgument;
+        }
+
+    TInt ret (KErrNone);
+	
+    iChunk.Adjust( KSConPCConnChunkMaxSize);
+    RMemWriteStream writeBuf( iChunk.Base(), iChunk.Size() );
+    writeBuf.WriteInt32L( aNameHeader.Size() );
+    writeBuf.WriteL( aNameHeader );
+    
+    writeBuf.WriteInt32L( aTypeHeader.Size() );
+    writeBuf.WriteL( aTypeHeader );
+
+    writeBuf.CommitL();
+    writeBuf.Close();
+    
+    TIpcArgs args;
+    ret = SendReceive ( EGetMessage, args );
+
+    if ( ret != KErrNone) 
+        {
+        LOGGER_WRITE_1( "RSConPCConnSession::GetPacketL() :\
+         Send Receive failed with code %d", ret );
+        return ret;
+        };
+	
+    // copy data from the chunk
+    RMemReadStream readBuf( iChunk.Base(), iChunk.Size() );
+    TInt32 length ( 0 );
+
+    aBuffer->Reset();
+    length = readBuf.ReadInt32L();
+	
+    HBufC8* data = HBufC8::NewLC( length );
+    TPtr8 dataPtr = data->Des();
+	
+    readBuf.ReadL( dataPtr, length );
+    aBuffer->ExpandL( 0, length );
+    aBuffer->Write ( 0, dataPtr );
+	
+    readBuf.Close();
+	
+    CleanupStack::PopAndDestroy(); // data;
+
+    LOGGER_WRITE_1( "RSConPCConnSession::GetPacketL()\
+     : returned %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RSConPCConnSession::Version()
+// Forwards a Reset -message to the server
+// -----------------------------------------------------------------------------
+//	
+EXPORT_C TInt RSConPCConnSession::ResetServer()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    TIpcArgs args;
+    ret = SendReceive ( EResetMessage, args );
+    LOGGER_WRITE_1( "RSConPCConnSession::ResetServerL(): ret %d", ret );
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// RSConPCConnSession::LaunchServer()
+// Launches the server
+// -----------------------------------------------------------------------------
+//	
+TInt RSConPCConnSession::LaunchServer()
+	{
+	TRACE_FUNC_ENTRY;
+	TInt ret( KErrNone );
+    
+    // Create server
+    RProcess p;
+    ret = p.Create(KSConPCConnServerExe, KNullDesC);
+    
+    if ( ret != KErrNone )
+        {
+        // Loading failed.
+        LOGGER_WRITE_1( "RProcess::Create failed, err: %d", ret );
+        return ret;
+        }
+    
+    
+    TRequestStatus status;
+    p.Rendezvous( status );
+    
+    if ( status != KRequestPending )
+        {
+        p.Kill(0);		// abort startup
+        p.Close();
+        LOGGER_WRITE("Abort startup, return KErrGeneral");
+        return KErrGeneral;   
+        }
+    else
+        {
+        p.Resume();	// logon OK - start the server
+        }
+    
+    User::WaitForRequest(status);
+    
+    p.Close();
+    
+	LOGGER_WRITE_1( "RSConPCConnSession::LaunchServerL(): returned %d", status.Int() );
+    return status.Int();
+	}
+	
+// -----------------------------------------------------------------------------
+// RSConPCConnSession::CreateAndSendChunkHandle()
+// Creates a chunk and sends a handle to server
+// -----------------------------------------------------------------------------
+//	
+TInt RSConPCConnSession::CreateAndSendChunkHandle()
+	{
+	TRACE_FUNC_ENTRY;
+	TInt err = iChunk.CreateGlobal( KNullDesC, 
+                                    KSConPCConnChunkSize, 
+                                    KSConPCConnChunkMaxSize );
+    if ( err != KErrNone )
+        {
+        LOGGER_WRITE_1("iChunk.CreateGlobal failed, err: %d", err);
+        return err;
+        }                           
+    TIpcArgs args;
+ 	args.Set( 0, iChunk );
+ 	err = SendReceive( EChunkMessage, args );
+    
+    LOGGER_WRITE_1("RSConPCConnSession::CreateAndSendChunkHandle : returned: %d", err);
+    return err;
+	}
+	
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/bld/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Contact Parser Client-Server build information file.
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+
+PRJ_MMPFILES
+cntparsersrv.mmp
+cntparsersrvexe.mmp
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/bld/cntparsersrv.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Contact Parser Client
+*
+*/
+
+
+// To get the MW_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_CLIENT_DLL
+
+TARGET          cntparserserver.dll
+TARGETTYPE      dll
+
+UID             0x10009d8d 0x101F99F8
+
+#if defined(ARMCC)
+DEFFILE	./def/eabiu
+#elif defined(WINSCW) 
+DEFFILE	./def/bwinscw
+#elif defined(WINS)
+DEFFILE	./def/bwins
+#elif defined(ARM)
+DEFFILE	./def/bmarm
+#endif
+
+SOURCEPATH      ../src
+SOURCE          cntparserclient.cpp
+SOURCE          cntparserinfolog.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../inc
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY	        cntmodel.lib
+LIBRARY	        efsrv.lib
+LIBRARY	        estor.lib
+LIBRARY	        versit.lib
+LIBRARY	        vcard.lib
+LIBRARY         bafl.lib
+DEBUGLIBRARY    flogger.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/bld/cntparsersrvexe.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Contact Parser Server
+*
+*/
+
+
+// To get the MW_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_SERVER
+
+TARGET          cntparserserverexe.exe
+TARGETTYPE      exe
+
+UID             0 0x101F99F9
+
+SOURCEPATH      ../src
+SOURCE          cntparserserverexe.cpp
+SOURCE          cntparserserversession.cpp
+SOURCE          cntparsercollector.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../inc
+
+// Default system include paths
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY	        cntmodel.lib
+LIBRARY	        efsrv.lib
+LIBRARY	        estor.lib
+LIBRARY	        versit.lib
+LIBRARY	        vcard.lib
+LIBRARY         bafl.lib
+DEBUGLIBRARY    flogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/bld/def/bwinscwu.def	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,18 @@
+EXPORTS
+	??0RCntParserServer@@QAE@XZ @ 1 NONAME ; RCntParserServer::RCntParserServer(void)
+	?Cancel@RCntParserServer@@QAEHXZ @ 2 NONAME ; int RCntParserServer::Cancel(void)
+	?CancelAll@RCntParserServer@@QAEHXZ @ 3 NONAME ; int RCntParserServer::CancelAll(void)
+	?Connect@RCntParserServer@@QAEHXZ @ 4 NONAME ; int RCntParserServer::Connect(void)
+	?ContactsParsed@RCntParserServer@@QAEHXZ @ 5 NONAME ; int RCntParserServer::ContactsParsed(void)
+	?ContactsSaved@RCntParserServer@@QAEHXZ @ 6 NONAME ; int RCntParserServer::ContactsSaved(void)
+	?CreateIrMCL2PhoneBook@RCntParserServer@@QAEHHH@Z @ 7 NONAME ; int RCntParserServer::CreateIrMCL2PhoneBook(int, int)
+	?Disconnect@RCntParserServer@@QAEHXZ @ 8 NONAME ; int RCntParserServer::Disconnect(void)
+	?MaximumRecords@CCntParserInfoLog@@QBEHXZ @ 9 NONAME ; int CCntParserInfoLog::MaximumRecords(void) const
+	?NewL@CCntParserInfoLog@@SAPAV1@XZ @ 10 NONAME ; class CCntParserInfoLog * CCntParserInfoLog::NewL(void)
+	?SaveToFileL@CCntParserInfoLog@@QBEXABVTDesC16@@@Z @ 11 NONAME ; void CCntParserInfoLog::SaveToFileL(class TDesC16 const &) const
+	?SetMaximumRecords@CCntParserInfoLog@@QAEXH@Z @ 12 NONAME ; void CCntParserInfoLog::SetMaximumRecords(int)
+	?SetTotalRecords@CCntParserInfoLog@@QAEXH@Z @ 13 NONAME ; void CCntParserInfoLog::SetTotalRecords(int)
+	?TotalNumberOfContacts@RCntParserServer@@QAEHXZ @ 14 NONAME ; int RCntParserServer::TotalNumberOfContacts(void)
+	?TotalRecords@CCntParserInfoLog@@QBEHXZ @ 15 NONAME ; int CCntParserInfoLog::TotalRecords(void) const
+	?Version@RCntParserServer@@QBE?AVTVersion@@XZ @ 16 NONAME ; class TVersion RCntParserServer::Version(void) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/bld/def/eabiuu.def	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,21 @@
+EXPORTS
+	_ZN16RCntParserServer10DisconnectEv @ 1 NONAME
+	_ZN16RCntParserServer13ContactsSavedEv @ 2 NONAME
+	_ZN16RCntParserServer14ContactsParsedEv @ 3 NONAME
+	_ZN16RCntParserServer21CreateIrMCL2PhoneBookEii @ 4 NONAME
+	_ZN16RCntParserServer21TotalNumberOfContactsEv @ 5 NONAME
+	_ZN16RCntParserServer6CancelEv @ 6 NONAME
+	_ZN16RCntParserServer7ConnectEv @ 7 NONAME
+	_ZN16RCntParserServer9CancelAllEv @ 8 NONAME
+	_ZN16RCntParserServerC1Ev @ 9 NONAME
+	_ZN16RCntParserServerC2Ev @ 10 NONAME
+	_ZN17CCntParserInfoLog15SetTotalRecordsEi @ 11 NONAME
+	_ZN17CCntParserInfoLog17SetMaximumRecordsEi @ 12 NONAME
+	_ZN17CCntParserInfoLog4NewLEv @ 13 NONAME
+	_ZNK16RCntParserServer7VersionEv @ 14 NONAME
+	_ZNK17CCntParserInfoLog11SaveToFileLERK7TDesC16 @ 15 NONAME
+	_ZNK17CCntParserInfoLog12TotalRecordsEv @ 16 NONAME
+	_ZNK17CCntParserInfoLog14MaximumRecordsEv @ 17 NONAME
+	_ZTI17CCntParserInfoLog @ 18 NONAME ; #<TI>#
+	_ZTV17CCntParserInfoLog @ 19 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/inc/clientserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Contact Parser Server definitions
+*
+*/
+
+
+#ifndef __CLIENTSERVER_H__
+#define __CLIENTSERVER_H__
+#include <e32base.h>
+
+// server name
+_LIT(KCntParserName,"Contacts Parser");
+
+// A version must be specified when creating a session with the server
+
+const TUint KCntParserMajorVersionNumber=0;
+const TUint KCntParserMinorVersionNumber=1;
+const TUint KCntParserBuildVersionNumber=1;
+
+// opcodes used in message passing between client and server
+enum TCntParserRqst
+	{
+	ECntParserServerCancel,
+	ECntParserServerClose,
+	ECntParserServerCreateIrMCL2,
+	ECntParserServerTotalNumOfContacts,
+	ECntParserServerDisconnect,
+	ECntParserServerCntParsed,
+	ECntParserServerCntSaved,
+	ECntParserServerCancelAll
+	};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/inc/cntparserclient.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Contact Parser Client
+*
+*/
+
+
+
+#if !defined(__CNTPARSERCLIENT_H__)
+#define __CNTPARSERCLIENT_H__
+
+#include <e32base.h>
+#include <e32std.h>
+
+enum TCntParserConnection
+{
+	ECntParserNotConnected,
+	ECntParserConnected
+};
+
+//**********************************
+//RCntParserServer
+//**********************************
+
+class RCntParserServer : public RSessionBase
+{
+	public:
+	IMPORT_C	RCntParserServer();
+	IMPORT_C	TInt Connect();
+	IMPORT_C	TInt Disconnect();
+	IMPORT_C	TVersion Version() const;
+	IMPORT_C	TInt CreateIrMCL2PhoneBook(TInt aMaxNumberOfContacts, TBool aForced);
+	IMPORT_C	TInt ContactsParsed();
+	IMPORT_C	TInt ContactsSaved();
+	IMPORT_C	TInt TotalNumberOfContacts();
+	IMPORT_C	TInt Cancel(); 		//cancels phonebook request
+	IMPORT_C	TInt CancelAll(); 	//cancels all request
+
+	private:
+	TCntParserConnection	iConnected;
+};
+
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/inc/cntparsercollector.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CCntParserCollector header
+*
+*/
+
+
+
+#ifndef __CNTPARSERCOLLECTOR_H__
+#define __CNTPARSERCOLLECTOR_H__
+
+#include <f32file.h>
+#include <s32file.h>
+
+class CCntParserServer;
+class CContactDatabase;
+class CContactIdArray;
+class CCntFilter;
+class CVersitTlsData;
+
+class CCntParserCollector : public CActive
+{
+	public:
+
+	CCntParserCollector();
+	static CCntParserCollector* NewL(CCntParserServer* aServer,CContactDatabase* aCurrentDatabase);
+	static CCntParserCollector* NewLC(CCntParserServer* aServer,CContactDatabase* aCurrentDatabase);
+	virtual ~CCntParserCollector();
+	void ConstructL(CCntParserServer* aServer,CContactDatabase* aCurrentDatabase);
+	TInt CreateIrMCL2FileL(const TDesC& aFileName,TInt aMaxNumberOfContacts,TBool aForced);
+	void PrepareParserL();
+	void ParseCntDatabaseL();
+	void DoCancel();
+
+	TInt CurrentItem();
+	TInt Count();
+	TInt ContactsSaved();
+
+	protected:
+	void RunL();
+	TInt RunError(TInt aError);
+	void ExternalizeCurrentContactL(CContactDatabase* aContactsDb,TInt aCurrentItem,TBool ExternalizeEmpty);
+	void CloseResources();
+	void SaveTotalCountL();
+	TInt ReadTotalCountL() const;
+	TBool ContactCountChanged();
+
+	private:
+	CContactDatabase*	iContactsDb;	//Caller has the ownership
+	TInt iCurrentItem;
+	TInt iCount;						//Contacts in CDB
+	TInt iMaxNumberOfContacts;			//Max contacts to be parsed (MAXIMUM RECORDS in info.log)
+	RFileWriteStream iWriter;
+	CContactIdArray* iIds;				//List of ID numbers of contacts
+	CCntParserServer* iServer;			//Caller has the ownership
+	CCntFilter* iFilter;
+	CVersitTlsData* iVersitTLS;			//For speed optimization
+	TBool iCancel;
+	TInt iContactsSaved;
+	TInt iTotalCount;
+	
+	RFs iFsSession;
+};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/inc/cntparserinfolog.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CCntParserInfoLog header.
+*    This class is intended to create the INFO.LOG file for RANSI car phone when
+*    downloading contacts using IrMC L2. The implementation contains only mandatory
+*    needs and some extension possibilities. This class is RANSI specific and
+*    should _NOT_ be used by anyone else without a deeper knowledge.
+*
+*/
+
+
+#ifndef _CNTPARSERINFOLOG_H_
+#define _CNTPARSERINFOLOG_H_
+
+
+class CCntParserInfoLog : public CBase
+{
+	public:
+	CCntParserInfoLog();
+	virtual ~CCntParserInfoLog();
+	IMPORT_C static CCntParserInfoLog* NewL();
+	void ConstructL();
+
+	IMPORT_C void SaveToFileL(const TDesC& aFileName) const;
+
+	IMPORT_C void SetTotalRecords(TInt aTotalRecords);
+	IMPORT_C void SetMaximumRecords(TInt aMaximumRecords);
+
+	IMPORT_C TInt TotalRecords() const;
+	IMPORT_C TInt MaximumRecords() const;
+
+	private:
+
+	TInt	iTotalRecords;
+	TInt	iLastUsedIndex;
+	TInt	iMaximumRecords;
+};
+
+#endif // _CNTPARSERINFOLOG_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/inc/cntparserserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,95 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CCntParserServer header
+*
+*/
+
+
+#ifndef __CNTPARSERSERVER_H__
+#define __CNTPARSERSERVER_H__
+
+#include <e32base.h>
+#include <e32svr.h>
+
+class CCntParserCollector;
+class CContactDatabase;
+
+_LIT(KTxtServer,"CntParserServerExe.exe");
+
+// needed for creating server thread.
+const TUint KDefaultHeapSize=0x10000;
+
+// reasons for server panic
+enum TCntParserServerPanic
+{
+	EBadRequest,
+	EBadDescriptor,
+	EMainSchedulerError,
+	ESvrCreateServer,
+	ESvrStartServer,
+	ECreateTrapCleanup,
+	ENotImplementedYet,
+};
+
+
+//**********************************
+//CCntParserServer
+//**********************************
+class CCntParserServer : public CServer2
+{
+	public:
+	IMPORT_C static CCntParserServer* NewL();
+	IMPORT_C virtual ~CCntParserServer();
+	static TInt RunServer();
+	static void RunServerL();
+	void IncreaseSessionCountL();
+	void DecreaseSessionCount();
+	void Stop();
+	
+	TInt CreateIrMCL2PhoneBookL(const TDesC& path, TInt aMaxNumberOfContacts,TBool aForced);
+	void PrepareCollectorL();
+	TInt ContactsParsed();
+	void CancelPhoneBookRequest();
+	void CancelAllPhoneBookRequests();
+	TInt TotalNumOfContacts();
+	TInt ContactsSaved();
+	void Disconnect();
+	void CompletePhoneBookRequests(TInt aErr);
+	void SetRequests(TInt aRequests);
+
+	protected:
+	virtual CSession2* NewSessionL(const TVersion &aVersion, const RMessage2& aMsg) const;
+
+
+	protected:
+	CCntParserServer();
+
+
+	private:
+	TInt	iSessionCount;
+	TInt	iRequests;	//How many PB.VCF requests are ongoing, if 0 collector is canceled
+
+	CCntParserCollector* iCollector;
+	CContactDatabase* iCurrentDatabase;
+};
+
+//**********************************
+//global functions
+//**********************************
+
+// function to panic the server
+GLREF_C void PanicServer(TCntParserServerPanic aPanic);
+
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/inc/cntparserserversession.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CCntParserServerSession header
+*
+*/
+
+
+#ifndef __CNTPARSERSERVERSESSION_H__
+#define __CNTPARSERSERVERSESSION_H__
+
+#include "clientserver.h"
+#include "cntparserclient.h"
+#include "cntparserserver.h"
+#include "cntparsercollector.h"
+
+class CCntParserServer;
+
+//**********************************
+//CCntParserServerSession
+//**********************************
+class CCntParserServerSession : public CSession2
+{
+	public:
+	static CCntParserServerSession* NewL(CCntParserServer* aServer);
+	virtual ~CCntParserServerSession();
+	void ConstructL(CCntParserServer* aServer);
+
+	private:
+	CCntParserServerSession();
+
+	public:
+	virtual void ServiceL(const RMessage2& aMessage);
+	TInt DispatchMessageL(const RMessage2& aMessage);
+	void CompletePhoneBookRequest(TInt aErr);
+
+	protected:
+	// panic the client
+	void PanicClient(TInt aPanic) const;
+
+	private:
+	CCntParserServer* iContactsParserSrv;
+	TBool iPhoneBookRequest;
+	RMessage2 iPhoneBookRequestMessage;
+};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/inc/irmcconsts.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Contact Parser constants
+*
+*/
+
+
+#ifndef _IRMCCONSTS_H_
+#define _IRMCCONSTS_H_
+
+_LIT(KPhoneBookFilename,"c:\\IrMC\\pb.vcf");
+const TInt KMaximumNumberOfContacts=-1; //-1 == all contacts are transferred
+const TInt KPBNotUpdated=1;	//Must be grater than 0
+const TInt KPerformComplete=2; //Must be grater than 0 and different than KPBNotUpdated
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/src/cntparserclient.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,252 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  RCntParserServer implementation.
+*
+*/
+
+
+// needed for client interface
+#include "clientserver.h"
+#include "cntparserserver.h"
+#include "cntparserclient.h"
+
+#include "debug.h"
+
+const TUint KDefaultMessageSlots=4;
+
+
+//------------------------------------------------------------
+// RCntParserServer::RCntParserServer()
+//------------------------------------------------------------
+EXPORT_C RCntParserServer::RCntParserServer():iConnected(ECntParserNotConnected)
+	{
+	}
+//------------------------------------------------------------
+// RCntParserServer::Connect()
+//------------------------------------------------------------
+EXPORT_C TInt RCntParserServer::Connect()
+	{
+	LOGGER_ENTERFN( "RCntParserServer::Connect()" );
+
+	TInt r = KErrNone;
+
+	if( iConnected == ECntParserNotConnected )
+		{
+		r = CreateSession( KCntParserName, Version(), KDefaultMessageSlots );
+		if(r==KErrNone) 
+			{
+			iConnected=ECntParserConnected;	
+			}
+		else
+			{
+			RProcess p;
+			TInt err = p.Create(KTxtServer, KNullDesC);
+	   		if ( err != KErrNone )
+           		{
+           		// Loading failed.
+           		return err;
+           		}
+			TRequestStatus status;
+			p.Rendezvous( status );
+			if( status != KRequestPending )
+				{
+				p.Kill(0);		// abort startup
+				p.Close();
+				return KErrGeneral;   // status can be KErrNone: don't return status.Int()
+				}
+			else
+				{
+				p.Resume();	// logon OK - start the server
+				}
+			
+			User::WaitForRequest( status );
+
+			if( status != KErrNone )
+				{
+				p.Close();
+				return status.Int();
+				}
+
+			r = CreateSession( KCntParserName, Version() );
+			if( r == KErrNone )
+				{
+				iConnected = ECntParserConnected;	
+				}
+			p.Close();
+			}
+		}
+	else
+		{
+		r = KErrCouldNotConnect;
+		}
+	LOGGER_WRITE_1( "RCntParserServer::Connect() : return %d", r );
+	return r; 
+	}
+//------------------------------------------------------------
+// RCntParserServer::Disconnect()
+//------------------------------------------------------------
+EXPORT_C TInt RCntParserServer::Disconnect()
+	{
+	LOGGER_ENTERFN( "RCntParserServer::Disconnect()" );
+
+	TInt res = KErrNone;
+	if(iConnected==ECntParserConnected)
+		{
+		res = SendReceive( ECntParserServerDisconnect, TIpcArgs(NULL) );
+		if( res == KErrNone )
+			{
+			iConnected = ECntParserNotConnected;
+			RSessionBase::Close();
+			}
+		}
+	else
+		{
+		res = KErrCouldNotDisconnect;
+		}
+	LOGGER_WRITE_1( "RCntParserServer::CreateIrMCL2PhoneBook() : return %d", res );
+	return res;
+	}
+//------------------------------------------------------------
+// RCntParserServer::Version(void) const
+//------------------------------------------------------------
+EXPORT_C TVersion RCntParserServer::Version(void) const
+	{
+	return(TVersion(KCntParserMajorVersionNumber,KCntParserMinorVersionNumber,KCntParserBuildVersionNumber));
+	}
+//------------------------------------------------------------
+// RCntParserServer::CreateIrMCL2PhoneBook(TInt aMaxNumberOfContacts, TBool aForced)
+//------------------------------------------------------------
+EXPORT_C int RCntParserServer::CreateIrMCL2PhoneBook(TInt aMaxNumberOfContacts, TBool aForced)
+	{
+	LOGGER_ENTERFN( "RCntParserServer::CreateIrMCL2PhoneBook()" );
+    TInt res(KErrNone);
+	if( iConnected == ECntParserConnected )
+		{
+		res = SendReceive(ECntParserServerCreateIrMCL2,TIpcArgs(aMaxNumberOfContacts,aForced));
+		}
+	else
+		{
+		res = KErrNotReady;
+		}
+	LOGGER_WRITE_1( "RCntParserServer::CreateIrMCL2PhoneBook() : return %d", res );
+	return res;
+	}
+//------------------------------------------------------------
+// RCntParserServer::ContactsParsed()
+//------------------------------------------------------------
+EXPORT_C TInt RCntParserServer::ContactsParsed()
+	{
+	LOGGER_ENTERFN( "RCntParserServer::ContactsParsed()" );
+
+	TInt res=KErrNone;
+	if( iConnected == ECntParserConnected )
+		{
+		TPckgBuf<TInt> pckg;
+		res = SendReceive(ECntParserServerCntParsed,TIpcArgs(&pckg));
+		if( res == KErrNone )
+            {
+            res = pckg();
+            }
+		}
+	else
+		{
+		res = KErrNotReady;
+		}
+	LOGGER_WRITE_1( "RCntParserServer::ContactsParsed() : return %d", res );
+	return res;
+	}
+//------------------------------------------------------------
+// RCntParserServer::TotalNumberOfContacts()
+//------------------------------------------------------------
+EXPORT_C TInt RCntParserServer::TotalNumberOfContacts()
+	{
+	LOGGER_ENTERFN( "RCntParserServer::TotalNumberOfContacts()" );
+
+	TInt res = KErrNone;
+	if( iConnected == ECntParserConnected )
+		{
+		TPckgBuf<TInt> pckg;
+		res = SendReceive(ECntParserServerTotalNumOfContacts,TIpcArgs(&pckg));
+		if( res == KErrNone)
+            {
+            res = pckg();
+            }
+		}
+	else
+		{
+		res = KErrNotReady;
+		}
+	LOGGER_WRITE_1( "RCntParserServer::TotalNumberOfContacts() : return %d", res );
+	return res;
+	}
+//------------------------------------------------------------
+// RCntParserServer::Cancel()
+//------------------------------------------------------------
+EXPORT_C TInt RCntParserServer::Cancel()
+	{
+	LOGGER_ENTERFN( "RCntParserServer::Cancel()" );
+
+	TInt res = KErrNone;
+	if( iConnected == ECntParserConnected )
+		{
+		res = SendReceive(ECntParserServerCancel,TIpcArgs(NULL));
+		}
+	else
+		{
+		res = KErrCancel;
+		}
+	LOGGER_WRITE_1( "RCntParserServer::Cancel() : return %d", res );
+	return res;
+	}
+//------------------------------------------------------------
+// RCntParserServer::CancelAll()
+//------------------------------------------------------------
+EXPORT_C TInt RCntParserServer::CancelAll()
+	{
+	LOGGER_ENTERFN( "RCntParserServer::CancelAll()" );
+
+	TInt res = KErrNone;
+	if(iConnected==ECntParserConnected)
+		{
+		res = SendReceive(ECntParserServerCancelAll,TIpcArgs(NULL));
+		}
+	else
+		{
+		res = KErrCancel;
+		}
+    LOGGER_WRITE_1( "RCntParserServer::CancelAll() : return %d", res );
+	return res;
+	}
+//------------------------------------------------------------
+// RCntParserServer::ContactsSaved()
+//------------------------------------------------------------
+EXPORT_C TInt RCntParserServer::ContactsSaved()
+	{
+	LOGGER_ENTERFN( "RCntParserServer::ContactsSaved()" );
+
+	TInt res = KErrNone;
+	if( iConnected == ECntParserConnected )
+		{
+		TPckgBuf<TInt> pckg;
+		SendReceive(ECntParserServerCntSaved,TIpcArgs(&pckg));
+		res = pckg();
+		}
+	else
+		{
+		res = KErrNotReady;
+		}
+    LOGGER_WRITE_1( "RCntParserServer::ContactsSaved() : return %d", res );
+	return res;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/src/cntparsercollector.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,620 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CCntParserCollector implementation.
+*
+*/
+
+
+
+#include <cntfilt.h>
+#include <cntitem.h>
+#include <cntfldst.h>
+
+#include <vcard.h>
+#include <versit.h>
+#include <s32mem.h>
+
+#include "cntparsercollector.h"
+#include "cntparserserver.h"
+#include "irmcconsts.h"
+#include "debug.h"
+
+//Next values are defined in cntdef.h
+const TUid typesToBeSearched[]={{KUidContactFieldPhoneNumberValue},{KUidContactFieldFaxValue}};
+
+_LIT( KTotalCountFilePath, "count.txt" );
+
+_LIT8( KNameProperty, "N" );
+_LIT8( KTelProperty, "TEL" );
+
+
+//------------------------------------------------------------
+// CCntParserCollector::CCntParserCollector():CActive( 0 )
+//------------------------------------------------------------
+CCntParserCollector::CCntParserCollector():CActive( 0 )
+    {
+    }
+//------------------------------------------------------------
+// CCntParserCollector::~CCntParserCollector()
+//------------------------------------------------------------
+CCntParserCollector::~CCntParserCollector()
+    {
+    LOGGER_ENTERFN( "CntParserCollector::~CCntParserCollector()" );
+
+    if( iVersitTLS != NULL )
+        {
+        iVersitTLS->VersitTlsDataClose(); //Close reference 
+        }
+    LOGGER_WRITE( "CntParserCollector: Versit OK!" );
+
+    iFsSession.Close();
+    LOGGER_WRITE( "CntParserCollector: FsSession OK!" );
+    iWriter.Close(); 
+    LOGGER_WRITE( "CntParserCollector: iWriter OK!" );
+    delete iFilter;
+    LOGGER_LEAVEFN( "CntParserCollector::~CCntParserCollector()" );
+    }
+//------------------------------------------------------------
+// CCntParserCollector::NewL(CCntParserServer* aServer,CContactDatabase* aCurrentDatabase)
+//------------------------------------------------------------
+CCntParserCollector* CCntParserCollector::NewL(CCntParserServer* aServer,CContactDatabase* aCurrentDatabase)
+    {
+    CCntParserCollector* self=NewLC(aServer, aCurrentDatabase);
+    CleanupStack::Pop();
+    return self;
+    }
+//------------------------------------------------------------
+// CCntParserCollector::NewLC(CCntParserServer* aServer,CContactDatabase* aCurrentDatabase)
+//------------------------------------------------------------
+CCntParserCollector* CCntParserCollector::NewLC(CCntParserServer* aServer,CContactDatabase* aCurrentDatabase)
+    {
+    CCntParserCollector* self=new (ELeave) CCntParserCollector();
+    CleanupStack::PushL( self );
+    self->ConstructL( aServer, aCurrentDatabase );
+    return self;
+    }
+//------------------------------------------------------------
+// CCntParserCollector::ConstructL(CCntParserServer* aServer,CContactDatabase* aCurrentDatabase)
+//------------------------------------------------------------
+void CCntParserCollector::ConstructL(CCntParserServer* aServer,CContactDatabase* aCurrentDatabase)
+    {
+    LOGGER_WRITE( "CntParserCollector: ConstructL" );
+
+    CVersitTlsData& VersitTLS = CVersitTlsData::VersitTlsDataL();   //For speed optimization take a reference to TLS, SEE DESTRUCTOR!!
+    iVersitTLS = &VersitTLS;
+
+    iServer = aServer;
+    iContactsDb = aCurrentDatabase;
+    PrepareParserL();
+
+    CActiveScheduler::Add(this);
+    }
+//------------------------------------------------------------
+// CCntParserCollector::CreateIrMCL2FileL(const TDesC& aFileName, TInt aMaxNumberOfContacts,TBool aForced)
+//------------------------------------------------------------
+TInt CCntParserCollector::CreateIrMCL2FileL(const TDesC& aFileName, TInt aMaxNumberOfContacts,TBool aForced)
+    {
+    LOGGER_WRITE( "CntParserCollector: CreateIrMCL2FileL" );
+    LOGGER_WRITE_1( "CCntParserCollector::CreateIrMCL2FileL aFileName %S", &aFileName );
+
+    iMaxNumberOfContacts = aMaxNumberOfContacts;
+
+    CContactIdArray* changedItems;
+    TTime tTime;
+
+    LOGGER_WRITE( "CntParserCollector: CreateIrMCL2FileL: Does the PB.VCF already exist" );
+
+    //Is there a previously created pb.vcf file?
+    RFile file;
+    TInt err = file.Open( iFsSession, aFileName, EFileShareExclusive ); //Open file
+    if( err == KErrNone )
+        {
+        LOGGER_WRITE( "CntParserCollector: CreateIrMCL2FileL: Yes, when created" );
+        file.Modified(tTime);   //When modified
+        }
+    file.Close();
+
+    err = iWriter.Open( iFsSession, aFileName, EFileShareExclusive ); //Open stream
+    CleanupClosePushL( iWriter );   //Yes, this is a member variable, but it's considered
+
+    if( err == KErrPathNotFound )
+        {
+        LOGGER_WRITE( "CntParserCollector: CreateIrMCL2FileL: dir did not exist, creating..." );
+        err = iFsSession.MkDir( aFileName );
+        LOGGER_WRITE_1( "CCntParserCollector MkDir returned %d", err );
+        if ( err == KErrNone )
+            {
+            LOGGER_WRITE( "CntParserCollector: CreateIrMCL2FileL: New file after MkDir" );
+            //This is the situation that the file is created for the first time
+            User::LeaveIfError( iWriter.Create( iFsSession, aFileName, EFileShareExclusive ) );
+            LOGGER_WRITE( "CntParserCollector: CreateIrMCL2FileL: New file created after MkDir" );
+            CleanupStack::Pop();    //iWriter
+            ParseCntDatabaseL(); //create IrMC L2 stuff
+            SaveTotalCountL();
+            return KErrNone;    //File created normally
+            }
+        }
+    if( err == KErrNotFound ) // file does not exist - create it
+        {
+        LOGGER_WRITE( "CntParserCollector: CreateIrMCL2FileL: New file" );
+
+        //This is the situation that the file is created for the first time
+        User::LeaveIfError( iWriter.Create( iFsSession, aFileName, EFileShareExclusive ) );
+        LOGGER_WRITE( "CntParserCollector: CreateIrMCL2FileL: New file created" );
+        CleanupStack::Pop();    //iWriter
+        ParseCntDatabaseL(); //create IrMC L2 stuff
+        SaveTotalCountL();
+        return KErrNone;    //File created normally
+        }
+    else
+        {
+        if( err != KErrNone )
+            {
+            LOGGER_WRITE_1( "CreateIrMCL2FileL errror leaving %d", err );
+            User::Leave(err);   
+            }
+        iWriter.Close();
+
+        LOGGER_WRITE( "CntParserCollector: CreateIrMCL2FileL: File exists, any changes in CDB?" );
+        //The file exists, but are there any changes?
+
+        changedItems = iContactsDb->ContactsChangedSinceL( tTime ); //Create a contactidarray, user takes the ownership
+        CleanupStack::PushL(changedItems);
+
+        LOGGER_WRITE_1( "CreateIrMCL2FileL changedItems %d", changedItems->Count() );
+        LOGGER_WRITE_1( "CreateIrMCL2FileL aForced %d", aForced );
+        //Are there changes in any contact
+        if( changedItems->Count()!=0 || aForced || ContactCountChanged() )
+            {
+            LOGGER_WRITE( "CntParserCollector: CreateIrMCL2FileL: Changes in CDB, replace existing PB.VCF" );
+
+            CleanupStack::PopAndDestroy(changedItems);
+
+            //Create pb.vcf
+            User::LeaveIfError( iWriter.Replace( iFsSession, aFileName, EFileShareExclusive) );
+            LOGGER_WRITE( "CntParserCollector: CreateIrMCL2FileL: file replaced" );
+            CleanupStack::Pop();    //iWriter
+            ParseCntDatabaseL(); //create IrMC L2 stuff
+            SaveTotalCountL();
+            return KErrNone;    //File created normally
+            }
+
+        //No changes
+        CleanupStack::PopAndDestroy(changedItems);
+        CleanupStack::PopAndDestroy();
+
+        LOGGER_WRITE( "CntParserCollector: CreateIrMCL2FileL: No Changes in CDB, keep old PB.VCF" );
+        }   
+    return KPBNotUpdated;   //No error occured, KPBNotUpdated used as return value to tell that the file was not created..
+    }
+//------------------------------------------------------------
+// CCntParserCollector::ParseCntDatabaseL()
+//------------------------------------------------------------
+void CCntParserCollector::ParseCntDatabaseL()
+    {
+    LOGGER_WRITE( "CntParserCollector: ParseCntDatabaseL" );
+
+    iCurrentItem = 0;
+    iCancel = EFalse;
+    iContactsSaved = 0;
+
+    //Create owncard (it's always included, even if it's empty)
+
+    TFileName defaultDb;
+    CContactDatabase::GetDefaultNameL( defaultDb );
+    TFileName currentDb;
+    iContactsDb->GetCurrentDatabase( currentDb );
+
+    if( defaultDb.CompareF(currentDb) == 0 || currentDb == KNullDesC16 /*|| currentDb.CompareF(KSimDummyDatabase)==0*/) //Is current database also default?
+        {
+        LOGGER_WRITE( "CntParserCollector: ParseCntDatabaseL: Using default database" );
+        TContactItemId ownCardId = iContactsDb->OwnCardId();
+        ExternalizeCurrentContactL( iContactsDb, ownCardId, ETrue);
+        }
+    else
+        {
+        LOGGER_WRITE( "CntParserCollector: ParseCntDatabaseL: Not using default database" );
+        CContactDatabase* db=CContactDatabase::OpenL(); //My contact card is only in default db, so open it
+        CleanupStack::PushL(db);
+
+        TContactItemId ownCardId = db->OwnCardId();
+        ExternalizeCurrentContactL( db, ownCardId, ETrue );
+
+        CleanupStack::PopAndDestroy( db );
+        }
+
+    //Start running RunL method and create everything else..
+    TRequestStatus* s = &iStatus;
+    User::RequestComplete( s, KErrNone );
+    SetActive();
+    }
+//------------------------------------------------------------
+// CCntParserCollector::CloseResources()
+//------------------------------------------------------------
+void CCntParserCollector::CloseResources()
+    {
+    LOGGER_WRITE( "CntParserCollector: CloseResources: Closing resources (iWriter)" );
+    iWriter.Close();
+    }
+//------------------------------------------------------------
+// CCntParserCollector::PrepareParserL()
+//------------------------------------------------------------
+void CCntParserCollector::PrepareParserL()
+    {
+    LOGGER_WRITE( "CntParserCollector: PrepareParserL" );
+    iFilter = CCntFilter::NewL();   //Filter all contact cards out of others
+
+    iFilter->SetContactFilterTypeALL( EFalse );
+    iFilter->SetContactFilterTypeCard( ETrue );
+    iContactsDb->FilterDatabaseL( *iFilter );
+
+    iIds=iFilter->iIds; //Get IDs to filtered contacts
+    iCount=iIds->Count(); //Get number of contacts to be collected
+
+    User::LeaveIfError( iFsSession.Connect() ); //Connect to the file server
+    
+    LOGGER_WRITE_1( "CntParserCollector: PrepareParserL: iCount == %d", iCount);
+    }
+//------------------------------------------------------------
+// CCntParserCollector::RunL()
+//------------------------------------------------------------
+void CCntParserCollector::RunL()
+    {
+    //MaxNumberOfContacts-1 for OwnCard
+    if( iCurrentItem < iCount && (iCurrentItem < ( iMaxNumberOfContacts - 1 ) || iMaxNumberOfContacts == -1 ) ) //If no more contacts left or maximum number of contacts already parsed
+        {
+        ExternalizeCurrentContactL( iContactsDb, (*iIds)[iCurrentItem], EFalse );
+        iCurrentItem++;
+        TRequestStatus* s = &iStatus;       //Let's rerun this RunL method as soon as possible
+        User::RequestComplete( s, KErrNone );
+        SetActive();
+        return;
+        }
+    iCurrentItem++; //for OwnCard that is created separately
+    LOGGER_WRITE( "CntParserCollector: RunL: No more items" );
+    CloseResources();
+    iServer->CompletePhoneBookRequests( KErrNone );
+    }
+//------------------------------------------------------------
+// CCntParserCollector::ExternalizeCurrentContactL(CContactDatabase* aContactsDb,TInt aCurrentItem,TBool ExternalizeEmpty)
+//------------------------------------------------------------
+void CCntParserCollector::ExternalizeCurrentContactL(CContactDatabase* aContactsDb,TInt aCurrentItem,TBool ExternalizeEmpty)
+    {
+    CContactItem* ownCard;
+
+    if( aCurrentItem < 0 )
+        {
+        ownCard = CContactCard::NewLC();
+        }
+    else
+        {
+        ownCard = aContactsDb->ReadContactLC( aCurrentItem );   //Take a new contact item
+        }
+
+    CParserVCard* VCard=CParserVCard::NewL();   //Create new VCard
+    CleanupStack::PushL( VCard );
+
+    TInt nField = ownCard->CardFields().Find( KUidContactFieldGivenName );
+    TInt fField = ownCard->CardFields().Find( KUidContactFieldFamilyName );
+    TInt cField = ownCard->CardFields().Find( KUidContactFieldCompanyName );
+
+    //FOR NAMES
+    //N: -field always included even if it's empty
+    CDesC16Array* ValueArray=new (ELeave) CDesCArrayFlat(4);
+    CleanupStack::PushL( ValueArray );
+    CParserPropertyValueCDesCArray* NameValues=new (ELeave) CParserPropertyValueCDesCArray( ValueArray );
+    CleanupStack::PushL( NameValues );
+    CArrayPtr<CParserParam>* parameters=new (ELeave) CArrayPtrFlat<CParserParam>(1);
+    CleanupStack::PushL( parameters );
+
+    TPtrC fName;
+    TPtrC nName;
+    TPtrC cName;
+
+    if( fField != KErrNotFound )
+        {
+        fName.Set( ownCard->CardFields()[fField].TextStorage()->Text() );
+        }
+    if( nField != KErrNotFound )
+        {
+        nName.Set( ownCard->CardFields()[nField].TextStorage()->Text() );
+        }
+    if( cField != KErrNotFound )
+        {
+        cName.Set( ownCard->CardFields()[cField].TextStorage()->Text() );
+        }
+
+    if( fName.Length() == 0)
+        {
+        fField = KErrNotFound;  
+        }
+    if(nName.Length()==0)
+        {
+        nField = KErrNotFound;
+        if( fField==KErrNotFound )
+            {
+            ValueArray->AppendL( cName );   
+            }
+        else
+            {
+            ValueArray->AppendL( fName );   
+            }
+        }
+    else
+        {
+        ValueArray->AppendL( fName );
+        ValueArray->AppendL( nName );
+        }
+
+    VCard->AddPropertyL( CParserProperty::NewL((*NameValues),KNameProperty,parameters) );   //Add name property to VCard (VCard takes the ownership of the property)
+    CleanupStack::Pop(3); //parameters namevalues valuearray
+
+    TBool isNumber = EFalse;
+
+    TInt typeIndex = 0;
+    TInt index = -1;    //NOTE: +1 added before used first time
+
+    for(;;) //Go through all fields (Number of fields is unknown)
+        {
+        index = ownCard->CardFields().FindNext(typesToBeSearched[typeIndex],index+1);//Find next field (of current type)
+        if( index == KErrNotFound ) //No more phone numbers, move to the next group -> (See TypesToBeSearched)
+            {
+            typeIndex++;
+            if( typeIndex >= (signed) (sizeof(typesToBeSearched) / sizeof(TUid)) )
+                {
+                break;  //if no more types to search -> exit FOR-loop
+                }
+
+            index=ownCard->CardFields().FindNext(typesToBeSearched[typeIndex],0); //Find next field
+            if( index==KErrNotFound )
+                {
+                break;  //No fields -> exit
+                }
+            }
+
+        TPtrC number = ownCard->CardFields()[index].TextStorage()->Text();
+        if( number.Length() != 0)
+            {
+            CDesC16Array* ValueArray2=new (ELeave) CDesCArrayFlat(4);
+            CleanupStack::PushL( ValueArray2 );
+            CParserPropertyValueCDesCArray* NumberValues=new (ELeave) CParserPropertyValueCDesCArray(ValueArray2);
+            CleanupStack::PushL( NumberValues );
+            CArrayPtr<CParserParam>* parameters2=new (ELeave) CArrayPtrFlat<CParserParam>(1);
+            CleanupStack::PushL( parameters2 );
+
+            //Take label name to parameter
+
+            for( TInt i=0;i<ownCard->CardFields()[index].ContentType().FieldTypeCount();i++ )
+                {
+                TFieldType fieldType=ownCard->CardFields()[index].ContentType().FieldType(i);
+
+                if(fieldType==KUidContactFieldVCardMapWORK) parameters2->AppendL(CParserParam::NewL(KVersitParam8Work,KNullDesC8));
+                if(fieldType==KUidContactFieldVCardMapHOME) parameters2->AppendL(CParserParam::NewL(KVersitParam8Home,KNullDesC8));
+                if(fieldType==KUidContactFieldVCardMapMSG)  parameters2->AppendL(CParserParam::NewL(KVersitParam8Msg,KNullDesC8));
+                if(fieldType==KUidContactFieldVCardMapVOICE)parameters2->AppendL(CParserParam::NewL(KVersitParam8Voice,KNullDesC8));
+                if(fieldType==KUidContactFieldVCardMapFAX)  parameters2->AppendL(CParserParam::NewL(KVersitParam8Fax,KNullDesC8));
+                if(fieldType==KUidContactFieldVCardMapPREF) parameters2->AppendL(CParserParam::NewL(KVersitParam8Pref,KNullDesC8));
+                if(fieldType==KUidContactFieldVCardMapCELL) parameters2->AppendL(CParserParam::NewL(KVersitParam8Cell,KNullDesC8));
+                if(fieldType==KUidContactFieldVCardMapPAGER)parameters2->AppendL(CParserParam::NewL(KVersitParam8Pager,KNullDesC8));
+                if(fieldType==KUidContactFieldVCardMapBBS)  parameters2->AppendL(CParserParam::NewL(KVersitParam8Bbs,KNullDesC8));
+                if(fieldType==KUidContactFieldVCardMapMODEM)parameters2->AppendL(CParserParam::NewL(KVersitParam8Modem,KNullDesC8));
+                if(fieldType==KUidContactFieldVCardMapCAR)  parameters2->AppendL(CParserParam::NewL(KVersitParam8Car,KNullDesC8));
+                if(fieldType==KUidContactFieldVCardMapISDN) parameters2->AppendL(CParserParam::NewL(KVersitParam8Isdn,KNullDesC8));
+                if(fieldType==KUidContactFieldVCardMapVIDEO)parameters2->AppendL(CParserParam::NewL(KVersitParam8Video,KNullDesC8));
+                }
+
+            ValueArray2->AppendL( number );
+            VCard->AddPropertyL(CParserProperty::NewL((*NumberValues),KTelProperty,parameters2)); //VCard takes the ownership of the property
+            isNumber=ETrue;
+
+            CleanupStack::Pop(3); //parameters2 numbervalues valuearray2
+            }
+        }
+
+    if( (nField!=KErrNotFound) || (fField!=KErrNotFound) || (cField!=KErrNotFound) || isNumber || ExternalizeEmpty )
+        {
+        if( !isNumber )
+            {
+            //Create empty TEL field (required by the specs)
+
+            CDesC16Array* ValueArray3=new (ELeave) CDesCArrayFlat(4);
+            CleanupStack::PushL(ValueArray3);
+            CParserPropertyValueCDesCArray* NumberValues2=new (ELeave) CParserPropertyValueCDesCArray(ValueArray3);
+            CleanupStack::PushL(NumberValues2);
+            CArrayPtr<CParserParam>* parameters3=new (ELeave) CArrayPtrFlat<CParserParam>(1);
+            CleanupStack::PushL(parameters3);
+
+            VCard->AddPropertyL(CParserProperty::NewL((*NumberValues2),KTelProperty,parameters3)); //VCard takes the ownership of the property
+
+            CleanupStack::Pop(3); //parameters3 numbervalues valuearray3
+            }
+
+        TRAPD( err, VCard->ExternalizeL( iWriter );) //If there are no name or numbers, then no externalizing..
+        //if error then only current contact card is discarded, but others will be still collected..
+        if( err == KErrNone )
+            {
+            iContactsSaved++;
+            }
+        else
+            {
+            LOGGER_WRITE( "CntParserCollector: RunL: Error,VCARD _NOT_ saved" );
+            }
+        }
+
+    aContactsDb->CloseContactL( aCurrentItem ); //Close current contact item
+
+    CleanupStack::PopAndDestroy( VCard ); // VCard and all arrays (parameters2, numvervalues, valuearray2) related to this VCard are deleted through the ownership relations
+    CleanupStack::PopAndDestroy( ownCard );
+    }
+//------------------------------------------------------------
+// CCntParserCollector::DoCancel()
+//------------------------------------------------------------
+void CCntParserCollector::DoCancel()
+    {
+    LOGGER_WRITE( "CntParserCollector: DoCancel" );
+    CloseResources();
+    }
+//------------------------------------------------------------
+// CCntParserCollector::RunError(TInt aError)
+//------------------------------------------------------------
+TInt CCntParserCollector::RunError( TInt aError )
+    {
+    LOGGER_WRITE( "CntParserCollector: RunError!" );
+    CloseResources(); //JIC
+
+    iServer->CompletePhoneBookRequests( aError );   //complete all requests with an error
+    return KErrNone;
+    }
+//------------------------------------------------------------
+// CCntParserCollector::CurrentItem()
+//------------------------------------------------------------
+TInt CCntParserCollector::CurrentItem()
+    {
+    return iCurrentItem;
+    }
+//------------------------------------------------------------
+// CCntParserCollector::Count()
+//------------------------------------------------------------
+TInt CCntParserCollector::Count()
+    {
+    return iCount;
+    }
+//------------------------------------------------------------
+// CCntParserCollector::ContactsSaved()
+//------------------------------------------------------------
+TInt CCntParserCollector::ContactsSaved()
+    {
+    return iContactsSaved;
+    }
+//------------------------------------------------------------
+// CCntParserCollector::SaveTotalCountL() const
+//------------------------------------------------------------
+void CCntParserCollector::SaveTotalCountL()
+    {
+    LOGGER_WRITE( "CntParserCollector: SaveTotalCount begin" );
+        
+    if( iContactsDb )
+        {
+        iTotalCount = iContactsDb->CountL();
+        LOGGER_WRITE_1( "CntParserCollector: SaveTotalCount iTotalCount %d", iTotalCount );
+        }
+        
+    RFs Fs;
+    RFile writer;
+    User::LeaveIfError(Fs.Connect());   //Connect to the file server
+    CleanupClosePushL(Fs);
+    
+    User::LeaveIfError(Fs.CreatePrivatePath( EDriveC ));
+    User::LeaveIfError(Fs.SetSessionToPrivate( EDriveC ));
+    
+    User::LeaveIfError(writer.Replace(Fs,KTotalCountFilePath,EFileWrite)); //Open file
+    CleanupClosePushL(writer);
+    LOGGER_WRITE( "CntParserCollector: SaveTotalCount file replaced" );
+    
+    // Prepare externalized representation of iTotalCount
+    TBuf8< 256 > countData;
+    RDesWriteStream writeStream( countData );
+    CleanupClosePushL( writeStream );
+    writeStream.WriteInt32L( iTotalCount );
+    writeStream.CommitL();
+    CleanupStack::PopAndDestroy( &writeStream );
+    
+    // Then write them to the file itself
+    User::LeaveIfError(writer.Write( countData ));
+
+    CleanupStack::PopAndDestroy();  //writer
+    CleanupStack::PopAndDestroy();  //Fs
+    
+    LOGGER_WRITE( "CntParserCollector: SaveTotalCount end" );
+    }
+//------------------------------------------------------------
+// CCntParserCollector::ReadTotalCountL() const
+//------------------------------------------------------------
+TInt CCntParserCollector::ReadTotalCountL() const
+    {
+    LOGGER_WRITE( "CntParserCollector: ReadTotalCount begin" );
+    TInt total;
+    RFs Fs;
+    RFile reader;
+    User::LeaveIfError(Fs.Connect());   //Connect to the file server
+    CleanupClosePushL(Fs);
+    
+    User::LeaveIfError(Fs.CreatePrivatePath( EDriveC ));
+    User::LeaveIfError(Fs.SetSessionToPrivate( EDriveC ));
+        
+    User::LeaveIfError(reader.Open(Fs,KTotalCountFilePath,EFileRead)); //Open file
+    CleanupClosePushL(reader);
+    LOGGER_WRITE( "CntParserCollector: ReadTotalCount file opened" );
+        
+    RFileReadStream readStream(reader);
+    readStream.PushL();
+
+    total = readStream.ReadInt32L();
+    
+    LOGGER_WRITE_1( "CntParserCollector: ReadTotalCount total %d", total );
+    
+    CleanupStack::PopAndDestroy();  //readStream
+    CleanupStack::PopAndDestroy();  //writer
+    CleanupStack::PopAndDestroy();  //Fs
+    LOGGER_WRITE( "CntParserCollector: ReadTotalCount end" );
+    return total;
+    }
+//------------------------------------------------------------
+// CCntParserCollector::ContactCountChanged() const
+//------------------------------------------------------------
+TBool CCntParserCollector::ContactCountChanged()
+    {
+    LOGGER_WRITE( "CntParserCollector: ContactCountChanged begin" );
+    TInt oldCount = 0;
+    TInt err( KErrNone );
+    
+    if( iContactsDb )
+        {
+        TRAP( err, iTotalCount = iContactsDb->CountL() );
+        if ( err != KErrNone )
+            {
+            LOGGER_WRITE_1( "iContactsDb->CountL leaved: %d", err );
+            LOGGER_WRITE( "CntParserCollector: ContactCountChanged ETrue" );
+            return ETrue;
+            }
+        LOGGER_WRITE_1( "CntParserCollector: ContactCountChanged iTotalCount %d", iTotalCount );
+        }
+    
+    TRAP( err, oldCount = ReadTotalCountL() );
+
+    LOGGER_WRITE_1( "CntParserCollector: ContactCountChanged err %d", err );
+    LOGGER_WRITE_1( "CntParserCollector: ContactCountChanged oldCount %d", oldCount );
+    LOGGER_WRITE_1( "CntParserCollector: ContactCountChanged iTotalCount %d", iTotalCount );
+    
+    if( err == KErrNone )
+        {
+        if( iTotalCount != oldCount )
+            {
+            LOGGER_WRITE( "CntParserCollector: ContactCountChanged ETrue" );
+            return ETrue;
+            }
+        else
+            {
+            LOGGER_WRITE( "CntParserCollector: ContactCountChanged EFalse" );
+            return EFalse;
+            }
+        }
+    else
+        {
+        LOGGER_WRITE( "CntParserCollector: ContactCountChanged ETrue" );
+        return ETrue;               
+        }
+    }
+    
+// end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/src/cntparserinfolog.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,119 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CCntParserInfoLog implementation.
+*
+*/
+
+
+#include <s32strm.h>
+#include <f32file.h>
+#include <s32file.h>
+
+#include "cntparserinfolog.h"
+
+_LIT8(KNewLine,"\r\n");
+
+_LIT8(KMaxRecords,"Maximum-Records:");
+_LIT8(KTotalRecords,"Total-Records:");
+
+//------------------------------------------------------------
+// CCntParserInfoLog::CCntParserInfoLog()
+//------------------------------------------------------------
+CCntParserInfoLog::CCntParserInfoLog()
+    {
+    }
+
+//------------------------------------------------------------
+// CCntParserInfoLog::~CCntParserInfoLog()
+//------------------------------------------------------------
+CCntParserInfoLog::~CCntParserInfoLog()
+    {
+    }
+
+//------------------------------------------------------------
+// CCntParserInfoLog::CCntParserInfoLog::NewL()
+//------------------------------------------------------------
+EXPORT_C CCntParserInfoLog* CCntParserInfoLog::NewL()
+    {
+    CCntParserInfoLog* self=new (ELeave) CCntParserInfoLog();
+    return self;
+    }
+
+//------------------------------------------------------------
+// CCntParserInfoLog::SaveToFileL(const TDesC& aFileName) const
+//------------------------------------------------------------
+EXPORT_C void CCntParserInfoLog::SaveToFileL( const TDesC& aFileName ) const
+    {
+    TInt err = KErrNone;
+    RFs Fs;
+    RFile writer;
+    User::LeaveIfError( Fs.Connect() ); //Connect to the file server
+    CleanupClosePushL( Fs );
+    err = writer.Replace( Fs, aFileName, EFileWrite ); //Open file
+    CleanupClosePushL( writer );
+    
+    if( err == KErrNone )
+        {
+        writer.Write( KMaxRecords );
+        
+        TBuf8<16> numVal;
+        numVal.Num( iMaximumRecords );
+        writer.Write( numVal );
+        
+        writer.Write( KNewLine );
+        
+        writer.Write( KTotalRecords );
+        
+        TBuf8<16> numVal2;
+        numVal2.Num( iTotalRecords );
+        writer.Write( numVal2 );
+        }
+    
+    CleanupStack::PopAndDestroy();  //writer
+    CleanupStack::PopAndDestroy();  //Fs
+    }
+
+//------------------------------------------------------------
+// CCntParserInfoLog::SetTotalRecords(TInt aTotalRecords)
+//------------------------------------------------------------
+EXPORT_C void CCntParserInfoLog::SetTotalRecords(TInt aTotalRecords)
+    {
+    iTotalRecords = aTotalRecords;
+    }
+
+//------------------------------------------------------------
+// CCntParserInfoLog::SetMaximumRecords(TInt aMaximumRecords)
+//------------------------------------------------------------
+EXPORT_C void CCntParserInfoLog::SetMaximumRecords(TInt aMaximumRecords)
+    {
+    iMaximumRecords = aMaximumRecords;
+    }
+
+//------------------------------------------------------------
+// CCntParserInfoLog::TotalRecords() const
+//------------------------------------------------------------
+EXPORT_C TInt CCntParserInfoLog::TotalRecords() const
+    {
+    return iTotalRecords;
+    }
+
+//------------------------------------------------------------
+// CCntParserInfoLog::MaximumRecords() const
+//------------------------------------------------------------
+EXPORT_C TInt CCntParserInfoLog::MaximumRecords() const
+    {
+    return iMaximumRecords;
+    }
+    
+// end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/src/cntparserserverexe.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,322 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CCntParserServer implementation.
+*
+*/
+
+
+#include "clientserver.h"
+#include "cntparserserver.h"
+#include "cntparserserversession.h"
+#include "irmcconsts.h"
+
+#include "debug.h"
+
+#include <cntdb.h>
+
+//------------------------------------------------------------
+// RunServer
+//------------------------------------------------------------
+TInt CCntParserServer::RunServer()
+	{
+	LOGGER_ENTERFN( "CCntParserServer::RunServer" );
+	
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	TInt ret( KErrNoMemory );
+	if( cleanup )
+		{
+		TRAP( ret, CCntParserServer::RunServerL() );
+		delete cleanup;
+		}
+	if( ret != KErrNone )
+		{
+		// Signal the client that server creation failed
+		RProcess::Rendezvous( ret );
+		}
+	LOGGER_LEAVEFN( "CCntParserServer::RunServer" );
+	return ret;
+	}
+//------------------------------------------------------------
+// RunServerL
+//------------------------------------------------------------
+void CCntParserServer::RunServerL()
+	{
+	// Create and install the active scheduler we need
+	LOGGER_ENTERFN( "CCntParserServer::RunServerL" );
+	CActiveScheduler *as=new (ELeave)CActiveScheduler;
+	CleanupStack::PushL( as );
+	CActiveScheduler::Install( as );
+
+	// Create server
+	CCntParserServer::NewL();
+
+	// Initialisation complete, now signal the client
+	User::LeaveIfError( RThread().RenameMe( KTxtServer ) );
+	RProcess::Rendezvous( KErrNone );
+
+	// Ready to run
+	CActiveScheduler::Start();
+
+	// Cleanup the scheduler
+	CleanupStack::PopAndDestroy( as );
+	LOGGER_LEAVEFN( "CCntParserServer::RunServerL" );
+	}
+//------------------------------------------------------------
+// E32Main()
+//------------------------------------------------------------
+TInt E32Main()
+	{
+	return CCntParserServer::RunServer();
+	}
+//------------------------------------------------------------
+// PanicServer(TCntParserServerPanic aPanic)
+//------------------------------------------------------------
+GLDEF_C void PanicServer(TCntParserServerPanic aPanic)
+	{
+	LOGGER_WRITE( "PANIC SERVER!" );
+	_LIT(KTxtServerPanic,"Parser server panic");
+	User::Panic( KTxtServerPanic, aPanic );
+	}
+
+
+//**********************************
+//CCntParserServer
+//**********************************
+
+//------------------------------------------------------------
+// CCntParserServer::CCntParserServer()
+//------------------------------------------------------------
+CCntParserServer::CCntParserServer() : CServer2( EPriorityStandard )
+	{
+	}
+//------------------------------------------------------------
+// CCntParserServer::~CCntParserServer()
+//------------------------------------------------------------
+EXPORT_C CCntParserServer::~CCntParserServer()
+	{
+	if( iCollector )
+	    {
+	    iCollector->Cancel();
+	    }
+	delete iCollector;
+	delete iCurrentDatabase;
+	LOGGER_WRITE( "CntParserServer: DELETED!" );
+	}
+//------------------------------------------------------------
+// CCntParserServer* CCntParserServer::NewL()
+//------------------------------------------------------------
+EXPORT_C CCntParserServer* CCntParserServer::NewL()
+	{
+	LOGGER_WRITE( "CntParserServer: NEW" );
+	CCntParserServer* pS=new (ELeave) CCntParserServer();
+	CleanupStack::PushL(pS);
+	pS->StartL( KCntParserName );
+	CleanupStack::Pop( pS );
+	LOGGER_WRITE( "CntParserServer: Created" );
+	return pS;
+	}
+//------------------------------------------------------------
+// CCntParserServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMsg*/) const
+//------------------------------------------------------------
+CSession2* CCntParserServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMsg*/) const
+	{
+	LOGGER_WRITE( "CntParserServer: NEW SessionL" );
+	// check we're the right version
+	TVersion v( KCntParserMajorVersionNumber,KCntParserMinorVersionNumber,KCntParserBuildVersionNumber );
+	if ( !User::QueryVersionSupported( v,aVersion ) )
+		User::Leave( KErrNotSupported );
+	CCntParserServerSession* self=CCntParserServerSession::NewL( (CCntParserServer*)this );
+	return self;
+	}
+//------------------------------------------------------------
+// CCntParserServer::IncreaseSessionCountL()
+//------------------------------------------------------------
+void CCntParserServer::IncreaseSessionCountL()
+	{
+	LOGGER_WRITE( "CntParserServer: Increase Session Count" );
+	iSessionCount++;
+	if( iSessionCount == 1 )	//If first session, prepare collector
+		{
+		PrepareCollectorL();
+		}
+	}
+//------------------------------------------------------------
+// CCntParserServer::DecreaseSessionCount()
+//------------------------------------------------------------
+void CCntParserServer::DecreaseSessionCount()
+	{
+	LOGGER_WRITE( "CntParserServer: Decrease Session Count" );
+	iSessionCount--;
+	if( iSessionCount==0 )	//if last session is disconnected, delete server
+		{
+		Stop();
+		}
+	}
+//------------------------------------------------------------
+// CCntParserServer::ContactsParsed()
+//------------------------------------------------------------
+TInt CCntParserServer::ContactsParsed()
+	{
+	return iCollector->CurrentItem();
+	}
+//------------------------------------------------------------
+// CCntParserServer::TotalNumOfContacts()
+//------------------------------------------------------------
+TInt CCntParserServer::TotalNumOfContacts()	
+	{
+	//After the PrepareCollector is called, the number of contacts can be returned
+	return iCollector->Count();
+	}
+//------------------------------------------------------------
+// CCntParserServer::ContactsSaved()
+//------------------------------------------------------------
+TInt CCntParserServer::ContactsSaved()
+	{
+	return iCollector->ContactsSaved();
+	}
+//------------------------------------------------------------
+// CCntParserServer::PrepareCollectorL()
+//------------------------------------------------------------
+void CCntParserServer::PrepareCollectorL()
+	{
+	LOGGER_WRITE( "CntParserServer: Prepare collectorL: Open Contact Database" );
+
+	TFileName dbFile;
+	TFileName defaultDb;
+  
+	CContactDatabase::GetDefaultNameL( defaultDb );
+	
+	LOGGER_WRITE( "CntParserServer: Prepare collectorL: GetDefault" );
+
+	iCurrentDatabase=CContactDatabase::OpenL();
+	
+	LOGGER_WRITE( "CntParserServer: Prepare collectorL: OpenDefault" );
+
+	iCurrentDatabase->GetCurrentDatabase( dbFile );	//Get selected database
+
+	LOGGER_WRITE( "CntParserServer: Prepare collectorL: CompareDefault" );
+
+	if( dbFile.CompareF(defaultDb)!=0 && dbFile!=KNullDesC16 /*&& dbFile.CompareF(KSimDummyDatabase)!=0*/)	//If the selected database is not the default and something is selected
+		{
+		LOGGER_WRITE( "CntParserServer: Prepare collectorL: Close Default" );
+		delete iCurrentDatabase;
+		iCurrentDatabase = NULL;
+
+		LOGGER_WRITE( "CntParserServer: Prepare collectorL: OpenSelected" );
+		iCurrentDatabase=CContactDatabase::OpenL( dbFile );	//open the selected one
+		}
+
+	LOGGER_WRITE( "CntParserServer: Prepare collectorL: Is everything ok?" );
+	if( !iCurrentDatabase )
+		{
+		User::Leave( KErrNotFound );	
+		}
+
+	LOGGER_WRITE( "CntParserServer: Prepare collectorL: Create Collector" );
+	iCollector = CCntParserCollector::NewL( this,iCurrentDatabase );
+
+	iRequests = 0;
+	}
+//------------------------------------------------------------
+// CCntParserServer::CreateIrMCL2PhoneBookL()
+//------------------------------------------------------------
+TInt CCntParserServer::CreateIrMCL2PhoneBookL(const TDesC& path, TInt aMaxNumberOfContacts,TBool aForced)
+	{
+	LOGGER_WRITE( "CntParserServer: CreateIrMCL2PhoneBookL" );
+
+	TInt err( KErrNone );
+
+	iRequests++;
+	if( iRequests == 1 )
+		{
+		LOGGER_WRITE( "CntParserServer: CreateIrMCL2PhoneBookL: Ready to call collector" );
+
+		err = iCollector->CreateIrMCL2FileL( path,aMaxNumberOfContacts,aForced );
+		if( err==KPBNotUpdated ) 
+			{
+			iRequests = 0;	//If the file exists (no parsing), then more requests can be made	
+			}
+		}
+	else
+		{
+		return KErrNotReady;	
+		}
+	return err;
+	}
+//------------------------------------------------------------
+// CCntParserServer::CompletePhoneBookRequests()
+//------------------------------------------------------------
+void CCntParserServer::CompletePhoneBookRequests(TInt aErr)	//Goes through all the sessions and completes the request
+	{
+	LOGGER_WRITE( "CntParserServer: Complete phonebook request" );
+	iSessionIter.SetToFirst();
+	while( iSessionIter!=NULL )	//Go through all sessions
+		{
+		( (CCntParserServerSession*) (iSessionIter++) )->CompletePhoneBookRequest( aErr );
+		}
+	iRequests = 0;	//Collector is ready to start again..
+	}
+//------------------------------------------------------------
+// CCntParserServer::CancelPhoneBookRequest()
+//------------------------------------------------------------
+void CCntParserServer::CancelPhoneBookRequest()
+	{
+	if( iRequests == 1 )
+		{
+		iCollector->Cancel();
+		}
+	iRequests--;
+	}
+//------------------------------------------------------------
+// CCntParserServer::CancelAllPhoneBookRequests()
+//------------------------------------------------------------
+void CCntParserServer::CancelAllPhoneBookRequests()
+	{
+	iCollector->Cancel();
+	iRequests = 0;
+	}
+//------------------------------------------------------------
+// CCntParserServer::Disconnect()
+//------------------------------------------------------------
+void CCntParserServer::Disconnect()
+	{
+	LOGGER_WRITE( "CntParserServer: Disconnect" );
+	}
+//------------------------------------------------------------
+// CCntParserServer::Stop()
+//------------------------------------------------------------
+void CCntParserServer::Stop()
+	{
+	LOGGER_ENTERFN( "CntParserServer::Stop()" );
+	if( iCollector )
+	    {
+	    iCollector->Cancel();
+	    }
+	delete iCollector;
+	iCollector = NULL;
+	delete iCurrentDatabase;
+	iCurrentDatabase = NULL;
+	CActiveScheduler::Stop();
+	LOGGER_LEAVEFN( "CntParserServer::Stop()" );
+	}
+//------------------------------------------------------------
+// CCntParserServer::SetRequests()
+//------------------------------------------------------------
+void CCntParserServer::SetRequests(TInt aRequests)
+	{
+	iRequests=aRequests;
+	}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/src/cntparserserversession.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,219 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CCntParserServerSession implementation.
+*
+*/
+
+
+#include "cntparserserversession.h"
+#include <cntdb.h>
+#include "cntparsercollector.h"
+#include "cntparserinfolog.h"
+#include "irmcconsts.h"
+
+#include "debug.h"
+
+//------------------------------------------------------------
+// CCntParserServerSession::CCntParserServerSession()
+//------------------------------------------------------------
+CCntParserServerSession::CCntParserServerSession()
+    {
+    }
+//------------------------------------------------------------
+// CCntParserServerSession::NewL(CCntParserServer* aServer)
+//------------------------------------------------------------
+CCntParserServerSession* CCntParserServerSession::NewL( CCntParserServer* aServer )
+    {
+    LOGGER_ENTERFN( "CntParserServerSession::NewL()" );
+
+    CCntParserServerSession* self = new( ELeave ) CCntParserServerSession();
+    CleanupStack::PushL( self );
+    self->ConstructL( aServer );
+    CleanupStack::Pop( self );
+    LOGGER_LEAVEFN( "CntParserServerSession::NewL()" );
+    return self;
+    }
+//------------------------------------------------------------
+// CCntParserServerSession::ConstructL( CCntParserServer* aServer )
+//------------------------------------------------------------
+void CCntParserServerSession::ConstructL( CCntParserServer* aServer )
+    {
+    iContactsParserSrv = aServer;
+    iContactsParserSrv->IncreaseSessionCountL();
+    }
+//------------------------------------------------------------
+// CCntParserServerSession::~CCntParserServerSession()
+//------------------------------------------------------------
+CCntParserServerSession::~CCntParserServerSession()
+    {
+    LOGGER_ENTERFN( "CntParserServerSession::~CCntParserServerSession()" );
+    if ( iContactsParserSrv )
+        {
+        iContactsParserSrv->DecreaseSessionCount();
+        }
+    LOGGER_LEAVEFN( "CntParserServerSession::~CCntParserServerSession()" );
+    }
+//------------------------------------------------------------
+// CCntParserServerSession::ServiceL( const RMessage2& aMessage )
+//------------------------------------------------------------
+void CCntParserServerSession::ServiceL( const RMessage2& aMessage )
+    {
+    LOGGER_WRITE( "CntParserServerSession: ServiceL" );
+
+    TInt err( KErrNone );
+    TInt ret( KErrNone );
+
+    TRAP( err, ret = DispatchMessageL( aMessage ) );
+
+    if ( err != KErrNone )
+        {
+        LOGGER_WRITE_1( "CntParserServerSession: ServiceL: Error trapped, complete with ERR code %d", err );
+
+        iPhoneBookRequest = EFalse; //If requested, then clear request flag
+        iContactsParserSrv->SetRequests( 0 );   //Reset requests count in server to allow new requests to start..
+        aMessage.Complete( err ); //If trap error, complete with it
+        return;
+        }   
+
+    if ( ret == KErrNone )
+        {
+        LOGGER_WRITE( "CntParserServerSession: ServiceL: No complete" );
+        return;
+        }
+
+    if ( ret == KPerformComplete )
+        {
+        LOGGER_WRITE( "CntParserServerSession: ServiceL: Normal complete" );
+
+        aMessage.Complete( KErrNone );
+        return;
+        }
+
+    if ( ret == KPBNotUpdated )
+        {
+        LOGGER_WRITE( "CntParserServerSession: ServiceL: Complete (PB not updated)" );
+
+        iPhoneBookRequest = EFalse;
+        aMessage.Complete( KPBNotUpdated );
+        return;
+        }
+    LOGGER_WRITE( "CntParserServerSession: ServiceL: Error, should never come here" );
+    aMessage.Complete( KErrGeneral );
+    }
+//------------------------------------------------------------
+// CCntParserServerSession::CompletePhoneBookRequest( TInt aErr )
+//------------------------------------------------------------
+void CCntParserServerSession::CompletePhoneBookRequest( TInt aErr )
+    {
+    LOGGER_WRITE( "CntParserServerSession: CompletePhoneBookRequest" );
+
+    if ( iPhoneBookRequest ) //If this session has requested phonebook, then the completion should be done here, as it was not done in ServiceL
+        {
+        LOGGER_WRITE( "CntParserServerSession: CompletePhoneBookRequest: collector or cancel" );
+        iPhoneBookRequest = EFalse;
+        iPhoneBookRequestMessage.Complete( aErr );
+        }
+    else
+        {
+        LOGGER_WRITE( "CntParserServerSession: CompletePhoneBookRequest: No complete for this session" );
+        }
+    }
+//------------------------------------------------------------
+// CCntParserServerSession::DispatchMessageL( const RMessage2 &aMessage )
+//------------------------------------------------------------
+TInt CCntParserServerSession::DispatchMessageL( const RMessage2 &aMessage )
+    {
+    LOGGER_WRITE( "CntParserServerSession: DispatchMessageL" );
+
+    TInt res( KPerformComplete );
+
+    switch( aMessage.Function() )
+        {
+        case ECntParserServerCreateIrMCL2:  //Create pb.vcf file
+            {
+            res = ETrue;
+
+            if ( iPhoneBookRequest == EFalse )
+                {
+                iPhoneBookRequestMessage = aMessage;
+                iPhoneBookRequest = ETrue;
+
+                TInt sid=aMessage.SecureId();
+                TInt MaxNumOfContacts = aMessage.Int0();
+                TBool Forced = aMessage.Int1();
+                TBuf<8> sidLit;
+                sidLit.AppendNumFixedWidth( sid, EHex, 8);
+                TBuf<255> path;
+                path.Insert( 0, KPhoneBookFilename );
+
+                res = iContactsParserSrv->CreateIrMCL2PhoneBookL( path, (TInt) MaxNumOfContacts, Forced );
+                }
+            break;
+            }
+        case ECntParserServerCntParsed: //How many contacts already parsed
+            {
+            TPckgBuf<TInt> p((TInt) iContactsParserSrv->ContactsParsed());
+            aMessage.WriteL( 0, p, 0 );
+            break;
+            }
+        case ECntParserServerTotalNumOfContacts: //How many contacts total?
+            {
+            TPckgBuf<TInt> p((TInt) iContactsParserSrv->TotalNumOfContacts());
+            aMessage.WriteL( 0, p, 0 );
+            break;
+            }
+        case ECntParserServerDisconnect:    //Disconnect session from server
+            {
+            iContactsParserSrv->Disconnect();
+            break;
+            }
+        case ECntParserServerCancel:    //Cancel phone book request
+            {
+            if (iPhoneBookRequest)
+                {
+                iContactsParserSrv->CancelPhoneBookRequest();
+                CompletePhoneBookRequest( KErrCancel );
+                }
+            break;
+            }
+        case ECntParserServerCntSaved: //How many contacts total?
+            {
+            TPckgBuf<TInt> p((TInt) iContactsParserSrv->ContactsSaved());
+            aMessage.WriteL( 0, p, 0 );
+            break;
+            }
+        case ECntParserServerCancelAll: //Cancel all requests, not just current?
+            {
+            iContactsParserSrv->CancelAllPhoneBookRequests();
+            break;
+            }
+        // requests we don't understand
+        // so panic the client here, this function also completes the message
+        default:
+            {
+            PanicClient( EBadRequest );
+            break;
+            }
+        }
+    return res;
+    }
+//------------------------------------------------------------
+// CCntParserServerSession::PanicClient(TInt aPanic) const
+//------------------------------------------------------------
+void CCntParserServerSession::PanicClient(TInt aPanic) const
+    {
+    User::Panic( KTxtServer,aPanic );
+    }
+    
+// end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/common/conmltask/inc/sconconmltask.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,597 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Header file for ConML tasks
+*
+*/
+
+
+#ifndef _SCONCONMLTASK_H_
+#define _SCONCONMLTASK_H_
+
+#include <e32base.h>
+#include <f32file.h>
+
+const TInt KSConTaskPartiallyCompleted( 206 );
+const TInt KMaxPackageNameLength = 128;
+
+enum TSConMethodName
+    {
+    ECancel = 0,
+    EGetDataOwnerStatus,
+    EGetDataSize,
+    EGetStatus,
+    EInstall,
+    EListDataOwners,
+    EListInstalledApps,
+    EListPublicFiles,
+    ERequestData,
+    ESetBURMode,
+    ESetInstParams,
+    ESupplyData,
+    EUninstall,
+    EUpdateDeviceInfo,
+    EReboot,
+    EGetMetadata
+    };
+
+enum TSConInstallMode
+    {
+    ESilentInstall = 0,
+    EUnsilentInstall,
+    EUnknown
+    };
+    
+enum TSConUserPerm
+    {
+    EPermReadOnly = 0,
+    EPermNormal
+    };
+    
+enum TSConDOType
+    {
+    EActiveDataOwner = 1,
+    EPassiveDataOwner,
+    EHybridDataOwner
+    };
+    
+enum TSConHasFiles
+    {
+    ENoFiles = 0,
+    EPublicFiles,
+    ESystemFiles,
+    EPublicSystemFiles
+    };
+    
+enum TSConAppType
+    {
+    ESisApplication = 0,
+    ESisAugmentation,
+    EJavaApplication,
+    EWidgetApplication
+    };
+
+enum TSConBurMode
+    {
+    ESConBurNormal = 1,     // 1 BUR mode - normal
+    ESConBurBackupFull,     // 2 BUR mode – backup full
+    ESConBurBackupPartial,  // 3 BUR mode – backup partial
+    ESConBurRestoreFull,    // 4 BUR mode – restore full
+    ESConBurRestorePartial  // 5 BUR mode – restore partial
+    };
+
+enum TSConIncType
+    {
+    ESConNoBackup = 0,          // 0   No backup
+    ESConBackupBase = 100,      // 100 Backup – base
+    ESConBackupIncrement = 200  // 200 Backup - increment
+    };
+
+enum TSConTransferDataType
+    {
+    ESConRegistrationData = 1,  // 1 RegistrationData
+    ESConPassiveSnapshotData,   // 2 Passive snapshot data
+    ESConPassiveBaseData,       // 3 Passive base data
+    ESConPassiveIncrementalData,// 4 Passive incremental data 
+    ESConActiveSnapshotData,    // 5 Active snapshot data
+    ESConActiveBaseData,        // 6 Active base data
+    ESConActiveIncrementalData, // 7 Active incremental data
+    ESConSystemData,            // 8 System data
+    ESConSystemSnapshotData     // 9 System snapshot data
+    };
+
+enum TSConDataOwnerStatus
+    {
+    ESConUnset = 0,         // 0 Unset
+    ESConNotFound,          // 1 Not found
+    ESConReady,             // 2 Ready
+    ESConNotReady,          // 3 Not ready
+    ESConFailed,            // 4 Failed
+    ESConNotConnected,      // 5 Not connected
+    ESConNotImplemented     // 6 Not implemented
+    };
+
+
+
+
+//============================================================
+// class CSConReboot declaration
+//============================================================  
+NONSHARABLE_CLASS( CSConReboot ) : public CBase
+    {
+    public:
+        CSConReboot();      
+        ~CSConReboot();
+        CSConReboot* CopyL();
+                    
+        //used only with reply
+        TBool               iComplete;      //task complete
+        TInt                iProgress;      //task progress     
+    };
+
+//============================================================
+// class CSConDataOwner declaration
+//============================================================  
+NONSHARABLE_CLASS( CSConDataOwner ) : public CBase
+    {
+    public:
+        CSConDataOwner();
+        ~CSConDataOwner();
+        CSConDataOwner* CopyL();
+    
+    public:
+        //dataowner type
+        TSConDOType                     iType;
+        //unique identifier
+        TUid                            iUid;
+        //drive list
+        TDriveList                      iDriveList;
+        //package name
+        TBuf<KMaxPackageNameLength>     iPackageName;
+        //requires reboot
+        TBool                           iReqReboot;
+        //has files 
+        TSConHasFiles                   iHasFiles;
+        //supports incremental backup
+        TBool                           iSupportsInc;
+        //supports selective backup
+        TBool                           iSupportsSel;
+        //delay to prepare data
+        TBool                           iDelayToPrep;
+        //size
+        TUint                           iSize;
+        //data owner status
+        TSConDataOwnerStatus            iDataOwnStatus;
+        //transfer data type
+        TSConTransferDataType           iTransDataType;
+        //Java hash
+        HBufC*                          iJavaHash;
+    };
+        
+//============================================================
+// class CSConUpdateDeviceInfo declaration
+//============================================================      
+NONSHARABLE_CLASS( CSConUpdateDeviceInfo ) : public CBase
+    {
+    public:
+        CSConUpdateDeviceInfo();
+        ~CSConUpdateDeviceInfo();
+        CSConUpdateDeviceInfo* CopyL();
+
+        TBuf8<3>            iVersion;       //version number
+        TBool               iInstallSupp;
+        TBool               iUninstallSupp;
+        TBool               iInstParamsSupp;
+        TBool               iInstAppsSupp;
+        TBool               iDataOwnersSupp;
+        TBool               iSetBURModeSupp;
+        TBool               iGetSizeSupp;
+        TBool               iReqDataSupp;
+        TBool               iSupplyDataSupp;
+        TBool               iRebootSupp;
+        TInt                iMaxObjectSize; //kBytes
+        
+        //used only with reply
+        TBool               iComplete;      //task complete
+        TInt                iProgress;      //task progress     
+    };
+//============================================================
+// class CSConInstApp declaration
+//============================================================      
+NONSHARABLE_CLASS( CSConInstApp ) : public CBase 
+    {
+    public:
+        CSConInstApp() {};
+        ~CSConInstApp() {};
+        CSConInstApp* CopyL();
+        
+        TFileName       iName;
+        TFileName       iParentName;
+        TFileName       iVendor;
+        TFileName       iVersion;
+        TInt64          iSize;
+        TSConAppType    iType;
+        TUid            iUid;
+    };
+    
+//============================================================
+// class CSConListInstApps declaration
+//============================================================      
+NONSHARABLE_CLASS( CSConListInstApps ) : public CBase
+    {
+    public:
+        CSConListInstApps();
+        ~CSConListInstApps();
+        CSConListInstApps* CopyL();
+            
+        TBool                   iAllApps;       //list all apps
+        TDriveList              iDriveList;     //drive list
+
+        //used only with reply
+        TBool               iComplete;      //task complete
+        TInt                iProgress;      //task progress 
+                
+        RPointerArray<CSConInstApp>     iApps; //installed apps
+    };
+    
+//============================================================
+// class CSConGetStatus declaration
+//============================================================      
+NONSHARABLE_CLASS( CSConGetStatus ) : public CBase
+    {
+    public:
+        TBool               iAll;           //list all statuses
+        TInt                iTaskId;        //task id
+    };  
+    
+//============================================================
+// class CSConFile declaration
+//============================================================      
+NONSHARABLE_CLASS( CSConFile ) : public CBase
+    {
+    public:
+        CSConFile();
+        ~CSConFile();
+        CSConFile* CopyL();     
+            
+        TFileName                   iPath;      //file path + name
+        TBuf<KMaxTimeFormatSpec>    iModified;  //modified date
+        TUint                       iSize;      //file size
+        TSConUserPerm               iUserPerm;  //user permission
+    };  
+    
+//============================================================
+// class CSConInstall declaration
+//============================================================      
+NONSHARABLE_CLASS( CSConInstall ) : public CBase
+    {
+    public:
+        CSConInstall();
+        ~CSConInstall();
+            
+        CSConInstall* CopyL();
+            
+        TFileName           iPath;          //path to file
+        TSConInstallMode    iMode;          //install mode
+        
+        //used only with reply
+        TBool               iComplete;      //task complete
+        TInt                iProgress;      //task progress 
+    };  
+    
+//============================================================
+// class CSConUninstall declaration
+//============================================================      
+NONSHARABLE_CLASS( CSConUninstall ) : public CBase
+    {
+    public:
+        CSConUninstall();
+        ~CSConUninstall();
+            
+        CSConUninstall* CopyL();
+            
+        TFileName           iName;          // application name
+        TFileName           iVendor;        // application vendor
+        TUid                iUid;           // application uid
+        TSConAppType    	iType;			// application type
+        TSConInstallMode    iMode;          // install mode
+        
+        //used only with reply
+        TBool               iComplete;      //task complete
+        TInt                iProgress;      //task progress 
+    };  
+    
+//============================================================
+// class CSConListDataOwners declaration
+//============================================================      
+NONSHARABLE_CLASS( CSConListDataOwners ) : public CBase
+    {
+    public:
+        CSConListDataOwners();
+        ~CSConListDataOwners();         
+        CSConListDataOwners* CopyL();           
+        void DeleteDataOwners();
+            
+        //used only with reply
+        TBool               iComplete;      //task complete
+        TInt                iProgress;      //task progress 
+        
+        RPointerArray<CSConDataOwner>   iDataOwners;    //data owners
+    };
+    
+//============================================================
+// class CSConSetBURMode declaration
+//============================================================      
+NONSHARABLE_CLASS( CSConSetBURMode ) : public CBase
+    {
+    public:
+        TDriveList          iDriveList;     //drive list
+        TSConBurMode        iPartialType;   //partial backup type
+        TSConIncType        iIncType;       //incremental backup type
+        
+        CSConSetBURMode();
+        ~CSConSetBURMode();     
+        CSConSetBURMode* CopyL();
+        
+        //used only with reply
+        TBool               iComplete;      //task complete
+        TInt                iProgress;      //task progress 
+    };
+
+//============================================================
+// class CSConGetDataSize declaration
+//============================================================  
+NONSHARABLE_CLASS( CSConGetDataSize ) : public CBase
+    {
+    public:
+        CSConGetDataSize();
+        ~CSConGetDataSize();
+        
+        CSConGetDataSize* CopyL();          
+        void DeleteDataOwners();
+            
+    public:
+        RPointerArray<CSConDataOwner> iDataOwners;  //data owners
+        
+        //used only with reply
+        TBool               iComplete;      //task complete
+        TInt                iProgress;      //task progress 
+    };
+    
+//============================================================
+// class CSConListPublicFiles declaration
+//============================================================  
+NONSHARABLE_CLASS( CSConListPublicFiles ) : public CBase
+    {
+    public:
+        CSConListPublicFiles();
+        ~CSConListPublicFiles();            
+        CSConListPublicFiles* CopyL();
+        
+    public:
+        RPointerArray<CSConFile>        iFiles;         //data owners
+        RPointerArray<CSConDataOwner>   iDataOwners;    //data owners
+        
+        //used only with reply
+        TBool               iComplete;      //task complete
+        TInt                iProgress;      //task progress 
+    };
+    
+//============================================================
+// class CSConRequestData declaration
+//============================================================  
+NONSHARABLE_CLASS( CSConRequestData ) : public CBase
+    {
+    public:
+        CSConRequestData();         
+        ~CSConRequestData();            
+        CSConRequestData* CopyL();          
+        void DeleteDataAndDataOwner();
+            
+        CSConDataOwner*     iDataOwner;     //data owner
+        HBufC8*             iBackupData;    //backup data
+        TBool               iMoreData;      //more data
+        
+        //used only with reply
+        TBool               iComplete;      //task complete
+        TInt                iProgress;      //task progress 
+    };
+    
+//============================================================
+// class CSConGetDataOwnerStatus declaration
+//============================================================  
+NONSHARABLE_CLASS( CSConGetDataOwnerStatus ) : public CBase
+    {
+    public:
+        CSConGetDataOwnerStatus();
+        ~CSConGetDataOwnerStatus();         
+        CSConGetDataOwnerStatus* CopyL();
+        void DeleteDataOwners();
+            
+    public:
+        RPointerArray<CSConDataOwner> iDataOwners;  //data owners
+        
+        //used only with reply
+        TBool               iComplete;      //task complete
+        TInt                iProgress;      //task progress 
+    };
+
+//============================================================
+// class CSConSupplyData declaration
+//============================================================  
+NONSHARABLE_CLASS( CSConSupplyData ) : public CBase
+    {
+    public:
+        CSConSupplyData();
+        ~CSConSupplyData();         
+        CSConSupplyData* CopyL();
+    public:
+        CSConDataOwner*     iDataOwner;
+        HBufC8*             iRestoreData;   //restore data
+        TBool               iMoreData;      //more data     
+        //used only with reply
+        TBool               iComplete;      //task complete
+        TInt                iProgress;      //task progress 
+    };
+
+//============================================================
+// class CSConGetMetadata declaration
+//============================================================
+NONSHARABLE_CLASS( CSConGetMetadata ) : public CBase
+    {
+    public:
+        CSConGetMetadata();
+        ~CSConGetMetadata();            
+        CSConGetMetadata* CopyL();
+    public:
+        TFileName           iFilename;
+        HBufC8*             iData;          //metadata
+        TBool               iMoreData;      //more data     
+        //used only with reply
+        TBool               iComplete;      //task complete
+        TInt                iProgress;      //task progress 
+    };
+
+//============================================================
+// class CSConTask declaration
+//============================================================  
+NONSHARABLE_CLASS( CSConTask ): public CBase
+    {
+    public:
+        /**
+        * Two-phase constructor
+        * @return CSConTask instance
+        */
+        static CSConTask* NewL( TSConMethodName aMethod );
+        static CSConTask* NewLC( TSConMethodName aMethod );
+
+        CSConTask();
+        ~CSConTask();
+        TSConMethodName GetServiceId() const;
+        CSConTask* CopyL() const;
+        TBool GetComplete();
+        void SetCompleteValue( TBool aValue );
+        TBool GetCompleteValue();
+        void SetProgressValue( TInt aValue );
+    private:
+        
+        void ConstructL( TSConMethodName aMethod );                
+    public:
+        //Task
+        //service id
+        TSConMethodName             iMethod;
+        //task number
+        TInt                        iTaskId;            
+        
+        //DeviceInfo -params
+        CSConUpdateDeviceInfo*      iDevInfoParams;
+        //ListInstalledTasks -params
+        CSConListInstApps*          iListAppsParams;
+        //GetStatus -params
+        CSConGetStatus*             iGetStatusParams;
+        //Install -params
+        CSConInstall*               iInstallParams; 
+        //Uninstall -params 
+        CSConUninstall*             iUninstallParams;
+        //SetBURMode -params
+        CSConSetBURMode*            iBURModeParams;
+        //GetDataSize -params
+        CSConGetDataSize*           iGetDataSizeParams;
+        //RequestData -params
+        CSConRequestData*           iRequestDataParams; 
+        //GetDataOwnerStatus -params
+        CSConGetDataOwnerStatus*    iGetDataOwnerParams;
+        //SupplyData -params
+        CSConSupplyData*            iSupplyDataParams;
+        //ListPublicFiles -params
+        CSConListPublicFiles*       iPubFilesParams;
+        //ListDataOwners -params
+        CSConListDataOwners*        iListDataOwnersParams;
+        //Reboot -params
+        CSConReboot*                iRebootParams;
+        //GetMetadata -params
+        CSConGetMetadata*           iGetMetadataParams;
+        
+        TInt                        iCancelTaskId;
+        TBool                       iCancelTaskAll;
+    };
+    
+//============================================================
+// class CSConTaskReply declaration
+//============================================================
+NONSHARABLE_CLASS( CSConTaskReply ) : public CBase
+    {
+    public:
+        CSConTaskReply();
+        CSConTaskReply( TSConMethodName aMethod );
+        ~CSConTaskReply();
+        void InitializeL( const CSConTask& aTask );   
+        void InitializeL( TSConMethodName aMethod, 
+            TInt aProgress, TBool aComplete );           
+        CSConTaskReply* CopyAndFreeL();
+        void CleanTaskData();
+            
+    public:
+        //task id number
+        TInt                        iTaskId;
+        //method type
+        TSConMethodName             iMethod;
+        
+        //DeviceInfo -params
+        CSConUpdateDeviceInfo*      iDevInfoParams;
+        //ListInstalledTasks -params
+        CSConListInstApps*          iListAppsParams;
+        //GetStatus -params
+        CSConGetStatus*             iGetStatusParams;
+        //Install -params
+        CSConInstall*               iInstallParams;
+        //Uninstall -params
+        CSConUninstall*             iUninstallParams;
+        //SetBURMode -params
+        CSConSetBURMode*            iBURModeParams;
+        //GetDataSize -params
+        CSConGetDataSize*           iGetDataSizeParams;
+        //RequestData -params
+        CSConRequestData*           iRequestDataParams;
+        //GetDataOwnerStatus -params
+        CSConGetDataOwnerStatus*    iGetDataOwnerParams;
+        //SupplyData -params
+        CSConSupplyData*            iSupplyDataParams;
+        //ListPublicFiles -params
+        CSConListPublicFiles*       iPubFilesParams;
+        //ListDataOwners -params
+        CSConListDataOwners*        iListDataOwnersParams;
+        //Reboot -params
+        CSConReboot*                iRebootParams;
+        //GetMetadata -params
+        CSConGetMetadata*           iGetMetadataParams;
+    };      
+    
+//============================================================
+// class CSConStatusReply declaration
+//============================================================
+NONSHARABLE_CLASS( CSConStatusReply ): public CBase
+    {
+    public:
+        CSConStatusReply();
+        ~CSConStatusReply();
+            
+    public:
+        TBool                           iNoTasks;       //no active tasks
+        RPointerArray<CSConTaskReply>   iTasks;
+    };
+
+#endif
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/common/conmltask/src/sconconmltask.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1684 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML Task implementations
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "sconconmltask.h"
+
+// -----------------------------------------------------------------------------
+// CSConReboot::CSConReboot()
+// 
+// -----------------------------------------------------------------------------
+//
+CSConReboot::CSConReboot() : iComplete( EFalse ), iProgress( 0 )
+    {
+    }
+        
+// -----------------------------------------------------------------------------
+// CSConReboot::~CSConReboot()
+// 
+// -----------------------------------------------------------------------------
+//  
+CSConReboot::~CSConReboot()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSConReboot::Copy()
+// 
+// -----------------------------------------------------------------------------
+//          
+CSConReboot* CSConReboot::CopyL()
+    {
+    CSConReboot* copy = new (ELeave) CSConReboot();
+    copy->iComplete = iComplete;
+    copy->iProgress = iProgress;
+    return copy;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConDataOwner::CSConDataOwner()
+// 
+// -----------------------------------------------------------------------------
+//  
+CSConDataOwner::CSConDataOwner()
+    {
+    iHasFiles = ENoFiles;
+    iJavaHash = NULL;
+    iUid.iUid = 0;
+    
+    //Initialize iDriveList with zeros
+    iDriveList.Fill( '\x0' );
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConDataOwner::~CSConDataOwner()
+// 
+// -----------------------------------------------------------------------------
+//  
+CSConDataOwner::~CSConDataOwner()
+    {
+    delete iJavaHash;
+    iJavaHash = NULL;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConDataOwner::Copy()
+// 
+// -----------------------------------------------------------------------------
+//          
+CSConDataOwner* CSConDataOwner::CopyL()
+    {
+    CSConDataOwner* copy = new (ELeave) CSConDataOwner();
+    copy->iType = iType;
+    copy->iUid = iUid;
+    copy->iDriveList.Copy( iDriveList );
+    copy->iPackageName = iPackageName;
+    copy->iReqReboot = iReqReboot;
+    copy->iHasFiles = iHasFiles;
+    copy->iSupportsInc = iSupportsInc;
+    copy->iSupportsSel = iSupportsSel;
+    copy->iDelayToPrep = iDelayToPrep;
+    copy->iSize = iSize;
+    copy->iDataOwnStatus = iDataOwnStatus;
+    copy->iTransDataType = iTransDataType;
+    
+    if ( iJavaHash )
+        {
+        if ( copy->iJavaHash )
+            {
+            delete copy->iJavaHash;
+            copy->iJavaHash = NULL;
+            }
+        copy->iJavaHash = iJavaHash->Alloc();
+        }
+                        
+    return copy;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConUpdateDeviceInfo::CSConUpdateDeviceInfo()
+// 
+// -----------------------------------------------------------------------------
+//  
+CSConUpdateDeviceInfo::CSConUpdateDeviceInfo() : 
+            iInstallSupp(EFalse), iUninstallSupp(EFalse), 
+            iInstParamsSupp(EFalse), iInstAppsSupp(EFalse), 
+            iDataOwnersSupp(EFalse), iSetBURModeSupp(EFalse),
+            iGetSizeSupp(EFalse), iReqDataSupp(EFalse), 
+            iSupplyDataSupp(EFalse), iRebootSupp(EFalse),
+            iComplete( EFalse ), iProgress( 0 )
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConUpdateDeviceInfo::~CSConUpdateDeviceInfo()
+// 
+// -----------------------------------------------------------------------------
+//           
+CSConUpdateDeviceInfo::~CSConUpdateDeviceInfo()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSConUpdateDeviceInfo::Copy()
+// 
+// -----------------------------------------------------------------------------
+//          
+CSConUpdateDeviceInfo* CSConUpdateDeviceInfo::CopyL()
+    {
+    CSConUpdateDeviceInfo* copy = new (ELeave) CSConUpdateDeviceInfo();
+    copy->iVersion.Copy( iVersion );
+    copy->iInstallSupp = iInstallSupp;
+    copy->iUninstallSupp = iUninstallSupp;
+    copy->iInstParamsSupp = iInstParamsSupp;
+    copy->iInstAppsSupp = iInstAppsSupp;
+    copy->iDataOwnersSupp = iDataOwnersSupp;
+    copy->iSetBURModeSupp = iSetBURModeSupp;
+    copy->iGetSizeSupp = iGetSizeSupp;
+    copy->iReqDataSupp = iReqDataSupp;
+    copy->iSupplyDataSupp = iSupplyDataSupp;
+    copy->iMaxObjectSize = iMaxObjectSize;
+    copy->iRebootSupp = iRebootSupp;
+    copy->iComplete = iComplete;
+    copy->iProgress = iProgress;        
+                
+    return copy;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConInstApp::Copy()
+// 
+// -----------------------------------------------------------------------------
+//  
+CSConInstApp* CSConInstApp::CopyL()
+    {
+    CSConInstApp* copy = new (ELeave) CSConInstApp();
+            
+    copy->iName.Copy( iName ); 
+    copy->iParentName.Copy( iParentName );
+    copy->iVendor.Copy( iVendor );
+    copy->iVersion.Copy( iVersion );
+    copy->iSize = iSize;
+    copy->iType = iType;
+    copy->iUid = iUid;
+
+    return copy;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConListInstApps::CSConListInstApps()
+// 
+// -----------------------------------------------------------------------------
+//      
+CSConListInstApps::CSConListInstApps() : iComplete( EFalse ), iProgress( 0 )
+    {
+    //Initialize iDriveList with zeros
+    iDriveList.Fill( '\x0' );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConListInstApps::~CSConListInstApps()
+// 
+// -----------------------------------------------------------------------------
+//      
+CSConListInstApps::~CSConListInstApps()
+    {
+    iApps.ResetAndDestroy();
+    iApps.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CSConListInstApps::CopyL()
+// 
+// -----------------------------------------------------------------------------
+//              
+CSConListInstApps* CSConListInstApps::CopyL()
+    {
+    CSConListInstApps* copy = new (ELeave) CSConListInstApps();
+    copy->iAllApps = iAllApps;
+    copy->iDriveList = iDriveList;
+            
+    copy->iComplete = iComplete;
+    copy->iProgress = iProgress;            
+        
+    for( TInt i = 0; i < iApps.Count(); i++ )
+        {
+        copy->iApps.Append( iApps[i]->CopyL() );
+        }
+            
+    return copy;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFile::CSConFile
+// 
+// -----------------------------------------------------------------------------
+//  
+CSConFile::CSConFile()
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConFile::~CSConFile
+// 
+// -----------------------------------------------------------------------------
+//  
+CSConFile::~CSConFile()
+    {
+    
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConFile::Copy()
+// 
+// -----------------------------------------------------------------------------
+//  
+CSConFile* CSConFile::CopyL()
+    {
+    CSConFile* copy = new (ELeave) CSConFile();
+            
+    copy->iPath.Copy( iPath ); 
+    copy->iModified.Copy( iModified );
+    copy->iSize = iSize;
+    copy->iUserPerm = iUserPerm;
+
+    return copy;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConInstall::CSConInstall()
+// 
+// -----------------------------------------------------------------------------
+//      
+CSConInstall::CSConInstall() : iMode( EUnknown ), iComplete( EFalse ), iProgress( 0 ) 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSConInstall::~CSConInstall()
+// 
+// -----------------------------------------------------------------------------
+//              
+CSConInstall::~CSConInstall()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSConInstall::CopyL()
+// 
+// -----------------------------------------------------------------------------
+//              
+CSConInstall* CSConInstall::CopyL()
+    {
+    CSConInstall* copy = new (ELeave) CSConInstall();
+    copy->iPath = iPath;
+    copy->iMode = iMode;
+            
+    copy->iComplete = iComplete;
+    copy->iProgress = iProgress;
+            
+    return copy;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConUninstall::CSConUninstall()
+// 
+// -----------------------------------------------------------------------------
+//  
+CSConUninstall::CSConUninstall() : iMode( EUnknown ), iComplete( EFalse ), iProgress( 0 )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSConUninstall::~CSConUninstall()
+// 
+// -----------------------------------------------------------------------------
+//          
+CSConUninstall::~CSConUninstall()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSConUninstall::Copy()
+// 
+// -----------------------------------------------------------------------------
+//          
+CSConUninstall* CSConUninstall::CopyL()
+    {
+    CSConUninstall* copy = new (ELeave) CSConUninstall();
+    copy->iName = iName;
+    copy->iVendor = iVendor;
+    copy->iUid = iUid;
+    copy->iMode = iMode;
+            
+    copy->iComplete = iComplete;
+    copy->iProgress = iProgress;
+            
+    return copy;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConListDataOwners::CSConListDataOwners()
+// 
+// -----------------------------------------------------------------------------
+//      
+CSConListDataOwners::CSConListDataOwners() : iComplete( EFalse ), iProgress( 0 )
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConListDataOwners::~CSConListDataOwners()
+// 
+// -----------------------------------------------------------------------------
+//          
+CSConListDataOwners::~CSConListDataOwners()
+    {
+    iDataOwners.ResetAndDestroy();
+    iDataOwners.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CSConListDataOwners::CopyL()
+// 
+// -----------------------------------------------------------------------------
+//              
+CSConListDataOwners* CSConListDataOwners::CopyL()
+    {
+    CSConListDataOwners* copy = new (ELeave) CSConListDataOwners();
+    CleanupStack::PushL( copy );
+    for( TInt i = 0; i < iDataOwners.Count(); i++ )
+        {
+        copy->iDataOwners.Append( iDataOwners[i]->CopyL() );
+        }
+    CleanupStack::Pop( copy );
+    
+    copy->iComplete = iComplete;
+    copy->iProgress = iProgress;
+        
+    return copy;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConListDataOwners::DeleteDataOwners()
+// 
+// -----------------------------------------------------------------------------
+//          
+void CSConListDataOwners::DeleteDataOwners()
+    {
+    iDataOwners.ResetAndDestroy();
+    iDataOwners.Close();
+    }
+    
+// -----------------------------------------------------------------------------
+// CCSConSetBURMode::CSConSetBURMode()
+// 
+// -----------------------------------------------------------------------------
+//      
+CSConSetBURMode::CSConSetBURMode() : iComplete( EFalse ), iProgress( 0 )
+    {
+    //Initialize iDriveList with zeros
+    iDriveList.Fill( '\x0' );
+    }
+        
+// -----------------------------------------------------------------------------
+// CSConSetBURMode::~CSConSetBURMode()
+// 
+// -----------------------------------------------------------------------------
+//      
+CSConSetBURMode::~CSConSetBURMode()
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConSetBURMode::Copy()
+// 
+// -----------------------------------------------------------------------------
+//      
+CSConSetBURMode* CSConSetBURMode::CopyL()
+    {
+    CSConSetBURMode* copy = new (ELeave) CSConSetBURMode();
+    copy->iDriveList.Copy( iDriveList );
+    copy->iPartialType = iPartialType;
+    copy->iIncType = iIncType;
+            
+    copy->iComplete = iComplete;
+    copy->iProgress = iProgress;
+
+    return copy;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConGetDataSize::CSConGetDataSize()
+// 
+// -----------------------------------------------------------------------------
+//          
+CSConGetDataSize::CSConGetDataSize() : iComplete( EFalse ), iProgress( 0 )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSConGetDataSize::~CSConGetDataSize()
+// 
+// -----------------------------------------------------------------------------
+//      
+CSConGetDataSize::~CSConGetDataSize()
+    {
+    iDataOwners.ResetAndDestroy();
+    iDataOwners.Close();
+    }
+        
+// -----------------------------------------------------------------------------
+// CSConGetDataSize::Copy()
+// 
+// -----------------------------------------------------------------------------
+//      
+CSConGetDataSize* CSConGetDataSize::CopyL()
+    {
+    CSConGetDataSize* copy = new (ELeave) CSConGetDataSize();
+    CleanupStack::PushL( copy );
+    for( TInt i = 0; i < iDataOwners.Count(); i++ )
+        {
+        copy->iDataOwners.Append( iDataOwners[i]->CopyL() );
+        }
+    CleanupStack::Pop( copy );
+    copy->iComplete = iComplete;
+    copy->iProgress = iProgress;
+        
+    return copy;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConGetDataSize::DeleteDataOwners()
+// 
+// -----------------------------------------------------------------------------
+//              
+void CSConGetDataSize::DeleteDataOwners()
+    {
+    iDataOwners.ResetAndDestroy();
+    iDataOwners.Close();
+    }   
+    
+// -----------------------------------------------------------------------------
+// CSConListPublicFiles::CSConListPublicFiles()
+// 
+// -----------------------------------------------------------------------------
+//  
+CSConListPublicFiles::CSConListPublicFiles() : iComplete( EFalse ), iProgress( 0 )
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConListPublicFiles::~CSConListPublicFiles()
+// 
+// -----------------------------------------------------------------------------
+//          
+CSConListPublicFiles::~CSConListPublicFiles()
+    {
+    iFiles.ResetAndDestroy();
+    iFiles.Close();
+    
+    iDataOwners.ResetAndDestroy();
+    iDataOwners.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CSConListPublicFiles::CopyL()
+// 
+// -----------------------------------------------------------------------------
+//              
+CSConListPublicFiles* CSConListPublicFiles::CopyL()
+    {
+    CSConListPublicFiles* copy = new (ELeave) CSConListPublicFiles();
+    CleanupStack::PushL( copy );
+    for( TInt i = 0; i < iFiles.Count(); i++ )
+        {
+        copy->iFiles.Append( iFiles[i]->CopyL() );
+        }
+        
+    for( TInt j = 0; j < iDataOwners.Count(); j++ )
+        {
+        copy->iDataOwners.Append( iDataOwners[j]->CopyL() );
+        }
+    CleanupStack::Pop( copy );
+    
+    copy->iComplete = iComplete;
+    copy->iProgress = iProgress;
+        
+    return copy;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConRequestData::CSConRequestData()
+// 
+// -----------------------------------------------------------------------------
+//
+CSConRequestData::CSConRequestData() : iDataOwner( NULL ), iBackupData( NULL ), 
+    iMoreData( EFalse ), iComplete( EFalse ), iProgress( 0 )
+    {
+    iDataOwner = new CSConDataOwner();
+    }
+            
+// -----------------------------------------------------------------------------
+// CSConRequestData::~CSConRequestData()
+// 
+// -----------------------------------------------------------------------------
+//
+CSConRequestData::~CSConRequestData()
+    {
+    if ( iDataOwner )
+        {
+        delete iDataOwner;
+        iDataOwner = NULL;
+        }
+        
+    if ( iBackupData )
+        {
+        delete iBackupData;
+        iBackupData = NULL;
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConRequestData::Copy()
+// 
+// -----------------------------------------------------------------------------
+//          
+CSConRequestData* CSConRequestData::CopyL()
+    {
+    CSConRequestData* copy = new (ELeave) CSConRequestData();
+    
+    if ( iDataOwner )
+        {
+        if ( copy->iDataOwner )
+            {
+            delete copy->iDataOwner;
+            copy->iDataOwner = NULL;
+            }
+        copy->iDataOwner = iDataOwner->CopyL();
+        }
+    
+    copy->iComplete = iComplete;
+    copy->iProgress = iProgress;
+        
+    if ( iBackupData )
+        {
+        if ( copy->iBackupData )
+            {
+            delete copy->iBackupData;
+            copy->iBackupData = NULL;
+            }
+        copy->iBackupData = iBackupData->Alloc();
+        }
+        
+    copy->iMoreData = iMoreData;
+    
+    return copy;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConRequestData::DeleteDataAndDataOwner()
+// 
+// -----------------------------------------------------------------------------
+//          
+void CSConRequestData::DeleteDataAndDataOwner()
+    {
+    if ( iDataOwner )
+        {
+        delete iDataOwner;
+        iDataOwner = NULL;
+        }
+    
+    if ( iBackupData )
+        {
+        delete iBackupData;
+        iBackupData = NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSConGetDataOwnerStatus::CSConGetDataOwnerStatus()
+// 
+// -----------------------------------------------------------------------------
+//      
+CSConGetDataOwnerStatus::CSConGetDataOwnerStatus() : iComplete( EFalse ), iProgress( 0 )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSConGetDataOwnerStatus::~CSConGetDataOwnerStatus()
+// 
+// -----------------------------------------------------------------------------
+//              
+CSConGetDataOwnerStatus::~CSConGetDataOwnerStatus()
+    {
+    iDataOwners.ResetAndDestroy();
+    iDataOwners.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CSConGetDataOwnerStatus::Copy()
+// 
+// -----------------------------------------------------------------------------
+//              
+CSConGetDataOwnerStatus* CSConGetDataOwnerStatus::CopyL()
+    {
+    CSConGetDataOwnerStatus* copy = new (ELeave) CSConGetDataOwnerStatus();
+    CleanupStack::PushL( copy );
+    for( TInt i = 0; i < iDataOwners.Count(); i++ )
+        {
+        copy->iDataOwners.Append( iDataOwners[i]->CopyL() );
+        }           
+    CleanupStack::Pop( copy );
+    
+    copy->iComplete = iComplete;
+    copy->iProgress = iProgress;
+        
+    return copy;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConGetDataOwnerStatus::DeleteDataOwners()
+// 
+// -----------------------------------------------------------------------------
+//              
+void CSConGetDataOwnerStatus::DeleteDataOwners()
+    {
+    iDataOwners.ResetAndDestroy();
+    iDataOwners.Close();
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConSupplyData::CSConSupplyData()
+// 
+// -----------------------------------------------------------------------------
+//  
+CSConSupplyData::CSConSupplyData() : iDataOwner( NULL ), iRestoreData( NULL ),
+    iComplete( EFalse ), iProgress( 0 )
+    {
+    iDataOwner = new CSConDataOwner();
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConSupplyData::~CSConSupplyData()
+// 
+// -----------------------------------------------------------------------------
+//          
+CSConSupplyData::~CSConSupplyData()
+    {
+    if ( iDataOwner )
+        {
+        delete iDataOwner;
+        iDataOwner = NULL;
+        }
+    
+    if ( iRestoreData )
+        {
+        delete iRestoreData;
+        iRestoreData = NULL;
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConSupplyData::Copy()
+// 
+// -----------------------------------------------------------------------------
+//          
+CSConSupplyData* CSConSupplyData::CopyL()
+    {
+    CSConSupplyData* copy = new (ELeave) CSConSupplyData();
+    CleanupStack::PushL( copy );
+    
+    copy->iComplete = iComplete;
+    copy->iProgress = iProgress;
+        
+    if ( iDataOwner )
+        {
+        if ( copy->iDataOwner )
+            {
+            delete copy->iDataOwner;
+            copy->iDataOwner = NULL;
+            }
+            
+        copy->iDataOwner = iDataOwner->CopyL();
+        }
+    CleanupStack::Pop( copy ); 
+        
+    if ( iRestoreData )
+        {
+        if ( copy->iRestoreData )
+            {
+            delete copy->iRestoreData;
+            copy->iRestoreData = NULL;
+            }
+            
+        copy->iRestoreData = iRestoreData->Alloc();
+        }
+    
+    copy->iMoreData = iMoreData;    
+    
+    return copy;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConGetMetadata::CSConGetMetadata()
+// 
+// -----------------------------------------------------------------------------
+//  
+CSConGetMetadata::CSConGetMetadata() : iData( NULL ),
+    iMoreData( EFalse ), iComplete( EFalse ), iProgress( 0 )
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConGetMetadata::~CSConGetMetadata()
+// 
+// -----------------------------------------------------------------------------
+//          
+CSConGetMetadata::~CSConGetMetadata()
+    {
+    if ( iData )
+        {
+        delete iData;
+        iData = NULL;
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConGetMetadata::Copy()
+// 
+// -----------------------------------------------------------------------------
+//          
+CSConGetMetadata* CSConGetMetadata::CopyL()
+    {
+    CSConGetMetadata* copy = new (ELeave) CSConGetMetadata();
+    
+    copy->iFilename = iFilename;
+    
+    if ( iData )
+        {
+        if ( copy->iData )
+            {
+            delete copy->iData;
+            copy->iData = NULL;
+            }
+        
+        copy->iData = iData->Alloc();
+        }
+    
+    copy->iMoreData = iMoreData;
+    copy->iComplete = iComplete;
+    copy->iProgress = iProgress;
+    
+    return copy;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSConTask::NewL( TSConMethodName aMethod )
+// 
+// -----------------------------------------------------------------------------
+//
+CSConTask* CSConTask::NewL( TSConMethodName aMethod )
+    {
+    CSConTask* self = NewLC( aMethod );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConTask::NewLC( TSConMethodName aMethod )
+// 
+// -----------------------------------------------------------------------------
+//
+CSConTask* CSConTask::NewLC( TSConMethodName aMethod )
+    {
+    CSConTask* self = new (ELeave) CSConTask();
+    CleanupStack::PushL( self );
+    self->ConstructL( aMethod );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConTask::ConstructL( TSConMethodName aMethod )
+// Initializes member data
+// -----------------------------------------------------------------------------
+//
+void CSConTask::ConstructL( TSConMethodName aMethod )
+    {
+    iMethod = aMethod;
+    
+    switch( aMethod )
+        {
+        case ECancel :
+            break;
+        case EGetDataOwnerStatus :
+            iGetDataOwnerParams = new (ELeave) CSConGetDataOwnerStatus();
+            break;
+        case EGetDataSize :
+            iGetDataSizeParams = new (ELeave) CSConGetDataSize();
+            break;
+        case EGetStatus :
+            iGetStatusParams = new (ELeave) CSConGetStatus();
+            break;
+        case EInstall :
+            iInstallParams = new (ELeave) CSConInstall();
+            break;
+        case EListDataOwners :
+            iListDataOwnersParams = new (ELeave) CSConListDataOwners();
+            break;
+        case EListInstalledApps :
+            iListAppsParams = new (ELeave) CSConListInstApps();
+            break;
+        case EListPublicFiles :
+            iPubFilesParams = new (ELeave) CSConListPublicFiles();
+            break;
+        case ERequestData :
+            iRequestDataParams = new (ELeave) CSConRequestData();
+            break;
+        case ESetBURMode :
+            iBURModeParams = new (ELeave) CSConSetBURMode();
+            break;
+        case ESetInstParams :
+            break;
+        case ESupplyData :
+            iSupplyDataParams = new (ELeave) CSConSupplyData();
+            break;
+        case EUninstall :
+            iUninstallParams = new (ELeave) CSConUninstall();
+            break;
+        case EUpdateDeviceInfo :
+            iDevInfoParams = new (ELeave) CSConUpdateDeviceInfo();
+            break;
+        case EReboot :
+            iRebootParams = new (ELeave) CSConReboot();
+            break;
+        case EGetMetadata :
+            iGetMetadataParams = new (ELeave) CSConGetMetadata();
+            break;
+        default :
+            break;
+        }
+    }
+// -----------------------------------------------------------------------------
+// CSConTask::CSConTask()
+// 
+// -----------------------------------------------------------------------------
+//      
+CSConTask::CSConTask()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSConTask::~CSConTask()
+// 
+// -----------------------------------------------------------------------------
+//          
+CSConTask::~CSConTask()
+    {
+    delete iDevInfoParams;
+    delete iListAppsParams;
+    delete iGetStatusParams;
+    delete iInstallParams;
+    delete iUninstallParams;
+    delete iBURModeParams;
+    delete iGetDataSizeParams;
+    delete iRequestDataParams;
+    delete iGetDataOwnerParams;
+    delete iSupplyDataParams;
+    delete iPubFilesParams;
+    delete iListDataOwnersParams;
+    delete iRebootParams;
+    delete iGetMetadataParams;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConTask::GetServiceId() const
+// 
+// -----------------------------------------------------------------------------
+//          
+TSConMethodName CSConTask::GetServiceId() const
+    { 
+    return iMethod; 
+    }
+
+// -----------------------------------------------------------------------------
+// CSConTask::Copy() const
+// 
+// -----------------------------------------------------------------------------
+//          
+CSConTask* CSConTask::CopyL() const
+    {
+    CSConTask* copy = new (ELeave) CSConTask();
+    copy->iMethod = iMethod;
+    
+    if ( iDevInfoParams )
+        {
+        copy->iDevInfoParams = iDevInfoParams->CopyL();
+        }
+    if ( iListAppsParams )
+        {
+        copy->iListAppsParams = iListAppsParams->CopyL();
+        }
+    if ( iGetStatusParams ) 
+        {
+        
+        }
+    if ( iInstallParams )
+        {
+        copy->iInstallParams = iInstallParams->CopyL();
+        }
+    if ( iUninstallParams )
+        {
+        copy->iUninstallParams = iUninstallParams->CopyL();
+        }
+    if ( iBURModeParams )
+        {
+        copy->iBURModeParams = iBURModeParams->CopyL();
+        }
+    if ( iGetDataSizeParams )
+        {
+        copy->iGetDataSizeParams = iGetDataSizeParams->CopyL();
+        }
+    if ( iRequestDataParams )
+        {
+        copy->iRequestDataParams = iRequestDataParams->CopyL();
+        }
+    if ( iGetDataOwnerParams )
+        {
+        copy->iGetDataOwnerParams = iGetDataOwnerParams->CopyL();
+        }
+    if ( iSupplyDataParams )
+        {
+        copy->iSupplyDataParams = iSupplyDataParams->CopyL();
+        }
+    if ( iPubFilesParams )
+        {
+        copy->iPubFilesParams = iPubFilesParams->CopyL();
+        }
+    if ( iListDataOwnersParams )
+        {
+        copy->iListDataOwnersParams = iListDataOwnersParams->CopyL();
+        }
+    if ( iRebootParams )
+        {
+        copy->iRebootParams = iRebootParams->CopyL();
+        }
+    if ( iGetMetadataParams )
+        {
+        copy->iGetMetadataParams = iGetMetadataParams->CopyL();
+        }
+    
+    return copy;
+    }
+            
+// -----------------------------------------------------------------------------
+// CSConTask::GetComplete()
+// 
+// -----------------------------------------------------------------------------
+//  
+TBool CSConTask::GetComplete()
+    {
+    TBool complete( EFalse );
+    
+    switch( iMethod )
+        {
+        case EInstall :
+            complete = this->iInstallParams->iComplete;
+            break;
+        case EUninstall :
+            complete =  this->iUninstallParams->iComplete;
+            break;
+        case EListInstalledApps :
+            complete =  this->iListAppsParams->iComplete;
+            break;
+        case ESetInstParams :
+            break;
+        case ESetBURMode :
+            complete = this->iBURModeParams->iComplete;
+            break;
+        case EListPublicFiles :
+            complete = this->iPubFilesParams->iComplete;
+            break;
+        case EListDataOwners :
+            complete = this->iListDataOwnersParams->iComplete;
+            break;
+        case EGetDataSize :
+            complete = this->iGetDataSizeParams->iComplete;
+            break;
+        case EReboot :
+            complete = this->iRebootParams->iComplete;
+            break;
+        case ERequestData :
+            //If task is partially completed, 
+            //it can be removed from the queue
+            if ( this->iRequestDataParams->iProgress == KSConTaskPartiallyCompleted )
+                {
+                complete = ETrue;
+                }
+            else
+                {
+                complete = this->iRequestDataParams->iComplete;
+                }
+            
+            break;
+        case EGetDataOwnerStatus :
+            complete = this->iGetDataOwnerParams->iComplete;
+            break;
+        case ESupplyData :
+            //If task is partially completed, 
+            //it can be removed from the queue
+            if ( this->iSupplyDataParams->iProgress == KSConTaskPartiallyCompleted )
+                {
+                complete = ETrue;
+                }
+            else
+                {
+                complete = this->iSupplyDataParams->iComplete;
+                }
+            
+            break;
+        case EGetMetadata :
+            complete = this->iGetMetadataParams->iComplete;
+            break;
+        default :
+            break;                      
+        }
+    
+    return complete;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConTask::SetCompleteValue( TBool aValue )
+// 
+// -----------------------------------------------------------------------------
+//          
+void CSConTask::SetCompleteValue( TBool aValue )   
+    {
+    switch( iMethod )
+        {
+        case EInstall :
+            this->iInstallParams->iComplete = aValue;
+            break;
+        case EUninstall :
+            this->iUninstallParams->iComplete = aValue;         
+            break;
+        case EListInstalledApps :
+            this->iListAppsParams->iComplete = aValue;
+            break;
+        case ESetInstParams :
+            this->iInstallParams->iComplete = aValue;
+            break;
+        case ESetBURMode :
+            this->iBURModeParams->iComplete = aValue;
+            break;
+        case EListPublicFiles :
+            this->iPubFilesParams->iComplete = aValue;
+            break;
+        case EListDataOwners :
+            this->iListDataOwnersParams->iComplete = aValue;
+            break;
+        case EGetDataSize :
+            this->iGetDataSizeParams->iComplete = aValue;
+            break;
+        case EReboot :
+            this->iRebootParams->iComplete = aValue;
+            break;
+        case ERequestData :
+            this->iRequestDataParams->iComplete = aValue;
+            break;
+        case EGetDataOwnerStatus :
+            this->iGetDataOwnerParams->iComplete = aValue;
+            break;
+        case ESupplyData :
+            this->iSupplyDataParams->iComplete = aValue;
+            break;
+        case EGetMetadata :
+            this->iGetMetadataParams->iComplete = aValue;
+            break;
+        default:
+            break;      
+        }
+    }
+        
+// -----------------------------------------------------------------------------
+// CSConTask::GetCompleteValue()
+// 
+// -----------------------------------------------------------------------------
+//  
+TBool CSConTask::GetCompleteValue()
+    {
+    TBool complete( EFalse );
+    
+    switch( iMethod )
+        {
+        case EInstall :
+            complete = this->iInstallParams->iComplete;
+            break;
+        case EUninstall :
+            complete = this->iUninstallParams->iComplete;           
+            break;
+        case EListInstalledApps :
+            complete = this->iListAppsParams->iComplete;
+            break;
+        case ESetInstParams :
+            complete = this->iInstallParams->iComplete;
+            break;
+        case ESetBURMode :
+            complete = this->iBURModeParams->iComplete;
+            break;
+        case EListPublicFiles :
+            complete = this->iPubFilesParams->iComplete;
+            break;
+        case EListDataOwners :
+            complete = this->iListDataOwnersParams->iComplete;
+            break;
+        case EGetDataSize :
+            complete = this->iGetDataSizeParams->iComplete;
+            break;
+        case EReboot :
+            complete = this->iRebootParams->iComplete;
+            break;
+        case ERequestData :
+            if ( this->iRequestDataParams->iProgress != KSConTaskPartiallyCompleted )
+                {
+                complete = this->iRequestDataParams->iComplete;
+                }
+            else
+                {
+                complete = ETrue;
+                }
+            
+            break;
+        case EGetDataOwnerStatus :
+            complete = this->iGetDataOwnerParams->iComplete;
+            break;
+        case ESupplyData :
+            if ( this->iSupplyDataParams->iProgress != KSConTaskPartiallyCompleted )
+                {
+                complete = this->iSupplyDataParams->iComplete;
+                }
+            else
+                {
+                complete = ETrue;
+                }
+            break;
+        case EGetMetadata :
+            complete = this->iGetMetadataParams->iComplete;
+            break;
+        default:
+            break;      
+        }
+    return complete;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConTask::SetProgressValue( TInt aValue )
+// 
+// -----------------------------------------------------------------------------
+//              
+void CSConTask::SetProgressValue( TInt aValue )
+    {
+    switch( iMethod )
+        {
+        case EInstall :
+            this->iInstallParams->iProgress = aValue;
+            break;
+        case EUninstall :
+            this->iUninstallParams->iProgress = aValue;
+            break;
+        case EListInstalledApps :
+            this->iListAppsParams->iProgress = aValue;
+            break;
+        case ESetInstParams :
+            this->iInstallParams->iProgress = aValue;
+            break;
+        case ESetBURMode :
+            this->iBURModeParams->iProgress = aValue;
+            break;
+        case EListPublicFiles :
+            this->iPubFilesParams->iProgress = aValue;
+            break;
+        case EListDataOwners :
+            this->iListDataOwnersParams->iProgress = aValue;
+            break;
+        case EGetDataSize :
+            this->iGetDataSizeParams->iProgress = aValue;
+            break;
+        case EReboot :
+            this->iRebootParams->iProgress = aValue;
+            break;
+        case ERequestData :
+            this->iRequestDataParams->iProgress = aValue;
+            break;
+        case EGetDataOwnerStatus :
+            this->iGetDataOwnerParams->iProgress = aValue;
+            break;
+        case ESupplyData :
+            this->iSupplyDataParams->iProgress = aValue;
+            break;
+        case EGetMetadata :
+            this->iGetMetadataParams->iProgress = aValue;
+            break;
+        default:
+            break;      
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSConTaskReply::CSConTaskReply()
+// 
+// -----------------------------------------------------------------------------
+//      
+CSConTaskReply::CSConTaskReply()
+    {
+    }
+   
+// -----------------------------------------------------------------------------
+// CSConTaskReply::CSConTaskReply( TSConMethodName aMethod )
+// 
+// -----------------------------------------------------------------------------
+//          
+CSConTaskReply::CSConTaskReply( TSConMethodName aMethod )
+    {
+    iMethod = aMethod;
+    switch( aMethod )
+        {
+        case ECancel :
+            break;
+        case EGetDataOwnerStatus :
+            iGetDataOwnerParams = new CSConGetDataOwnerStatus();
+            break;
+        case EGetDataSize :
+            iGetDataSizeParams = new CSConGetDataSize();
+            break;
+        case EGetStatus :
+            iGetStatusParams = new CSConGetStatus();
+            break;
+        case EInstall :
+            iInstallParams = new CSConInstall();
+            break;
+        case EListDataOwners :
+            iListDataOwnersParams = new CSConListDataOwners();
+            break;
+        case EListInstalledApps :
+            iListAppsParams = new CSConListInstApps();
+            break;
+        case EListPublicFiles :
+            iPubFilesParams = new CSConListPublicFiles();
+            break;
+        case ERequestData :
+            iRequestDataParams = new CSConRequestData();
+            break;
+        case ESetBURMode :
+            iBURModeParams = new CSConSetBURMode();
+            break;
+        case ESetInstParams :
+            break;
+        case ESupplyData :
+            iSupplyDataParams = new CSConSupplyData();
+            break;
+        case EUninstall :
+            iUninstallParams = new CSConUninstall();
+            break;
+        case EUpdateDeviceInfo :
+            iDevInfoParams = new CSConUpdateDeviceInfo();
+            break;
+        case EReboot :
+            iRebootParams = new CSConReboot();
+            break;
+        case EGetMetadata :
+            iGetMetadataParams = new CSConGetMetadata();
+            break;
+        default :
+            break;
+        }
+    }
+      
+// -----------------------------------------------------------------------------
+// CSConTaskReply::~CSConTaskReply()
+// 
+// -----------------------------------------------------------------------------
+//          
+CSConTaskReply::~CSConTaskReply()
+    {
+    delete iDevInfoParams;
+    delete iListAppsParams;
+    delete iGetStatusParams;
+    delete iInstallParams;
+    delete iUninstallParams;
+    delete iBURModeParams;
+    delete iGetDataSizeParams;
+    delete iRequestDataParams;
+    delete iGetDataOwnerParams;
+    delete iSupplyDataParams;
+    delete iPubFilesParams;
+    delete iListDataOwnersParams;
+    delete iRebootParams;
+    delete iGetMetadataParams;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConTaskReply::Initialize( const CSConTask& aTask )
+// 
+// -----------------------------------------------------------------------------
+// 
+void CSConTaskReply::InitializeL( const CSConTask& aTask )
+    {
+    iTaskId = aTask.iTaskId;
+    iMethod = aTask.iMethod;
+    
+    if ( iMethod == EInstall )
+        {
+        if ( iInstallParams )
+            {
+            delete iInstallParams;
+            iInstallParams = NULL;
+            }
+        iInstallParams = aTask.iInstallParams->CopyL();
+        }
+    else if ( iMethod == EListInstalledApps )
+        {
+        if ( iListAppsParams )
+            {
+            delete iListAppsParams;
+            iListAppsParams = NULL;
+            }
+            
+        iListAppsParams = aTask.iListAppsParams->CopyL();
+        }
+    else if ( iMethod == EUninstall )
+        {
+        if ( iUninstallParams )
+            {
+            delete iUninstallParams;
+            iUninstallParams = NULL;
+            }
+            
+        iUninstallParams = aTask.iUninstallParams->CopyL();
+        }
+    else if ( iMethod == ESetBURMode )
+        {
+        if ( iBURModeParams )
+            {
+            delete iBURModeParams;
+            iBURModeParams = NULL;
+            }
+            
+        iBURModeParams = aTask.iBURModeParams->CopyL();
+        }
+    else if ( iMethod == EListPublicFiles )
+        {
+        if ( iPubFilesParams )
+            {
+            delete iPubFilesParams;
+            iPubFilesParams = NULL;
+            }
+        
+        iPubFilesParams = aTask.iPubFilesParams->CopyL();
+        }
+    else if ( iMethod == EListDataOwners )
+        {
+        if ( iListDataOwnersParams )
+            {
+            delete iListDataOwnersParams;
+            iListDataOwnersParams = NULL;
+            }
+        
+        iListDataOwnersParams = aTask.iListDataOwnersParams->CopyL();
+        }
+    else if ( iMethod == EGetDataSize )
+        {
+        if ( iGetDataSizeParams )
+            {
+            delete iGetDataSizeParams;
+            iGetDataSizeParams = NULL;
+            }
+        
+        iGetDataSizeParams = aTask.iGetDataSizeParams->CopyL();
+        }
+    else if ( iMethod == EReboot )
+        {
+        if ( iRebootParams )
+            {
+            delete iRebootParams;
+            iRebootParams = NULL;
+            }
+        }
+    else if ( iMethod == ERequestData )
+        {
+        if ( iRequestDataParams )
+            {
+            delete iRequestDataParams;
+            iRequestDataParams = NULL;
+            }
+        
+        iRequestDataParams = aTask.iRequestDataParams->CopyL();
+        }
+    else if ( iMethod == EGetDataOwnerStatus )
+        {
+        if ( iGetDataOwnerParams )
+            {
+            delete iGetDataOwnerParams;
+            iGetDataOwnerParams = NULL;
+            }
+            
+        iGetDataOwnerParams = aTask.iGetDataOwnerParams->CopyL();
+        }
+    else if ( iMethod == ESupplyData )
+        {
+        if ( iSupplyDataParams )
+            {
+            delete iSupplyDataParams;
+            iSupplyDataParams = NULL;
+            }
+        
+        iSupplyDataParams = aTask.iSupplyDataParams->CopyL();
+        }
+    else if ( iMethod == EGetMetadata )
+        {
+        if ( iGetMetadataParams )
+            {
+            delete iGetMetadataParams;
+            iGetMetadataParams = NULL;
+            }
+        
+        iGetMetadataParams = aTask.iGetMetadataParams->CopyL();
+        }
+    }
+ 
+// -----------------------------------------------------------------------------
+// CSConTaskReply::Initialize( TSConMethodName aMethod, 
+//              TInt aProgress, TBool aComplete )
+// 
+// -----------------------------------------------------------------------------
+//              
+void CSConTaskReply::InitializeL( TSConMethodName aMethod, 
+                TInt aProgress, TBool aComplete )
+    {
+    iMethod = aMethod;
+    if ( aMethod == EUpdateDeviceInfo )
+        {
+        if ( !iDevInfoParams )
+            {
+            iDevInfoParams = new (ELeave) CSConUpdateDeviceInfo();
+            }
+            
+        iDevInfoParams->iComplete = aComplete;
+        iDevInfoParams->iProgress = aProgress;
+        }
+    else if ( aMethod == EReboot )
+        {
+        if ( !iRebootParams )
+            {
+            iRebootParams = new (ELeave) CSConReboot();
+            }
+            
+        iRebootParams->iComplete = aComplete;
+        iRebootParams->iProgress = aProgress;
+        }
+    else if ( aMethod == EGetMetadata )
+        {
+        if ( !iGetMetadataParams )
+            {
+            iGetMetadataParams = new (ELeave) CSConGetMetadata();
+            }
+            
+        iGetMetadataParams->iComplete = aComplete;
+        iGetMetadataParams->iProgress = aProgress;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSConTaskReply::CopyAndFree()
+// 
+// -----------------------------------------------------------------------------
+// 
+CSConTaskReply* CSConTaskReply::CopyAndFreeL()  
+    {
+    CSConTaskReply* copy = new (ELeave) CSConTaskReply();
+    copy->iTaskId = iTaskId;
+    copy->iMethod = iMethod;
+    
+    if ( iDevInfoParams )
+        {
+        copy->iDevInfoParams = iDevInfoParams->CopyL();
+        
+        //free allocated memory
+        delete iDevInfoParams;
+        iDevInfoParams = NULL;
+        }
+    if ( iListAppsParams )
+        {
+        copy->iListAppsParams = iListAppsParams->CopyL();
+        
+        //free allocated memory
+        delete iListAppsParams;
+        iListAppsParams = NULL;
+        }
+    if ( iInstallParams )
+        {
+        copy->iInstallParams = iInstallParams->CopyL();
+        
+        //free allocated memory
+        delete iInstallParams;
+        iInstallParams = NULL;
+        }
+    if ( iUninstallParams )
+        {
+        copy->iUninstallParams = iUninstallParams->CopyL();
+        
+        //free allocated memory
+        delete iUninstallParams;
+        iUninstallParams = NULL;
+        }
+    if ( iBURModeParams )
+        {
+        copy->iBURModeParams = iBURModeParams->CopyL();
+        
+        //free allocated memory
+        delete iBURModeParams;
+        iBURModeParams = NULL;
+        }
+    if ( iGetDataSizeParams )
+        {
+        copy->iGetDataSizeParams = iGetDataSizeParams->CopyL();
+        
+        //free allocated memory
+        delete iGetDataSizeParams;
+        iGetDataSizeParams = NULL;
+        }
+    if ( iRequestDataParams )
+        {
+        copy->iRequestDataParams = iRequestDataParams->CopyL();
+        
+        //free allocated memory
+        delete iRequestDataParams;
+        iRequestDataParams = NULL;
+        }
+    if ( iGetDataOwnerParams )
+        {
+        copy->iGetDataOwnerParams = iGetDataOwnerParams->CopyL();
+        
+        //free allocated memory
+        delete iGetDataOwnerParams;
+        iGetDataOwnerParams = NULL;
+        }
+    if ( iSupplyDataParams )
+        {
+        copy->iSupplyDataParams = iSupplyDataParams->CopyL();
+        
+        //free allocated memory
+        delete iSupplyDataParams;
+        iSupplyDataParams = NULL;
+        }
+    if ( iPubFilesParams )
+        {
+        copy->iPubFilesParams = iPubFilesParams->CopyL();
+        
+        //free allocated memory
+        delete iPubFilesParams;
+        iPubFilesParams = NULL;
+        }
+    if ( iListDataOwnersParams )
+        {
+        copy->iListDataOwnersParams = iListDataOwnersParams->CopyL();
+        
+        //free allocated memory
+        delete iListDataOwnersParams;
+        iListDataOwnersParams = NULL;
+        }
+    if ( iRebootParams )
+        {
+        copy->iRebootParams = iRebootParams->CopyL();
+        
+        //free allocated memory
+        delete iRebootParams;
+        iRebootParams = NULL;
+        }
+    if ( iGetMetadataParams )
+        {
+        copy->iGetMetadataParams = iGetMetadataParams->CopyL();
+        
+        //free allocated memory
+        delete iGetMetadataParams;
+        iGetMetadataParams = NULL;
+        }
+    
+    return copy;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConTaskReply::CleanTaskData()
+// 
+// -----------------------------------------------------------------------------
+// 
+void CSConTaskReply::CleanTaskData()
+    {
+    switch( iMethod )   
+        {
+        case EGetDataSize :
+            if ( iGetDataSizeParams )
+                {
+                this->iGetDataSizeParams->DeleteDataOwners();
+                }
+            break;
+        case EGetDataOwnerStatus :
+            if ( iGetDataOwnerParams )
+                {
+                this->iGetDataOwnerParams->DeleteDataOwners();
+                }
+            break;
+        case EListDataOwners :
+            if ( iListDataOwnersParams )
+                {
+                this->iListDataOwnersParams->DeleteDataOwners();
+                }
+            break;
+        case ERequestData :
+            if ( iRequestDataParams )
+                {
+                this->iRequestDataParams->DeleteDataAndDataOwner();
+                }
+            break;
+        default :
+            break;
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConStatusReply::CSConStatusReply()
+// 
+// -----------------------------------------------------------------------------
+// 
+CSConStatusReply::CSConStatusReply() : iNoTasks( EFalse )
+    {
+    }
+   
+// -----------------------------------------------------------------------------
+// CSConStatusReply::~CSConStatusReply()
+// 
+// -----------------------------------------------------------------------------
+//      
+CSConStatusReply::~CSConStatusReply() 
+    {
+    iTasks.ResetAndDestroy();
+    iTasks.Close();
+    };
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build info file for SeCon
+*
+*/
+
+#include <platform_paths.hrh>
+
+#include "../catalogspcconnectivityplugin/group/bld.inf"
+#include "../cntparser/bld/bld.inf"
+#include "../services/csc/bld/bld.inf"
+#include "../services/ftp/bld/bld.inf"
+#include "../services/pcd/bld/bld.inf"
+#include "../wbxml/conmlhandler/bld/bld.inf"
+#include "../servers/pcconn/bld/bld.inf"
+#include "../clients/pcconn/bld/bld.inf"
+#include "../plugins/pcconn/bld/bld.inf"
+#include "../plugins/ftp/bld/bld.inf"
+#include "../plugins/hapticsconnplugin/group/bld.inf"
+
+PRJ_EXPORTS
+
+// Export stub files
+stubs/secon_stub.SIS                /epoc32/data/z/system/install/secon_stub.SIS
+stubs/sconpcconnplugin_stub.SIS     /epoc32/data/z/system/install/sconpcconnplugin_stub.SIS
+stubs/sconftpplugin_stub.SIS        /epoc32/data/z/system/install/sconftpplugin_stub.SIS
+
+../rom/sconpcd.iby                  CORE_MW_LAYER_IBY_EXPORT_PATH(sconpcd.iby)
+../rom/sconpcconnplugin.iby         CORE_MW_LAYER_IBY_EXPORT_PATH(sconpcconnplugin.iby)
+../rom/sconpcconnclientserver.iby   CORE_MW_LAYER_IBY_EXPORT_PATH(sconpcconnclientserver.iby)
+../rom/sconftpresources.iby         LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(sconftpresources.iby)
+../rom/sconftpplugin.iby            CORE_MW_LAYER_IBY_EXPORT_PATH(sconftpplugin.iby)
+../rom/sconftp.iby                  CORE_MW_LAYER_IBY_EXPORT_PATH(sconftp.iby)
+../rom/sconcsc.iby                  CORE_MW_LAYER_IBY_EXPORT_PATH(sconcsc.iby)
+../rom/cntparser.iby                CORE_MW_LAYER_IBY_EXPORT_PATH(cntparser.iby)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/group/stubs/createstubs.bat	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,19 @@
+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 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: Batch file for creating needed stub files.
+rem
+
+makesis -s sconftpplugin_stub.pkg
+makesis -s sconpcconnplugin_stub.pkg
+makesis -s secon_stub.pkg
Binary file connectivitymodules/SeCon/group/stubs/sconftpplugin_stub.SIS has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/group/stubs/sconftpplugin_stub.pkg	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,30 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: Sis-stub file for FTP Plugin
+;
+; Languages
+&EN
+
+; Header
+#{"FTP Plugin"},(0x101F9686),1,0,0, TYPE=SA
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Files to install
+""-"z:\resource\plugins\sconftpplugin.rsc"
+""-"z:\sys\bin\sconftpplugin.dll"
Binary file connectivitymodules/SeCon/group/stubs/sconpcconnplugin_stub.SIS has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/group/stubs/sconpcconnplugin_stub.pkg	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,30 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: Sis-stub file for PCConn Plugin
+;
+; Languages
+&EN
+
+; Header
+#{"PCConn Plugin"},(0x101F9688),1,0,0, TYPE=SA
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Files to install
+""-"z:\resource\plugins\sconpcconnplugin.rsc"
+""-"z:\sys\bin\sconpcconnplugin.dll"
Binary file connectivitymodules/SeCon/group/stubs/secon_stub.SIS has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/group/stubs/secon_stub.pkg	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,38 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: Sis-stub file for Service Controllers
+;
+; Languages
+&EN
+
+; Header
+#{"Service Controllers"},(0x101F99F6),1,0,0, TYPE=SA
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Files to install
+""-"z:\sys\bin\sconpcconnserver.exe"
+""-"z:\sys\bin\sconpcconnclient.dll"
+""-"z:\sys\bin\sconpcd.dll"
+""-"z:\resource\sconftp.r??"
+""-"z:\sys\bin\sconftp.dll"
+""-"z:\sys\bin\sconcsc.dll"
+""-"z:\sys\bin\sconconmlhandler.dll"
+""-"z:\sys\bin\catalogspcconnectivityplugin.dll"
+""-"z:\sys\bin\cntparserserver.dll"
+""-"z:\sys\bin\cntparserserverexe.exe"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/inc/debug.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,128 @@
+/*
+* 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:  Debug utility for SeCon components.
+*
+*/
+
+
+#ifndef _SECON_DEBUG_H
+#define _SECON_DEBUG_H
+
+#ifdef _DEBUG
+    
+    #ifdef __WINS__
+        // Enable file logging
+        #define __FLOGGING__
+    #endif //__WINS__
+    
+    #include <e32svr.h>
+    #ifdef __FLOGGING__
+        #include <f32file.h>
+        #include <flogger.h>
+    #endif
+    
+    NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow
+        {
+    public:
+        void Overflow(TDes16& /*aDes*/) {}
+        };
+    
+    NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow
+        {
+    public:
+        void Overflow(TDes8& /*aDes*/) {}
+        };
+    
+    _LIT( KLogDir, "SECON" );
+    _LIT( KLogFile, "SeconDebug.txt" );
+    
+    _LIT(KTracePrefix16, "[SeCon] ");
+    _LIT8(KTracePrefix8, "[SeCon] ");
+    _LIT8(KFuncEntryFormat8, "%S : Begin");
+    _LIT8(KFuncExitFormat8, "%S : End");
+    _LIT8(KFuncReturnFormat8, "%S : End, return: %d");
+    _LIT8(KFuncFormat8, "><%S");
+    
+    const TInt KMaxLogLineLength = 512;
+    
+    // old function loggin macros
+    #define LOGGER_ENTERFN( name )      {TRACE_FUNC_ENTRY;}
+    #define LOGGER_LEAVEFN( name )      {TRACE_FUNC_EXIT;}
+    
+    #define LOGGER_WRITE( text )                    {_LIT( KTemp, text ); FPrint( KTemp );}
+    #define LOGGER_WRITE_1( text,par1 )             {_LIT( KTemp, text ); FPrint( KTemp, par1 );}
+    #define LOGGER_WRITE8_1( text,par1 )            {_LIT8( KTemp, text ); FPrint( KTemp, par1 );}
+    #define LOGGER_WRITE_2( text,par1,par2 )        {_LIT( KTemp, text ); FPrint( KTemp, par1, par2 );}
+    #define LOGGER_WRITE_3( text,par1,par2,par3 )   {_LIT( KTemp, text ); FPrint( KTemp, par1, par2, par3 );}
+    
+    // New function logging macros
+    #define TRACE_FUNC_ENTRY {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncEntryFormat8, &ptr8);}
+    #define TRACE_FUNC_EXIT {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncExitFormat8, &ptr8);}
+    #define TRACE_FUNC {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncFormat8, &ptr8);}
+    
+    #define TRACE_FUNC_RET( number )  {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncReturnFormat8, &ptr8, number);}
+    // Declare the FPrint function
+    inline void FPrint( TRefByValue<const TDesC16> aFmt, ...)
+        {
+        VA_LIST list;
+        VA_START(list,aFmt);
+    #ifdef __FLOGGING__
+        RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list );
+    #endif
+        TBuf16<KMaxLogLineLength> theFinalString;
+        theFinalString.Append(KTracePrefix16);
+        TOverflowTruncate16 overflow;
+        theFinalString.AppendFormatList(aFmt,list,&overflow);
+        RDebug::Print(theFinalString);
+        }
+    
+    // Declare the FPrint function
+    inline void FPrint(TRefByValue<const TDesC8> aFmt, ...)
+        {
+        VA_LIST list;
+        VA_START(list, aFmt);
+    #ifdef __FLOGGING__
+        RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+    #endif
+        TOverflowTruncate8 overflow;
+        TBuf8<KMaxLogLineLength> buf8;
+        buf8.Append(KTracePrefix8);
+        buf8.AppendFormatList(aFmt, list, &overflow);
+        TBuf16<KMaxLogLineLength> buf16(buf8.Length());
+        buf16.Copy(buf8);
+        TRefByValue<const TDesC> tmpFmt(_L("%S"));
+        RDebug::Print(tmpFmt, &buf16);
+        }
+#else
+    
+    // No loggings --> reduced code size
+
+    #define LOGGER_ENTERFN( name )
+    #define LOGGER_LEAVEFN( name )
+    #define LOGGER_WRITE( text )
+    #define LOGGER_WRITE_1( text, par1 )
+    #define LOGGER_WRITE8_1( text, par1 )
+    #define LOGGER_WRITE_2( text, par1, par2 )
+    #define LOGGER_WRITE_3( text, par1, par2, par3 )
+    #define TRACE_FUNC_ENTRY
+    #define TRACE_FUNC_EXIT
+    #define TRACE_FUNC
+    #define TRACE_FUNC_RET( number )
+
+#endif //_DEBUG
+
+#endif // SECON_DEBUG_H
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/ftp/bld/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File Transfer Profile Plug-in build information file.
+*
+*/
+
+
+PRJ_PLATFORMS  
+DEFAULT
+
+PRJ_MMPFILES
+sconftpplugin.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/ftp/bld/def/bwinscwU.DEF	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/ftp/bld/def/eabiU.DEF	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,5 @@
+EXPORTS
+	_Z24ImplementationGroupProxyRi @ 1 NONAME
+	_ZTI14CSConFTPplugin @ 2 NONAME ; #<TI>#
+	_ZTV14CSConFTPplugin @ 3 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/ftp/bld/sconftpplugin.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies 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 Transfer Profile Plug-in
+*
+*/
+
+
+// To get the MW_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_ECOM_PLUGIN
+
+TARGET          sconftpplugin.dll
+TARGETTYPE      PLUGIN
+
+UID             0x10009D8D 0x101F9686
+
+SOURCEPATH     	../src
+
+SOURCE          sconftpplugin.cpp
+SOURCE          proxy.cpp
+SOURCE          sconftppluginutils.cpp
+SOURCE          sconservicetimer.cpp
+SOURCE          sconshutdownwatcher.cpp
+
+START RESOURCE 101f9686.rss
+  TARGET        sconftpplugin.rsc
+END
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE     ../inc 
+USERINCLUDE     ../../../inc 
+USERINCLUDE     ../../../services/ftp/inc 
+
+DEBUGLIBRARY    flogger.lib
+LIBRARY	        euser.lib
+LIBRARY	        irobex.lib 
+LIBRARY         ecom.lib			
+LIBRARY	        efsrv.lib 
+LIBRARY         bluetooth.lib
+LIBRARY         esock.lib 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/ftp/inc/sconftpplugin.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,194 @@
+/*
+* 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 Transfer Profile Plug-in header file
+*
+*/
+
+
+#ifndef _SCONFTPPLUGIN_H
+#define _SCONFTPPLUGIN_H
+
+#include <obexserver.h>
+#include <SrcsInterface.h>
+
+#include "sconshutdownwatcher.h"
+
+// forward declaration
+class CSConFTP;
+class CSConServiceTimer;
+// CLASS DECLARATION
+
+/*
+* File Transfer Profile Plugin class
+*
+*/
+
+class CSConFTPplugin : public CSrcsInterface, public MObexServerNotify,
+                          public MShutdownObserver
+    {
+    public:
+        static CSConFTPplugin* NewL();
+        ~CSConFTPplugin();
+
+        /**
+         * Returns active status of OBEX session
+         * @return ETrue if session is active, else EFalse
+         */
+        TBool IsOBEXActive();
+        
+        /**
+         * Device is shutting down, abort connection.
+         */
+        void NotifyShutdown();
+
+    private:
+        /**
+         * Loads sconftp.dll module
+         * @return none
+         */
+        void LoadFTPDllL();
+        /**
+         * Closes initialized services
+         * @return none
+         */
+        void Disconnect();
+        /**
+         * Removes spaces and nulls from the end of the string
+         * @param aDes String to be formatted
+         * @return none
+         */
+        void TrimRightSpaceAndNull( TDes8& aDes ) const;
+        /**
+         * Current used transfer media (IR,USB,BT)
+         * @param aMediaType Enumeration indicating the media type
+         * @return none
+         */
+        void SetMediaType( TSrcsMediaType aMediaType );
+        /**
+         * MObexServerNotify implementation
+         * @param aError Error code
+         * @return none
+         */
+        void ErrorIndication( TInt aError );
+        /**
+         * MObexServerNotify implementation
+         * @return none
+         */
+        void TransportUpIndication();
+        /**
+         * MObexServerNotify implementation
+         * @return none
+         */
+        void TransportDownIndication();
+        /**
+         * MObexServerNotify implementation
+         * @param aRemoteInfo Structure containing information used during OBEX
+         * connection
+         * @param aInfo Further information about the requested connection
+         * @return System wide error code that indicates the success of the connection
+         */
+        TInt ObexConnectIndication( const TObexConnectInfo& aRemoteInfo,
+                                    const TDesC8& aInfo );
+        /**
+         * MObexServerNotify implementation
+         * @param aInfo Contains information about the disconnection
+         * @return none
+         */
+        void ObexDisconnectIndication( const TDesC8& aInfo );
+        /**
+         * MObexServerNotify implementation
+         * @return CObexBaseObject-derived object, which the object being put
+         * will be parsed into.
+         */
+        CObexBufObject* PutRequestIndication();
+        /**
+         * MObexServerNotify implementation
+         * @return System wide error code that indicates the success of the
+         * PUT packet operation.
+         */
+        TInt PutPacketIndication();
+        /**
+         * MObexServerNotify implementation
+         * @return System wide error code that indicates the success of the
+         * PUT packet operation.
+         */
+        TInt PutCompleteIndication();
+        /**
+         * MObexServerNotify implementation
+         * @param aRequiredObject Details about the object the remote client
+         * has requested
+         * @returnObject to return to the client
+         */
+        CObexBufObject* GetRequestIndication( CObexBaseObject
+                                                *aRequiredObject );
+        /**
+         * MObexServerNotify implementation
+         * @return System wide error code that indicates the success of the
+         * GET packet operation.
+         */
+        TInt GetPacketIndication();
+        /**
+         * MObexServerNotify implementation
+         * @return System wide error code that indicates the success of the
+         * GET packet operation.
+         */
+        TInt GetCompleteIndication();
+        /**
+         * MObexServerNotify implementation
+         * @param aPathInfo SETPATH command parameters
+         * @param aInfo Not currently used
+         * @return System wide error code indicating the success of the
+         * setpath command.
+         */
+        TInt SetPathIndication( const CObex::TSetPathInfo& aPathInfo,
+                                const TDesC8& aInfo );
+        /**
+         * SetObexServer
+         * @param aObexServer pass obex server pointer to sevice controller
+         * @return System wide error code.
+         */
+        TInt SetObexServer( CObexServer* aObexServer );
+        /**
+         * MObexServerNotify implementation
+         * @return none
+         */
+        void AbortIndication();
+
+        void ConstructL();
+    CSConFTPplugin();
+
+    private:
+        RLibrary                    iFTPlib;
+        CObexBufObject*             iObject;
+        CBufFlat*                   iBuffer;
+        CSConFTP*                   iFTPHandler;
+        TInt                        iPutError;
+        TBool                       iSessionActive;
+        CSConServiceTimer*          iServiceTimer;
+        TBool                       iStartTimer;
+        TSrcsMediaType              iMediaType;
+        CObexFileObject*            iFileObject;
+        TBool                       iPutPacketIndicationCalled;
+        CShutdownWatcher*           iShutdownWatcher;
+        TBool                       iShutdownInProgress;
+        CObexServer*                iObexServer;
+        RSocketServ                 iSocketServer;
+        RBTPhysicalLinkAdapter      iLinkAdapter;
+    private:
+        // Friend class is used,because existing impelentation has been working
+        // properly. Avoiding re-design.
+        friend class CSConServiceTimer;
+    };
+
+#endif // SCONPCCONNPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/ftp/inc/sconftppluginutils.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File Transfer Profile Plug-in Utils header
+*
+*/
+
+
+#ifndef _SCONFTPPLUGINUTILS_H
+#define _SCONFTPPLUGINUTILS_H
+
+#include <e32base.h>
+//============================================================
+// Class TFTPpluginUtils declaration
+//============================================================
+class TFTPpluginUtils
+	{
+	public:
+		/**
+		 * Converts Symbian error code to OBEX error code
+		 * @param aError The error code
+		 * @return The converted error code
+		 */
+		static TInt ConvertFTPResponseCode( TInt aError );
+	};
+
+#endif // _SCONFTPPLUGINUTILS_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/ftp/inc/sconservicetimer.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File Transfer Profile Plug-in Service Timer Header file
+*
+*/
+
+
+#ifndef _SCONSERVICETIMER_H
+#define _SCONSERVICETIMER_H
+
+#include <e32base.h>
+
+class CSConFTPplugin;
+
+
+//============================================================
+// Class CSConServiceTimer declaration
+//============================================================
+
+NONSHARABLE_CLASS ( CSConServiceTimer ) : public CActive
+	{
+	public:
+		CSConServiceTimer( CSConFTPplugin* aEngine, TInt aValue );
+		void ConstructL();
+		~CSConServiceTimer();
+		
+		/**
+	 	* Starts the timer
+		* @return none
+	 	*/
+		void StartTimer();
+		/**
+		 * Stops the timer
+		 * @return none
+		 */
+		void StopTimer();
+	
+	private:
+		void DoCancel();
+		void RunL();
+		
+	private:
+		RTimer 				iTimer;
+		CSConFTPplugin* 	iEngine;
+		TInt 				iValue;
+	};
+	
+#endif //_SCONSERVICETIMER_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/ftp/inc/sconshutdownwatcher.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Power shutdown -watcher header file
+*
+*/
+
+
+#ifndef _SCONSHUTDOWNWATCHER_H
+#define _SCONSHUTDOWNWATCHER_H
+
+
+#include <e32base.h>
+#include <e32property.h>
+
+//============================================================
+// Class MShutdownObserver declaration
+//============================================================
+class MShutdownObserver
+    {
+public:
+    virtual void NotifyShutdown()=0;
+    };
+
+//============================================================
+// Class CShutdownWatcher declaration
+//============================================================
+NONSHARABLE_CLASS (  CShutdownWatcher ) : public CActive
+    {
+    public:
+        static CShutdownWatcher* NewL( MShutdownObserver* aObserver );
+        ~CShutdownWatcher();
+
+        /**
+         * Starts to watch shutdown status
+         * @return none
+         */
+        void StartShutdownWatcher();
+
+    private:
+        //construct/destruct
+        CShutdownWatcher( MShutdownObserver* aObserver );
+        void ConstructL();
+
+        // from CActive
+        void DoCancel();
+        void RunL();
+
+    private:
+        MShutdownObserver*   iObserver; 
+        RProperty            iProperty;
+    };
+
+#endif //_SCONSHUTDOWNWATCHER_H
+
+// End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/ftp/src/101f9686.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File Transfer Profile Plug-in resource file
+*
+*/
+
+
+#include "ecom/registryinfo.rh"
+
+// Declares info for two implementations
+RESOURCE REGISTRY_INFO theInfo
+	{
+	// UID for the DLL
+	dll_uid = 0x101F9686;
+	// Declare array of interface info
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			// UID of interface that is implemented
+			interface_uid = 0x101F7C8C;
+			implementations = 
+				{
+				// Info for CSConFTPplugin
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x101F9687;
+					version_no = 1;
+					display_name = "OBEX File Transfer";
+					default_data = "OBEX/BT";
+					
+					// 
+					// opaque_data contains parameters used by following API calls in SRCS:
+					// 1. Setup USB interface string descriptor in Unicode;
+					// 2. TInt CObex::SetLocalWho(const TDesC8& aInfo);
+					// 3. TInt CBTConnection::RegisterSecuritySettingsL( TUint aService,
+					//						 TInt  aProtocol,
+					//						 TInt  aChannel,
+					//						 TBool aAuthenticate,
+					//						 TBool aAuthorise,
+					//						 TBool aEncrypt );
+					// opaque_data = "@0||@1||@2||@3||@4||@5||@6"
+					// @0 aStrDesc		e.g. "OBEX File Transfer"
+					// @1 aInfo			e.g. KFolderBrowsingID, "\xF9\xEC\x7B\xC4\x95\x3C\x11\xd2\x98\x4E\x52\x54\x00\xDC\x9E\x09"
+					// @2 aService		e.g. KBTSecurityUidFileTransfer, 0x1106
+					// @3 aProtocol		e.g. KSolBtRFCOMM, 0x1013
+					// @4 aAuthenticate	e.g. EFalse, 0
+					// @5 aAuthorise	e.g. EFalse, 0
+					// @6 aEncrypt		e.g. EFalse, 0
+					//
+					opaque_data = "OBEX File Transfer||\xF9\xEC\x7B\xC4\x95\x3C\x11\xd2\x98\x4E\x52\x54\x00\xDC\x9E\x09||0x1106||0x1013||1||1||1";
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/ftp/src/proxy.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File Transfer Profile Plug-in proxy implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+
+#include "sconftpplugin.h"
+
+const TImplementationProxy ImplementationTable[] = 
+	{
+	IMPLEMENTATION_PROXY_ENTRY(0x101F9687,	CSConFTPplugin::NewL)
+	};
+
+// -----------------------------------------------------------------------------
+// TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+// Exported proxy for instantiation method resolution
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
+														TInt& aTableCount)
+	{
+	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+
+	return ImplementationTable;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/ftp/src/sconftpplugin.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,880 @@
+/*
+* 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 Transfer Profile Plug-in implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <obexconstantsinternal.h>
+#endif
+#include "sconftpplugin.h"
+#include "sconftp.h"
+#include "sconftppluginutils.h"
+#include "sconservicetimer.h"
+#include "debug.h"
+
+
+// CONSTANTS
+_LIT(KSConFTPLibName, "sconftp.dll");
+const TInt KSConFTPUidValue = 0x10009D8D;
+const TUid KSConFTPUid = {KSConFTPUidValue};
+
+// Folder listing type from IrObex specification
+_LIT8( KSConFolderListType, "x-obex/folder-listing" );
+
+_LIT( K_C_ROOT, "C:\\" );
+const TInt KSConBufSize = 262144; // 256KB
+// Time (in milliseconds) for the timer
+const TInt KSConTimeOutValue =  60000000;
+// Flags used to indicate SetPath commands
+const TInt KSConNULLSetPath =   0x00;
+
+const TInt KSConHeaderMaxLength = 256;
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::NewL()
+// Two-phase constructor
+// -----------------------------------------------------------------------------
+//
+CSConFTPplugin* CSConFTPplugin::NewL()
+    {
+    TRACE_FUNC_ENTRY;
+    CSConFTPplugin* self = new ( ELeave ) CSConFTPplugin();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    TRACE_FUNC_EXIT;
+    return( self );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::~CSConFTPplugin()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSConFTPplugin::~CSConFTPplugin()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // Disconnect from services.
+    Disconnect();
+    
+    if ( iFTPHandler )
+        {
+        delete iFTPHandler;
+        iFTPHandler = NULL;
+        iFTPlib.Close();
+        }
+    
+    delete iBuffer;
+    iBuffer = NULL;
+    delete iObject;
+    iObject = NULL;
+
+    if ( iServiceTimer )
+        {
+        iServiceTimer->Cancel();
+        }
+
+    delete iServiceTimer;
+    iServiceTimer = NULL;
+
+    if ( iFileObject )
+        {
+        delete iFileObject;
+        iFileObject = NULL;
+        }
+
+
+    delete iShutdownWatcher;
+    iShutdownWatcher = NULL;
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::IsOBEXActive()
+// Returns active status of OBEX session
+// -----------------------------------------------------------------------------
+//
+TBool CSConFTPplugin::IsOBEXActive()
+    {
+    TRACE_FUNC;
+    return iSessionActive;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::NotifyShutdown()
+// System is shutting down
+// -----------------------------------------------------------------------------
+//
+void CSConFTPplugin::NotifyShutdown()
+    {
+    TRACE_FUNC;
+    iShutdownInProgress = ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::LoadFTPDllL()
+// Loads sconftp.dll module
+// -----------------------------------------------------------------------------
+//
+void CSConFTPplugin::LoadFTPDllL()
+    {
+    TRACE_FUNC_ENTRY;
+    // Dynamically load DLL
+    User::LeaveIfError( iFTPlib.Load( KSConFTPLibName ) );
+    if ( iFTPlib.Type()[1] != KSConFTPUid )
+        {
+        LOGGER_WRITE( "KSConFTPUidValue incorrect" );
+        iFTPlib.Close();
+        User::Leave( KErrNotFound );
+        }
+    TSConCreateCSConFTPFunc CreateCSConFTPL =
+    (TSConCreateCSConFTPFunc)iFTPlib.Lookup(1);
+    iFTPHandler = (CSConFTP*)CreateCSConFTPL();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::Disconnect()
+// Closes initialized services
+// -----------------------------------------------------------------------------
+//
+void CSConFTPplugin::Disconnect()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iLinkAdapter.Close();
+    iSocketServer.Close();
+    
+    if ( iStartTimer != EFalse )
+        {
+        iServiceTimer->Cancel();
+        iServiceTimer->StartTimer();
+        }
+    
+    delete iObject;
+    iObject = NULL;
+    
+    if ( iFileObject )
+        {
+        delete iFileObject;
+        iFileObject = NULL;
+        }
+    if ( iFTPHandler )
+        {
+        delete iFTPHandler;
+        iFTPHandler = NULL;
+        iFTPlib.Close();
+        }
+
+    TRACE_FUNC_EXIT
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::ErrorIndication( TInt aError )
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+void CSConFTPplugin::ErrorIndication( TInt aError )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aError : %d", aError );
+    
+    if ( iFTPHandler )
+        {
+        iFTPHandler->AbortFileTransfer( iObject );
+        }
+
+    if ( iObject )
+        {
+        delete iObject;
+        iObject = NULL;
+        }
+    
+    if ( iFileObject )
+        {
+        iFileObject->Reset();
+        delete iFileObject;
+        iFileObject = NULL;
+        }
+
+    // Keep compiler happy
+    (void)aError;
+    
+    delete iShutdownWatcher;
+    iShutdownWatcher = NULL;
+    
+	if ( iLinkAdapter.IsOpen() )
+        {
+        // Cancel ActivateActiveRequester & allow going to low power mode
+        TInt err2 = iLinkAdapter.CancelLowPowerModeRequester();
+        LOGGER_WRITE_1( "iLinkAdapter.CancelLowPowerModeRequester() err: %d", err2 );
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::AbortIndication()
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+void CSConFTPplugin::AbortIndication()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iFTPHandler )
+        {
+        iFTPHandler->AbortFileTransfer( iObject );
+        }
+
+    if ( iObject )
+        {
+        delete iObject;
+        iObject = NULL;
+        }
+    
+    if ( iFileObject )
+        {
+        iFileObject->Reset();
+        delete iFileObject;
+        iFileObject = NULL;
+        }
+    
+    delete iShutdownWatcher;
+    iShutdownWatcher = NULL;
+    
+    if ( iLinkAdapter.IsOpen() )
+        {
+        // Cancel ActivateActiveRequester & allow going to low power mode
+        TInt err = iLinkAdapter.CancelLowPowerModeRequester();
+        LOGGER_WRITE_1( "iLinkAdapter.CancelLowPowerModeRequester() err: %d", err );
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::TransportUpIndication()
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+void CSConFTPplugin::TransportUpIndication()
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::ObexConnectIndication( const TObexConnectInfo& aRemoteInfo,
+// const TDesC8& aInfo )
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTPplugin::ObexConnectIndication(
+                        const TObexConnectInfo& /*aRemoteInfo*/,
+                        const TDesC8& /*aInfo*/ )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt err( KErrNone );
+    iStartTimer = ETrue;
+    
+    if ( iMediaType == ESrcsMediaBT && iObexServer )
+        {
+        TSockAddr remoteAddr;
+        iObexServer->RemoteAddr( remoteAddr );
+        
+        TBTSockAddr btSockAddr( remoteAddr );
+        TBTDevAddr devAddr = btSockAddr.BTAddr();
+        
+        err = iSocketServer.Connect();
+        LOGGER_WRITE_1("iSocketServer.Connect err: %d", err );
+        if ( !err )
+            {
+            err = iLinkAdapter.Open( iSocketServer, devAddr );
+            LOGGER_WRITE_1("iLinkAdapter.Open err: %d", err );
+            }
+        // Ignore all BT link errors
+        err = KErrNone;
+        }
+    
+    if ( err == KErrNone && !iFTPHandler )
+        {
+        TRAP( err, LoadFTPDllL() );
+        LOGGER_WRITE_1( "LoadFTPDllL returned : %d", err );
+        }
+    
+    if ( err == KErrNone )
+        {
+        iFTPHandler->SetProfile( EStandard );
+        LOGGER_WRITE( "CSConFTPplugin::ObexConnectIndication() : iServiceTimer->StopTimer()" );
+        iServiceTimer->Cancel();
+        iServiceTimer->StopTimer();
+        }
+
+    TRACE_FUNC_EXIT;
+    LOGGER_WRITE_1( "CSConFTPplugin::ObexConnectIndication returned %d", err );
+    return TFTPpluginUtils::ConvertFTPResponseCode( err );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::ObexDisconnectIndication( const TDesC8& )
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+void CSConFTPplugin::ObexDisconnectIndication( const TDesC8& )
+    {
+    TRACE_FUNC_ENTRY;
+    Disconnect();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::TransportDownIndication()
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+void CSConFTPplugin::TransportDownIndication()
+    {
+    TRACE_FUNC_ENTRY;
+    Disconnect();
+    if ( iBuffer )
+        {
+        iBuffer->Reset();
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::PutRequestIndication()
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+CObexBufObject* CSConFTPplugin::PutRequestIndication()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    TInt err( KErrNone );
+    iPutError = KErrNone;
+
+    if ( iBuffer )
+        {
+        iBuffer->Reset();
+        }
+
+    if ( iObject )
+        {
+        delete iObject;
+        iObject = NULL;
+        }
+
+    TRAP( err, iObject = CObexBufObject::NewL ( iBuffer ) );
+
+    if ( err != KErrNone )
+        {
+        return NULL;
+        }
+
+    if ( !iFTPHandler )
+        {
+        LOGGER_WRITE( "Creating iFTPHandler has failed" );
+        return NULL;
+        }
+
+    TRAP( err, ret = iFTPHandler->PutFileObjectInitL( iObject, iBuffer ) );
+
+    if ( err != KErrNone )
+        {
+        LOGGER_WRITE_1( "iFTPHandler->PutFileObjectInitL() leaves: %d", err );
+        return NULL;
+        }
+    if ( ret != KErrNone )
+        {
+        LOGGER_WRITE_1( "PutFileObjectInitL failed - returning error in next PutPacketIndication : %d", ret );
+        iPutError = ret;
+        }
+    iPutPacketIndicationCalled = EFalse;
+    
+    if ( !iShutdownWatcher )
+        {
+        TRAP( err, iShutdownWatcher = CShutdownWatcher::NewL( this ) );
+        if ( err == KErrNone )
+            {
+            iShutdownWatcher->StartShutdownWatcher();
+            }
+        else
+            {
+            LOGGER_WRITE_1( "CShutdownWatcher::NewL leaves: %d", err );
+            }
+        }
+    
+    if ( iLinkAdapter.IsOpen() )
+        {
+        // request active BT mode (high power mode)
+        err = iLinkAdapter.ActivateActiveRequester();
+        LOGGER_WRITE_1( "iLinkAdapter.ActivateActiveRequester() err: %d", err );
+        }
+    
+    TRACE_FUNC_EXIT;
+    return( iObject );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::PutPacketIndication()
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTPplugin::PutPacketIndication()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    
+    // always normal file transfer
+    if ( (TInt)iObject->Length() > 0 )
+        {
+        if ( !iPutPacketIndicationCalled )
+            {
+            // This is first check, need to check only once
+            TFileName path;
+            iFTPHandler->GetPath( path );
+            if ( path.CompareF( K_C_ROOT ) == 0 )
+                {
+                // path forbidden
+                ret = KErrAccessDenied;
+                }
+            else
+                {
+                if ( iPutError != KErrNone )
+                    {
+                    ret = iPutError;
+                    LOGGER_WRITE_1( "CSConFTPplugin::PutPacketIndication() : PutError : %d", iPutError );
+                    }
+                else
+                    {
+                    // check required free space
+                    // if filesize is small ( <65k ) it fits into one package and its already saved to filesystem.
+                    // if file is larger, need to check is there enought free space in device.
+                    
+                    const TUint32  filesize = iObject->Length();
+                    LOGGER_WRITE_1( "CSConFTPplugin::PutPacketIndication() filesize %d", filesize );
+                    LOGGER_WRITE_1( "CSConFTPplugin::PutPacketIndication() iObject->BytesReceived() %d", iObject->BytesReceived() );
+                    if ( filesize > iObject->BytesReceived() )
+                        {
+                        LOGGER_WRITE( "CSConFTPplugin::PutPacketIndication() : check freespace" );
+                        // file does not fit into one obex packet, check is there enought free space in current drive
+                        if ( iFTPHandler->IsCurrentDiskSpaceBelowCritical( filesize ) )
+                            {
+    	                    LOGGER_WRITE( "CSConFTPplugin::PutPacketIndication() : returning KErrNoMemory" );
+                            ret = KErrNoMemory;
+                            }
+                        }
+                    }
+                }
+            }
+        
+        if ( iShutdownInProgress )
+            {
+            LOGGER_WRITE( "ShutdownInProgress, abort" );
+            ret = KErrDisconnected;
+            }
+        }
+    
+    if ( !iPutPacketIndicationCalled )
+        {
+        // Need to check only once
+        iPutPacketIndicationCalled = ETrue;
+        
+        //Check if filename is too long.
+        TFileName path;
+        iFTPHandler->GetPath( path );
+        if ( ret == KErrNone && path.Length() + iObject->Name().Length() > KMaxFileName )
+            {
+            LOGGER_WRITE_1( "Name length overflow! : %d", path.Length() + iObject->Name().Length() );
+            ret = KErrBadName;
+            }
+        }
+    
+    if ( ret != KErrNone )
+        {
+        if ( iFTPHandler )
+            {
+            iFTPHandler->AbortFileTransfer( iObject );
+            }
+        
+        delete iObject;
+        iObject = NULL;
+        
+        if ( iLinkAdapter.IsOpen() )
+            {
+            // Cancel ActivateActiveRequester & allow going to low power mode
+            TInt err = iLinkAdapter.CancelLowPowerModeRequester();
+            LOGGER_WRITE_1( "iLinkAdapter.CancelLowPowerModeRequester() err: %d", err );
+            }
+        }
+    
+    LOGGER_WRITE_1( "CSConFTPplugin::PutPacketIndication returned: %d", ret );
+    return TFTPpluginUtils::ConvertFTPResponseCode( ret );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::PutCompleteIndication()
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTPplugin::PutCompleteIndication()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    TInt err( KErrNone );
+    
+    if ( iLinkAdapter.IsOpen() )
+        {
+        // Cancel ActivateActiveRequester & allow going to low power mode
+        TInt err2 = iLinkAdapter.CancelLowPowerModeRequester();
+        LOGGER_WRITE_1( "iLinkAdapter.CancelLowPowerModeRequester() err: %d", err2 );
+        }
+    
+    TObexHeaderMask validHdrs = iObject->ValidHeaders();
+    TTime time = iObject->Time();
+    
+    // shutdownWatcher is not needed anymore
+    delete iShutdownWatcher;
+    iShutdownWatcher = NULL;
+
+    TInt size = iObject->BytesReceived();
+
+    if (!(validHdrs & KObexHdrTime))
+        {
+        LOGGER_WRITE( "CSConFTPplugin::PutCompleteIndication() no valid time header received - using hometime" );
+        time.HomeTime();
+        TRAP( ret, iObject->SetTimeL(time) );
+        LOGGER_WRITE_1( "CSConFTPplugin::PutCompleteIndication SetTimeL  %d", ret );
+        }
+
+    if ( ( validHdrs & KObexHdrBody ) || ( validHdrs & KObexHdrEndOfBody ) )
+        {
+        LOGGER_WRITE_1( "CSConFTPplugin::PutCompleteIndication : number of received bytes  %d", size );
+        TSConUsedMedia media( ESConNoMedia );
+
+        switch ( iMediaType )
+            {
+            case ESrcsMediaBT:
+                media = ESConBTMedia;
+                break;
+            case ESrcsMediaIrDA:
+                media = ESConIRMedia;
+                break;
+            case ESrcsMediaUSB:
+                media = ESConUSBMedia;
+                break;
+            default:
+                media = ESConNoMedia;
+                break;
+            }
+        iFTPHandler->SetUsedMedia( media );
+        
+        TRAP( ret, err =
+        this->iFTPHandler->PutFileObjectFinalizeL( iObject ) );
+        LOGGER_WRITE_1( "CSConFTPplugin::PutCompleteIndication :PutFileObjectL  %d", ret );
+        }
+    else
+        {
+        LOGGER_WRITE( "CSConFTPplugin::PutCompleteIndication() : Delete  starts" );
+        TRAP( ret, err = this->iFTPHandler->DeleteObjectL( iObject->Name() ) );
+        LOGGER_WRITE_1( "CSConFTPplugin::PutCompleteIndication : DeleteObjectL  %d", ret );
+        }
+
+    if ( iObject )
+        {
+        delete iObject;
+        iObject = NULL;
+        }
+
+    iFTPHandler->DeleteTempFile();
+
+    if ( ret != KErrNone )
+        {
+        LOGGER_WRITE_1( "CSConFTPplugin::PutCompleteIndication : returned  %d", ret );
+        return TFTPpluginUtils::ConvertFTPResponseCode( ret );
+        }
+
+    LOGGER_WRITE_1( "CSConFTPplugin::PutCompleteIndication : returned  %d", err );
+    return TFTPpluginUtils::ConvertFTPResponseCode( err );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::GetRequestIndication( CObexBaseObject* aRequiredObject )
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+CObexBufObject* CSConFTPplugin::GetRequestIndication(
+                                            CObexBaseObject* aRequiredObject )
+    {
+    TRACE_FUNC_ENTRY;
+    CObexBufObject* bufObject(NULL);
+    if ( aRequiredObject->Type().Length() > KSConHeaderMaxLength )
+        {
+        LOGGER_WRITE("TypeHeader too big");
+        return NULL;
+        }
+    if ( aRequiredObject->Name().Length() > KMaxFileName )
+        {
+        LOGGER_WRITE("NameHeader is too long");
+        return NULL;
+        }
+    TInt ret( KErrNone );
+    TInt err( KErrNone );
+    TBuf8<KSConHeaderMaxLength> typeHeader( aRequiredObject->Type() );
+    TrimRightSpaceAndNull( typeHeader );
+    LOGGER_WRITE8_1("type: %S", &typeHeader);
+    LOGGER_WRITE_1("name: %S", &aRequiredObject->Name());
+
+    iBuffer->Reset();
+    
+    delete iObject;
+    iObject = NULL;
+    
+    TRAP( err, iObject = CObexBufObject::NewL ( iBuffer ) );
+    if ( err != KErrNone )
+        {
+        return NULL;
+        }
+    
+    // Client requests folder listing
+    if ( typeHeader == KSConFolderListType )
+        {
+        LOGGER_WRITE( "Client requests folder listning" );
+        if ( !iFTPHandler )
+            {
+            LOGGER_WRITE( "Creating iFTPHandler has failed" );
+            return NULL;
+            }
+
+        TRAP( err, ret = iFTPHandler->GetFolderObjectL( iObject ) );
+        LOGGER_WRITE_1( "iFTPHandler->GetFolderObjectL() returned: %d", ret );
+        if ( err == KErrNone && ret == KErrNone )
+            {
+            bufObject = iObject;
+            }
+        else
+            {
+            LOGGER_WRITE_1( "CSConFTPplugin::GetRequestIndication : Leavecode returned  %d", err );
+            return NULL;
+            }
+        }
+
+    // Client requests a file
+    else
+        {
+        if ( iFileObject )
+            {
+            delete iFileObject;
+            iFileObject = NULL;
+            }
+        
+        TRAP( err, iFileObject = CObexFileObject::NewL() );
+        if ( err != KErrNone )
+            {
+            LOGGER_WRITE( "Creating iFileObject has failed" );
+            return NULL;
+            }
+        iFileObject->Reset();
+        TRAP( err, iFileObject->SetNameL( aRequiredObject->Name() ) );
+
+        if ( err == KErrNone )
+            {
+            if ( !iFTPHandler )
+                {
+                LOGGER_WRITE( "CSConFTPplugin::GetRequestIndication() Creating iFTPHandler has failed" );
+                return NULL;
+                }
+
+            TRAP( err, ret =
+            this->iFTPHandler->GetFileObjectL( iFileObject ) );
+            LOGGER_WRITE_1( "CSConFTPplugin::GetRequestIndication :  GetFileObjectL returned  %d", ret );
+            }
+        if ( err == KErrNone && ret == KErrNone )
+            {
+            bufObject = (CObexBufObject*)iFileObject;
+            }
+        else
+            {
+            LOGGER_WRITE_1( "CSConFTPplugin::GetRequestIndication : Leavecode   %d", err );
+            return NULL;
+            }
+        }
+    if ( bufObject && iLinkAdapter.IsOpen() )
+        {
+        // request active BT mode (high power mode)
+        err = iLinkAdapter.ActivateActiveRequester();
+        LOGGER_WRITE_1( "iLinkAdapter.ActivateActiveRequester() err: %d", err );
+        }
+    return bufObject;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::GetPacketIndication()
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTPplugin::GetPacketIndication()
+    {
+    TRACE_FUNC;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::GetCompleteIndication()
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTPplugin::GetCompleteIndication()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iLinkAdapter.IsOpen() )
+        {
+        // Cancel ActivateActiveRequester & allow going to low power mode
+        TInt err = iLinkAdapter.CancelLowPowerModeRequester();
+        LOGGER_WRITE_1( "iLinkAdapter.CancelLowPowerModeRequester() err: %d", err );
+        }
+    
+    TInt ret( KErrNone );
+    if ( iFileObject )
+        {
+        iFileObject->Reset();
+        delete iFileObject;
+        iFileObject = NULL;
+        }
+
+    LOGGER_WRITE_1( "CSConFTPplugin::GetCompleteIndication() : returned %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::SetPathIndication( const CObex::TSetPathInfo& aPathInfo,
+// const TDesC8& aInfo )
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTPplugin::SetPathIndication( const CObex::TSetPathInfo& aPathInfo,
+                                        const TDesC8& /*aInfo*/ )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    TInt err( KErrNone );
+
+    if ( !iFTPHandler )
+        {
+        LOGGER_WRITE( "Creating iFTPHandler has failed" );
+        return TFTPpluginUtils::ConvertFTPResponseCode( KErrNoMemory );
+        }
+
+    if ( aPathInfo.iFlags == KSConNULLSetPath )
+        {
+        TRAP( err, ret = this->iFTPHandler->CreateFolderL( aPathInfo.iName ) );
+        }
+    else
+        {
+        TRAP( err, ret = this->iFTPHandler->SetPathL( aPathInfo.iName,
+        aPathInfo.iFlags ) );
+        }
+    
+    if ( err != KErrNone )
+        {
+        LOGGER_WRITE_1( "CSConFTPplugin::SetPathIndication : returned   %d", err );
+        return TFTPpluginUtils::ConvertFTPResponseCode( err );
+        }
+    LOGGER_WRITE_1( "CSConFTPplugin::SetPathIndication : returned %d", ret );
+    return TFTPpluginUtils::ConvertFTPResponseCode( ret );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::TrimRightSpaceAndNull( TDes8& aDes ) const
+// Removes spaces and nulls from the end of the string
+// -----------------------------------------------------------------------------
+//
+void CSConFTPplugin::TrimRightSpaceAndNull( TDes8& aDes ) const
+    {
+    TRACE_FUNC;
+    aDes.TrimRight();
+    if ( aDes.Length() > 0 )
+        {
+        if ( !aDes[aDes.Length() - 1] )
+            {
+            aDes.SetLength( aDes.Length() - 1 );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::SetMediaType ( TSrcsMediaType aMediaType )
+// Current used transfer media (IR,USB,BT)
+// -----------------------------------------------------------------------------
+//
+void CSConFTPplugin::SetMediaType ( TSrcsMediaType aMediaType )
+    {
+    TRACE_FUNC;
+    iMediaType = aMediaType;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::CSConFTPplugin()
+// Constructor
+// -----------------------------------------------------------------------------
+//
+CSConFTPplugin::CSConFTPplugin()
+    {
+    TRACE_FUNC;
+    iBuffer = NULL;
+    iObject = NULL;
+    iFileObject = NULL;
+    iSessionActive = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::ConstructL()
+// Initializes member data
+// -----------------------------------------------------------------------------
+//
+void CSConFTPplugin::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    iBuffer = CBufFlat::NewL( KSConBufSize );
+    iObject = CObexBufObject::NewL ( iBuffer );
+    iServiceTimer = new (ELeave) CSConServiceTimer( this, KSConTimeOutValue );
+    iServiceTimer->ConstructL();
+    CActiveScheduler::Add( iServiceTimer );
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTPplugin::SetObexServer( CObexServer* aObexServer )
+// SetObexServer
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTPplugin::SetObexServer( CObexServer* aObexServer )
+    {
+    iObexServer = aObexServer;
+    TInt ret = iObexServer->Start(this);
+    LOGGER_WRITE_1( "CSConFTPplugin::SetObexServer() ret: %d", ret );
+    return ret;
+    }
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/ftp/src/sconftppluginutils.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,129 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File Transfer Profile Plug-in utilities
+*
+*/
+
+
+// INCLUDE FILES
+#include <obexconstants.h>
+#include "sconftppluginutils.h"
+#include "debug.h"
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// TFTPpluginUtils::ConvertFTPResponseCode( TInt aError )
+// Converts Symbian error code to OBEX error code
+// -----------------------------------------------------------------------------
+//
+TInt TFTPpluginUtils::ConvertFTPResponseCode( TInt aError )
+	{
+	LOGGER_WRITE_1( "TFTPpluginUtils::ConvertFTPResponseCode : begin Code  %d", aError );
+	TInt obexErr ( KErrIrObexRespBadRequest );
+	switch( aError )
+		{
+		case KErrNone:
+			obexErr = KErrNone;
+			break;
+		case KErrNotFound:
+			obexErr = KErrIrObexRespNotFound;
+			break;
+		case KErrGeneral:
+		case KErrCancel:
+			obexErr = KErrIrObexRespBadRequest;
+			break;
+		case KErrNoMemory:
+			obexErr = KErrIrObexRespDatabaseFull;
+			break;
+		case KErrNotSupported:
+			obexErr = KErrIrObexRespNotImplemented;
+			break;
+		case KErrArgument:
+		case KErrTotalLossOfPrecision:
+		case KErrBadHandle:
+		case KErrOverflow:
+		case KErrUnderflow:
+		case KErrAlreadyExists:
+			obexErr = KErrIrObexRespConflict;
+			break;
+		case KErrPathNotFound:
+		case KErrDied:
+			obexErr = KErrIrObexRespNotFound;
+			break;
+		case KErrInUse:
+			obexErr = KErrIrObexRespTimedOut;
+			break;
+		case KErrServerTerminated:
+			obexErr = KErrIrObexRespNotFound;
+			break;
+		case KErrServerBusy:
+		case KErrCompletion:
+		case KErrNotReady:
+		case KErrUnknown:
+		case KErrCorrupt:
+			obexErr = KErrIrObexRespForbidden;
+			break;
+		case KErrAccessDenied:
+		case KErrLocked:
+			obexErr = KErrIrObexRespUnauthorized;
+			break;
+		case KErrWrite:
+		case KErrDisMounted:
+		case KErrEof:
+			obexErr = KErrIrObexRespForbidden;
+			break;
+		case KErrDiskFull:
+			obexErr = KErrIrObexRespDatabaseFull;
+			break;
+		case KErrBadDriver:
+		case KErrBadName:
+			obexErr = KErrIrObexRespPreCondFailed;
+			break;
+		case KErrCommsLineFail:
+		case KErrCommsFrame:
+		case KErrCommsOverrun:
+		case KErrCommsParity:
+		case KErrTimedOut:
+		case KErrCouldNotConnect:
+		case KErrCouldNotDisconnect:
+		case KErrBadLibraryEntryPoint:
+		case KErrBadDescriptor:
+		case KErrAbort:
+			obexErr = KErrIrObexRespForbidden;
+			break;
+		case KErrTooBig:
+			obexErr = KErrIrObexRespReqEntityTooLarge;
+			break;
+		case KErrDivideByZero:
+		case KErrBadPower:
+		case KErrDirFull:
+		case KErrHardwareNotAvailable:
+			obexErr = KErrIrObexRespForbidden;
+			break;
+		case KErrDisconnected: // System is shutting down
+		    obexErr = KErrIrObexRespMethodNotAllowed;
+		    break;
+		default:
+			obexErr = KErrIrObexRespBadRequest;
+			break;
+		};
+	LOGGER_WRITE_1( "TFTPpluginUtils::ConvertFTPResponseCode : returned %d", obexErr );
+	return obexErr;
+};
+
+//End of file
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/ftp/src/sconservicetimer.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,119 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File Transfer Profile Plug-in Service Timer implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "sconservicetimer.h"
+#include "sconftpplugin.h"
+#include "debug.h"
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSConServiceTimer::CSConServiceTimer( CSConFTPplugin* aEngine, TInt aValue )
+// Constuctor
+// -----------------------------------------------------------------------------
+//
+CSConServiceTimer::CSConServiceTimer( CSConFTPplugin* aEngine, TInt aValue )
+	: CActive( EPriorityStandard ), iEngine( aEngine ), iValue( aValue ) {}
+
+// -----------------------------------------------------------------------------
+// CSConServiceTimer::ConstructL()
+// Initializes member data
+// -----------------------------------------------------------------------------
+//
+void CSConServiceTimer::ConstructL()
+	{
+	LOGGER_ENTERFN( "CSConServiceTimer::ConstructL()" );
+	// create a thread-relative timer
+	User::LeaveIfError( iTimer.CreateLocal() );
+	LOGGER_LEAVEFN( "CSConServiceTimer::ConstructL()" );
+	}
+
+// -----------------------------------------------------------------------------
+// CSConServiceTimer::~CSConServiceTimer()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSConServiceTimer::~CSConServiceTimer()
+	{
+	LOGGER_ENTERFN( "CSConServiceTimer::~CSConServiceTimer()" );
+	iTimer.Close();
+	LOGGER_LEAVEFN( "CSConServiceTimer::~CSConServiceTimer()" );	
+	}
+
+// -----------------------------------------------------------------------------
+// CSConServiceTimer::~CSConServiceTimer()
+// Starts the timer
+// -----------------------------------------------------------------------------
+//
+void CSConServiceTimer::StartTimer()
+	{
+	LOGGER_ENTERFN( "CSConServiceTimer::StartTimer()" );
+	if( !IsActive() )
+		{
+		LOGGER_WRITE( "CSConServiceTimer::StartTimer() : !IsActive()" );
+		iTimer.After( iStatus, TTimeIntervalMicroSeconds32( iValue ) );
+		iEngine->iSessionActive = ETrue;
+		SetActive();
+		LOGGER_WRITE( "CSConServiceTimer::StartTimer() : SetActive()" );
+		}
+	LOGGER_LEAVEFN( "CSConServiceTimer::StartTimer()" );
+	}
+
+// -----------------------------------------------------------------------------
+// CSConServiceTimer::StopTimer()
+// StopTimer()
+// -----------------------------------------------------------------------------
+//
+void CSConServiceTimer::StopTimer()
+	{
+	LOGGER_ENTERFN( "CSConServiceTimer::StopTimer()" );
+	iEngine->iSessionActive = ETrue;	
+	LOGGER_WRITE( "CSConServiceTimer::StopTimer() : iSessionActive = ETrue" );
+	LOGGER_LEAVEFN( "CSConServiceTimer::StopTimer()" );	
+	}
+
+// -----------------------------------------------------------------------------
+// CSConServiceTimer::DoCancel()
+// Cancels the timer
+// -----------------------------------------------------------------------------
+//
+void CSConServiceTimer::DoCancel()
+	{
+	LOGGER_ENTERFN( "CSConServiceTimer::DoCancel()" );
+	iTimer.Cancel();
+	LOGGER_LEAVEFN( "CSConServiceTimer::DoCancel()" );
+	}
+
+// -----------------------------------------------------------------------------
+// CSConServiceTimer::RunL()
+// Executed when timer is triggered
+// -----------------------------------------------------------------------------
+//
+void CSConServiceTimer::RunL()
+	{
+	LOGGER_ENTERFN( "CSConServiceTimer::RunL()" );
+	iEngine->iSessionActive = EFalse;
+	LOGGER_WRITE( "CSConServiceTimer::RunL() : iSessionActive = EFalse" );
+	iEngine->iStartTimer = EFalse;
+	LOGGER_WRITE( "CSConServiceTimer::RunL() : iStartTimer = EFalse " );
+	LOGGER_LEAVEFN( "CSConServiceTimer::RunL()" );
+	}
+	
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/ftp/src/sconshutdownwatcher.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,153 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Power shutdown -watcher implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "sconshutdownwatcher.h"
+#include "debug.h"
+
+#include <startupdomainpskeys.h>
+
+
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CShutdownWatcher::NewL( MShutdownObserver* aObserver )
+// Two-phase constructor
+// -----------------------------------------------------------------------------
+//
+CShutdownWatcher* CShutdownWatcher::NewL( MShutdownObserver* aObserver )
+    {
+    LOGGER_ENTERFN( "CShutdownWatcher::NewL()" );
+    CShutdownWatcher* self = new (ELeave) CShutdownWatcher( aObserver );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    LOGGER_LEAVEFN( "CShutdownWatcher::NewL()" );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CShutdownWatcher::~CShutdownWatcher()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CShutdownWatcher::~CShutdownWatcher()
+    {
+    LOGGER_ENTERFN( "CShutdownWatcher::~CShutdownWatcher()" );
+    Cancel();
+    iProperty.Close();
+    LOGGER_LEAVEFN( "CShutdownWatcher::~CShutdownWatcher()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CShutdownWatcher::StartShutdownWatcher()
+// Starts to watch shutdown status
+// -----------------------------------------------------------------------------
+//
+void CShutdownWatcher::StartShutdownWatcher()
+    {
+    LOGGER_ENTERFN( "CShutdownWatcher::StartShutdownWatcher()" );
+    TInt status;
+    TInt err = iProperty.Get( KPSUidStartup, KPSGlobalSystemState, status );
+    LOGGER_WRITE_2( "CShutdownWatcher::StartShutdownWatcher() :\
+     err %d, KPSGlobalSystemState status %d", err, status);
+    if ( err == KErrNone )
+        {
+        if ( status == ESwStateShuttingDown )
+            {
+            LOGGER_WRITE( "Call NotifyShutdown" );
+            iObserver->NotifyShutdown();
+            return;
+            }
+        }
+    
+    err = iProperty.Attach( KPSUidStartup, KPSGlobalSystemState );
+    LOGGER_WRITE_1( "CShutdownWatcher::StartShutdownWatcher() :\
+     iProperty.Attach( KPSUidStartup, KPSGlobalSystemState ) : err %d", err );
+    iProperty.Subscribe( iStatus );
+    LOGGER_WRITE( "CShutdownWatcher::StartShutdownWatcher() :\
+     iProperty.Subscribe( iStatus ) : ok" );
+    SetActive();
+
+    LOGGER_LEAVEFN( "CShutdownWatcher::StartShutdownWatcher()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CShutdownWatcher::DoCancel()
+// Executed when CActive is canceled.
+// -----------------------------------------------------------------------------
+//
+void CShutdownWatcher::DoCancel()
+    {
+    LOGGER_ENTERFN( "CShutdownWatcher::DoCancel()" );
+    iProperty.Cancel();
+    LOGGER_LEAVEFN( "CShutdownWatcher::DoCancel()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CShutdownWatcher::RunL()
+// Executed when disk watcher is triggered
+// -----------------------------------------------------------------------------
+//
+void CShutdownWatcher::RunL()
+    {
+    LOGGER_ENTERFN( "CShutdownWatcher::RunL()" );
+    TInt status;
+    iProperty.Get( status );
+    LOGGER_WRITE_1( "CShutdownWatcher::RunL() : status %d", status );
+    
+    if ( status == ESwStateShuttingDown )
+        {
+        LOGGER_WRITE( "Call NotifyShutdown" );
+        iObserver->NotifyShutdown();
+        return;
+        }
+    
+    iProperty.Cancel();
+    iProperty.Close();
+    
+    LOGGER_LEAVEFN( "CShutdownWatcher::RunL()" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CShutdownWatcher::CShutdownWatcher( MShutdownObserver* aObserver )
+// Default constructor
+// -----------------------------------------------------------------------------
+//
+CShutdownWatcher::CShutdownWatcher( MShutdownObserver* aObserver )
+: CActive(EPriorityStandard),
+    iObserver(aObserver)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CShutdownWatcher::ConstructL()
+// Initializes member data
+// -----------------------------------------------------------------------------
+//
+void CShutdownWatcher::ConstructL()
+    {
+    LOGGER_ENTERFN( "CShutdownWatcher::ConstructL()" );
+    CActiveScheduler::Add(this);
+    LOGGER_LEAVEFN( "CShutdownWatcher::ConstructL()" );
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/hapticsconnplugin/data/2001FE54.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2001 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Plugin info file.
+*
+*/
+
+
+#include "ecom/registryinfo.rh"
+
+// Declares info for two implementations
+RESOURCE REGISTRY_INFO theInfo
+    {
+    // UID for the DLL
+    dll_uid = 0x2001FE54;
+    // Declare array of interface info
+    interfaces = 
+        {
+        INTERFACE_INFO
+            {
+            // UID of interface that is implemented
+            interface_uid = 0x101F7C8C;
+            implementations = 
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x2001FE53;
+                    version_no = 1;
+                    display_name = "Haptics Bridge";
+                    default_data = "OBEX/USB||OBEX/BT";
+                    // 
+                    // opaque_data contains parameters used by following API calls in SRCS:
+                    // 1. Setup USB interface string descriptor in Unicode;
+                    // 2. TInt CObex::SetLocalWho(const TDesC8& aInfo);
+                    // 3. TInt CBTConnection::RegisterSecuritySettingsL( TUint aService,
+                    //                       TInt  aProtocol,
+                    //                       TInt  aChannel,
+                    //                       TBool aAuthenticate,
+                    //                       TBool aAuthorise,
+                    //                       TBool aEncrypt );
+                    // opaque_data = "@0||@1||@2||@3||@4||@5||@6"
+                    // @0 aStrDesc      e.g. "PC Connectivity"
+                    // @1 aInfo         e.g. KFolderBrowsingID, "\xF9\xEC\x7B\xC4\x95\x3C\x11\xd2\x98\x4E\x52\x54\x00\xDC\x9E\x09"
+                    // @2 aService      e.g. KBTSecurityUidFileTransfer, 0x1106
+                    // @3 aProtocol     e.g. KSolBtRFCOMM, 0x1013
+                    // @4 aAuthenticate e.g. EFalse, 0
+                    // @5 aAuthorise    e.g. EFalse, 0
+                    // @6 aEncrypt      e.g. EFalse, 0
+                    //
+                    opaque_data = "Haptics Bridge|"\
+                              "|\xF9\xEC\x7B\xC4\x95\x3C\x11\xd2\x98\x4E\x52\x54\x00\xDC\x9E\x09|"\
+                              "|0x2001E2B5|"\
+                              "|0x1013|"\
+                              "|0|"\
+                              "|1|"\
+                              "|0|"\
+                              "|0xffff|"\
+                              "|0xffff";
+                    }
+                };
+            }
+        };
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/hapticsconnplugin/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -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:  Haptics connection plugin build file. 
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS  
+DEFAULT
+
+PRJ_EXPORTS
+../rom/hapticsconnplugin.iby CORE_IBY_EXPORT_PATH(mw, hapticsconnplugin.iby)
+
+PRJ_MMPFILES
+hapticsconnplugin.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/hapticsconnplugin/group/hapticsconnplugin.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Haptics connection plugin project definition file.
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_ECOM_PLUGIN
+
+TARGET          hapticsconnplugin.dll
+TARGETTYPE      PLUGIN
+
+UID             0x10009D8D 0x2001FE54
+
+SOURCEPATH     	../src
+
+SOURCE          hapticsconnplugin.cpp
+SOURCE          hapticsconntimer.cpp
+SOURCE          hapticsmsghandler.cpp
+SOURCE          hapticsbridgeclient.cpp
+SOURCE          proxy.cpp
+
+SOURCEPATH     	../data
+
+START RESOURCE 2001FE54.rss
+  TARGET        hapticsconnplugin.rsc
+END 
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE /epoc32/include/stdapis
+
+USERINCLUDE     ../inc
+
+LIBRARY         flogger.lib
+LIBRARY         euser.lib
+LIBRARY         ecom.lib			
+LIBRARY         efsrv.lib
+LIBRARY         avkon.lib
+LIBRARY         bafl.lib
+LIBRARY         platformenv.lib
+LIBRARY         irobex.lib
+LIBRARY         hwrmhapticspacketizer.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/hapticsconnplugin/inc/hapticsbridgeclient.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,101 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client interface to haptics server for haptics bridge 
+*                commands.
+*
+*/
+
+
+#ifndef C_HAPTICSBRIDGECLIENT_H
+#define C_HAPTICSBRIDGECLIENT_H
+
+#include <e32base.h>
+
+class CHWRMHapticsPacketizer;
+
+class RHapticsBridgeClient : public RSessionBase
+{
+public:
+    /**
+     * Constructor
+     */
+     RHapticsBridgeClient();
+     
+     /**
+      * Destructor
+      */
+     virtual ~RHapticsBridgeClient();
+
+public:
+    /**
+     * Create a connection to haptics server.
+     */
+	TInt Connect();
+
+    /**
+     * Close the connection to haptics server.
+     */
+	void Close();
+
+    /**
+     * Send message to haptics server.
+     * @param aReqData     Data request to be sent to haptics server.
+     * @param aRetDataPckg Returned data from haptics server.
+     * @return KErrNone if sent succesfully, otherwise system wide error code.
+     */
+	TInt SendBridgeBuffer( const TDesC8& aReqData, TDes8& aRetDataPckg );
+
+    /**
+     * Sends a message clean-up commend to haptics server.
+     */
+	void CleanUp();
+    
+
+private:
+
+    /**
+     * Returns the version of the haptics server.
+     * @return Version.
+     */
+	TVersion ServerVersion() const;
+
+    /**
+     * Starts the server process if it is not already running.
+     * @return KErrNone on success, otherwise a system error code.
+     */
+	TInt StartServer() const;
+
+    /**
+     * Handles the device opening request.
+     * @param aResponse Reference to a descriptor containing the response
+     *                  received from haptics server.
+     */
+	void HandleOpenDeviceResponseL( const TDesC8& aResponse );
+	
+	/**
+	 * Opens the haptic effect ("vibra") device.
+	 * @return KErrNone on success, otherwise a system error code.
+	 */
+    TInt OpenHapticsDevice();
+
+private:
+
+    /**
+     * Haptic packetizer.
+     * Owned.
+     */
+    CHWRMHapticsPacketizer* iPacketizer;     
+};
+
+#endif // C_HAPTICSBRIDGECLIENT_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/hapticsconnplugin/inc/hapticsconnplugin.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Haptics OBEX connection plugin.
+*
+*/
+
+
+#ifndef C_HAPTICSCONNPLUGIN_H
+#define C_HAPTICSCONNPLUGIN_H
+
+#include <obexserver.h>
+#include <SrcsInterface.h>
+
+class CHapticsMsgHandler;
+
+class CHapticsConnPlugin : public CSrcsInterface
+    {
+    public:
+        /**
+         * 2-phased constructor.
+         */
+        static CHapticsConnPlugin* NewL();
+
+        /**
+         * Destructor.
+         */
+        virtual ~CHapticsConnPlugin();
+        
+        /**
+         * From CSrcsInterface.
+         * @see CSrcsInterface.
+         */
+        TBool IsOBEXActive();
+        
+    private:
+        /**
+         * 2nd phase constructor.
+         */    
+        void ConstructL();
+        
+        /**
+         * Constructor.
+         */
+        CHapticsConnPlugin();
+        
+    private:
+        /**
+         * Component to handle messages between file systen and 
+         * haptics server.
+         * Own.
+         */
+        CHapticsMsgHandler* iMsgHandler;
+    };
+
+#endif // C_HAPTICSCONNPLUGIN_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/hapticsconnplugin/inc/hapticsconntimer.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Connection shutdown timer for haptics server connection.
+*
+*/
+
+
+#ifndef C_HAPTICSCONNTIMER_H
+#define C_HAPTICSCONNTIMER_H
+
+#include <e32base.h>
+
+#include "hapticsmsghandler.h"
+
+NONSHARABLE_CLASS ( CHapticsConnTimer ) : public CTimer
+	{
+	public:
+        /**
+         * 2-phased constructor.
+         */
+        static CHapticsConnTimer* NewL( MHapticsConnectionShutdown* aCallback );
+
+        /**
+         * Destructor.
+         */
+        virtual ~CHapticsConnTimer();
+
+		/**
+	 	* Starts the timer
+	 	*/
+        void Start();
+        
+    private: // From CActive.
+        /**
+         * Notifies client on timeout.
+         */
+        void RunL();
+        			
+    private:
+        /**
+         * Constructor.
+         */
+        CHapticsConnTimer( MHapticsConnectionShutdown* aCallback );
+
+        /**
+         * 2nd phase constructor.
+         */    
+	    void ConstructL();
+
+    private:
+        /**
+         * Callback interface to notify about timeout.
+         * Not own.
+         */        
+        MHapticsConnectionShutdown* iCallback;
+	};
+	
+#endif // C_HAPTICSCONNTIMER_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/hapticsconnplugin/inc/hapticsconntrace.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,113 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Haptics conn plugin debug trace macro definition header file.
+*
+*/
+#ifndef HAPTICSCONNTRACE_H
+#define HAPTICSCONNTRACE_H
+
+#include <bldvariant.hrh>
+#include <e32svr.h>
+#include <e32std.h>
+#include <e32svr.h>
+#include <flogger.h>
+
+/**
+ * Writes formatted string data to a file using RFileLogger.
+ *
+ * @param aFmt Value-referenced descriptor containing the formatted string. 
+ */
+inline void HwrmWriteFormat( TRefByValue<const TDesC> aFmt, ... )
+    {
+    _LIT( KDir, "Hwrm" );
+    _LIT( KName, "Hwres.log" );
+
+    // take the ellipsis parameters
+    VA_LIST args;
+    VA_START( args, aFmt );
+    RFileLogger::WriteFormat( KDir, KName, EFileLoggingModeAppend, aFmt, args );
+    VA_END( args );
+    }
+
+/**
+ * Writes data dump in hex format in "[ 00 01 FF ]" style.
+ * 
+ * @param aPrefix Descriptor containing the string to be appended in 
+ *                front of the actual data dump.
+ * @param aData   An 8-bit descriptor containing the data buffer for which 
+ *                the data dump is written.
+ */
+inline void DataDumpTrace( const TDesC& aPrefix, const TDesC8& aData )
+    {
+    _LIT( KSATraceDataDumpStart, " [ " );
+    _LIT( KSATraceDataDumpLineAlign, "   " );
+    _LIT( KSATraceDataDumpStop, " ] " );
+    _LIT( KSATraceDataDumpValue, "%02x " );
+    const TInt KSASDataDumpTraceBytesPerLine = 10;
+    
+    HBufC* buffer = HBufC::New( 255 );
+
+    if ( buffer != NULL )
+        {
+        buffer->Des().Copy( aPrefix );
+        buffer->Des().Append( KSATraceDataDumpStart );
+        for ( TInt i = 0; i < aData.Length(); i++)
+            {
+            buffer->Des().AppendFormat( KSATraceDataDumpValue,  aData[i] );
+            
+            if( ( i % KSASDataDumpTraceBytesPerLine == ( KSASDataDumpTraceBytesPerLine - 1 ) ) && 
+                ( i + 1 < aData.Length() ) )
+                {
+                RDebug::Print( buffer->Des() );
+
+                buffer->Des().Copy( aPrefix);
+                buffer->Des().Append( KSATraceDataDumpLineAlign );
+                }
+            }
+        buffer->Des().Append( KSATraceDataDumpStop );
+            
+        RDebug::Print( buffer->Des() );
+                
+        }
+
+    delete buffer;
+    }
+
+#ifdef _DEBUG
+
+    #ifdef USE_FILE_LOGGING
+    
+        #define COMPONENT_TRACE( a ) HwrmWriteFormat a
+        #define API_TRACE( a ) HwrmWriteFormat a
+        #define DATADUMP_TRACE( a, b )
+    
+    #else
+
+        #define COMPONENT_TRACE( a ) RDebug::Print a
+        #define API_TRACE( a ) RDebug::Print a
+        #define DATADUMP_TRACE( a, b ) DataDumpTrace( a, b )
+        
+    #endif // #ifdef USE_FILE_LOGGING
+
+#else // #ifdef _DEBUG
+
+    #define COMPONENT_TRACE( a )
+    #define API_TRACE( a )
+    #define DATADUMP_TRACE( a, b ) 
+
+#endif //#ifdef _DEBUG
+#endif //#ifndef HAPTICSCONNTRACE_H
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/hapticsconnplugin/inc/hapticsmsghandler.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,136 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handles messaging between file system and haptics 
+*                client interface.
+*
+*/
+
+
+#ifndef C_HAPTICSMSGHANDLER_H
+#define C_HAPTICSMSGHANDLER_H
+
+#include <e32base.h>
+#include <e32debug.h>
+#include <f32file.h>
+
+#include "hapticsbridgeclient.h"
+
+class CHapticsConnTimer;
+
+/**
+ * Interface to notify about connection timeout.
+ */
+class MHapticsConnectionShutdown
+    {
+    public:
+        /**
+         * Called to notify about connection timeout.
+         */
+        virtual void NotifyShutdown() = 0;
+    
+    };
+
+/**
+ * Helper class for Bridge functionality for handling RFs (File Session)
+ * change notifications for VibeTonz request file.
+ *
+ * @since S60 5.1
+ */
+class CHapticsMsgHandler : public CActive,
+                           public MHapticsConnectionShutdown
+    {        
+public:    
+    /**
+     * 2-phased constructor.
+     */
+    static CHapticsMsgHandler* NewL();
+    
+    /**
+     * Destructor
+     */
+    virtual ~CHapticsMsgHandler();
+
+    /**
+     * Method for starting the listening for change notifications    
+     */
+    void StartNotifier();
+        
+    /**
+     * From MHapticsConnectionShutdown.
+     * Called to notify about connection timeout.
+     */        
+    void NotifyShutdown();   
+    
+protected: // From CActive.    
+    /**
+     * @see CActive
+     */
+    void RunL();
+    /**
+     * @see CActive
+     */    
+    TInt RunError(TInt aError);
+    /**
+     * @see CActive
+     */    
+    void DoCancel();
+        
+private:
+
+    /**
+     * Constructor
+     */
+    CHapticsMsgHandler();
+
+    /**
+     * Two-phase construction ConstructL
+     */
+    void ConstructL();
+    
+    /**
+     * Method for connecting to file system. Also sets the paths and
+     * creates directories (if not already exists).
+     */
+    void ConnectToFilesystemL();            	
+ 
+    /**
+     * Helper for clearing the possible left-over request file from
+     * previous runs.
+     */
+    void ClearRequestFile();
+
+private: // data
+    
+    /**
+     * File server session through which all file server related 
+     * services are requested.
+     */
+    RFs iFs;
+    
+    /**
+     * Buffer for the request file data
+     */
+    HBufC8* iReqBuf;    
+
+    /**
+     * The RHapticsBridgeClient object that is responsible for further
+     * handling of received Bridge commands
+     */
+    RHapticsBridgeClient iClient;
+    
+    CHapticsConnTimer* iConnectionTimeout;
+        
+  };
+
+#endif // C_HAPTICSMSGHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/hapticsconnplugin/rom/hapticsconnplugin.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file for Haptics conn plugin.
+*
+*/
+
+
+#ifndef HAPTICSCONNPLUGIN_IBY
+#define HAPTICSCONNPLUGIN_IBY
+
+#include <data_caging_paths_for_iby.hrh>
+
+ECOM_PLUGIN(hapticsconnplugin.dll,hapticsconnplugin.rsc)
+
+#endif // HAPTICSCONNPLUGIN_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/hapticsconnplugin/src/hapticsbridgeclient.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,317 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client interface to haptics server for haptics bridge 
+*                commands.
+*
+*/
+
+
+#include <e32svr.h>
+#include <f32file.h>
+#include <data_caging_path_literals.hrh> // KDC_PROGRAMS_DIR
+#include <hwrmhaptics.h>
+#include <hwrmlogicalactuators.h>
+#include <hwrmhapticspacketizer.h>
+
+#include "hapticsbridgeclient.h"
+#include "hapticsconntrace.h"
+
+const TInt KServerVersionMajor       = 1;
+const TInt KServerVersionMinor       = 1;
+const TInt KServerVersionBuild       = 1;
+_LIT( KServerProcessName, "!hwrmhapticsserver" );
+_LIT( KServerExeName, "hwrmhapticsserver.exe" );
+const TInt KAsyncMsgSlots = 10;
+
+const TInt KHWRMHapticsServiceCommand      = 2001;
+const TInt KHWRMHapticsOpenActuatorCommand = 2004;
+const TInt KHWRMHapticsCleanupCommand      = 2008;
+const TInt KHWRMHapticsBridgeCommand       = 2011;
+
+// --------------------------------------------------------------------------
+// Simple constructor
+// 
+// --------------------------------------------------------------------------
+// 
+RHapticsBridgeClient::RHapticsBridgeClient()
+    {
+    TRAP_IGNORE( iPacketizer = 
+                 CHWRMHapticsPacketizer::NewL( EHWRMLogicalActuatorAny ) );
+    }
+
+// --------------------------------------------------------------------------
+// Simple destructor
+// 
+// --------------------------------------------------------------------------
+// 
+RHapticsBridgeClient::~RHapticsBridgeClient()
+    {
+    delete iPacketizer;
+    }
+
+// --------------------------------------------------------------------------
+// Method for connecting (creating a new session) with Haptics Server
+// 
+// --------------------------------------------------------------------------
+// 
+TInt RHapticsBridgeClient::Connect()
+    {
+    COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::Connect()" ) ) );
+    TInt ret = CreateSession( KServerProcessName, 
+                              ServerVersion(), 
+                              KAsyncMsgSlots );
+    if ( ret != KErrNone )
+        {
+        ret = StartServer();
+        if ( ret == KErrNone )
+            {
+            ret = CreateSession( KServerProcessName, 
+                                 ServerVersion(),
+                                 KAsyncMsgSlots );    
+            COMPONENT_TRACE(_L("RHapticsBridgeClient::Connect(), Session created"));
+            }       
+        }
+
+    // Initialize server components.
+    if ( ret == KErrNone )
+        {
+        ret = SendReceive( KHWRMHapticsServiceCommand );
+        }
+
+    // Open the haptic effect ("vibra") device.
+    if ( ret == KErrNone )
+        {
+        ret = OpenHapticsDevice();
+        }
+    
+        
+    COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::Connect - return(%d)" ), ret ) );        
+    return ret;
+    }
+
+// --------------------------------------------------------------------------
+// Method for starting Haptics Server (if not already running)
+// 
+// --------------------------------------------------------------------------
+//
+TInt RHapticsBridgeClient::StartServer() const
+    {
+    COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::StartServer()" ) ) );
+
+    TParse parser;
+    parser.Set( KServerExeName, &KDC_PROGRAMS_DIR, NULL );
+        
+    RProcess server;
+    TInt ret = server.Create( parser.FullName(), KNullDesC );
+
+    if ( ret != KErrNone ) // Loading failed.
+        {
+        return ret;
+        }
+
+    TRequestStatus status;
+    server.Rendezvous( status );
+
+    if ( status != KRequestPending )
+        {
+        server.Kill( 0 ); // Abort startup.
+        server.Close();
+        return KErrGeneral;
+        }
+    else
+        {
+        server.Resume(); // Logon OK - start the server.
+        }
+        
+    User::WaitForRequest( status );
+    server.Close();
+
+    COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::StartServer() - return %d" ), status.Int() ) );
+    return status.Int();    
+    }
+
+// --------------------------------------------------------------------------
+// Method for closing session to haptics server.
+// 
+// --------------------------------------------------------------------------
+//    
+void RHapticsBridgeClient::Close()    
+    {
+    RSessionBase::Close();
+    }
+
+// --------------------------------------------------------------------------
+// Getter method for server version.
+// 
+// --------------------------------------------------------------------------
+//
+TVersion RHapticsBridgeClient::ServerVersion() const 
+    {
+    return TVersion( KServerVersionMajor, 
+                     KServerVersionMinor,
+                     KServerVersionBuild );
+    }
+
+// --------------------------------------------------------------------------
+// Method for sending commands to Haptics Server.
+// 
+// --------------------------------------------------------------------------
+//    
+TInt RHapticsBridgeClient::SendBridgeBuffer( const TDesC8& aReqData, TDes8& aRetDataPckg )
+    {
+    COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::SendBridgeBufferL() - Begin" ) ) );
+
+    TInt retVal( KErrDisconnected );
+    if ( iHandle )
+        {
+        TInt vibeStatus(0);
+        TPckg<TInt> vibeStatusPckg( vibeStatus );
+        retVal = SendReceive( KHWRMHapticsBridgeCommand, 
+                              TIpcArgs( &aReqData, 
+                                        &vibeStatusPckg, 
+                                        &aRetDataPckg ) );
+
+        if ( retVal == KErrNone ) 
+            {
+            TRAP( retVal, HandleOpenDeviceResponseL( aRetDataPckg ) );
+            }
+        }
+    
+    COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::SendBridgeBufferL() - End (%d)" ), retVal ) );    
+    return retVal;
+    }
+
+// --------------------------------------------------------------------------
+// Method for cleaning up session to Haptics Server.
+// 
+// --------------------------------------------------------------------------
+//
+void RHapticsBridgeClient::CleanUp()
+    {
+    COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::CleanUp() - Begin" ) ) );
+    if ( iHandle )
+        {
+        SendReceive ( KHWRMHapticsCleanupCommand );
+        }
+    COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::CleanUp() - End" ) ) );
+    }
+
+// --------------------------------------------------------------------------
+// Method for handling Open Device responses (basically for requesting the 
+// setting of the license key).
+// 
+// --------------------------------------------------------------------------
+//
+void RHapticsBridgeClient::HandleOpenDeviceResponseL( const TDesC8& aResponse )
+    {
+    COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::HandleOpenDeviceResponse() - Begin" ) ) );
+    TInt err( KErrNone );
+    if ( !iPacketizer )
+        {
+        COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::HandleOpenDeviceResponse() - No Packetizer!" ) ) );
+        User::Leave( KErrGeneral );
+        }
+    else    
+        {
+        const TUint8* pRsp ( aResponse.Ptr() );
+        if ( 0x12 == pRsp[0] && 0x00 == pRsp[1] && 0x00 == pRsp[2] )
+            {
+            COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::HandleOpenDeviceResponse() - OPEN DEVICE RESPONSE handling" ) ) );
+            iPacketizer->DecodeMessageL( aResponse, err );
+            if ( !err )
+                {
+                RBuf8 reqBuf;
+                err = iPacketizer->EncSetPlatformLicenseKeyReq( 
+                    iPacketizer->DeviceHandle(), reqBuf );
+                if ( !err )
+                    {
+                    TBuf8<50> dummyRetBuf;
+                    TInt dummyStatus;
+                    TPckg<TInt> dummyStatusPckg( dummyStatus );
+                    err = SendReceive( KHWRMHapticsBridgeCommand, 
+                                       TIpcArgs ( &reqBuf,
+                                                  &dummyStatusPckg, 
+                                                  &dummyRetBuf ) );
+                    COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::HandleOpenDeviceResponse() - Sent set license command (%d)"), err ) );
+                    }
+                reqBuf.Close();
+                }
+            User::LeaveIfError( err );
+            }
+        }
+    COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::HandleOpenDeviceResponse() - End" ) ) );
+    }
+
+
+// --------------------------------------------------------------------------
+// Method for opening haptics device. This is needed since there's possibility
+// that no other haptics client has opened the device prior to this bridge
+// connectivity. This method also call set license key, i.e., completes the
+// device opening. 
+//
+// --------------------------------------------------------------------------
+//
+TInt RHapticsBridgeClient::OpenHapticsDevice()
+    {
+    COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::OpenHapticsDevice - Begin" ) ) );
+    TInt err( KErrGeneral );
+    if ( iPacketizer )
+        {
+        RBuf8 openDevReqBuf;
+        RBuf8 setLicenseReqBuf;
+        TBuf8<50> setLicenseRspBuf;
+        TInt dummyStatus;
+        TPckg<TInt> dummyStatusPckg( dummyStatus );
+        
+        err = iPacketizer->EncOpenDeviceReq( EHWRMLogicalActuatorAny,
+                                             openDevReqBuf );
+
+        COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::OpenHapticsDevice - EncOpenDevice (%d)" ), err ) );
+        if ( !err )
+            {
+            TInt deviceHandle;
+            TPckg<TInt> deviceHandlePckg( deviceHandle );
+            err = SendReceive( KHWRMHapticsOpenActuatorCommand,
+                               TIpcArgs ( &openDevReqBuf, 
+                                          &deviceHandlePckg,
+                                          EHWRMLogicalActuatorAny ) );
+            COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::OpenHapticsDevice - Send OpenDevice (%d)" ), err ) );
+            COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::OpenHapticsDevice - Device handle = %d" ), deviceHandle ) );
+            if ( !err )
+                {
+                err = iPacketizer->EncSetPlatformLicenseKeyReq( 
+                    deviceHandle, setLicenseReqBuf );
+                COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::OpenHapticsDevice - EncSetEmptyLicenseKey (%d)" ), err ) );    
+                if ( !err )
+                    {
+                    TBuf8<50> dummyRspBuf;
+                    TInt dummyStatus;
+                    TPckg<TInt> dummyStatusPckg( dummyStatus );
+                    err = SendReceive( KHWRMHapticsBridgeCommand, 
+                                       TIpcArgs ( &setLicenseReqBuf,
+                                                  &dummyStatusPckg, 
+                                                  &dummyRspBuf ) );
+                    COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::OpenHapticsDevice - Send SetLicense (%d)" ), err ) );
+                    }
+                }
+            }
+
+        openDevReqBuf.Close();
+        setLicenseReqBuf.Close();
+        }
+    COMPONENT_TRACE( ( _L( "RHapticsBridgeClient::OpenHapticsDevice - End (err=%d)" ),err ) );    
+    return err;
+    }
+
+// eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/hapticsconnplugin/src/hapticsconnplugin.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Haptics OBEX connection plugin.
+*
+*/
+
+
+#include "hapticsconnplugin.h"
+#include "hapticsmsghandler.h"
+#include "hapticsconntrace.h"
+
+// -----------------------------------------------------------------------------
+// CHapticsConnPlugin::NewL()
+// Two-phase constructing
+// -----------------------------------------------------------------------------
+//
+CHapticsConnPlugin* CHapticsConnPlugin::NewL()
+    {
+    COMPONENT_TRACE( ( _L( "CHapticsConnPlugin::NewL - Begin" ) ) );
+    CHapticsConnPlugin* self = new ( ELeave ) CHapticsConnPlugin();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    COMPONENT_TRACE( ( _L( "CHapticsConnPlugin::NewL - End" ) ) );
+    return( self );
+    }
+
+// -----------------------------------------------------------------------------
+// CHapticsConnPlugin::ConstructL()
+// 
+// -----------------------------------------------------------------------------
+//
+void CHapticsConnPlugin::ConstructL()
+    {
+    COMPONENT_TRACE( ( _L( "CHapticsConnPlugin::ConstructL() - Begin" ) ) );
+    iMsgHandler = CHapticsMsgHandler::NewL();
+    iMsgHandler->StartNotifier();
+    COMPONENT_TRACE( ( _L( "CHapticsConnPlugin::ConstructL() - End" )));
+    }
+
+// -----------------------------------------------------------------------------
+// CHapticsConnPlugin::~CHapticsConnPlugin()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CHapticsConnPlugin::~CHapticsConnPlugin()
+    {
+    COMPONENT_TRACE( ( _L( "CHapticsConnPlugin::~CHapticsConnPlugin() - Begin" ) ) );
+    delete iMsgHandler;
+    COMPONENT_TRACE( ( _L( "CHapticsConnPlugin::~CHapticsConnPlugin() - End" ) ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CHapticsConnPlugin::CHapticsConnPlugin()
+// Constructor
+// -----------------------------------------------------------------------------
+//
+CHapticsConnPlugin::CHapticsConnPlugin()
+    {    
+    }
+
+// -----------------------------------------------------------------------------
+// CHapticsConnPlugin::IsOBEXActive()
+//
+// -----------------------------------------------------------------------------
+//    
+TBool CHapticsConnPlugin::IsOBEXActive()   
+    {
+    COMPONENT_TRACE( ( _L( "CHapticsConnPlugin::IsOBEXActive" ) ));
+    return ETrue;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/hapticsconnplugin/src/hapticsconntimer.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Connection shutdown timer for haptics server connection.
+*
+*/
+
+
+#include "hapticsconntimer.h"
+
+const TInt KHapticsConnectionTimeout = 30000000; // 30 sec.
+
+// ---------------------------------------------------------------------------
+// Two phased constructor.
+// ---------------------------------------------------------------------------
+//
+CHapticsConnTimer* CHapticsConnTimer::NewL( MHapticsConnectionShutdown* aCallback )
+    {
+    CHapticsConnTimer* self = new ( ELeave ) CHapticsConnTimer(aCallback);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CHapticsConnTimer::~CHapticsConnTimer()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Activates this timer.
+// ---------------------------------------------------------------------------
+//
+void CHapticsConnTimer::Start()
+    {
+    After( KHapticsConnectionTimeout );
+    }
+
+// ---------------------------------------------------------------------------
+// Constructor of the shutdown timer.
+// ---------------------------------------------------------------------------
+//
+CHapticsConnTimer::CHapticsConnTimer( MHapticsConnectionShutdown* aCallback )
+    : CTimer( EPriorityStandard ), iCallback(aCallback)
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// Second phase construction.
+// ---------------------------------------------------------------------------
+//
+void CHapticsConnTimer::ConstructL()
+    {
+    CTimer::ConstructL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CHapticsConnTimer::RunL()
+    {
+    iCallback->NotifyShutdown();
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/hapticsconnplugin/src/hapticsmsghandler.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,255 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handles messaging between file system and haptics 
+*                client interface.
+*
+*/
+
+
+#include <f32file.h> 
+#include <bautils.h> 
+#include <pathinfo.h>
+#include <hwrmhaptics.h>
+
+#include "hapticsmsghandler.h"
+#include "hapticsconntimer.h"
+#include "hapticsconntrace.h"
+
+_LIT( KVibeTonzFolder,"VibeTonz\\" );
+_LIT( KSourceFileName,"VibeTonzDataReq" );
+_LIT( KTargetFileName,"VibeTonzDataRsp" );
+
+// ---------------------------------------------------------------------------
+// CHapticsMsgHandler* CHapticsMsgHandler::NewL()
+// ---------------------------------------------------------------------------
+//
+CHapticsMsgHandler* CHapticsMsgHandler::NewL()
+    {
+    CHapticsMsgHandler* self = new (ELeave) CHapticsMsgHandler();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Default C++ constructor
+// ---------------------------------------------------------------------------
+//
+CHapticsMsgHandler::CHapticsMsgHandler () : CActive( EPriorityStandard )
+    {
+    }    
+
+// ---------------------------------------------------------------------------
+// void CHapticsMsgHandler::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CHapticsMsgHandler::ConstructL()
+    {
+    COMPONENT_TRACE( ( _L( "CHapticsMsgHandler::ConstructL - Begin") ) );    
+    CActiveScheduler::Add( this );
+    ConnectToFilesystemL();
+    iConnectionTimeout = CHapticsConnTimer::NewL(this);
+    COMPONENT_TRACE( ( _L( "CHapticsMsgHandler::ConstructL - End") ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CHapticsMsgHandler::~CHapticsMsgHandler()
+// ---------------------------------------------------------------------------
+//
+CHapticsMsgHandler::~CHapticsMsgHandler()
+    {    
+    Cancel();
+
+    if ( iConnectionTimeout )
+        {
+        iConnectionTimeout->Cancel();
+        delete iConnectionTimeout;
+        }
+
+    delete iReqBuf;
+        
+    iClient.Close();
+    iFs.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// void ClearRequestFile()
+// ---------------------------------------------------------------------------
+//   
+void CHapticsMsgHandler::ClearRequestFile()
+	{
+	COMPONENT_TRACE( ( _L( "CHapticsMsgHandler::ClearRequestFile - Begin") ) );
+	
+    TFindFile findDataFile( iFs );
+    
+    TFileName sourcefile = PathInfo::PhoneMemoryRootPath();
+    sourcefile.Append( PathInfo::OthersPath() );
+    sourcefile.Append( KVibeTonzFolder );
+    sourcefile.Append( KSourceFileName );
+    
+    if( findDataFile.FindByDir( sourcefile, KNullDesC ) == KErrNone )
+    	{
+    	COMPONENT_TRACE( _L("CHapticsMsgHandler::ClearRequestFile - Deleting REQ file") );
+    	iFs.Delete( KSourceFileName ); 
+    	}
+    COMPONENT_TRACE( ( _L( "CHapticsMsgHandler::ClearRequestFile - End") ) );    	
+	}
+// ---------------------------------------------------------------------------
+// void ConnectToFilesystem()
+// ---------------------------------------------------------------------------
+//    
+void CHapticsMsgHandler::ConnectToFilesystemL()
+    {
+    COMPONENT_TRACE( ( _L( "CHapticsMsgHandler::ConnectToFilesystemL - Begin") ) );
+    User::LeaveIfError( iFs.Connect() );
+    
+    TFileName sessionPath = PathInfo::PhoneMemoryRootPath();
+    sessionPath.Append( PathInfo::OthersPath() );
+    sessionPath.Append( KVibeTonzFolder );
+    TBool folderExists = BaflUtils::FolderExists( iFs, sessionPath );
+    
+    if( folderExists )
+        {
+        User::LeaveIfError( iFs.SetSessionPath( sessionPath ) );
+        ClearRequestFile();
+        }
+    else
+        {
+        User::LeaveIfError( iFs.MkDir( sessionPath ) );
+        User::LeaveIfError( iFs.SetSessionPath( sessionPath ) );
+        }
+    COMPONENT_TRACE( ( _L( "CHapticsMsgHandler::ConnectToFilesystemL - End") ) );
+    }    
+
+// ---------------------------------------------------------------------------
+// CHapticsMsgHandler::StartNotifier()
+// ---------------------------------------------------------------------------
+//
+void CHapticsMsgHandler::StartNotifier()
+	{
+	COMPONENT_TRACE( ( _L( "CHapticsMsgHandler::StartNotifier - Begin" ) ) );
+    if ( !IsActive() )
+        {
+        TFileName sessionPath = PathInfo::PhoneMemoryRootPath();
+        sessionPath.Append( PathInfo::OthersPath() );
+        sessionPath.Append( KVibeTonzFolder );        
+        iFs.NotifyChange( ENotifyAll, iStatus, sessionPath );
+        SetActive();
+	    COMPONENT_TRACE( ( _L( "CHapticsMsgHandler::StartNotifier - Started" ) ) );        
+        }
+    COMPONENT_TRACE( ( _L( "CHapticsMsgHandler::StartNotifier - End" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CHapticsMsgHandler::RunL()
+// ---------------------------------------------------------------------------
+//
+void CHapticsMsgHandler::RunL()
+    {
+    COMPONENT_TRACE( ( _L( "CHapticsMsgHandler::RunL - Begin" ) ) );
+
+    StartNotifier(); // re-subscribe for change notifications.
+
+    TFindFile findDataFile(iFs); 
+    TFileName sourcefileName = PathInfo::PhoneMemoryRootPath();
+    sourcefileName.Append( PathInfo::OthersPath() );
+    sourcefileName.Append( KVibeTonzFolder );
+    sourcefileName.Append( KSourceFileName ); 
+          
+    if( findDataFile.FindByDir( sourcefileName, KNullDesC ) == KErrNone )
+        {
+        COMPONENT_TRACE( ( _L("CHapticsMsgHandler::RunL - found request file") ) );
+        
+        RFile sourceFile;
+		TInt sourceFileSize;
+
+		User::LeaveIfError( sourceFile.Open( iFs, sourcefileName, EFileShareAny )  );
+		CleanupClosePushL( sourceFile );
+		sourceFile.Size( sourceFileSize );
+		
+		iReqBuf = HBufC8::NewL( sourceFileSize );
+		TPtr8 reqBufPtr = iReqBuf->Des();		
+		sourceFile.Read( reqBufPtr );
+		CleanupStack::PopAndDestroy( &sourceFile );
+			
+		ClearRequestFile();
+
+        DATADUMP_TRACE( _L("CHapticsMsgHandler::RunL - request data dump:"), reqBufPtr );
+
+        if ( !iClient.Handle() )
+            {
+            User::LeaveIfError( iClient.Connect() );
+            }
+
+		TBuf8<256> retData;	
+		TInt bridgeErr = iClient.SendBridgeBuffer( reqBufPtr, retData );
+					
+	    delete iReqBuf;
+	    iReqBuf = NULL;
+	    
+		if ( bridgeErr == KErrNone )
+			{		
+            iConnectionTimeout->Cancel();
+            iConnectionTimeout->Start();
+            			
+			DATADUMP_TRACE( _L("CHapticsMsgHandler::RunL - response data dump:"), retData );
+            RFile targetFile;
+			targetFile.Replace( iFs, KTargetFileName, EFileWrite );
+			targetFile.Write( retData );
+        	targetFile.Close();
+        	}
+        }      
+    COMPONENT_TRACE( ( _L( "CHapticsMsgHandler::RunL - End" ) ) );
+    }
+
+// -----------------------------------------------------------------------------
+//
+//
+// -----------------------------------------------------------------------------
+//
+TInt CHapticsMsgHandler::RunError( TInt aError )
+    {
+    COMPONENT_TRACE( ( _L( "CHapticsMsgHandler::RunError: %d" ), aError ) );
+    return aError;
+    }
+
+// -----------------------------------------------------------------------------
+//
+//
+// -----------------------------------------------------------------------------
+//
+void CHapticsMsgHandler::DoCancel()
+    {
+    COMPONENT_TRACE( ( _L( "Inside CHapticsMsgHandler::DoCancel" ) ) );
+    if ( IsActive() )
+        {
+        iFs.NotifyChangeCancel( iStatus );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CHapticsConnPlugin::CHapticsConnPlugin()
+// Constructor
+// -----------------------------------------------------------------------------
+//
+void CHapticsMsgHandler::NotifyShutdown()
+    {
+    COMPONENT_TRACE( ( _L( "CHapticsMsgHandler::NotifyShutdown - Begin" ) ) );
+    iClient.CleanUp();
+    iClient.Close(); 
+    COMPONENT_TRACE( ( _L( "CHapticsMsgHandler::NotifyShutdown - End" ) ) );    
+    } 
+	
+// end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/hapticsconnplugin/src/proxy.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation proxy for haptics connection plugin.
+*
+*/
+
+
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+
+#include "hapticsconnplugin.h"
+
+// Map the interface UIDs to implementation factory functions
+const TImplementationProxy ImplementationTable[] = 
+	{
+		IMPLEMENTATION_PROXY_ENTRY( 0x2001FE53,	CHapticsConnPlugin::NewL )
+	};
+
+// Exported proxy for instantiation method resolution
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+	{
+	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+
+	return ImplementationTable;
+	}
+	
+// End of file
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/pcconn/bld/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  PC Connectivity Plug-in build information file.
+*
+*/
+
+
+PRJ_PLATFORMS  
+DEFAULT
+
+PRJ_MMPFILES
+sconpcconnplugin.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/pcconn/bld/def/bwinscwu.def	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/pcconn/bld/def/eabiu.def	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,5 @@
+EXPORTS
+	_Z24ImplementationGroupProxyRi @ 1 NONAME
+	_ZTI17CSConPCConnplugin @ 2 NONAME ; #<TI>#
+	_ZTV17CSConPCConnplugin @ 3 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/pcconn/bld/sconpcconnplugin.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:  PC Connectivity Plug-in MMP file
+*
+*/
+
+
+// To get the MW_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_ECOM_PLUGIN
+
+TARGET          sconpcconnplugin.dll
+TARGETTYPE      PLUGIN
+
+UID             0x10009D8D 0x101F9688
+
+SOURCEPATH     	../src
+
+SOURCE          sconpcconnplugin.cpp
+SOURCE          proxy.cpp
+SOURCE          sconpcconnpluginutils.cpp
+SOURCE          sconservicetimer.cpp
+SOURCE          sconshutdownwatcher.cpp
+
+START RESOURCE 101f9688.rss
+  TARGET        sconpcconnplugin.rsc
+END
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc 
+USERINCLUDE     ../../../clients/pcconn/inc
+USERINCLUDE     ../../../servers/pcconn/inc
+USERINCLUDE     ../../../services/ftp/inc 
+USERINCLUDE     ../../../catalogspcconnectivityplugin/inc 
+
+DEBUGLIBRARY    flogger.lib
+LIBRARY         sconpcconnclient.lib
+LIBRARY         euser.lib
+LIBRARY         irobex.lib 
+LIBRARY         ecom.lib			
+LIBRARY         efsrv.lib 
+LIBRARY         bafl.lib
+LIBRARY         catalogspcconnectivityplugin.lib
+LIBRARY         apmime.lib 
+LIBRARY         bluetooth.lib
+LIBRARY         esock.lib 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/pcconn/inc/sconpcconnplugin.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:  PC Connectivity plugin header file
+*
+*/
+
+#ifndef _SCONPCCONNPLUGIN_H
+#define _SCONPCCONNPLUGIN_H
+
+#include <obexserver.h>
+#include <SrcsInterface.h>
+#include <apmstd.h>
+
+#include "sconpcconnclient.h"
+#include "sconshutdownwatcher.h"
+
+// forward declaration
+class CSConFTP;
+class CSConServiceTimer;
+class CCatalogsPCConnectivityPlugin;
+
+
+
+class CSConPCConnplugin : public CSrcsInterface, public MObexServerNotify,
+                          public MShutdownObserver
+    {
+    public:
+        static CSConPCConnplugin* NewL();
+        virtual ~CSConPCConnplugin();
+
+        /**
+         * Returns active status of OBEX session
+         * @return ETrue if session is active, else EFalse
+         */
+        TBool IsOBEXActive();
+        
+        /**
+         * Device is shutting down, abort connection.
+         */
+        void NotifyShutdown();
+
+    private:
+        /**
+         * Loads sconftp.dll module
+         * @return none
+         */
+        void LoadFTPDllL();
+        /**
+         * Closes initialized services
+         * @return none
+         */
+        void Disconnect();
+        /**
+         * Removes spaces and nulls from the end of the string
+         * @param aDes String to be formatted
+         * @return none
+         */
+        void TrimRightSpaceAndNull( TDes8& aDes ) const;
+        /**
+         * Current used transfer media (IR,USB,BT)
+         * @param aMediaType Enumeration indicating the media type
+         * @return none
+         */
+        void SetMediaType( TSrcsMediaType aMediaType );
+        /**
+         * MObexServerNotify implementation
+         * @param aError Error code
+         * @return none
+         */
+        void ErrorIndication( TInt aError );
+        /**
+         * MObexServerNotify implementation
+         * @return none
+         */
+        void TransportUpIndication();
+        /**
+         * MObexServerNotify implementation
+         * @return none
+         */
+        void TransportDownIndication();
+        /**
+         * MObexServerNotify implementation
+         * @param aRemoteInfo Structure containing information used during OBEX
+         * connection
+         * @param aInfo Further information about the requested connection
+         * @return System wide error code that indicates the success of the connection
+         */
+        TInt ObexConnectIndication( const TObexConnectInfo& aRemoteInfo,
+                                    const TDesC8& aInfo );
+        /**
+         * MObexServerNotify implementation
+         * @param aInfo Contains information about the disconnection
+         * @return none
+         */
+        void ObexDisconnectIndication( const TDesC8& aInfo );
+        /**
+         * MObexServerNotify implementation
+         * @return CObexBaseObject-derived object, which the object being put
+         * will be parsed into.
+         */
+        CObexBufObject* PutRequestIndication();
+        /**
+         * MObexServerNotify implementation
+         * @return System wide error code that indicates the success of the
+         * PUT packet operation.
+         */
+        TInt PutPacketIndication();
+        /**
+         * MObexServerNotify implementation
+         * @return System wide error code that indicates the success of the
+         * PUT packet operation.
+         */
+        TInt PutCompleteIndication();
+        /**
+         * MObexServerNotify implementation
+         * @param aRequiredObject Details about the object the remote client
+         * has requested
+         * @returnObject to return to the client
+         */
+        CObexBufObject* GetRequestIndication( CObexBaseObject
+                                                *aRequiredObject );
+        /**
+         * MObexServerNotify implementation
+         * @return System wide error code that indicates the success of the
+         * GET packet operation.
+         */
+        TInt GetPacketIndication();
+        /**
+         * MObexServerNotify implementation
+         * @return System wide error code that indicates the success of the
+         * GET packet operation.
+         */
+        TInt GetCompleteIndication();
+        /**
+         * MObexServerNotify implementation
+         * @param aPathInfo SETPATH command parameters
+         * @param aInfo Not currently used
+         * @return System wide error code indicating the success of the
+         * setpath command.
+         */
+        TInt SetPathIndication( const CObex::TSetPathInfo& aPathInfo,
+                                const TDesC8& aInfo );
+        /**
+         * SetObexServer
+         * @param aObexServer pass obex server pointer to sevice controller
+         * @return System wide error code.
+         */
+        TInt SetObexServer( CObexServer* aObexServer );
+        /**
+         * MObexServerNotify implementation
+         * @return none
+         */
+        void AbortIndication();
+        /**
+         * Checks if mime type belongs to Catalogs
+         * @return TBool
+         */
+        TBool IsCatalogsMimeType( TDataType aMime );
+
+        void ConstructL();
+        CSConPCConnplugin();
+        
+        /**
+         * Handles PCD object. Used for advanced file handling.
+         * @param aDescriptionHeader Contains command code and destination filename
+         * @param aNameHeader Source filename
+         * @return System wide error code.
+         */
+        TInt HandlePCDObjectPut( const TDesC& aDescriptionHeader, const TDesC& aNameHeader );
+        
+        /**
+         * Get Capbility object or ConML message from PCConnServer
+         * @param aNameHeader Name information.
+         * @param aTypeHeader Object type header. ConML or Capability object type
+         * @return none
+         */
+        void HandleGetPCConnObjectL( const TDesC& aNameHeader, const TDesC8& aTypeHeader );
+        
+        /**
+         * Get Catalogs object
+         * @param aTypeHeader Object type header.
+         * @return none
+         */
+        void HandleGetCatalogsObjectL( const TDesC8& aTypeHeader );
+        
+        /**
+         * Get file object
+         * @param aNameHeader requested filename.
+         * @return none
+         */
+        void HandleGetFileObjectL( const TDesC& aNameHeader );
+        
+    private:
+        RLibrary                    iFTPlib;
+        CObexBufObject*             iObject;
+        CBufFlat*                   iBuffer;
+        CSConFTP*                   iFTPHandler;
+        TInt                        iPutError;
+        TBool                       iSessionActive;
+        CSConServiceTimer*          iServiceTimer;
+        TBool                       iStartTimer;
+        TSrcsMediaType              iMediaType;
+        CObexFileObject*            iFileObject;
+        RSConPCConnSession          iPCConnSession;
+        TBool                       iPCConnSessionConnected;
+        CCatalogsPCConnectivityPlugin*  iCatalogs;
+        TBool                           iCatalogsConnected;
+        HBufC8*                         iCatalogsMimeType;
+        RPointerArray<TDataType>        iMimeArray;
+        TBool                           iCatalogsMimeTypesExist;
+        TBool                       iPutPacketIndicationCalled;
+        CShutdownWatcher*           iShutdownWatcher;
+        TBool                       iShutdownInProgress;
+        CObexServer*                iObexServer;
+        RSocketServ                 iSocketServer;
+        RBTPhysicalLinkAdapter      iLinkAdapter;
+    private:
+        // Friend class is used,because existing impelentation has been working
+        // properly. Avoiding re-design.
+        friend class CSConServiceTimer;
+    };
+
+#endif // SCONPCCONNPLUGIN_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/pcconn/inc/sconpcconnpluginutils.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  PC Connectivity Plug-in Utils header
+*
+*/
+
+
+#ifndef _SCONPCCONNPLUGINUTILS_H
+#define _SCONPCCONNPLUGINUTILS_H
+
+#include <e32base.h>
+//============================================================
+// Class TPCConnpluginUtils declaration
+//============================================================
+class TPCConnpluginUtils
+	{
+	public:
+		/**
+		 * Converts Symbian error code to OBEX error code
+		 * @param aError The error code
+		 * @return The converted error code
+		 */
+		static TInt ConvertPCDResponseCode( TInt aError );
+		/**
+		 * Converts Symbian error code to OBEX error code
+		 * @param aError The error code
+		 * @return The converted error code
+		 */
+		static TInt ConvertFTPResponseCode( TInt aError );
+		
+		/**
+		 * Converts Symbian error code to OBEX error code
+		 * @param aError The error code
+		 * @return The converted error code
+		 */
+		static TInt ConvertObexMoveResponseCode( TInt aError );
+	};
+	
+#endif //_SCONPCCONNPLUGINUTILS_H
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/pcconn/inc/sconservicetimer.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  PC Connectivity Plug-in Service Timer Header file
+*
+*/
+
+
+#ifndef _SCONSERVICETIMER_H
+#define _SCONSERVICETIMER_H
+
+#include <e32base.h>
+
+class CSConPCConnplugin;
+
+
+//============================================================
+// Class CSConServiceTimer declaration
+//============================================================
+
+NONSHARABLE_CLASS ( CSConServiceTimer ) : public CActive
+	{
+	public:
+		CSConServiceTimer( CSConPCConnplugin* aEngine, TInt aValue );
+		void ConstructL();
+		~CSConServiceTimer();
+		
+		/**
+	 	* Starts the timer
+		* @return none
+	 	*/
+		void StartTimer();
+		/**
+		 * Stops the timer
+		 * @return none
+		 */
+		void StopTimer();
+	
+	private:
+		void DoCancel();
+		void RunL();
+		
+	private:
+		RTimer 				iTimer;
+		CSConPCConnplugin* 	iEngine;
+		TInt 				iValue;
+	};
+	
+#endif //_SCONSERVICETIMER_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/pcconn/inc/sconshutdownwatcher.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Power shutdown -watcher header file
+*
+*/
+
+
+#ifndef _SCONSHUTDOWNWATCHER_H
+#define _SCONSHUTDOWNWATCHER_H
+
+
+#include <e32base.h>
+#include <e32property.h>
+
+//============================================================
+// Class MShutdownObserver declaration
+//============================================================
+class MShutdownObserver
+    {
+public:
+    virtual void NotifyShutdown()=0;
+    };
+
+//============================================================
+// Class CShutdownWatcher declaration
+//============================================================
+NONSHARABLE_CLASS (  CShutdownWatcher ) : public CActive
+    {
+    public:
+        static CShutdownWatcher* NewL( MShutdownObserver* aObserver );
+        ~CShutdownWatcher();
+
+        /**
+         * Starts to watch shutdown status
+         * @return none
+         */
+        void StartShutdownWatcher();
+
+    private:
+        //construct/destruct
+        CShutdownWatcher( MShutdownObserver* aObserver );
+        void ConstructL();
+
+        // from CActive
+        void DoCancel();
+        void RunL();
+
+    private:
+        MShutdownObserver*   iObserver; 
+        RProperty            iProperty;
+    };
+
+#endif //_SCONSHUTDOWNWATCHER_H
+
+// End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/pcconn/src/101f9688.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  PC Connectivity Plug-in resource file
+*
+*/
+
+
+#include "ecom/registryinfo.rh"
+
+// Declares info for two implementations
+RESOURCE REGISTRY_INFO theInfo
+	{
+	// UID for the DLL
+	dll_uid = 0x101F9688;
+	// Declare array of interface info
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			// UID of interface that is implemented
+			interface_uid = 0x101F7C8C;
+			implementations = 
+				{
+				// Info for CSConPCConnplugin
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x101F9689;
+					version_no = 1;
+					display_name = "PC Suite Services";
+					default_data = "OBEX/USB||OBEX/BT||OBEX/IrDA";
+					
+					// 
+					// opaque_data contains parameters used by following API calls in SRCS:
+					// 1. Setup USB interface string descriptor in Unicode;
+					// 2. TInt CObex::SetLocalWho(const TDesC8& aInfo);
+					// 3. TInt CBTConnection::RegisterSecuritySettingsL( TUint aService,
+					//						 TInt  aProtocol,
+					//						 TInt  aChannel,
+					//						 TBool aAuthenticate,
+					//						 TBool aAuthorise,
+					//						 TBool aEncrypt );
+					// opaque_data = "@0||@1||@2||@3||@4||@5||@6"
+					// @0 aStrDesc		e.g. "PC Connectivity"
+					// @1 aInfo			e.g. KFolderBrowsingID, "\xF9\xEC\x7B\xC4\x95\x3C\x11\xd2\x98\x4E\x52\x54\x00\xDC\x9E\x09"
+					// @2 aService		e.g. KBTSecurityUidFileTransfer, 0x1106
+					// @3 aProtocol		e.g. KSolBtRFCOMM, 0x1013
+					// @4 aAuthenticate	e.g. EFalse, 0
+					// @5 aAuthorise	e.g. EFalse, 0
+					// @6 aEncrypt		e.g. EFalse, 0
+					//
+					opaque_data = "PC Suite Services||\xF9\xEC\x7B\xC4\x95\x3C\x11\xd2\x98\x4E\x52\x54\x00\xDC\x9E\x09||0x000050050000100080000002EE000001||0x1013||1||1||1||0xffff||0xffff";
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/pcconn/src/proxy.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  PC Connectivity Plug-in proxy implementation
+*
+*/
+
+
+
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+
+#include "sconpcconnplugin.h"
+
+// Map the interface UIDs to implementation factory functions
+const TImplementationProxy ImplementationTable[] = 
+	{
+		IMPLEMENTATION_PROXY_ENTRY(0x101F9689,	CSConPCConnplugin::NewL)
+	};
+
+// Exported proxy for instantiation method resolution
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+	{
+	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+
+	return ImplementationTable;
+	}
+	
+// End of file
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/pcconn/src/sconpcconnplugin.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1254 @@
+/*
+* 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:  PC Connectivity Plug-in implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <obexconstantsinternal.h>
+#endif
+#include "sconpcconnplugin.h"
+#include "sconftp.h"
+#include "sconpcconnpluginutils.h"
+#include "sconservicetimer.h"
+#include "catalogspcconnectivityplugin.h"
+#include "debug.h"
+
+
+// CONSTANTS
+_LIT(KSConFTPLibName, "sconftp.dll");
+const TInt KSConFTPUidValue = 0x10009D8D;
+const TUid KSConFTPUid = {KSConFTPUidValue};
+
+// Folder listing type from IrObex specification
+_LIT8( KSConFolderListType, "x-obex/folder-listing" );
+// Folder listing type from IrObex specification
+_LIT8( KSConCapabilityObjectType, "x-obex/capability" );
+// PCD types
+_LIT8( KSConPCDObjectType, "application/vnd.nokia.pcd" );
+_LIT8( KSConPCDXMLObjectType, "application/vnd.nokia.conml+xml" );
+_LIT8( KSConPCDWBXMLObjectType, "application/vnd.nokia.conml+wbxml" );
+_LIT8( KSConPCDXMLObjectType2, "application/vnd.nokia.pcd+xml" );
+_LIT8( KSConPCDWBXMLObjectType2, "application/vnd.nokia.pcd+wbxml" );
+_LIT( K_C_ROOT, "C:\\" );
+
+// PCD header commands
+const TInt KSCon_PCD_TAG = 0x003A;
+const TInt KSCon_PCD_CMD_COPY = 0x0037;
+const TInt KSCon_PCD_CMD_MOVE_OR_RENAME = 0x0038;
+const TInt KSCon_PCD_CMD_SET_PERMISSION = 0x0039;
+// PCD header parameters
+const TInt KSCon_PCD_PAR_FULL_PERMISSION = 0x0040;
+const TInt KSCon_PCD_PAR_READ_ONLY_PERMISSION = 0x0041;
+
+
+const TInt KSConBufSize = 262144; // 256KB
+// Time (in milliseconds) for the timer
+const TInt KSConTimeOutValue =  180000000;
+// Flags used to indicate SetPath commands
+const TInt KSConNULLSetPath =   0x00;
+
+const TInt KSConHeaderMaxLength = 256;
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::NewL()
+// Two-phase constructing
+// -----------------------------------------------------------------------------
+//
+CSConPCConnplugin* CSConPCConnplugin::NewL()
+    {
+    TRACE_FUNC_ENTRY;
+    CSConPCConnplugin* self = new ( ELeave ) CSConPCConnplugin();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    TRACE_FUNC_EXIT;
+    return( self );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::~CSConPCConnplugin()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSConPCConnplugin::~CSConPCConnplugin()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // Disconnect from services.
+    Disconnect();
+    
+    delete iBuffer;
+    iBuffer = NULL;
+    
+    if ( iServiceTimer )
+        {
+        iServiceTimer->Cancel();
+        }
+    
+    delete iServiceTimer;
+    iServiceTimer = NULL;
+    
+    delete iCatalogs;
+    iCatalogs = NULL;
+    delete iCatalogsMimeType;
+    iCatalogsMimeType = NULL;
+    
+    iMimeArray.Reset();
+    iMimeArray.Close();
+    
+    delete iShutdownWatcher;
+    iShutdownWatcher = NULL;
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::IsOBEXActive()
+// Returns active status of OBEX session
+// -----------------------------------------------------------------------------
+//
+TBool CSConPCConnplugin::IsOBEXActive()
+    {
+    TRACE_FUNC;
+    return iSessionActive;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::NotifyShutdown()
+// System is shutting down
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnplugin::NotifyShutdown()
+    {
+    TRACE_FUNC;
+    iShutdownInProgress = ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::LoadFTPDllL()
+// Loads sconftp.dll module
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnplugin::LoadFTPDllL()
+    {
+    TRACE_FUNC_ENTRY;
+    // Dynamically load DLL
+    User::LeaveIfError( iFTPlib.Load( KSConFTPLibName ) );
+    if ( iFTPlib.Type()[1] != KSConFTPUid )
+        {
+        LOGGER_WRITE( "KSConFTPUidValue incorrect" );
+        iFTPlib.Close();
+        User::Leave( KErrNotFound );
+        }
+    TSConCreateCSConFTPFunc CreateCSConFTPL =
+    (TSConCreateCSConFTPFunc)iFTPlib.Lookup(1);
+    iFTPHandler = (CSConFTP*)CreateCSConFTPL();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::Disconnect()
+// Closes initialized services
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnplugin::Disconnect()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iLinkAdapter.Close();
+    iSocketServer.Close();
+    
+    //Disconnect from server
+    iPCConnSession.Close();
+    iPCConnSessionConnected = EFalse;
+    
+    if ( iStartTimer != EFalse )
+        {
+        iServiceTimer->Cancel();
+        iServiceTimer->StartTimer();
+        }
+    
+    delete iObject;
+    iObject = NULL;
+    
+    if ( iFTPHandler )
+        {
+        delete iFTPHandler;
+        iFTPHandler = NULL;
+        iFTPlib.Close();
+        }
+    if ( iFileObject )
+        {
+        delete iFileObject;
+        iFileObject = NULL;
+        }
+    if ( iCatalogsConnected )
+        {
+        iCatalogs->Close();
+        iCatalogsConnected = EFalse;
+        iCatalogsMimeTypesExist = EFalse;
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::ErrorIndication( TInt aError )
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnplugin::ErrorIndication( TInt aError )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aError : %d", aError );
+
+    if ( iFTPHandler )
+        {
+        iFTPHandler->AbortFileTransfer( iObject );
+        }
+
+    if ( iObject )
+        {
+        delete iObject;
+        iObject = NULL;
+        }
+    
+    if ( iFileObject )
+        {
+        iFileObject->Reset();
+        delete iFileObject;
+        iFileObject = NULL;
+        }
+    
+    if ( iPCConnSessionConnected )
+        {
+        iPCConnSession.ResetServer();
+        }
+    
+    // Keep compiler happy
+    (void)aError;
+    
+    delete iShutdownWatcher;
+    iShutdownWatcher = NULL;
+    
+    if ( iLinkAdapter.IsOpen() )
+        {
+        // Cancel ActivateActiveRequester & allow going to low power mode
+        TInt err = iLinkAdapter.CancelLowPowerModeRequester();
+        LOGGER_WRITE_1( "iLinkAdapter.CancelLowPowerModeRequester() err: %d", err );
+        }
+
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::AbortIndication()
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnplugin::AbortIndication()
+    {
+    TRACE_FUNC_ENTRY;
+
+    if ( iFTPHandler )
+        {
+        iFTPHandler->AbortFileTransfer( iObject );
+        }
+
+    if ( iObject )
+        {
+        delete iObject;
+        iObject = NULL;
+        }
+    
+    if ( iFileObject )
+        {
+        iFileObject->Reset();
+        delete iFileObject;
+        iFileObject = NULL;
+        }
+    
+    if ( iPCConnSessionConnected )
+        {
+        iPCConnSession.ResetServer();
+        }
+    
+    delete iShutdownWatcher;
+    iShutdownWatcher = NULL;
+    
+    if ( iLinkAdapter.IsOpen() )
+        {
+        // Cancel ActivateActiveRequester & allow going to low power mode
+        TInt err = iLinkAdapter.CancelLowPowerModeRequester();
+        LOGGER_WRITE_1( "iLinkAdapter.CancelLowPowerModeRequester() err: %d", err );
+        }
+
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::TransportUpIndication()
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnplugin::TransportUpIndication()
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::ObexConnectIndication( const TObexConnectInfo&
+// aRemoteInfo, const TDesC8& aInfo )
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnplugin::ObexConnectIndication( const TObexConnectInfo&
+                                    /*aRemoteInfo*/, const TDesC8& /*aInfo*/ )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt err( KErrNone );
+    TInt catalogsErr( KErrNone );
+    iStartTimer = ETrue;
+    
+    if ( iMediaType == ESrcsMediaBT && iObexServer )
+        {
+        TSockAddr remoteAddr;
+        iObexServer->RemoteAddr( remoteAddr );
+        
+        TBTSockAddr btSockAddr( remoteAddr );
+        TBTDevAddr devAddr = btSockAddr.BTAddr();
+        
+        err = iSocketServer.Connect();
+        LOGGER_WRITE_1("iSocketServer.Connect err: %d", err );
+        if ( !err )
+            {
+            err = iLinkAdapter.Open( iSocketServer, devAddr );
+            LOGGER_WRITE_1("iLinkAdapter.Open err: %d", err );
+            }
+        // Ignore all BT link errors
+        err = KErrNone;
+        }
+    
+    //Connect to server
+    if ( !iPCConnSessionConnected )
+        {
+        LOGGER_WRITE("Try to connect to iPCConnSession");
+        err = iPCConnSession.Connect();
+        LOGGER_WRITE_1( "iPCConnSession.Connect returned : %d", err );
+        if ( err == KErrNone )
+            {
+            iPCConnSessionConnected = ETrue;
+            }
+        }
+    
+    if ( err == KErrNone && !iFTPHandler )
+        {
+        TRAP( err, LoadFTPDllL() );
+        LOGGER_WRITE_1( "LoadFTPDllL returned : %d", err );
+        }
+    
+    if ( err == KErrNone )
+        {
+        iFTPHandler->SetProfile( EProprietary );
+        LOGGER_WRITE( "iServiceTimer->StopTimer()" );
+        iServiceTimer->Cancel();
+        iServiceTimer->StopTimer();
+        }
+
+    if ( !iCatalogsConnected )
+        {
+        LOGGER_WRITE( "CSConPCConnplugin::ObexConnectIndication() before iCatalogs->Connect()" );
+        catalogsErr = iCatalogs->Connect();
+        LOGGER_WRITE_1( "CSConPCConnplugin::ObexConnectIndication() iCatalogs->Connect() err: %d", catalogsErr );
+        if ( catalogsErr == KErrNone )
+            {
+            LOGGER_WRITE( "CSConPCConnplugin::ObexConnectIndication() iCatalogs->Connect() success" );
+            iCatalogsConnected = ETrue;
+            TRAPD( ret, iMimeArray = iCatalogs->SupportedMimeTypesL() );
+            if ( ret == KErrNone )
+                {
+                LOGGER_WRITE_1( "iCatalogs->SupportedMimeTypesL count: %d", iMimeArray.Count() );
+                iCatalogsMimeTypesExist = ETrue;
+                }
+            }
+        }
+    TRACE_FUNC_EXIT;
+    return TPCConnpluginUtils::ConvertFTPResponseCode( err );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::ObexDisconnectIndication( const TDesC8& )
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnplugin::ObexDisconnectIndication( const TDesC8& )
+    {
+    TRACE_FUNC_ENTRY;
+    Disconnect();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::TransportDownIndication()
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnplugin::TransportDownIndication()
+    {
+    TRACE_FUNC_ENTRY;
+    Disconnect();
+    if ( iBuffer )
+        {
+        iBuffer->Reset();
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::PutRequestIndication()
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+CObexBufObject* CSConPCConnplugin::PutRequestIndication()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    TInt err( KErrNone );
+    iPutError = KErrNone;
+
+    if ( iBuffer )
+        {
+        iBuffer->Reset();
+        }
+
+    if ( iObject )
+        {
+        delete iObject;
+        iObject = NULL;
+        }
+
+    TRAP( err, iObject = CObexBufObject::NewL ( iBuffer ) );
+
+    if ( err != KErrNone )
+        {
+        return NULL;
+        }
+
+    if ( !iFTPHandler )
+        {
+        LOGGER_WRITE( "Creating iFTPHandler has failed" );
+        return NULL;
+        }
+
+    TRAP( err, ret = iFTPHandler->PutFileObjectInitL( iObject, iBuffer ) );
+
+    if ( err != KErrNone )
+        {
+        LOGGER_WRITE_1( "iFTPHandler->PutFileObjectInitL() leaves: %d", err );
+        return NULL;
+        }
+    if ( ret != KErrNone )
+        {
+        LOGGER_WRITE_1( "PutFileObjectInitL failed - returning error in next PutPacketIndication : %d", ret );
+        iPutError = ret;
+        }
+    iPutPacketIndicationCalled = EFalse;
+    
+    if ( !iShutdownWatcher )
+        {
+        TRAP( err, iShutdownWatcher = CShutdownWatcher::NewL( this ) );
+        if ( err == KErrNone )
+            {
+            iShutdownWatcher->StartShutdownWatcher();
+            }
+        else
+            {
+            LOGGER_WRITE_1( "CShutdownWatcher::NewL leaves: %d", err );
+            }
+        }
+    
+    if ( iLinkAdapter.IsOpen() )
+        {
+        // request active BT mode (high power mode)
+        err = iLinkAdapter.ActivateActiveRequester();
+        LOGGER_WRITE_1( "iLinkAdapter.ActivateActiveRequester() err: %d", err );
+        }
+    
+    TRACE_FUNC_EXIT;
+    return( iObject );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::PutPacketIndication()
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnplugin::PutPacketIndication()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+
+    TBool catalogsMime( EFalse );
+    if ( iObject->Type().Length() > KSConHeaderMaxLength )
+        {
+        LOGGER_WRITE("TypeHeader too big, return KErrNotSupported");
+        return TPCConnpluginUtils::ConvertFTPResponseCode( KErrNotSupported );
+        }
+    TBuf8<KSConHeaderMaxLength> typeHeader( iObject->Type() );
+    TrimRightSpaceAndNull( typeHeader );
+    
+    if ( iCatalogsConnected && IsCatalogsMimeType( TDataType( typeHeader ) ) )
+        {
+        catalogsMime = ETrue;
+        }
+
+    if ( (TInt)iObject->Length() > 0 
+        && typeHeader != KSConPCDWBXMLObjectType
+        && typeHeader != KSConPCDWBXMLObjectType2
+        && !catalogsMime
+        && typeHeader != KSConPCDObjectType )
+        {
+        // normal file transfer
+        if ( !iPutPacketIndicationCalled )
+            {
+            // This is first check, need to check only once
+                   
+            TFileName path;
+            iFTPHandler->GetPath( path );
+            if ( path.CompareF( K_C_ROOT ) == 0 )
+                {
+                // path forbidden
+                ret = KErrAccessDenied;
+                }
+            else
+                {
+                if ( iPutError != KErrNone )
+                    {
+                    ret = iPutError;
+                    LOGGER_WRITE_1( "CSConPCConnplugin::PutPacketIndication() : PutError : %d", iPutError );
+                    }
+                else
+                    {
+                    // check required free space
+                    // if filesize is small ( <65k ) it fits into one package and its already saved to filesystem.
+                    // if file is larger, need to check is there enought free space in device.
+                    
+                    const TUint32  filesize = iObject->Length();
+                    LOGGER_WRITE_1( "CSConPCConnplugin::PutPacketIndication() filesize %d", filesize );
+                    LOGGER_WRITE_1( "CSConPCConnplugin::PutPacketIndication() iObject->BytesReceived() %d", iObject->BytesReceived() );
+                    if ( filesize > iObject->BytesReceived() )
+                        {
+                        LOGGER_WRITE( "CSConPCConnplugin::PutPacketIndication() : check freespace" );
+                        // file does not fit into one obex packet, check is there enought free space in current drive
+                        if ( iFTPHandler->IsCurrentDiskSpaceBelowCritical( filesize ) )
+                            {
+                            LOGGER_WRITE( "CSConPCConnplugin::PutPacketIndication() : returning KErrNoMemory" );
+                            ret = KErrNoMemory;
+                            }
+                        }
+                    }
+                }
+            }
+        
+        if ( iShutdownInProgress )
+            {
+            LOGGER_WRITE( "ShutdownInProgress, abort" );
+            ret = KErrDisconnected;
+            }
+        }
+    
+    if ( !iPutPacketIndicationCalled )
+        {
+        // Need to check only once
+        iPutPacketIndicationCalled = ETrue;
+        
+        //Check if filename is too long.
+        TFileName path;
+        iFTPHandler->GetPath( path );
+        if ( ret == KErrNone && path.Length() + iObject->Name().Length() > KMaxFileName )
+            {
+            LOGGER_WRITE_1( "Name length overflow! : %d", path.Length() + iObject->Name().Length() );
+            ret = KErrBadName;
+            }
+        }
+    
+    if ( ret != KErrNone )
+        {
+        if ( iFTPHandler )
+            {
+            iFTPHandler->AbortFileTransfer( iObject );
+            }
+        
+        delete iObject;
+        iObject = NULL;
+        
+        if ( iLinkAdapter.IsOpen() )
+            {
+            // Cancel ActivateActiveRequester & allow going to low power mode
+            TInt err = iLinkAdapter.CancelLowPowerModeRequester();
+            LOGGER_WRITE_1( "iLinkAdapter.CancelLowPowerModeRequester() err: %d", err );
+            }
+        }
+    
+    LOGGER_WRITE_1( "CSConPCConnplugin::PutPacketIndication(): ret %d", ret );
+    return TPCConnpluginUtils::ConvertFTPResponseCode( ret );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::PutCompleteIndication()
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnplugin::PutCompleteIndication()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    TInt err( KErrNone );
+    
+    if ( iLinkAdapter.IsOpen() )
+        {
+        // Cancel ActivateActiveRequester & allow going to low power mode
+        TInt err2 = iLinkAdapter.CancelLowPowerModeRequester();
+        LOGGER_WRITE_1( "iLinkAdapter.CancelLowPowerModeRequester() err: %d", err2 );
+        }
+    
+    if ( iObject->Type().Length() > KSConHeaderMaxLength )
+        {
+        LOGGER_WRITE("TypeHeader too big, return KErrNotSupported");
+        delete iObject;
+        iObject = NULL;
+                
+        iFTPHandler->DeleteTempFile();
+        return TPCConnpluginUtils::ConvertPCDResponseCode( KErrNotSupported );
+        }
+    if ( iObject->Name().Length() > KSConHeaderMaxLength )
+        {
+        LOGGER_WRITE("NameHeader too big, return KErrNotSupported");
+        delete iObject;
+        iObject = NULL;
+                
+        iFTPHandler->DeleteTempFile();
+        return TPCConnpluginUtils::ConvertPCDResponseCode( KErrNotSupported );
+        }
+    
+    // check if ConML signal is received
+    TBuf8<KSConHeaderMaxLength> typeHeader( iObject->Type() );
+    TBuf<KSConHeaderMaxLength> nameHeader( iObject->Name() );
+    TrimRightSpaceAndNull( typeHeader );
+    LOGGER_WRITE8_1("type: %S", &typeHeader);
+    LOGGER_WRITE_1("name: %S", &nameHeader);
+    LOGGER_WRITE_1("description: %S", &iObject->Description());
+    TInt size = iObject->BytesReceived();
+    TTime time = iObject->Time();
+    
+    // shutdownWatcher is not needed anymore
+    delete iShutdownWatcher;
+    iShutdownWatcher = NULL;
+    
+    if ( IsCatalogsMimeType( TDataType( typeHeader ) ) )
+        {
+        if ( iCatalogsConnected )
+            {
+            LOGGER_WRITE( "iCatalogs->PutDataL" );
+            TRAP( err, iCatalogs->PutDataL( typeHeader, *iBuffer ) );
+            LOGGER_WRITE_1( "iCatalogs->PutDataL : %d", err );
+            if ( err == KErrServerTerminated )
+                {
+                err = iCatalogs->Connect();
+                LOGGER_WRITE_1( "CSConPCConnplugin::PutCompleteIndication() iCatalogs->Connect() err: %d", err );
+                if ( err == KErrNone )
+                    {
+                    LOGGER_WRITE( "iCatalogs->PutDataL" );
+                    TRAP( err, iCatalogs->PutDataL( typeHeader, *iBuffer ) );
+                    LOGGER_WRITE_1( "iCatalogs->PutDataL : %d", err );
+                    }
+                }
+            }
+        else
+            {
+            LOGGER_WRITE( "Catalogs mime type recognised - failing due no connection" );
+            err = KErrNotSupported;
+            }
+        
+        delete iObject;
+        iObject = NULL;
+        
+        iFTPHandler->DeleteTempFile();
+        return TPCConnpluginUtils::ConvertPCDResponseCode( err );
+        }
+
+    if ( typeHeader == KSConPCDObjectType )
+        {
+        LOGGER_WRITE( "CSConPCConnplugin::PutCompleteIndication KSConPCDObjectType" );
+        err = HandlePCDObjectPut( iObject->Description(), iObject->Name() );
+        delete iObject;
+        iObject = NULL;
+        
+        iFTPHandler->DeleteTempFile();
+        LOGGER_WRITE_1( "CSConPCConnplugin::PutCompleteIndication() end, err: %d", err );
+        return TPCConnpluginUtils::ConvertObexMoveResponseCode( err );
+        }
+
+    if ( typeHeader != KSConPCDWBXMLObjectType &&
+        typeHeader != KSConPCDWBXMLObjectType2 )
+        {
+        TObexHeaderMask validHdrs = iObject->ValidHeaders();
+        if ( ( validHdrs & KObexHdrBody ) || ( validHdrs & KObexHdrEndOfBody ) )
+            {
+            LOGGER_WRITE( "CSConPCConnplugin::PutCompleteIndication() normal filetransfer" );
+            LOGGER_WRITE_1( "Number of received bytes : %d", size );
+            TSConUsedMedia media( ESConNoMedia );
+            
+            switch( iMediaType )
+                {
+                case ESrcsMediaBT :
+                    media = ESConBTMedia;
+                    break;
+                case ESrcsMediaIrDA :
+                    media = ESConIRMedia;
+                    break;
+                case ESrcsMediaUSB :
+                    media = ESConUSBMedia;
+                    break;
+                default :
+                    media = ESConNoMedia;
+                    break;
+                }
+            
+            iFTPHandler->SetUsedMedia( media );
+            
+            TRAP( ret, err = iFTPHandler->PutFileObjectFinalizeL( iObject ) );
+            LOGGER_WRITE_1( "PutFileObjectL() returned : %d", ret );
+            }
+        else
+            {
+            LOGGER_WRITE( "Delete starts" );
+            TRAP( ret, err = iFTPHandler->DeleteObjectL( iObject->Name() ) );
+            LOGGER_WRITE_1( "DeleteObjectL() returned : %d", ret );
+            }
+        }
+    
+    delete iObject;
+    iObject = NULL;
+    
+    if ( typeHeader == KSConPCDWBXMLObjectType ||
+        typeHeader == KSConPCDWBXMLObjectType2 )
+        {
+        LOGGER_WRITE( "CSConPCConnplugin::PutCompleteIndication() ReadWBXMLDataL" );
+        TRAP( ret, err = iFTPHandler->ReadWBXMLDataL( iBuffer ) );
+        
+        if ( err == KErrNone && ret == KErrNone )
+            {
+            TRAP( ret, err = iPCConnSession.PutPacketL( nameHeader,
+            typeHeader, iBuffer ) );
+            LOGGER_WRITE_1( "iPCConnSession.PutPacketL() leaveCode : %d", ret );
+            LOGGER_WRITE_1( "iPCConnSession.PutPacketL() returned : %d", err );
+            }
+        
+        iFTPHandler->DeleteTempFile();
+        
+        return TPCConnpluginUtils::ConvertPCDResponseCode( err );
+        }
+    
+    iFTPHandler->DeleteTempFile();
+    
+    TRACE_FUNC_EXIT;
+    if ( ret != KErrNone )
+        {
+        return TPCConnpluginUtils::ConvertFTPResponseCode( ret );
+        }
+    return TPCConnpluginUtils::ConvertFTPResponseCode( err );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::GetRequestIndication( CObexBaseObject* aRequiredObject )
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+CObexBufObject* CSConPCConnplugin::GetRequestIndication( CObexBaseObject*
+                                                        aRequiredObject )
+    {
+    TRACE_FUNC_ENTRY;
+    CObexBufObject* bufObject(NULL);
+    if ( aRequiredObject->Type().Length() > KSConHeaderMaxLength )
+        {
+        LOGGER_WRITE("TypeHeader too big");
+        return NULL;
+        }
+    if ( aRequiredObject->Name().Length() > KMaxFileName )
+        {
+        LOGGER_WRITE("NameHeader is too long");
+        return NULL;
+        }
+    TInt ret( KErrNone );
+    TInt err( KErrNone );
+    TBuf8<KSConHeaderMaxLength> typeHeader( aRequiredObject->Type() );
+    TrimRightSpaceAndNull( typeHeader );
+    LOGGER_WRITE8_1("type: %S", &typeHeader);
+    LOGGER_WRITE_1("name: %S", &aRequiredObject->Name());
+
+    iBuffer->Reset();
+    
+    delete iObject;
+    iObject = NULL;
+    
+    TRAP( err, iObject = CObexBufObject::NewL ( iBuffer ) );
+    if ( err != KErrNone )
+        {
+        return NULL;
+        }
+    
+    // Client requests folder listing
+    if ( typeHeader == KSConFolderListType )
+        {
+        LOGGER_WRITE( "Client requests folder listning" );
+        if ( !iFTPHandler )
+            {
+            LOGGER_WRITE( "Creating iFTPHandler has failed" );
+            return NULL;
+            }
+
+        TRAP( err, ret = iFTPHandler->GetFolderObjectL( iObject ) );
+        LOGGER_WRITE_1( "iFTPHandler->GetFolderObjectL() returned: %d", ret );
+        if ( err == KErrNone && ret == KErrNone )
+            {
+            bufObject = iObject;
+            }
+        else
+            {
+            return NULL;
+            }
+        }
+    // Client requests capability object or ConML packet
+    else if ( typeHeader == KSConCapabilityObjectType
+            || typeHeader == KSConPCDWBXMLObjectType
+            || typeHeader == KSConPCDWBXMLObjectType2)
+        {
+        LOGGER_WRITE( "Client requests capability object or ConML packet" );
+        // HandleGetPCConnObjectL will set some data to iObject, or leaves if error occurs
+        TRAP( err, HandleGetPCConnObjectL( aRequiredObject->Name(), typeHeader ) );
+        
+        if ( err == KErrNone )
+            {
+            bufObject = iObject;
+            }
+        else
+            {
+            LOGGER_WRITE_1("Get PCConn object failed, err: %d", err);
+            return NULL;
+            }
+        }
+    // Client requests file conversion
+    else if ( typeHeader == KSConPCDObjectType )
+        {
+        LOGGER_WRITE("request of KSConPCDObjectType is not supported.")
+        return NULL;
+        }
+    // catalogs
+    else if ( IsCatalogsMimeType( TDataType( typeHeader ) ) )
+        {
+        TRAP( err, HandleGetCatalogsObjectL( typeHeader ) );
+        if ( err == KErrNone )
+            {
+            bufObject = iObject;
+            }
+        else
+            {
+            LOGGER_WRITE_1("Get catalogs object failed, err: %d", err);
+            return NULL;
+            }
+        }
+    // Client requests file
+    else
+        {
+        LOGGER_WRITE( "Client requests file" );
+        TRAP( err, HandleGetFileObjectL( aRequiredObject->Name() ) );
+        if ( err == KErrNone )
+            {
+            bufObject = (CObexBufObject*)iFileObject;
+            }
+        else
+            {
+            LOGGER_WRITE_1("Get file object failed, err: %d", err);
+            return NULL;
+            }
+        }
+    if ( bufObject && iLinkAdapter.IsOpen() )
+        {
+        // request active BT mode (high power mode)
+        err = iLinkAdapter.ActivateActiveRequester();
+        LOGGER_WRITE_1( "iLinkAdapter.ActivateActiveRequester() err: %d", err );
+        }
+    return bufObject;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::GetPacketIndication()
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnplugin::GetPacketIndication()
+    {
+    TRACE_FUNC;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::GetCompleteIndication()
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnplugin::GetCompleteIndication()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iLinkAdapter.IsOpen() )
+        {
+        // Cancel ActivateActiveRequester & allow going to low power mode
+        TInt err = iLinkAdapter.CancelLowPowerModeRequester();
+        LOGGER_WRITE_1( "iLinkAdapter.CancelLowPowerModeRequester() err: %d", err );
+        }
+    
+    TInt ret( KErrNone );
+    if ( iFileObject )
+        {
+        iFileObject->Reset();
+        delete iFileObject;
+        iFileObject = NULL;
+        }
+
+    LOGGER_WRITE_1( "CSConPCConnplugin::GetCompleteIndication() : returned %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::SetPathIndication( const CObex::TSetPathInfo& aPathInfo,
+// const TDesC8& aInfo )
+// MObexServerNotify implementation
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnplugin::SetPathIndication( const CObex::TSetPathInfo& aPathInfo,
+                                            const TDesC8& /*aInfo*/ )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    TInt err( KErrNone );
+    
+    if ( !iFTPHandler )
+        {
+        LOGGER_WRITE( "Creating iFTPHandler has failed" );
+        return TPCConnpluginUtils::ConvertFTPResponseCode( KErrNoMemory );
+        }
+    
+    if ( aPathInfo.iFlags == KSConNULLSetPath )
+        {
+        TRAP( err, ret = this->iFTPHandler->CreateFolderL( aPathInfo.iName ) );
+        }
+    else
+        {
+        TRAP( err, ret = this->iFTPHandler->SetPathL( aPathInfo.iName,
+        aPathInfo.iFlags ) );
+        }
+    
+    if ( err != KErrNone )
+        {
+        LOGGER_WRITE_1( "CSConPCConnplugin::SetPathIndication : returned   %d", err );
+        return TPCConnpluginUtils::ConvertFTPResponseCode( err );
+        }
+    LOGGER_WRITE_1( "CSConPCConnplugin::SetPathIndication : returned %d", ret );
+    return TPCConnpluginUtils::ConvertFTPResponseCode( ret );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::TrimRightSpaceAndNull( TDes8& aDes ) const
+// Removes spaces and nulls from the end of the string
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnplugin::TrimRightSpaceAndNull( TDes8& aDes ) const
+    {
+    TRACE_FUNC;
+    aDes.TrimRight();
+    if ( aDes.Length() > 0 )
+        {
+        if ( !aDes[aDes.Length() - 1] )
+            {
+            aDes.SetLength( aDes.Length() - 1 );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::SetMediaType( TSrcsMediaType aMediaType )
+// Current used transfer media (IR,USB,BT)
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnplugin::SetMediaType( TSrcsMediaType aMediaType )
+    {
+    TRACE_FUNC;
+    iMediaType = aMediaType;
+    }
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::TBool IsCatalogsMimeType( TDataType aMime )
+// Checks if mime type belogs to Catalogs
+// -----------------------------------------------------------------------------
+//
+TBool CSConPCConnplugin::IsCatalogsMimeType( TDataType aMime )
+    {
+    TRACE_FUNC_ENTRY;
+    TBool result = EFalse;
+
+    if ( !iCatalogsConnected
+        && aMime.Des8() != KSConPCDObjectType
+        && aMime.Des8() != KSConPCDXMLObjectType
+        && aMime.Des8() != KSConPCDWBXMLObjectType
+        && aMime.Des8() != KSConPCDXMLObjectType2
+        && aMime.Des8() != KSConPCDWBXMLObjectType2
+        )
+        {
+        // Catalogs never connected and not secon mime type
+        // Try to connect to catalogs to get catalogstypes
+        TInt catalogsErr = iCatalogs->Connect();
+        LOGGER_WRITE_1( "CSConPCConnplugin::IsCatalogsMimeType() iCatalogs->Connect() err: %d", catalogsErr );
+        if ( catalogsErr == KErrNone )
+            {
+            LOGGER_WRITE( "CSConPCConnplugin::IsCatalogsMimeType() iCatalogs->Connect() success" );
+            iCatalogsConnected = ETrue;
+            TRAPD( ret, iMimeArray = iCatalogs->SupportedMimeTypesL() );
+            if ( ret == KErrNone )
+                {
+                LOGGER_WRITE_1( "iCatalogs->SupportedMimeTypesL count: %d", iMimeArray.Count() );
+                iCatalogsMimeTypesExist = ETrue;
+                }
+            }
+        }
+
+    if ( iCatalogsMimeTypesExist )
+        {
+        // Compare to supported values
+        for ( TInt j = 0; j < iMimeArray.Count(); j++ )
+            {
+            if ( (*iMimeArray[j]) == aMime )
+                {
+                LOGGER_WRITE( "CSConPCConnplugin::IsCatalogsMimeTypeL returns TRUE" );
+                result = ETrue;
+                break;
+                }
+            }
+        }
+    TRACE_FUNC_EXIT;
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::CSConPCConnplugin()
+// Default constructor
+// -----------------------------------------------------------------------------
+//
+CSConPCConnplugin::CSConPCConnplugin()
+    {
+    TRACE_FUNC;
+    iBuffer = NULL;
+    iObject = NULL;
+    iFileObject = NULL;
+    iSessionActive = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::ConstructL()
+// Initializes member data
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnplugin::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    iBuffer = CBufFlat::NewL( KSConBufSize );
+    iObject = CObexBufObject::NewL ( iBuffer );
+    iServiceTimer = new (ELeave) CSConServiceTimer( this, KSConTimeOutValue );
+    iServiceTimer->ConstructL();
+    CActiveScheduler::Add( iServiceTimer );
+    
+    // catalogs
+    iCatalogs = CCatalogsPCConnectivityPlugin::NewL();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::SetObexServer( CObexServer* aObexServer )
+// SetObexServer
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnplugin::SetObexServer( CObexServer* aObexServer )
+    {
+    iObexServer = aObexServer;
+    TInt ret = iObexServer->Start(this);
+    LOGGER_WRITE_1( "CSConPCConnplugin::SetObexServer() ret: %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::HandlePCDObjectPut
+// Handles PCD object. Used for advanced file handling.
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnplugin::HandlePCDObjectPut( const TDesC& aDescriptionHeader,
+        const TDesC& aNameHeader )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt err( KErrNotSupported);
+    if ( aDescriptionHeader.Length() >= 3 )
+        {
+        TInt commandTag = aDescriptionHeader[0];
+        TInt commandID = aDescriptionHeader[1];
+        TInt commandParam1 = aDescriptionHeader[2];
+
+        TPtrC destination;
+        if ( aDescriptionHeader.Length() >= 3 )
+            {
+            destination.Set( aDescriptionHeader.Mid(3) );
+            }
+        TPtrC source;
+        if ( aNameHeader.Length() >= 1 )
+            {
+            // remove ":" character from beginning
+            source.Set( aNameHeader.Mid(1) );
+            }
+
+        if ( commandTag == KSCon_PCD_TAG )
+            {
+            LOGGER_WRITE( "CSConPCConnplugin::HandlePCDObjectPut KSCon_PCD_TAG found" );
+            switch (commandID)
+                {
+                case KSCon_PCD_CMD_COPY:
+                    err = iFTPHandler->CopyFile( source, destination );
+                    break;
+
+                case KSCon_PCD_CMD_MOVE_OR_RENAME:
+                    err = iFTPHandler->MoveFile( source, destination );
+                    break;
+
+                case KSCon_PCD_CMD_SET_PERMISSION:
+                    if ( commandParam1 == KSCon_PCD_PAR_FULL_PERMISSION )
+                        {
+                        err = iFTPHandler->SetReadOnly( source, EFalse );
+                        }
+                    else if ( commandParam1 == KSCon_PCD_PAR_READ_ONLY_PERMISSION )
+                        {
+                        err = iFTPHandler->SetReadOnly( source, ETrue );
+                        }
+                    else
+                        {
+                        err = KErrNotSupported;
+                        }
+                    break;
+
+                default:
+                    LOGGER_WRITE( "CSConPCConnplugin::HandlePCDObjectPut unknown commandID" );
+                    err = KErrNotSupported;
+                    break;
+                }
+
+            }
+
+        }
+    TRACE_FUNC_EXIT;
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::HandleGetPCConnObjectL
+// Get Capbility object or ConML message from PCConnServer
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnplugin::HandleGetPCConnObjectL( const TDesC& aNameHeader,
+        const TDesC8& aTypeHeader )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( !iPCConnSessionConnected )
+        {
+        LOGGER_WRITE( "ERROR, iPCConnSession was not connected" );
+        User::Leave( KErrNotReady );
+        }
+    TInt err = iPCConnSession.GetPacketL( aNameHeader, aTypeHeader, iBuffer );
+    LOGGER_WRITE_1( "iPCConnSession.GetPacketL() returned: %d", err );
+    User::LeaveIfError( err );
+    iObject->SetDataBufL( iBuffer );
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::HandleGetCatalogsObjectL
+// Get Catalogs object
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnplugin::HandleGetCatalogsObjectL( const TDesC8& aTypeHeader )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt err(KErrNone);
+    if ( !iCatalogsConnected )
+        {
+        LOGGER_WRITE( "catalogs mime type recognised - failing due to no connection" );
+        User::Leave( KErrNotReady );
+        }
+    else
+        {
+        LOGGER_WRITE( "iCatalogs->GetDataL" );
+        TDataType mime( aTypeHeader );
+        TRAP( err, iCatalogs->GetDataL( mime, *iBuffer ) );
+        LOGGER_WRITE_1( "iCatalogs->GetDataL : %d", err );
+        if ( err == KErrServerTerminated )
+            {
+            // server was terminated, try to reconnect
+            err = iCatalogs->Connect();
+            LOGGER_WRITE_1( "iCatalogs->Connect() err: %d", err );
+            User::LeaveIfError( err );
+            LOGGER_WRITE( "iCatalogs->GetDataL" );
+            iCatalogs->GetDataL( mime, *iBuffer );
+            }
+        }
+    User::LeaveIfError( err );
+    iObject->SetDataBufL( iBuffer );
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnplugin::HandleGetFileObjectL
+// Get file object
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnplugin::HandleGetFileObjectL( const TDesC& aNameHeader )
+    {
+    TRACE_FUNC_ENTRY;
+    delete iFileObject;
+    iFileObject = NULL;
+    iFileObject = CObexFileObject::NewL();
+    
+    iFileObject->Reset();
+    iFileObject->SetNameL( aNameHeader );
+
+    if ( !iFTPHandler )
+        {
+        LOGGER_WRITE( "Creating iFTPHandler has failed" );
+        User::Leave( KErrNotReady );
+        }
+
+    TInt err = iFTPHandler->GetFileObjectL( iFileObject );
+    User::LeaveIfError( err );
+    TRACE_FUNC_EXIT;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/pcconn/src/sconpcconnpluginutils.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,274 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  PC Connectivity Plug-in Utils implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include <obexconstants.h>
+#include "sconpcconnpluginutils.h"
+#include "debug.h"
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// TPCConnpluginUtils::ConvertFTPResponseCode( TInt aError )
+// Converts Symbian error code to OBEX error code
+// -----------------------------------------------------------------------------
+//
+TInt TPCConnpluginUtils::ConvertFTPResponseCode( TInt aError )
+	{
+	LOGGER_WRITE_1( "TPCConnpluginUtils::ConvertFTPResponseCode( TInt aError )\
+	 : begin, aError: %d", aError );
+	TInt obexErr ( KErrIrObexRespBadRequest );
+	switch( aError )
+		{
+		case KErrNone:
+			obexErr = KErrNone;
+			break;
+		case KErrNotFound:
+			obexErr = KErrIrObexRespNotFound;
+			break;
+		case KErrGeneral:
+		case KErrCancel:
+			obexErr = KErrIrObexRespBadRequest;
+			break;
+		case KErrNoMemory:
+			obexErr = KErrIrObexRespDatabaseFull;
+			break;
+		case KErrNotSupported:
+			obexErr = KErrIrObexRespNotImplemented;
+			break;
+		case KErrArgument:
+		case KErrTotalLossOfPrecision:
+		case KErrBadHandle:
+		case KErrOverflow:
+		case KErrUnderflow:
+		case KErrAlreadyExists:
+			obexErr = KErrIrObexRespConflict;
+			break;
+		case KErrPathNotFound:
+		case KErrDied:
+			obexErr = KErrIrObexRespNotFound;
+			break;
+		case KErrInUse:
+			obexErr = KErrIrObexRespTimedOut;
+			break;
+		case KErrServerTerminated:
+			obexErr = KErrIrObexRespNotFound;
+			break;
+		case KErrServerBusy:
+		case KErrCompletion:
+		case KErrNotReady:
+		case KErrUnknown:
+		case KErrCorrupt:
+			obexErr = KErrIrObexRespForbidden;
+			break;
+		case KErrAccessDenied:
+		case KErrLocked:
+			obexErr = KErrIrObexRespUnauthorized;
+			break;
+		case KErrWrite:
+		case KErrDisMounted:
+		case KErrEof:
+			obexErr = KErrIrObexRespForbidden;
+			break;
+		case KErrDiskFull:
+			obexErr = KErrIrObexRespDatabaseFull;
+			break;
+		case KErrBadDriver:
+		case KErrBadName:
+			obexErr = KErrIrObexRespPreCondFailed;
+			break;
+		case KErrCommsLineFail:
+		case KErrCommsFrame:
+		case KErrCommsOverrun:
+		case KErrCommsParity:
+		case KErrTimedOut:
+		case KErrCouldNotConnect:
+		case KErrCouldNotDisconnect:
+		case KErrBadLibraryEntryPoint:
+		case KErrBadDescriptor:
+		case KErrAbort:
+			obexErr = KErrIrObexRespForbidden;
+			break;
+		case KErrTooBig:
+			obexErr = KErrIrObexRespReqEntityTooLarge;
+			break;
+		case KErrDivideByZero:
+		case KErrBadPower:
+		case KErrDirFull:
+		case KErrHardwareNotAvailable:
+			obexErr = KErrIrObexRespForbidden;
+			break;
+		case KErrDisconnected: // System is shutting down
+		    obexErr = KErrIrObexRespMethodNotAllowed;
+		    break;
+		default:
+			obexErr = KErrIrObexRespBadRequest;
+			break;
+		};
+	LOGGER_WRITE_1( "TPCConnpluginUtils::ConvertFTPResponseCode( \
+	TInt aError ) returned : %d", obexErr );
+	return obexErr;
+};
+
+// -----------------------------------------------------------------------------
+// TPCConnpluginUtils::ConvertPCDResponseCode( TInt aError )
+// Converts Symbian error code to OBEX error code
+// -----------------------------------------------------------------------------
+//
+TInt TPCConnpluginUtils::ConvertPCDResponseCode( TInt aError )
+	{
+	LOGGER_WRITE_1( "TPCConnpluginUtils::ConvertPCDResponseCode( TInt \
+	aError ) : begin, aError: %d", aError );
+	
+	TInt obexErr ( KErrIrObexRespInternalError );
+	switch( aError )
+		{
+		case KErrNone:
+			obexErr = KErrNone;
+			break;
+		case KErrNotFound:
+			obexErr = KErrIrObexRespNotFound;
+			break;
+		case KErrGeneral:
+		case KErrCancel:
+			obexErr = KErrIrObexRespInternalError;
+			break;
+		case KErrNoMemory:
+			obexErr = KErrIrObexRespDatabaseFull;
+			break;
+		case KErrNotSupported:
+			obexErr = KErrIrObexRespUnsupMediaType;
+			break;
+		case KErrArgument:
+		case KErrTotalLossOfPrecision:
+		case KErrBadHandle:
+		case KErrOverflow:
+		case KErrUnderflow:
+			obexErr = KErrIrObexRespPreCondFailed;
+			break;
+		case KErrAlreadyExists:
+			obexErr = KErrIrObexRespConflict;
+			break;
+		case KErrPathNotFound:
+		case KErrDied:
+		case KErrInUse:
+			obexErr = KErrIrObexRespTimedOut;
+			break;
+		case KErrServerTerminated:
+			obexErr = KErrIrObexRespPreCondFailed;
+			break;
+		case KErrServerBusy:
+			obexErr = KErrIrObexRespConflict;
+			break;
+		case KErrCompletion:
+		case KErrNotReady:
+		case KErrUnknown:
+		case KErrCorrupt:
+			obexErr = KErrIrObexRespInternalError;
+			break;
+		case KErrAccessDenied:
+		case KErrLocked:
+			obexErr = KErrIrObexRespUnauthorized;
+			break;
+		case KErrWrite:
+		case KErrDisMounted:
+		case KErrEof:
+			obexErr = KErrIrObexRespInternalError;
+			break;
+		case KErrDiskFull:
+			obexErr = KErrIrObexRespDatabaseFull;
+			break;
+		case KErrBadDriver:
+		case KErrBadName:
+			obexErr = KErrIrObexRespNotFound;
+			break;
+		case KErrCommsLineFail:
+		case KErrCommsFrame:
+		case KErrCommsOverrun:
+		case KErrCommsParity:
+		case KErrTimedOut:
+		case KErrCouldNotConnect:
+		case KErrCouldNotDisconnect:
+		case KErrBadLibraryEntryPoint:
+		case KErrBadDescriptor:
+		case KErrAbort:
+		case KErrTooBig:
+		case KErrDivideByZero:
+		case KErrBadPower:
+		case KErrDirFull:
+		case KErrHardwareNotAvailable:
+			obexErr = KErrIrObexRespInternalError;
+			break;
+		default:
+			obexErr = KErrIrObexRespInternalError;
+			break;
+		};
+	LOGGER_WRITE_1( "TPCConnpluginUtils::ConvertPCDResponseCode(\
+	 TInt aError ) returned : %d", obexErr );
+	return obexErr;
+};
+
+// -----------------------------------------------------------------------------
+// TPCConnpluginUtils::ConvertObexMoveResponseCode( TInt aError )
+// Converts Symbian error code to OBEX error code
+// -----------------------------------------------------------------------------
+//
+TInt TPCConnpluginUtils::ConvertObexMoveResponseCode( TInt aError )
+	{
+	LOGGER_WRITE_1( "TPCConnpluginUtils::ConvertObexMoveResponseCode( TInt \
+	aError ) : begin, aError: %d", aError );
+	
+	TInt obexErr ( KErrIrObexRespInternalError );
+	switch( aError )
+		{
+		case KErrNone:
+			obexErr = KErrIrObexRespSuccess;
+			break;
+		case KErrNotFound:
+		case KErrPathNotFound:
+			obexErr = KErrIrObexRespNotFound;
+			break;
+        case KErrAccessDenied:
+            obexErr = KErrIrObexRespForbidden;
+            break;
+        case KErrNoMemory:
+        case KErrDiskFull:
+            obexErr = KErrIrObexRespDatabaseFull;
+            break;
+        case KErrInUse:
+        case KErrLocked:
+            obexErr = KErrIrObexRespConflict;
+            break;
+        case KErrNotSupported:
+            obexErr = KErrIrObexRespNotImplemented;
+            break;
+        case KErrAlreadyExists:
+            obexErr = KErrIrObexRespNotModified;
+            break;
+		
+		default:
+			obexErr = KErrIrObexRespInternalError;
+			break;
+		};
+	LOGGER_WRITE_1( "TPCConnpluginUtils::ConvertObexMoveResponseCode(\
+	 TInt aError ) returned : %d", obexErr  );
+	return obexErr;
+};
+
+//End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/pcconn/src/sconservicetimer.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,119 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  PC Connectivity Plug-in Service Timer implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "sconservicetimer.h"
+#include "sconpcconnplugin.h"
+#include "debug.h"
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSConServiceTimer::CSConServiceTimer( CSConPCConnplugin* aEngine, TInt aValue )
+// Constuctor
+// -----------------------------------------------------------------------------
+//
+CSConServiceTimer::CSConServiceTimer( CSConPCConnplugin* aEngine, TInt aValue )
+	: CActive( EPriorityStandard ), iEngine( aEngine ), iValue( aValue ) {}
+
+// -----------------------------------------------------------------------------
+// CSConServiceTimer::ConstructL()
+// Initializes member data
+// -----------------------------------------------------------------------------
+//
+void CSConServiceTimer::ConstructL()
+	{
+	LOGGER_ENTERFN( "CSConServiceTimer::ConstructL()" );
+	// create a thread-relative timer
+	User::LeaveIfError( iTimer.CreateLocal() );
+	LOGGER_LEAVEFN( "CSConServiceTimer::ConstructL()" );
+	}
+
+// -----------------------------------------------------------------------------
+// CSConServiceTimer::~CSConServiceTimer()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSConServiceTimer::~CSConServiceTimer()
+	{
+	LOGGER_ENTERFN( "CSConServiceTimer::~CSConServiceTimer()" );
+	iTimer.Close();
+	LOGGER_LEAVEFN( "CSConServiceTimer::~CSConServiceTimer()" );	
+	}
+
+// -----------------------------------------------------------------------------
+// CSConServiceTimer::~CSConServiceTimer()
+// Starts the timer
+// -----------------------------------------------------------------------------
+//
+void CSConServiceTimer::StartTimer()
+	{
+	LOGGER_ENTERFN( "CSConServiceTimer::StartTimer()" );
+	if( !IsActive() )
+		{
+		LOGGER_WRITE( "CSConServiceTimer::StartTimer() : !IsActive()" );
+		iTimer.After( iStatus, TTimeIntervalMicroSeconds32( iValue ) );
+		iEngine->iSessionActive = ETrue;
+		SetActive();
+		LOGGER_WRITE( "CSConServiceTimer::StartTimer() : SetActive()" );
+		}
+	LOGGER_LEAVEFN( "CSConServiceTimer::StartTimer()" );
+	}
+
+// -----------------------------------------------------------------------------
+// CSConServiceTimer::StopTimer()
+// StopTimer()
+// -----------------------------------------------------------------------------
+//
+void CSConServiceTimer::StopTimer()
+	{
+	LOGGER_ENTERFN( "CSConServiceTimer::StopTimer()" );
+	iEngine->iSessionActive = ETrue;	
+	LOGGER_WRITE( "CSConServiceTimer::StopTimer() : iSessionActive = ETrue" );
+	LOGGER_LEAVEFN( "CSConServiceTimer::StopTimer()" );	
+	}
+
+// -----------------------------------------------------------------------------
+// CSConServiceTimer::DoCancel()
+// Cancels the timer
+// -----------------------------------------------------------------------------
+//
+void CSConServiceTimer::DoCancel()
+	{
+	LOGGER_ENTERFN( "CSConServiceTimer::DoCancel()" );
+	iTimer.Cancel();
+	LOGGER_LEAVEFN( "CSConServiceTimer::DoCancel()" );
+	}
+
+// -----------------------------------------------------------------------------
+// CSConServiceTimer::RunL()
+// Executed when timer is triggered
+// -----------------------------------------------------------------------------
+//
+void CSConServiceTimer::RunL()
+	{
+	LOGGER_ENTERFN( "CSConServiceTimer::RunL()" );
+	iEngine->iSessionActive = EFalse;
+	LOGGER_WRITE( "CSConServiceTimer::RunL() : iSessionActive = EFalse" );
+	iEngine->iStartTimer = EFalse;
+	LOGGER_WRITE( "CSConServiceTimer::RunL() : iStartTimer = EFalse " );
+	LOGGER_LEAVEFN( "CSConServiceTimer::RunL()" );
+	}
+	
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/pcconn/src/sconshutdownwatcher.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,153 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Power shutdown -watcher implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "sconshutdownwatcher.h"
+#include "debug.h"
+
+#include <startupdomainpskeys.h>
+
+
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CShutdownWatcher::NewL( MShutdownObserver* aObserver )
+// Two-phase constructor
+// -----------------------------------------------------------------------------
+//
+CShutdownWatcher* CShutdownWatcher::NewL( MShutdownObserver* aObserver )
+    {
+    LOGGER_ENTERFN( "CShutdownWatcher::NewL()" );
+    CShutdownWatcher* self = new (ELeave) CShutdownWatcher( aObserver );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    LOGGER_LEAVEFN( "CShutdownWatcher::NewL()" );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CShutdownWatcher::~CShutdownWatcher()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CShutdownWatcher::~CShutdownWatcher()
+    {
+    LOGGER_ENTERFN( "CShutdownWatcher::~CShutdownWatcher()" );
+    Cancel();
+    iProperty.Close();
+    LOGGER_LEAVEFN( "CShutdownWatcher::~CShutdownWatcher()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CShutdownWatcher::StartShutdownWatcher()
+// Starts to watch shutdown status
+// -----------------------------------------------------------------------------
+//
+void CShutdownWatcher::StartShutdownWatcher()
+    {
+    LOGGER_ENTERFN( "CShutdownWatcher::StartShutdownWatcher()" );
+    TInt status;
+    TInt err = iProperty.Get( KPSUidStartup, KPSGlobalSystemState, status );
+    LOGGER_WRITE_2( "CShutdownWatcher::StartShutdownWatcher() :\
+     err %d, KPSGlobalSystemState status %d",err, status);
+    if ( err == KErrNone )
+        {
+        if ( status == ESwStateShuttingDown )
+            {
+            LOGGER_WRITE( "Call NotifyShutdown" );
+            iObserver->NotifyShutdown();
+            return;
+            }
+        }
+    
+    err = iProperty.Attach( KPSUidStartup, KPSGlobalSystemState );
+    LOGGER_WRITE_1( "CShutdownWatcher::StartShutdownWatcher() :\
+     iProperty.Attach( KPSUidStartup, KPSGlobalSystemState ) : err %d", err );
+    iProperty.Subscribe( iStatus );
+    LOGGER_WRITE( "CShutdownWatcher::StartShutdownWatcher() :\
+     iProperty.Subscribe( iStatus ) : ok" );
+    SetActive();
+
+    LOGGER_LEAVEFN( "CShutdownWatcher::StartShutdownWatcher()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CShutdownWatcher::DoCancel()
+// Executed when CActive is canceled.
+// -----------------------------------------------------------------------------
+//
+void CShutdownWatcher::DoCancel()
+    {
+    LOGGER_ENTERFN( "CShutdownWatcher::DoCancel()" );
+    iProperty.Cancel();
+    LOGGER_LEAVEFN( "CShutdownWatcher::DoCancel()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CShutdownWatcher::RunL()
+// Executed when disk watcher is triggered
+// -----------------------------------------------------------------------------
+//
+void CShutdownWatcher::RunL()
+    {
+    LOGGER_ENTERFN( "CShutdownWatcher::RunL()" );
+    TInt status;
+    iProperty.Get( status );
+    LOGGER_WRITE_1( "CShutdownWatcher::RunL() : status %d", status );
+    
+    if ( status == ESwStateShuttingDown )
+        {
+        LOGGER_WRITE( "Call NotifyShutdown" );
+        iObserver->NotifyShutdown();
+        return;
+        }
+    
+    iProperty.Cancel();
+    iProperty.Close();
+    
+    LOGGER_LEAVEFN( "CShutdownWatcher::RunL()" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CShutdownWatcher::CShutdownWatcher( MShutdownObserver* aObserver )
+// Default constructor
+// -----------------------------------------------------------------------------
+//
+CShutdownWatcher::CShutdownWatcher( MShutdownObserver* aObserver )
+: CActive(EPriorityStandard),
+    iObserver(aObserver)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CShutdownWatcher::ConstructL()
+// Initializes member data
+// -----------------------------------------------------------------------------
+//
+void CShutdownWatcher::ConstructL()
+    {
+    LOGGER_ENTERFN( "CShutdownWatcher::ConstructL()" );
+    CActiveScheduler::Add(this);
+    LOGGER_LEAVEFN( "CShutdownWatcher::ConstructL()" );
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/rom/cntparser.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Image description file for Contact Parser Client and Server.
+*
+*/
+
+
+file=ABI_DIR\BUILD_DIR\cntparserserverexe.exe   PROGRAMS_DIR\cntparserserverexe.exe
+file=ABI_DIR\BUILD_DIR\cntparserserver.dll      SHARED_LIB_DIR\cntparserserver.dll
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/rom/sconcsc.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -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:  Image description file for project SConCSC
+*
+*/
+
+
+#ifndef __SCONCSC_IBY__
+#define __SCONCSC_IBY__
+//file content
+
+file=ABI_DIR\BUILD_DIR\sconcsc.dll              SHARED_LIB_DIR\sconcsc.dll
+data=ZPRIVATE\101F99F6\capability\101F9698.xml  PRIVATE\101F99F6\capability\101F9698.xml
+data=ZPRIVATE\101F99F6\capability\fwdcomp.xml   PRIVATE\101F99F6\capability\fwdcomp.xml
+data=ZPRIVATE\101F99F6\capability\101F99F6.xml  PRIVATE\101F99F6\capability\101F99F6.xml
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/rom/sconftp.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Image description file for CSConFTP
+*
+*/
+
+
+#ifndef __SCONFTP_IBY__
+#define __SCONFTP_IBY__
+//file content
+
+file=ABI_DIR\BUILD_DIR\sconftp.dll              SHARED_LIB_DIR\sconftp.dll
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/rom/sconftpplugin.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Image description file for FTPplugin
+*
+*/
+
+
+#ifndef __SCONFTP_PLUGIN_IBY__
+#define __SCONFTP_PLUGIN_IBY__
+//file content
+
+ECOM_PLUGIN(sconftpplugin.dll,101F9686.RSC)
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/rom/sconftpresources.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Image description file for SConFTP resources.
+*
+*/
+
+#ifndef __SCONFTP_RESOURCE_IBY__
+#define __SCONFTP_RESOURCE_IBY__
+
+data=DATAZ_\RESOURCE_FILES_DIR\sconftp.rsc	RESOURCE_FILES_DIR\sconftp.rsc
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/rom/sconpcconnclientserver.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Image description file for project PCCONNClientServer
+*
+*/
+
+
+#ifndef __SCONPCCONNCLIENTSERVER_IBY__
+#define __SCONPCCONNCLIENTSERVER_IBY__
+//file content
+
+file=ABI_DIR\BUILD_DIR\sconconmlhandler.dll		SHARED_LIB_DIR\sconconmlhandler.dll
+
+file=ABI_DIR\BUILD_DIR\sconpcconnserver.exe		PROGRAMS_DIR\sconpcconnserver.exe
+file=ABI_DIR\BUILD_DIR\sconpcconnclient.dll		SHARED_LIB_DIR\sconpcconnclient.dll
+
+// stub files
+data=ZSYSTEM\install\secon_stub.sis             system\install\secon_stub.sis
+data=ZSYSTEM\install\sconpcconnplugin_stub.sis  system\install\sconpcconnplugin_stub.sis
+data=ZSYSTEM\install\sconftpplugin_stub.sis     system\install\sconftpplugin_stub.sis
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/rom/sconpcconnplugin.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Image description file for PC Connectivity Plug-in.
+*
+*/
+#ifndef __SCONPCCONN_PLUGIN_IBY__
+#define __SCONPCCONN_PLUGIN_IBY__
+//file content
+
+ECOM_PLUGIN(sconpcconnplugin.dll,101F9688.RSC)
+
+file=ABI_DIR\BUILD_DIR\catalogspcconnectivityplugin.dll              SHARED_LIB_DIR\catalogspcconnectivityplugin.dll
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/rom/sconpcd.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Image description file for SConPCD.
+*
+*/
+#ifndef __SCONPCD_IBY__
+#define __SCONPCD_IBY__
+//file content
+
+file=ABI_DIR\BUILD_DIR\sconpcd.dll		system\libs\sconpcd.dll
+
+data=ZPRIVATE\10202D56\sbeconfig.xml	PRIVATE\10202D56\sbeconfig.xml
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/pcconn/bld/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -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:  Build information file for project PCConnServer
+*
+*/
+
+
+PRJ_EXPORTS
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+sconpcconnserver.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/pcconn/bld/sconpcconnserver.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,61 @@
+/*
+* 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:  PC Connectivity Server
+*
+*/
+
+
+// To get the MW_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_SERVER TrustedUI
+
+TARGET          sconpcconnserver.exe
+TARGETTYPE      exe
+
+EPOCSTACKSIZE   49152
+EPOCHEAPSIZE    0x10000 0x800000
+
+UID             0 0x101F99F6
+
+// Server
+SOURCEPATH      ../src
+SOURCE          sconpcconnserver.cpp
+
+// ConML
+SOURCEPATH      ../../../wbxml/conmlhandler/src
+SOURCE          sconconmldtd.cpp
+SOURCE          sconxmlelement.cpp
+
+SOURCEPATH      ../../../common/conmltask/src
+SOURCE          sconconmltask.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc
+USERINCLUDE     ../../../common/conmltask/inc
+USERINCLUDE     ../../../services/pcd/inc 
+USERINCLUDE     ../../../services/csc/inc
+USERINCLUDE     ../../../wbxml/conmlhandler/inc
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         estor.lib       // RMemWriteStream, RMemReadStream
+LIBRARY         efsrv.lib       // Rfs, RFile
+LIBRARY         charconv.lib    // For Unicode conversion
+DEBUGLIBRARY    flogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/pcconn/inc/sconpcconnclientserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  PC Connectivity server client
+*
+*/
+
+
+
+
+#ifndef __SCONPCCONNCLIENTSERVER_H__
+#define __SCONPCCONNCLIENTSERVER_H__
+
+#include <e32base.h>
+
+// for debugging ConML messages and capability objects 
+//#define DEBUG_XML
+
+
+// reasons for server panic
+enum TPCConnServPanic
+	{
+	E_BadRequest = 1,
+	E_DispatchRequest,
+	E_InvalidClient,
+	E_CleanupCreate,
+	E_MainSchedulerError
+	};
+	
+	
+// server related constants
+_LIT( KSConPCConnServerName,"SConPCConnServer" );
+_LIT( KSConPCConnServerExe, "SConPCConnServer.exe" );
+
+// client 
+_LIT( KSConPCConnClientDll, "SConPCConnClient.dll" );
+
+
+// Chunk
+const TUint KSConPCConnChunkSize = 128;
+const TUint KSConPCConnChunkMaxSize = 65536;
+const TUint KSConPCConnBufferMaxSize = 65000; 
+
+// Version number
+const TUint KSConPCConnServerVersionMajor = 1;
+const TUint KSConPCConnServerVersionMinor = 0;
+const TUint KSConPCConnServerVersionBuild = 1;
+
+
+// Function codes
+
+enum TRequest 
+{
+	EPutMessage,
+	EGetMessage,
+	EResetMessage,
+	EChunkMessage
+};
+
+#endif // __SCONPCCONNCLIENTSERVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/pcconn/inc/sconpcconnserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,237 @@
+/*
+* 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:  PC Connectivity server
+*
+*/
+
+
+#ifndef __SCONPCCONNSERVER_H__
+#define __SCONPCCONNSERVER_H__
+
+#include "sconconmlhandler.h"
+#include "sconconmltask.h"
+
+
+class CSConPCD;
+class CSConCSC;
+class CSConConMLParser;
+
+const TUint KSConDefaultHeapSize=0x10000;
+const TInt KSConFirstDrive = 65;
+
+_LIT8 ( KParamNameSilent, "Silent" );
+
+
+// PCD Handler Dll
+_LIT(KSConPCDLibName, "sconpcd.dll");
+const TInt KSConPCDUidValue = 0x10009D8D;
+const TUid KSConPCDUid = {KSConPCDUidValue};
+
+// CSC Handler Dll
+_LIT(KSConCSCLibName, "sconcsc.dll");
+const TInt KSConCSCUidValue = 0x10009D8D;
+const TUid KSConCSCUid = {KSConCSCUidValue};
+
+// ConML Handler Dll
+_LIT (KSConConMLHandlerLibName, "sconconmlhandler.dll");
+const TInt KSConConMLHandlerUidValue = 0x10009D8D;
+const TUid KSConConMLHandlerUid = {KSConConMLHandlerUidValue};
+
+// debug file for put and get messages
+_LIT ( KSConConMLDebugFile, "c:\\data\\handler_result.txt");
+
+// Secure ids
+_LIT_SECURE_ID(KSConPCConnClientSecureId,0x101F7C87);
+
+// PCD types
+_LIT8( KSConPCDXMLObjectType, "application/vnd.nokia.conml+xml" );
+_LIT8( KSConPCDXMLObjectType2, "application/vnd.nokia.pcd+xml" );
+_LIT8( KSConPCDWBXMLObjectType, "application/vnd.nokia.conml+wbxml" );
+_LIT8( KSConPCDWBXMLObjectType2, "application/vnd.nokia.pcd+wbxml" );
+
+// CSC types
+_LIT8( KSConCapabilityObjectType, "x-obex/capability" );
+
+// Drives
+_LIT( KSConNoDrive, "\x0" );
+_LIT( KSConDriveExists, "\x1" );
+
+// user permissions
+_LIT8( KSConPermReadOnly, "R" );
+_LIT8( KSConPermNormal, "RW" );
+// Java hash id for ConML
+_LIT8( KSConJavaHashId, "JAVA_");
+
+_LIT8( KSConAppInfoSeparator, "#" );
+
+//**********************************
+//CSConPCConnServer - PC Connectivity Server 
+//**********************************
+
+class CSConPCConnServer : public CServer2
+    {
+public:
+        // From CServer2
+    IMPORT_C static CSConPCConnServer* NewLC();
+    IMPORT_C ~CSConPCConnServer();
+    
+    /**
+     * Function to start the server
+     * @param none
+     * @return Error code
+     */
+    static TInt RunServer();
+    
+    /**
+     * Function to start the server
+     * @param none
+     * @return none
+     */
+    static void RunServerL();
+    
+    /**
+     * Increments session count.
+     * @param none
+     * @return none
+     */
+    void IncSessionCount();
+    
+    /**
+     * Decrements session count. 
+     * When count reaches zero, stops active scheduler
+     * @param none
+     * @return none
+     */ 
+    void DecSessionCount();
+    
+
+protected:
+    virtual CSession2* NewSessionL( const TVersion &aVersion, 
+                                    const RMessage2& aMessage) const;
+
+private:
+    CSConPCConnServer();
+    
+    TInt iSessionCount;
+
+    };
+
+//**********************************
+//CSConPCConnSession - Server session class, handles the requested operations
+//**********************************
+class CSConPCConnSession : public CSession2, public MWBXMLConMLCallback
+    {
+
+public:
+    static CSConPCConnSession* NewL(CSConPCConnServer& aServer);
+    
+    /**
+    * From CSession2
+    */
+    void ServiceL( const RMessage2 &aMessage);
+
+private:
+    void DispatchRequestL( const RMessage2 &aMessage);
+    void LoadPCDDllL();
+    void LoadCSCDllL();
+    void LoadConMLHandlerDllL();
+
+protected:
+    // Callback funktion for WBXML parsing
+    void ConMLL ( ConML_ConMLPtr_t aContent );
+
+private:
+    void ConstructL();
+    CSConPCConnSession ( CSConPCConnServer& aServer);
+    ~CSConPCConnSession();
+
+    TInt HandlePutMessageL();
+    TInt HandleGetMessageL();
+    TInt HandleWBXMLGetRequestL( const TDesC& aFileName );
+    TInt HandleResetMessage();
+    TInt HandleChunkMessage( const RMessage2& aMessage );
+    TInt OptionsFromExecuteL ( ConML_ExecutePtr_t aContent );
+    TInt TaskCancelL(ConML_CancelPtr_t aContent);
+    TInt TaskGetStatusL(ConML_GetStatusPtr_t aContent );
+    TInt TaskInstallL( ConML_InstallPtr_t aContent );
+    TInt TaskUnInstallL( ConML_UnInstallPtr_t aContent );
+    void SplitL( const TDesC8& aText, const TChar aSeparator, RArray<TPtrC8>& aArray );
+    TInt TaskListInstalledAppsL( ConML_ListInstalledAppsPtr_t aContent );
+    TInt TaskListDataOwnersL();
+    TInt TaskSetBURModeL( ConML_SetBURModePtr_t aContent );
+    TInt TaskGetDataSizeL( ConML_GetDataSizePtr_t aContent );
+    TInt TaskRequestDataL( ConML_RequestDataPtr_t aContent );
+    TInt TaskUpdateDeviceInfoL( ConML_UpdateDeviceInfoPtr_t aContent );
+    TInt TaskListPublicFilesL( ConML_ListPublicFilesPtr_t aContent );
+    TInt TaskGetDataOwnerStatusL( ConML_GetDataOwnerStatusPtr_t aContent );
+    TInt TaskSupplyDataL ( ConML_SupplyDataPtr_t aContent );
+    TInt TaskRebootL();
+    TInt TaskGetMetadataL( ConML_GetMetadataPtr_t aContent );
+    void AppendStatusL( ConML_ConMLPtr_t aContent, CSConStatusReply* reply );
+    void AppendUpdateDeviceInfoResultsL( ConML_ResultsPtr_t aContent, 
+                                         CSConUpdateDeviceInfo* aResult );
+    void AppendSetBURModeResultsL ( ConML_ResultsPtr_t aContent, 
+                                    CSConSetBURMode* aResult );
+    void AppendListInstalledAppsResultsL ( ConML_ResultsPtr_t aContent, 
+                                           CSConListInstApps* aResult );
+    void AppendListPublicFilesResultsL ( ConML_ResultsPtr_t aContent, 
+                                         CSConListPublicFiles* aResult );
+    void AppendRequestDataResultsL( ConML_ResultsPtr_t aContent, 
+                                    CSConRequestData* aResult );
+    void AppendSupplyDataResultsL( ConML_ResultsPtr_t aContent, 
+                                   CSConSupplyData* aResult );
+    void AppendInstallResultsL( ConML_ResultsPtr_t aContent, 
+                                CSConInstall* aResult );
+    void AppendUninstallResultsL( ConML_ResultsPtr_t aContent, 
+                                CSConUninstall* aResult );                          
+    void AppendListDataOwnersResultsL ( ConML_ResultsPtr_t aContent, 
+                                        CSConListDataOwners* aResult  );
+    void AppendGetDataOwnerStatusResultsL ( ConML_ResultsPtr_t aContent, 
+                                            CSConGetDataOwnerStatus* aResult );
+    void AppendGetDataSizeResultsL ( ConML_ResultsPtr_t aContent, 
+                                     CSConGetDataSize* aResult );
+    void AppendGetMetadataResultsL ( ConML_ResultsPtr_t aContent, 
+                                     CSConGetMetadata* aResult );
+    void AppendProgressL ( ConML_ResultsPtr_t aContent, TInt progress );
+    void AppendDrivesL( ConML_DrivesPtr_t aContent, TDriveList aDrives );
+    TDriveList DriveList( ConML_DriveListPtr_t aContent );
+    TDesC8& IntToDesLC( const TInt& anInt);
+    TDesC8& DriveNumToDesLC( const TInt& anInt );
+    TDesC8& BufToDesLC( const TDesC& aBuf );
+    TDesC8& UidToDesLC( const TUid& aUid );
+    TUid DesToUid ( const TDesC8& aDes );
+    TInt DesToInt( const TDesC8& aDes);
+    TBool HasDrives( TDriveList& aDrive );
+    TDesC8& HashToDesLC( const TDesC& aBuf );
+    TPtr DesToHashLC( const TDesC8& aDes );
+    TBool IsJavaHash( const TDesC8& aDes );
+        
+// data
+private:
+    CSConPCConnServer& iServer;
+    
+    RLibrary iPCDlib;
+    RLibrary iCSClib;
+    RLibrary iConMLHandlerLib;
+    
+    CSConPCD* iPCDHandler;
+    CSConCSC* iCSCHandler;
+    CSConConMLHandler* iConMLHandler;
+    
+    RChunk iChunk;
+    CBufFlat* iBuffer;  
+    TInt iResult;
+    };
+
+#endif // __SCONPCCONNSERVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/pcconn/src/sconpcconnserver.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,2725 @@
+/*
+* 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:  PC Connectivity server
+*
+*/
+
+
+#include <s32mem.h> // For RMemReadStream
+#include <utf.h>
+
+#include "sconpcconnclientserver.h"
+#include "sconpcconnserver.h"
+#include "sconpcd.h"
+#include "sconcsc.h"
+#include "sconconmlhandler.h"
+#include "debug.h"
+
+#ifdef DEBUG_XML
+#include <s32file.h>
+_LIT8( KTimeFormat, "%02d:%02d:%02d.%03d" );
+_LIT8( KXmlBegin, "\nXML:\n" );
+#endif
+
+_LIT( KSCONGetMetadataRequest, "METADATA:" );
+
+//------------------------------------------------------------
+// Global functions 
+//------------------------------------------------------------
+
+// -----------------------------------------------------------------------------
+// E32Main()
+// Entry point 
+// -----------------------------------------------------------------------------
+//
+TInt E32Main()
+    {
+    TRACE_FUNC_ENTRY;
+    __UHEAP_MARK;
+    TInt error( KErrNone );
+    error = CSConPCConnServer::RunServer();
+    __UHEAP_MARKEND;
+    TRACE_FUNC_EXIT;
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// PanicServer()
+// Panics the server with panic reason aPanic 
+// -----------------------------------------------------------------------------
+//
+GLDEF_C void PanicServer(TPCConnServPanic aPanic)
+    {
+    LOGGER_WRITE_1( "CSConPCConnSession::PanicServer() : Panic code  %d", aPanic );  
+    _LIT(KTxtServerPanic,"PCConn server panic");
+    User::Panic(KTxtServerPanic,aPanic);
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnServer::CSConPCConnServer ()
+// Default constructor - can not leave
+// -----------------------------------------------------------------------------
+//
+CSConPCConnServer::CSConPCConnServer () : CServer2( EPriorityStandard)
+    {
+    LOGGER_WRITE( "* * * *  CSConPCConnServer  * * * *" );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnServer::~CSConPCConnServer()
+// Default destructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSConPCConnServer::~CSConPCConnServer()
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnServer::NewLC()
+// Creates a new instance of CSConPCConnServer
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSConPCConnServer*  CSConPCConnServer::NewLC()
+    {
+    TRACE_FUNC_ENTRY;
+    CSConPCConnServer* self  = new (ELeave) CSConPCConnServer();
+    CleanupStack::PushL( self );
+    self->StartL( KSConPCConnServerName );
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnServer::NewSessionL()
+// Creates a new session to the client
+// -----------------------------------------------------------------------------
+//
+CSession2* CSConPCConnServer::NewSessionL( 
+    const TVersion &aVersion, const RMessage2& /*aMessage*/ ) const
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // check version
+    TVersion version( KSConPCConnServerVersionMajor, 
+                                  KSConPCConnServerVersionMinor, 
+                                  KSConPCConnServerVersionBuild);
+    
+    if (!User::QueryVersionSupported(version, aVersion))
+        {
+        User::Leave(KErrNotSupported);
+        }
+    
+    // check client identity
+    RThread client;
+    Message().Client( client );
+    TSecureId clientId = client.SecureId();
+    
+    if ( clientId != KSConPCConnClientSecureId )
+        {
+        LOGGER_WRITE( "CSConPCConnServer::NewSessionL() : Secure ID does not match" );
+        User::Leave( KErrAccessDenied );
+        }
+    
+    TRACE_FUNC_EXIT;
+    return CSConPCConnSession::NewL( *CONST_CAST( CSConPCConnServer*, this));
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnServer::RunServer()
+// Starts the server
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnServer::RunServer()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    TInt ret = KErrNoMemory;
+    if( cleanup )
+        {
+        TRAP( ret, CSConPCConnServer::RunServerL(  ) );
+        delete cleanup;
+        }
+    if( ret != KErrNone )
+        {
+        // Signal the client that server creation failed
+        RProcess::Rendezvous( ret );
+        }
+    TRACE_FUNC_EXIT;
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnServer::RunServerL()
+// Starts the server
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnServer::RunServerL()
+    {
+    // Create and install the active scheduler we need
+    TRACE_FUNC_ENTRY;
+    CActiveScheduler *as=new (ELeave)CActiveScheduler;
+    CleanupStack::PushL( as );
+    CActiveScheduler::Install( as );
+
+    // Create server
+    CSConPCConnServer* server = CSConPCConnServer::NewLC();
+
+    // Initialisation complete, now signal the client
+    User::LeaveIfError( RThread().RenameMe( KSConPCConnServerName ) );
+    RProcess::Rendezvous( KErrNone );
+
+    // Ready to run
+    CActiveScheduler::Start();
+    
+    // Cleanup the scheduler
+    CleanupStack::PopAndDestroy( 2, as );
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnServer::IncSessionCount()
+// Increments session count
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnServer::IncSessionCount()
+    {
+    TRACE_FUNC_ENTRY;
+    iSessionCount++;
+    LOGGER_WRITE_1( "There are now %d sessions", iSessionCount );
+    TRACE_FUNC_EXIT;
+    }    
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnServer::DecSessionCount()
+// Decrements session count
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnServer::DecSessionCount()
+    {
+    TRACE_FUNC_ENTRY;
+    iSessionCount--;
+    LOGGER_WRITE_1( "There are still %d sessions", iSessionCount );
+    if ( iSessionCount < 1 )
+        {
+        Cancel();
+        CActiveScheduler::Stop();   
+        }
+    TRACE_FUNC_EXIT;
+    } 
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::CSConPCConnSession()
+// Default constructor 
+// -----------------------------------------------------------------------------
+//
+CSConPCConnSession::CSConPCConnSession (
+     CSConPCConnServer& aServer ) : iServer (aServer)
+    {
+    TRACE_FUNC_ENTRY;
+    iServer.IncSessionCount();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::CSConPCConnSession()
+// Default destructor - frees resources
+// -----------------------------------------------------------------------------
+//
+CSConPCConnSession::~CSConPCConnSession()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iServer.DecSessionCount();
+
+    if ( iConMLHandler )
+        {
+        delete iConMLHandler;
+        iConMLHandler = NULL;
+        iConMLHandlerLib.Close();
+        }
+
+    if ( iPCDHandler )
+        {
+        delete iPCDHandler;
+        iPCDHandler = NULL;
+        iPCDlib.Close();
+        }
+
+    if ( iCSCHandler )
+        {
+        delete iCSCHandler;
+        iCSCHandler = NULL;
+        iCSClib.Close();
+        }
+    
+    if ( iBuffer )
+        {
+        delete iBuffer;
+        iBuffer = NULL;
+        }
+        
+    iChunk.Close();
+        
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::NewL()
+// Creates a new instance of CSConPCConnSession
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSConPCConnSession *CSConPCConnSession::NewL(
+    CSConPCConnServer& aServer)
+    {
+    TRACE_FUNC_ENTRY;
+    CSConPCConnSession* self = new ( ELeave ) CSConPCConnSession(aServer);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::ConstructL()
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    iResult = KErrNone;
+    
+#ifdef DEBUG_XML
+    // create log file 
+    RFs fs;
+    User::LeaveIfError( fs.Connect () );
+    CleanupClosePushL( fs );
+    
+    RFile file;
+    TInt err = file.Create ( fs, KSConConMLDebugFile, EFileWrite );
+    if( err == KErrNone )
+        {
+        // file created, close it
+        file.Close();
+        }       
+    
+    CleanupStack::PopAndDestroy( &fs );               
+#endif
+    
+    // initialize buffer
+    iBuffer = CBufFlat::NewL ( KSConPCConnBufferMaxSize );
+    
+    // load handlers
+    if ( !iPCDHandler )
+        {
+        TRAP( ret, LoadPCDDllL() );
+        if ( ret != KErrNone) 
+            {
+            LOGGER_WRITE_1( "CSConPCConnSession::ConstructL() : PCD load failed with error code %d", ret );
+            User::Leave( ret );
+            }
+        }   
+    
+    if ( !iCSCHandler )
+        {
+        TRAP( ret, LoadCSCDllL() );
+        if ( ret != KErrNone) 
+            {
+            LOGGER_WRITE_1( "CSConPCConnSession::ConstructL() : CSC dll load failed with error code %d", ret ); 
+            User::Leave ( ret );
+            }
+        }
+
+    // Load parser
+    if ( !iConMLHandler )
+        {
+        TRAPD( ret, LoadConMLHandlerDllL() );
+        if ( ret != KErrNone)
+            {
+            LOGGER_WRITE_1( "CSConPCConnSession::ConstructL() : Parser dll load failed with error code %d", ret );
+            User::Leave ( ret );
+            }
+        }
+
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::ServiceL()
+// Gets the client's request
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::ServiceL( const RMessage2 &aMessage)
+    {
+    TRACE_FUNC_ENTRY;
+    TRAPD(err,DispatchRequestL(aMessage) );
+    if ( err != KErrNone )
+        {
+        LOGGER_WRITE_1( "CSConPCConnSession::ServiceL() : leave code %d", err );
+        PanicServer( E_DispatchRequest );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::DispatchRequestL()
+// Identifies an IPC command from the client 
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::DispatchRequestL(const RMessage2 &aMessage)
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TInt ret (KErrNone);
+        
+    switch (aMessage.Function())
+        {
+        case EPutMessage:
+            LOGGER_WRITE( "CSConPCConnSession::DispatchRequestL() : EPutMessage" );
+            ret = HandlePutMessageL();
+            break;
+        
+        case EGetMessage:
+            LOGGER_WRITE( "CSConPCConnSession::DispatchRequestL() : EGetMessage" );
+            ret = HandleGetMessageL();
+            break;
+        
+        case EResetMessage:
+            LOGGER_WRITE( "CSConPCConnSession::DispatchRequestL() : EResetMessage" );
+            ret = HandleResetMessage();
+            break;
+            
+        case EChunkMessage:
+            LOGGER_WRITE( "CSConPCConnSession::DispatchRequestL() : EChunkMessage" );
+            ret = HandleChunkMessage( aMessage );
+            break;
+                        
+        default:
+            PanicServer (E_BadRequest);
+            break;
+        }
+
+    aMessage.Complete( ret );
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::HandlePutMessageL()
+// Handles a PUT -type message from the client
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::HandlePutMessageL()
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "CSConPCConnSession::HandlePutMessageL() : begin : Heap count : %d", User::Heap().Count() );
+    TInt ret ( KErrNone );
+        
+    if ( !iPCDHandler )
+        {
+        TRAP( ret, LoadPCDDllL() );
+        if ( ret != KErrNone) 
+            {
+            LOGGER_WRITE_1( "CSConPCConnSession::HandlePutMessageL (): PCD dll load failed with error code %d", ret );    
+            return ( ret );
+            }
+        }   
+        
+    if ( ! iConMLHandler )
+        {
+        TRAP ( ret, LoadConMLHandlerDllL() );
+        if ( ret != KErrNone )
+            {
+            LOGGER_WRITE_1( "CSConPCConnSession::HandlePutMessageL (): ConML Handler dll load failed with error code %d", ret );  
+            return ( ret );
+            }
+        }
+        
+    TInt length ( 0 );
+    
+    RMemReadStream buf( iChunk.Base(), iChunk.Size() );
+
+
+    iBuffer->Reset();
+
+    length = buf.ReadInt32L();
+    HBufC8* name = HBufC8::NewLC( length );
+    TPtr8 namePtr = name->Des();
+    buf.ReadL( namePtr, length);
+        
+    length = buf.ReadInt32L();
+    HBufC8* type = HBufC8::NewLC( length );
+    TPtr8 typePtr = type->Des();
+    buf.ReadL( typePtr, length);
+   
+    // WBXML Document
+    length = buf.ReadInt32L();
+    HBufC8* data = HBufC8::NewLC( length );
+    TPtr8 dataPtr = data->Des();
+    
+    buf.ReadL( dataPtr, length );
+    iBuffer->ResizeL( length );
+    iBuffer->Write( 0, dataPtr );
+            
+    buf.Close();
+    
+#ifdef DEBUG_XML
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+
+    RFile file;
+    if ( file.Open( fs, KSConConMLDebugFile, EFileWrite ) == KErrNone )
+        {
+        RFileWriteStream fws;
+        TInt fileSize;
+        file.Size( fileSize );
+        
+        TTime now;
+        now.HomeTime();
+        TDateTime time = now.DateTime();
+        TBuf8<16> timeLine;
+        timeLine.Format (KTimeFormat, time.Hour(), time.Minute(), 
+                                    time.Second(), time.MicroSecond() );
+        
+        fws.Attach( file, fileSize );
+        fws.PushL();
+        fws.WriteL( timeLine );
+        _LIT8( KPutMessage, "__________PUT-MESSAGE \nWBXML:\n" );
+        fws.WriteL( KPutMessage );
+        fws.WriteL( iBuffer->Ptr(0), iBuffer->Size() );
+        TRAP_IGNORE( fws.CommitL() );
+        fws.Close();
+ 
+        CleanupStack::PopAndDestroy( &fws );
+        }
+    file.Close();   
+    CleanupStack::PopAndDestroy( &fs );
+#endif
+    
+    if ( ( typePtr.Compare( KSConPCDWBXMLObjectType ) == KErrNone) || 
+         ( typePtr.Compare( KSConPCDWBXMLObjectType2 )== KErrNone) )
+        {
+        LOGGER_WRITE( "CSConPCConnSession::HandlePutMessageL() : Object type PCD " );
+        TRAPD( err, ret = iConMLHandler->ParseDocumentL( *iBuffer, this ) );    
+        if ( err != KErrNone )
+            {
+            ret = err;
+            }
+        if ( ret == KErrNone )
+            {
+            // Possible error code returned from PCCS 
+            ret = iResult;
+            }
+        }
+    else 
+        {
+        LOGGER_WRITE( "Object type not regognized " );
+        ret = KErrNotSupported;
+        }
+    CleanupStack::PopAndDestroy( data );
+    CleanupStack::PopAndDestroy( type );
+    CleanupStack::PopAndDestroy( name );
+    LOGGER_WRITE_1( "CSConPCConnSession::HandlePutMessageL() end : Heap count : %d", User::Heap().Count() );
+    LOGGER_WRITE_1( "CSConPCConnSession::HandlePutMessageL() : returned %d", ret );    
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::HandleGetMessageL()
+// Handles a GET -type message from the client
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::HandleGetMessageL()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    
+    if ( !iCSCHandler )
+        {
+        TRAP( ret, LoadCSCDllL() );
+        if ( ret != KErrNone) 
+            {
+            LOGGER_WRITE_1( "CSConPCConnSession::HandleGetMessageL() : CSC dll load failed with error code %d", ret ); 
+            return ret;
+            }
+        }
+
+    TInt32 length ( 0 );
+    RMemReadStream readBuf( iChunk.Base(), iChunk.Size() );
+    iBuffer->Reset();
+    
+    length = readBuf.ReadInt32L();
+    HBufC8* name = HBufC8::NewLC( length );
+    TPtr8 namePtr8 = name->Des();
+    readBuf.ReadL( namePtr8, length);
+    namePtr8.SetLength( length );
+    LOGGER_WRITE8_1("namePtr: %S", &namePtr8);
+    
+    const TUint8* ptr8 = namePtr8.Ptr();
+    const TUint16* ptr16 = reinterpret_cast<const TUint16*>( ptr8 );
+    TPtrC namePtr;
+    namePtr.Set( ptr16, length/2 );
+    
+    length = readBuf.ReadInt32L();
+    HBufC8* type = HBufC8::NewLC( length );
+    TPtr8 typePtr = type->Des();
+    readBuf.ReadL( typePtr, length);
+    
+    readBuf.Close();
+        
+    if ( typePtr.Compare( KSConCapabilityObjectType ) == KErrNone )
+        {
+        ret = iCSCHandler->CapabilityObject( *iBuffer );
+        
+#ifdef DEBUG_XML
+        RFs fs;
+        User::LeaveIfError(fs.Connect());
+        CleanupClosePushL(fs);
+
+        RFile file;
+        if ( file.Open(fs, KSConConMLDebugFile, EFileWrite ) == KErrNone )
+            {
+            RFileWriteStream fws;
+            TInt fileSize;
+            file.Size ( fileSize );
+            TTime now;
+            now.HomeTime();
+            TDateTime time = now.DateTime();
+            TBuf8<16> timeLine;
+            timeLine.Format( KTimeFormat, time.Hour(), time.Minute(), 
+                                        time.Second(), time.MicroSecond() );
+
+            fws.Attach ( file, fileSize);
+            fws.PushL();
+            fws.WriteL( timeLine );
+            _LIT8( KGetMessage, "__________GET -MESSAGE - Capability Object \n " );
+            fws.WriteL( KGetMessage );
+            fws.WriteL( iBuffer->Ptr(0), iBuffer->Size() );
+            TRAP_IGNORE( fws.CommitL() );
+            fws.Close();
+
+            CleanupStack::PopAndDestroy( &fws );
+            }
+        file.Close();
+        CleanupStack::PopAndDestroy( &fs );
+#endif
+
+        }
+    else if (  typePtr.CompareC( KSConPCDWBXMLObjectType) == KErrNone )
+        {
+        ret = HandleWBXMLGetRequestL( namePtr );
+        }
+    else
+        {
+        LOGGER_WRITE( "CSConPCConnSession::HandleGetMessageL() : Header type not regognized " );
+        ret = KErrNotSupported;
+        }
+    
+    CleanupStack::PopAndDestroy( 2 ); // name, type
+    
+    if ( ret != KErrNone )
+        {
+        return ret;
+        }
+    
+    length = iBuffer->Size();
+    
+    if ( sizeof(TInt32) + length > iChunk.Size() )
+        {
+        // need to resize chunk
+        TInt err = iChunk.Adjust( sizeof(TInt32) + length );
+        LOGGER_WRITE_2("iChunk.Adjust( %d ) err: %d", sizeof(TInt32) + length, err);
+        if ( err )
+            {
+            iBuffer->Reset();
+            LOGGER_WRITE_1( "CSConPCConnSession::HandleGetMessageL() : returned %d", ret );
+            return err;
+            }
+        }
+    
+    // copy data to chunk
+    RMemWriteStream writeBuf ( iChunk.Base(), iChunk.Size() );
+    
+    if ( length > 0 )
+        {
+        writeBuf.WriteInt32L( length );
+        writeBuf.WriteL( iBuffer->Ptr(0), length );
+        writeBuf.CommitL();
+        }
+    else 
+        {
+        writeBuf.WriteInt32L( 0 );
+        }
+    writeBuf.CommitL();
+    writeBuf.Close();
+    iBuffer->Reset();
+    LOGGER_WRITE_1( "CSConPCConnSession::HandleGetMessageL() : returned %d", ret );
+    return ( ret );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::HandleWBXMLGetRequestL()
+// Handles a ConML(wbxml) Get request from the client
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::HandleWBXMLGetRequestL( const TDesC& aFileName )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret(KErrNone);
+    if ( aFileName.Find(KSCONGetMetadataRequest) == 0 )
+        {
+        // ConML get metadata request --> Create metadata task
+        LOGGER_WRITE( "ConML GetMetadataRequest" );
+        TPtrC filename = aFileName.Mid( KSCONGetMetadataRequest().Length() );
+        
+        TSConMethodName method ( EGetMetadata );
+        CSConTask* task = CSConTask::NewLC( method );
+        
+        if ( filename.Length() > task->iGetMetadataParams->iFilename.MaxLength() )
+            {
+            User::Leave( KErrTooBig );
+            }
+        task->iGetMetadataParams->iFilename = filename;
+        
+        ret = iPCDHandler->PutTaskL( task );
+        CleanupStack::Pop( task );
+        LOGGER_WRITE_1("iPCDHandler->PutTaskL ret: %d", ret);
+        }
+    else if ( aFileName.Length() > 0 )
+        {
+        LOGGER_WRITE("Error: aFilename does not match to any definitions");
+        TRACE_FUNC_RET( KErrArgument );
+        return KErrArgument;
+        }
+    
+	// Get reply
+    LOGGER_WRITE( "CSConPCConnSession::HandleGetMessageL() before ConML GetReplyL" );
+    CSConStatusReply* reply = iPCDHandler->GetReply();
+    CleanupStack::PushL( reply );
+    
+    ConML_ConMLPtr_t content = new ( ELeave ) ConML_ConML_t();
+    CleanupStack::PushL( content );
+    
+    AppendStatusL( content, reply );
+    ret = iConMLHandler->GenerateDocument( content );
+    
+    CleanupStack::PopAndDestroy( content );
+    CleanupStack::PopAndDestroy( reply );
+     
+    TPtrC8 ptr( iConMLHandler->WBXMLDocument() );
+    LOGGER_WRITE_1("ptr.Size(): %d", ptr.Size());
+    iBuffer->ResizeL( ptr.Size() );
+    iBuffer->Write( 0, ptr );
+
+#ifdef DEBUG_XML
+    RFile file;
+    if ( file.Open( iFs, KSConConMLDebugFile, EFileWrite) == KErrNone )
+        {
+        RFileWriteStream fws;   
+        TInt fileSize;
+        file.Size ( fileSize );
+        fws.Attach ( file, fileSize);
+        fws.PushL();
+        TTime now;
+        now.HomeTime();
+        TDateTime time = now.DateTime();
+        TBuf8<16> timeLine;
+        timeLine.Format( KTimeFormat, time.Hour(), time.Minute(), 
+                         time.Second(), time.MicroSecond() );
+
+        fws.WriteL( timeLine );
+        _LIT8( KGetMessage, "__________GET -MESSAGE" );
+        fws.WriteL( KGetMessage );
+        fws.WriteL(KXmlBegin);
+        fws.WriteL(iConMLHandler->XMLDocument().Ptr(), 
+                          iConMLHandler->XMLDocument().Length());
+        fws.WriteL(_L("\n\n"));
+        TRAP_IGNORE( fws.CommitL() );
+        fws.Close();
+        CleanupStack::PopAndDestroy( &fws );
+        }
+        
+    file.Close();
+#endif
+    TRACE_FUNC_RET(ret);
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::HandleResetMessage()
+// Resets the PCCS service
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::HandleResetMessage()   
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    
+    // reset PCD
+    if ( iPCDHandler )
+        {
+        iPCDHandler->ResetPCD();
+        }
+        
+    LOGGER_WRITE_1( "CSConPCConnSession::HandleResetMessage() : ret %d", ret );
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::HandleChunkMessage( const RMessage2& aMessage )
+// Receives the chunk handle from the client
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::HandleChunkMessage( const RMessage2& aMessage )    
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    
+    ret = iChunk.Open( aMessage, 0, EFalse );
+        
+    LOGGER_WRITE_1( "CSConPCConnSession::HandleChunkMessageL() : ret %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::LoadPCDDllL()
+// Loads the PCCS service
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::LoadPCDDllL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // Dynamically load DLL
+    User::LeaveIfError( iPCDlib.Load( KSConPCDLibName ) );
+    if( iPCDlib.Type()[1] != KSConPCDUid )
+        {
+        LOGGER_WRITE( "CSConPCConnSession::LoadPCDDllL() : KSConPCDUidValue incorrect..." );
+        iPCDlib.Close();
+        User::Leave( KErrNotFound );
+        }   
+    TSConCreateCSConPCDFunc CreateCSConPCDL =
+    (TSConCreateCSConPCDFunc)iPCDlib.Lookup(1);
+    
+    iPCDHandler = (CSConPCD*)CreateCSConPCDL();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::LoadCSCDllL()
+// Loads the CSC service
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::LoadCSCDllL()
+    {
+    TRACE_FUNC_ENTRY;
+    // Dynamically load DLL
+    User::LeaveIfError( iCSClib.Load( KSConCSCLibName ) );
+    if( iCSClib.Type()[1] != KSConCSCUid )
+        {
+        LOGGER_WRITE( "CSConPCConnSession::LoadCSCDllL() : KSConCSCUidValue incorrect" );
+        iCSClib.Close();
+        User::Leave( KErrNotFound );
+        }   
+    TSConCreateCSConCSCFunc CreateCSConCSCL = 
+    (TSConCreateCSConCSCFunc)iCSClib.Lookup(1);
+    
+    iCSCHandler = (CSConCSC*)CreateCSConCSCL();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::LoadConMLHandlerDllL()
+// Loads the ConML handler
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::LoadConMLHandlerDllL()
+    {
+    TRACE_FUNC_ENTRY;
+    // Dynamically load DLL
+    User::LeaveIfError( iConMLHandlerLib.Load( KSConConMLHandlerLibName ) );
+    if ( iConMLHandlerLib.Type()[1] != KSConConMLHandlerUid )
+        {
+        LOGGER_WRITE( "CSConPCConnSession::LoadConMLHandlerDllL() : KSConConMLHandlerUidValue incorrect" );
+        iConMLHandlerLib.Close();
+        User::Leave( KErrNotFound );
+        }
+    TSConCreateCSConConMLHandlerFunc CreateCSConConMLHandlerL = 
+    (TSConCreateCSConConMLHandlerFunc)iConMLHandlerLib.Lookup(1);
+    
+    iConMLHandler = (CSConConMLHandler*)CreateCSConConMLHandlerL();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::ConMLL()
+// Callback function for ConML handler - parsed data processing starts
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::ConMLL( ConML_ConMLPtr_t aContent )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    
+#ifdef DEBUG_XML
+    iConMLHandler->GenerateDocument( aContent );
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    RFile file;
+    
+    if ( file.Open(fs, KSConConMLDebugFile, EFileWrite) == KErrNone )
+        {
+        RFileWriteStream fws;
+        TInt fileSize;
+        file.Size( fileSize );
+        fws.Attach ( file, fileSize );
+        fws.PushL();
+        
+        TTime now;
+        now.HomeTime();
+        TDateTime time = now.DateTime();
+        TBuf8<16> timeLine;
+        timeLine.Format (KTimeFormat, time.Hour(), time.Minute(), 
+                                    time.Second(), time.MicroSecond() );
+        
+        fws.WriteL( timeLine );
+        _LIT8( KPutMessage, "__________PUT-MESSAGE" );
+        fws.WriteL( KPutMessage );
+        fws.WriteL( KXmlBegin );
+        fws.WriteL( iConMLHandler->XMLDocument().Ptr(), 
+                    iConMLHandler->XMLDocument().Length());
+        fws.WriteL(_L("\n\n"));
+        TRAP_IGNORE( fws.CommitL() );
+        fws.Close();
+        CleanupStack::PopAndDestroy( &fws );
+        }
+    file.Close();
+    CleanupStack::PopAndDestroy( &fs );
+    
+#endif
+
+
+    if ( aContent )
+        {
+        if ( aContent->execute )
+            {
+            ret = OptionsFromExecuteL( aContent->execute );
+            }
+        else if ( aContent->cancel )
+            {
+            ret = TaskCancelL( aContent->cancel );
+            }
+        else if ( aContent->getStatus )
+            {
+            ret = TaskGetStatusL ( aContent->getStatus );
+            }
+        else 
+            {
+            LOGGER_WRITE( "CSConPCConnSession::ConML() : No appropriate content in ConML -element " );
+            ret = KErrArgument;
+            }
+        }
+    else 
+        {
+        ret  = KErrArgument;
+        }
+    
+    // store result for later use
+    iResult = ret;
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::OptionsFromExecuteL()
+// Handles data of an execute -element
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::OptionsFromExecuteL(ConML_ExecutePtr_t aContent )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TInt ret ( KErrNone );
+    if ( aContent->updateDeviceInfo )
+        {
+        ret = TaskUpdateDeviceInfoL( aContent->updateDeviceInfo);
+        }
+    else if ( aContent->listInstalledApps )
+        {
+        ret = TaskListInstalledAppsL( aContent->listInstalledApps);
+        }
+    else if ( aContent->install )
+        {
+        ret = TaskInstallL( aContent->install );
+        }       
+    else if ( aContent->unInstall )
+        {
+        ret = TaskUnInstallL( aContent->unInstall );
+        }
+    else if ( aContent->listDataOwners )
+        {
+        ret = TaskListDataOwnersL();
+        }
+    else if ( aContent->setBurMode )    
+        {
+        ret = TaskSetBURModeL( aContent->setBurMode );
+        }
+    else if ( aContent->getDataSize )
+        {
+        ret = TaskGetDataSizeL( aContent->getDataSize );
+        }
+    else if ( aContent->requestData )
+        {
+        ret = TaskRequestDataL( aContent->requestData );
+        }
+    else if ( aContent->listPublicFiles )
+        {
+        ret = TaskListPublicFilesL( aContent->listPublicFiles );
+        }
+    else if ( aContent->reboot )
+        {
+        ret = TaskRebootL();
+        }
+    else if ( aContent->getDataOwnerStatus )
+        {
+        ret = TaskGetDataOwnerStatusL( aContent->getDataOwnerStatus );      
+        }
+    else if ( aContent->supplyData )
+        {
+        ret = TaskSupplyDataL( aContent->supplyData );
+        }
+    else if ( aContent->getMetadata )
+        {
+        ret = TaskGetMetadataL( aContent->getMetadata );
+        }
+    else 
+        {
+        LOGGER_WRITE( "CSConPCConnSession::OptionsFromExecute() : No content " );
+        ret = KErrNotSupported;
+        }
+    LOGGER_WRITE_1( "CSConPCConnSession::OptionsFromExecute() : returned %d", ret );    
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::TaskCancelL(ConML_CancelPtr_t aContent)
+// Sends a Cancel -task to PCCS service
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::TaskCancelL( ConML_CancelPtr_t aContent )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    TSConMethodName method ( ECancel );
+    CSConTask* task = CSConTask::NewLC( method );
+    if ( aContent->all )
+        {
+        task->iCancelTaskAll = ETrue;
+        }
+    if ( aContent->id )
+        {
+        task->iCancelTaskId = ( DesToInt( aContent->id->Data() ));
+        }
+    ret = iPCDHandler->PutTaskL( task );
+    CleanupStack::Pop( task );
+    LOGGER_WRITE_1( "CSConPCConnSession::TaskCancelL() : returned %d", ret );    
+    return ret;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::TaskGetStatusL()
+// Sends a Get Status -task to PCCS service
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::TaskGetStatusL( ConML_GetStatusPtr_t aContent )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    TSConMethodName method ( EGetStatus );
+    CSConTask* task = CSConTask::NewLC( method );
+    if ( aContent->all )
+        {
+        task->iGetStatusParams->iAll = ETrue;
+        }
+    if ( aContent->id)
+        {
+        task->iGetStatusParams->iTaskId = ( DesToInt( aContent->id->Data() ));
+        }
+    ret = iPCDHandler->PutTaskL( task );
+    CleanupStack::Pop( task );
+    LOGGER_WRITE_1( "CSConPCConnSession::TaskGetStatusL() : returned %d", ret );    
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::TaskInstallL()
+// Sends an Install -task to PCCS service
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::TaskInstallL( ConML_InstallPtr_t aContent )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    TSConMethodName method ( EInstall );
+    CSConTask* task = CSConTask::NewLC( method);
+    task->iInstallParams->iMode = EUnknown;
+    if ( aContent->name )
+        {
+        // Unicode conversion from 8-bit to 16-bit
+        CnvUtfConverter::ConvertToUnicodeFromUtf8(task->iInstallParams->iPath, 
+                                                    aContent->name->Data());    
+        }
+    if ( aContent->instParams )
+        {
+        if ( aContent->instParams->param )
+            {
+            for ( ConML_ParamListPtr_t p = aContent->instParams->param; 
+                  p && p->data; p = p->next)
+                {
+                LOGGER_WRITE( "CSConPCConnSession::TaskInstallL() : Parameters found " );
+                if ( p->data->name )
+                    {
+                    LOGGER_WRITE( "CSConPCConnSession::TaskInstallL() : name param found " );
+                    TPtrC8 silent(KParamNameSilent);
+                    
+                    TInt comp = Mem::Compare((TUint8*)p->data->name->content, (TInt)p->data->name->length, silent.Ptr(), silent.Length());
+                    if( comp == 0)
+                        {
+                        // "Silent"-param found
+                        LOGGER_WRITE( "CSConPCConnSession::TaskInstallL() : Silent-param found " );
+                        if ( p->data->value )
+                            {
+                            TPtrC8 dataValue((TUint8*)p->data->value->content, (TInt)p->data->value->length);
+                            TInt value = DesToInt( dataValue );
+                            if (value == 1)
+                                {
+                                LOGGER_WRITE( "CSConPCConnSession::TaskInstallL() : ESilentInstall " );
+                                task->iInstallParams->iMode = ESilentInstall;
+                                }
+                            else if( value == 0 )
+                                {
+                                LOGGER_WRITE( "CSConPCConnSession::TaskInstallL() : EUnsilentInstall " );
+                                task->iInstallParams->iMode = EUnsilentInstall;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    ret = iPCDHandler->PutTaskL( task );
+    CleanupStack::Pop( task );
+    LOGGER_WRITE_1( "CSConPCConnSession::TaskInstallL() : returned %d", ret );    
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::TaskUnInstallL()
+// Sends an Uninstall -task to PCCS service
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::TaskUnInstallL( ConML_UnInstallPtr_t aContent )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    TSConMethodName method ( EUninstall );
+    CSConTask* task = CSConTask::NewLC( method );
+    task->iUninstallParams->iMode = EUnknown;
+    
+    if ( aContent->applications->application)       
+        {
+        for ( ConML_ApplicationListPtr_t p = 
+              aContent->applications->application; p && p->data; p = p->next )
+            {
+            if ( p->data )
+                {
+                if ( p->data->name )
+                    {
+                    // get application name
+                    HBufC* nameBuf = CnvUtfConverter::ConvertToUnicodeFromUtf8L( p->data->name->Data() );
+                    task->iUninstallParams->iName.Copy( nameBuf->Des() );
+                    delete nameBuf;
+                    nameBuf = NULL;
+                    }
+                if ( p->data->uid )
+                    {
+                    // parse uid:  UID # Type # Size # Version # Vendor # Parent app. name #
+                    // only UID and Vendor are needed from whole uid-field.
+                    LOGGER_WRITE( "CSConPCConnSession::TaskUnInstallL() : start parsing uid " );
+                    
+                    TPtrC8 buf( p->data->uid->Data() );
+                    
+                    RArray<TPtrC8> arr(6);
+                    CleanupClosePushL( arr );
+                    TBuf8<1> separator(KSConAppInfoSeparator);
+                    
+                    SplitL(buf, separator[0], arr);
+                    if ( arr.Count() >= 5 )
+                    	{
+                    	task->iUninstallParams->iUid = DesToUid( arr[0] );
+                    	task->iUninstallParams->iType = (TSConAppType)DesToInt( arr[1] );
+                    	HBufC* vendorBuf = CnvUtfConverter::ConvertToUnicodeFromUtf8L( arr[4] );
+                    	task->iUninstallParams->iVendor.Copy( vendorBuf->Des() );
+                    	delete vendorBuf;
+                    	vendorBuf = NULL;
+                    	}
+                    CleanupStack::PopAndDestroy( &arr );
+                    
+                        
+                    } // endif p->data->uid
+                }
+            }
+        }
+    
+    if ( aContent->instParams)
+        {
+        if ( aContent->instParams->param )
+            {
+            for ( ConML_ParamListPtr_t p = aContent->instParams->param; 
+                    p && p->data; p = p->next )
+                {
+                LOGGER_WRITE( "CSConPCConnSession::TaskUnInstallL() : Parameters found " );
+                if ( p->data->name )
+                    {
+                    LOGGER_WRITE( "CSConPCConnSession::TaskUnInstallL() : name param found " );
+                    TPtrC8 silent(KParamNameSilent);
+                    
+                    TInt comp = Mem::Compare((TUint8*)p->data->name->content, (TInt)p->data->name->length, silent.Ptr(), silent.Length());
+                    if( comp == 0)
+                        {
+                        // "Silent"-param found
+                        LOGGER_WRITE( "CSConPCConnSession::TaskUnInstallL() : Silent-param found " );
+                        if ( p->data->value )
+                            {
+                            TPtrC8 dataValue((TUint8*)p->data->value->content, (TInt)p->data->value->length);
+                            TInt value = DesToInt( dataValue );
+                            if ( value == 1 )
+                                {
+                                LOGGER_WRITE( "CSConPCConnSession::TaskUnInstallL() : ESilentInstall " );
+                                task->iUninstallParams->iMode = ESilentInstall;
+                                }
+                            else if ( value == 0 )
+                                {
+                                LOGGER_WRITE( "CSConPCConnSession::TaskUnInstallL() : EUnsilentInstall " );
+                                task->iUninstallParams->iMode = EUnsilentInstall;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    ret = iPCDHandler->PutTaskL( task );
+    CleanupStack::Pop( task );
+    LOGGER_WRITE_1( "CSConPCConnSession::TaskUnInstallL() : returned %d", ret );    
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::SplitL(const TDesC& aText, const TChar aSeparator, 
+// RArray<TPtrC>& aArray)
+// Function splits string (eg "name1, name2, name3") into substrings.
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::SplitL(const TDesC8& aText, const TChar aSeparator, 
+                    RArray<TPtrC8>& aArray)
+    {
+    TRACE_FUNC_ENTRY;
+    TPtrC8 ptr;
+    ptr.Set(aText);
+
+    for (;;)
+        {
+        TInt pos=ptr.Locate(aSeparator);
+        if (pos==KErrNotFound)
+            {
+            aArray.AppendL(ptr);
+            break;
+            }
+
+        TPtrC8 subStr=ptr.Left(pos); // get pos characters starting from position 0
+        aArray.AppendL(subStr);
+
+        if (!(ptr.Length()>pos+1))
+            {
+            break;
+            }
+            
+        ptr.Set(ptr.Mid(pos+1));// get all characters starting from position pos+1
+        }
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::TaskListInstalledAppsL()
+// Sends a List installed apps -task to PCCS service
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::TaskListInstalledAppsL(
+    ConML_ListInstalledAppsPtr_t aContent )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    TSConMethodName method ( EListInstalledApps );
+    CSConTask* task = CSConTask::NewLC( method );
+    if( aContent-> drives )
+        {
+        task->iListAppsParams->iDriveList = DriveList( aContent->drives->drive);
+        }
+    if ( aContent->all )
+        {
+        task->iListAppsParams->iAllApps = ETrue;
+        }
+    ret = iPCDHandler->PutTaskL( task );
+    CleanupStack::Pop( task );
+    LOGGER_WRITE_1( "CSConPCConnSession::TaskListInstalledAppsL() : returned %d", ret);
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::TaskListDataOwnersL()
+// Sends a List data owners -task to PCCS service
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::TaskListDataOwnersL()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    TSConMethodName method ( EListDataOwners );
+    CSConTask* task = CSConTask::NewLC( method );
+    ret = iPCDHandler->PutTaskL( task );
+    CleanupStack::Pop( task );
+    LOGGER_WRITE_1( "CSConPCConnSession::TaskListDataOwnersL() : returned %d", ret );    
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::TaskSetBURModeL()
+// Sends a Set BUR mode -task to PCCS service
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::TaskSetBURModeL(ConML_SetBURModePtr_t aContent )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    TSConMethodName method ( ESetBURMode );
+    CSConTask* task = CSConTask::NewLC( method );
+    if ( aContent->drives )
+        {
+        task->iBURModeParams->iDriveList = DriveList( aContent->drives->drive);
+        }
+    if ( aContent->partialType )
+        {
+        TInt intValue = DesToInt( aContent->partialType->Data() );
+        task->iBURModeParams->iPartialType = static_cast<TSConBurMode> (intValue) ;
+        }
+    if ( aContent->incType )
+        {
+        TInt intValue = DesToInt( aContent->incType->Data() );
+        task->iBURModeParams->iIncType = static_cast<TSConIncType> (intValue) ;
+        }
+    ret = iPCDHandler->PutTaskL( task );
+    CleanupStack::Pop( task );
+    LOGGER_WRITE_1( "CSConPCConnSession::TaskSetBURModeL() : returned %d", ret );    
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::TaskGetDataSizeL()
+// Sends a Get data size -task to PCCS service
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::TaskGetDataSizeL(ConML_GetDataSizePtr_t aContent )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    TSConMethodName method ( EGetDataSize );
+    CSConTask* task = CSConTask::NewLC( method );
+    if ( aContent->dataOwners )
+        {
+        for ( ConML_SIDListPtr_t p = aContent->dataOwners->sid; 
+                p && p->data; p=p->next )
+            {
+            CSConDataOwner* dataOwner = new (ELeave) CSConDataOwner();
+            if ( p->data->type )
+                {
+                dataOwner->iType = TSConDOType (DesToInt( 
+                    p->data->type->Data() ));
+                }
+            if (p->data->uid )
+                {
+                if( !IsJavaHash( p->data->uid->Data() ) )
+                    {
+                    dataOwner->iUid = DesToUid( p->data->uid->Data() );
+                    }
+                else
+                    {
+                    TPtr hashPtr = DesToHashLC( p->data->uid->Data() );
+                    dataOwner->iJavaHash = HBufC::NewL( hashPtr.Size() );
+                    dataOwner->iJavaHash->Des().Copy( hashPtr );
+                    CleanupStack::PopAndDestroy(); //DesToHashLC()
+                    }
+                }
+            if ( p->data->drives )
+                {
+                dataOwner->iDriveList = DriveList ( p->data->drives->drive );
+                }
+            if ( p->data->transferDataType )
+                {
+                TInt intValue = DesToInt( p->data->transferDataType->Data() );
+                dataOwner->iTransDataType = static_cast<TSConTransferDataType> (intValue);
+                }
+            task->iGetDataSizeParams->iDataOwners.Append( dataOwner );
+            }
+        }
+    ret = iPCDHandler->PutTaskL( task );
+    CleanupStack::Pop( task );
+    LOGGER_WRITE_1( "CSConPCConnSession::TaskGetDataSizeL() : returned %d", ret );    
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::TaskRequestDataL()
+// Sends a Request data -task to PCCS service
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::TaskRequestDataL(ConML_RequestDataPtr_t aContent )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    TSConMethodName method ( ERequestData );
+    CSConTask* task = CSConTask::NewLC( method );
+    if ( aContent )
+        {
+        if ( aContent->sid )
+            {
+            for ( ConML_SIDListPtr_t p=aContent->sid; p && p->data; p=p->next )
+                {
+                if ( p->data->type )
+                    {
+                    task->iRequestDataParams->iDataOwner->iType = 
+                    TSConDOType ( DesToInt ( p->data->type->Data() ) );
+                    }
+                if ( p->data->uid )
+                    {
+                    if( !IsJavaHash( p->data->uid->Data() ) )
+                        {
+                        task->iRequestDataParams->iDataOwner->iUid = DesToUid(
+                                                     p->data->uid->Data() );
+                        }
+                    else
+                        {
+                        TPtr hashPtr = DesToHashLC( p->data->uid->Data() );
+                        task->iRequestDataParams->iDataOwner->iJavaHash = HBufC::NewL( hashPtr.Size() );
+                        task->iRequestDataParams->iDataOwner->iJavaHash->Des().Copy( hashPtr );
+                        CleanupStack::PopAndDestroy(); //DesToHashLC()
+                        }                                 
+                    }
+                if ( p->data->drives )
+                    {
+                    task->iRequestDataParams->iDataOwner->iDriveList = 
+                    DriveList ( p->data->drives->drive );
+                    }
+                if ( p->data->transferDataType )
+                    {
+                    TInt intValue = DesToInt( p->data->transferDataType->Data() );
+                    task->iRequestDataParams->iDataOwner->iTransDataType =
+                        static_cast<TSConTransferDataType> (intValue);
+                    }
+                }
+            }
+        }
+    ret = iPCDHandler->PutTaskL( task );
+    CleanupStack::Pop( task );
+    LOGGER_WRITE_1( "CSConPCConnSession::TaskRequestDataL() : returned %d", ret );    
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::TaskUpdateDeviceInfoL()
+// Sends a Update device info -task to PCCS service
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::TaskUpdateDeviceInfoL(
+    ConML_UpdateDeviceInfoPtr_t aContent )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    TSConMethodName method ( EUpdateDeviceInfo );
+    CSConTask* task = CSConTask::NewLC( method );
+
+    if ( aContent->deviceInfo)
+        {
+        ConML_DeviceInfoPtr_t dPtr = aContent->deviceInfo;
+        if ( dPtr->version )
+            {
+            task->iDevInfoParams->iVersion.Copy( dPtr->version->Data());
+            }
+        if ( dPtr->maxObjectSize )
+            {
+            task->iDevInfoParams->iMaxObjectSize = DesToInt(
+                                            dPtr->maxObjectSize->Data());
+            }
+        if ( dPtr->supportedMethods )
+            {
+            ConML_SupportedMethodsPtr_t smPtr = dPtr->supportedMethods;
+            if ( smPtr->install )
+                {
+                task->iDevInfoParams->iInstallSupp = ETrue; 
+                }
+            if ( smPtr->unInstall )
+                {
+                task->iDevInfoParams->iUninstallSupp = ETrue;
+                }
+            if ( smPtr->listInstalledApps )
+                {
+                task->iDevInfoParams->iInstAppsSupp = ETrue;
+                }
+            if ( smPtr->listDataOwners )
+                {
+                task->iDevInfoParams->iDataOwnersSupp = ETrue;
+                }
+            if ( smPtr->setBurMode )
+                {
+                task->iDevInfoParams->iSetBURModeSupp = ETrue;
+                }
+            if ( smPtr->getDataSize )
+                {
+                task->iDevInfoParams->iGetSizeSupp = ETrue;
+                }
+            if ( smPtr->requestData )
+                {
+                task->iDevInfoParams->iReqDataSupp = ETrue;
+                }
+            if ( smPtr->supplyData )
+                {
+                task->iDevInfoParams->iSupplyDataSupp = ETrue;  
+                }
+            if ( smPtr->reboot )
+                {
+                task->iDevInfoParams->iRebootSupp = ETrue;
+                }
+            }
+        }
+    ret = iPCDHandler->PutTaskL( task );
+    CleanupStack::Pop( task );
+    LOGGER_WRITE_1( "CSConPCConnSession::TaskUpdateDeviceInfoL() : returned %d", ret );    
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::TaskListPublicFilesL()
+// Sends a List public files -task to PCCS service
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::TaskListPublicFilesL(
+    ConML_ListPublicFilesPtr_t aContent )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    TSConMethodName method ( EListPublicFiles );
+    CSConTask* task = CSConTask::NewLC( method );
+    if ( aContent->sid )
+        {
+        for ( ConML_SIDListPtr_t p = aContent->sid; p && p->data; p = p->next )
+            {
+            CSConDataOwner* dataOwner = new (ELeave) CSConDataOwner();
+            
+            if ( p->data->type )                
+                {
+                dataOwner->iType = TSConDOType ( DesToInt( 
+                                        p->data->type->Data() ) );
+                }
+            if ( p->data->uid )
+                {
+                if( !IsJavaHash( p->data->uid->Data() ) )
+                    {
+                    dataOwner->iUid = DesToUid( p->data->uid->Data() );
+                    }
+                else
+                    {
+                    TPtr hashPtr = DesToHashLC( p->data->uid->Data() );
+                    dataOwner->iJavaHash = HBufC::NewL( hashPtr.Size() );
+                    dataOwner->iJavaHash->Des().Copy( hashPtr );
+                    CleanupStack::PopAndDestroy(); //DesToHashLC()
+                    }
+                }
+            if ( p->data->drives )
+                {
+                dataOwner->iDriveList = DriveList ( p->data->drives->drive );
+                }
+            if ( p->data->packageInfo && p->data->packageInfo->name )
+                {
+                // Unicode conversion from 8-bit to 16-bit
+                CnvUtfConverter::ConvertToUnicodeFromUtf8(
+                        dataOwner->iPackageName, 
+                        p->data->packageInfo->name->Data());
+                }
+            task->iPubFilesParams->iDataOwners.Append( dataOwner );
+            }
+        }
+    ret = iPCDHandler->PutTaskL( task );
+    CleanupStack::Pop( task );
+    LOGGER_WRITE_1( "CSConPCConnSession::TaskListPublicFilesL() : returned %d", ret );    
+    return ret;
+    }
+        
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::TaskSupplyDataL()
+// Sends a Supply data -task to PCCS service
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::TaskSupplyDataL ( ConML_SupplyDataPtr_t aContent )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    TSConMethodName method ( ESupplyData );
+    CSConTask* task = CSConTask::NewLC( method );
+    if (aContent )
+        {
+        for ( ConML_SIDListPtr_t p = aContent->sid; p && p->data; p = p->next )
+            {
+            if ( p->data->type )
+                {
+                task->iSupplyDataParams->iDataOwner->iType = 
+                TSConDOType ( DesToInt( p->data->type->Data() ) );
+                }
+            if ( p->data->uid )
+                {
+                if( !IsJavaHash( p->data->uid->Data() ) )
+                    {
+                    task->iSupplyDataParams->iDataOwner->iUid = DesToUid( 
+                                                p->data->uid->Data() );
+                    }
+                else
+                    {
+                    TPtr hashPtr = DesToHashLC( p->data->uid->Data() );
+                    task->iSupplyDataParams->iDataOwner->iJavaHash = HBufC::NewL( hashPtr.Size() );
+                    task->iSupplyDataParams->iDataOwner->iJavaHash->Des().Copy( hashPtr );
+                    CleanupStack::PopAndDestroy(); //DesToHashLC()
+                    }
+                }
+            if ( p->data->drives )
+                {
+                task->iSupplyDataParams->iDataOwner->iDriveList = 
+                DriveList ( p->data->drives->drive );
+                }
+            if ( p->data->transferDataType )
+                {
+                TInt intValue = DesToInt ( p->data->transferDataType->Data() );
+                task->iSupplyDataParams->iDataOwner->iTransDataType =
+                    static_cast<TSConTransferDataType> (intValue);
+                }
+            if ( p->data->data )
+                {
+                task->iSupplyDataParams->iRestoreData = HBufC8::NewL(
+                                            p->data->data->Data().Size() );
+                *task->iSupplyDataParams->iRestoreData = p->data->data->Data();
+                }
+            if ( p->data->moreData )
+                {
+                task->iSupplyDataParams->iMoreData = ETrue;
+                }
+            else
+                {
+                task->iSupplyDataParams->iMoreData = EFalse;
+                }
+            }
+        }
+    ret = iPCDHandler->PutTaskL( task );
+    CleanupStack::Pop( task );
+    LOGGER_WRITE_1( "CSConPCConnSession::TaskSupplyDataL() : returned %d", ret );    
+    return ret;
+}
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::TaskGetDataOwnerStatusL()
+// Sends a Get data owner status -task to PCCS service
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::TaskGetDataOwnerStatusL
+    ( ConML_GetDataOwnerStatusPtr_t aContent )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    TSConMethodName method ( EGetDataOwnerStatus );
+    CSConTask* task = CSConTask::NewLC( method );
+
+    if ( aContent->dataOwners )
+        {
+        for ( ConML_SIDListPtr_t p = aContent->dataOwners->sid; 
+                p && p->data; p=p->next )
+            {
+            CSConDataOwner* dataOwner = new (ELeave) CSConDataOwner();
+            if ( p->data->type )    
+                {
+                dataOwner->iType = TSConDOType (DesToInt(
+                                     p->data->type->Data() ));
+                }
+            if ( p->data->uid )             
+                {
+                if( !IsJavaHash( p->data->uid->Data() ) )
+                    {
+                    dataOwner->iUid = DesToUid( p->data->uid->Data() );
+                    }
+                else
+                    {
+                    TPtr hashPtr = DesToHashLC( p->data->uid->Data() );
+                    dataOwner->iJavaHash = HBufC::NewL( hashPtr.Size() );
+                    dataOwner->iJavaHash->Des().Copy( hashPtr );
+                    CleanupStack::PopAndDestroy(); //DesToHashLC()
+                    }
+                }           
+            task->iGetDataOwnerParams->iDataOwners.Append( dataOwner );
+            }
+        }
+    ret = iPCDHandler->PutTaskL( task );
+    CleanupStack::Pop( task );
+    LOGGER_WRITE_1( "CSConPCConnSession::TaskGetDataOwnerStatusL() : returned %d", ret );    
+    return ret; 
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::TaskRebootL()
+// Sends a Reboot -task to PCCS service
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::TaskRebootL( )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    TSConMethodName method ( EReboot );
+    CSConTask* task = CSConTask::NewLC( method );
+    ret = iPCDHandler->PutTaskL( task );
+    CleanupStack::Pop( task );
+    LOGGER_WRITE_1( "CSConPCConnSession::TaskRebootL() : returned %d", ret );    
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::TaskGetMetadataL()
+// Sends a GetMetadata -task to PCCS service
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::TaskGetMetadataL( ConML_GetMetadataPtr_t aContent )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    TSConMethodName method ( EGetMetadata );
+    CSConTask* task = CSConTask::NewLC( method );
+    if( aContent )
+        {
+        if ( aContent->filename )
+            {
+            // Unicode conversion from 8-bit to 16-bit
+            CnvUtfConverter::ConvertToUnicodeFromUtf8(task->iGetMetadataParams->iFilename, 
+                                                        aContent->filename->Data());    
+            }
+        }
+    ret = iPCDHandler->PutTaskL( task );
+    CleanupStack::Pop( task );
+    LOGGER_WRITE_1( "CSConPCConnSession::TaskGetMetadataL() : returned %d", ret );    
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::TaskRebootL()
+// Appends a status element from the reply data of PCCS
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::AppendStatusL( 
+    ConML_ConMLPtr_t aContent, CSConStatusReply* reply )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    if ( !reply )
+        {
+        LOGGER_WRITE( "CSConPCConnSession::AppendStatus() : No data in reply!" );
+        return;
+        }
+    aContent->status = new ( ELeave ) ConML_Status_t();
+        
+    if ( reply->iTasks.Count() > 0 ) 
+        {
+        for ( TInt i=0; i < reply->iTasks.Count(); i ++)
+            {
+            ConML_TaskListPtr_t task = new ( ELeave ) ConML_TaskList_t();
+            CleanupStack::PushL( task );
+            GenericListAddL ( &aContent->status->task, task );
+            CleanupStack::Pop(); // task
+            
+            task->data = new ( ELeave ) ConML_Task_t();
+            task->data->id = new ( ELeave ) pcdata_t();
+            task->data->id->SetDataL ( IntToDesLC(reply->iTasks[i]->iTaskId) );
+            CleanupStack::PopAndDestroy(); // IntToDesLC 
+            TSConMethodName method ( reply->iTasks[i]->iMethod );
+            
+            switch ( method )
+                {
+                case EUpdateDeviceInfo:
+                    task->data->updateDeviceInfo = 
+                        new ( ELeave ) ConML_UpdateDeviceInfo_t();
+                    task->data->updateDeviceInfo->results = 
+                        new ( ELeave ) ConML_Results_t();
+                    AppendUpdateDeviceInfoResultsL( 
+                        task->data->updateDeviceInfo->results,
+                        reply->iTasks[i]->iDevInfoParams );
+                    break;
+                
+                case ESetBURMode:
+                    task->data->setBurMode = 
+                        new ( ELeave ) ConML_SetBURMode_t();
+                    task->data->setBurMode->results = 
+                        new ( ELeave) ConML_Results_t();
+                    AppendSetBURModeResultsL( 
+                        task->data->setBurMode->results,
+                        reply->iTasks[i]->iBURModeParams );
+                    break;
+            
+                case EListInstalledApps:
+                    task->data->listInstalledApps = 
+                        new ( ELeave ) ConML_ListInstalledApps_t();
+                    task->data->listInstalledApps->results = 
+                        new ( ELeave ) ConML_Results_t();
+                    AppendListInstalledAppsResultsL( 
+                        task->data->listInstalledApps->results,
+                        reply->iTasks[i]->iListAppsParams);
+                    break;
+                
+                case EInstall:
+                    task->data->install = new ( ELeave ) ConML_Install_t();
+                    task->data->install->results = 
+                        new ( ELeave ) ConML_Results_t();
+                    AppendInstallResultsL( 
+                        task->data->install->results, 
+                        reply->iTasks[i]->iInstallParams );
+                    break;
+            
+                case EUninstall:
+                    task->data->unInstall = new ( ELeave ) ConML_UnInstall_t();
+                    task->data->unInstall->results = 
+                        new ( ELeave ) ConML_Results_t();
+                    AppendUninstallResultsL(
+                        task->data->unInstall->results, 
+                        reply->iTasks[i]->iUninstallParams );
+                    break;
+                
+                case EListDataOwners:
+                    task->data->listDataOwners = 
+                        new ( ELeave ) ConML_ListDataOwners_t();
+                    task->data->listDataOwners->results = 
+                        new ( ELeave ) ConML_Results_t();
+                    AppendListDataOwnersResultsL( 
+                        task->data->listDataOwners->results, 
+                        reply->iTasks[i]->iListDataOwnersParams );
+                    break;
+                
+                case EGetDataOwnerStatus:
+                    task->data->getDataOwnerStatus = 
+                        new ( ELeave ) ConML_GetDataOwnerStatus_t();
+                    task->data->getDataOwnerStatus->results = 
+                        new ( ELeave ) ConML_Results_t();
+                    AppendGetDataOwnerStatusResultsL( 
+                        task->data->getDataOwnerStatus->results,
+                        reply->iTasks[i]->iGetDataOwnerParams);
+                    break;
+                
+                case EGetDataSize:
+                    task->data->getDataSize = 
+                        new ( ELeave ) ConML_GetDataSize_t();
+                    task->data->getDataSize->results = 
+                        new ( ELeave ) ConML_Results_t();
+                    AppendGetDataSizeResultsL( 
+                        task->data->getDataSize->results,
+                        reply->iTasks[i]->iGetDataSizeParams );
+                    break;
+                                
+                case EListPublicFiles:
+                    task->data->listPublicFiles = 
+                        new ( ELeave ) ConML_ListPublicFiles_t();
+                    task->data->listPublicFiles->results = 
+                        new ( ELeave ) ConML_Results_t();
+                    AppendListPublicFilesResultsL ( 
+                        task->data->listPublicFiles->results,
+                        reply->iTasks[i]->iPubFilesParams );
+                    break;
+            
+                case ERequestData:
+                    task->data->requestData = 
+                        new ( ELeave ) ConML_RequestData_t();
+                    task->data->requestData->results = 
+                        new ( ELeave ) ConML_Results_t();
+                    AppendRequestDataResultsL( 
+                        task->data->requestData->results, 
+                        reply->iTasks[i]->iRequestDataParams );
+                    break;
+                
+                case ESupplyData:
+                    task->data->supplyData = 
+                        new ( ELeave ) ConML_SupplyData_t();
+                    task->data->supplyData->results = 
+                        new ( ELeave ) ConML_Results_t();
+                    AppendSupplyDataResultsL ( 
+                        task->data->supplyData->results, 
+                        reply->iTasks[i]->iSupplyDataParams );
+                    break;
+                
+                case EGetMetadata:
+                    task->data->getMetadata = 
+                        new ( ELeave ) ConML_GetMetadata_t();
+                    task->data->getMetadata->results = 
+                        new ( ELeave ) ConML_Results_t();
+                    AppendGetMetadataResultsL ( 
+                        task->data->getMetadata->results, 
+                        reply->iTasks[i]->iGetMetadataParams );
+                    break;
+                    
+                default:
+                    LOGGER_WRITE_1( "CSConPCConnSession:: AppendStatus() : Unknown method  %d ", method );
+                    break;
+                }
+            }
+        }
+    else
+        {
+        LOGGER_WRITE( "CSConPCConnSession::AppendStatus() : No Task " );     
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::AppendUpdateDeviceInfoResultsL()
+// Appends a update device info -element from the reply data of PCCS
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::AppendUpdateDeviceInfoResultsL 
+    ( ConML_ResultsPtr_t aContent, CSConUpdateDeviceInfo* aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( aResult )  
+        {
+        if ( aResult->iComplete )
+            {
+            aContent->complete = new ( ELeave ) pcdata_t();
+            }
+        AppendProgressL ( aContent, aResult->iProgress );
+    
+        aContent->deviceInfo = new ( ELeave ) ConML_DeviceInfo_t();
+        aContent->deviceInfo->version = new ( ELeave ) pcdata_t();
+        aContent->deviceInfo->version->SetDataL ( aResult->iVersion );
+
+        aContent->deviceInfo->supportedMethods = 
+            new ( ELeave ) ConML_SupportedMethods_t();
+            
+        if ( aResult->iInstallSupp )
+            {
+            aContent->deviceInfo->supportedMethods->install = 
+                new ( ELeave ) pcdata_t();
+            }
+        if ( aResult->iUninstallSupp )
+            {
+            aContent->deviceInfo->supportedMethods->unInstall = 
+                new ( ELeave ) pcdata_t();
+            }
+        if ( aResult->iInstAppsSupp )
+            {
+            aContent->deviceInfo->supportedMethods->listInstalledApps = 
+                new ( ELeave ) pcdata_t();
+            }
+        if ( aResult->iDataOwnersSupp )
+            {
+            aContent->deviceInfo->supportedMethods->listDataOwners = 
+                new ( ELeave ) pcdata_t();
+            }
+        if ( aResult->iSetBURModeSupp )
+            {
+            aContent->deviceInfo->supportedMethods->setBurMode = 
+                new ( ELeave ) pcdata_t();
+            }
+        if ( aResult->iGetSizeSupp )
+            {
+            aContent->deviceInfo->supportedMethods->getDataSize = 
+                new ( ELeave ) pcdata_t();
+            }
+        if ( aResult->iReqDataSupp )
+            {
+            aContent->deviceInfo->supportedMethods->requestData = 
+                new (ELeave ) pcdata_t();
+            }
+        if ( aResult->iSupplyDataSupp )
+            {
+            aContent->deviceInfo->supportedMethods->supplyData = 
+                new ( ELeave ) pcdata_t();
+            }
+        if ( aResult->iRebootSupp )
+            {
+            aContent->deviceInfo->supportedMethods->reboot = 
+                new ( ELeave ) pcdata_t();
+            }
+        aContent->deviceInfo->maxObjectSize = new ( ELeave ) pcdata_t();
+        aContent->deviceInfo->maxObjectSize->SetDataL ( IntToDesLC(
+            aResult->iMaxObjectSize ));
+        CleanupStack::PopAndDestroy(); // IntToDesLC
+        }
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::AppendSetBURModeResultsL()
+// Appends a Set BUR mode -element from the reply data of PCCS
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::AppendSetBURModeResultsL (
+    ConML_ResultsPtr_t aContent, CSConSetBURMode* aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( aResult )
+        {
+        if ( aResult->iComplete )
+            {
+            aContent->complete = new ( ELeave ) pcdata_t();
+            }
+        AppendProgressL ( aContent, aResult->iProgress );
+        }
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::AppendListInstalledAppsResultsL()
+// Appends a List installed apps -element from the reply data of PCCS
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::AppendListInstalledAppsResultsL ( 
+    ConML_ResultsPtr_t aContent, CSConListInstApps* aResult )
+    {
+    TRACE_FUNC_ENTRY;
+
+    if ( aResult )
+        {
+        if ( aResult->iComplete )
+            {
+            aContent->complete = new ( ELeave ) pcdata_t();
+            }
+        AppendProgressL ( aContent, aResult->iProgress );
+        
+        if ( aResult->iApps.Count() > 0 )
+            {
+            // 5 * KMaxFileName should be enought
+            // ( 4 items of TFileName and uid + type + size + 6* "#" )
+            HBufC8* buf = HBufC8::NewLC( 5 * KMaxFileName );
+            TPtr8 ptrBuf = buf->Des();
+            
+            aContent->applications = new ( ELeave ) ConML_Applications_t();
+            for ( TInt i=0; i<aResult->iApps.Count(); i++)
+                {
+                ConML_ApplicationListPtr_t app = 
+                    new ( ELeave )ConML_ApplicationList_t();
+                CleanupStack::PushL ( app );
+                GenericListAddL ( &aContent->applications->application, app );
+                CleanupStack::Pop(); // app
+                
+                app->data = new ( ELeave ) ConML_Application_t();
+                app->data->name = new ( ELeave ) pcdata_t();
+                app->data->name->SetDataL( BufToDesLC( 
+                    aResult->iApps[i]->iName));
+                CleanupStack::PopAndDestroy(); // BufToDesLC
+                
+                // create uid: UID # Type # Size # Version # Vendor # Parent app. name #
+                LOGGER_WRITE( "CSConPCConnSession::AppendListInstalledAppsResultsL() : Create Uid" );
+                
+                ptrBuf.Copy( UidToDesLC( aResult->iApps[i]->iUid ) );
+                CleanupStack::PopAndDestroy(); // UidToDesLC
+                
+                ptrBuf.Append( KSConAppInfoSeparator );
+                
+                ptrBuf.Append( IntToDesLC(aResult->iApps[i]->iType ));
+                CleanupStack::PopAndDestroy(); // IntToDesLC
+                
+                ptrBuf.Append( KSConAppInfoSeparator );
+                
+                ptrBuf.Append( IntToDesLC(aResult->iApps[i]->iSize ) );
+                CleanupStack::PopAndDestroy(); // IntToDesLC
+                
+                ptrBuf.Append( KSConAppInfoSeparator );
+                ptrBuf.Append( aResult->iApps[i]->iVersion );
+                
+                ptrBuf.Append( KSConAppInfoSeparator );
+                ptrBuf.Append( BufToDesLC( aResult->iApps[i]->iVendor ) );
+                CleanupStack::PopAndDestroy(); // BufToDesLC
+                
+                ptrBuf.Append( KSConAppInfoSeparator );
+                ptrBuf.Append( BufToDesLC( aResult->iApps[i]->iParentName ) );
+                CleanupStack::PopAndDestroy(); // BufToDesLC
+                
+                ptrBuf.Append( KSConAppInfoSeparator );
+                
+                LOGGER_WRITE( "CSConPCConnSession::AppendListInstalledAppsResultsL() : set data" );
+                app->data->uid = new ( ELeave ) pcdata_t();
+                app->data->uid->SetDataL( *buf );
+                    
+                LOGGER_WRITE( "CSConPCConnSession::AppendListInstalledAppsResultsL() : Info added" );
+                }
+            CleanupStack::PopAndDestroy(buf);       
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::AppendListPublicFilesResultsL()
+// Appends a List public files -element from the reply data of PCCS
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::AppendListPublicFilesResultsL ( 
+    ConML_ResultsPtr_t aContent, CSConListPublicFiles* aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( aResult )
+        {
+        if ( aResult->iComplete )
+            {
+            aContent->complete = new ( ELeave ) pcdata_t();
+            }
+        AppendProgressL ( aContent, aResult->iProgress );
+        
+        if ( aResult->iFiles.Count() > 0 )
+            {
+            aContent->files = new ( ELeave ) ConML_Files_t();
+            for ( TInt i=0;i<aResult->iFiles.Count(); i++ )
+                {
+                ConML_FileListPtr_t file = new ( ELeave ) ConML_FileList_t();
+                CleanupStack::PushL( file );
+                GenericListAddL ( &aContent->files->file, file );
+                CleanupStack::Pop(); // file
+                
+                file->data = new ( ELeave ) ConML_File_t();
+                file->data->name = new ( ELeave ) pcdata_t();
+                file->data->name->SetDataL( BufToDesLC (
+                    aResult->iFiles[i]->iPath ) );
+                CleanupStack::PopAndDestroy(); // BufToDesLC
+                
+                file->data->modified = new ( ELeave ) pcdata_t();
+                file->data->modified->SetDataL( BufToDesLC (
+                    aResult->iFiles[i]->iModified ) );
+                CleanupStack::PopAndDestroy(); // BufToDesLC
+                
+                file->data->size = new ( ELeave ) pcdata_t();
+                file->data->size->SetDataL( IntToDesLC ( 
+                    aResult->iFiles[i]->iSize ) );
+                CleanupStack::PopAndDestroy(); // IntToDesLC
+                
+                file->data->userPerm = new ( ELeave ) pcdata_t();
+                switch ( aResult->iFiles[i]->iUserPerm )
+                    {
+                    case EPermReadOnly:
+                        file->data->userPerm->SetDataL ( KSConPermReadOnly );
+                        break;
+                    
+                    case EPermNormal:
+                        file->data->userPerm->SetDataL ( KSConPermNormal );
+                        break;
+                    
+                    default:
+                        LOGGER_WRITE( "CSConPCConnSession:: AppendListPublicFilesResultsL() : Unknown userPerm! " );
+                        break;          
+                    }
+                }
+        }
+    }
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::AppendRequestDataResultsL()
+// Appends a Request data -element from the reply data of PCCS
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::AppendRequestDataResultsL( 
+    ConML_ResultsPtr_t aContent, CSConRequestData* aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( aResult )
+        {
+        if ( aResult->iComplete )
+            {
+            aContent->complete = new ( ELeave ) pcdata_t();
+            }
+        AppendProgressL ( aContent, aResult->iProgress );
+        
+        if ( aResult->iMoreData )
+            {
+            aContent->moreData = new ( ELeave ) pcdata_t();
+            }
+        if ( aResult->iBackupData )
+            {
+            aContent->data = new ( ELeave ) pcdata_t();
+            aContent->data->SetDataL( aResult->iBackupData->Des() );
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::AppendSupplyDataResultsL()
+// Appends a Supply data -element from the reply data of PCCS
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::AppendSupplyDataResultsL( 
+    ConML_ResultsPtr_t aContent, CSConSupplyData* aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( aResult )
+        {
+        if ( aResult->iComplete )
+            {
+            aContent->complete = new ( ELeave ) pcdata_t();
+            }
+        AppendProgressL( aContent, aResult->iProgress );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::AppendInstallResultsL()
+// Appends an Install -element from the reply data of PCCS
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::AppendInstallResultsL( 
+    ConML_ResultsPtr_t aContent, CSConInstall* aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( aResult )
+        {
+        if ( aResult->iComplete )
+            {
+            aContent->complete = new ( ELeave ) pcdata_t();
+            }
+        AppendProgressL( aContent, aResult->iProgress );
+        }
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::AppendUninstallResultsL()
+// Appends an Uninstall -element from the reply data of PCCS
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::AppendUninstallResultsL( 
+    ConML_ResultsPtr_t aContent, CSConUninstall* aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( aResult )
+        {
+        if ( aResult->iComplete )
+            {
+            LOGGER_WRITE( "CSConPCConnSession::AppendUninstallResultsL() Complete" );
+            aContent->complete = new ( ELeave ) pcdata_t();
+            }
+        LOGGER_WRITE_1( "CSConPCConnSession::AppendUninstallResultsL() iProgress: %d", aResult->iProgress );
+        AppendProgressL( aContent, aResult->iProgress );
+        }
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::AppendListDataOwnersResultsL()
+// Appends a List data owners -element from the reply data of PCCS
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::AppendListDataOwnersResultsL ( 
+    ConML_ResultsPtr_t aContent, CSConListDataOwners* aResult  )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( aResult )  
+        {
+        if ( aResult->iComplete )
+            {
+            aContent->complete = new ( ELeave ) pcdata_t();
+            }
+        AppendProgressL( aContent, aResult->iProgress );
+        
+        if ( aResult->iDataOwners.Count() > 0 )
+            {
+            aContent->dataOwners = new ( ELeave ) ConML_DataOwners_t();
+            for ( TInt i=0; i < aResult->iDataOwners.Count(); i ++)
+                {
+                ConML_SIDListPtr_t sid = new ( ELeave ) ConML_SIDList_t();
+                CleanupStack::PushL( sid );
+                GenericListAddL ( &aContent->dataOwners->sid, sid );
+                CleanupStack::Pop();
+            
+                sid->data = new ( ELeave ) ConML_SID_t();
+                
+                sid->data->type = new ( ELeave ) pcdata_t();
+                sid->data->type->SetDataL ( IntToDesLC ( 
+                    aResult->iDataOwners[i]->iType) );  
+                CleanupStack::PopAndDestroy(); // IntToDesLC
+                
+                sid->data->uid = new ( ELeave ) pcdata_t();
+                
+                if( aResult->iDataOwners[i]->iUid.iUid )
+                    {
+                    sid->data->uid->SetDataL ( UidToDesLC ( 
+                        aResult->iDataOwners[i]->iUid ) );
+                    CleanupStack::PopAndDestroy(); // UidToDesLC    
+                    }
+                    
+                if( aResult->iDataOwners[i]->iJavaHash )
+                    {
+                    sid->data->uid->SetDataL ( HashToDesLC ( 
+                        aResult->iDataOwners[i]->iJavaHash->Des() ) );
+                    CleanupStack::PopAndDestroy(); // HashToDesLC
+                    }
+                                
+                if ( HasDrives ( aResult->iDataOwners[i]->iDriveList ) )
+                    {
+                    sid->data->drives = new ( ELeave ) ConML_Drives_t();
+                    AppendDrivesL ( sid->data->drives, 
+                        aResult->iDataOwners[i]->iDriveList );
+                    }       
+            
+                if ( aResult->iDataOwners[i]->iPackageName.Length() > 0 ) 
+                    {
+                    sid->data->packageInfo = 
+                        new ( ELeave ) ConML_PackageInfo_t();
+                    sid->data->packageInfo->name = new ( ELeave ) pcdata_t();
+                    sid->data->packageInfo->name->SetDataL ( BufToDesLC ( 
+                        aResult->iDataOwners[i]->iPackageName  ) );
+
+                    CleanupStack::PopAndDestroy(); // BufToDesLC
+                    }           
+            
+                if ( aResult->iDataOwners[i]->iHasFiles || 
+                aResult->iDataOwners[i]->iSupportsInc ||
+                aResult->iDataOwners[i]->iDelayToPrep ||
+                aResult->iDataOwners[i]->iReqReboot )
+                    {
+                    sid->data->burOptions = new ( ELeave ) ConML_BUROptions_t();
+                    if ( aResult->iDataOwners[i]->iHasFiles ) 
+                        {
+                        sid->data->burOptions->hasFiles = 
+                            new ( ELeave ) pcdata_t();
+                        sid->data->burOptions->hasFiles->SetDataL( IntToDesLC(
+                                aResult->iDataOwners[i]->iHasFiles ));
+                                
+                        CleanupStack::PopAndDestroy(); // IntToDesLC
+                        }
+                    if ( aResult->iDataOwners[i]->iSupportsInc )
+                        {
+                        sid->data->burOptions->supportsInc = 
+                            new ( ELeave ) pcdata_t();
+                        }
+                    if ( aResult->iDataOwners[i]->iDelayToPrep )                        
+                        {
+                        sid->data->burOptions->delayToPrepareData = 
+                            new ( ELeave ) pcdata_t();
+                        }
+                    if ( aResult->iDataOwners[i]->iReqReboot )
+                        {
+                        sid->data->burOptions->requiresReboot = 
+                            new ( ELeave ) pcdata_t();
+                        }
+                    }
+                }
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::AppendGetDataOwnerStatusResultsL()
+// Appends a Get data owner status -element from the reply data of PCCS
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::AppendGetDataOwnerStatusResultsL 
+    ( ConML_ResultsPtr_t aContent, CSConGetDataOwnerStatus* aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( aResult )
+        {
+        if ( aResult->iComplete )
+            {
+            aContent->complete = new ( ELeave ) pcdata_t();
+            }
+        AppendProgressL( aContent, aResult->iProgress );
+
+        if ( aResult->iDataOwners.Count() > 0 )
+            {
+            aContent->dataOwners = new ( ELeave ) ConML_DataOwners_t();
+            for ( TInt i=0; i < aResult->iDataOwners.Count(); i ++)
+                {
+                ConML_SIDListPtr_t sid = new ( ELeave ) ConML_SIDList_t();
+                CleanupStack::PushL( sid );
+                GenericListAddL ( &aContent->dataOwners->sid, sid );
+                CleanupStack::Pop();
+            
+                sid->data = new ( ELeave ) ConML_SID_t();
+                
+                sid->data->type = new ( ELeave ) pcdata_t();
+                sid->data->type->SetDataL ( IntToDesLC ( 
+                    aResult->iDataOwners[i]->iType) );  
+                CleanupStack::PopAndDestroy(); // IntToDesLC
+                
+                sid->data->uid = new ( ELeave ) pcdata_t();
+                sid->data->uid->SetDataL ( UidToDesLC ( 
+                    aResult->iDataOwners[i]->iUid ) );
+                CleanupStack::PopAndDestroy(); // UidToDesLC    
+                
+                sid->data->dataOwnerStatus = new ( ELeave ) pcdata_t();
+                sid->data->dataOwnerStatus->SetDataL ( IntToDesLC( 
+                        aResult->iDataOwners[i]->iDataOwnStatus ));
+                
+                CleanupStack::PopAndDestroy(); // IntToDesLC
+                }
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::AppendGetDataSizeResultsL()
+// Appends a Get data owner size -element from the reply data of PCCS
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::AppendGetDataSizeResultsL ( 
+    ConML_ResultsPtr_t aContent, CSConGetDataSize* aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( aResult )  
+        {
+        if ( aResult->iComplete )
+            {
+            aContent->complete = new ( ELeave ) pcdata_t();
+            }
+        AppendProgressL( aContent, aResult->iProgress );
+        
+        if ( aResult->iDataOwners.Count() > 0 )
+            {
+            aContent->dataOwners = new ( ELeave ) ConML_DataOwners_t();
+                
+            for ( TInt i=0; i< aResult->iDataOwners.Count(); i++ )      
+                {
+                ConML_SIDListPtr_t sid = new ( ELeave ) ConML_SIDList_t();
+                CleanupStack::PushL( sid );
+                GenericListAddL ( &aContent->dataOwners->sid, sid );
+                CleanupStack::Pop();
+                
+                sid->data = new ( ELeave ) ConML_SID_t();
+                
+                sid->data->type = new ( ELeave ) pcdata_t();
+                sid->data->type->SetDataL ( IntToDesLC ( 
+                    aResult->iDataOwners[i]->iType) );  
+                CleanupStack::PopAndDestroy(); // IntToDesLC
+                    
+                sid->data->uid = new ( ELeave ) pcdata_t();
+                
+                if( aResult->iDataOwners[i]->iUid.iUid )
+                    {
+                    sid->data->uid->SetDataL ( UidToDesLC ( 
+                        aResult->iDataOwners[i]->iUid ) );
+                    CleanupStack::PopAndDestroy(); // UidToDesLC    
+                    }
+
+                if( aResult->iDataOwners[i]->iJavaHash )
+                    {
+                    sid->data->uid->SetDataL ( HashToDesLC ( 
+                        aResult->iDataOwners[i]->iJavaHash->Des() ) );
+                    CleanupStack::PopAndDestroy(); // HashToDesLC
+                    }
+    
+                if ( HasDrives (  aResult->iDataOwners[i]->iDriveList ) )
+                    {
+                    sid->data->drives = new ( ELeave ) ConML_Drives_t();
+                    AppendDrivesL ( sid->data->drives, 
+                        aResult->iDataOwners[i]->iDriveList );
+                    }       
+                
+                sid->data->size = new ( ELeave ) pcdata_t();
+                sid->data->size->SetDataL( IntToDesLC( 
+                    aResult->iDataOwners[i]->iSize ) );
+                CleanupStack::PopAndDestroy(); // IntToDesLC
+                
+                sid->data->transferDataType = new ( ELeave ) pcdata_t();
+                sid->data->transferDataType->SetDataL( IntToDesLC( 
+                        aResult->iDataOwners[i]->iTransDataType ) );
+
+                CleanupStack::PopAndDestroy(); // IntToDesLC
+                }
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::AppendGetMetadataResultsL()
+// Appends a GetMetadata -element from the reply data of PCCS
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::AppendGetMetadataResultsL(
+    ConML_ResultsPtr_t aContent, CSConGetMetadata* aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    if ( aResult )
+        {
+        if ( aResult->iComplete )
+            {
+            aContent->complete = new ( ELeave ) pcdata_t();
+            
+            // add filename only if task is completed
+            aContent->filename = new ( ELeave ) pcdata_t();
+            aContent->filename->SetDataL( BufToDesLC(aResult->iFilename ) );
+            CleanupStack::PopAndDestroy(); // BufToDesLC
+            }
+        AppendProgressL( aContent, aResult->iProgress );
+        
+        if ( aResult->iData )
+            {
+            aContent->data = new ( ELeave ) pcdata_t();
+            aContent->data->SetDataL( aResult->iData->Des() );
+            }
+        
+        if ( aResult->iMoreData )
+            {
+            aContent->moreData = new ( ELeave ) pcdata_t();
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::AppendProgressL()
+// Appends a Progress -element from the reply data of PCCS
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::AppendProgressL ( 
+    ConML_ResultsPtr_t aContent, TInt progress )
+    {
+    TRACE_FUNC_ENTRY;
+    aContent->progress = new ( ELeave ) ConML_Progress_t();
+    aContent->progress->value = new ( ELeave ) pcdata_t();
+    aContent->progress->value->SetDataL ( IntToDesLC ( progress ));
+    CleanupStack::PopAndDestroy(); // IntToDesLC
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::AppendDrivesL()
+// Appends a Drives -element from the reply data of PCCS
+// -----------------------------------------------------------------------------
+//
+void CSConPCConnSession::AppendDrivesL( 
+    ConML_DrivesPtr_t aContent, TDriveList aDrives )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    for ( TInt i = 0; i<KMaxDrives; i++ )
+        {
+        if ( aDrives[i] )
+            {
+            ConML_DriveListPtr_t drive = new ( ELeave ) ConML_DriveList_t();
+            CleanupStack::PushL ( drive );
+            GenericListAddL ( &aContent->drive, drive );
+            CleanupStack::Pop(); // drive
+            
+            drive->data = new ( ELeave ) ConML_Drive_t();
+            drive->data->name = new ( ELeave ) pcdata_t();
+            drive->data->name->SetDataL( DriveNumToDesLC(i+KSConFirstDrive  ));
+            CleanupStack::PopAndDestroy(); // IntToDesLC
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::DriveList()
+// Converts an Drives -element to TDriveList
+// -----------------------------------------------------------------------------
+//
+TDriveList CSConPCConnSession::DriveList( ConML_DriveListPtr_t aContent )
+    {
+    TBuf8<KMaxDrives>  driveBuf;
+    TDriveList driveList;
+
+    for ( ConML_DriveListPtr_t p = aContent; p && p->data; p = p->next )
+        {
+        if ( p->data->name )            
+            {
+            driveBuf.Append( p->data->name->Data() );
+            }
+        }
+
+    for ( TInt i = 0; i<KMaxDrives; i++ )
+        {
+        if ( driveBuf.Locate ( TChar( i + KSConFirstDrive ) ) != KErrNotFound )
+            {
+            driveList.Append( KSConDriveExists );
+            }
+        else
+            {
+            driveList.Append( KSConNoDrive );
+            }
+        }
+    return driveList;
+    }
+
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::IntToDesLC()
+// Converts an integer to descriptor
+// -----------------------------------------------------------------------------
+//
+TDesC8& CSConPCConnSession::IntToDesLC(const TInt& anInt)
+    {
+    HBufC8* buf = HBufC8::NewLC(20);
+    TPtr8 ptrBuf = buf->Des();
+    ptrBuf.Num(anInt);
+    return *buf;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::DriveNumToDesLC()
+// Convers a drive number to equivalent drive letter 
+// -----------------------------------------------------------------------------
+//
+TDesC8& CSConPCConnSession::DriveNumToDesLC( const TInt& anInt )
+    {
+    TChar mark ( anInt );
+    HBufC8* buf = HBufC8::NewLC(1);
+    TPtr8 ptrBuf = buf->Des();
+    ptrBuf.Append(mark);
+    return *buf;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::BufToDesLC()
+// converts a buffer to descriptor
+// -----------------------------------------------------------------------------
+//
+TDesC8& CSConPCConnSession::BufToDesLC( const TDesC& aBuf)
+    {
+    HBufC8* buf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aBuf );
+    CleanupStack::PushL( buf );
+    return *buf;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::UidToDesLC()
+// converts an UID to a descriptor
+// -----------------------------------------------------------------------------
+//
+TDesC8& CSConPCConnSession::UidToDesLC( const TUid& aUid )
+    {
+    HBufC8* buf = HBufC8::NewLC(10);
+    TPtr8 ptrBuf = buf->Des();
+    ptrBuf.Copy (aUid.Name().Mid(1, 8) );
+    return *buf;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::DesToUid()
+// converts a descriptor to a UID value
+// -----------------------------------------------------------------------------
+//
+TUid CSConPCConnSession::DesToUid ( const TDesC8& aDes )
+    {
+    TLex8 lex( aDes );
+    TUint32 value;
+    lex.Val( value, EHex );
+    TUid uid = TUid::Uid( value );
+    return uid;
+    }   
+    
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::DesToInt()
+// converts a descriptor to a integer value
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::DesToInt( const TDesC8& aDes)
+    {
+    TLex8 lex(aDes);
+    TInt value = 0;
+    lex.Val(value);
+    return value;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::HasDrives()
+// Returns ETrue if at least one drive is found from the given TDriveList
+// -----------------------------------------------------------------------------
+//
+TBool CSConPCConnSession::HasDrives( TDriveList& aDrive )
+    {
+    TBool hasDrives ( EFalse );     
+    for ( TInt i = 0; i<KMaxDrives; i++ )
+        {
+        if ( aDrive[i] )
+            {
+            hasDrives = ETrue;
+            }
+        }
+    return hasDrives;
+    }
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::HashToDesLC()
+// converts a Java hash to descriptor
+// -----------------------------------------------------------------------------
+//
+TDesC8& CSConPCConnSession::HashToDesLC( const TDesC& aBuf)
+    {
+    HBufC8* buf = HBufC8::NewLC(aBuf.Size()+5);
+    TPtr8 ptrBuf = buf->Des();
+    // Unicode conversion from 16-bit to 8-bit
+    CnvUtfConverter::ConvertFromUnicodeToUtf8(ptrBuf, aBuf);
+    //Add JAVA_ identifier to the begining of the hash
+    ptrBuf.Insert(0, KSConJavaHashId);
+    return *buf;
+    }
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::DesToHashLC()
+// converts descriptor to Java hash
+// -----------------------------------------------------------------------------
+//    
+TPtr CSConPCConnSession::DesToHashLC( const TDesC8& aDes )
+    {
+    HBufC* buf = HBufC::NewLC(aDes.Size());
+    TPtr ptrBuf = buf->Des();
+    // Unicode conversion from 8-bit to 16-bit
+    CnvUtfConverter::ConvertToUnicodeFromUtf8(ptrBuf, aDes);
+    //Delete JAVA_
+    ptrBuf.Delete(0, KSConJavaHashId().Length());   
+    return ptrBuf;
+    }
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::IsJavaHash()
+// Returns ETrue if descriptor is Java hash, else EFalse
+// -----------------------------------------------------------------------------
+//  
+TBool CSConPCConnSession::IsJavaHash( const TDesC8& aDes )
+    {
+    if ( aDes.FindC(KSConJavaHashId) == 0 )
+        {
+        return ETrue;
+        }
+    else
+        {
+        return EFalse;
+        }
+    }
+
Binary file connectivitymodules/SeCon/services/csc/bld/101F9698.xml has changed
Binary file connectivitymodules/SeCon/services/csc/bld/101F99F6.xml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/bld/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -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:  Capability Object Module bld.inf file
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS  
+DEFAULT
+
+PRJ_EXPORTS
+./101F9698.xml  /epoc32/data/Z/private/101F99F6/capability/101F9698.xml
+./fwdcomp.xml   /epoc32/data/Z/private/101F99F6/capability/fwdcomp.xml
+./101F99F6.xml  /epoc32/data/Z/private/101F99F6/capability/101F99F6.xml
+
+./101F9698.xml  /epoc32/RELEASE/winscw/udeb/Z/private/101F99F6/capability/101F9698.xml
+./fwdcomp.xml   /epoc32/RELEASE/winscw/udeb/Z/private/101F99F6/capability/fwdcomp.xml
+./101F99F6.xml  /epoc32/RELEASE/winscw/udeb/Z/private/101F99F6/capability/101F99F6.xml
+
+
+PRJ_MMPFILES
+
+sconcsc.mmp
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/bld/def/bwinscwu.def	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?CreateCSConCSCL@@YAPAVCSConCSC@@XZ @ 1 NONAME ; class CSConCSC * CreateCSConCSCL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/bld/def/eabiuu.def	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,5 @@
+EXPORTS
+	_Z15CreateCSConCSCLv @ 1 NONAME
+	_ZTI8CSConCSC @ 2 NONAME ; #<TI>#
+	_ZTV8CSConCSC @ 3 NONAME ; #<VT>#
+
Binary file connectivitymodules/SeCon/services/csc/bld/fwdcomp.xml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/bld/sconcsc.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,80 @@
+/*
+* 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:  Capability Object Module mmp file
+*
+*/
+
+
+// To get the MW_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_GENERAL_DLL
+
+TARGETPATH      sys/bin
+
+TARGET          sconcsc.dll
+TARGETTYPE      DLL
+UID             0x10009D8D 0x101F9698
+
+#if defined(ARMCC)
+DEFFILE	./def/eabiu
+#elif defined(WINSCW) 
+DEFFILE	./def/bwinscw
+#elif defined(WINS)
+DEFFILE	./def/bwins
+#elif defined(ARM)
+DEFFILE	./def/bmarm
+#endif
+
+SOURCEPATH      ../src
+SOURCE          sconcsc.cpp
+SOURCE          capinfo.cpp
+SOURCE          caputils.cpp
+SOURCE          caplist.cpp
+SOURCE          stringlist.cpp
+SOURCE          capparser.cpp
+SOURCE          sconsyncservice.cpp
+SOURCE          sconversioninfo.cpp 
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc
+
+// Default system include paths for middleware layer modules.
+//MW_LAYER_SYSTEMINCLUDE
+APP_LAYER_SYSTEMINCLUDE
+
+DEBUGLIBRARY    flogger.lib
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib
+LIBRARY         bafl.lib
+LIBRARY         sysutil.lib
+LIBRARY         etel.lib
+LIBRARY         etelmm.lib
+LIBRARY         hal.lib
+LIBRARY         platformenv.lib
+LIBRARY         charconv.lib
+LIBRARY	        customapi.lib
+LIBRARY	        centralrepository.lib
+LIBRARY         apgrfx.lib
+LIBRARY         apparc.lib
+LIBRARY         sisregistryclient.lib
+LIBRARY         SyncMLClientAPI.lib
+LIBRARY         javaregistryclient.lib
+LIBRARY         sysversioninfo.lib
+LIBRARY         Etel3rdParty.lib
+LIBRARY         platformver.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/inc/capability.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,483 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Capability service controller
+*
+*/
+
+
+#ifndef _CAPABILITY_H_
+#define _CAPABILITY_H_
+
+#include <e32std.h>
+
+//
+// string sizes
+//
+const TInt KBufSize(128);
+const TInt KTagSize(64);
+const TInt KMaxSize(512);
+
+const TInt KNestingLimit(10);
+
+//
+// this directory contains xml-format files for
+// Service-elements
+//
+_LIT(KCapabilityDirC, "c:\\private\\101F99F6\\capability\\");
+_LIT(KCapabilityDirCImport, "c:\\private\\101F99F6\\import\\");
+_LIT(KCapabilityDirZ, "z:\\private\\101F99F6\\capability\\");
+
+//
+// folder service constants
+//
+_LIT(KFolderServiceName, "Folder-Browsing");
+_LIT(KFolderServiceUid, "F9EC7BC4-953c-11d2-984E-525400DC9E09");
+_LIT(KFolderServiceVersion, "1.0");
+_LIT(KFolderServiceType, "x-obex/folder-listing");
+_LIT(KFolderMemoryTypeTag, "MemType");
+_LIT(KFolderNameTag, "Folder");
+
+_LIT(KFolderImages, "Images");
+_LIT(KFolderGraphics, "Graphics");
+_LIT(KFolderTones, "Tones");
+_LIT(KFolderMusic, "Music");
+_LIT(KFolderVideos, "Videos");
+_LIT(KFolderInstalls, "Installs");
+
+_LIT( KSyncSolutionsServiceName, "SyncSolutions" );
+_LIT( KSyncSolutionsServiceVersion, "1.0" );
+_LIT( KSyncCalendar, "Calendar" );
+_LIT( KSyncContacts, "Contacts" );
+_LIT( KSyncSms, "Sms" );
+_LIT( KSyncBookmark, "Bookmark" );
+
+_LIT( KDesktopSync, "DesktopSync" );
+
+enum TFolderTypes
+    {
+    EFolderImages,
+    EFolderGraphics,
+    EFolderTones,
+    EFolderMusic,
+    EFolderVideos,
+    EFolderInstalls
+    };
+
+
+//
+// misc capabily document strings
+//
+_LIT(KServiceHeader,   "<!-- Capability Object Service -->");
+_LIT(KXmlVersion,      "<?xml version=\"1.0\" ?>");
+_LIT(KComment1,        "<!-- OBEX Capability Object -->");
+_LIT(KDocType,         "<!DOCTYPE Capability SYSTEM \"obex-capability.dtd\">");
+_LIT(KRootBegin,       "<Capability Version=\"1.0\">");
+_LIT(KRootEnd,         "</Capability>");
+_LIT(KCommentBegin,    "<!--");
+_LIT(KCommentEnd,      "-->");
+_LIT(KFormatText, "  ");
+_LIT(KXmlExtension, ".xml");
+
+
+//
+// manufacturers
+//
+_LIT(KManufacturerNokia, "Nokia");
+_LIT(KManufacturerEricsson, "Ericsson");
+_LIT(KManufacturerMotorola, "Motorola");
+_LIT(KManufacturerPanasonic, "Panasonic");
+_LIT(KManufacturerPsion, "Psion");
+_LIT(KManufacturerIntel, "Intel");
+_LIT(KManufacturerCogent, "Cogent");
+_LIT(KManufacturerCirrus, "Cirrus");
+_LIT(KManufacturerLinkup, "Linkup");
+_LIT(KManufacturerTexasInstruments, "TexasInstruments");
+
+
+//
+// media types (TMediaType in e32std.h)
+//
+_LIT(KMediaMMC, "MMC");     // memory card
+_LIT(KMediaFlash, "DEV");   // device memory
+
+//
+// TElementType contains all element types used in 
+// capabilty xml document
+//
+//
+enum TElementType
+    {
+    ECapability,
+    EGeneral,
+    EManufacturer,
+    EModel,
+    ESN,
+    EOEM,
+    ESW,
+    EFW,
+    EHW,
+    ELanguage,
+    EMemory,
+    EMemType,
+    ELocation,
+    EFree,
+    EUsed,
+    EShared,
+    EFileSize,
+    EFolderSize,
+    EFileNLen,
+    EFolderNLen,
+    ECaseSenN,
+
+    EExt,
+    EXNam,
+    EXVal,
+    
+    EObject,
+    EType,
+    EName_Ext,
+    ESize,
+
+    EAccess,
+    EProtocol,
+    EEndpoint,
+    ETarget,
+
+    EInbox,
+    EService,   
+    EName,
+    EUUID,
+    EVersion,
+
+    EAttVersion,
+    EAttDate,
+    
+    EAttCurrentNetwork,
+    EAttHomeNetwork,
+    EAttCountryCode
+    };
+
+
+
+
+//
+// KXmlTokens contains all tokens (=tags) used in 
+// capabilty xml document
+//
+//
+
+typedef const TText*  TTag;
+NONSHARABLE_STRUCT( TXmlToken )
+    {
+    TInt id;
+    TTag tag;
+    };
+
+const TXmlToken KXmlTokens[] =
+    {
+    {ECapability,   _S("Capability")},
+    {EGeneral,      _S("General")},
+    {EManufacturer, _S("Manufacturer")},
+    {EModel,        _S("Model")},
+    {ESN,           _S("SN")}, 
+    {EOEM,          _S("OEM")},
+    {ESW,           _S("SW")},
+    {EFW,           _S("FW")},
+    {EHW,           _S("HW")},
+    {ELanguage,     _S("Language")},
+    {EMemory,       _S("Memory")},
+    {EMemType,      _S("MemType")},
+    {ELocation,     _S("Location")},
+    {EFree,         _S("Free")},
+    {EUsed,         _S("Used")},
+    {EShared,       _S("Shared")},
+    {EFileSize,     _S("FileSize")},
+    {EFolderSize,   _S("FolderSize")},
+    {EFileNLen,     _S("FileNLen")},
+    {EFolderNLen,   _S("FolderNLen")},
+    {ECaseSenN,     _S("CaseSenN")},
+    {EExt,          _S("Ext")},
+    {EXNam,         _S("XNam")},
+    {EXVal,         _S("XVal")},
+    {EObject,       _S("Object")},
+    {EType,         _S("Type")},
+    {EName_Ext,     _S("Name_Ext")},
+    {ESize,         _S("Size")},
+    {EAccess,       _S("Access")},
+    {EProtocol,     _S("Protocol")},
+    {EEndpoint,     _S("Endpoint")},
+    {ETarget,       _S("Target")},
+    {EInbox,        _S("Inbox")},
+    {EService,      _S("Service")},
+    {EName,         _S("Name")},
+    {EUUID,         _S("UUID")},
+    {EVersion,      _S("Version")},
+    {EXNam,             _S("XNam")},
+    {EXVal,             _S("XVal")},
+    {EAttVersion,       _S("Version")},
+    {EAttDate,          _S("Date")},
+    {EAttCurrentNetwork,_S("CurrentNetwork")},
+    {EAttHomeNetwork,   _S("HomeNetwork")},
+    {EAttCountryCode,   _S("CountryCode")}  
+    };
+
+#define NUMXMLTOKENS (sizeof(KXmlTokens)/sizeof(TXmlToken))
+
+
+
+
+//
+// string array to convert symbian TLanguage enums to 
+// ISO 639 language codes
+// 
+// See "http://www.sil.org/iso639-3/default.asp" 
+//
+
+typedef const TText*  TLangString;
+NONSHARABLE_STRUCT( TLangStringStruct )
+    {
+    TInt id;
+    TLangString lang;
+    };
+
+/**
+ * Language mapping table.
+ */
+const TLangStringStruct KLangStrings[] =
+    {
+    {ELangEnglish,   _S("en")},
+    {ELangFrench,    _S("fr")},
+    {ELangGerman,    _S("de")},
+    {ELangSpanish,   _S("es")},
+    {ELangItalian,   _S("it")},
+    {ELangSwedish,   _S("sv")},
+    {ELangDanish,    _S("da")},
+    {ELangNorwegian, _S("no")},
+    {ELangFinnish, _S("fi")},
+
+    {ELangAmerican, _S("en_US")},
+    {ELangSwissFrench, _S("fr_CH")},
+    {ELangSwissGerman, _S("de_CH")},
+    {ELangPortuguese, _S("pt")},
+    {ELangTurkish, _S("tr")},
+    {ELangIcelandic, _S("is")},
+    {ELangRussian, _S("ru")},
+    {ELangHungarian, _S("hu")},
+    {ELangDutch, _S("nl")},
+    
+    {ELangBelgianFlemish, _S("nl_BE")},
+    {ELangAustralian, _S("aus")},
+    {ELangBelgianFrench, _S("fr_BE")},
+    {ELangAustrian, _S("de_AT")},
+    {ELangNewZealand, _S("en_NZ")},
+    {ELangInternationalFrench, _S("fr")},
+    {ELangCzech, _S("cs")},
+    {ELangSlovak, _S("sk")},
+    {ELangPolish, _S("pl")},
+    
+    {ELangSlovenian, _S("sl")},
+    {ELangTaiwanChinese, _S("zh_TW")},
+    {ELangHongKongChinese, _S("zh_HK")},
+    {ELangPrcChinese, _S("zh_CN")},
+    {ELangJapanese, _S("ja")},
+    {ELangThai, _S("th")},
+    {ELangAfrikaans, _S("af")},
+    {ELangAlbanian, _S("sq")},
+    {ELangAmharic, _S("am")},
+    
+    {ELangArabic, _S("ar")},
+    {ELangArmenian, _S("hy")},
+    {ELangTagalog, _S("tl")},
+    {ELangBelarussian, _S("be")},
+    {ELangBengali, _S("bn")},
+    {ELangBulgarian, _S("bg")},
+    {ELangBurmese, _S("my")},
+    {ELangCatalan, _S("ca")},
+    {ELangCroatian, _S("hr")},
+    
+    {ELangCanadianEnglish, _S("en_CA")},
+    {ELangInternationalEnglish, _S("en")},
+    {ELangSouthAfricanEnglish, _S("en_ZA")},
+    {ELangEstonian, _S("et")},
+    {ELangFarsi, _S("fa")},
+    {ELangCanadianFrench, _S("fr_CA")},
+    {ELangScotsGaelic, _S("gd")},
+    {ELangGeorgian, _S("ka")},
+    {ELangGreek, _S("el")},
+    
+    {ELangCyprusGreek, _S("el_CY")},
+    {ELangGujarati, _S("gu")},
+    {ELangHebrew, _S("he")},
+    {ELangHindi, _S("hi")},
+    {ELangIndonesian, _S("id")},
+    {ELangIrish, _S("ga")},
+    {ELangSwissItalian, _S("it_CH")},
+    {ELangKannada, _S("kn")},
+    {ELangKazakh, _S("kk")},
+    
+    {ELangKhmer, _S("km")},
+    {ELangKorean, _S("ko")},
+    {ELangLao, _S("lo")},
+    {ELangLatvian, _S("lv")},
+    {ELangLithuanian, _S("lt")},
+    {ELangMacedonian, _S("mk")},
+    {ELangMalay, _S("ms")},
+    {ELangMalayalam, _S("ml")},
+    {ELangMarathi, _S("mr")},
+    
+    {ELangMoldavian, _S("mo")},
+    {ELangMongolian, _S("mn")},
+    {ELangNorwegianNynorsk, _S("nn")},
+    {ELangBrazilianPortuguese, _S("pt_BR")},
+    {ELangPunjabi, _S("pa")},
+    {ELangRomanian, _S("ro")},
+    {ELangSerbian, _S("sr")},
+    {ELangSinhalese, _S("si")},
+    {ELangSomali, _S("so")},
+    
+    {ELangInternationalSpanish, _S("es")},
+    {ELangLatinAmericanSpanish, _S("es_US")},
+    {ELangSwahili, _S("sw")},
+    {ELangFinlandSwedish, _S("sv_FI")},
+    {ELangReserved1, _S("en")},  
+    {ELangTamil, _S("ta")},
+    {ELangTelugu, _S("te")},
+    {ELangTibetan, _S("bo")},
+    {ELangTigrinya, _S("ti")},
+    
+    {ELangCyprusTurkish, _S("tr_CY")},
+    {ELangTurkmen, _S("tk")},
+    {ELangUkrainian, _S("uk")},
+    {ELangUrdu, _S("ur")},
+    {ELangReserved2, _S("en")},
+    {ELangVietnamese, _S("vi")},
+    {ELangWelsh, _S("cy")},
+    {ELangZulu, _S("zu")},
+    {ELangOther, _S("other")},
+    
+    {ELangManufacturerEnglish, _S("en")},
+    {ELangSouthSotho, _S("st")},
+    {ELangBasque, _S("eu")},
+    {ELangGalician, _S("gl")},
+    {ELangJavanese, _S("jv")},
+    {ELangMaithili, _S("bh")},
+    {ELangAzerbaijani_Latin, _S("az")},
+    {ELangAzerbaijani_Cyrillic, _S("az")},
+    {ELangOriya, _S("or")},
+    {ELangBhojpuri, _S("bh")},
+    {ELangSundanese, _S("su")},
+    {ELangKurdish_Latin, _S("ku")},
+    {ELangKurdish_Arabic, _S("ku")},
+    {ELangPashto, _S("ps")},
+    {ELangHausa, _S("ha")},
+    {ELangOromo, _S("om")},
+    {ELangUzbek_Latin, _S("uz")},
+    {ELangUzbek_Cyrillic, _S("uz")},
+    {ELangSindhi_Arabic, _S("sd")},
+    {ELangSindhi_Devanagari, _S("sd")},
+    {ELangYoruba, _S("yo")},
+    {ELangCebuano, _S("ceb")},
+    {ELangIgbo, _S("ig")},
+    {ELangMalagasy, _S("mg")},
+    {ELangNepali, _S("ne")},
+	{ELangAssamese, _S("as")},
+    {ELangShona, _S("sn")},
+    {ELangZhuang, _S("za")},
+    {ELangMadurese, _S("mad")},
+    
+    {ELangEnglish_Apac, _S("en")},
+    {ELangEnglish_Taiwan, _S("en")},
+    {ELangEnglish_HongKong, _S("en")},
+    {ELangEnglish_Prc, _S("en")},
+    {ELangEnglish_Japan, _S("en")},
+    {ELangEnglish_Thailand, _S("en")},
+    
+	{ELangFulfulde, _S("ff")},
+    {ELangTamazight, _S("ber")},
+    {ELangBolivianQuechua, _S("qu")},
+    {ELangPeruQuechua, _S("qu")},
+    {ELangEcuadorQuechua, _S("qu")},
+    {ELangTajik_Cyrillic, _S("tg")},
+    {ELangTajik_PersoArabic, _S("tg")},
+    {ELangNyanja, _S("ny")},
+    {ELangHaitianCreole, _S("ht")},
+    {ELangLombard, _S("lmo")},
+    {ELangKoongo, _S("kg")},
+    {ELangAkan, _S("ak")},
+    {ELangHmong, _S("hmn")},
+    {ELangYi, _S("ii")},
+    {ELangTshiluba, _S("lu")},
+    {ELangIlocano, _S("ilo")},
+    {ELangUyghur, _S("ug")},
+    {ELangNeapolitan, _S("nap")},
+    {ELangRwanda, _S("rw")},
+    {ELangXhosa, _S("xh")},
+    {ELangBalochi, _S("bal")},
+    {ElangHiligaynon, _S("hil")},
+    {ELangMinangkabau, _S("min")},
+    {ELangMakhuwa, _S("vmw")},
+    {ELangSantali, _S("sat")},
+    {ELangGikuyu, _S("ki")},
+    {ELangMoore, _S("mos")},
+    {ELangGuarani, _S("gnHI")},
+    {ELangRundi, _S("ru")},
+    {ELangRomani_Latin, _S("rom")},
+    {ELangRomani_Cyrillic, _S("rom")},
+    {ELangTswana, _S("tn")},
+    {ELangKanuri, _S("kr")},
+    {ELangKashmiri_Devanagari, _S("ks")},
+    {ELangKashmiri_PersoArabic, _S("ks")},
+    {ELangUmbundu, _S("umb")},
+    {ELangKonkani, _S("kok")},
+    {ELangBalinese, _S("ban")},
+    {ELangNorthernSotho, _S("nso")},
+    {ELangWolof, _S("wo")},
+    {ELangBemba, _S("bmy")}, 	 	 	
+    {ELangTsonga, _S("ts")},
+    {ELangYiddish, _S("yi")},
+    {ELangKirghiz, _S("ky")},
+    {ELangGanda, _S("lg")},
+    {ELangSoga, _S("xog")},
+    {ELangMbundu, _S("kmb")},
+    {ELangBambara, _S("bm")},
+    {ELangCentralAymara, _S("ay")},
+    {ELangZarma, _S("dje")},
+    {ELangLingala, _S("ln")},
+    {ELangBashkir, _S("ba")},
+    {ELangChuvash, _S("cv")},
+    {ELangSwati, _S("ss")},
+    {ELangTatar, _S("tt")},
+    {ELangSouthernNdebele, _S("nr")},
+    {ELangSardinian, _S("sc")},
+    {ELangScots, _S("sco")},
+    {ELangMeitei, _S("mni")},
+    {ELangWalloon, _S("wa")},
+    {ELangKabardian, _S("kbd")},
+    {ELangMazanderani, _S("mzn")},
+    {ELangGilaki, _S("glk")},
+    {ELangShan, _S("shn")},
+    {ELangLuyia, _S("luy")},
+    {ELanguageLuo, _S("luo")},
+    {ELangSukuma, _S(" 	suk")},
+    {ELangAceh, _S("ace")},
+    {ELangMalay_Apac, _S("ms")}
+    };
+
+#define NUMLANGSTRINGS (sizeof(KLangStrings)/sizeof(TLangStringStruct))
+
+
+
+
+#endif // capability.h
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/inc/capinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Capability service controller
+*
+*/
+
+
+#ifndef _CAPINFO_H_
+#define _CAPINFO_H_
+
+#include <e32base.h>
+#include <f32file.h>
+
+#include "caputils.h"
+
+//
+// CCapInfo creates capability document
+// 
+//
+
+class CCapList;
+class CStringList;
+class TSConSolutionInfo;
+class CSconVersionInfo;
+
+NONSHARABLE_CLASS( CCapInfo ) : public CBase
+{
+public:
+    static CCapInfo* NewL();        
+    ~CCapInfo();
+private:
+    CCapInfo();
+    void ConstructL();
+
+public:
+    void CapabilityDocumentL( CBufFlat* aBuf );
+
+private:
+    CCapList* CapList();
+    void SetCapabilityBuf( CBufFlat* aBuf );
+    
+    void GeneralInfoL();
+    void MemoryInfoL();
+    void WriteMemoryInfoL( TMemoryInfo& aInfo );
+    void ServiceInfoL( const TDesC& aDir, const RArray<TFileName>& aExcludeList,
+        RArray<TFileName>& aFilesAdded );
+    void FolderServiceL();
+    
+    void SyncSolutionsServiceL();
+    void WriteSyncSolutionsServiceL( const TSConSolutionInfo& aCalendar,
+    		const TSConSolutionInfo& aContact,
+    		const TSConSolutionInfo& aSms,
+    		const TSConSolutionInfo& aBookmark );
+    void WriteSolutionTagL( const TDesC& aContentName, const TSConSolutionInfo& aSolution );
+    
+    void WriteFolderL( const TDesC& aType, const TDesC& aFullName, const TDesC& aMemory );
+
+    void WriteValueL( TInt aId, const TDesC& aValue );
+    void WriteBigValueL( TInt aId, const TDesC& aValue );
+    void WriteValueL( TInt aId, TInt64 aValue );
+    void WriteTagL( TInt aId, TInt aType );
+    void WriteAttributeL( TInt aId, const TDesC& aVersion, const TDesC& aDate );
+    void WriteL( const TDesC& aText );
+
+    void WriteFromListL( CStringList* aList );
+    void WriteNewLineL();
+
+    void FormatElement( TDes& aText );
+    void AddFormatText( TDes& aText, TInt aNum ) const;
+
+private:
+    RFs             iFsSession;     // has
+    CCapList*       iCapList;       // has
+    HBufC8*         iHeapBuf;       // has
+    TBuf<KMaxSize>  iBuf;
+    TIdStack        iIdStack;
+
+    CBufFlat*       iCapabilityBuf; // uses
+    CSconVersionInfo* iSconInfo;
+};
+
+#endif // CCapability
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/inc/caplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,107 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CCapList header file.
+*
+*/
+
+
+#ifndef _CAPLIST_H_
+#define _CAPLIST_H_
+
+// INCLUDES
+
+#include <e32base.h>
+#include <badesca.h>
+#include "stringlist.h"
+
+//
+// Class CCapList
+//
+NONSHARABLE_CLASS( CCapList ) : public CBase
+{
+public:
+    /**
+     * Two-phase constructor.
+     * @return CCapList instance
+     */
+    static CCapList* NewL();
+    /**
+     * Destructor
+     * @return none
+     */
+    ~CCapList();
+
+private:
+    /**
+     * Constructor
+     * @return none
+     */
+    CCapList();
+    /**
+     * Initializes the member data
+     * @return none
+     */
+    void ConstructL();
+    /**
+     * Operator =
+     * @param aList The data to be copied
+     * @return none
+     */
+    void operator=(const CCapList& aList); // not allowed
+
+public:
+    /**
+     * Returns the list
+     * @return The CStringList object
+     */
+    CStringList* List();
+
+public:
+    /**
+     * Find element
+     * @param aId
+     * @param aType
+     * @param aIndex (Default=0)
+     * @return position
+     */
+    TInt Find(TInt aId, TInt aType, TInt aIndex=0);
+    /**
+     * Find from mark
+     * @param aId
+     * @param aType
+     * @return position
+     */
+    TInt FindFromMark(TInt aId, TInt aType);
+    /**
+     * Finds service xml-file identification header. This header must be the first 
+     * line in every service file.
+     * @return ETrue if service header found
+     */
+    TBool FindServiceHeader();
+    /**
+     * Find service
+     * @param aList The source list
+     * @return ETrue if Service is found
+     */
+    TBool FindServiceL(CStringList* aList);
+
+private:
+    CStringList*   iList;           // has
+};
+
+#endif 
+
+// End of file
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/inc/capparser.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,296 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CapParser header file
+*
+*/
+
+
+
+#ifndef _CAPPARSER_H_
+#define _CAPPARSER_H_
+
+// INCLUDES
+
+#include <e32base.h>
+#include <badesca.h>
+
+//
+// Class CapParser
+//
+NONSHARABLE_CLASS( CapParser )
+    {
+
+public:
+    /**
+     * Parses element's id and type (eg. "<Memory>" -> EMemory, EElementBegin)
+     * @param aText
+     * @param aId
+     * @param aType
+     * @return none
+     */
+    static void ParseElement(const TDesC& aText, TInt& aId, TInt& aType);
+    
+public:
+    /**
+     * Constructs element with value (eg. "<Free>23456</Free>").
+     * @param aText
+     * @param aId
+     * @param aValue
+     * @return none
+     */
+    static void MakeElementL(TDes& aText, TInt aId, const TDesC& aValue);   
+    /**
+     * Constructs element without value (eg. "<Memory>" or "</Memory>").
+     * @param aText
+     * @param aId
+     * @param aType
+     * @return none
+     */
+    static void MakeElementL(TDes& aText, TInt aId, TInt aType);
+    /**
+     * Constructs element with attributes "Version" and "Date"(eg. 
+     * "<FW Version="2.2"/>").
+     * @param aText
+     * @param aId
+     * @param aVersion
+     * @param aDate
+     * @return none
+     */
+    static void MakeElementL(TDes& aText, TInt aId, const TDesC& aVersion, 
+                            const TDesC& aDate);
+    /**
+     * Constructs element with attributes
+     * @param aText
+     * @param aId
+     * @param aAttributes
+     * @return none
+     */
+    static void MakeElementL(TDes& aText, TInt aId, CDesCArrayFlat* aAttributes);
+    
+public:
+    /**
+     * Returns capability element id (eg. EMemory).
+     * @param aText
+     * @return none
+     */
+    static TInt ElementId(const TDesC& aText);
+    /**
+     * Returns capability element tag (eg. "Memory").
+     * @param aText
+     * @param aId
+     * @return none
+     */
+    static void GetTagL(TDes& aText, TInt aId);
+    
+private:
+    /**
+     * Replaces special characters to xml compliant.
+     * @param aText
+     * @param aValue
+     * @return none
+     */
+    static void ReplaceSpecialCharsL( TDes& aText, const TDesC& aValue );
+    };
+
+
+//
+// Class TXmlParser
+//
+NONSHARABLE_CLASS( TXmlParser )
+    {
+
+public:
+    enum TElementType
+        {
+        EElementValue,
+        EElementBegin,
+        EElementEnd,
+        EElementEmpty,
+        EElementAtt,
+        EElementComment,
+        EElementVersion,
+        EElementDocType,
+        EElementUnknown
+        };
+
+
+public:
+    /**
+     * Sets a tag
+     * @param aText The tag
+     * @return none
+     */
+    void Set(const TDesC& aText);
+    /**
+     * Returns type
+     * @return type
+     */
+    TInt Type() const;
+    /**
+     * Returns a pointer to a tag
+     * @return The tag pointer
+     */
+    TPtrC Tag() const;
+    /**
+     * Gets the tag
+     * @param aText The tag buffer
+     * @return none
+     */
+    void GetTag(TDes& aText) const;
+
+private:
+    /**
+     * Parses value (eg. <Language>en</Language>)
+     * @return Operation success
+     */
+    TBool ElementValue();
+    /**
+     * Parses beginning tag (eg. <General>)
+     * @return Operation success
+     */
+    TBool ElementBegin();
+    /**
+     * Parses ending tag (eg. </General>)
+     * @return Operation success
+     */
+    TBool ElementEnd();
+    /**
+     * Parses empty element (eg. <CaseSenN/>)
+     * @return Operation success
+     */
+    TBool ElementEmpty();
+    /**
+     * Parses attribute element (eg. <HW Version="1.5"/>)
+     * Note: Attribute values cannot contain equals (=) or quotations (")
+     * @return Operation success
+     */
+    TBool ElementAtt();
+    /**
+     * Identifies comment element ("<!-- OBEX Capability Object -->").
+     * @return Operation success
+     */
+    TBool ElementComment();
+    /**
+     * Parses unknown elements
+     * @return Operation success
+     */
+    TBool ElementUnknown();
+    /**
+     * Identifies version element ("<?xml version="1.0" ?>") 
+     * @return Operation success
+     */
+    TBool ElementVersion();
+    /**
+     * Identifies document type element 
+     * ("<!DOCTYPE Capability SYSTEM "obex-capability.dtd">").
+     * @return Operation success
+     */
+    TBool ElementDocType();
+
+private:
+    /**
+     * Inits the parser
+     * @return none
+     */
+    void Init();
+    /**
+     * Parses xml-element.  
+     * @return none
+     */
+    void Parse();
+
+public:
+    /**
+     * Validates the character
+     * @param aChar The char to be validated.
+     * @return ETrue if the char is valid
+     */
+    static TBool ValidChar(const TChar aChar);
+    /**
+     * Validates the tag
+     * @param aText The tag to be validated.
+     * @return ETrue if the tag is valid
+     */
+    static TBool ValidTag(const TDesC& aText);
+    /**
+     * Returns the number of characters (aChar)
+     * @param aText The buffer
+     * @param aChar The character
+     * @return The number of characters
+     */
+    static TInt Count(const TDesC& aText, const TChar aChar);
+    /**
+     * Returns the position of the first non space character
+     * @param aText The buffer
+     * @return The position
+     */
+    static TInt FirstNonSpace(const TDesC& aText);
+    /**
+     * Returns the position of the last non space character
+     * @param aText The buffer
+     * @return The position
+     */
+    static TInt LastNonSpace(const TDesC& aText);
+    /**
+     * Function returns a sub-string between aPos1 and aPos2
+     * @param aText The buffer
+     * @param aText Start position
+     * @param aText End position
+     * @return The pointer to the substring
+     */
+    static TPtrC SubStr(const TDesC& aText, TInt aPos1, TInt aPos2);
+    /**
+     * Function performs string copy with length checking.
+     * @param aTarget Target buffer
+     * @param aSource Source buffer
+     * @return none
+     */
+    static void StrCopy(TDes& aTarget, const TDesC& aSource);
+
+private:    
+    /**
+     * Returns a string
+     * @return A pointer to a string
+     */
+    TPtrC Str() const;
+    /**
+     * Trimmer function
+     * @return none
+     */
+    void TrimOriginal();
+    /**
+     * Function returns sub string between aPos1 and aPos2
+     * @param aPos1 Start position
+     * @param aPos2 End posiotion
+     * @return none
+     */
+    TPtrC SubStr(TInt pos1, TInt pos2);
+
+private:
+    TPtrC iOriginal;
+    TPtrC iText;
+    TPtrC iTag;
+    TPtrC iValue;
+    TInt  iType;
+
+    TInt iSlash;
+    TInt iFirst;
+    TInt iLast;
+    };
+
+#endif 
+
+// End of file
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/inc/caputils.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,252 @@
+/*
+* 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:  CapUtil header file
+*
+*/
+
+
+// INCLUDES
+
+#ifndef _CAPUTILS_H_
+#define _CAPUTILS_H_
+
+#include "capability.h"
+
+class RFs;
+
+//
+// TMemoryInfo
+//
+NONSHARABLE_CLASS( TMemoryInfo )
+    {
+public:
+    TChar    iDriveLetter;
+    TInt     iDriveNum;
+    TBuf<16> iLocation;
+    TInt64   iFree;
+    TInt64   iUsed;
+    TBool    iShared;
+    TInt64   iFileSize;
+    TInt64   iFolderSize;
+    TInt     iFileNameSize;
+    TInt     iFolderNameSize;
+    TBool    iCaseSensitivity;
+    TUint    iDriveStatus;
+    TInt     iMemNr;
+    };
+
+//
+// CapUtil 
+//
+NONSHARABLE_CLASS( CapUtil )
+    {
+public:
+    /**
+     * Gets default root path from pathinfo. 
+     * @param aText
+     * @param aType
+     * @return none
+     */
+    static void GetDefaultRootPathL( RFs& aFs, TDes& aRootPath );
+    
+    /**
+     * Gets memory type. 
+     * @param aFs
+     * @param aMemoryType
+     * @param aDrive
+     * @return none
+     */
+    static void GetMemoryType( RFs& aFs, TDes& aMemoryType, const TInt aDrive );
+    
+    /**
+     * Gets language
+     * @param aText
+     * @return none
+     */
+    static void GetLanguage( TDes& aText );
+    
+    /**
+     * Gets SW version, SW version date  and device model from SysUtil. 
+     * @param aVersion SW version
+     * @param aDate SW date
+     * @param aModel Device model
+     * @return none
+     */
+    static void GetSWVersionL( TDes& aVersion, TDes& aDate, TDes& aModel );
+    
+    /**
+     * Gets phone manufacturer from HAL. In case manufacturer is not known,
+     * empty value is used.
+     * @param aText Manufacturer
+     * @return none
+     */
+    static void GetManufacturer( TDes& aText );
+    
+    /**
+     * Get memory information for one drive.
+     * @param aFs RFs handle
+     * @param aDriveNumber drive number
+     * @param aInfo Memory information
+     * @return none
+     */
+    static void GetMemoryInfoL( const RFs& aFs, const TInt aDriveNumber, TMemoryInfo& aInfo );
+    
+    /**
+     * Initializes TMemoryInfo.
+     * @param aInfo TMemoryInfo to be initialized
+     * @return none
+     */
+    static void InitMemoryInfo( TMemoryInfo& aInfo );
+    
+    /**
+     * Get language string for aId.
+     * @param aId Language id
+     * @param aText Language text
+     * @return none
+     */
+    static void GetLanguageString( TLanguage aId, TDes& aText );
+    
+    /**
+     * Finds all files in aDir.
+     * @param aFs RFs handle
+     * @param aDir Directory
+     * @param aList List of files in directory
+     * @return none
+     */
+    static void GetFileListL( const RFs& aFs, const TDesC& aDir, 
+                            RArray<TFileName>& aList );
+    
+    
+    /**
+     * Gets operator name, country code, network ID
+     * @param aLongName
+     * @param aCountryCode
+     * @param aNetworkID
+     * @return none
+     */
+    static void GetOperatorNameL( TDes& aLongName, TDes& aCountryCode, TDes& aNetworkID );
+    
+    /**
+     * Creates a panic
+     * @param aReason Panic code
+     * @return none
+     */
+    static void Panic( TInt aReason );
+    
+    /**
+     * String copy with lenght check.
+     * @param aTarget Target string
+     * @param aSource Source string
+     * @return none
+     */
+    static void StrCopy( TDes& aTarget, const TDesC& aSource );
+    
+    /**
+     * Function converts ínteger to string.
+     * @param aText string
+     * @param aNum integer
+     * @return none
+     */
+    static void IntToStr( TDes& aText, TInt64 aNum );
+    
+    /**
+     * Function converts string to integer. If string cannot be converted,
+     * error code is returned.
+     * @param aText string
+     * @param aNum integer
+     * @return error code
+     */
+    static TInt StrToInt( const TDesC& aText, TInt& aNum );
+    
+    /**
+     * Function splits string (eg "name1, name2, name3") into substrings.
+     * @param aText string
+     * @param aSeparator separator character
+     * @param aArray substrings
+     * @return none
+     */
+    static void SplitL( const TDesC& aText, const TChar aSeparator, 
+                        RArray<TPtrC>& aArray );
+    
+    /**
+     * Constructs capability date as string
+     * @param aText string
+     * @param aTime time object
+     * @return none
+     */
+    static void CapabilityDate( TDes& aText, const TTime aTime );
+    
+    /**
+     * Function parses date string of the format "dd-mm-yy".
+     * @param aText string
+     * @return time object
+     */
+    static TTime ParseDateL( const TDesC& aText );
+    
+    /**
+     * Function return TMonth presentation of integer
+     * @param aNum
+     * @return TMonth object
+     */
+    static TMonth Month( TInt aNum );
+    
+    /**
+     * Function checks file extension.
+     * @param aFile File name
+     * @param aExt extension
+     * @return boolean
+     */
+    static TBool CheckFileType( const TDesC& aFile, const TDesC& aExt );
+    };
+
+//
+//  TIdStack
+//
+NONSHARABLE_CLASS( TIdStack )
+    {
+public:
+    
+    /**
+     * Push id to the stack
+     * @param aId Id number
+     * @return none
+     */
+    void Push( TInt aId );
+    
+    /**
+     * Pop id from the stack
+     * @return id
+     */
+    TInt Pop();
+    
+    /**
+     * Size of the stack
+     * @return size
+     */
+    TInt Size() const;
+    
+    /**
+     * Reset the stack.
+     * @return none
+     */
+    void Reset();
+
+private:
+    TInt iPos;
+    TFixedArray<TInt, KNestingLimit> iArray;
+    };
+
+#endif // CapUtils.h
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/inc/sconcsc.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,61 @@
+/*
+* 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:  CSConCSC header file
+*
+*/
+
+
+// INCLUDES
+
+#ifndef _SCONCSC_H_
+#define _SCONCSC_H_
+
+#include <e32base.h>
+
+class CCapInfo;
+
+//============================================================
+// Class CSConCSC declaration
+//============================================================
+class CSConCSC : public CBase
+{
+public:
+    static CSConCSC* NewL();        
+    ~CSConCSC();
+
+public:
+    // Creates capability object and places it into aBuf.
+    // Returns system error code
+	virtual TInt CapabilityObject( CBufFlat& aBuf );
+
+private:	
+	void CapabilityObjectL( CBufFlat& aBuf );
+	
+	CSConCSC();
+    virtual void ConstructL();
+    
+private: // data
+    CCapInfo*   iCapInfo;
+    
+};
+
+IMPORT_C CSConCSC* CreateCSConCSCL();
+typedef CSConCSC* (*TSConCreateCSConCSCFunc) ();   
+
+
+#endif // SCONCSC
+
+// End of file
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/inc/sconsyncservice.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,116 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSConSyncService header file.
+*
+*/
+
+
+#ifndef _SCONSYNCSERVICE_H_
+#define _SCONSYNCSERVICE_H_
+
+#include <e32base.h>
+#include <apgcli.h>     // RApaLsSession
+#include <SyncMLClientDS.h>
+
+
+class TApaAppInfo;
+class RApaLsSession;
+class CRepository;
+
+
+class TSConSolutionInfo
+	{
+	public:
+	TSConSolutionInfo():iTime(0){}
+	public:
+	TFileName 	iSolutionName;
+	TUint		iUid;
+	TTime		iTime;
+	};
+
+/**
+ *  This class provides information about active sync solutions.
+ *
+ *  @code
+ *   CSConSyncService *syncService = CSConSyncService::NewLC();
+ *   SConSolutionInfo solutionInfo;
+ *   syncService->GetSolutionL( KSeconCalendarUid, solutionInfo );
+ *   CleanupStack::PopAndDestroy( syncService );
+ *  @endcode
+ *
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( CSConSyncService ) : public CBase
+	{
+	public:
+	static CSConSyncService* NewLC();
+	~CSConSyncService();
+	
+	/**
+     * Populate SolutionInfo according to content type.
+     *
+     * @since S60 v5.0
+     * @param aSeconContentType Contenttype to be readed
+     * @param aSolutionInfo contains founded solution info,
+     * 				        solution info is empty if not found
+     * @return none
+     */
+	void GetSolutionL( const TUint aSeconContentType, TSConSolutionInfo& aSolutionInfo );
+	
+	private:
+	
+	CSConSyncService();
+	void ConstructL();
+	
+	// Return correct providerId according to content type.
+	TSmlDataProviderId ProviderId( const TUint32 aSeconContentType ) const;
+	
+	// Parse time from text
+	TInt ParseTimestamp( TTime& aTime, const TDesC& aTimestamp ) const;
+	
+	// Get application caption.
+	void GetApplicationCaptionL( TDes& aCaption, const TUid aAppUid );
+	
+	// Search UID from installed applications, return app caption
+	void GetInstPackageCaptionL( TDes& aCaption, const TUid aPackageUid );
+	
+	// Gets last used profile for selected provider
+	void GetLastUsedProfileNameL( TDes& aProfileName, TTime& aTime,
+			const TSmlDataProviderId& aDataProviderId );
+	
+	// Gets last sync time for certain profile and provider.
+	void GetLastSyncTimeL( TTime& aTime, const TSmlProfileId aSyncProfileId,
+			const TSmlDataProviderId aDataProviderId );
+	
+	// Gets provider task id from profile
+	void GetProviderTaskL( TSmlTaskId& aProviderTask,
+			RSyncMLDataSyncProfile& aSyncProfile,
+			const TSmlDataProviderId aDataProviderId ) const;
+	
+	// Gets latest historyJob where task is correct.
+	const CSyncMLHistoryJob* LatestHistoryJob( RSyncMLHistoryLog& aHistoryLog,
+			TInt aTaskId ) const;
+	
+	// Returns ETrue if task exists in HistoryJob.
+	TBool TaskExist( const CSyncMLHistoryJob* aHistoryJob, TInt aTaskId ) const;
+	
+	private: // data
+	TBool			iApaSessionConnected;
+	RApaLsSession 	iApaSession;
+	TBool			iSyncSessionOpened;
+	RSyncMLSession 	iSyncSession;
+	CRepository* 	iRepository;
+	};
+
+#endif // _SCONSYNCSERVICE_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/inc/sconversioninfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,116 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handles version fetching
+*
+*/
+
+
+#ifndef SCONVERSIONINFO_H_
+#define SCONVERSIONINFO_H_
+
+#include <e32base.h>
+#include <sysversioninfo.h>
+#include <versioninfo.h>
+#include <etelmm.h>
+#include <sysutil.h>
+
+const TInt KSconSWVersionSize = 50;
+const TInt KSconDateSize = 16;
+const TInt KMaxLangSize = 5;
+
+NONSHARABLE_CLASS( CSconVersionInfo ) : public CBase
+{
+public:
+	CSconVersionInfo();
+	~CSconVersionInfo();
+	
+	static CSconVersionInfo* NewL();
+	
+	/**
+	 * 
+	 * @param aFs RFs session
+	 * @return none.
+	 */
+	void FetchInfoL( RFs& aFs );
+	
+	/**
+	 *  Is all data ready.
+	 *  @return ETrue if FetchInfoL has been called succesfully.
+	 */
+	TBool IsReady();
+	
+	/**
+	 * Get symbian version. FetchInfoL must be called first
+	 * @param aSymbianVersion symbian version
+	 * @return error code.
+	 */
+	TInt GetSymbianVersion( SysVersionInfo::TSymbianOSVersion& aSymbianVersion );
+	
+	/**
+     * Get S60 platform version. FetchInfoL must be called first
+     * @param aS60Version S60 platform version
+     * @return error code.
+     */
+    TInt GetS60Version( VersionInfo::TPlatformVersion& aS60Version );
+    
+public: // data
+    
+    /**  Contains the manufacturer name. For example "Nokia". */
+    HBufC* iManufacturer;
+
+    /**  Contains the phone model sales name. For example "N01". */
+    HBufC* iModel;
+
+    /**  Contains the product code name. For example "RM-1". */
+    HBufC* iProduct;
+
+    /**  Contains the product revision. For example "01". */
+    HBufC* iRevision;
+    
+    TBuf< KSconDateSize > iDate;
+    
+    HBufC* iSWVersion;
+    
+    /** Phone serial number (IMEI or ESN), in character string format. */
+    HBufC* iSerialNumber;
+    
+    TBuf<KMaxLangSize> iLanguage;
+    
+    HBufC* iSysVersionInfo;
+    
+    HBufC* iLangVersion;
+    
+    HBufC* iLangSWVersion;
+    
+    HBufC* iOPVersion;
+    
+    TSize iScreenSize;
+    
+    HBufC* iProductCode;
+    
+    TInt iDesktopSyncError;
+    TInt iDesktopSync;
+    
+private:
+    TBool iInfoFetched; // ETrue if FetchInfoL has been called succesfully.
+    
+    TInt iSymbianVersionError;
+    SysVersionInfo::TSymbianOSVersion iSymbianVersion;
+    
+    TInt iS60VersionError;
+    VersionInfo::TPlatformVersion iS60Version;
+    
+};
+
+#endif /*SCONVERSIONINFO_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/inc/stringlist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,142 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CStringList header file
+*
+*/
+
+
+#ifndef _STRINGLIST_H_
+#define _STRINGLIST_H_
+
+// INCLUDES
+
+#include <e32base.h>
+#include <badesca.h>  // for CDesCArrayFlat
+#include <f32file.h>
+
+//
+// CStringList is used for storing lines of text.
+//
+NONSHARABLE_CLASS( CStringList ) : public CBase
+{
+public:
+    /**
+     * Two-phase constructor. The created instance is placed to cleanup stack
+     * @param aFileName Default KNullDesC
+     * @return CStringList instance
+     */
+    static CStringList* NewLC();
+    /**
+     * Two-phase constructor.
+     * @param aFileName Default KNullDesC
+     * @return CStringList instance
+     */
+    static CStringList* NewL();
+    /**
+     * Destructor
+     * @return none
+     */
+    ~CStringList();
+    
+public:
+    /**
+     * Returns the count of lines
+     * @return The count
+     */
+    TInt Count() const;
+    /**
+     * Returns pointer to the string
+     * @param aIndex The position
+     * @return String pointer
+     */
+    TPtrC16 ReadPtr(TInt aIndex);
+    /**
+     * Copies a string / strings
+     * @param aSource Source buffer
+     * @param aStart A start position
+     * @param aStop A stop position
+     * @return none
+     */
+    void CopyL(CStringList* aSource, TInt aStart, TInt aStop);
+    /**
+     * Resets iLines
+     * @return none
+     */
+    void Reset();
+    /**
+     * Returns the mark
+     * @return Mark value
+     */
+    TInt Mark() const;
+    /**
+     * Sets mark
+     * @param aMark The mark value
+     * @return none
+     */
+    void SetMark(TInt aMark);
+    /**
+     * Read strings from file.
+     * @param aText The tag buffer
+     * @return none
+     */
+    void ReadFromFileL( RFs& aFs, const TDesC& aName );
+
+private:
+    /**
+     * Default constuctor
+     * @return none
+     */
+    CStringList();
+    /**
+     * Initializes member data
+     * @param aFileName The file name
+     * @return none
+     */
+    void ConstructL();
+    /**
+     * Creates a panic
+     * @param aPanic Panic code
+     * @return none
+     */
+    void Panic(TInt aPanic) const;
+    /**
+     * Copies the string
+     * @param aTarget Target string
+     * @param aSource Source string
+     * @return ETrue if successful
+     */
+    TBool StrCopy(TDes& aTarget, const TDesC& aSource) const;
+    /**
+     * Writes a string
+     * @param aText The string
+     * @return none
+     */
+    void WriteL(const TDesC& aText);
+    /**
+     * Internalizes from file
+     * @param aFileName The name of the file
+     * @return none
+     */
+    void InternalizeL( RFs& aFs, const TDesC& aFileName );
+
+private:
+    TInt            iMark; 
+    CDesCArrayFlat* iLines;
+};
+
+#endif
+
+// End of file
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/src/capinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1031 @@
+/*
+* 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:  CCapInfo implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <utf.h>
+#include <driveinfo.h>
+#include <pathinfo.h>    // for PathInfo::SoundsPath
+#include <seconsdkcrkeys.h>
+#include "sconsyncservice.h"
+#include "capinfo.h"
+#include "caplist.h"
+#include "capparser.h"
+#include "caputils.h"
+#include "stringlist.h"
+#include "sconversioninfo.h"
+#include "debug.h"
+
+
+_LIT8( KLineFeed, "\r\n" );
+
+const TInt KDefaultArrayGranularity = 5;
+
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CCapInfo::NewL()
+// Two-phase constructor
+// -----------------------------------------------------------------------------
+//
+CCapInfo* CCapInfo::NewL()
+    {
+    TRACE_FUNC_ENTRY;
+    CCapInfo* self = new (ELeave) CCapInfo();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+    
+// -----------------------------------------------------------------------------
+// CCapInfo::~CCapInfo()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CCapInfo::~CCapInfo()
+    {
+    TRACE_FUNC_ENTRY;
+    iFsSession.Close();
+    delete iHeapBuf;
+    delete iCapList;
+    delete iSconInfo;
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CCapInfo::CapabilityDocumentL(CBufFlat* aBuf)
+// Creates capability xml document end places it in aBuf
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::CapabilityDocumentL(CBufFlat* aBuf)
+    {
+    TRACE_FUNC_ENTRY;
+    TInt err( KErrNone );
+    
+    // set buffer where capability document is written
+    SetCapabilityBuf( aBuf );
+    
+    WriteL( KXmlVersion );
+    WriteL( KComment1 );
+    WriteL( KDocType );
+    WriteL( KRootBegin );
+    
+    
+    //
+    // general
+    //
+    TRAP( err, GeneralInfoL() );
+    if ( err != KErrNone )
+        {
+        LOGGER_WRITE_1( "GeneralInfoL failed : %d", err );
+        User::Leave( err ); 
+        }
+    
+    
+    //
+    // services
+    //
+    // Search service files first from C-drive, and then from Z
+    // Do not add same files twice.
+    
+    RArray<TFileName> excludeList( KDefaultArrayGranularity );
+    CleanupClosePushL( excludeList );
+    RArray<TFileName> filesAdded( KDefaultArrayGranularity );
+    CleanupClosePushL( filesAdded );
+    
+    //read service files from C Import folder
+    TRAP( err, ServiceInfoL( KCapabilityDirCImport, excludeList, filesAdded ) );     
+    LOGGER_WRITE_1( "ServiceInfoL(KCapabilityDirCImport) returned : %d", err );
+    for ( TInt i=0; i<filesAdded.Count(); i++ )
+        {
+        excludeList.Append( filesAdded[i] );
+        }
+    filesAdded.Reset();
+    
+    // read service files from C Capability folder
+    TRAP( err, ServiceInfoL( KCapabilityDirC, excludeList, filesAdded ) ); 
+    LOGGER_WRITE_1( "ServiceInfoL(KCapabilityDirC) returned : %d", err );
+    for ( TInt i=0; i<filesAdded.Count(); i++ )
+        {
+        excludeList.Append( filesAdded[i] );
+        }
+    filesAdded.Reset();
+    
+    // read service files from Z Capability folder
+    TRAP( err, ServiceInfoL( KCapabilityDirZ, excludeList, filesAdded ) );
+    LOGGER_WRITE_1( "ServiceInfoL(KCapabilityDirZ) returned : %d", err );
+    
+    CleanupStack::PopAndDestroy( &filesAdded );
+    CleanupStack::PopAndDestroy( &excludeList );
+    
+        
+    // this service does not come from file
+    TRAP( err, FolderServiceL() );
+    LOGGER_WRITE_1( "FolderServiceL() returned : %d", err );
+    
+    TRAP( err, SyncSolutionsServiceL() );
+    LOGGER_WRITE_1( "SyncSolutionsServiceL() returned: %d", err );
+
+    WriteL( KRootEnd );
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CCapInfo::ConstructL()
+// Initializes member data
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    User::LeaveIfError( iFsSession.Connect() );
+    
+    iHeapBuf = HBufC8::NewL( KMaxSize*2 );
+    iCapList = CCapList::NewL();
+    iIdStack.Reset();
+    
+    iSconInfo = CSconVersionInfo::NewL();
+    TInt err(KErrNone);
+    TRAP(err, iSconInfo->FetchInfoL( iFsSession ));
+    LOGGER_WRITE_1("sconInfo->FetchInfoL() Leaved: %d", err);
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::CCapInfo()
+// Constuctor
+// -----------------------------------------------------------------------------
+//
+CCapInfo::CCapInfo()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::CapList()
+// Returns caplist
+// -----------------------------------------------------------------------------
+//
+CCapList* CCapInfo::CapList()
+    {
+    TRACE_FUNC;
+    __ASSERT_DEBUG(iCapList, CapUtil::Panic(KErrGeneral));
+    return iCapList;
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::SetCapabilityBuf( CBufFlat* aBuf )
+// Set capability buffer
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::SetCapabilityBuf( CBufFlat* aBuf )
+    {
+    TRACE_FUNC;
+    iCapabilityBuf=aBuf;
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::GeneralInfoL()
+// Write general device capability information.
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::GeneralInfoL()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt err( KErrNone );
+    TBuf<KBufSize> buf;
+    TBuf<KBufSize> longName;
+    TBuf<KBufSize> coutryCode;
+    TBuf<KBufSize> networkID;
+    
+    WriteTagL(EGeneral, TXmlParser::EElementBegin);
+    
+    if ( !iSconInfo->IsReady() )
+        {
+        LOGGER_WRITE("iSconInfo wasn't ready, call iSconInfo->FetchInfoL");
+        iSconInfo->FetchInfoL( iFsSession );
+        }
+    
+    if ( iSconInfo->iManufacturer )
+        {
+        WriteValueL( EManufacturer, *iSconInfo->iManufacturer );
+        }
+    
+    if ( iSconInfo->iProduct )
+        {
+        WriteValueL( EModel, *iSconInfo->iProduct );
+        }
+    
+    // serial number
+    if ( iSconInfo->iSerialNumber )
+        {
+        WriteValueL( ESN, *iSconInfo->iSerialNumber );
+        }
+    
+    // software version 
+    if ( iSconInfo->iSWVersion )
+        {
+        WriteAttributeL( ESW, *iSconInfo->iSWVersion, iSconInfo->iDate );
+        }
+    
+    // language
+    WriteValueL( ELanguage, iSconInfo->iLanguage );
+
+    // this must succeed - do not trap
+    MemoryInfoL();
+    
+    // Operator
+    TRAP( err, CapUtil::GetOperatorNameL( longName, coutryCode, networkID ) );
+    LOGGER_WRITE_1( "CapUtil::GGetOperatorNameL returned : %d", err );
+    if( err == KErrNone )
+        {
+        LOGGER_WRITE_3( "CSConFsHandler::GetOperatorNameL longName =  %S coutryCode = %S networkID = %S", &longName, &coutryCode, &networkID );       
+        _LIT( KNetworkInfo, "NetworkInfo" );
+        _LIT( KCurrentNetwork, "CurrentNetwork=" );
+        _LIT( KCountryCode, "CountryCode=" );
+        _LIT( KNetworkID, "NetworkID=" );
+        
+        WriteTagL( EExt, TXmlParser::EElementBegin );
+        WriteValueL( EXNam, KNetworkInfo );
+        
+        // write CurrentNetwork
+        buf.Copy( KCurrentNetwork );
+        buf.Append( longName );
+        WriteValueL( EXVal, buf );
+        
+        // write CountryCode
+        buf.Copy( KCountryCode );
+        buf.Append( coutryCode );
+        WriteValueL( EXVal, buf );
+        
+        // write NetworkID
+        buf.Copy( KNetworkID );
+        buf.Append( networkID );
+        WriteValueL( EXVal, buf );
+        
+        WriteTagL( EExt, TXmlParser::EElementEnd );     
+        }
+    
+    if ( iSconInfo->iModel )
+        {
+        // print modelname (phone model sales name. For example "N01".)
+        WriteTagL( EExt, TXmlParser::EElementBegin );
+        _LIT(KModelName, "ModelName");
+        WriteValueL( EXNam, KModelName );
+        WriteValueL( EXVal, *iSconInfo->iModel );
+        WriteTagL( EExt, TXmlParser::EElementEnd ); 
+        }
+        
+    if ( iSconInfo->iProductCode )
+        {
+        // print productcode
+        WriteTagL( EExt, TXmlParser::EElementBegin );
+        _LIT( KProductCode, "ProductCode" );
+        WriteValueL( EXNam, KProductCode );
+        WriteValueL( EXVal, *iSconInfo->iProductCode );
+        WriteTagL( EExt, TXmlParser::EElementEnd );
+        }
+    
+    
+    // print advanced info
+    WriteTagL( EExt, TXmlParser::EElementBegin );
+    _LIT(KAdvancedDeviceInfo, "AdvancedDeviceInfo");
+    WriteValueL( EXNam, KAdvancedDeviceInfo );
+    
+    TBuf<KSysVersionInfoTextLength> temp;
+    
+    if ( iSconInfo->iRevision )
+        {
+        // product revision. For example "01"
+        _LIT( KRevision, "Revision=" );
+        temp.Copy( KRevision );
+        temp.Append( *iSconInfo->iRevision );
+        LOGGER_WRITE_1( "CCapInfo::GeneralInfoL() : %S ", &temp );
+        WriteValueL( EXVal, temp );
+        }
+    
+    
+    if ( iSconInfo->iSysVersionInfo )
+        {
+        _LIT( KFWVersion, "FWVersion=" );
+        temp.Copy( KFWVersion );
+        temp.Append( *iSconInfo->iSysVersionInfo );
+        LOGGER_WRITE_1( "CCapInfo::GeneralInfoL() : %S ", &temp );
+        WriteValueL( EXVal, temp );
+        }
+    
+    SysVersionInfo::TSymbianOSVersion osVersion;
+    err = iSconInfo->GetSymbianVersion( osVersion );
+    LOGGER_WRITE_1("TSymbianOSVersion info error: %d", err)
+    if ( !err )
+        {
+        // Now osVersion contains the Symbian OS version information
+        _LIT( KSymbianOSVersion, "SymbianOSVersion=%d.%d" );
+        temp.Format( KSymbianOSVersion,
+                osVersion.iMajorVersion,
+                osVersion.iMinorVersion  );
+        LOGGER_WRITE_1( "CCapInfo::GeneralInfoL() : %S ", &temp );
+                        
+        WriteValueL( EXVal, temp );
+        }
+    
+    VersionInfo::TPlatformVersion platformVersion;
+    err = iSconInfo->GetS60Version( platformVersion );
+    if ( !err )
+       {
+       _LIT( KS60Version, "S60PlatformVersion=%d.%d" );
+       temp.Format( KS60Version,
+               platformVersion.iMajorVersion,
+               platformVersion.iMinorVersion  );
+       LOGGER_WRITE_1( "CCapInfo::GeneralInfoL() : %S ", &temp );
+       WriteValueL( EXVal, temp );
+       }
+    
+    
+    if ( iSconInfo->iLangVersion )
+        {
+        _LIT( KLangVersion, "LangVersion=" );
+        temp.Copy( KLangVersion );
+        temp.Append( *iSconInfo->iLangVersion );
+        LOGGER_WRITE_1( "CCapInfo::GeneralInfoL() : %S ", &temp );
+        WriteValueL( EXVal, temp );
+        }
+    
+    if ( iSconInfo->iLangSWVersion )
+        {
+        _LIT( KLangSWVersion, "LangSWVersion=" );
+        temp.Copy( KLangSWVersion );
+        temp.Append( *iSconInfo->iLangSWVersion );
+        LOGGER_WRITE_1( "CCapInfo::GeneralInfoL() : %S ", &temp );
+        WriteValueL( EXVal, temp );
+        }
+    
+    if ( iSconInfo->iOPVersion )
+        {
+        // CustomerVersion
+        _LIT( KOPVersion, "OPVersion=" );
+        temp.Copy( KOPVersion );
+        temp.Append( *iSconInfo->iOPVersion );
+        LOGGER_WRITE_1( "CCapInfo::GeneralInfoL() : %S ", &temp );
+        WriteValueL( EXVal, temp );
+        }
+    
+    // screen size
+    LOGGER_WRITE_2("Size, width: %d, height: %d",
+            iSconInfo->iScreenSize.iWidth,
+            iSconInfo->iScreenSize.iHeight );
+    _LIT( KWidth, "ScreenWidth=%d" );
+    _LIT( KHeight, "ScreenHeight=%d" );
+    
+    temp.Format( KWidth, iSconInfo->iScreenSize.iWidth );
+    WriteValueL( EXVal, temp );
+    
+    temp.Format( KHeight, iSconInfo->iScreenSize.iHeight );
+    WriteValueL( EXVal, temp );
+    
+    WriteTagL( EExt, TXmlParser::EElementEnd ); 
+    // end of advanced info
+    
+    WriteTagL(EGeneral, TXmlParser::EElementEnd);
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::MemoryInfoL()
+// Create memory info for all drives (RAM excluded).
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::MemoryInfoL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TMemoryInfo info;
+    TInt devDriveCount = 0;
+    TInt mmcDriveCount = 0;
+    
+    //Write all drivers to folderlisting object
+    TDriveList driveList;
+    // Get all drives that are visible to the user.
+    TInt driveCount;
+    User::LeaveIfError( DriveInfo::GetUserVisibleDrives( iFsSession, driveList, driveCount ) );
+    
+    for( TInt i = EDriveA; i < KMaxDrives; i++ )
+        {
+        if( driveList[i] )
+            {
+            TUint driveStatus;
+            TInt err = DriveInfo::GetDriveStatus( iFsSession, i, driveStatus );
+            if( err )
+                {
+                LOGGER_WRITE_1( "CCapInfo::MemoryInfoL() : DriveInfo::GetDriveStatus: %d", i);
+                continue;
+                }
+            
+            if( !(driveStatus & DriveInfo::EDrivePresent )
+                || driveStatus & DriveInfo::EDriveCorrupt
+                || (driveStatus & DriveInfo::EDriveRemote) )
+                {
+                LOGGER_WRITE_1( "skip drive %d", i);
+                continue;
+                }
+            
+            TRAP( err, CapUtil::GetMemoryInfoL( iFsSession, i, info ));
+            if ( err )
+                {
+                LOGGER_WRITE_1( "CapUtil::GetMemoryInfoL() : Leaved with: %d", err);
+                continue;
+                }
+            
+            info.iDriveStatus = driveStatus;
+            if( driveStatus & DriveInfo::EDriveInternal )
+                {
+                // if internal (DEV) drive, save drive number
+                devDriveCount++;
+                info.iMemNr = devDriveCount;
+                }
+            else if ( driveStatus & DriveInfo::EDriveRemovable )
+                {
+                // if removable (MMC) drive, save drive number
+                mmcDriveCount++;
+                info.iMemNr = mmcDriveCount;
+                }
+            else
+                {
+                // was not internal or removable, skip.
+                LOGGER_WRITE( "CCapInfo::MemoryInfoL() : not internal or removable, skip." );
+                continue;
+                }
+                
+            WriteMemoryInfoL(info);
+            
+            }
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::MemoryInfoL(TMemoryInfo& aInfo)
+// Create memory info for all drives (RAM excluded).
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::WriteMemoryInfoL(TMemoryInfo& aInfo)
+    {
+    TRACE_FUNC_ENTRY;
+    TBuf<KBufSize> buf;
+
+    WriteTagL(EMemory, TXmlParser::EElementBegin);
+
+    if( aInfo.iDriveStatus & DriveInfo::EDriveInternal )
+        {
+        buf = KMediaFlash;
+        }
+    else
+        {
+        buf = KMediaMMC;  // memory card (MMC)
+        }
+        
+    if( aInfo.iMemNr > 1 )
+        {
+        // append memory number DEV2, MMC2..
+        buf.AppendNum( aInfo.iMemNr ); 
+        }
+    
+    WriteValueL(EMemType, buf);
+    WriteValueL(ELocation, aInfo.iLocation);
+    WriteValueL(EFree, aInfo.iFree);
+    WriteValueL(EUsed, aInfo.iUsed);
+    
+    WriteValueL(EFileNLen, aInfo.iFileNameSize);
+
+    WriteTagL(EMemory, TXmlParser::EElementEnd);
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::ServiceInfoL(const TDesC& aDir)
+// Reads service xml-files from directory and writes them into capability 
+// document.
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::ServiceInfoL(const TDesC& aDir, const RArray<TFileName>& aExcludeList,
+    RArray<TFileName>& aFilesAdded)
+    {
+    TRACE_FUNC_ENTRY;
+    CCapList* capList=CapList();
+
+    RArray<TFileName> array( KDefaultArrayGranularity );
+    CleanupClosePushL(array);
+
+    CStringList* stringList=CStringList::NewLC();
+
+    CapUtil::GetFileListL(iFsSession, aDir, array);
+    
+    _LIT(KFormat, "%S%S");
+    TFileName name;
+    TInt count=array.Count();
+    for (TInt i=0; i<count; i++)
+        {
+        TBool exludeFromList(EFalse);
+        
+        // Check if file is already added to list
+        for ( TInt j=0; j<aExcludeList.Count() && !exludeFromList; j++ )
+            {
+            if ( array[i].CompareF(aExcludeList[j]) == 0 )
+                {
+                LOGGER_WRITE_1( "match found at pos %d", j);
+                exludeFromList = ETrue;
+                }
+            }
+        
+        if ( !exludeFromList )
+            {
+            name.Format(KFormat, &aDir, &array[i]);
+            if (!CapUtil::CheckFileType(name, KXmlExtension))
+                {
+                continue;  // only accept .xml files
+                }
+            
+            capList->List()->Reset();
+            capList->List()->ReadFromFileL( iFsSession, name );
+            if (capList->FindServiceL(stringList))
+                {
+                WriteNewLineL();
+                WriteFromListL(stringList);
+                
+                User::LeaveIfError( aFilesAdded.Append(array[i]) );
+                LOGGER_WRITE_1( "File '%S' added to list", &array[i] );
+                }
+            }
+        }
+
+    CleanupStack::PopAndDestroy(stringList);
+    CleanupStack::PopAndDestroy(&array);
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::FolderServiceL()
+// Writes folder service. Notice that this service is created in code because
+// pathinfo component is used to get folder names.
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::FolderServiceL()
+    {
+    TRACE_FUNC_ENTRY;
+    TBuf<KBufSize> rootPath;
+    TBuf<KBufSize> memoryType(KNullDesC);
+    TFileName folderName;
+    _LIT( KFormat, "%S%S" );
+    
+    WriteNewLineL();
+    WriteTagL(EService, TXmlParser::EElementBegin);
+
+    WriteValueL(EName,  KFolderServiceName);
+    WriteValueL(EUUID,  KFolderServiceUid);
+    WriteValueL(EVersion,  KFolderServiceVersion);
+
+    WriteTagL(EObject, TXmlParser::EElementBegin);
+    WriteValueL(EType,  KFolderServiceType);
+    WriteTagL(EObject, TXmlParser::EElementEnd);
+    TInt drive;
+    TInt err;
+    
+    CapUtil::GetDefaultRootPathL( iFsSession, rootPath );
+    if( rootPath.Length() > 0 )
+        {
+        err = iFsSession.CharToDrive( rootPath[0], drive );
+        if( err == KErrNone )
+            {
+            CapUtil::GetMemoryType( iFsSession, memoryType, drive );
+            }
+        }
+
+    // EFolderImages
+    folderName.Format( KFormat, &rootPath, &PathInfo::ImagesPath() );
+    WriteFolderL( KFolderImages, folderName, memoryType );
+    
+    // EFolderGraphics
+    folderName.Format( KFormat, &rootPath, &PathInfo::ImagesPath() );
+    WriteFolderL(KFolderGraphics, folderName, memoryType);
+    
+    // EFolderTones
+    folderName.Format( KFormat, &rootPath, &PathInfo::DigitalSoundsPath() );
+    WriteFolderL(KFolderTones, folderName, memoryType);
+    
+    // EFolderMusic
+    folderName.Format( KFormat, &rootPath, &PathInfo::SoundsPath() );
+    WriteFolderL(KFolderMusic, folderName, memoryType);
+    
+    // EFolderVideos
+    folderName.Format( KFormat, &rootPath, &PathInfo::VideosPath() );
+    WriteFolderL(KFolderVideos, folderName, memoryType);
+    
+    // EFolderInstalls
+    folderName.Format( KFormat, &rootPath, &PathInfo::InstallsPath() );
+    WriteFolderL(KFolderInstalls, folderName, memoryType);
+
+
+    WriteTagL(EService, TXmlParser::EElementEnd);
+    WriteNewLineL();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::SyncSolutionsServiceL()
+// Reads last used syncSolutions from cenrep and writes to capability object
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::SyncSolutionsServiceL()
+    {
+    TRACE_FUNC_ENTRY;
+    TSConSolutionInfo calendar;
+    TSConSolutionInfo contact;
+    TSConSolutionInfo sms;
+    TSConSolutionInfo bookmark;
+    
+    CSConSyncService *syncService = CSConSyncService::NewLC();
+    syncService->GetSolutionL( KSeconCalendarUid, calendar );
+    syncService->GetSolutionL( KSeconContactsUid, contact );
+    syncService->GetSolutionL( KSeconSmsUid, sms );
+    syncService->GetSolutionL( KSeconBookmarkUid, bookmark );
+    CleanupStack::PopAndDestroy( syncService );
+    
+    WriteSyncSolutionsServiceL( calendar, contact, sms, bookmark );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CCapInfo::WriteSyncSolutionsServiceL()
+// Writes SyncSolutionsService data to capability object.
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::WriteSyncSolutionsServiceL( const TSConSolutionInfo& aCalendar,
+        const TSConSolutionInfo& aContact,
+        const TSConSolutionInfo& aSms,
+        const TSConSolutionInfo& aBookmark)
+    {
+    TRACE_FUNC_ENTRY;
+    
+    WriteTagL( EService, TXmlParser::EElementBegin );
+
+    WriteValueL( EName,  KSyncSolutionsServiceName );
+    WriteValueL( EVersion,  KSyncSolutionsServiceVersion );
+    
+    if ( aCalendar.iUid != 0 )
+        {
+        WriteSolutionTagL( KSyncCalendar, aCalendar );
+        }
+    
+    if ( aContact.iUid != 0 )
+        {
+        WriteSolutionTagL( KSyncContacts, aContact );
+        }
+    
+    if ( aSms.iUid != 0 )
+        {
+        WriteSolutionTagL( KSyncSms, aSms );
+        }
+    
+    if ( aBookmark.iUid != 0 )
+        {
+        WriteSolutionTagL( KSyncBookmark, aBookmark );
+        }
+    
+    /*
+     * <Ext>
+     *   <XNam>DesktopSync</XNam>
+     *   <XVal></XVal>
+     * </Ext>
+     * 
+     */
+    if ( !iSconInfo->iDesktopSyncError )
+        {
+        WriteTagL( EExt, TXmlParser::EElementBegin );
+        WriteValueL( EXNam, KDesktopSync );
+        
+        TBuf<KBufSize> buffer;
+        buffer.AppendNum( iSconInfo->iDesktopSync );
+        
+        WriteValueL( EXVal, buffer );
+        WriteTagL( EExt, TXmlParser::EElementEnd );
+        }
+    
+    
+    
+    WriteTagL( EService, TXmlParser::EElementEnd );
+    TRACE_FUNC_EXIT;
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CCapInfo::WriteSolutionTagL()
+// Writes SyncSolutionsService solution data to capability object.
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::WriteSolutionTagL( const TDesC& aContentName,
+        const TSConSolutionInfo& aSolution )
+    {
+    TRACE_FUNC_ENTRY;
+    _LIT( KFormatUID, "UID=0x%08x" );
+    _LIT( KFormatName, "Name=%S" );
+    _LIT( KFormatDate, "Timestamp=%04d%02d%02dT%02d%02d%02dZ" );
+    
+    WriteTagL( EExt, TXmlParser::EElementBegin );
+    WriteValueL( EXNam, aContentName );
+    
+    TFileName temp;
+    temp.Format( KFormatUID, aSolution.iUid );
+    WriteValueL( EXVal, temp );
+    
+    temp.Format( KFormatName, &aSolution.iSolutionName );
+    WriteValueL( EXVal, temp );
+    
+    if ( aSolution.iTime.Int64() != 0 )
+        {
+        // write time
+        TDateTime time = aSolution.iTime.DateTime();
+        temp.Format( KFormatDate, time.Year(), time.Month() + 1,
+            time.Day() + 1, time.Hour(), time.Minute(), time.Second() );
+        WriteValueL( EXVal, temp );
+        
+        }
+    
+    
+    WriteTagL( EExt, TXmlParser::EElementEnd );
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::WriteFolderL(const TDesC& aType, const TDesC& aFullName, 
+// const TDesC& aMemory)
+// Writes one folder name element.
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::WriteFolderL(const TDesC& aType, const TDesC& aFullName, 
+                            const TDesC& aMemory)
+    {
+    TRACE_FUNC_ENTRY;
+    _LIT(KFormat, "%S=%S");
+
+    TBuf<KBufSize> buf; 
+    const TInt KReservedSize = 10;
+    if ( aFullName.Length() + KReservedSize > KBufSize )
+        {
+        return;
+        }
+    buf.Format(KFormat, &KFolderNameTag, &aFullName);
+    
+
+    WriteTagL(EExt, TXmlParser::EElementBegin);
+
+    WriteValueL(EXNam, aType);
+    WriteValueL(EXVal, buf);
+
+    buf.Format(KFormat, &KFolderMemoryTypeTag, &aMemory);
+    WriteValueL(EXVal, buf);
+    
+
+    WriteTagL(EExt, TXmlParser::EElementEnd);
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::WriteL(const TDesC& aText)
+// Writes one element to capability buffer.
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::WriteL(const TDesC& aText)
+    {
+    if (aText.Length() > iBuf.MaxLength())
+        {
+        User::Leave(KErrTooBig);
+        }
+        
+
+    iBuf=aText;
+    iBuf.Trim();
+    FormatElement(iBuf);
+    TPtr8 ptr = iHeapBuf->Des();
+
+    if ( iBuf.Length()+2 > ptr.MaxLength() )
+        {
+        User::Leave(KErrTooBig);
+        }
+        
+    //unicode conversion
+    HBufC8* convBuf = HBufC8::NewLC( iBuf.Size() );
+    TPtr8 convPtr = convBuf->Des();
+    
+    CnvUtfConverter::ConvertFromUnicodeToUtf8(convPtr, iBuf);
+
+    ptr.Copy(convPtr);
+    ptr.Append( KLineFeed );  // linefeed
+    
+    CleanupStack::PopAndDestroy( convBuf );
+    
+    TInt pos=iCapabilityBuf->Size();
+    iCapabilityBuf->InsertL(pos, ptr);
+
+    iBuf=KNullDesC;
+    }
+
+void CCapInfo::WriteNewLineL()
+    {
+    TInt pos=iCapabilityBuf->Size();
+    iCapabilityBuf->InsertL(pos, KLineFeed );
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::WriteValueL(TInt aId, const TDesC& aValue)
+// Constructs element with value (eg <Language>en</Language>)
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::WriteValueL(TInt aId, const TDesC& aValue)
+    {
+    // empty values not written to capability object
+    if (aValue.Length()<1)
+        {
+        LOGGER_WRITE( "WriteValueL: value is empty" );
+        return;
+        }
+
+    TBuf<KBufSize> buf;
+
+    TRAPD(err, CapParser::MakeElementL(buf, aId, aValue));
+    if (err==KErrNone)
+        {
+        WriteL(buf);
+        }
+    else if (err==KErrTooBig)
+        {
+        WriteBigValueL(aId, aValue);
+        }
+    else
+        {
+        User::Leave(err);
+        }
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::WriteBigValueL(TInt aId, const TDesC& aValue)
+// Constructs element with value
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::WriteBigValueL(TInt aId, const TDesC& aValue)
+    {
+    HBufC* hBuf=HBufC::NewL(aValue.Length()+KBufSize);
+    CleanupStack::PushL(hBuf);
+
+    TPtr pBuf(hBuf->Des());
+    CapParser::MakeElementL(pBuf, aId, aValue);
+    WriteL(*hBuf);
+    
+    CleanupStack::PopAndDestroy(hBuf);
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::WriteValueL(TInt aId, TInt64 aValue)
+// Constructs element with integer value
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::WriteValueL(TInt aId, TInt64 aValue)
+    {
+    TBuf<KBufSize> buf;
+    TBuf<KTagSize> value;
+    CapUtil::IntToStr(value, aValue);
+    CapParser::MakeElementL(buf, aId, value);
+    WriteL(buf);
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::WriteTagL(TInt aId, TInt aType)
+// Constructs element without value (eg <Memory>)
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::WriteTagL(TInt aId, TInt aType)
+    {
+    TBuf<KBufSize> buf;
+    CapParser::MakeElementL(buf, aId, aType);
+    WriteL(buf);
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::WriteAttributeL(TInt aId, const TDesC& aVersion, const TDesC& aDate)
+// Constructs element with attributes "Version" and "Date" 
+// (eg <HW Version="1.5"/>)
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::WriteAttributeL(TInt aId, const TDesC& aVersion, 
+                                const TDesC& aDate)
+    {
+    // empty values not written to capability object
+    if (aVersion.Length()<1 && aDate.Length()<1)
+        {
+        LOGGER_WRITE( "WriteAttributeL: attributes are empty" );
+        return;
+        }
+    
+    TBuf<KBufSize> buf;
+    CapParser::MakeElementL(buf, aId, aVersion, aDate);
+    WriteL(buf);
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::WriteFromListL(CStringList* aList)
+// Writes elements from list to capability buffer.
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::WriteFromListL(CStringList* aList)
+    {
+    TInt count=aList->Count();
+
+    for (TInt i=0; i<count; i++)
+        {
+        WriteL(aList->ReadPtr(i));
+        }
+    }   
+
+// -----------------------------------------------------------------------------
+// CCapInfo::FormatElement(TDes& aText)
+// Function adds indentation spaces to capability elements to improve 
+// readability.
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::FormatElement(TDes& aText)
+    {
+    TXmlParser parser;
+
+    parser.Set(aText);
+    TInt type=parser.Type();
+    TBuf<KTagSize> tag;
+    parser.GetTag(tag);
+        
+    if (type==TXmlParser::EElementEnd)
+        {
+        TInt id1=CapParser::ElementId(tag);
+        TInt id2=iIdStack.Pop();
+        
+        __ASSERT_DEBUG(id1==id2, CapUtil::Panic(KErrGeneral));
+        id1=0;
+        id2=0;
+        }
+
+    AddFormatText(aText, iIdStack.Size());
+
+    if (type==TXmlParser::EElementBegin)
+        {
+        TInt id1=CapParser::ElementId(tag);
+        iIdStack.Push(id1);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CCapInfo::AddFormatText( TDes& aText, TInt aNum ) const
+// Adds format text
+// -----------------------------------------------------------------------------
+//
+void CCapInfo::AddFormatText( TDes& aText, TInt aNum ) const
+    {
+    TBuf<KBufSize> buf;
+    buf = KNullDesC;
+
+    if ( aNum > KNestingLimit )
+        {
+        aNum = KNestingLimit;
+        }
+        
+    for ( TInt i=0; i<aNum; i++ )
+        {
+        buf.Append( KFormatText );
+        }
+    if ( aText.MaxLength()-aText.Length()>buf.Length() )
+        {
+        aText.Insert( 0, buf );
+        }
+    }
+    
+// End of file
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/src/caplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,228 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CCapList implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "caplist.h"
+#include "caputils.h"
+#include "capparser.h"
+#include "capability.h"
+#include "debug.h"
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CCapList::NewL()
+// Two-phase constructor.
+// -----------------------------------------------------------------------------
+//
+CCapList* CCapList::NewL()
+    {
+    TRACE_FUNC_ENTRY;
+    CCapList* self = new(ELeave) CCapList();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CCapList::~CCapList()
+// Gets phone serial number from etel.
+// -----------------------------------------------------------------------------
+//
+CCapList::~CCapList()
+    {
+    TRACE_FUNC_ENTRY;
+    delete iList;
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCapList::CCapList()
+// Constructor
+// -----------------------------------------------------------------------------
+//
+CCapList::CCapList()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CCapList::ConstructL()
+// Initializes the member data
+// -----------------------------------------------------------------------------
+//
+void CCapList::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    iList = CStringList::NewL();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCapList::List()
+// Returns the list
+// -----------------------------------------------------------------------------
+//
+CStringList* CCapList::List()
+    {
+    __ASSERT_DEBUG(iList, CapUtil::Panic(KErrGeneral));
+    return iList;
+    }
+
+// -----------------------------------------------------------------------------
+// CCapList::FindFromMark(TInt aId, TInt aType)
+// Find from mark
+// -----------------------------------------------------------------------------
+//
+TInt CCapList::FindFromMark(TInt aId, TInt aType)
+    {
+    TRACE_FUNC_ENTRY;
+    TInt mark = List()->Mark();
+    TInt count= List()->Count();
+    
+    if ( mark >= count )
+        {
+        return KErrNotFound;
+        }       
+
+    TInt index=Find(aId, aType, mark);
+    if ( index == KErrNotFound )
+        {
+        LOGGER_WRITE_1( "CCapList::FindFromMark(TInt aId, TInt aType) returned : %d", KErrNotFound );
+        return KErrNotFound;
+        }
+        
+
+    __ASSERT_DEBUG(index>=mark, CapUtil::Panic(KErrGeneral));
+
+    List()->SetMark(index+1);
+    LOGGER_WRITE_1( "CCapList::FindFromMark(TInt aId, TInt aType) returned : %d", index );
+    return index;
+    }
+
+// -----------------------------------------------------------------------------
+// CCapList::FindServiceHeader()
+// Finds service xml-file identification header. This header must be the first 
+// line in every service file.
+// -----------------------------------------------------------------------------
+//
+TBool CCapList::FindServiceHeader()
+    {
+    TRACE_FUNC_ENTRY;
+    if (List()->Count()<1)
+        {
+        LOGGER_WRITE( "CCapList::FindServiceHeader() : returned EFalse" );
+        return EFalse;
+        }
+
+    TBuf<KBufSize> buf;
+    TPtrC ptr=List()->ReadPtr(0);
+    CapUtil::StrCopy(buf, ptr);
+    buf.Trim();
+    if (buf.Compare(KServiceHeader)==0)
+        {
+        LOGGER_WRITE( "CCapList::FindServiceHeader() : returned ETrue" );
+        return ETrue;
+        }       
+    else
+        {
+        LOGGER_WRITE( "CCapList::FindServiceHeader() : returned EFalse" );
+        return EFalse;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CCapList::FindServiceL(CStringList* aList)
+// Find service
+// -----------------------------------------------------------------------------
+//
+TBool CCapList::FindServiceL(CStringList* aList)
+    {
+    TRACE_FUNC_ENTRY;
+    aList->Reset();
+    List()->SetMark(0);
+
+    if (!FindServiceHeader())
+        {
+        LOGGER_WRITE( "CCapList::FindServiceL(CStringList* aList) : returned EFalse" );
+        return EFalse;
+        }
+        
+
+    for (;;)
+        {
+        TInt start=FindFromMark(EService, TXmlParser::EElementBegin);
+        TInt stop=FindFromMark(EService, TXmlParser::EElementEnd);
+        
+        if (start==KErrNotFound || stop==KErrNotFound || start>=stop)
+            {
+            break;
+            }
+                    
+        aList->CopyL(List(), start, stop);
+        }
+
+    if (aList->Count()>0)
+        {
+        LOGGER_WRITE( "CCapList::FindServiceL(CStringList* aList) : returned ETrue" );
+        return ETrue;
+        }
+    
+    LOGGER_WRITE( "CCapList::FindServiceL(CStringList* aList) : returned EFalse" );   
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CCapList::Find(TInt aId, TInt aType, TInt aIndex)
+// Find element
+// -----------------------------------------------------------------------------
+//
+TInt CCapList::Find(TInt aId, TInt aType, TInt aIndex)
+    {
+    TInt count=List()->Count();
+    if (aIndex<0 || aIndex>=count)
+        {
+        CapUtil::Panic(KErrArgument);
+        }
+        
+    for (TInt i=aIndex; i<count; i++)
+        {
+        TPtrC ptr=List()->ReadPtr(i);
+
+        TInt id=0;
+        TInt type=0;
+        
+        CapParser::ParseElement(ptr, id, type);
+        if (type==TXmlParser::EElementUnknown)
+            {
+            continue;  // invalid capability element
+            }
+
+        if (id==aId && aType==type)
+            {
+            return i;
+            }
+        }
+    return KErrNotFound;
+    }
+
+
+// End of files
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/src/capparser.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,766 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CapParser implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "capparser.h"
+#include "caputils.h"
+
+const char KFind1 = '&';
+const char KFind2 = '<';
+const char KFind3 = '>';
+const char KFind4 = '"';
+const char KFind5 = '\'';
+
+_LIT( KReplace1, "&amp;" );
+_LIT( KReplace2, "&lt;" );
+_LIT( KReplace3, "&gt;" );
+_LIT( KReplace4, "&quot;" );
+_LIT( KReplace5, "&apos;" );
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CapParser::GetTagL(TDes& aText, TInt aId)
+// Returns capability element tag (eg. "Memory")
+// -----------------------------------------------------------------------------
+//
+void CapParser::GetTagL(TDes& aText, TInt aId)
+    {
+    aText=KNullDesC;
+    
+    TInt count=NUMXMLTOKENS;
+    for (TInt i=0; i<count; i++)
+        {
+        TXmlToken t=KXmlTokens[i];
+        if (t.id==aId)
+            {
+            aText=t.tag;
+            return;
+            }
+        }
+    User::Leave(KErrNotFound);
+    }
+
+// -----------------------------------------------------------------------------
+// CapParser::ElementId(const TDesC& aText)
+// Returns capability element id (eg. EMemory).
+// -----------------------------------------------------------------------------
+//
+TInt CapParser::ElementId(const TDesC& aText)
+    {
+    TBuf<KTagSize>buf;
+    TInt count=NUMXMLTOKENS;
+    for (TInt i=0; i<count; i++)
+        {
+        TXmlToken t=KXmlTokens[i];
+        buf=t.tag;
+        if (buf.Compare(aText)==0)
+            {
+            return t.id;
+            }
+        }
+    return KErrNotFound;
+    }
+
+// -----------------------------------------------------------------------------
+// CapParser::ParseElement(const TDesC& aText, TInt& aId, TInt& aType)
+// Parses element's id and type (eg. "<Memory>" -> EMemory, EElementBegin)
+// -----------------------------------------------------------------------------
+//
+void CapParser::ParseElement(const TDesC& aText, TInt& aId, TInt& aType)
+    {
+    TXmlParser parse;
+    aId=KErrNotFound;
+    
+    parse.Set(aText);
+    aType=parse.Type();
+    if (aType==TXmlParser::EElementUnknown)
+        {
+        return;
+        }
+
+    TPtrC ptr=parse.Tag();
+    aId=ElementId(ptr);
+    }
+
+// -----------------------------------------------------------------------------
+// CapParser::MakeElementL(TDes& aText, TInt aId, const TDesC& aValue)
+// Constructs element with value (eg. "<Free>23456</Free>").
+// -----------------------------------------------------------------------------
+//
+void CapParser::MakeElementL(TDes& aText, TInt aId, const TDesC& aValue)
+    {
+    aText=KNullDesC;
+    ReplaceSpecialCharsL( aText, aValue );
+    
+    TBuf<KTagSize> buf;
+    MakeElementL( buf, aId, TXmlParser::EElementBegin );
+    
+    TInt len = aText.Length() + buf.Length() + buf.Length() + 1;
+    if ( len > aText.MaxLength())
+        {
+        User::Leave(KErrTooBig);
+        }
+    
+    aText.Insert( 0, buf );
+    MakeElementL( buf, aId, TXmlParser::EElementEnd );
+    aText.Append( buf );
+    }
+
+// -----------------------------------------------------------------------------
+// CapParser::MakeElementL(TDes& aText, TInt aId, TInt aType)
+// Constructs element without value (eg. "<Memory>" or "</Memory>").
+// -----------------------------------------------------------------------------
+//
+void CapParser::MakeElementL(TDes& aText, TInt aId, TInt aType)
+    {
+    _LIT(KFormat1, "<%S>");
+    _LIT(KFormat2, "</%S>");
+    _LIT(KFormat3, "<%S/>");
+
+    aText=KNullDesC;
+    TBuf<KTagSize> buf;
+    GetTagL(buf, aId);
+    
+    switch(aType)
+        {
+        case TXmlParser::EElementBegin:
+            aText.Format(KFormat1, &buf);
+            break;
+        case TXmlParser::EElementEnd:
+            aText.Format(KFormat2, &buf);
+            break;
+        case TXmlParser::EElementEmpty:
+            aText.Format(KFormat3, &buf);
+            break;
+        default:
+            CapUtil::Panic(KErrArgument);
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CapParser::MakeElementL(TDes& aText, TInt aId, const TDesC& aVersion,
+// const TDesC& aDate)
+// Constructs element with attributes "Version" and "Date"(eg. 
+// "<FW Version="2.2"/>").
+// -----------------------------------------------------------------------------
+//
+void CapParser::MakeElementL(TDes& aText, TInt aId, const TDesC& aVersion, 
+                            const TDesC& aDate)
+    {
+    _LIT(KFormat1, "<%S %S=\"%S\" %S=\"%S\"/>");
+    _LIT(KFormat2, "<%S %S=\"%S\"/>");
+
+    aText=KNullDesC;
+    
+    TBuf<KTagSize> element;
+    TBuf<KTagSize> versionTag;
+    TBuf<KTagSize> dateTag;
+    
+    GetTagL(element, aId);
+    GetTagL(versionTag, EAttVersion);
+    GetTagL(dateTag, EAttDate);
+
+    if (aDate.Length()>0)
+        {
+        aText.Format(KFormat1, &element, &versionTag, &aVersion, &dateTag, 
+        &aDate);
+        }       
+    else
+        {
+        aText.Format(KFormat2, &element, &versionTag, &aVersion);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CapParser::ReplaceSpecialCharsL( TDes& aText, const TDesC& aValue )
+// Replaces special characters to xml compliant.
+// -----------------------------------------------------------------------------
+//
+void CapParser::ReplaceSpecialCharsL( TDes& aText, const TDesC& aValue )
+    {
+    if ( aValue.Length() > aText.MaxLength() )
+        {
+        User::Leave(KErrTooBig);
+        }
+    aText.Copy( aValue );
+    
+    //Replace special characters
+    for( TInt i = 0; i < aText.Length(); i++ )
+        {
+        switch( aText[i] )
+            {
+            case KFind1:
+                if ( aText.Length()+KReplace1().Length()-1 > aText.MaxLength() )
+                    {
+                    User::Leave(KErrTooBig);
+                    }
+                aText.Replace( i, 1, KReplace1 );
+                i+=KReplace1().Length()-1;
+                break;
+            case KFind2:
+                if ( aText.Length()+KReplace2().Length()-1 > aText.MaxLength() )
+                    {
+                    User::Leave(KErrTooBig);
+                    }
+                aText.Replace( i, 1, KReplace2 );
+                i+=KReplace2().Length()-1;
+                break;
+            case KFind3:
+                if ( aText.Length()+KReplace3().Length()-1 > aText.MaxLength() )
+                    {
+                    User::Leave(KErrTooBig);
+                    }
+                aText.Replace( i, 1, KReplace3 );
+                i+=KReplace3().Length()-1;
+                break;
+            case KFind4:
+                if ( aText.Length()+KReplace4().Length()-1 > aText.MaxLength() )
+                    {
+                    User::Leave(KErrTooBig);
+                    }
+                aText.Replace( i, 1, KReplace4 );
+                i+=KReplace4().Length()-1;
+                break;
+            case KFind5:
+                if ( aText.Length()+KReplace5().Length()-1 > aText.MaxLength() )
+                    {
+                    User::Leave(KErrTooBig);
+                    }
+                aText.Replace( i, 1, KReplace5 );
+                i+=KReplace5().Length()-1;
+                break;
+            default:
+                break;
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::Set(const TDesC& aText)
+// Sets a tag
+// -----------------------------------------------------------------------------
+//
+void TXmlParser::Set(const TDesC& aText)
+    {
+    iOriginal.Set(aText);
+    TrimOriginal();
+    Init();
+    Parse();
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::Init()
+// Inits the parser
+// -----------------------------------------------------------------------------
+//
+void TXmlParser::Init()
+    {
+    iType=EElementUnknown;
+    iTag.Set(KNullDesC);
+    iValue.Set(KNullDesC);
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::GetTag(TDes& aText) const
+// Gets the tag
+// -----------------------------------------------------------------------------
+//
+void TXmlParser::GetTag(TDes& aText) const
+    {
+    StrCopy(aText, iTag);
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::Tag() const
+// Returns a pointer to a tag
+// -----------------------------------------------------------------------------
+//
+TPtrC TXmlParser::Tag() const
+    {
+    return iTag;
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::Type() const
+// Returns type
+// -----------------------------------------------------------------------------
+//
+TInt TXmlParser::Type() const
+    {
+    return iType;
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::Parse()
+// Parses xml-element.  
+// -----------------------------------------------------------------------------
+//
+void TXmlParser::Parse()
+    {
+    iType=EElementUnknown;
+    
+    // this must be the first check
+    if (ElementUnknown())
+        {
+        return;
+        }       
+    
+    if (ElementBegin())
+        {
+        return;
+        }
+    
+    if (ElementEnd())
+        {
+        return;
+        }
+        
+    if (ElementValue())
+        {
+        return;
+        }
+            
+    if (ElementComment())
+        {
+        return;
+        }
+        
+    if (ElementDocType())
+        {
+        return;
+        }
+        
+    if (ElementVersion())
+        {
+        return;
+        }
+        
+    if (ElementEmpty())
+        {
+        return;
+        }
+        
+    if (ElementAtt())
+        {
+        return;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::ElementUnknown()
+// Parses unknown elements
+// -----------------------------------------------------------------------------
+//
+TBool TXmlParser::ElementUnknown()
+    {
+    TPtrC str=Str();
+    TInt len=str.Length();
+    const TInt KXmlElementMinLength = 3;
+    if ( len < KXmlElementMinLength )
+        {
+        return ETrue;  // too short to be xml element
+        }
+        
+    
+    iFirst=str.Locate('<');
+    iLast=str.LocateReverse('>');
+    iSlash=str.LocateReverse('/');
+
+    if (iFirst!=0 || iLast!=len-1)
+        {
+        return ETrue;  // first char must be "<" and last ">"
+        }
+        
+    return EFalse;    
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::ElementBegin()
+// Parses beginning tag (eg. <General>)
+// -----------------------------------------------------------------------------
+//
+TBool TXmlParser::ElementBegin()
+    {
+    TPtrC str=Str();
+        
+    if (iSlash!=KErrNotFound)
+        {
+        return EFalse;
+        }
+        
+    // remove possible attributes
+    TInt pos=str.Locate(' ');
+    if (pos==KErrNotFound)
+        {
+        pos=iLast;
+        }
+        
+    TPtrC ptr=SubStr(iFirst, pos);
+
+    if (!ValidTag(ptr))
+        {
+        return EFalse;
+        }       
+
+    iType=EElementBegin;
+    iTag.Set(ptr);
+
+    return ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::ElementEnd()
+// Parses ending tag (eg. </General>)
+// -----------------------------------------------------------------------------
+//
+TBool TXmlParser::ElementEnd()
+    {
+    if (iSlash!=iFirst+1)
+        {
+        return EFalse;
+        }
+        
+    TPtrC ptr=SubStr(iSlash, iLast);
+    if (!ValidTag(ptr))
+        {
+        return EFalse;
+        }       
+
+    iType=EElementEnd;
+    iTag.Set(ptr);
+    return ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::ElementValue()
+// Parses value (eg. <Language>en</Language>)
+// -----------------------------------------------------------------------------
+//
+TBool TXmlParser::ElementValue()
+    {
+    TPtrC str=Str();
+
+    TInt pos1=str.Locate('>');
+    TInt pos2=str.LocateReverse('<');
+    
+    if (pos1<pos2 && iSlash==pos2+1)
+        {
+        TPtrC ptr1=SubStr(iFirst, pos1);
+        TPtrC ptr2=SubStr(iSlash, iLast);
+        if (!ValidTag(ptr1) || ptr1.Compare(ptr2)!=0)
+            {
+            return EFalse;
+            }
+                    
+        iType=EElementValue;
+        iTag.Set(ptr1);
+        iValue.Set(SubStr(pos1, pos2));
+        return ETrue;
+        }
+    return EFalse;    
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::ElementEmpty()
+// Parses empty element (eg. <CaseSenN/>)
+// -----------------------------------------------------------------------------
+//
+TBool TXmlParser::ElementEmpty()
+    {
+    if (iSlash!=iLast-1)
+        {
+        return EFalse;
+        }       
+    
+    TPtrC ptr=SubStr(iFirst, iSlash);
+    if (!ValidTag(ptr))
+        {
+        return EFalse;
+        }
+        
+    iType=EElementEmpty;
+    iTag.Set(ptr);
+    return ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::ElementVersion()
+// Identifies version element ("<?xml version="1.0" ?>") 
+// -----------------------------------------------------------------------------
+//
+TBool TXmlParser::ElementVersion()
+    {
+    TPtrC str=Str();
+
+    if ( str.Length()>=3 && str[1]=='?' && str[2]=='x')
+        {
+        iType=EElementVersion;
+        return ETrue;
+        }
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::ElementDocType()
+// Identifies document type element 
+// ("<!DOCTYPE Capability SYSTEM "obex-capability.dtd">").
+// -----------------------------------------------------------------------------
+//
+TBool TXmlParser::ElementDocType()
+    {
+    TPtrC str=Str();
+    const TInt KElementMinLength = 10;
+    if ( str.Length() < KElementMinLength )
+        {
+        return EFalse;
+        }
+        
+    if (str[1]=='!' && str[2]=='D' && str[3]=='O' && str[4]=='C')
+        {
+        iType=EElementDocType;
+        return ETrue;
+        }
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::ElementComment()
+// Identifies comment element ("<!-- OBEX Capability Object -->").
+// -----------------------------------------------------------------------------
+//
+TBool TXmlParser::ElementComment()
+    {
+    TPtrC str=Str();
+    
+    if (str.Length()<7)
+        {
+        return EFalse;
+        }
+        
+    if (str[1]=='!' && str[2]=='-' && str[3]=='-')
+        {
+        iType=EElementComment;
+        return ETrue;
+        }
+    
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::ElementAtt()
+// Parses attribute element (eg. <HW Version="1.5"/>)
+// Note: Attribute values cannot contain equals (=) or quotations (")
+// -----------------------------------------------------------------------------
+//
+TBool TXmlParser::ElementAtt()
+    {
+    TPtrC str=Str();
+    TInt num1=Count(str, '=');
+    TInt num2=Count(str, '"');
+    TInt pos=str.Locate(' ');  // find end of tag
+    
+    if (iSlash==iLast-1 && num1>0 && num2==(2*num1) && pos!=KErrNotFound)
+        {
+        TPtrC ptr1=SubStr(iFirst, pos);
+        if (!ValidTag(ptr1))
+            {
+            return EFalse;
+            }
+            
+        iType=EElementAtt;
+        iTag.Set(ptr1);
+        TPtrC ptr2=SubStr(pos, iSlash);
+        iValue.Set(ptr2);
+        return ETrue;
+        }
+    return EFalse;    
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::Str() const
+// Locates the position of the given character
+// -----------------------------------------------------------------------------
+//
+TPtrC TXmlParser::Str() const
+    {
+    return iText;
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::FirstNonSpace(const TDesC& aText)
+// Returns the position of the first non space character
+// -----------------------------------------------------------------------------
+//
+TInt TXmlParser::FirstNonSpace(const TDesC& aText)
+    {
+    TInt len=aText.Length();
+    for (TInt i=0; i<len; i++)
+        {
+        TChar c=aText[i];
+        if (!c.IsSpace())
+            {
+            return i;
+            }
+        }
+    return KErrNotFound;
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::LastNonSpace(const TDesC& aText)
+// Returns the position of the last non space character
+// -----------------------------------------------------------------------------
+//
+TInt TXmlParser::LastNonSpace(const TDesC& aText)
+    {
+    TInt last=aText.Length()-1;
+    for (TInt i=last; i>=0; i--)
+        {
+        TChar c=aText[i];
+        if (!c.IsSpace())
+            {
+            return i;
+            }           
+        }
+    return KErrNotFound;
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::SubStr(const TDesC& aText, TInt pos1, TInt pos2)
+// Function returns a sub-string between aPos1 and aPos2
+// -----------------------------------------------------------------------------
+//
+TPtrC TXmlParser::SubStr(const TDesC& aText, TInt pos1, TInt pos2)
+    {
+    if (pos1<0 || pos2>=aText.Length() || pos1>=pos2)
+        {
+        return TPtrC(); // return empty descriptor
+        }
+        
+    TInt len=pos2-pos1;
+    return aText.Mid(pos1+1, len-1); 
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::SubStr(TInt pos1, TInt pos2)
+// Function returns a sub-string between aPos1 and aPos2
+// -----------------------------------------------------------------------------
+//
+TPtrC TXmlParser::SubStr(TInt pos1, TInt pos2)
+    {
+    TPtrC str=Str();
+    return SubStr(str, pos1, pos2);
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::StrCopy(TDes& aTarget, const TDesC& aSource)
+// Function performs string copy with length checking.
+// -----------------------------------------------------------------------------
+//
+void TXmlParser::StrCopy(TDes& aTarget, const TDesC& aSource)
+    {
+    TInt len=aTarget.MaxLength();
+    if(len<aSource.Length()) 
+        {
+        aTarget.Copy(aSource.Left(len));
+        }        
+    else
+        {
+        aTarget.Copy(aSource);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::Count(const TDesC& aText, const TChar aChar)
+// Returns the number of characters (aChar)
+// -----------------------------------------------------------------------------
+//
+TInt TXmlParser::Count(const TDesC& aText, const TChar aChar)
+    {
+    TInt count=0;
+    TInt len=aText.Length();
+
+    for (TInt i=0; i<len; i++)
+        {
+        TChar ch=aText[i];
+        if (ch == aChar)
+            {
+            count++;
+            }
+        }
+    return count;
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::TrimOriginal()
+// Trimmer function
+// -----------------------------------------------------------------------------
+//
+void TXmlParser::TrimOriginal()
+    {
+    // trim iOriginal and place into iText
+    iText.Set(KNullDesC);
+    TInt first=FirstNonSpace(iOriginal);
+    TInt last=LastNonSpace(iOriginal);
+    if(first!=KErrNotFound && last!=KErrNotFound && last>first+1)
+        {
+        TPtrC ptr=iOriginal.Mid(first, last-first+1);
+        iText.Set(ptr);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::ValidChar(const TChar aChar)
+// Validates the character
+// -----------------------------------------------------------------------------
+//
+TBool TXmlParser::ValidChar(const TChar aChar)
+    {
+    if (aChar >= 'A' && aChar <= 'Z')
+        {
+        return ETrue;
+        }
+    if (aChar >= 'a' && aChar <= 'z')
+        {
+        return ETrue;
+        }
+        
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// TXmlParser::ValidTag(const TDesC& aText)
+// Validates the tag
+// -----------------------------------------------------------------------------
+//
+TBool TXmlParser::ValidTag(const TDesC& aText)
+    {
+    TInt len=aText.Length();
+    for (TInt i=0; i<len; i++)
+        {
+        if (!ValidChar(aText[i]))
+            {
+            return EFalse;
+            }           
+        }
+    return ETrue;
+    }
+    
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/src/caputils.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,719 @@
+/*
+* 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:  CapUtil implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <pathinfo.h>
+#include <sysutil.h>
+#include <hal.h>
+#include <hal_data.h>
+#include <etelmm.h>      // for etel
+#include <mmtsy_names.h> // for etel
+#include <utf.h>
+#include <eikenv.h>
+#include <driveinfo.h>
+#include <centralrepository.h>
+#include <sysutildomaincrkeys.h>
+
+#include "caputils.h"
+#include "capability.h"
+#include "debug.h"
+
+const TInt KPackageSize = 65536;
+const TInt KDefaultArrayGranularity = 5;
+// ============================= MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CapUtil::GetDefaultRootPathL( RFs& aFs, TDes& aRootPath )
+// Gets default root path
+// -----------------------------------------------------------------------------
+//
+void CapUtil::GetDefaultRootPathL( RFs& aFs, TDes& aRootPath )
+    {
+    TRACE_FUNC_ENTRY;
+    // Use the default mass storage if it is internal drive
+    TInt msDrive;
+    User::LeaveIfError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, msDrive ) );
+    LOGGER_WRITE_1("drive: %d", msDrive);
+    
+    TUint msStatus( 0 );
+    TInt err = DriveInfo::GetDriveStatus( aFs, msDrive, msStatus );
+    LOGGER_WRITE_1("DriveInfo::GetDriveStatus err: %d", err);
+    
+    // if no errors, also check drive status
+    if( !err && !( msStatus & DriveInfo::EDrivePresent )
+        || msStatus & DriveInfo::EDriveCorrupt )
+        {
+        LOGGER_WRITE( "Internal mass storage not present or corrupted" );
+        err = KErrNotFound;
+        }
+    
+    if ( !err && ( msStatus & DriveInfo::EDriveInternal ) )
+        {
+        // Use internal mass storage
+        LOGGER_WRITE( "Use internal mass storage" );
+        User::LeaveIfError( PathInfo::GetRootPath( aRootPath, msDrive ) );
+        }
+    else
+        {
+        // Use phone memory
+        LOGGER_WRITE( "Use phone memory" );
+        StrCopy( aRootPath, PathInfo::PhoneMemoryRootPath() );
+        }
+    LOGGER_WRITE_1( "rootPath: %S", &aRootPath );
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CapUtil::GetMemoryType( RFs& aFs, TDes& aMemoryType, const TInt aDrive )
+// Gets drive memory type
+// -----------------------------------------------------------------------------
+//
+void CapUtil::GetMemoryType( RFs& aFs, TDes& aMemoryType, const TInt aDrive )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aDrive: %d", aDrive);
+    aMemoryType = KNullDesC;
+    TUint driveStatus;
+    TInt err = DriveInfo::GetDriveStatus( aFs, aDrive, driveStatus );
+    if( err )
+        {
+        LOGGER_WRITE_1( "CapUtil::GetMemoryType() : DriveInfo::GetDriveStatus err: %d", err );
+        return;
+        }
+    // search internal or removable drives
+    TBool searchInternalDrives;
+    if( driveStatus & DriveInfo::EDriveInternal )
+        {
+        aMemoryType = KMediaFlash;
+        searchInternalDrives = ETrue;
+        }
+    else
+        {
+        aMemoryType = KMediaMMC;
+        searchInternalDrives = EFalse;
+        }
+    
+    TInt typeNumber(0);
+    TInt driveCount;
+    TDriveList driveList;
+    
+    err = DriveInfo::GetUserVisibleDrives( aFs, driveList, driveCount );
+    if( err )
+        {
+        LOGGER_WRITE_1( "CapUtil::GetMemoryType() : DriveInfo::GetUserVisibleDrives err: %d", err );
+        return;
+        }
+    
+    for( TInt i = EDriveA; i <= aDrive; i++ )
+        {
+        if( driveList[i] )
+            {
+            TUint driveStatus;
+            err = DriveInfo::GetDriveStatus( aFs, i, driveStatus );
+            if( err )
+                {
+                LOGGER_WRITE_1( "CapUtil::GetMemoryType() : DriveInfo::GetDriveStatus err: %d", err );
+                continue;
+                }
+
+            if( !(driveStatus & DriveInfo::EDrivePresent )
+                || driveStatus & DriveInfo::EDriveCorrupt )
+                {
+                LOGGER_WRITE( "not present or corrupted" );
+                continue;
+                }
+            
+            if( driveStatus & DriveInfo::EDriveInternal )
+                {
+                if( searchInternalDrives )
+                    {
+                    typeNumber++;
+                    }
+                }
+            else if( driveStatus & DriveInfo::EDriveRemovable )
+                {
+                if( !searchInternalDrives )
+                    {
+                    typeNumber++;
+                    }
+                }
+            }
+        }
+        
+    if( typeNumber > 1 )
+        {
+        aMemoryType.AppendNum( typeNumber );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CapUtil::GetOperatornameL(TDes& aLongName, TDes& aCountryCode, TDes& aNetworkID)
+// Gets phone operator name, country code, networkID.
+// -----------------------------------------------------------------------------
+//
+void CapUtil::GetOperatorNameL(TDes& aLongName, TDes& aCountryCode, TDes& aNetworkID)
+    {
+    TRACE_FUNC_ENTRY;
+    TUint32 networkCaps;
+    RTelServer::TPhoneInfo phoneInfo;
+    
+    RTelServer server;
+    RMobilePhone mobilePhone;
+    User::LeaveIfError( server.Connect() );
+    CleanupClosePushL( server );
+    
+    TInt numPhones;
+    User::LeaveIfError( server.EnumeratePhones( numPhones ) );
+    server.GetPhoneInfo( 0, phoneInfo );
+    
+    User::LeaveIfError( mobilePhone.Open( server, phoneInfo.iName ) );
+    CleanupClosePushL( mobilePhone );
+    User::LeaveIfError( mobilePhone.GetNetworkCaps( networkCaps ) );
+    
+    RMobilePhone::TMobilePhoneNetworkInfoV1 mobilePhoneNetworkInfo;
+    RMobilePhone::TMobilePhoneNetworkInfoV1Pckg mobilePhoneNetworkInfoPckg(
+        mobilePhoneNetworkInfo );
+    RMobilePhone::TMobilePhoneLocationAreaV1 mobilePhoneLocationArea;
+    
+    if (networkCaps & RMobilePhone::KCapsGetCurrentNetwork)
+        {
+        TRequestStatus status;
+        mobilePhone.GetCurrentNetwork( 
+            status, mobilePhoneNetworkInfoPckg, mobilePhoneLocationArea );
+        User::WaitForRequest( status );
+        User::LeaveIfError( status.Int() );     
+        }
+    
+    CleanupStack::PopAndDestroy( &mobilePhone );
+    CleanupStack::PopAndDestroy( &server );
+    StrCopy( aLongName, mobilePhoneNetworkInfo.iLongName );
+    StrCopy( aCountryCode, mobilePhoneNetworkInfo.iCountryCode );
+    StrCopy( aNetworkID, mobilePhoneNetworkInfo.iNetworkId );
+    
+    TRACE_FUNC_EXIT;
+    }
+// -----------------------------------------------------------------------------
+// CapUtil::GetManufacturer(TDes& aText)
+// Gets phone manufacturer from HAL. In case manufacturer is not known,
+// -----------------------------------------------------------------------------
+//
+void CapUtil::GetManufacturer(TDes& aText)
+    {
+    TRACE_FUNC_ENTRY;
+    TInt num(KErrNotFound);
+    
+    HAL::Get(HALData::EManufacturer, num);
+    
+    switch (num)
+        {
+        case HALData::EManufacturer_Ericsson:
+            aText=KManufacturerEricsson; 
+            break;
+        case HALData::EManufacturer_Motorola:
+            aText=KManufacturerMotorola; 
+            break;
+        case HALData::EManufacturer_Nokia:
+            aText=KManufacturerNokia; 
+            break;
+        case HALData::EManufacturer_Panasonic:
+            aText=KManufacturerPanasonic; 
+            break;
+        case HALData::EManufacturer_Psion:
+            aText=KManufacturerPsion; 
+            break;
+        case HALData::EManufacturer_Intel:
+            aText=KManufacturerIntel; 
+            break;
+        case HALData::EManufacturer_Cogent:
+            aText=KManufacturerCogent; 
+            break;
+        case HALData::EManufacturer_Cirrus:
+            aText=KManufacturerCirrus; 
+            break;
+        case HALData::EManufacturer_Linkup:
+            aText=KManufacturerLinkup; 
+            break;
+        case HALData::EManufacturer_TexasInstruments:
+            aText=KManufacturerTexasInstruments; 
+            break;
+        default: 
+            aText=KNullDesC; 
+            break;
+        }
+
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CapUtil::GetLanguage(TDes& aText)
+// Gets language
+// -----------------------------------------------------------------------------
+//
+void CapUtil::GetLanguage(TDes& aText)
+    {
+    TRACE_FUNC_ENTRY;
+    TLanguage lang=User::Language();
+    GetLanguageString(lang, aText);
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CapUtil::GetSWVersionL(TDes& aVersion, TDes& aDate, TDes& aModel)
+// Gets SW version, SW version date  and device model from SysUtil. 
+// -----------------------------------------------------------------------------
+//
+void CapUtil::GetSWVersionL(TDes& aVersion, TDes& aDate, TDes& aModel)
+    {
+    TRACE_FUNC_ENTRY;
+    TBuf<KBufSize> buf;
+    aVersion=KNullDesC;
+    aDate=KNullDesC;
+    aModel=KNullDesC;
+
+    User::LeaveIfError( SysUtil::GetSWVersion( buf ) );
+    RArray<TPtrC> arr(KDefaultArrayGranularity);
+    CleanupClosePushL( arr );
+
+    CapUtil::SplitL(buf, '\n', arr);
+    const TInt KFieldsToFind = 3;
+    if ( arr.Count() < KFieldsToFind )
+        {
+        User::Leave( KErrNotFound );
+        }
+    
+    StrCopy( aVersion, arr[0] );
+    aVersion.Trim();
+
+    StrCopy(aModel,arr[2]);
+    aModel.Trim();
+
+    TBuf<KTagSize> date;
+    StrCopy(date, arr[1]);
+    TTime t;
+    t.UniversalTime(); // this is to avoid warnings
+    TRAPD( err, t = ParseDateL( date ) );
+    if ( err == KErrNone )
+        {
+        CapabilityDate( aDate, t );
+        }
+    
+    CleanupStack::PopAndDestroy( &arr );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CapUtil::InitMemoryInfo(TMemoryInfo& aInfo)
+// Initializes TMemoryInfo.
+// -----------------------------------------------------------------------------
+//
+void CapUtil::InitMemoryInfo(TMemoryInfo& aInfo)
+    {
+    aInfo.iDriveNum        = KErrNotFound;
+    aInfo.iDriveLetter     = KNoChar;
+    aInfo.iLocation        = KNullDesC;
+    aInfo.iFree            = KErrNotFound;
+    aInfo.iUsed            = KErrNotFound;
+    aInfo.iShared          = EFalse;
+    aInfo.iFileSize        = KErrNotFound;
+    aInfo.iFolderSize      = KErrNotFound;
+    aInfo.iFileNameSize    = KMaxFileName;    // TFileName 256
+    aInfo.iFolderNameSize  = KMaxFileName;    // TFileName 256
+    aInfo.iCaseSensitivity = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CapUtil::GetMemoryInfoL( const RFs& aFs, TInt aDriveNumber, TMemoryInfo& aInfo )
+// Get memory information for one drive.
+// -----------------------------------------------------------------------------
+//
+void CapUtil::GetMemoryInfoL( const RFs& aFs, const TInt aDriveNumber, TMemoryInfo& aInfo )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("  aDriveNumber: %d", aDriveNumber);
+    
+    TVolumeInfo volumeInfo;
+    TDriveInfo driveInfo;
+
+    InitMemoryInfo( aInfo );
+
+    User::LeaveIfError( aFs.Drive(driveInfo, aDriveNumber) ); 
+    if ( driveInfo.iDriveAtt == (TUint)KDriveAbsent ) 
+        {
+        LOGGER_WRITE(" iDriveAtt == (TUint)KDriveAbsent, Leave KErrNotFound");
+        User::Leave( KErrNotFound );
+        }
+                
+    User::LeaveIfError( aFs.Volume(volumeInfo, aDriveNumber) );
+
+    User::LeaveIfError( aFs.DriveToChar(aDriveNumber, aInfo.iDriveLetter) );
+    aInfo.iDriveNum = aDriveNumber;
+    aInfo.iLocation.Append( aInfo.iDriveLetter );
+    aInfo.iLocation.Append( KDriveDelimiter );
+    aInfo.iLocation.Append( KPathDelimiter );
+    aInfo.iFree = volumeInfo.iFree;
+    aInfo.iUsed = volumeInfo.iSize - volumeInfo.iFree;
+    
+    // set free memory up to critical level for all drives
+    CRepository* repository = CRepository::NewLC( KCRUidDiskLevel );
+    TInt criticalLevel(0);
+    User::LeaveIfError( repository->Get( KDiskCriticalThreshold, criticalLevel ) );
+    CleanupStack::PopAndDestroy( repository );
+    criticalLevel += KPackageSize; // add obex package size to critical level
+    LOGGER_WRITE_1( "CapUtil::GetMemoryInfoL() criticalLevel: %d", criticalLevel ) ;
+    if ( aInfo.iFree > criticalLevel )
+        {
+        aInfo.iFree = aInfo.iFree - criticalLevel;
+        }       
+    else
+        {
+        aInfo.iFree = 0;
+        }
+    
+    aInfo.iFileSize = aInfo.iFree;
+    aInfo.iFolderSize = aInfo.iFree;
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CapUtil::GetFileListL( RFs& aFs, const TDesC& aDir, 
+// RArray<TFileName>& aList)
+// Finds all files in aDir.
+// -----------------------------------------------------------------------------
+//
+void CapUtil::GetFileListL( const RFs& aFs, const TDesC& aDir, 
+                            RArray<TFileName>& aList)
+    {
+    TRACE_FUNC_ENTRY;
+    
+    aList.Reset();
+    
+    CDir* dir( NULL );
+    User::LeaveIfError( aFs.GetDir( aDir, KEntryAttMatchMask, ESortByName, dir ) );
+    CleanupStack::PushL( dir );
+    
+    for ( TInt i=0; i < dir->Count(); ++i )
+        {
+        TEntry entry = (*dir)[i];
+        if ( !entry.IsDir() )
+            {
+            User::LeaveIfError( aList.Append( entry.iName ) );
+            }
+        }
+    CleanupStack::PopAndDestroy( dir );
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CapUtil::CheckFileType(const TDesC& aFile, const TDesC& aExt)
+// Function checks file extension.
+// -----------------------------------------------------------------------------
+//
+TBool CapUtil::CheckFileType(const TDesC& aFile, const TDesC& aExt)
+    {
+    TRACE_FUNC_ENTRY;
+    TParse parse;
+    parse.Set(aFile, NULL, NULL);
+    TPtrC ptr=parse.Ext();
+
+    TBuf<KTagSize> buf1;
+    TBuf<KTagSize> buf2;
+    
+    buf1=ptr;
+    buf2=aExt;
+    
+    buf1.LowerCase();
+    buf2.LowerCase();
+
+    if (buf1.Compare(buf2)==0)
+        {
+        LOGGER_WRITE( "CapUtil::CheckFileType(const TDesC& aFile, const TDesC& aExt) : returned ETrue" );
+        return ETrue;
+        }
+        
+    else
+        {
+        LOGGER_WRITE( "CapUtil::CheckFileType(const TDesC& aFile, const TDesC& aExt) : returned EFalse" );
+        return EFalse;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CapUtil::GetLanguageString(TLanguage aId, TDes& aText)
+// Get language string for aId.
+// -----------------------------------------------------------------------------
+//
+void CapUtil::GetLanguageString(TLanguage aId, TDes& aText)
+    {
+    TRACE_FUNC_ENTRY;
+    aText=KNullDesC;
+    
+    TInt count=NUMLANGSTRINGS;
+    for (TInt i=0; i<count; i++)
+        {
+        TLangStringStruct t=KLangStrings[i];
+        if (t.id == (TInt)aId)
+            {
+            aText=t.lang;
+            return;
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CapUtil::Panic(TInt aReason)
+// Panic.
+// -----------------------------------------------------------------------------
+//
+#ifdef _DEBUG
+void CapUtil::Panic(TInt aReason)
+#else
+void CapUtil::Panic(TInt /*aReason*/)
+#endif
+    {
+    TRACE_FUNC_ENTRY;
+#ifdef _DEBUG
+    _LIT(KPanicCategory,"CapabilitySC");
+
+    User::Panic(KPanicCategory, aReason);
+#endif
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CapUtil::StrCopy(TDes& aTarget, const TDesC& aSource)
+// String copy with lenght check.
+// -----------------------------------------------------------------------------
+//
+void CapUtil::StrCopy(TDes& aTarget, const TDesC& aSource)
+    {
+    TInt len=aTarget.MaxLength();
+    if(len<aSource.Length()) 
+        {
+        aTarget.Copy(aSource.Left(len));
+        return;
+        }
+    aTarget.Copy(aSource);
+    }
+
+// -----------------------------------------------------------------------------
+// CapUtil::IntToStr(TDes& aText, TInt64 aNum)
+// Function converts ínteger to string.
+// -----------------------------------------------------------------------------
+//
+void CapUtil::IntToStr(TDes& aText, TInt64 aNum)
+    {
+    aText.Num(aNum);
+    }
+
+// -----------------------------------------------------------------------------
+// CapUtil::StrToInt(const TDesC& aText, TInt& aNum)
+// Function converts string to integer. If string cannot be converted,
+// error code is returned.
+// -----------------------------------------------------------------------------
+//
+TInt CapUtil::StrToInt(const TDesC& aText, TInt& aNum)
+    {
+    TLex lex(aText);
+
+    TInt err=lex.Val(aNum); 
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CapUtil::SplitL(const TDesC& aText, const TChar aSeparator, 
+// RArray<TPtrC>& aArray)
+// Function splits string (eg "name1, name2, name3") into substrings.
+// -----------------------------------------------------------------------------
+//
+void CapUtil::SplitL(const TDesC& aText, const TChar aSeparator, 
+                    RArray<TPtrC>& aArray)
+    {
+    TRACE_FUNC_ENTRY;
+    TPtrC ptr;
+    ptr.Set(aText);
+
+    for (;;)
+        {
+        TInt pos=ptr.Locate(aSeparator);
+        if (pos==KErrNotFound)
+            {
+            aArray.AppendL(ptr);
+            break;
+            }
+
+        TPtrC subStr=ptr.Left(pos); // get pos characters starting from position 0
+        aArray.AppendL(subStr);
+
+        if (!(ptr.Length()>pos+1))
+            {
+            break;
+            }
+            
+        ptr.Set(ptr.Mid(pos+1));// get all characters starting from position pos+1
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CapUtil::ParseDateL(const TDesC& aText)
+// Function parses date string of the format "dd-mm-yy".
+// -----------------------------------------------------------------------------
+//
+TTime CapUtil::ParseDateL(const TDesC& aText)
+    {
+    TRACE_FUNC_ENTRY;
+    RArray<TPtrC> arr(KDefaultArrayGranularity);
+    CleanupClosePushL( arr );
+
+    CapUtil::SplitL( aText, '-', arr );
+    if ( arr.Count() != 3 )
+        {
+        User::Leave( KErrNotSupported );
+        }
+           
+    TInt day; 
+    TInt month; 
+    TInt year;
+    
+    User::LeaveIfError( StrToInt(arr[0], day) );
+    User::LeaveIfError( StrToInt(arr[1], month) );
+    User::LeaveIfError( StrToInt(arr[2], year) );
+
+    TDateTime td;
+    TMonth month2 = Month( month );
+    // if year is defined as two digit, add currect millenium for it
+    const TInt KDefaultMillenium = 2000;
+    if ( year < KDefaultMillenium )
+        {
+        year = year + KDefaultMillenium;
+        }
+        
+
+    User::LeaveIfError( td.Set(year, month2, day-1, 0, 0, 0, 0) );
+
+    CleanupStack::PopAndDestroy( &arr );
+    
+    TTime t(td);
+    TRACE_FUNC_EXIT;
+    return t;
+}
+
+// -----------------------------------------------------------------------------
+// CapUtil::Month(TInt aNum)
+// Function return TMonth presentation of integer
+// -----------------------------------------------------------------------------
+//
+TMonth CapUtil::Month(TInt aNum)
+    {
+    TRACE_FUNC_ENTRY;
+    __ASSERT_DEBUG(aNum>=1 && aNum<=12, Panic(KErrArgument));
+
+    switch (aNum)
+        {
+        case 1: return EJanuary;
+        case 2: return EFebruary;
+        case 3: return EMarch;
+        case 4: return EApril;
+        case 5: return EMay;
+        case 6: return EJune;
+        case 7: return EJuly;
+        case 8: return EAugust;
+        case 9: return ESeptember;
+        case 10: return EOctober;
+        case 11: return ENovember;
+        case 12: return EDecember;
+        default: return EJanuary;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CapUtil::CapabilityDate(TDes& aText, const TTime aTime)
+// Constructs capability date as string
+// -----------------------------------------------------------------------------
+//
+void CapUtil::CapabilityDate(TDes& aText, const TTime aTime)
+    {
+    TRACE_FUNC_ENTRY;
+    _LIT(KFormat,"%04d%02d%02dT%02d%02d%02dZ");
+
+    TDateTime dt=aTime.DateTime();
+    aText.Format(KFormat, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(),
+     dt.Minute(), dt.Second());
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// TIdStack::Pop()
+// Pop id from the stack
+// -----------------------------------------------------------------------------
+//
+TInt TIdStack::Pop()
+    {
+    if (iPos<0)
+        {
+        LOGGER_WRITE( "TIdStack::Pop() returned KErrNotFound" );
+        return KErrNotFound;
+        }
+        
+    TInt id=iArray[iPos];
+    iPos--;
+    return id;
+    }
+
+// -----------------------------------------------------------------------------
+// TIdStack::Push( TInt aId )
+// Push id to the stack
+// -----------------------------------------------------------------------------
+//
+void TIdStack::Push( TInt aId )
+    {
+    if ( Size() >= KNestingLimit )
+        {
+        return;
+        }
+        
+    iPos++;
+    iArray[iPos] = aId;
+    }
+
+// -----------------------------------------------------------------------------
+// TIdStack::Size() const
+// Size of the stack
+// -----------------------------------------------------------------------------
+//
+TInt TIdStack::Size() const
+    {
+    return iPos+1;
+    }
+
+// -----------------------------------------------------------------------------
+// TIdStack::Reset()
+// Reset the stack.
+// -----------------------------------------------------------------------------
+//
+void TIdStack::Reset()
+    {
+    iArray.Reset();
+    iPos=-1;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/src/sconcsc.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSConCSC implementation
+*
+*/
+
+
+//
+// This program creates a polymorphic interface DLL that is used
+// to create capability object
+//
+
+// INCLUDE FILES
+
+#include <e32def.h>
+#include <e32uid.h>
+
+#include "sconcsc.h"
+#include "capinfo.h"
+#include "debug.h"
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CreateCSConCSCL()
+// Function to construct CSConCSC object. Note that this function
+// is exported at ordinal 1 and is not a member of any class.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSConCSC* CreateCSConCSCL()
+    {
+    TRACE_FUNC;
+    return CSConCSC::NewL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSConCSC::NewL()
+// Two-phase constructor
+// -----------------------------------------------------------------------------
+//
+CSConCSC* CSConCSC::NewL()
+    {
+    TRACE_FUNC_ENTRY;
+    CSConCSC* self = new (ELeave) CSConCSC();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConCSC::~CSConCSC()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSConCSC::~CSConCSC()
+    {
+    TRACE_FUNC_ENTRY;
+    delete iCapInfo;
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConCSC::CapabilityObject(CBufFlat& aBuf)
+// Creates a capability object data and sets data into aBuf.
+// -----------------------------------------------------------------------------
+//
+TInt CSConCSC::CapabilityObject(CBufFlat& aBuf)
+    {
+    TRACE_FUNC_ENTRY;
+    TRAPD(err, CSConCSC::CapabilityObjectL(aBuf));
+    LOGGER_WRITE_1( "CSConCSC::CapabilityObject(CBufFlat& aBuf) : returned %d", err );
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConCSC::ConstructL()
+// Initializes member data
+// -----------------------------------------------------------------------------
+//
+void CSConCSC::ConstructL()
+    {
+    iCapInfo = CCapInfo::NewL();
+    }
+
+// -----------------------------------------------------------------------------
+// CSConCSC::CSConCSC()
+// Default constructor
+// -----------------------------------------------------------------------------
+//
+CSConCSC::CSConCSC()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSConCSC::CapabilityObjectL(CBufFlat& aBuf)
+// Creates a capability object data and sets data into aBuf.
+// -----------------------------------------------------------------------------
+//
+void CSConCSC::CapabilityObjectL(CBufFlat& aBuf)
+    {
+    TRACE_FUNC_ENTRY;
+    iCapInfo->CapabilityDocumentL( &aBuf );
+    TRACE_FUNC_EXIT;
+    }
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/src/sconsyncservice.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,505 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSConSyncService implementation.
+*
+*/
+
+
+// Includes
+#include <centralrepository.h>
+#include <seconsdkcrkeys.h>
+
+#include <swi/sisregistryentry.h>   // for searching app name from installer
+#include <swi/sisregistrypackage.h>
+#include <swi/sisregistrysession.h>
+#include <javaregistryincludes.h>
+using namespace Java;
+
+#include "sconsyncservice.h"
+#include "capability.h"
+#include "debug.h"
+
+// Constants
+const TInt KDsAppUi = 0x101F6DE4; // NSmlDSSync.exe
+const TSmlDataProviderId KCalendarId = 0x101f6dde;
+const TSmlDataProviderId KContactsId = 0x101f6ddd;
+const TSmlDataProviderId KSmsId = 0x10206b5c;
+const TSmlDataProviderId KBookmarkId = 0x102751ba;
+
+const TInt KDateFormatLength(16);
+
+// -----------------------------------------------------------------------------
+// CSConSyncService::NewLC()
+// -----------------------------------------------------------------------------
+//
+CSConSyncService* CSConSyncService::NewLC()
+	{
+	TRACE_FUNC_ENTRY;
+	CSConSyncService* self = new (ELeave) CSConSyncService();
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	TRACE_FUNC_EXIT;
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConSyncService::CSConSyncService()
+// -----------------------------------------------------------------------------
+//
+CSConSyncService::CSConSyncService()
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CSConSyncService::~CSConSyncService()
+// -----------------------------------------------------------------------------
+//
+CSConSyncService::~CSConSyncService()
+	{
+	TRACE_FUNC_ENTRY;
+	if ( iApaSessionConnected )
+		{
+		iApaSession.Close();
+		}
+	if ( iSyncSessionOpened )
+		{
+		iSyncSession.Close();
+		}
+	delete iRepository;
+	TRACE_FUNC_EXIT;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConSyncService::ConstructL()
+// -----------------------------------------------------------------------------
+//
+void CSConSyncService::ConstructL()
+	{
+	iRepository = CRepository::NewL( KCRUidSecon );
+	}
+
+// -----------------------------------------------------------------------------
+// CSConSyncService::GetSolutionL()
+// Populate SolutionInfo according to content type.
+// -----------------------------------------------------------------------------
+//
+void CSConSyncService::GetSolutionL( const TUint aSeconContentType,
+		TSConSolutionInfo& aSolutionInfo )
+	{
+	TRACE_FUNC_ENTRY;
+	TInt appUid;
+	User::LeaveIfError( iRepository->Get( aSeconContentType, appUid ));
+    LOGGER_WRITE_2( "repository readed ok, uid: %d, hex:%x", appUid, appUid );
+    
+    aSolutionInfo.iUid = appUid;
+    if ( aSolutionInfo.iUid == KDsAppUi )
+        {
+        // read profile name
+        LOGGER_WRITE( "Search correct profile" );
+        GetLastUsedProfileNameL( aSolutionInfo.iSolutionName,
+        	aSolutionInfo.iTime, ProviderId( aSeconContentType ) );
+        }
+    else if ( aSolutionInfo.iUid != 0 )
+        {
+        LOGGER_WRITE( "Search correct application name" );
+        TUid appUid = {aSolutionInfo.iUid};
+        GetApplicationCaptionL( aSolutionInfo.iSolutionName, appUid );
+        
+        // get solution timestamp
+        TBuf<KDateFormatLength> timeBuffer;
+        // Timestamp is stored always in next to Uid value on cenrep
+        TInt err = iRepository->Get( aSeconContentType+1, timeBuffer );
+        
+        LOGGER_WRITE_1( "iRepository->Get(time) err: %d", err );
+        if ( err == KErrNone )
+        	{
+	        err = ParseTimestamp( aSolutionInfo.iTime, timeBuffer );
+	        LOGGER_WRITE_1( "ParseTimestamp err: %d", err );
+        	}
+        }
+    TRACE_FUNC_EXIT;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConSyncService::ProviderId()
+// Return correct providerId according to content type.
+// -----------------------------------------------------------------------------
+//
+TSmlDataProviderId CSConSyncService::ProviderId( const TUint32 aSeconContentType ) const
+	{
+	TSmlDataProviderId providerId(KErrNotFound);
+	switch (aSeconContentType)
+		{
+		case KSeconCalendarUid:
+		providerId = KCalendarId;
+		break;
+		case KSeconContactsUid:
+		providerId = KContactsId;
+		break;
+		case KSeconSmsUid:
+		providerId = KSmsId;
+		break;
+		case KSeconBookmarkUid:
+		providerId = KBookmarkId;
+		break;
+		default:
+		LOGGER_WRITE_1( "Invalid content type: %d", aSeconContentType );
+		}
+	return providerId;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConSyncService::ParseTimestamp()
+// Parses timestamp to TTime format
+// -----------------------------------------------------------------------------
+//
+TInt CSConSyncService::ParseTimestamp( TTime& aTime, const TDesC& aTimestamp ) const
+	{
+	// timestamp must be in following format:
+	// YYYYMMDDTHHMMSSZ
+	// MM=1..12, DD=1..number of days in month, HH=0..23, MM;SS=0..59
+	// Example 20071224T162215Z = 24.12.2007, 16:22:15 UTC time
+	
+	if ( aTimestamp.Length() != KDateFormatLength )
+		{
+		LOGGER_WRITE_1( "aTimestamp.Length(): %d", aTimestamp.Length() );
+		return KErrArgument;
+		}
+	
+	TPtrC temp;
+	temp.Set(aTimestamp.Ptr());
+	
+	TLex lex(temp.Mid(0,4));
+	TInt year;
+	TInt month;
+	TInt day;
+	TInt hour;
+	TInt minute;
+	TInt second;
+	TInt err = lex.Val( year );
+	if (err != KErrNone) return err;
+	
+	lex = temp.Mid(4,2);
+	err = lex.Val( month );
+	if ( err != KErrNone) return err;
+	month--;
+	
+	lex = temp.Mid(6,2);
+	err = lex.Val( day );
+	if (err != KErrNone) return err;
+	day--;
+	
+	lex = temp.Mid(9,2);
+	err = lex.Val( hour );
+	if (err != KErrNone) return err;
+	
+	lex = temp.Mid(11,2);
+	err = lex.Val( minute );
+	if (err != KErrNone) return err;
+	
+	lex = temp.Mid(13,2);
+	err = lex.Val( second );
+	if (err != KErrNone) return err;
+	
+	TDateTime parsedTime;
+	err = parsedTime.Set(year, (TMonth)month, day, hour, minute, second, 0);
+	if (err != KErrNone) return err;
+	
+	aTime = parsedTime;
+	return err;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConSyncService::GetApplicationCaptionL()
+// Get application caption.
+// -----------------------------------------------------------------------------
+//
+void CSConSyncService::GetApplicationCaptionL( TDes& aCaption, const TUid aAppUid )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TInt err(KErrNotReady);
+    // connect to RApaLsSession, if not yet ready
+    if ( !iApaSessionConnected )
+    	{
+    	err = iApaSession.Connect();
+    	if ( err == KErrNone )
+    		{
+    		iApaSessionConnected = ETrue;
+    		}
+    	}
+    
+    // Get application caption using RApaLsSession::GetAppInfo
+	TApaAppInfo appInfo;
+	if ( iApaSessionConnected )
+		{
+		err = iApaSession.GetAppInfo( appInfo ,aAppUid );
+		}
+    
+    LOGGER_WRITE_1( "GetAppInfo err: %d", err );
+    if ( err == KErrNone )
+    	{
+    	aCaption = appInfo.iCaption;
+    	}
+    else
+        {
+        // Caption does not exist, search application name from installer
+        GetInstPackageCaptionL( aCaption, aAppUid );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConSyncService::GetInstPackageCaptionL()
+// Search UID from installed applications, return app caption
+// -----------------------------------------------------------------------------
+//
+void CSConSyncService::GetInstPackageCaptionL( TDes& aCaption, const TUid aPackageUid )
+	{
+	TRACE_FUNC_ENTRY;
+    LOGGER_WRITE("Name not found, search from installer");
+    // Search application name from Installer.
+    Swi::RSisRegistrySession sisRegistry;
+    User::LeaveIfError( sisRegistry.Connect() );
+    CleanupClosePushL( sisRegistry );
+    
+    //Check if uid belongs to SIS package
+    if( sisRegistry.IsInstalledL( aPackageUid ) )
+        {
+        LOGGER_WRITE("SIS package found");
+        Swi::RSisRegistryEntry entry;
+        CleanupClosePushL(entry);
+        User::LeaveIfError( entry.Open( sisRegistry, aPackageUid ) );
+        aCaption.Copy( *entry.PackageNameL() );
+        CleanupStack::PopAndDestroy( &entry );
+        }
+    else
+        {
+        // not sis app, might be java app.
+        LOGGER_WRITE("SIS package not found");
+        CJavaRegistry* javaRegistry = CJavaRegistry::NewLC( );
+        TBool entryExist = javaRegistry->RegistryEntryExistsL( aPackageUid );
+        if ( entryExist )
+            {
+            CJavaRegistryEntry* entry = javaRegistry->RegistryEntryL( aPackageUid );
+            if ( entry )
+                {
+                aCaption.Copy( entry->Name() );
+                delete entry;
+                }
+            }
+        
+        CleanupStack::PopAndDestroy( javaRegistry ); 
+        }
+    
+    CleanupStack::PopAndDestroy( &sisRegistry );
+    TRACE_FUNC_EXIT;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConSyncService::GetLastUsedProfileNameL()
+// Gets last used profile for selected provider
+// -----------------------------------------------------------------------------
+//
+void CSConSyncService::GetLastUsedProfileNameL( TDes& aProfileName, TTime& aTime,
+		const TSmlDataProviderId& aDataProviderId )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( !iSyncSessionOpened )
+		{
+		iSyncSession.OpenL();
+		iSyncSessionOpened = ETrue;
+		}
+    RArray<TSmlProfileId> profiles;
+    CleanupClosePushL( profiles );
+    iSyncSession.ListProfilesL(profiles, ESmlDataSync );
+    TSmlProfileId lastSyncProfile(KErrNotFound);
+    TTime lastSyncTime(0);
+    LOGGER_WRITE_1( "Profiles count: %d", profiles.Count() );
+    for (TInt i=0; i<profiles.Count(); i++)
+    	{
+    	TTime syncTime(0);
+    	GetLastSyncTimeL( syncTime, profiles[i], aDataProviderId );
+    	if ( syncTime.Int64() != 0 && syncTime > lastSyncTime )
+    		{
+    		LOGGER_WRITE_1( "New record, profile: %d",profiles[i]);
+    		lastSyncTime = syncTime;
+    		lastSyncProfile = profiles[i];
+    		}
+    	}
+    CleanupStack::PopAndDestroy( &profiles );
+    LOGGER_WRITE_1( "lastSyncProfile: %d", lastSyncProfile );
+    if ( lastSyncProfile != KErrNotFound )
+    	{
+    	aTime = lastSyncTime;
+    	RSyncMLDataSyncProfile syncProfile;
+    	syncProfile.OpenL( iSyncSession, lastSyncProfile, ESmlOpenRead );
+    	TPtrC displayName = syncProfile.DisplayName();
+    	aProfileName.Copy( displayName );
+    	syncProfile.Close();
+    	}
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConSyncService::GetLastSyncTimeL()
+// Gets last sync time for certain profile and provider.
+// -----------------------------------------------------------------------------
+//
+void CSConSyncService::GetLastSyncTimeL( TTime& aTime, const TSmlProfileId aSyncProfileId,
+		const TSmlDataProviderId aDataProviderId  )
+	{
+	TRACE_FUNC_ENTRY;
+	LOGGER_WRITE_1( "aSyncProfileId: %d", aSyncProfileId );
+	LOGGER_WRITE_1( "aDataProviderId: 0x%08x", aDataProviderId );
+	if ( !iSyncSessionOpened )
+		{
+		LOGGER_WRITE("iSyncSession is not opened, Leave!");
+		User::Leave( KErrNotReady );
+		}
+	
+	RSyncMLDataSyncProfile syncProfile;
+	syncProfile.OpenL( iSyncSession, aSyncProfileId, ESmlOpenRead );
+    CleanupClosePushL( syncProfile );
+    LOGGER_WRITE( "syncProfile opened OK" );
+    
+    TSmlTaskId providerTask;
+    GetProviderTaskL( providerTask, syncProfile, aDataProviderId  );
+    if ( providerTask != KErrNone )
+    	{
+        RSyncMLHistoryLog historyLog;
+        historyLog.OpenL( iSyncSession, aSyncProfileId );
+        CleanupClosePushL( historyLog );
+        historyLog.SortEntries(CSyncMLHistoryEntry::ESortByTime);
+        LOGGER_WRITE_1( "historyLog.Count: %d", historyLog.Count() );
+        const CSyncMLHistoryJob* historyJob = LatestHistoryJob( historyLog, providerTask );
+        if ( historyJob )
+            {
+            aTime = historyJob->TimeStamp();
+#ifdef _DEBUG
+            TDateTime timeStamp = historyJob->TimeStamp().DateTime();
+            _LIT(KDateFormat, " (%04d%02d%02dT%02d%02d%02d)");
+            const TInt KDateFormatLength(20);
+            TBuf<KDateFormatLength> tempdate;
+            tempdate.Format(KDateFormat, timeStamp.Year(), timeStamp.Month()+1, timeStamp.Day()+1,
+                    timeStamp.Hour(), timeStamp.Minute(), timeStamp.Second());
+            LOGGER_WRITE_1("history found, TimeStamp: %S", &tempdate);
+#endif
+            }
+    	
+        CleanupStack::PopAndDestroy( &historyLog );
+    	}
+    CleanupStack::PopAndDestroy( &syncProfile );
+    TRACE_FUNC_EXIT;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConSyncService::GetProviderTaskL()
+// Gets provider task id from profile
+// -----------------------------------------------------------------------------
+//
+void CSConSyncService::GetProviderTaskL( TSmlTaskId& aProviderTask,
+		RSyncMLDataSyncProfile& aSyncProfile,
+		const TSmlDataProviderId aDataProviderId  ) const
+	{
+	TRACE_FUNC_ENTRY;
+	aProviderTask = KErrNotFound;
+	
+	RArray<TSmlTaskId> tasks;
+	CleanupClosePushL( tasks );
+	
+	aSyncProfile.ListTasksL( tasks );
+	LOGGER_WRITE_1( "tasks.Count: %d", tasks.Count() );
+	
+	for ( TInt i=0; i<tasks.Count() && aProviderTask==KErrNotFound; i++ )
+		{
+		RSyncMLTask syncTask;
+	    syncTask.OpenL( aSyncProfile, tasks[i] );
+	    if ( syncTask.DataProvider() == aDataProviderId )
+	        {
+	        LOGGER_WRITE_1( "dataprovider task found, taskId: %d", tasks[i] );
+	        aProviderTask = tasks[i];
+	        }
+	    syncTask.Close();
+		}
+	
+	CleanupStack::PopAndDestroy( &tasks );
+	TRACE_FUNC_EXIT;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConSyncService::LatestHistoryJob()
+// Gets latest historyJob where task is correct.
+// -----------------------------------------------------------------------------
+//
+ const CSyncMLHistoryJob* CSConSyncService::LatestHistoryJob(
+		 RSyncMLHistoryLog& aHistoryLog, TInt aTaskId ) const
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TInt count = aHistoryLog.Count();
+    if ( count == 0 )
+        {
+        LOGGER_WRITE( "profile has no history job" );
+        TRACE_FUNC_EXIT;
+        return NULL;  // profile has no history job
+        }
+
+    aHistoryLog.SortEntries(CSyncMLHistoryEntry::ESortByTime);    
+
+    // try to find latest sync job (start from last array entry)
+
+    for ( TInt i=count-1; i>=0; i-- )
+        {
+        const CSyncMLHistoryEntry& entry = aHistoryLog[i];
+        const CSyncMLHistoryJob* jobEntry = CSyncMLHistoryJob::DynamicCast(&entry);
+        if ( jobEntry )
+            {
+            if ( TaskExist(jobEntry, aTaskId) )
+                {
+                LOGGER_WRITE( "history job found" );
+                TRACE_FUNC_EXIT;
+                return jobEntry;
+                }
+            }
+        }
+    LOGGER_WRITE( "history job not found" );
+    TRACE_FUNC_EXIT;
+    return NULL;
+    }
+
+ // -----------------------------------------------------------------------------
+ // CSConSyncService::TaskExist()
+ // Returns ETrue if task exists in HistoryJob.
+ // -----------------------------------------------------------------------------
+ //
+TBool CSConSyncService::TaskExist( const CSyncMLHistoryJob* aHistoryJob, TInt aTaskId ) const
+    {
+    TRACE_FUNC_ENTRY;
+    TInt taskCount = aHistoryJob->TaskCount();
+    for ( TInt i=0; i<taskCount; i++ )
+        {
+        const CSyncMLHistoryJob::TTaskInfo& taskInfo = aHistoryJob->TaskAt(i);
+
+        if ( taskInfo.iTaskId == aTaskId )
+            {
+            LOGGER_WRITE( "task exists." );
+            TRACE_FUNC_EXIT;
+            return ETrue;
+            }
+        }
+    TRACE_FUNC_EXIT;
+    return EFalse;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/src/sconversioninfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,276 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSconVersionInfo implementation.
+*
+*/
+
+
+#include "sconversioninfo.h"
+
+#include <centralrepository.h>
+#include <DSCapabilityManagementCRKeys.h>
+#include <etel3rdparty.h> // read imsi
+#include <etel.h>
+#include <etelmm.h>
+#include <e32event.h>
+#include <e32svr.h>
+
+#include "caputils.h"
+#include "debug.h"
+
+CSconVersionInfo::CSconVersionInfo()
+    {
+    iSymbianVersionError = KErrNotReady;
+    iS60VersionError = KErrNotReady;
+    }
+
+CSconVersionInfo::~CSconVersionInfo()
+    {
+    delete iManufacturer;
+    delete iModel;
+    delete iProduct;
+    delete iRevision;
+    delete iSWVersion;
+    delete iSerialNumber;
+    delete iSysVersionInfo;
+    delete iLangVersion;
+    delete iLangSWVersion;
+    delete iOPVersion;
+    delete iProductCode;
+    }
+
+CSconVersionInfo* CSconVersionInfo::NewL()
+    {
+    CSconVersionInfo* self = new (ELeave) CSconVersionInfo;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSconVersionInfo::FetchInfoL()
+// fetch device info
+// -----------------------------------------------------------------------------
+//
+void CSconVersionInfo::FetchInfoL( RFs& aFs )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iSymbianVersionError = SysVersionInfo::GetVersionInfo( iSymbianVersion, aFs );
+    iS60VersionError = VersionInfo::GetVersion( iS60Version, aFs );
+    
+    TBuf<KSysVersionInfoTextLength> info;
+    TBuf<KSysVersionInfoTextLength> productBuf;
+    TInt err(KErrNone);
+    delete iSWVersion;
+    iSWVersion = NULL;
+    delete iProduct;
+    iProduct = NULL;
+    // get SW version, SW version date and model
+    TRAP( err, CapUtil::GetSWVersionL( info, iDate, productBuf ) );
+    iSWVersion = info.AllocL();
+    iProduct = productBuf.AllocL();
+    LOGGER_WRITE_1("CapUtil::GetSWVersionL err: %d", err);
+    
+    
+    SysVersionInfo::TProductVersion productVersion;
+    TInt sysVersionError = SysVersionInfo::GetVersionInfo( productVersion, aFs );
+    LOGGER_WRITE_1( "SysVersionInfo::GetVersionInfo returned : %d", sysVersionError );
+    
+    // Use TelServer to get IMEI and also other info if SysVersionInfo is not supported
+    RTelServer telServer;
+    User::LeaveIfError( telServer.Connect() );
+    CleanupClosePushL( telServer );
+    RTelServer::TPhoneInfo teleinfo;
+    User::LeaveIfError( telServer.GetPhoneInfo( 0, teleinfo ) );
+    RMobilePhone phone;
+    User::LeaveIfError( phone.Open( telServer, teleinfo.iName ) );
+    CleanupClosePushL( phone );
+    User::LeaveIfError(phone.Initialise()); 
+    TUint32 teleidentityCaps;
+    phone.GetIdentityCaps( teleidentityCaps );
+    RMobilePhone::TMobilePhoneIdentityV1 telid;
+    TRequestStatus status;
+    phone.GetPhoneId( status, telid );
+    User::WaitForRequest( status );
+    if ( status == KErrNone )
+        {
+        if ( sysVersionError )
+            {
+            LOGGER_WRITE("Use info from TMobilePhoneIdentityV1");
+            delete iModel;
+            iModel = NULL;
+            delete iRevision;
+            iRevision = NULL;
+            
+            // phone model sales name. For example "N01".
+            iModel = telid.iModel.AllocL();
+            // product revision. For example "01"
+            iRevision = telid.iRevision.AllocL();
+            }
+        delete iSerialNumber;
+        iSerialNumber = NULL;
+        // Phone serial number (IMEI or ESN), in character string format.
+        iSerialNumber = telid.iSerialNumber.AllocL();
+        }
+    
+    CleanupStack::PopAndDestroy( &phone );
+    CleanupStack::PopAndDestroy( &telServer );
+        
+    if ( sysVersionError == KErrNone )
+        {
+        // use information from SysVersionInfo instead of previous APIs.
+        LOGGER_WRITE("Using SysVersionInfo");
+        
+        // phone model sales name. For example "N01".
+        delete iModel;
+        iModel = NULL;
+        iModel = productVersion.iModel.AllocL();
+        // product revision. For example "01"
+        delete iRevision;
+        iRevision = NULL;
+        iRevision = productVersion.iRevision.AllocL();
+        // manufacturer name. For example "Nokia"
+        delete iManufacturer;
+        iManufacturer = NULL;
+        iManufacturer = productVersion.iManufacturer.AllocL();
+        // product code name. For example "RM-1"
+        delete iProduct;
+        iProduct = NULL;
+        iProduct = productVersion.iProduct.AllocL();
+        }
+    else
+        {
+        CapUtil::GetManufacturer( info );
+        delete iManufacturer;
+        iManufacturer = NULL;
+        iManufacturer = info.AllocL();
+        }
+        
+    CapUtil::GetLanguage( iLanguage );
+    
+    
+    err = SysVersionInfo::GetVersionInfo( SysVersionInfo::EFWVersion, info, aFs );
+    delete iSysVersionInfo;
+    iSysVersionInfo = NULL;
+    if ( !err )
+        {
+        iSysVersionInfo = info.AllocL();
+        }
+    
+    err = SysUtil::GetLangVersion( info );
+    delete iLangVersion;
+    iLangVersion = NULL;
+    if ( !err )
+        {
+        iLangVersion = info.AllocL();
+        }
+    
+    sysVersionError = SysUtil::GetLangSWVersion( info );
+    delete iLangSWVersion;
+    iLangSWVersion = NULL;
+    if ( !sysVersionError )
+        {
+        iLangSWVersion = info.AllocL();
+        }
+                
+    sysVersionError = SysVersionInfo::GetVersionInfo( SysVersionInfo::EOPVersion, info, aFs );
+    delete iOPVersion;
+    iOPVersion = NULL;
+    if ( !sysVersionError )
+        {
+        iOPVersion = info.AllocL();
+        }
+    
+    
+    sysVersionError = SysVersionInfo::GetVersionInfo( SysVersionInfo::EProductCode, info, aFs );
+    delete iProductCode;
+    iProductCode = NULL;
+    if ( !sysVersionError )
+        {
+        iProductCode = info.AllocL();
+        }
+    
+    // screen size
+    TPckgBuf<TScreenInfoV01> siBuf;
+    UserSvr::ScreenInfo(siBuf);
+    TScreenInfoV01& si=siBuf();
+    iScreenSize = si.iScreenSize;
+    
+    
+    // read DesktopSync key value
+    CRepository* repository(NULL);
+    TRAP( iDesktopSyncError, repository = CRepository::NewL( KCRUidDSDCMOConfig ));
+    if ( !iDesktopSyncError )
+        {
+        iDesktopSyncError = repository->Get( KNsmlDesktopSync, iDesktopSync );
+        LOGGER_WRITE_1("iDesktopSyncError: %d", iDesktopSyncError );
+        LOGGER_WRITE_1("iDesktopSync: %d", iDesktopSync );
+        delete repository;
+        }
+    else
+        {
+        LOGGER_WRITE_1("Could not create CRepository, err: %d", iDesktopSyncError );
+        }
+    
+    
+    
+    iInfoFetched = ETrue;
+    TRACE_FUNC_EXIT;   
+    }
+
+// -----------------------------------------------------------------------------
+// CSconVersionInfo::IsReady()
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CSconVersionInfo::IsReady()
+    {
+    return iInfoFetched;
+    }
+
+// -----------------------------------------------------------------------------
+// CSconVersionInfo::GetSymbianVersion()
+// Get Symbian OS version
+// -----------------------------------------------------------------------------
+//
+TInt CSconVersionInfo::GetSymbianVersion( SysVersionInfo::TSymbianOSVersion& aSymbianVersion )
+    {
+    if ( iSymbianVersionError )
+        {
+        return iSymbianVersionError;
+        }
+    else
+        {
+        aSymbianVersion = iSymbianVersion;
+        return KErrNone;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSconVersionInfo::GetS60Version()
+// Get S60 platform version
+// -----------------------------------------------------------------------------
+//
+TInt CSconVersionInfo::GetS60Version( VersionInfo::TPlatformVersion& aS60Version )
+    {
+    if ( iS60VersionError )
+        {
+        return iS60VersionError;
+        }
+    else
+        {
+        aS60Version = iS60Version;
+        return KErrNone;
+        }
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/src/stringlist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,277 @@
+/*
+* 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:  CStringList implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "stringlist.h"
+#include "capability.h"
+#include "debug.h"
+
+const TInt KMaxStringlistSize( 1000 );
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CStringList::NewL()
+// Two-phase constructor.
+// -----------------------------------------------------------------------------
+//
+CStringList* CStringList::NewL()
+    {
+    TRACE_FUNC_ENTRY;
+    CStringList* self = CStringList::NewLC();
+    CleanupStack::Pop( self );
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CStringList::NewLC()
+// Two-phase constructor. The created instance is placed to cleanup stack
+// -----------------------------------------------------------------------------
+//
+CStringList* CStringList::NewLC()
+    {
+    TRACE_FUNC_ENTRY;
+    CStringList* self = new ( ELeave ) CStringList();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CStringList::CStringList()
+// Default constuctor
+// -----------------------------------------------------------------------------
+//
+CStringList::CStringList()
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// CStringList::~CStringList()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CStringList::~CStringList()
+    {
+    TRACE_FUNC_ENTRY;
+    delete iLines;
+    iLines = NULL;
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CStringList::ConstructL()
+// Initializes member data
+// -----------------------------------------------------------------------------
+//
+void CStringList::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    const TInt KDefaultArrayGranularity = 10;
+    iLines = new (ELeave) CDesCArrayFlat(KDefaultArrayGranularity);
+    SetMark(0);
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CStringList::Count() const
+// Returns the count of lines
+// -----------------------------------------------------------------------------
+//
+TInt CStringList::Count() const
+    {
+    return iLines->Count();
+    }
+
+// -----------------------------------------------------------------------------
+// CStringList::Panic(TInt aPanic) const
+// Creates a panic
+// -----------------------------------------------------------------------------
+//
+#ifdef _DEBUG
+void CStringList::Panic(TInt aPanic) const
+#else
+void CStringList::Panic(TInt /*aPanic*/) const
+#endif
+    {
+    TRACE_FUNC_ENTRY;
+#ifdef _DEBUG
+    _LIT(KPanicCategory,"CStringList");
+
+    User::Panic(KPanicCategory, aPanic);
+#endif
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CStringList::Reset()
+// Resets iLines
+// -----------------------------------------------------------------------------
+//
+void CStringList::Reset()
+    {
+    iLines->Reset();
+    }
+
+// -----------------------------------------------------------------------------
+// CStringList::WriteL(const TDesC& aText)
+// Writes a string
+// -----------------------------------------------------------------------------
+//
+void CStringList::WriteL(const TDesC& aText)
+    {
+    iLines->AppendL(aText);
+    }
+
+// -----------------------------------------------------------------------------
+// CStringList::ReadPtr(TInt aIndex)
+// Returns pointer to the string
+// -----------------------------------------------------------------------------
+//
+TPtrC16 CStringList::ReadPtr(TInt aIndex)
+    {
+    if (aIndex<0 || aIndex>=Count())
+        {
+        Panic(KErrArgument);
+        }
+        
+    return iLines->MdcaPoint(aIndex);
+    }
+
+// -----------------------------------------------------------------------------
+// CStringList::CopyL(CStringList* aSource, TInt aStart, TInt aStop)
+// Copies a string / strings
+// -----------------------------------------------------------------------------
+//
+void CStringList::CopyL(CStringList* aSource, TInt aStart, TInt aStop)
+    {
+    if (aStart<0 || aStop>=aSource->Count() || aStart>aStop)
+        {
+        Panic(KErrArgument);
+        }        
+    
+    for (TInt i=aStart; i<=aStop; i++)
+        {
+        WriteL(aSource->ReadPtr(i));
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CStringList::StrCopy(TDes& aTarget, const TDesC& aSource) const
+// Copies the string
+// -----------------------------------------------------------------------------
+//
+TBool CStringList::StrCopy(TDes& aTarget, const TDesC& aSource) const
+    {
+    TInt len=aTarget.MaxLength();
+    if(len<aSource.Length()) 
+        {
+        aTarget.Copy(aSource.Left(len));
+        return EFalse;
+        }
+    aTarget.Copy(aSource);
+    return ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// CStringList::ReadFromFileL(const TDesC& aFileName)
+// Read strings from file.
+// -----------------------------------------------------------------------------
+//
+
+void CStringList::ReadFromFileL( RFs& aFs, const TDesC& aFileName )
+    {
+    InternalizeL( aFs, aFileName );
+    }
+
+// -----------------------------------------------------------------------------
+// CStringList::InternalizeL(const TDesC& aFileName)
+// Internalizes from file
+// -----------------------------------------------------------------------------
+//
+void CStringList::InternalizeL( RFs& aFs, const TDesC& aFileName )
+    {
+    
+    RFile file;
+    User::LeaveIfError( file.Open( aFs, aFileName, EFileRead ) );
+    CleanupClosePushL( file );
+    
+    
+    TFileText textFile;
+    textFile.Set( file );
+    textFile.Seek( ESeekStart );
+    TBuf<KMaxSize> buffer;
+    TInt count(0);
+    for (;;)
+        {
+        count++;
+        if ( count > KMaxStringlistSize )
+            {
+            break;
+            }           
+
+        buffer = KNullDesC;
+        
+        //
+        // Read seems to read chars until newline is reached or
+        // the descriptor is full. In case descriptor becomes full,
+        // err is KErrTooBig and next read starts from the next line. 
+        //
+        TInt err = textFile.Read( buffer );
+        if ( err == KErrEof )
+            {
+            break;
+            }
+            
+        if ( err != KErrNone )
+            {
+            User::Leave( err );
+            }           
+
+        iLines->AppendL( buffer );
+        }
+    
+    CleanupStack::PopAndDestroy( &file ); // file 
+    }
+
+
+// -----------------------------------------------------------------------------
+// CStringList::Mark() const
+// Returns the mark
+// -----------------------------------------------------------------------------
+//
+TInt CStringList::Mark() const
+    {
+    return iMark;
+    }
+
+// -----------------------------------------------------------------------------
+// CStringList::SetMark(TInt aMark)
+// Sets mark
+// -----------------------------------------------------------------------------
+//
+void CStringList::SetMark(TInt aMark)
+    {
+    iMark=aMark;
+    }
+
+// End of files
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/ftp/bld/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File Transfer Controller build file.
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS  
+DEFAULT
+
+PRJ_EXPORTS
+../loc/sconftp.loc  MW_LAYER_LOC_EXPORT_PATH(sconftp.loc)
+
+PRJ_MMPFILES
+../bld/sconftp.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/ftp/bld/def/bwinscwu.def	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?CreateCSConFTPL@@YAPAVCSConFTP@@XZ @ 1 NONAME ; class CSConFTP * CreateCSConFTPL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/ftp/bld/def/eabiuu.def	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,5 @@
+EXPORTS
+	_Z15CreateCSConFTPLv @ 1 NONAME
+	_ZTI8CSConFTP @ 2 NONAME ; #<TI>#
+	_ZTV8CSConFTP @ 3 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/ftp/bld/sconftp.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:  File Transfer Controller mmp file
+*
+*/
+
+
+// To get the MW_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_GENERAL_DLL
+
+TARGET          sconftp.dll
+TARGETTYPE      DLL
+
+UID             0x10009D8D 0x101F968A
+
+#if defined(ARMCC)
+DEFFILE ./def/eabiu
+#elif defined(WINSCW)
+DEFFILE ./def/bwinscw
+#elif defined(WINS)
+DEFFILE ./def/bwins
+#elif defined(ARM)
+DEFFILE ./def/bmarm
+#endif
+
+SOURCEPATH      ../src
+SOURCE          sconfshandler.cpp
+SOURCE          sconftp.cpp
+SOURCE          sconinboxhandler.cpp
+
+USERINCLUDE     ../../../inc
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../cntparser/inc
+
+
+APP_LAYER_SYSTEMINCLUDE
+
+
+START RESOURCE  ../src/sconftp.rss
+HEADER
+TARGETPATH      RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+
+LIBRARY         efsrv.lib               // For File server
+LIBRARY         euser.lib               // Base library
+LIBRARY         IrObex.lib              // For Object exchange
+LIBRARY         obexutils.lib
+LIBRARY         msgs.lib                // For Inbox entry
+LIBRARY         charconv.lib            // For Unicode conversion
+LIBRARY         bafl.lib                // Basic Application Framework Library
+LIBRARY         commonengine.lib        // For resource reader
+LIBRARY         platformenv.lib         // For pathinfo
+LIBRARY         CntParserServer.lib     // for contacts
+LIBRARY         directorylocalizer.lib  // For localizing directories
+LIBRARY         sysutil.lib
+LIBRARY         centralrepository.lib
+DEBUGLIBRARY    flogger.lib             // For debug logging
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/ftp/inc/sconconstants.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Common constants for PC Connectivity
+*
+*/
+
+
+#ifndef __SCONCONSTANTS_H
+#define __SCONCONSTANTS_H
+
+enum TSConProfile
+	{
+	EStandard = 0,
+	EProprietary,
+	EOther
+	};
+
+enum TSConUsedMedia
+	{
+	ESConNoMedia = 0,
+	ESConIRMedia,
+	ESConBTMedia,
+	ESConUSBMedia		
+	};
+
+#endif // __SCONCONSTANTS_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/ftp/inc/sconconsts.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,97 @@
+/*
+* 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:  Constant definitions for File Transfer Controller
+*
+*/
+
+
+#ifndef _SCONCONSTS_H_
+#define _SCONCONSTS_H_
+
+_LIT( K_C_ROOT, "C:\\" );
+
+// Following folders on MMC are exluded from folder listing
+_LIT( KSConResource, "resource\\" ); // resource folder on MMC
+_LIT( KSConSys, "sys\\" );           // sys folder on MMC
+_LIT( KSConPrivate, "private\\" );   // private folder on MMC
+_LIT( KSConSystem, "system\\" );     // system folder on MMC
+
+// Suite needs access to SuiteConf.xml file
+_LIT( KSConAllowedPath, "Z:\\Private\\101F7C87" );
+
+// For folder listing
+_LIT8( KSConXmlDocBegin,
+       "<?xml version=\"1.0\"?>\n<!DOCTYPE folder-listing SYSTEM \"obex-folder-listing.dtd\"\n  [ <!ATTLIST folder mem-type CDATA #IMPLIED>\n  <!ATTLIST folder label CDATA #IMPLIED> ]>\n<folder-listing version=\"1.0\">\n" );
+_LIT8( KSConXmlParentFolder, "   <parent-folder />\n" );
+_LIT8( KSConXmlFileNameBegin,"   <file name=\"" );
+_LIT8( KSConXmlFolderNameBegin,"   <folder name=\"" );
+_LIT8( KSConXmlDriveNameBegin,"   <drive name=\"" );
+_LIT8( KSConXmlType,"\" type=\"" );
+_LIT8( KSConXmlModified,"\" modified=\"" );
+_LIT8( KSConXmlSize,"\" size=\"" );
+_LIT8( KSConXmlUserAttributes,"\" user-perm=\"" );
+_LIT8( KSConXmlMemoryType,"\" mem-type=\"" );
+_LIT8( KSConXmlMemoryLabel,"\" label=\"" );
+
+_LIT8( KSConXmlTypeWord, "x-epoc/x-app268450404" );
+_LIT8( KSConXmlTypeSheet, "x-epoc/x-app268450429" );
+
+_LIT8( KSConXmlUserEntryArchive,"RWD" );
+_LIT8( KSConXmlUserEntryReadOnly,"R" );
+_LIT8( KSConXmlUserEntryDrive, "RW" );
+
+_LIT8( KSConXmlFileEnd,"\"/>\n" );
+_LIT8( KSConXmlFolderListEnd,"</folder-listing>" );
+_LIT8( KSConDriveCName,"C:" );
+_LIT8( KSConDriveZName,"Z:" );
+_LIT8( KSConFolderListType, "x-obex/folder-listing" );
+
+const TInt KSConMemTypeMaxLength = 5;
+_LIT8( KSConMemoryTypeDev, "DEV" ); // prefix for device memory
+_LIT8( KSConMemoryTypeMmc, "MMC" ); // prefix for MMC memory
+
+// Date field format
+_LIT( KSConXmlDate, "%F%Y%M%DT%H%T%SZ" );
+const TInt KSConDateMaxLength = 16;
+
+//File extensions
+_LIT( KSConEpocWordExt, ".ewd" );
+_LIT( KSConEpocSheetExt, ".sht" );
+
+_LIT8( KFind1,"&" );
+_LIT8( KReplace1, "&amp;" );
+_LIT8( KReplace2, "&lt;" );
+_LIT8( KReplace3, "&gt;" );
+_LIT8( KReplace4, "&quot;" );
+_LIT8( KReplace5, "&apos;" );
+
+_LIT( KSConResourceName, "z:\\Resource\\sconftp.rsc" );
+
+const TInt KSConBufSize = 1024;
+const TInt KSConSetPathDontCreate = 0x01;   // Flags used to indicate SetPath commands
+const TInt KSConSetPathRoot = 0x02;         // Flags used to indicate SetPath commands
+const TInt KSConSetPathForward = 0x02;      // Flags used to indicate SetPath commands
+const TInt KSConSetPathBack = 0x03;         // Flags used to indicate SetPath commands
+const TInt KSConXmlBufSize = 30;
+const TInt KSConDriveNameLength = 2;
+const TInt KSConMaxMimeTypeLength = 25;
+const TInt KSConBufferSize = 262144; // 256KB
+
+const TUid KSConSheetUid = { 0x10003a7d };  // Sheet document uid
+const TUid KSConWordUid = { 0x10003a64 };   // Word document uid
+
+const TInt KDriveLength = 3;
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/ftp/inc/sconfshandler.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:  CSConFSHandler header file
+*
+*/
+
+
+#ifndef _SCONFSHANDLER_H_
+#define _SCONFSHANDLER_H_
+
+// INCLUDES
+
+#include <e32base.h>
+#include <obexobjects.h>
+
+
+// FORWARD DECLARATIONS
+class CDirectoryLocalizer;
+
+
+//============================================================
+// Class CSConFsHandler declaration
+//============================================================
+NONSHARABLE_CLASS( CSConFsHandler ) : public CBase
+    {
+    public:
+        static CSConFsHandler* NewL( RFs& aFs );
+        ~CSConFsHandler();
+        /**
+         * Parses folder and file listing from specified directory
+         * @param aBuffer Buffer to store the folder list
+         * @param aPathName Folder path
+         * @param aMemNumber memory number (1= DEV or MMC, 2= DEV2 or MMC2..)
+         * @return KErrNone if no errors, else system wide error codes.
+         */
+        TInt ParseFolderListL( CBufFlat* aBuffer, const TPtrC aPathName,
+            const TInt aMemNumber );
+        /**
+         * Gets a file object
+         * @param aBuffer CObexFileObject object where the file will be stored
+         * @param aPathName The path of the file
+         * @param aFileName The name of the file
+         * @return KErrNone if no errors, else system wide error codes.
+         */
+        TInt GetFileObjectL( CObexFileObject*& aBuffer, const TPtrC aPathName,
+            const TPtrC aFileName );
+        /**
+         * Stores a file object
+         * @param aFullPathName The full path and name of the file
+         * @param aTime The time stamp of the file
+         * @param aTempFileName Data temp file
+         * @return KErrNone if no errors, else system wide error codes.
+         */
+        TInt SaveFileObjectL( const TPtrC aFullPathName, const TTime aTime, 
+            const TPtrC aTempFileName );
+        /**
+         * Validates the file name
+         * @param aName File name to be validated
+         * @return KErrNone if no errors, else system wide error codes.
+         */
+        TInt ValidateFileName( const TPtrC aName );
+        /**
+         * Creates a folder
+         * @param aFolderPath The name and the path of the folder
+         * @return KErrNone if no errors, else system wide error codes.
+         */
+        TInt CreateFolderL( const TPtrC aFolderPath );
+        /**
+         * Removes a folder or a file
+         * @param aFullPath The path and name of the object
+         * @return KErrNone if no errors, else system wide error codes.
+         */
+        TInt DeleteObjectL( const TPtrC aFullPath );
+        
+        /**
+         * Copy or Move file/folder
+         * @param aSource
+         * @param aTarget
+         * @param aUseCopyCommand if ETrue does copy, else does move.
+         * @return none.
+         */
+        void DoCopyOrMoveFileL( const TDesC& aSource, const TDesC& aTarget,
+            const TBool aUseCopyCommand );
+        
+        /**
+         * Check if folder can be showed
+         * @param aFullPath The path of the object
+         * @return ETrue if folder exists and can be showed.
+         */
+        TBool IsFolderVisible( const TDesC& aFullPath );
+        
+    private:
+        CSConFsHandler( RFs& aFs );
+        void ConstructL();
+        /**
+         * Updates the name of the data folder from a localized string
+         * @param none
+         * @return none
+         */
+        void GetDataPathNameL();
+        
+        /**
+         * Check if folder is read only
+         * @param aFullPath The path of the object
+         * @return ETrue if folder is read only, or if folder does not exist
+         */
+        TBool IsFolderReadOnly( const TDesC& aFullPath ) const;
+        /**
+         * Check if folder can be deleted
+         * @param aFullPath The path of the object
+         * @return ETrue if folder can be deleted
+         */
+        TBool IsFolderDeletable( const TDesC& aFullPath ) const;
+        /**
+         * Get parent folder
+         * @param aFullPath The folder full path with or without backlash ending
+         * @param aParent The founded parent folder with backlash
+         * @return KErrNone if parent folder founded
+         */
+        TInt GetParentFolder( const TDesC& aFullPath, TDes& aParent);
+        
+        /**
+         * Get folder (and subfolders) size
+         * @param aFullPath The folder full path with backlash ending
+         * @return folder total size
+         */
+        TInt64 GetFolderSizeL( const TDesC& aFullPath );
+        
+        /**
+         * Replaces all special characters to xml compliant ones
+         * @param aDes characters to be checked and replaced
+         */
+        void ReplaceSpecialChars( TDes8& aDes );
+        
+        /**
+         * Check if folder is exluded and cannot be shown to user
+         * @param aFullPath The full path with backlash ending
+         * @return ETrue if folder is exluded
+         */
+        TBool IsExludedPath( const TDesC& aFullPath ) const;
+        
+		/**
+		 * Prints folder information to obex-folder-list
+		 */
+        void PrintFolderL( CBufFlat* aBuffer, TInt& aOffset, const TDesC& aParentPath,
+                            const TDesC8& aMemType, const TEntry& aFolderEntry );
+        /**
+		 * Prints file information to obex-folder-list
+		 */
+        void PrintFileL( CBufFlat* aBuffer, TInt& aOffset, const TEntry& aFileEntry );
+        
+    private:
+        RFs&                 iFs; // not own
+        CDirectoryLocalizer* iLocalizer;
+        TBuf8<KMaxFileName> iDataPathName;  // Localized data path
+    };
+
+#endif
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/ftp/inc/sconftp.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,261 @@
+/*
+* 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:  CSConFTP header file
+*
+*/
+
+
+#ifndef _SCONFTP_H_
+#define _SCONFTP_H_
+
+// INCLUDES
+
+#include <e32base.h>
+#include <obexobjects.h>
+
+#include "sconconstants.h"
+
+class CSConInboxHandler;
+class CSConFsHandler;
+
+//============================================================
+// Class CSConFTP declaration
+//============================================================
+class CSConFTP : public CBase
+    {
+    public:
+        // construct / destruct
+        static CSConFTP* NewL();        
+        ~CSConFTP();
+
+        // methods
+         /**
+         * Gets object that contains folder listing from inbox or file system
+         * @param aObject CObexBufObject object
+         * @return KErrNone if no errors, else system wide error codes.
+         */
+         virtual TInt GetFolderObjectL( CObexBufObject*& aObject );
+
+         /**
+         * Gets object that contains a file from file system
+         * @param aFileObject CObexFileObject object
+         * @return KErrNone if no errors, else system wide error codes.
+         */
+         virtual TInt GetFileObjectL( CObexFileObject*& aFileObject );
+
+         /**
+         * Initializes the receiving from the client.
+         * @param aObject CObexBufObject object
+         * @param aObject CBufFlat object
+         * @return KErrNone if no error, else system wide error codes.
+         */
+         virtual TInt PutFileObjectInitL( CObexBufObject*& aObject, 
+                                            CBufFlat*& aBuffer );
+
+         /**
+         * Stores the relayed file object to inbox or file system.
+         * @param aObject CObexBufObject object
+         * @return KErrNone if no error, else system wide error codes.        
+         */
+         virtual TInt PutFileObjectFinalizeL( CObexBufObject*& aObject );
+
+         /**
+         * Changes the current path. The path can point to inbox or file system
+         * @param aPathName The name of the new path
+         * @param aFlags Flag value of OBEX Setpath operation
+         * @return KErrNone if no error, else system wide error codes.
+         */
+         virtual TInt SetPathL( const TPtrC aPathName, const TUint8 aFlags );
+
+         /**
+         * Creates a new folder to file system
+         * @param aFolderName The name of the folder to be created
+         * @return KErrNone if no error, else system wide error codes.
+         */
+         virtual TInt CreateFolderL( const TPtrC aFolderName );
+
+         /**
+         * Deletes file/folder from inbox or file system
+         * @param aObjectName The name of the object (file or folder) to be created
+         * @return KErrNone if no error, else system wide error codes.
+         */
+         virtual TInt DeleteObjectL( const TPtrC aObjectName );
+
+         /**
+         * Gets the current path
+         * @param aPath The name of the current path
+         * @return KErrNone if no error, else system wide error codes.
+         */
+         virtual TInt GetPath( TDes& aPath );
+         
+         /**
+         * Abort file transfer
+         * @param aObject The OBEX stack object which will reseted
+         * @return KErrNone if no error, else system wide error codes.
+         */
+         virtual TInt AbortFileTransfer( CObexBufObject*& aObject );
+
+         /**
+         * Set used transfer profile
+         * @param aProfile The profile id
+         * @return none
+         */
+         virtual void SetProfile( TSConProfile aProfile );
+
+         /**
+         * Set backup status
+         * @param aValue Is backup started or not
+         * @return none
+         */
+         virtual void SetBackupStarted( TBool aValue );
+         
+         /**
+         * Set the used media information
+         * @param aMedia The media which is currently used
+         * @return none
+         */
+         virtual void SetUsedMedia( TSConUsedMedia aMedia );
+
+         /**
+         * Check is current drive space below critical level
+         * @param aFilesize, additional free space needed
+         * @return ETrue if below critical                                                  
+         */
+         virtual TBool IsCurrentDiskSpaceBelowCritical( TUint32 aFilesize = 0 );
+         
+         /**
+         * Read received ConML protocol packet
+         * @param aBuffer The buffer for the data
+         * @return KErrNone if no error, else system wide error codes.                                                                        
+         */
+         virtual TInt ReadWBXMLDataL( CBufFlat*& aBuffer );
+         
+         /**
+         * Delete OBEX stack's temp file
+         * @param none
+         * @return KErrNone if no error, else system wide error codes.
+         */
+         virtual void DeleteTempFile();
+         
+         /**
+         * Move or rename file/folder
+         * @param aSource
+         * @param aTarget
+         * @return KErrNone if no error, else system wide error codes.
+         */
+         virtual TInt MoveFile( const TDesC& aSource, const TDesC& aTarget );
+         
+         /**
+         * Copy file/folder
+         * @param aSource
+         * @param aTarget
+         * @return KErrNone if no error, else system wide error codes.
+         */
+         virtual TInt CopyFile( const TDesC& aSource, const TDesC& aTarget );
+         
+         /**
+         * Set read-only attribute to file or folder
+         * @param aTarget file or folder fullname
+         * @param aReadOnly set read-only permission to ETrue or EFalse
+         * @return KErrNone if no error, else system wide error codes.
+         */
+         virtual TInt SetReadOnly( const TDesC& aTarget, const TBool aReadOnly );
+         
+        /**
+         * Set hidden attribute to file or folder
+         * @param aTarget file or folder fullname
+         * @param aHidden set read-only permission to ETrue or EFalse
+         * @return KErrNone if no error, else system wide error codes.
+         */
+        virtual TInt SetHidden( const TDesC& aTarget, const TBool aHidden );
+         
+    private:
+        // methods
+        /**
+         * Get absolute path from given relative foldername
+         * @param aFolderName relative or absolute filename
+         * @param aFullPath return absolete path of file/folder
+         * @return KErrNone if no error, else system wide error codes.
+        */
+        virtual TInt GetAbsolutePath( const TDesC& aFolderName, TDes& aFullPath );
+        
+        /**
+         * Checks if user can see/access to the drive
+         * @param aDriveNumber drive to be tested
+         * @return ETrue if user can see drive.
+        */
+        TBool IsDriveVisible( const TInt aDriveNumber );
+        
+        /**
+         * Checks if user access to the current volume
+         * @param none
+         * @return ETrue if volume is ok.
+        */
+        TBool IsCurrentVolumeOK();
+        
+        /**
+         * Go to (sub)directory
+         * @param aPath (sub)directory
+         * @param aFlags used to check if new folder(s) should be created
+         * @return KErrNone if no error, else system wide error codes.
+        */
+        TInt SetPathForwardL( const TPtrC aPath, const TUint8 aFlags );
+        
+        /**
+         * Go to parent directory
+         * @param aPath subdirectory under parent (additional)
+         * @return KErrNone if no error, else system wide error codes.
+        */
+        TInt SetPathBackwardL( const TPtrC aPath );
+        
+        /**
+         * Get volume name (Memory card name)
+         * @param aDriveNumber drive where to read
+         * @param aVolumeName if name found return volume name, else localised string
+         * @return KErrNone if no error, else system wide error codes.
+        */
+        TInt GetVolumeNameL(const TInt aDriveNumber, TDes8& aVolumeName);
+        
+        /**
+         * Updates drive information (iCurrentDrive and iCurrentDriveTypeNumber)
+         * @param none
+         * @return none, leaves if error occurs.
+        */
+        void UpdateDriveTypeInfoL();
+        
+        CSConFTP();
+        virtual void ConstructL();
+    
+    private:
+        CSConInboxHandler*                  iSConInboxHandler;  // Object saving-fetching
+        CBufFlat*                           iBuffer;            // Temporary buffer
+        CSConFsHandler*                     iSConFsHandler;     // Object saving-fetching
+        TBuf<KObexObjectDescriptionSize>    iPathName;          // Path
+        TFileName                           iTempFileName;      // Temp file name
+        RFs                                 iFs;
+        TSConProfile                        iProfile;           // Used profile
+        TBool                               iBackupStarted;
+        TSConUsedMedia                      iMedia;
+        TInt                                iCurrentDrive;
+        TInt                                iCurrentDriveTypeNumber; // DEV=1, DEV2=2, MMC=1, MMC2=2.
+        TInt                                iCriticalDiskLevel;
+    };
+
+    IMPORT_C CSConFTP* CreateCSConFTPL();
+    typedef CSConFTP* (*TSConCreateCSConFTPFunc) ();   
+
+
+#endif // SCONFTP
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/ftp/inc/sconinboxhandler.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,84 @@
+/*
+* 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:  CSConInboxHandler header file
+*
+*/
+
+
+#ifndef _SCONINBOXHANDLER_H_
+#define _SCONINBOXHANDLER_H_
+
+// INCLUDES
+
+#include <e32base.h>
+#include <e32cons.h>
+#include <msvapi.h>
+
+
+//============================================================
+// Class CSConInboxHandler declaration
+//============================================================
+NONSHARABLE_CLASS( CSConInboxHandler ) : public CBase, MMsvSessionObserver
+    {
+    public:
+        static CSConInboxHandler* NewL();
+        virtual ~CSConInboxHandler();
+        
+        /**
+         * Creates an attachment to device's Inbox
+         * @param aObject CObexBufObject object
+         * @return KErrNone if no errors, else system wide error codes.
+         */
+        TInt CreateInboxAttachmentL( CObexBufObject*& aObject, 
+                                        CBufFlat*& aBuffer );
+        /**
+         * Saves the object to the Inbox
+         * @param aObject CObexBufObject object
+         * @return KErrNone if no errors, else system wide error codes.
+         */
+        TInt SaveObjToInboxL( CObexBufObject*& aObject );
+        /**
+         * Aborts the storing operation
+         * @param aObject CObexBufObject object
+         * @return KErrNone if no errors, else system wide error codes.
+         */
+        TInt AbortInboxOperation( CObexBufObject*& aObject );
+        /**
+         * Implementation of MMsvSessionObserver::HandleSessionEventL
+         * @param aEvent Indicates the event type. 
+         * @param aArg1 Event type-specific argument value 
+         * @param aArg2 Event type-specific argument value 
+         * @param aArg3 Event type-specific argument value
+         * @return none
+         */
+        void HandleSessionEventL( TMsvSessionEvent aEvent, 
+                                TAny* aArg1, 
+                                TAny* aArg2, 
+                                TAny* aArg3 );
+        
+    private:
+        CSConInboxHandler();
+        
+        TInt GetMessageCenterDriveL();
+        
+    private:
+        TInt            iDrive;
+        TMsvId          iMsvIdParent;
+        TMsvId          iMsvIdAttach;
+        RFile           iFile;          
+};
+
+#endif
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/ftp/loc/sconftp.loc	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Localization file for csconftp
+*
+*/
+
+
+//d:Default name for device
+//l:list_double_pane_t2_cp2
+#define	qtn_secon_device "Phone"
+
+//d:Default name for memory card
+//l:list_double_pane_t2_cp2
+#define	qtn_secon_mmc "Memory card"
+
+//d:Default name for mass storage
+//l:None
+//r:3.2
+#define	qtn_secon_mass_storage "Mass memory"
+
+//d:Default name for data folder
+//l:None
+//r:3.2
+#define	qtn_secon_data_folder "Personal files"
+
+// d: Value in a PC Suite dialog showing program details
+// l: None
+// r: 3.2
+#define qtn_secon_unknown_supplier "Unknown"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/ftp/src/sconfshandler.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1497 @@
+/*
+* 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 Transfer Controller implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include <stringresourcereader.h>
+#include <sconftp.rsg>
+#include <pathinfo.h>
+#include <connect/sbdefs.h> // to get backup/restore mode
+#include <driveinfo.h>
+#include <bautils.h>
+#include <sysutil.h>
+#include <CDirectoryLocalizer.h>
+
+#include "sconfshandler.h"
+#include "sconconsts.h"
+#include "irmcconsts.h"
+#include "cntparserclient.h"
+#include "cntparserinfolog.h"
+#include "debug.h"
+
+_LIT(KPhoneBookIrMCL2Request,"telecom/pb.vcf");
+_LIT(KInfoLogIrMCL2Request,"telecom/pb/info.log");
+_LIT(KInfoLogIrMCL2File,"IrMC\\info.log");
+_LIT(KInfoLogPathAndFileName,"c:\\IrMC\\info.log");
+_LIT(KPbPathAndFileName,"c:\\IrMC\\pb.vcf");
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSConFsHandler::NewL()
+// Two-phase constructor
+// -----------------------------------------------------------------------------
+//
+CSConFsHandler* CSConFsHandler::NewL( RFs& aFs )
+    {
+    TRACE_FUNC_ENTRY;
+    CSConFsHandler* self = new (ELeave) CSConFsHandler( aFs );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFsHandler::~CSConFsHandler()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSConFsHandler::~CSConFsHandler()
+    {
+    TRACE_FUNC_ENTRY;
+    delete iLocalizer;
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFsHandler::ParseFolderListL( CBufFlat* aBuffer, const TPtrC aPathName
+//                                  , const TInt aMemNumber )
+// Parses folder and file listing from specified directory
+// -----------------------------------------------------------------------------
+//
+TInt CSConFsHandler::ParseFolderListL( CBufFlat* aBuffer, const TPtrC aPathName,
+                                       const TInt aMemNumber )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "CSConFsHandler::ParseFolderListL aPathName =  %S", &aPathName );
+    if( aPathName.Length() == 0 )
+        {
+        LOGGER_WRITE( "CSConFsHandler::ParseFolderListL( CBufFlat* aBuffer, const TPtrC aPathName ) : No path" );
+        return KErrArgument;
+        }
+            
+    if( aPathName.Length() > KDriveLength && !BaflUtils::FolderExists( iFs, aPathName ) )
+        {
+        LOGGER_WRITE( "CSConFsHandler::ParseFolderListL( CBufFlat* aBuffer, const TPtrC aPathName ) : Current folder doesn't exist any more" );
+        return KErrNotFound;
+        }
+    
+    TInt driveNumber;
+    TInt err = iFs.CharToDrive(aPathName[0], driveNumber);
+    if( err )
+        {
+        LOGGER_WRITE_1( "CSConFsHandler::ParseFolderListL : CharToDrive err: %d", err );
+        return KErrNotFound;
+        }
+    TUint driveStatus;
+    err = DriveInfo::GetDriveStatus( iFs, driveNumber, driveStatus);
+    if( err )
+        {
+        LOGGER_WRITE_1( "CSConFsHandler::ParseFolderListL : DriveInfo::GetDriveStatus err: %d", err );
+        return KErrNotFound;
+        }
+    
+    // check mem type (DEV, DEV2, MMC, MMC2..)
+    TBuf8<KSConMemTypeMaxLength> memType;
+    if( driveStatus & DriveInfo::EDriveInternal )
+        {
+        memType.Copy( KSConMemoryTypeDev );
+        if( aMemNumber > 1 )
+            {
+            memType.AppendNum(aMemNumber);
+            }
+        }
+    else if( driveStatus & DriveInfo::EDriveRemovable )
+        {
+        memType.Copy( KSConMemoryTypeMmc );
+        if( aMemNumber > 1 )
+            {
+            memType.AppendNum(aMemNumber);
+            }
+        }
+
+    CDir *entryList = 0;
+    CDir *dirList = 0;
+    
+    // show only normal files and folders
+    TUint entryAttMask = KEntryAttNormal;
+    
+    
+    // get folders and files
+    err = iFs.GetDir( aPathName, entryAttMask, ESortByName, 
+            entryList, dirList );
+    
+    if ( err )
+        {
+        LOGGER_WRITE_1( "ParseFolderListL GetDir returned: %d", err );
+        return err;
+        }
+    
+    CleanupStack::PushL( entryList );
+    CleanupStack::PushL( dirList );
+    
+    TInt offset = 0;
+    
+    LOGGER_WRITE( "CSConFsHandler::ParseFolderList XML creation" );
+    //Create folder XML
+    aBuffer->ResizeL( KSConXmlDocBegin().Length() );
+    aBuffer->Write( offset, KSConXmlDocBegin );
+    offset += KSConXmlDocBegin().Length();
+
+    aBuffer->ExpandL( offset, KSConXmlParentFolder().Length() );
+    aBuffer->Write( offset, KSConXmlParentFolder );
+    offset += KSConXmlParentFolder().Length();
+
+    HBufC* fullNameBuf = HBufC::NewLC( KMaxPath );
+    TPtr fullName = fullNameBuf->Des();
+    
+    // Print folders to folder listing object
+    for( TInt i = 0; i < dirList->Count(); i++ )
+        {
+        const TEntry entry = ( *dirList )[i];
+        
+        fullName.Copy( aPathName );
+        fullName.Append( entry.iName );
+        fullName.Append( KPathDelimiter );
+        
+        // show path if not exluded
+        TBool proceed = !IsExludedPath( fullName );
+        if ( proceed )
+            {
+            PrintFolderL( aBuffer, offset, fullName, memType, entry );
+            }
+        }
+    CleanupStack::PopAndDestroy( fullNameBuf );
+    CleanupStack::PopAndDestroy( dirList );
+    
+    LOGGER_WRITE("Print files");
+    // Print files to folder listing object
+    for( TInt j = 0; j < entryList->Count(); j++ )
+        {
+        const TEntry entry = ( *entryList )[j];
+        PrintFileL( aBuffer, offset, entry );
+        }
+    LOGGER_WRITE("files printed");
+    //Write the end of XML
+    aBuffer->ExpandL( offset, KSConXmlFolderListEnd().Length() );
+    aBuffer->Write( offset, KSConXmlFolderListEnd );
+    aBuffer->Compress();
+    
+    CleanupStack::PopAndDestroy( entryList );
+
+    LOGGER_WRITE_1( "CSConFsHandler::ParseFolderListL() : returned %d", err );
+    return err;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSConFsHandler::PrintFolderL
+// Prints folder entry to folder listing object
+// -----------------------------------------------------------------------------
+//
+void CSConFsHandler::PrintFolderL( CBufFlat* aBuffer, TInt& aOffset, const TDesC& aFullPath,
+                    const TDesC8& aMemType, const TEntry& aFolderEntry )
+    {
+    TRACE_FUNC_ENTRY;
+    // initialize Localizer
+    iLocalizer->SetFullPath( aFullPath );
+    
+    TBool dataPath( EFalse );
+    if ( aFullPath.CompareF( PathInfo::PhoneMemoryRootPath() ) == 0 ) // datapath
+        {
+        // printable folder is C:\Data (Localized)
+        dataPath = ETrue;
+        }
+    
+    // print foldername
+    aBuffer->ExpandL( aOffset, KSConXmlFolderNameBegin().Length() );
+    aBuffer->Write( aOffset, KSConXmlFolderNameBegin );
+    aOffset += KSConXmlFolderNameBegin().Length();
+    
+    HBufC8* folderBuf = HBufC8::NewLC( KMaxFileName );
+    TPtr8 folderName = folderBuf->Des();
+    User::LeaveIfError( 
+        CnvUtfConverter::ConvertFromUnicodeToUtf8( folderName, aFolderEntry.iName ) );
+    
+    //Replace special characters
+    ReplaceSpecialChars( folderName );
+
+    aBuffer->ExpandL( aOffset, folderName.Length() );
+    aBuffer->Write( aOffset, folderName );
+    aOffset += folderName.Length();
+    
+    CleanupStack::PopAndDestroy( folderBuf );
+    
+    // print modified time
+    TBuf<KSConDateMaxLength> modifiedTime;
+    TTime time = aFolderEntry.iModified;
+    time.FormatL( modifiedTime, KSConXmlDate );
+    
+    TBuf8<KSConDateMaxLength> modifiedTime8;
+    User::LeaveIfError( 
+        CnvUtfConverter::ConvertFromUnicodeToUtf8( modifiedTime8, modifiedTime ) );
+    
+    aBuffer->ExpandL( aOffset, KSConXmlModified().Length() );
+    aBuffer->Write( aOffset, KSConXmlModified );
+    aOffset += KSConXmlModified().Length();
+    
+    aBuffer->ExpandL( aOffset, modifiedTime8.Length() );
+    aBuffer->Write( aOffset, modifiedTime8 );
+    aOffset += modifiedTime8.Length();
+    
+    // print attributes
+    aBuffer->ExpandL( aOffset, KSConXmlUserAttributes().Length() );
+    aBuffer->Write( aOffset, KSConXmlUserAttributes );
+    aOffset += KSConXmlUserAttributes().Length();
+    
+    // Add user-perm info
+    if( aFolderEntry.IsReadOnly() )
+        {
+        aBuffer->ExpandL( aOffset, 
+            KSConXmlUserEntryReadOnly().Length() );
+        aBuffer->Write( aOffset, KSConXmlUserEntryReadOnly );
+        aOffset += KSConXmlUserEntryReadOnly().Length();
+        }
+    else if( iLocalizer->IsLocalized() || dataPath ) // delete disabled
+        {
+        aBuffer->ExpandL( aOffset, 
+            KSConXmlUserEntryDrive().Length() );
+        aBuffer->Write( aOffset, KSConXmlUserEntryDrive );
+        aOffset += KSConXmlUserEntryDrive().Length();
+        }
+    else
+        {
+        aBuffer->ExpandL( aOffset, 
+            KSConXmlUserEntryArchive().Length() );
+        aBuffer->Write( aOffset, KSConXmlUserEntryArchive );
+        aOffset += KSConXmlUserEntryArchive().Length();
+        }
+    
+    
+    // print memory type
+    aBuffer->ExpandL( aOffset, KSConXmlMemoryType().Length() );
+    aBuffer->Write( aOffset, KSConXmlMemoryType );
+    aOffset += KSConXmlMemoryType().Length();
+    
+    aBuffer->ExpandL( aOffset, aMemType.Length() );
+    aBuffer->Write( aOffset, aMemType );
+    aOffset += aMemType.Length();
+    
+    // print label if exists
+    if( iLocalizer->IsLocalized() )
+        {
+        //get localized folder name
+        HBufC8* labelBuf = 
+            CnvUtfConverter::ConvertFromUnicodeToUtf8L( iLocalizer->LocalizedName() );
+        CleanupStack::PushL( labelBuf );
+        TPtrC8 label = labelBuf->Des();
+        //memory label
+        aBuffer->ExpandL( aOffset, 
+            KSConXmlMemoryLabel().Length() );
+        aBuffer->Write( aOffset, KSConXmlMemoryLabel );
+        aOffset += KSConXmlMemoryLabel().Length();
+        
+        aBuffer->ExpandL( aOffset, label.Length() );
+        aBuffer->Write( aOffset, label );
+        aOffset += label.Length();
+        
+        CleanupStack::PopAndDestroy( labelBuf );
+        }
+    if ( dataPath ) // datapath
+        {
+        //memory label
+        aBuffer->ExpandL( aOffset, 
+            KSConXmlMemoryLabel().Length() );
+        aBuffer->Write( aOffset, KSConXmlMemoryLabel );
+        aOffset += KSConXmlMemoryLabel().Length();
+        
+        aBuffer->ExpandL( aOffset, iDataPathName.Length() );
+        aBuffer->Write( aOffset, iDataPathName );
+        aOffset += iDataPathName.Length();
+        }
+    // print ending
+    aBuffer->ExpandL( aOffset, KSConXmlFileEnd().Length() );
+    aBuffer->Write( aOffset, KSConXmlFileEnd );
+    aOffset += KSConXmlFileEnd().Length();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFsHandler::PrintFileL
+// Prints file entry to folder listing object
+// -----------------------------------------------------------------------------
+//
+void CSConFsHandler::PrintFileL( CBufFlat* aBuffer, TInt& aOffset, const TEntry& aFileEntry )
+    {
+    LOGGER_WRITE_1("CSConFsHandler::PrintFileL, filename: %S", &aFileEntry.iName );
+    HBufC8* fileBuf = HBufC8::NewLC( KMaxFileName );
+    TPtr8 fileName = fileBuf->Des();
+        
+    User::LeaveIfError( 
+        CnvUtfConverter::ConvertFromUnicodeToUtf8( fileName, aFileEntry.iName ) );
+
+    //Replace special characters
+    ReplaceSpecialChars( fileName );
+        
+    // print filename
+    aBuffer->ExpandL( aOffset, KSConXmlFileNameBegin().Length() );
+    aBuffer->Write( aOffset, KSConXmlFileNameBegin );
+    aOffset += KSConXmlFileNameBegin().Length();
+
+    aBuffer->ExpandL( aOffset, fileName.Length() );
+    aBuffer->Write( aOffset, fileName );
+    aOffset += fileName.Length();
+
+    // print size
+    aBuffer->ExpandL( aOffset, KSConXmlSize().Length() );
+    aBuffer->Write( aOffset, KSConXmlSize );
+    aOffset += KSConXmlSize().Length();
+
+    fileName.Delete( 0, fileName.Length() ); // re-use fileName descriptor
+    fileName.AppendNum( aFileEntry.iSize );
+    aBuffer->ExpandL( aOffset, fileName.Length() );
+    aBuffer->Write( aOffset, fileName );
+    aOffset += fileName.Length();
+    
+    CleanupStack::PopAndDestroy( fileBuf );
+
+    // print modified
+    TBuf<KSConDateMaxLength> modifiedTime;
+    TTime time = aFileEntry.iModified;
+    time.FormatL( modifiedTime, KSConXmlDate );
+    
+    TBuf8<KSConDateMaxLength> modifiedTime8;
+    User::LeaveIfError( 
+        CnvUtfConverter::ConvertFromUnicodeToUtf8( modifiedTime8, modifiedTime ) );
+    
+    
+    aBuffer->ExpandL( aOffset, KSConXmlModified().Length() );
+    aBuffer->Write( aOffset, KSConXmlModified );
+    aOffset += KSConXmlModified().Length();
+    
+    aBuffer->ExpandL( aOffset, modifiedTime8.Length() );
+    aBuffer->Write( aOffset, modifiedTime8 );
+    aOffset += modifiedTime8.Length();
+
+    // attributes
+    aBuffer->ExpandL( aOffset, KSConXmlUserAttributes().Length() );
+    aBuffer->Write( aOffset, KSConXmlUserAttributes );
+    aOffset += KSConXmlUserAttributes().Length();
+
+    if( aFileEntry.IsSystem() )
+        {
+        aBuffer->ExpandL( aOffset, 
+            KSConXmlUserEntryReadOnly().Length() );
+        aBuffer->Write( aOffset, KSConXmlUserEntryReadOnly );
+        aOffset += KSConXmlUserEntryReadOnly().Length();
+        }
+    else if( aFileEntry.IsReadOnly() )
+        {
+        LOGGER_WRITE("was readonly" );
+        aBuffer->ExpandL( aOffset, 
+            KSConXmlUserEntryReadOnly().Length() );
+        aBuffer->Write( aOffset, KSConXmlUserEntryReadOnly );
+        aOffset += KSConXmlUserEntryReadOnly().Length();
+        }
+    else
+        {
+        aBuffer->ExpandL( aOffset, 
+            KSConXmlUserEntryArchive().Length() );
+        aBuffer->Write( aOffset, KSConXmlUserEntryArchive );
+        aOffset += KSConXmlUserEntryArchive().Length();
+        }
+    
+
+    //Word document
+    if ( aFileEntry.iType.IsPresent( KSConWordUid ) ||
+            aFileEntry.iName.Find( KSConEpocWordExt ) == aFileEntry.iName.Length() - 4 )
+        {
+        aBuffer->ExpandL( aOffset, KSConXmlType().Length() );
+        aBuffer->Write( aOffset, KSConXmlType );
+        aOffset += KSConXmlType().Length();
+        
+        aBuffer->ExpandL( aOffset, KSConXmlTypeWord().Length() );
+        aBuffer->Write( aOffset, KSConXmlTypeWord );
+        aOffset += KSConXmlTypeWord().Length();
+        }
+    //Sheet document
+    else if ( aFileEntry.iType.IsPresent( KSConSheetUid ) ||
+            aFileEntry.iName.Find( KSConEpocSheetExt ) == aFileEntry.iName.Length() - 4 )
+        {
+        aBuffer->ExpandL( aOffset, KSConXmlType().Length() );
+        aBuffer->Write( aOffset, KSConXmlType );
+        aOffset += KSConXmlType().Length();
+        
+        aBuffer->ExpandL( aOffset, KSConXmlTypeSheet().Length() );
+        aBuffer->Write( aOffset, KSConXmlTypeSheet );
+        aOffset += KSConXmlTypeSheet().Length();
+        }
+
+    aBuffer->ExpandL( aOffset, KSConXmlFileEnd().Length() );
+    aBuffer->Write( aOffset, KSConXmlFileEnd );
+    aOffset += KSConXmlFileEnd().Length();
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFsHandler::GetFileObjectL( CObexFileObject*& aFileObject, 
+// const TPtrC aPathName, const TPtrC aFileName )
+// Gets a file object
+// -----------------------------------------------------------------------------
+//
+TInt CSConFsHandler::GetFileObjectL( CObexFileObject*& aFileObject, 
+                                const TPtrC aPathName, const TPtrC aFileName )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_2( "CSConFsHandler::GetFileObjectL aFileName =  %S aPathName = %S", &aFileName, &aPathName );
+
+    TInt ret( KErrNone );
+    
+    if( ( aPathName.Length() == 0 || aFileName.Length() == 0 ) && 
+    !( aFileName==KPhoneBookIrMCL2Request || 
+    aFileName==KInfoLogIrMCL2Request ) )
+        {
+        return KErrArgument;
+        }
+
+    if( aPathName.Length() + aFileName.Length() > KMaxFileName )
+        {
+        return KErrAbort;
+        }
+
+    HBufC* pathBuf = HBufC::NewLC( KMaxFileName );
+    TPtr pathBufPtr = pathBuf->Des();
+
+    /*These modifiactions are mean to catch an IrMC L2 request. 
+    If the request is made, then the requested phonebook file and
+    info log -file are created. Path and filename is also changed 
+    to point to these created files.*/
+    if( aFileName == KPhoneBookIrMCL2Request || 
+    aFileName == KInfoLogIrMCL2Request )
+        {
+        LOGGER_WRITE( "CSConFsHandler: IrMC L2 request!" );
+        TInt err;
+        TInt status;
+        TInt contactsSaved = 0;
+        RCntParserServer cntParserServer;
+
+        err = cntParserServer.Connect();
+        if( err != KErrNone )
+            {
+            LOGGER_WRITE( "CSConFsHandler: Cannot connect to the cntparserserver, ABORT!" );
+
+            CleanupStack::PopAndDestroy( pathBuf );
+            return KErrAbort;
+            }
+
+        LOGGER_WRITE( "CSConFsHandler: Time to call CreateIrMCL2PhoneBook" );
+        TBool force = ( aFileName == KInfoLogIrMCL2Request );
+        status=cntParserServer.CreateIrMCL2PhoneBook( KMaximumNumberOfContacts,
+         force );
+        LOGGER_WRITE_1( "CntParserServer.CreateIrMCL2PhoneBook returned %d", status );
+         
+        //Check how many vcards were saved
+        contactsSaved = cntParserServer.ContactsSaved();    
+        LOGGER_WRITE_1( "CntParserServer.ContactsSaved returned %d", contactsSaved );
+
+        err = cntParserServer.Disconnect();
+        LOGGER_WRITE_1( "CntParserServer.Disconnect() %d", err );
+        if( err != KErrNone )
+            {
+            CleanupStack::PopAndDestroy( pathBuf );
+            return KErrAbort;
+            }
+        //save info.log, if pb.vcf has changed (Note: KPBNotUpdated is returned
+        // if no changes made to pb.vcf)
+        if( status == KErrNone )    
+            {
+            LOGGER_WRITE( "CSConFsHandler: Create info.log" );
+
+            CCntParserInfoLog* infoLog=CCntParserInfoLog::NewL();
+            CleanupStack::PushL( infoLog );
+            //see KMaximumNumberOfContacts for more details
+            infoLog->SetMaximumRecords( contactsSaved ); 
+            infoLog->SetTotalRecords( contactsSaved );
+            TFileName privatepath( K_C_ROOT );
+            privatepath.Append( KInfoLogIrMCL2File );
+            infoLog->SaveToFileL( privatepath );
+            CleanupStack::PopAndDestroy( infoLog );
+            }
+
+        if( aFileName == KInfoLogIrMCL2Request )
+            {
+            //Changes filename and path to info.log
+            pathBufPtr.Copy( KInfoLogPathAndFileName ); 
+            }
+        else
+            {
+            //Changes filename and path to pb.vcf
+            pathBufPtr.Copy( KPbPathAndFileName );  
+            }
+        }       
+    else
+        {
+        pathBufPtr.Copy( aPathName );
+        pathBufPtr.Append( aFileName );         
+        }
+    
+    LOGGER_WRITE( "CSConFsHandler::GetFileObjectL() : aFileObject->InitFromFileL( pathBufPtr )" );
+    TRAP( ret, aFileObject->InitFromFileL( pathBufPtr ) );
+    LOGGER_WRITE( "CSConFsHandler::GetFileObjectL() : aFileObject->InitFromFileL( pathBufPtr ) ok" );
+
+    CleanupStack::PopAndDestroy( pathBuf );
+
+    LOGGER_WRITE_1( "CSConFsHandler::GetFileObjectL( CObexFileObject*& aFileObject, const TPtrC aPathName, const TPtrC aFileName ) : returned %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFsHandler::SaveFileObjectL( const TPtrC aFullPathName, const TTime aTime,
+// const TPtrC aTempFileName )
+// Stores a file object
+// -----------------------------------------------------------------------------
+//
+TInt CSConFsHandler::SaveFileObjectL( const TPtrC aFullPathName, 
+                        const TTime aTime, const TPtrC aTempFileName )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_2( "CSConFsHandler::SaveFileObjectL aFullPathName = %S aTempFileName = %S", &aFullPathName, &aTempFileName );
+
+    TInt ret( KErrNone );
+    
+    if( aFullPathName.Length() == 0 )
+        {
+        iFs.Delete( aTempFileName );
+        return KErrPathNotFound;
+        }
+
+    ret = ValidateFileName( aFullPathName );
+        
+    if( ret == KErrNone )
+        {
+        TUint attr;
+        TInt err = iFs.Att( BaflUtils::DriveAndPathFromFullName(aFullPathName), attr );
+        if ( err == KErrNone && attr & KEntryAttReadOnly )
+            {
+            // folder is read only, permission denied
+            iFs.Delete( aTempFileName );
+            ret = KErrAccessDenied;
+            }
+        else if( !BaflUtils::FileExists( iFs, aFullPathName ) ) 
+            {
+            // file does not exist, rename.
+            ret = iFs.Rename( aTempFileName, aFullPathName );
+
+            if( ret == KErrNone )
+                {
+                ret = iFs.SetModified( aFullPathName, aTime );
+                ret = KErrNone;
+                }
+            else
+                {
+                iFs.Delete( aTempFileName );
+                }
+            }
+        else
+            {
+            LOGGER_WRITE( "CSConFsHandler::SaveFileObjectL() file exists. replace" );
+            // file exists. Replace if not read-only file.
+            TUint attr;
+            ret = iFs.Att( aFullPathName, attr );
+            // Check permissions
+            if( ret == KErrNone && ( attr == KEntryAttNormal || 
+            attr == KEntryAttArchive ) && !(attr & KEntryAttReadOnly) )
+                {
+                ret = iFs.Replace( aTempFileName, aFullPathName );
+                LOGGER_WRITE_1( "CSConFsHandler::SaveFileObjectL() iFs.Replace ret %d", ret);
+                //Set correct time stamp
+                if( ret == KErrNone )
+                    {
+                    ret = iFs.SetModified( aFullPathName, aTime );
+                    ret = KErrNone;
+                    }
+                else
+                    {
+                    iFs.Delete( aTempFileName );
+                    }
+                }
+            else
+                {
+                LOGGER_WRITE( "CSConFsHandler::SaveFileObjectL() no permissions" );
+                iFs.Delete( aTempFileName );
+                ret = KErrAccessDenied;
+                }
+            }   
+        }
+    else
+        {
+        iFs.Delete( aTempFileName );
+        }
+    
+    LOGGER_WRITE_1( "CSConFsHandler::SaveFileObjectL() : returned %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFsHandler::ValidateFileName( const TPtrC aName )
+// Validates the file name
+// -----------------------------------------------------------------------------
+//
+TInt CSConFsHandler::ValidateFileName( const TPtrC aName )
+    {
+    TInt ret( KErrNone );
+
+    if( !iFs.IsValidName( aName ) )
+        {
+        ret = KErrBadName;
+        }
+
+    LOGGER_WRITE_1( "CSConFsHandler::ValidateFileName( const TPtrC aName ) : returned %d", ret  );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFsHandler::CreateFolderL( const TPtrC aFolderPath )
+// Creates a folder
+// -----------------------------------------------------------------------------
+//
+TInt CSConFsHandler::CreateFolderL( const TPtrC aFolderPath )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TInt ret( KErrNone );
+    
+    if( aFolderPath.Length() == 0 )
+        {
+        return KErrArgument;
+        }
+    if( aFolderPath.Length() > KMaxPath )
+        {
+        return KErrAbort;
+        }
+    if( BaflUtils::PathExists( iFs, aFolderPath ) )
+        {
+        return KErrAlreadyExists;
+        }
+    // get restore mode
+    TBool restoreInProgress( EFalse );
+    RProperty backupProperty;
+    TInt burState( 0 );
+    TInt burErr = backupProperty.Get( KUidSystemCategory, conn::KUidBackupRestoreKey, burState ); 
+    const conn::TBURPartType partType = 
+        static_cast< conn::TBURPartType >( burState & conn::KBURPartTypeMask );
+    if( burErr == KErrNone &&
+     ( partType == conn::EBURRestorePartial || partType == conn::EBURRestoreFull ) )
+        {
+        // restore mode
+        LOGGER_WRITE( "CSConFsHandler::CreateFolderL() restore mode" );
+        restoreInProgress = ETrue;
+        }
+    
+    // check permissions if not restore mode
+    if ( !restoreInProgress )
+        {
+        if ( IsExludedPath( aFolderPath ) )
+            {
+            // user has no access to this folder
+            LOGGER_WRITE( "CSConFsHandler::CreateFolderL() KErrAccessDenied" );
+            return KErrAccessDenied;
+            }
+        
+        // user can create whole folder path at once and we need to check that
+        // user has permission to create folders. We need to find first folder that 
+        // should be created, and see if parent folder has read-only permission.
+        
+        HBufC* fullPath = HBufC::NewLC( KMaxFileName );
+        TPtr fullPathPtr = fullPath->Des();
+    
+        fullPathPtr.Copy(aFolderPath);
+        TBool parentFound(EFalse);
+        LOGGER_WRITE( "CSConFsHandler::CreateFolder() start loop" );
+        TInt err(KErrNone);
+        while (!parentFound && err==KErrNone)
+            {
+            err = GetParentFolder( fullPathPtr, fullPathPtr );
+            if( err == KErrNone )
+                {
+                if (BaflUtils::PathExists( iFs, fullPathPtr ))
+                    {
+                    parentFound = ETrue;
+                    TUint attr;
+                    ret = iFs.Att( fullPathPtr, attr );
+                    if ( ret == KErrNone &&  (attr & KEntryAttReadOnly || attr & KEntryAttSystem) )
+                        {
+                        // parent folder is read-only
+                        LOGGER_WRITE( "CSConFsHandler::CreateFolderL() KErrAccessDenied" );
+                        err = KErrAccessDenied;
+                        }
+                    }
+                }
+            }
+        
+        CleanupStack::PopAndDestroy( fullPath );
+        if ( err == KErrAccessDenied )
+            {
+            return KErrAccessDenied;
+            }
+        }
+    
+    ret = iFs.MkDirAll( aFolderPath );
+    LOGGER_WRITE_1( "CSConFsHandler::CreateFolderL( const TPtrC aFolderPath ) : returned %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFsHandler::DeleteObjectL( const TPtrC aFullPath )
+// Removes a folder or a file
+// -----------------------------------------------------------------------------
+//
+TInt CSConFsHandler::DeleteObjectL( const TPtrC aFullPath )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aFullPath: %S", &aFullPath);
+    TInt ret( KErrNone );
+    
+    if( aFullPath.Length() == 0 )
+        {
+        return KErrArgument;
+        }
+    
+    if( aFullPath.Length() > KMaxFileName )
+        {
+        return KErrAbort;
+        }
+    
+    TUint attr;
+    // get source folder permissions.
+    ret = iFs.Att( BaflUtils::DriveAndPathFromFullName(aFullPath), attr );
+    if ( ret == KErrNone && (attr & KEntryAttReadOnly || attr & KEntryAttSystem ) )
+        {
+        return KErrAccessDenied;
+        }
+    
+    
+    // Check file/folder permissions
+    ret = iFs.Att( aFullPath, attr );
+    if ( ret == KErrNone && ( attr & KEntryAttReadOnly || attr & KEntryAttSystem ) )
+        {
+        return KErrAccessDenied;
+        }
+    
+    TBool isFolder(EFalse);
+    ret = BaflUtils::IsFolder( iFs, aFullPath, isFolder );
+    
+    if( isFolder && ret == KErrNone )
+        {
+        HBufC* fullPath = HBufC::NewLC( KMaxFileName );
+        TPtr fullPathPtr = fullPath->Des();
+        
+        fullPathPtr.Copy( aFullPath );
+        //check if there is a slash at the end
+        if( fullPathPtr.LocateReverse( KPathDelimiter ) != fullPathPtr.Length()-1 )
+            {
+            fullPathPtr.Append( KPathDelimiter );
+            }
+        
+        if ( !IsFolderVisible( fullPathPtr ) )
+            {
+            LOGGER_WRITE("folder was not visible");
+            CleanupStack::PopAndDestroy( fullPath );
+            return KErrNotFound;
+            }
+        else if ( !IsFolderDeletable( fullPathPtr ) )
+            {
+            LOGGER_WRITE("folder was not deletable");
+            CleanupStack::PopAndDestroy( fullPath );
+            return KErrAccessDenied;
+            }
+        
+        ret = iFs.RmDir( fullPathPtr );
+        LOGGER_WRITE_1("iFs.RmDir err: %d", ret);
+        //delete non-empty folder
+        if( ret != KErrNone )
+            {
+            CFileMan* fileMan = CFileMan::NewL( iFs );
+            CleanupStack::PushL( fileMan );
+            // if directory contains read-only files, those files are not deleted
+            // and KErrAccessDenied is returned.
+            ret = fileMan->RmDir( fullPathPtr );
+            LOGGER_WRITE_1("fileMan->RmDir err: %d", ret);
+            CleanupStack::PopAndDestroy( fileMan ); //fileman
+            }
+        if( ret == KErrNone )
+            {
+            // check is delete operation really succesfully completed
+            if( BaflUtils::PathExists( iFs, fullPathPtr ) )
+                {
+                // Folder still exist, return error
+                // KErrBadName mapped to precondition failed error.
+                ret = KErrBadName;
+                }
+            }
+        CleanupStack::PopAndDestroy( fullPath ); //fullPath
+        }
+    else if (ret == KErrNone)
+        {
+        // deleting file
+        if ( IsExludedPath( aFullPath ) )
+            {
+            LOGGER_WRITE("Cannot delete from specified folder, return KErrAccessDenied");
+            ret = KErrAccessDenied;
+            }
+        else
+            {
+            ret = iFs.Delete( aFullPath );
+            }
+        }
+    
+    
+    
+    LOGGER_WRITE_1( "CSConFsHandler::DeleteObjectL() : returned %d", ret );
+    return ret;
+    }
+    
+    
+// -----------------------------------------------------------------------------
+// CSConFsHandler::CopyOrMoveFile()
+// Copy or Move file/folder.
+// -----------------------------------------------------------------------------
+//
+void CSConFsHandler::DoCopyOrMoveFileL( const TDesC& aSource, const TDesC& aTarget,
+                                 const TBool aUseCopyCommand)
+    {
+    TRACE_FUNC_ENTRY;
+    TInt lastError(KErrNone);
+    TBool isFolder;
+    
+    if( !iFs.IsValidName( aSource ) || !iFs.IsValidName( aTarget ) )
+        {
+        LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : Not valid name" );
+        User::Leave( KErrBadName );
+        }
+    
+    // will leave if source (file/folder) does not exists.
+    User::LeaveIfError( BaflUtils::IsFolder(iFs, aSource, isFolder ) );
+    
+    // Check source file/folder permissions
+    TUint attr;
+    User::LeaveIfError( iFs.Att( aSource, attr ) );
+    if ( !aUseCopyCommand && (attr & KEntryAttReadOnly || attr & KEntryAttSystem ) )
+        {
+        LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : no permissions, abort" );
+        User::Leave(  KErrAccessDenied );
+        }
+    
+    HBufC* sourceFolderBuf = HBufC::NewLC( KMaxFileName );
+    TPtr sourceFolder = sourceFolderBuf->Des();
+    HBufC* targetFolderBuf = HBufC::NewLC( KMaxFileName );
+    TPtr targetFolder = targetFolderBuf->Des();
+    
+    sourceFolder.Copy( BaflUtils::DriveAndPathFromFullName(aSource) );
+    targetFolder.Copy( BaflUtils::DriveAndPathFromFullName(aTarget) );
+    
+    
+    // check disk space
+    TInt driveNumber;
+    
+    User::LeaveIfError( iFs.CharToDrive(targetFolder[0], driveNumber) );
+    
+    TVolumeInfo volumeInfo;
+    TInt err = iFs.Volume(volumeInfo, driveNumber);
+    if( err != KErrNone )
+        {
+        LOGGER_WRITE_1( "CSConFsHandler::DoCopyOrMoveFileL : iFs.Volume err %d", err );
+        User::Leave( KErrNotFound );
+        }
+    
+    if( !isFolder )
+        {
+        // file handling routines
+        if( !IsFolderVisible( aSource ) )
+            {
+            LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : Current folder doesn't exist" );
+            User::Leave( KErrNotFound );
+            }
+        else if( !aUseCopyCommand && IsFolderReadOnly( sourceFolder ) )
+            {
+            LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : folder read only, abort" );
+            User::Leave( KErrAccessDenied );
+            }
+            
+        // source file is ok, check target
+
+        if( !IsFolderVisible( targetFolder ) )
+            {
+            LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : Current target file/folder doesn't exist" );
+            User::Leave( KErrNotFound );
+            }
+        else if( IsFolderReadOnly( targetFolder ) )
+            {
+            LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : folder read only, abort" );
+            User::Leave( KErrAccessDenied );
+            }
+        else
+            {
+            TBool diskFull( EFalse );
+            TEntry fileEntry;
+            User::LeaveIfError( iFs.Entry( aSource, fileEntry ) );
+            if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iFs, fileEntry.iSize, driveNumber ) )
+                {
+                diskFull = ETrue;
+                }
+            
+            // target ok, ready to copy or move
+            CFileMan* fileMan=CFileMan::NewL(iFs);
+            CleanupStack::PushL(fileMan);
+            
+            if( aUseCopyCommand )
+                {
+                if( diskFull )
+                    {
+                    LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : disk full" );
+                    User::Leave( KErrDiskFull );
+                    }
+                LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : Copy file" );
+                User::LeaveIfError( fileMan->Copy( aSource, aTarget, 0 ) );
+                }
+            else
+                {
+                if( aSource.Find( aTarget.Left(2) ) == KErrNone)
+                    {
+                    // same drive
+                    LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : Rename file" );
+                    User::LeaveIfError( fileMan->Rename( aSource, aTarget, 0 ) );
+                    }
+                else
+                    {
+                    // different drive
+                    if( diskFull )
+                        {
+                        LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : disk full" );
+                        User::Leave( KErrDiskFull );
+                        }
+                    LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : copy file" );
+                    User::LeaveIfError( fileMan->Copy( aSource, aTarget, 0 ) );
+
+                    LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : delete original" );
+                    User::LeaveIfError( fileMan->Delete( aSource, 0 ) );
+                    }
+                }
+            CleanupStack::PopAndDestroy( fileMan ); // fileMan
+            }
+        }
+    else
+        {
+        // set trailing backslash after the final directory name
+        HBufC* tmpSourceBuf = HBufC::NewLC( KMaxFileName );
+        TPtr tmpSourcePtr = tmpSourceBuf->Des();
+        HBufC* tmpTargetBuf = HBufC::NewLC( KMaxFileName );
+        TPtr tmpTargetPtr = tmpTargetBuf->Des();
+        
+        tmpSourcePtr.Copy( aSource );
+        if( tmpSourcePtr.LocateReverse( KPathDelimiter ) != tmpSourcePtr.Length()-1 )
+            {
+            tmpSourcePtr.Append( KPathDelimiter );
+            }
+
+        tmpTargetPtr.Copy( aTarget );
+        if( tmpTargetPtr.LocateReverse( KPathDelimiter ) != tmpTargetPtr.Length()-1 )
+            {
+            tmpTargetPtr.Append( KPathDelimiter );
+            }
+        
+        if( !IsFolderVisible( tmpSourcePtr ) )
+            {
+            LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : Current folder doesn't exist" );
+            User::Leave( KErrNotFound );
+            }
+        else if( !aUseCopyCommand && IsFolderReadOnly( sourceFolder ) )
+            {
+            LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : sourcefolder read only, abort" );
+            User::Leave( KErrAccessDenied );
+            }
+        else if( !aUseCopyCommand && !IsFolderDeletable( tmpSourcePtr ) )
+            {
+            LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : source folder read only, abort" );
+            User::Leave( KErrAccessDenied );
+            }
+        else if( !IsFolderVisible( targetFolder ) )
+            {
+            LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : Current target base-folder doesn't exist" );
+            User::Leave( KErrNotFound );
+            }
+        else if( IsFolderReadOnly( targetFolder) )
+            {
+            LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : target folder read only, abort" );
+            User::Leave( KErrAccessDenied );
+            }
+        else if( BaflUtils::FolderExists(iFs, tmpTargetPtr ) )
+            {
+            LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : target folder exist, abort" );
+            User::Leave( KErrAlreadyExists );
+            }
+        else if ( tmpTargetPtr.Find( tmpSourcePtr ) == KErrNone )
+            {
+            LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : conflict, abort" );
+            User::Leave( KErrInUse );
+            }
+        else
+            {
+            // is folder empty
+            TBool emptyFolder( ETrue );
+            CDir *entryList = 0;
+            CDir *dirList = 0;
+
+            User::LeaveIfError( iFs.GetDir( tmpSourcePtr, KEntryAttNormal, EDirsAnyOrder, 
+            entryList, dirList ) );
+            if( entryList->Count() > 0 || dirList->Count() > 0 )
+                {
+                emptyFolder = EFalse;
+                }
+                
+            delete entryList;
+            delete dirList;
+            
+            // get folder size
+            TBool diskFull( EFalse );
+            if( !emptyFolder )
+                {
+                TInt64 folderSize = GetFolderSizeL(tmpSourcePtr);
+                LOGGER_WRITE_1( "CSConFsHandler::DoCopyOrMoveFileL : folderSize: %d", folderSize );
+                if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iFs, folderSize, driveNumber ) )
+                    {
+                    diskFull = ETrue;
+                    }
+                }
+            
+            
+            CFileMan* fileMan = CFileMan::NewL(iFs);
+            CleanupStack::PushL(fileMan);
+    
+            // ready to copy or move
+            if( aUseCopyCommand )
+                {
+                LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : Copy folder" );
+                if( emptyFolder )
+                    {
+                    // folder is empty, can't copy folder. Create new empty folder.
+                    User::LeaveIfError( iFs.MkDir( tmpTargetPtr ) );
+                    }
+                else
+                    {
+                    // folder not empty
+                    if( diskFull )
+                        {
+                        LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : disk full" );
+                        User::Leave( KErrDiskFull );
+                        }
+                    
+                    User::LeaveIfError( 
+                     fileMan->Copy( aSource, aTarget, CFileMan::ERecurse ) ); 
+                    if( lastError == KErrNone )
+                        {
+                        lastError = fileMan->GetLastError();
+                        }
+                    }
+                
+                TUint attr;
+                TInt err = iFs.Att( tmpSourcePtr, attr );
+                if ( err == KErrNone && (attr & KEntryAttReadOnly ) )
+                    {
+                    //set read only attribute
+                    err = iFs.SetAtt( tmpTargetPtr, KEntryAttReadOnly, KEntryAttArchive );
+                    if (err != KErrNone)
+                        {
+                        // can't set attribute
+                        LOGGER_WRITE_1( "CSConFsHandler::DoCopyOrMoveFileL : iFs.SetAtt err: %d",err );
+                        }
+                    }
+                }
+            else
+                {
+                if( aSource.FindF( aTarget.Left(2) ) == KErrNone)
+                    {
+                    // same drive
+                    LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : Rename folder" );
+                    User::LeaveIfError( fileMan->Rename( aSource, aTarget, 0 ) );
+                    }
+                else
+                    {
+                    // different drive
+                    if( diskFull )
+                        {
+                        LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : disk full" );
+                        User::Leave( KErrDiskFull );
+                        }
+                    
+                    LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : Copy folder" );
+                    if( emptyFolder )
+                        {
+                        // folder is empty, can't copy empty folder. Create empty folder.
+                        User::LeaveIfError( iFs.MkDir( tmpTargetPtr ) );
+                        }
+                    else
+                        {
+                        User::LeaveIfError( 
+                         fileMan->Copy( aSource, aTarget, CFileMan::ERecurse ) );
+                        }
+                    // copy completed, delete original folder.
+                    LOGGER_WRITE( "CSConFsHandler::DoCopyOrMoveFileL : delete original" );
+                    User::LeaveIfError( fileMan->RmDir( tmpSourcePtr ) );
+                    // check was delete operation succesfully completed
+                    if( BaflUtils::PathExists( iFs, tmpSourcePtr ) )
+                        {
+                        // Folder still exist, return error
+                        lastError = KErrAccessDenied;
+                        }
+                    }
+                }
+            CleanupStack::PopAndDestroy(fileMan); // fileMan
+            }
+        CleanupStack::PopAndDestroy(tmpTargetBuf); // tmpTargetBuf
+        CleanupStack::PopAndDestroy(tmpSourceBuf); // tmpSourceBuf
+        }
+    
+    CleanupStack::PopAndDestroy( targetFolderBuf );
+    CleanupStack::PopAndDestroy( sourceFolderBuf );
+    
+    if( lastError != KErrNone )
+        {
+        LOGGER_WRITE_1( "CSConFTP::DoCopyOrMoveFileL() : lastError: %d", lastError );
+        User::Leave( lastError );
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFsHandler::IsFolderVisible()
+// Check if folder can be showed
+// -----------------------------------------------------------------------------
+//
+TBool CSConFsHandler::IsFolderVisible( const TDesC& aFullPath )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aFullPath: %S", &aFullPath );
+    TBool visible(EFalse);
+    
+    if( !BaflUtils::FolderExists( iFs, aFullPath ) )
+        {
+        LOGGER_WRITE( "CSConFsHandler::IsFolderVisible() notExist ret EFalse" );
+        return EFalse;
+        }
+    
+    // don't show if folder is exluded
+    visible = !IsExludedPath( aFullPath );
+    LOGGER_WRITE_1( "CSConFsHandler::IsFolderVisible() : end, ret %d", (TInt)visible );
+    return visible;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConFsHandler::IsFolderReadOnly()
+// Check if folder is read only (system folder)
+// -----------------------------------------------------------------------------
+//
+TBool CSConFsHandler::IsFolderReadOnly( const TDesC& aFullPath ) const
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aFullPath: %S", &aFullPath );
+    TBool readOnly(EFalse);
+    
+    // C-drive root is read only, but there are some exceptions
+    
+    readOnly = IsExludedPath( aFullPath );
+    
+    if ( aFullPath.CompareF( K_C_ROOT ) == 0 )
+        {
+        // Root of C-drive is read-only
+		LOGGER_WRITE("Root of C-Drive is read only");
+        readOnly = ETrue;
+        }
+    
+    // Check folder permissions
+    TUint attr;
+    TInt err = iFs.Att( aFullPath, attr );
+    LOGGER_WRITE_1("iFs.Att err: %d", err);
+    if ( err == KErrNone && (attr & KEntryAttReadOnly || attr & KEntryAttSystem ) )
+        {
+        LOGGER_WRITE("Folder is readonly");
+        readOnly = ETrue;
+        }
+    
+    LOGGER_WRITE_1( "CSConFsHandler::IsFolderReadOnly() : end, ret %d", (TInt)readOnly );
+    return readOnly;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConFsHandler::IsFolderDeletable()
+// Check if folder can be deleted. Localized folders cannot delete.
+// In C-drive folders can be deleted only from under C:\\Data\\
+// -----------------------------------------------------------------------------
+//
+TBool CSConFsHandler::IsFolderDeletable( const TDesC& aFullPath ) const
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aFullPath: %S", &aFullPath );
+    TBool deleteAllowed(ETrue);
+    TPath PhoneMem( PathInfo::PhoneMemoryRootPath() ); // "C:\\Data\\"
+
+    if ( aFullPath.CompareF( PhoneMem ) == 0 )
+        {
+        // C:\\Data\\
+        LOGGER_WRITE( "CSConFsHandler::IsFolderDeletable() datapath, ret EFalse" );
+        deleteAllowed = EFalse;
+        }
+    else if ( IsExludedPath( aFullPath ) )
+        {
+        deleteAllowed = EFalse;
+        }
+    
+    iLocalizer->SetFullPath( aFullPath );
+    if ( iLocalizer->IsLocalized() ) // delete disabled
+        {
+        // Cannot delete localized paths (default paths)
+        deleteAllowed = EFalse;
+        }
+    
+    LOGGER_WRITE_1( "CSConFsHandler::IsFolderDeletable() : end, ret %d", (TInt)deleteAllowed );
+    return deleteAllowed;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFsHandler::GetParentFolder( const TPtrC aFullPath, TDes& aParent)
+// Get parent folder
+// -----------------------------------------------------------------------------
+//
+TInt CSConFsHandler::GetParentFolder( const TDesC& aFullPath, TDes& aParent)
+    {
+    TRACE_FUNC_ENTRY;
+    if (aFullPath.LocateReverse(KPathDelimiter) == aFullPath.Length()-1 )
+        {
+        // remove backlash
+        aParent.Copy(aFullPath.Left(aFullPath.Length()-1));
+        }
+    else
+        {
+        aParent.Copy(aFullPath);
+        }
+    
+    TInt pos = aParent.LocateReverse(KPathDelimiter);
+    if (pos != KErrNotFound)
+        {
+        aParent.Copy(aParent.Left(pos+1));
+        LOGGER_WRITE( "CSConFsHandler::GetParentFolder : end KErrNone" );
+        return KErrNone;
+        }
+    else
+        {
+        LOGGER_WRITE_1( "CSConFsHandler::GetParentFolder : end err %d", pos);
+        return pos;
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConFsHandler::CSConFsHandler()
+// Constructor
+// -----------------------------------------------------------------------------
+//
+CSConFsHandler::CSConFsHandler( RFs& aFs ) : iFs(aFs)
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFsHandler::ConstructL()
+// Initializes member data
+// -----------------------------------------------------------------------------
+//
+void CSConFsHandler::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    iLocalizer = CDirectoryLocalizer::NewL();
+    
+    GetDataPathNameL();
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConFsHandler::GetDataPathNameL()
+// Updates the name of the data folder from a localized string
+// -----------------------------------------------------------------------------
+//
+void CSConFsHandler::GetDataPathNameL()
+    {
+    TRACE_FUNC_ENTRY;
+    //Read memory string and convert it
+    TFileName file( KSConResourceName );
+    
+    BaflUtils::NearestLanguageFile( iFs, file );
+       
+    CStringResourceReader* reader = CStringResourceReader::NewL( file );
+    CleanupStack::PushL( reader );
+    
+    CnvUtfConverter::ConvertFromUnicodeToUtf8( iDataPathName, 
+        reader->ReadResourceString( R_SECON_DATA_FOLDER ) );
+    
+    CleanupStack::PopAndDestroy( reader );
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConFsHandler::GetFolderSizeL()
+// Get folder (and subfolders) size
+// -----------------------------------------------------------------------------
+//
+TInt64 CSConFsHandler::GetFolderSizeL( const TDesC& aFullPath )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aFullPath: %S", &aFullPath );
+    TInt64 totalSize(0);
+    CDir* dir( NULL );
+    
+    User::LeaveIfError( iFs.GetDir(aFullPath, KEntryAttMatchMask, ESortByName, dir) );
+    CleanupStack::PushL(dir);
+    for( TInt i=0; i<dir->Count(); ++i )
+        {
+        TEntry entry = (*dir)[i];
+        if( !entry.IsDir() )
+            {
+            // file
+            totalSize += entry.iSize;
+            }
+        else
+            {
+            // folder
+            HBufC* subfolderBuf = HBufC::NewLC( KMaxPath );
+            TPtr subfolderPtr = subfolderBuf->Des();
+            
+            subfolderPtr.Copy(aFullPath);
+            subfolderPtr.Append(entry.iName);
+            subfolderPtr.Append( KPathDelimiter );
+            
+            LOGGER_WRITE( "CSConFsHandler::GetFolderSizeL() : get subfolder size" );
+            totalSize += GetFolderSizeL( subfolderPtr );
+            CleanupStack::PopAndDestroy( subfolderBuf );
+            }
+        }
+    CleanupStack::PopAndDestroy(dir);
+    TRACE_FUNC_EXIT;
+    return totalSize;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFsHandler::ReplaceSpecialChars()
+// Replace special characters to xml compliant
+// -----------------------------------------------------------------------------
+//
+void CSConFsHandler::ReplaceSpecialChars( TDes8& aDes )
+    {
+    for( TInt i = 0; i < aDes.Length(); i++ )
+        {
+        switch( aDes[i] )
+            {
+            case '&':
+                aDes.Delete( i, 1 );
+                aDes.Insert( i, KReplace1 );
+                break;
+            case '<':
+                aDes.Delete( i, 1 );
+                aDes.Insert( i, KReplace2 );
+                break;
+            case '>':
+                aDes.Delete( i, 1 );
+                aDes.Insert( i, KReplace3 );
+                break;
+            case '"':
+                aDes.Delete( i, 1 );
+                aDes.Insert( i, KReplace4 );
+                break;
+            case '\'':
+                aDes.Delete( i, 1 );
+                aDes.Insert( i, KReplace5 );
+                break;
+            default:
+                break;
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFsHandler::IsExludedPath()
+// Some folders are exluded from user access
+// -----------------------------------------------------------------------------
+//
+TBool CSConFsHandler::IsExludedPath( const TDesC& aFullPath ) const
+    {
+    TInt exluded(ETrue);
+    LOGGER_WRITE_1( "aFullPath: %S", &aFullPath );
+    TPath mmcRoot( PathInfo::MemoryCardRootPath() );
+    if ( aFullPath.Length() == KDriveLength )
+        {
+        // root paths not exluded
+        exluded = EFalse;
+        }
+    else if ( aFullPath.FindF( K_C_ROOT ) == 0 )
+        {
+        if ( aFullPath.FindF( PathInfo::PhoneMemoryRootPath() ) == 0 )
+            {
+            // C:\\Data is visible, not exluded
+            exluded = EFalse;
+            }
+        else {
+            // other paths on C-drive are exluded
+            LOGGER_WRITE_1("CSConFsHandler::IsExludedPath() Path '%S' is not visible to user", &aFullPath);
+            exluded = ETrue;
+            }
+        }
+    // hide undesired folders from E: root level
+    else if( aFullPath.CompareF( mmcRoot ) == 0 )
+        {
+        if ( aFullPath.FindF( KSConSys ) == KDriveLength )
+            {
+            LOGGER_WRITE( "hiding mmcRoot KSConSys" );
+            exluded = ETrue;
+            }
+        else if( aFullPath.FindF( KSConResource ) == KDriveLength )
+            {
+            LOGGER_WRITE( "hiding mmcRoot KSConResource" );
+            exluded = ETrue;
+            }
+        else if( aFullPath.FindF( KSConPrivate ) == KDriveLength )
+            {
+            LOGGER_WRITE( "mmcRoot KSConPrivate" );
+            exluded = ETrue;
+            }
+        else if( aFullPath.FindF( KSConSystem ) == KDriveLength )
+            {
+            LOGGER_WRITE( "hiding mmcRoot KSConSystem" );
+            exluded = ETrue;
+            }
+        }
+    // end of E: root level handling
+    else
+        {
+        // don't exlude paths from other drives
+        exluded = EFalse;
+        }
+    return exluded;
+    }
+
+// End of file
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/ftp/src/sconftp.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1591 @@
+/*
+* 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 Transfer Controller implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <pathinfo.h>
+#include <stringresourcereader.h>
+#include <bautils.h>
+#include <driveinfo.h>
+#include <sconftp.rsg>
+#include <centralrepository.h>
+#include <sysutildomaincrkeys.h>
+
+#include "debug.h" 
+#include "sconftp.h"
+#include "sconfshandler.h"
+#include "sconinboxhandler.h"
+#include "sconconsts.h"
+
+const TInt KPackageSize = 65536;
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CreateCSConFTPL()
+// Entry to CSConFTP
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSConFTP* CreateCSConFTPL()
+    {
+    TRACE_FUNC;
+    return CSConFTP::NewL();
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::NewL()
+// Two-phase constructor
+// -----------------------------------------------------------------------------
+//
+CSConFTP* CSConFTP::NewL()
+    {
+    TRACE_FUNC_ENTRY;
+    CSConFTP* self = new (ELeave) CSConFTP();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::~CSConFTP()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSConFTP::~CSConFTP()
+    {
+    TRACE_FUNC_ENTRY;
+    delete iSConInboxHandler;
+    iSConInboxHandler = NULL;
+    delete iSConFsHandler;
+    iSConFsHandler = NULL;
+    delete iBuffer;
+    iBuffer = NULL;
+
+    iFs.Delete( iTempFileName );
+    iFs.Close();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::GetFolderObjectL( CObexBufObject*& aObjectList )
+// Gets object that contains folder listing from inbox or file system
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTP::GetFolderObjectL( CObexBufObject*& aObjectList )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TInt ret( KErrNone );
+    TInt offset = 0;
+    TChar driveLetter;
+    TBuf8<KSConDriveNameLength> tmpBuf8;
+    
+    iBuffer->Reset();
+    
+    //default folder list - lists all available drives, inbox
+    if( iPathName.Length() == 0 )
+        {
+        TInt devDriveCount = 0;
+        TInt mmcDriveCount = 0;
+        
+        iBuffer->ResizeL( KSConXmlDocBegin().Length() );
+        iBuffer->Write( offset, KSConXmlDocBegin );
+        offset += KSConXmlDocBegin().Length();
+        
+        //Write all drivers to folderlisting object
+        TDriveList driveList;
+        // Get all drives that are visible to the user.
+        TInt driveCount;
+        User::LeaveIfError( DriveInfo::GetUserVisibleDrives( iFs, driveList, driveCount ) );
+        
+        for( TInt i = EDriveA; i < KMaxDrives; i++ )
+            {
+            if( driveList[i] )
+                {
+                TUint driveStatus;
+                User::LeaveIfError( DriveInfo::GetDriveStatus( iFs, i, driveStatus ) );
+                LOGGER_WRITE_1( "DriveInfo for drive: %d", i);
+
+                if( !(driveStatus & DriveInfo::EDrivePresent )
+                    || driveStatus & DriveInfo::EDriveCorrupt
+                    || (driveStatus & DriveInfo::EDriveRemote) )
+                    {
+                    LOGGER_WRITE_1( "skip drive %d", i);
+                    continue;
+                    }
+                
+                User::LeaveIfError( iFs.DriveToChar( i, driveLetter ) );
+                
+                //Letter to uppercase form.
+                driveLetter.UpperCase();
+                
+                //Folder begin
+                iBuffer->ExpandL( offset, 
+                KSConXmlFolderNameBegin().Length() );
+                iBuffer->Write( offset, KSConXmlFolderNameBegin );
+                offset += KSConXmlFolderNameBegin().Length();
+                
+                iBuffer->ExpandL( offset, KSConDriveCName().Length() );
+                
+                tmpBuf8.Delete( 0, tmpBuf8.Length() );
+                tmpBuf8.Append( driveLetter );
+                tmpBuf8.Append( KDriveDelimiter );
+                
+                iBuffer->Write( offset, tmpBuf8 );
+                offset += KSConDriveNameLength;
+                
+                //permission
+                iBuffer->ExpandL( offset, 
+                KSConXmlUserAttributes().Length() );
+                iBuffer->Write( offset, KSConXmlUserAttributes );
+                offset += KSConXmlUserAttributes().Length();
+                if( driveStatus & DriveInfo::EDriveInternal && devDriveCount==0 )
+                    {
+                    //permission always R for first internal drive
+                    iBuffer->ExpandL( offset, 
+                    KSConXmlUserEntryReadOnly().Length() );
+                    iBuffer->Write( offset, KSConXmlUserEntryReadOnly );
+                    offset += KSConXmlUserEntryReadOnly().Length();
+                    }
+                else
+                    {
+                    //permission always RW
+                    iBuffer->ExpandL( offset, 
+                    KSConXmlUserEntryDrive().Length() );
+                    iBuffer->Write( offset, KSConXmlUserEntryDrive );
+                    offset += KSConXmlUserEntryDrive().Length();
+                    }
+                
+                //memory type
+                iBuffer->ExpandL( offset, 
+                KSConXmlMemoryType().Length() );
+                iBuffer->Write( offset, KSConXmlMemoryType );
+                offset += KSConXmlMemoryType().Length();
+                if( driveStatus & DriveInfo::EDriveInternal )
+                    {
+                    LOGGER_WRITE( "DriveInfo::EDriveInternal" );
+                    // DEV type
+                    devDriveCount++;
+                    if( devDriveCount > 1 )
+                        {
+                        // DEV2
+                        TBuf8<KSConMemTypeMaxLength> memType;
+                        memType.Copy( KSConMemoryTypeDev );
+                        memType.AppendNum(devDriveCount);
+                        iBuffer->ExpandL( offset, memType.Length() );
+                        iBuffer->Write( offset, memType );
+                        offset += memType.Length();
+                        }
+                    else
+                        {
+                        // DEV
+                        iBuffer->ExpandL( offset, 
+                        KSConMemoryTypeDev().Length() );
+                        iBuffer->Write( offset, KSConMemoryTypeDev );
+                        offset += KSConMemoryTypeDev().Length();
+                        }
+                    }
+                if( driveStatus & DriveInfo::EDriveRemovable )
+                    {
+                    LOGGER_WRITE( "DriveInfo::EDriveRemovable" );
+                    // MMC type
+                    mmcDriveCount++;
+                    if( mmcDriveCount > 1 )
+                        {
+                        // MMC2
+                        TBuf8<KSConMemTypeMaxLength> memType;
+                        memType.Copy( KSConMemoryTypeMmc );
+                        memType.AppendNum(mmcDriveCount);
+                        iBuffer->ExpandL( offset, memType.Length() );
+                        iBuffer->Write( offset, memType );
+                        offset += memType.Length();
+                        }
+                    else
+                        {
+                        // MMC
+                        iBuffer->ExpandL( offset, 
+                        KSConMemoryTypeMmc().Length() );
+                        iBuffer->Write( offset, KSConMemoryTypeMmc );
+                        offset += KSConMemoryTypeMmc().Length();
+                        }
+                    }
+                
+                //memory label
+                iBuffer->ExpandL( offset, 
+                KSConXmlMemoryLabel().Length() );
+                iBuffer->Write( offset, KSConXmlMemoryLabel );
+                offset += KSConXmlMemoryLabel().Length();
+                
+                TInt err( KErrNotFound );
+                TBuf8<KMaxFileName> volumeName;
+                if( driveStatus & DriveInfo::EDriveRemovable || devDriveCount == 1 )
+                    {
+                    // get Volume name for C-drive(Phone) and E-drive(MMC)
+                    err = GetVolumeNameL( i, volumeName );
+                    }
+                else
+                    {
+                    // Get localized name for DEV2 (Mass memory)
+                    //Read memory string and convert it
+                    TFileName file( KSConResourceName );
+                    
+                    BaflUtils::NearestLanguageFile( iFs, file );
+                    
+                    CStringResourceReader* reader = CStringResourceReader::NewL( file );
+                    
+                    CnvUtfConverter::ConvertFromUnicodeToUtf8( volumeName, 
+                        reader->ReadResourceString( R_SECON_VALUE_MASS_STORAGE ) );
+                    
+                    delete reader;
+                    err = KErrNone;
+                    }
+                
+                if ( err == KErrNone )
+                    {
+                    iBuffer->ExpandL( offset, 
+                    volumeName.Length() );
+                    iBuffer->Write( offset, volumeName );
+                    offset += volumeName.Length();
+                    }
+                
+                //Write the end of filelist to folderlisting object
+                iBuffer->ExpandL( offset, KSConXmlFileEnd().Length() );
+                iBuffer->Write( offset, KSConXmlFileEnd );
+                offset += KSConXmlFileEnd().Length();
+                }
+            }
+        //Write the end of folderlist to folderlisting object
+        iBuffer->ExpandL( offset, KSConXmlFolderListEnd().Length() );
+        iBuffer->Write( offset, KSConXmlFolderListEnd );
+        iBuffer->Compress();
+        }
+    else
+        {
+        if( IsCurrentVolumeOK() )
+            {
+            ret = iSConFsHandler->ParseFolderListL( iBuffer, iPathName, iCurrentDriveTypeNumber );
+            }
+        else
+            {
+            ret = KErrNotFound;
+            }
+        }
+    
+    //Put data to aObjectList
+    delete aObjectList;
+    aObjectList = NULL;
+    
+    aObjectList = CObexBufObject::NewL( iBuffer );
+    aObjectList->SetTypeL( KSConFolderListType );
+    aObjectList->SetLengthL( iBuffer->Size() );
+    
+    LOGGER_WRITE_1( "CSConFTP::GetFolderObjectL( CObexBufObject*& aObjectList ) : returned %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::GetFileObjectL( CObexFileObject*& aFileObject )
+// Gets object that contains a file from file system
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTP::GetFileObjectL( CObexFileObject*& aFileObject )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TInt ret( KErrNone );
+    
+    if( aFileObject->Name().Length() == 0 )
+        {
+        return KErrBadName;
+        }
+    
+    // check is current drive ok
+    if( iPathName.Length() > 0 )
+        {
+        TPath path( KSConAllowedPath );
+        path.Append( KPathDelimiter );
+        if( iPathName.CompareF( path ) != 0 )
+            {
+            // was normal path (not KSConAllowedPath)
+            if( !IsCurrentVolumeOK() )
+                {
+                return KErrNotFound;
+                }
+            }
+        }
+    
+    HBufC* nameBuf = HBufC::NewLC( KMaxFileName );
+    TPtr namePtr = nameBuf->Des();
+    namePtr.Append( aFileObject->Name() );
+    
+    if( namePtr.LocateReverse( KPathDelimiter ) == namePtr.Length()-1 )
+        {
+        namePtr.Delete( namePtr.Length()-1, 1 );
+        }
+    
+    ret = iSConFsHandler->GetFileObjectL( aFileObject, iPathName, namePtr );
+    
+    CleanupStack::PopAndDestroy( nameBuf );
+    
+    LOGGER_WRITE_1( "CSConFTP::GetFileObjectL() : returned %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::PutFileObjectInitL( CObexBufObject*& aObject, 
+//                                  CBufFlat*& aBuffer )
+// Initializes the receiving from the client.
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTP::PutFileObjectInitL( CObexBufObject*& aObject, 
+                                    CBufFlat*& aBuffer )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    
+    RFile file;
+    
+    TBool lowMemory = IsCurrentDiskSpaceBelowCritical();
+    
+    //if Inbox then save temp file to default drive
+    if( iPathName.Length() == 0 )
+        {
+        //When proprietary profile (PC Suite), doesn't allow to use Inbox
+        if( iProfile == EProprietary )
+            {
+            LOGGER_WRITE( "CSConFTP::PutFileObjectInitL() : iProfile EProprietary" );
+            ret = file.Temp( iFs, PathInfo::PhoneMemoryRootPath(), iTempFileName,
+            EFileWrite | EFileShareExclusive );
+            file.Close();
+
+            if( ret == KErrNone )
+                {
+                delete aObject;
+                aObject = CObexBufObject::NewL( NULL );
+                        
+                if( aBuffer )
+                    {
+                    aBuffer->Reset();
+                    delete aBuffer;
+                    }
+                
+                aBuffer = CBufFlat::NewL( KSConBufferSize );
+                aBuffer->ResizeL( KSConBufferSize );
+                
+                TObexFilenameBackedBuffer bufferdetails( *aBuffer, iTempFileName, 
+                CObexBufObject::EDoubleBuffering );
+                aObject->SetDataBufL( bufferdetails );
+                }
+            }
+        else
+            {
+            LOGGER_WRITE( "CSConFTP::PutFileObjectInitL() : not EProprietary" );
+            if( lowMemory )
+                {
+                // do not even try to save
+                LOGGER_WRITE( "CSConFTP::PutFileObjectInitL() : disk full" );
+                ret = KErrNoMemory;
+                }
+            else
+                {
+                ret = iSConInboxHandler->CreateInboxAttachmentL( aObject, aBuffer );
+                }
+            }
+        
+        return ret;
+        }
+    else
+        {
+        LOGGER_WRITE_1("iPathName: %S", &iPathName);
+        // check is current drive ok 
+        if( !IsCurrentVolumeOK() )
+            {
+            LOGGER_WRITE( "CSConFTP::PutFileObjectInitL() : drive not visible" );
+            ret = KErrNotFound;
+            }
+        else
+            {
+            ret = file.Temp( iFs, iPathName, iTempFileName, EFileWrite | 
+            EFileShareExclusive );
+            }
+        }
+    
+    file.Close();
+    
+    if( ret == KErrNone )
+        {
+        delete aObject;
+        aObject = CObexBufObject::NewL( NULL );
+                
+        if( aBuffer )
+            {
+            aBuffer->Reset();
+            delete aBuffer;
+            }
+        
+        aBuffer = CBufFlat::NewL( KSConBufferSize );
+        aBuffer->ResizeL( KSConBufferSize );
+        
+        TObexFilenameBackedBuffer bufferdetails( *aBuffer, iTempFileName, 
+        CObexBufObject::EDoubleBuffering );
+        aObject->SetDataBufL( bufferdetails );
+        
+        if( lowMemory )
+            {
+            // return error. it's up to pccon/ftp plugin howto handle it..
+            LOGGER_WRITE( "CSConFTP::PutFileObjectInitL() : low memory" );
+            ret = KErrNoMemory;
+            }
+        }
+    
+    LOGGER_WRITE_1( "CSConFTP::PutFileObjectInitL( CObexBufObject*& aObject, CBufFlat*& aBuffer ) : returned %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::PutFileObjectFinalizeL( CObexBufObject*& aObject )
+// Stores the relayed file object to inbox or file system.
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTP::PutFileObjectFinalizeL( CObexBufObject*& aObject )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    
+    // if iPathName is not defined trying to save to inbox, no need to call IsCurrentVolumeOK()
+    if( iPathName.Length() > 0 && !IsCurrentVolumeOK() )
+        {
+        // Memory card removed
+        LOGGER_WRITE( "CSConFTP::PutFileObjectFinalizeL() : disk err, return KErrNotFound" );
+        return KErrNotFound;
+        }
+    else if ( iPathName.Length() + aObject->Name().Length() > KMaxFileName )
+        {
+        LOGGER_WRITE( "CSConFTP::PutFileObjectFinalizeL() : Too long filename, return KErrBadName");
+        return KErrBadName;
+        }
+        
+    TBool lowMemory = IsCurrentDiskSpaceBelowCritical();
+    if ( lowMemory )
+        {
+        LOGGER_WRITE( "CSConFTP::PutFileObjectFinalizeL() : Low memory, return KErrNoMemory");
+        return KErrNoMemory;
+        }
+    
+    HBufC* fullPathBuf = HBufC::NewLC( KMaxFileName );
+    TPtr fullPathPtr = fullPathBuf->Des();
+    fullPathPtr.Copy( iPathName );
+    fullPathPtr.Append( aObject->Name() );
+    
+    // Save to inbox if path is not set.
+    if( iPathName.Length() == 0 )
+        {
+        LOGGER_WRITE( "CSConFTP::PutFileObjectFinalizeL before SaveObjectToInbox" );
+        ret = iSConInboxHandler->SaveObjToInboxL( aObject );
+        LOGGER_WRITE_1( "CSConFTP::PutFileObjectFinalize SaveObjectToInbox returned %d", ret );
+        }
+    else if( iPathName.CompareF( K_C_ROOT ) == 0 )
+        {
+        // Saving to root of C:\ is not allowed
+        ret = KErrAccessDenied;
+        }
+    //Save to file system
+    else
+        {
+        TTime time = aObject->Time();
+    
+        // UTC offset   
+        time -= User::UTCOffset();      
+        
+        delete aObject;
+        aObject = NULL;
+            
+        ret = iSConFsHandler->SaveFileObjectL( fullPathPtr, time, 
+        iTempFileName );
+        }
+
+    CleanupStack::PopAndDestroy( fullPathBuf );
+    
+    LOGGER_WRITE_1( "CSConFTP::PutFileObjectFinalizeL( CObexBufObject*& aObject ) : returned %d", ret );
+    
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::SetPathL( const TPtrC aPath, const TUint8 aFlags )
+// Changes the current path. The path can point to inbox or file system
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTP::SetPathL( const TPtrC aPath, const TUint8 aFlags )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aPath: %S", &aPath );
+    TInt ret( KErrNone );
+
+    if( ( aPath.Length() > 0 && aFlags != KSConSetPathRoot )  
+        || ( iPathName.Length() == KDriveLength  && aFlags == KSConSetPathBack) ) 
+        {
+        // check is current drive ok
+        if( !IsCurrentVolumeOK() )
+            {
+            LOGGER_WRITE( "CSConFTP::SetPathL() : drive not found" );
+            return KErrNotFound;
+            }
+        }
+    
+    ret = KErrNotFound;
+    
+    //path forward, deny access to forbidden directories and drives
+    if( aPath.Length() > 0 
+        && ( iPathName.Length() + aPath.Length() < KMaxFileName ) 
+        && ( aFlags == KSConSetPathForward || aFlags == KSConSetPathDontCreate ) )
+        {
+        ret = SetPathForwardL( aPath, aFlags );
+        }
+    //path backward
+    else if( aFlags == KSConSetPathBack )
+        {
+        ret = SetPathBackwardL( aPath );
+        }
+    //path root
+    else if( aPath.Length() == 0 && aFlags == KSConSetPathRoot )
+        {
+        LOGGER_WRITE( "CSConFTP::SetPathL() : KSConSetPathRoot" );
+        if( iPathName.Length() > 0 )
+            {
+            iPathName.Delete( 0, iPathName.Length() );
+            }
+        iCurrentDrive = KErrNotFound;
+        ret = KErrNone;
+        }
+    
+    if( ret == KErrNone )
+        {
+        // drive may have changed, update info
+        UpdateDriveTypeInfoL();
+        }
+    
+    LOGGER_WRITE_1( "CSConFTP::CSConFTP::SetPathL( const TPtrC aPath, const TUint8 aFlags ) : returned %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::SetPathForwardL( const TPtrC aPath, const TUint8 aFlags )
+// Set path forward
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTP::SetPathForwardL( const TPtrC aPath, const TUint8 aFlags )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret(KErrNone);
+    HBufC* fullPath = HBufC::NewLC( KMaxFileName );
+    TPtr fullPathPtr = fullPath->Des();
+    
+    if( iPathName.Length() == 0 )
+        {
+        fullPathPtr.Copy( aPath );   
+        }
+    else
+        {
+        fullPathPtr.Copy( iPathName );
+        fullPathPtr.Append( aPath );
+        }
+    LOGGER_WRITE_1( "fullPathPtr: %S", &fullPathPtr );
+    // now fullpath is new path
+    // check validity
+    if( fullPathPtr.Length() < 2 || fullPathPtr[1] != KDriveDelimiter )
+        {
+        LOGGER_WRITE( "CSConFTP::SetPathForwardL() : not valid name" );
+        CleanupStack::PopAndDestroy( fullPath );
+        return KErrNotFound;
+        }
+    
+    if( fullPathPtr.CompareF( KSConAllowedPath ) == 0 )
+        {
+        // Always access to PC Suite configuration file on ROM
+        LOGGER_WRITE( "CSConFTP::SetPathForwardL() : KSConAllowedPath" );
+        iPathName.Copy( fullPathPtr );
+        if( iPathName[iPathName.Length()-1] != KPathDelimiter )
+            {
+            iPathName.Append( KPathDelimiter );
+            }
+        
+        CleanupStack::PopAndDestroy( fullPath );
+        return KErrNone;
+        }
+    
+    // check drive
+    TInt driveNumber;
+    TInt err = iFs.CharToDrive( fullPathPtr[0], driveNumber );
+    if( err != KErrNone || !IsDriveVisible( driveNumber ) )
+        {
+        LOGGER_WRITE( "CSConFTP::SetPathForwardL() : drive err" );
+        CleanupStack::PopAndDestroy( fullPath );
+        return KErrNotFound;
+        }
+    
+    // check folder and create it if needed
+    if( fullPathPtr.Length() > 2 )
+        {
+        TBool isFolder = EFalse;
+        err = BaflUtils::IsFolder( iFs, fullPathPtr, isFolder );
+        if( err != KErrNone )
+            {
+            isFolder = EFalse;
+            }
+        LOGGER_WRITE_1( "CSConFTP::SetPathForwardL() IsFolder: %d", (TInt)isFolder );
+        
+        if( !isFolder )
+            {
+            //if "Don't create" is 1
+            if( aFlags & 2 )
+                {
+                ret = KErrNotFound;
+                }
+            else
+                {
+                CreateFolderL( fullPathPtr );
+                ret = KErrNone;
+                }
+            }
+        else
+            {
+            ret = KErrNone;
+            }
+        }
+    else
+        {
+        ret = KErrNone;
+        }
+    
+    if( ret == KErrNone )
+        {
+        iPathName.Copy( fullPathPtr );
+        
+        if( iPathName[iPathName.Length()-1] != KPathDelimiter )
+            {
+            iPathName.Append( KPathDelimiter );
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( fullPath );
+    LOGGER_WRITE_1( "CSConFTP::SetPathForwardL() : end, ret: %d", ret );
+    return ret;
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::SetPathBackwardL( const TPtrC aPath )
+// Set path backward
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTP::SetPathBackwardL( const TPtrC aPath )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret(KErrNotFound);
+    if( iPathName.Length() == 0 )
+        {
+        // already in root, exit
+        LOGGER_WRITE( "CSConFTP::SetPathBackwardL() : already in root" );
+        LOGGER_WRITE_1( "CSConFTP::SetPathBackwardL() : end, ret: %d", ret );
+        return ret;
+        }
+    TInt pos;
+    TBool isFolder(EFalse);
+    HBufC* fullPath = HBufC::NewLC( KMaxFileName );
+    TPtr fullPathPtr = fullPath->Des();
+
+    //no directory/folder name
+    if( aPath.Length() == 0 )
+        {
+        LOGGER_WRITE( "CSConFTP::SetPathBackwardL() : no new path, goto parent" );
+        iPathName.Delete( iPathName.Length()-1, 1 );
+        pos = iPathName.LocateReverse( KPathDelimiter );
+        iPathName.Delete( pos+1, iPathName.Length()-pos );
+        ret = KErrNone;
+        }
+    //if folder name
+    else if( aPath.Locate( KDriveDelimiter ) != 1 && iPathName.Length() > KDriveLength  )
+        {
+        LOGGER_WRITE( "CSConFTP::SetPathBackwardL() : goto parent and new path" );                
+        fullPathPtr.Copy( iPathName );
+        fullPathPtr.Delete( fullPathPtr.Length()-1, 1 );
+        pos = fullPathPtr.LocateReverse( KPathDelimiter );
+        fullPathPtr.Delete( pos+1, fullPathPtr.Length()-pos );
+        fullPathPtr.Append( aPath );
+        
+        if( fullPathPtr.CompareF( KSConAllowedPath ) == 0 )
+            {
+            // Always access to PC Suite configuration file on ROM
+            isFolder = ETrue;
+            }
+        else
+            { 
+            TInt driveNumber;
+            TInt err = iFs.CharToDrive(fullPathPtr[0], driveNumber);
+            if( err != KErrNone )
+                {
+                LOGGER_WRITE( "CSConFTP::SetPathForwardL() : drive err" );
+                isFolder = EFalse;
+                }
+            else if( !IsDriveVisible(driveNumber) )
+                {
+                isFolder = EFalse;
+                }
+            else
+                {
+                // drive ok, check folder.
+                err = BaflUtils::IsFolder( iFs, fullPathPtr, isFolder );
+                if( err != KErrNone )
+                    {
+                    isFolder = EFalse;
+                    }
+                }
+            }
+
+        if( isFolder ) 
+            {
+            iPathName.Copy( fullPathPtr );
+
+            if( aPath.LocateReverse( KPathDelimiter ) != aPath.Length()-1 )
+                {
+                iPathName.Append( KPathDelimiter );
+                }
+
+            ret = KErrNone;
+            }
+        else
+            {
+            ret = KErrNotFound;
+            }
+        
+        }
+    //drive
+    else if( aPath.Locate( KDriveDelimiter ) == 1 )
+        {
+        fullPathPtr.Copy( aPath );
+        if( fullPathPtr.LocateReverse( KPathDelimiter ) 
+                    != fullPathPtr.Length()-1 )
+            {
+            fullPathPtr.Append( KPathDelimiter );
+            }
+        
+        TFileName tempPath( KSConAllowedPath );
+        tempPath.Append(KPathDelimiter);
+        if( fullPathPtr.CompareF( tempPath ) == 0 )
+            {
+            // Always access to PC Suite configuration file on ROM
+            isFolder = ETrue;
+            }
+        else
+            {
+            TInt driveNumber;
+            TInt err = iFs.CharToDrive(fullPathPtr[0], driveNumber);
+            if( err != KErrNone )
+                {
+                LOGGER_WRITE( "CSConFTP::SetPathForwardL() : drive err" );
+                isFolder = EFalse;
+                }
+            else if( !IsDriveVisible(driveNumber) )
+                {
+                isFolder = EFalse;
+                }
+            else
+                {
+                // drive ok, check folder.
+                err = BaflUtils::IsFolder( iFs, fullPathPtr, isFolder );
+                if( err != KErrNone )
+                    {
+                    isFolder = EFalse;
+                    }
+                }
+            }
+            
+        if( isFolder ) 
+            {
+            iPathName.Copy( fullPathPtr );
+            
+            if( aPath.LocateReverse( KPathDelimiter ) != aPath.Length()-1 )
+                {
+                iPathName.Append( KPathDelimiter );
+                }
+            
+            ret = KErrNone;
+            }
+        else
+            {
+            ret = KErrNotFound;
+            }               
+        }
+    CleanupStack::PopAndDestroy( fullPath );
+    LOGGER_WRITE_1( "CSConFTP::SetPathBackwardL() : end, ret: %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::CreateFolderL( const TPtrC aFolderName )
+// Creates a new folder to file system
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTP::CreateFolderL( const TPtrC aFolderName )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aFolderName: %S", &aFolderName );
+    TInt ret( KErrNone );
+    if( aFolderName.Length() == 0 )
+        {
+        return KErrArgument;
+        }
+    
+    HBufC*  pathBuf = HBufC::NewLC( KMaxFileName );
+    TPtr pathBufPtr = pathBuf->Des();
+    //absolute folder path
+    if( aFolderName.Length() > 1 && aFolderName[1] == KDriveDelimiter )
+        {
+        if ( iPathName.Length()>0 )
+            {
+            LOGGER_WRITE( "CSConFTP::CreateFolderL() : KErrBadName" );
+            CleanupStack::PopAndDestroy( pathBuf );
+            return KErrBadName;
+            }
+        pathBufPtr.Copy( aFolderName );
+        }
+    else
+        {
+        pathBufPtr.Copy( iPathName );
+        pathBufPtr.Append( aFolderName );
+        }
+    
+    if( !iFs.IsValidName( pathBufPtr ) )
+        {
+        ret = KErrBadName;
+        }
+    else
+        {
+        // check drive
+        TInt driveNumber;
+        ret = iFs.CharToDrive(pathBufPtr[0], driveNumber);
+        if( ret != KErrNone || !IsDriveVisible(driveNumber) )
+            {
+            LOGGER_WRITE( "CSConFTP::CreateFolderL() : drive err" );
+            ret = KErrNotFound;
+            }
+        }
+
+    if ( ret == KErrNone )
+        {
+        if( pathBufPtr.LocateReverse( KPathDelimiter ) != pathBufPtr.Length()-1 )
+            {
+            pathBufPtr.Append( KPathDelimiter );
+            }
+        ret = iSConFsHandler->CreateFolderL( pathBufPtr );
+        }
+    
+    if( ret == KErrNone || ret == KErrAlreadyExists )
+        {
+        ret = SetPathL( aFolderName, KSConSetPathForward );
+        }
+    
+    CleanupStack::PopAndDestroy( pathBuf );
+    
+    LOGGER_WRITE_1( "CSConFTP::CreateFolderL( const TPtrC aFolderName ) : returned %d", ret );
+    
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::DeleteObjectL( const TPtrC aObjectName )
+// Deletes file/folder from inbox or file system
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTP::DeleteObjectL( const TPtrC aObjectName )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aObjectName: %S", &aObjectName );
+    TInt ret( KErrNone );
+    TFileName tmpTarget;
+    HBufC* targetBuf = HBufC::NewLC( KMaxFileName );
+    TPtr target = targetBuf->Des();
+    
+    //absolute folder path
+    if( aObjectName.Length() > 1 && aObjectName[1] == KDriveDelimiter )
+        {
+        if ( iPathName.Length()>0 )
+            {
+            LOGGER_WRITE( "CSConFTP::DeleteObjectL() : KErrBadName" );
+            CleanupStack::PopAndDestroy( targetBuf );
+            return KErrBadName;
+            }
+        target.Copy( aObjectName );
+        }
+    else
+        {
+        target.Copy( iPathName );
+        target.Append( aObjectName );
+        }
+    
+    if( !iFs.IsValidName( target ) )
+        {
+        ret = KErrBadName;
+        }
+    else
+        {
+        TInt driveNumber;
+        ret = iFs.CharToDrive(target[0], driveNumber);
+        if( ret != KErrNone || !IsDriveVisible(driveNumber) )
+            {
+            LOGGER_WRITE( "CSConFTP::DeleteObjectL() : drive err" );
+            ret = KErrNotFound;
+            }
+        }
+    
+
+    if ( ret == KErrNone )
+        {
+        ret = iSConFsHandler->DeleteObjectL( target );
+        }
+    
+    CleanupStack::PopAndDestroy( targetBuf );
+    
+    LOGGER_WRITE_1( "CSConFTP::DeleteObjectL( const TPtrC aObjectName ) : returned %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::GetPath( TDes& aPath )
+// Gets the current path
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTP::GetPath( TDes& aPath )
+    {
+    TRACE_FUNC;
+    aPath.Copy( iPathName );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::AbortFileTransfer( CObexBufObject*& aObject )
+// Abort file transfer
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTP::AbortFileTransfer( CObexBufObject*& aObject )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt err( KErrNone );
+    
+    if( iPathName.Length() == 0 )
+        {
+        iSConInboxHandler->AbortInboxOperation( aObject );
+        }
+    
+    //aObject has to be deleted, otherwise the temp file is locked
+    delete aObject;
+    aObject = NULL;
+    
+    err = iFs.Delete( iTempFileName );
+    
+    LOGGER_WRITE_1( "CSConFTP::AbortFileTransfer( CObexBufObject*& aObject ) : iFs.Delete() err: %d", err );
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::SetProfile( TInt aProfile )
+// Set used transfer profile
+// -----------------------------------------------------------------------------
+//
+void CSConFTP::SetProfile( TSConProfile aProfile )
+    {
+    TRACE_FUNC;
+    iProfile = aProfile;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::SetBackupStarted( TBool aValue )
+// Set backup status
+// -----------------------------------------------------------------------------
+//
+void CSConFTP::SetBackupStarted( TBool aValue )
+    {
+    TRACE_FUNC;
+    iBackupStarted = aValue;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::SetUsedMedia( TSConUsedMedia aMedia )
+// Set the used media information
+// -----------------------------------------------------------------------------
+//  
+void CSConFTP::SetUsedMedia( TSConUsedMedia aMedia )
+    {
+    TRACE_FUNC;
+    iMedia = aMedia;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::IsCurrentDiskSpaceBelowCritical( TUint32 aFilesize )
+// Check is current disk space below critical level.
+// -----------------------------------------------------------------------------
+//
+TBool CSConFTP::IsCurrentDiskSpaceBelowCritical( TUint32 aFilesize )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aFilesize: %d", aFilesize );
+    TInt drive;
+    TInt err;
+    
+    if( iCurrentDrive != KErrNotFound )
+        {
+        drive = iCurrentDrive;
+        }
+    else
+        {
+        LOGGER_WRITE( "CSConFTP::IsCurrentDiskSpaceBelowCritical() : drive not specified, use default drive" );
+        err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, drive );
+        if( err )
+            {
+            LOGGER_WRITE_1( "CSConFTP::IsCurrentDiskSpaceBelowCriticaL() : DriveInfo::GetDefaultDrive err %d", err );
+            return ETrue; //exit
+            }
+        }
+    
+    // check disk space
+    LOGGER_WRITE_1( "drive: %d", drive );
+    TVolumeInfo volumeInfo;
+    err = iFs.Volume(volumeInfo, drive);
+    if( err != KErrNone )
+        {
+        LOGGER_WRITE_1( "CSConFTP::IsCurrentDiskSpaceBelowCritical() : iFs.Volume err %d", err );
+        LOGGER_WRITE( "CSConFTP::IsCurrentDiskSpaceBelowCritical() : End" );
+        return ETrue; //exit
+        }
+    LOGGER_WRITE_1( "volumeInfo.iFree: %Ld", volumeInfo.iFree );
+    TBool diskLevelCritical( EFalse );
+    if ( volumeInfo.iFree - aFilesize <= iCriticalDiskLevel )
+        {
+        // Can not write the data, there's not enough free space on disk.
+        diskLevelCritical = ETrue;
+        }
+
+    LOGGER_WRITE_1( "CSConFTP::IsCurrentDiskSpaceBelowCritical() : ret %d",
+     (TInt)diskLevelCritical );
+    return diskLevelCritical;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::ReadWBXMLDataL( CBufFlat*& aBuffer )
+// Read received ConML protocol packet
+// -----------------------------------------------------------------------------
+//  
+TInt CSConFTP::ReadWBXMLDataL( CBufFlat*& aBuffer )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    
+    RFile file;
+    TInt fileSize;
+    
+    ret = file.Open( iFs, iTempFileName, EFileRead|EFileShareAny );
+    CleanupClosePushL( file );
+    if( ret == KErrNone )
+        {
+        file.Size( fileSize );
+        
+        delete aBuffer;
+        aBuffer = NULL;
+            
+        HBufC8* wbxmlDataBuf = HBufC8::NewLC( fileSize );
+        TPtr8 wbxmlDataPtr = wbxmlDataBuf->Des();
+        
+        file.Read( wbxmlDataPtr );
+        
+        aBuffer = CBufFlat::NewL( KSConBufSize );
+        aBuffer->ExpandL( 0, fileSize );
+        aBuffer->Write( 0, wbxmlDataPtr );
+        
+        CleanupStack::PopAndDestroy( wbxmlDataBuf );
+        }
+    CleanupStack::PopAndDestroy( &file );
+    LOGGER_WRITE_1( "CSConFTP::ReadWBXMLData( CBufFlat*& aBuffer ) : WBXML packet size: %d", fileSize );
+        
+    LOGGER_WRITE_1( "CSConFTP::ReadWBXMLData( CBufFlat*& aBuffer ) : returned %d", ret );
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConFTP::DeleteTempFile()
+// Delete OBEX stack's temp file
+// -----------------------------------------------------------------------------
+//  
+void CSConFTP::DeleteTempFile()
+    {
+    TRACE_FUNC_ENTRY;
+    iFs.Delete( iTempFileName );
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConFTP::MoveFile()
+// Move file/folder
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTP::MoveFile(const TDesC& aSource, const TDesC& aTarget)
+    {
+    TRACE_FUNC_ENTRY;
+    TInt err;
+    TFileName tmpSource;
+    TFileName tmpTarget;
+    err = GetAbsolutePath( aSource, tmpSource );
+    if( err == KErrNone )
+        {
+        err = GetAbsolutePath( aTarget, tmpTarget );
+        }
+        
+    if( err == KErrNone )
+        {
+        TInt sourceDrive;
+        TInt targetDrive;
+        
+        err = iFs.CharToDrive( tmpSource[0], sourceDrive );
+        TInt err2 = iFs.CharToDrive( tmpTarget[0], targetDrive );
+        
+        if( err != KErrNone || err2 != KErrNone
+            || !IsDriveVisible( sourceDrive )
+            || !IsDriveVisible( targetDrive ) )
+            {
+            // drive not visible to user
+            err = KErrNotFound;
+            }
+        }
+        
+    if( err == KErrNone )
+        {
+        TRAP( err,
+        iSConFsHandler->DoCopyOrMoveFileL( tmpSource, tmpTarget, EFalse ) );
+        }
+    
+    LOGGER_WRITE_1( "CSConFTP::MoveFile() : end, err: %d", err );
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::CopyFile()
+// Copy file/folder
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTP::CopyFile(const TDesC& aSource, const TDesC& aTarget)
+    {
+    TRACE_FUNC_ENTRY;
+    TInt err;
+    TFileName tmpSource;
+    TFileName tmpTarget;
+    err = GetAbsolutePath( aSource, tmpSource );
+    if (err == KErrNone)
+        {
+        err = GetAbsolutePath( aTarget, tmpTarget );
+        }
+    
+    if( err == KErrNone )
+        {
+        TInt sourceDrive;
+        TInt targetDrive;
+        
+        err = iFs.CharToDrive( tmpSource[0], sourceDrive );
+        TInt err2 = iFs.CharToDrive( tmpTarget[0], targetDrive );
+        
+        if( err != KErrNone || err2 != KErrNone
+            || !IsDriveVisible( sourceDrive )
+            || !IsDriveVisible( targetDrive ) )
+            {
+            // drive not visible to user
+            err = KErrNotFound;
+            }
+        }
+        
+    if (err == KErrNone)
+        {
+        TRAP( err,
+        iSConFsHandler->DoCopyOrMoveFileL( tmpSource, tmpTarget, ETrue ) );
+        }
+    
+    LOGGER_WRITE_1( "CSConFTP::CopyFile() : end, ret: %d", err );
+    return err;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConFTP::SetReadOnly()
+// Set read-only permissions to file or folder
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTP::SetReadOnly(const TDesC& aTarget, const TBool aReadOnly)
+    {
+    TRACE_FUNC_ENTRY;
+    TInt err;
+    TFileName tmpTarget;
+    err = GetAbsolutePath( aTarget, tmpTarget );
+    if( err != KErrNone )
+        {
+        return err;
+        }
+    else
+        {
+        TInt targetDrive;
+        err = iFs.CharToDrive( tmpTarget[0], targetDrive );
+        
+        if( err != KErrNone
+            || !IsDriveVisible( targetDrive ) )
+            {
+            // drive not visible to user
+            return KErrNotFound;
+            }
+        }
+    
+    TBool isFolder(EFalse);
+    err = BaflUtils::IsFolder( iFs, tmpTarget, isFolder );
+    if ( err == KErrNone && isFolder )
+        {
+        tmpTarget.Append(KPathDelimiter);
+        }
+    if ( !iSConFsHandler->IsFolderVisible( tmpTarget ) )
+        {
+        // folder is not visible to user
+        err = KErrAccessDenied;
+        }
+    else
+        {
+        if( aReadOnly )
+            {
+            err = iFs.SetAtt( tmpTarget, KEntryAttReadOnly, KEntryAttArchive );
+            }
+        else
+            {
+            err = iFs.SetAtt( tmpTarget, KEntryAttNormal, KEntryAttReadOnly );
+            }
+        }
+        
+    LOGGER_WRITE_1( "CSConFTP::SetReadOnly() : ret: %d", err );
+    return err;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConFTP::SetHidden()
+// Set hidden permissions to file or folder
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTP::SetHidden( const TDesC& /*aTarget*/, const TBool /*aHidden*/ )
+    {
+	// This is currently not supported.
+    LOGGER_WRITE("CSConFTP::SetHidden return KErrNotSupported");
+    return KErrNotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::GetAbsolutePath()
+// Get absolute path from relative file/folder
+// -----------------------------------------------------------------------------
+//
+TInt CSConFTP::GetAbsolutePath( const TDesC& aFolderName, TDes &aFullPath )
+    {
+    if (aFolderName.Length() == 0)
+        {
+        return KErrBadName;
+        }
+    //absolute folder path
+    if( aFolderName.Length() > 1 && aFolderName[1] == KDriveDelimiter )
+        {
+        aFullPath.Copy( aFolderName );
+        }
+    // relative to the root folder
+    else if( aFolderName[0] == KPathDelimiter )
+        {
+        if( iPathName.Length() < 2 )
+            {
+            return KErrBadName;
+            }
+        aFullPath.Copy( iPathName.Left(2) );
+        aFullPath.Append( aFolderName );
+        }
+    // relative to the current folder
+    else
+        {
+        aFullPath.Copy( iPathName );
+        if( aFullPath.LocateReverse( KPathDelimiter ) != aFullPath.Length()-1 )
+            {
+            aFullPath.Append( KPathDelimiter );
+            }
+        aFullPath.Append( aFolderName );
+        // no need to check internal root, because iPathName is real target.
+        }
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::CSConFTP()
+// Default constructor
+// -----------------------------------------------------------------------------
+//  
+CSConFTP::CSConFTP() : iProfile( EStandard ), iCurrentDrive( KErrNotFound )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::ConstructL()
+// Initializes member data
+// -----------------------------------------------------------------------------
+//  
+void CSConFTP::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iBuffer = CBufFlat::NewL( KSConBufSize );
+    User::LeaveIfError( iFs.Connect() );
+    iSConFsHandler = CSConFsHandler::NewL( iFs );
+    iSConInboxHandler = CSConInboxHandler::NewL();
+    
+    CRepository* repository = CRepository::NewLC( KCRUidDiskLevel );
+    User::LeaveIfError( repository->Get( KDiskCriticalThreshold, iCriticalDiskLevel ) );
+    CleanupStack::PopAndDestroy( repository );
+    // inlcude package size
+    iCriticalDiskLevel += KPackageSize;
+    LOGGER_WRITE_1( "criticalLevel: %d", iCriticalDiskLevel );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::GetVolumeNameL()
+// Get volume name
+// -----------------------------------------------------------------------------
+//  
+TInt CSConFTP::GetVolumeNameL(const TInt aDriveNumber, TDes8& aVolumeName)
+    {
+    TRACE_FUNC_ENTRY;
+    TVolumeInfo volumeInfo;
+    TInt ret = iFs.Volume( volumeInfo, aDriveNumber );
+    
+    if ( ret == KErrNone)
+        {
+        CnvUtfConverter::ConvertFromUnicodeToUtf8( aVolumeName,
+             volumeInfo.iName );
+        //Replace special characters
+        for( TInt i = 0; i < aVolumeName.Length(); i++ )
+            {
+            switch( aVolumeName[i] )
+                {
+                case '&':
+                    aVolumeName.Delete( i, 1 );
+                    aVolumeName.Insert( i, KReplace1 );
+                    break;
+                case '<':
+                    aVolumeName.Delete( i, 1 );
+                    aVolumeName.Insert( i, KReplace2 );
+                    break;
+                case '>':
+                    aVolumeName.Delete( i, 1 );
+                    aVolumeName.Insert( i, KReplace3 );
+                    break;
+                case '"':
+                    aVolumeName.Delete( i, 1 );
+                    aVolumeName.Insert( i, KReplace4 );
+                    break;
+                case '\'':
+                    aVolumeName.Delete( i, 1 );
+                    aVolumeName.Insert( i, KReplace5 );
+                    break;
+                default:
+                    break;
+                }
+            }
+        
+        //No name
+        if( aVolumeName.Length() == 0 )
+            {
+            LOGGER_WRITE( "Volume has no name, use default localized name" );
+            //Read memory string and convert it
+            TFileName file( KSConResourceName );
+            
+            BaflUtils::NearestLanguageFile( iFs, file );
+            
+            CStringResourceReader* reader = CStringResourceReader::NewL( file );
+            CleanupStack::PushL( reader );
+            TUint driveStatus;
+            User::LeaveIfError( DriveInfo::GetDriveStatus( iFs, aDriveNumber, driveStatus ) );
+            if( driveStatus & DriveInfo::EDriveRemovable )
+                {
+                // read default MMC name
+                CnvUtfConverter::ConvertFromUnicodeToUtf8( aVolumeName, 
+                reader->ReadResourceString( R_SECON_VALUE_MMC ) );
+                }
+            else
+                {
+                // read default DEV name
+                CnvUtfConverter::ConvertFromUnicodeToUtf8( aVolumeName, 
+                reader->ReadResourceString( R_SECON_VALUE_DEVICE ) );
+                }
+            CleanupStack::PopAndDestroy( reader );
+            }
+        }
+    LOGGER_WRITE_1("GetVolumeNameL returned: %d", ret);
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::IsDriveVisible()
+// Check is drive visible for user
+// -----------------------------------------------------------------------------
+//  
+TBool CSConFTP::IsDriveVisible( const TInt aDriveNumber )
+    {
+    TUint driveStatus;
+    TInt err = DriveInfo::GetDriveStatus( iFs, aDriveNumber, driveStatus);
+    if( err )
+        {
+        LOGGER_WRITE_1( "CSConFTP::IsDriveVisible() : DriveInfo::GetDriveStatus err: %d", err );
+        return EFalse;
+        }
+    if( driveStatus & DriveInfo::EDriveRemote )
+        {
+        LOGGER_WRITE( "CSConFTP::IsDriveVisible() : remote drive" );
+        return EFalse;
+        }
+    if( !(driveStatus & DriveInfo::EDriveUserVisible) )
+        {
+        LOGGER_WRITE( "CSConFTP::IsDriveVisible() : not visible" );
+        return EFalse;
+        }
+    if( !(driveStatus & DriveInfo::EDrivePresent ) )
+        {
+        LOGGER_WRITE( "CSConFTP::IsDriveVisible() : not present" );
+        return EFalse;
+        }
+    if( driveStatus & DriveInfo::EDriveCorrupt )
+        {
+        LOGGER_WRITE( "CSConFTP::IsDriveVisible() : corrupted" );
+        return EFalse;
+        }
+    else
+        {
+        return ETrue;
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConFTP::UpdateDriveTypeInfoL()
+// Test is current volume still ok.
+// -----------------------------------------------------------------------------
+//  
+TBool CSConFTP::IsCurrentVolumeOK()
+    {
+    if( iCurrentDrive == KErrNotFound )
+        {
+        LOGGER_WRITE( "CSConFTP::IsCurrentVolumeOK() : not set" );
+        return EFalse;
+        }
+    
+    TUint driveStatus;
+    TInt err = DriveInfo::GetDriveStatus( iFs, iCurrentDrive, driveStatus);
+    if( err )
+        {
+        LOGGER_WRITE_1( "CSConFTP::IsCurrentVolumeOK() : DriveInfo::GetDriveStatus err: %d", err );
+        return EFalse;
+        }
+    if( !(driveStatus & DriveInfo::EDrivePresent ))
+        {
+        LOGGER_WRITE( "CSConFTP::IsCurrentVolumeOK() : not present" );
+        return EFalse;
+        }
+    if( driveStatus & DriveInfo::EDriveCorrupt )
+        {
+        LOGGER_WRITE( "CSConFTP::IsCurrentVolumeOK() : corrupted" );
+        return EFalse;
+        }   
+    else
+        {
+        return ETrue;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSConFTP::UpdateDriveTypeInfoL()
+// Updates drive information (iCurrentDrive and iCurrentDriveTypeNumber)
+// -----------------------------------------------------------------------------
+//  
+void CSConFTP::UpdateDriveTypeInfoL()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt driveNumber;
+    iCurrentDriveTypeNumber = 0;
+    
+    if( iPathName.Length() == 0 )
+        {
+        LOGGER_WRITE( "CSConFTP::UpdateDriveTypeInfoL() : drive not specified" );
+        iCurrentDrive = KErrNotFound;
+        return;
+        }
+    
+    User::LeaveIfError( iFs.CharToDrive(iPathName[0], driveNumber) );
+    iCurrentDrive = driveNumber;
+    
+    TUint driveStatus;
+    User::LeaveIfError( DriveInfo::GetDriveStatus( iFs, iCurrentDrive, driveStatus ) );
+    // if true, search internal drives, else search removable drives
+    TBool searchInternalDrives = (driveStatus & DriveInfo::EDriveInternal);
+    
+    TInt driveCount;
+    TDriveList driveList;
+    
+    User::LeaveIfError( DriveInfo::GetUserVisibleDrives( iFs, driveList, driveCount ) );
+    
+    for( TInt i = EDriveA; i <= iCurrentDrive; i++ )
+        {
+        if( driveList[i] )
+            {
+            TUint driveStatus;
+            User::LeaveIfError( DriveInfo::GetDriveStatus( iFs, i, driveStatus ) );
+
+            if( !(driveStatus & DriveInfo::EDrivePresent )
+                || driveStatus & DriveInfo::EDriveCorrupt )
+                {
+                LOGGER_WRITE( "not present or corrupted" );
+                continue;
+                }
+            
+            if( driveStatus & DriveInfo::EDriveInternal )
+                {
+                if( searchInternalDrives )
+                    {
+                    iCurrentDriveTypeNumber++;
+                    }
+                }
+            else if( driveStatus & DriveInfo::EDriveRemovable )
+                {
+                if( !searchInternalDrives )
+                    {
+                    iCurrentDriveTypeNumber++;
+                    }
+                }
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+    
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/ftp/src/sconftp.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource file for sconftp.dll
+*
+*/
+
+
+// -----------------------------------------------------------------------------
+//  RESOURCE IDENTIFIER
+// -----------------------------------------------------------------------------
+//
+NAME SFTP
+
+// -----------------------------------------------------------------------------
+//  INCLUDE FILES
+// -----------------------------------------------------------------------------
+//
+#include <eikon.rh>
+#include <eikon.rsg>
+
+#include <sconftp.loc>
+
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF r_secon_value_device      { buf = qtn_secon_device; }
+RESOURCE TBUF r_secon_value_mmc         { buf = qtn_secon_mmc; }
+RESOURCE TBUF r_secon_value_mass_storage { buf = qtn_secon_mass_storage; }
+RESOURCE TBUF r_secon_data_folder       { buf = qtn_secon_data_folder; }
+RESOURCE TBUF r_secon_unknown_supplier  { buf = qtn_secon_unknown_supplier; }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/ftp/src/sconinboxhandler.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,199 @@
+/*
+* 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 Transfer Controller implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include <obexutilsmessagehandler.h>
+#include <btmsgtypeuid.h>    // BT Message Uid
+
+#include "sconinboxhandler.h"
+#include "debug.h"
+#include "sconconsts.h"
+
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSConInboxHandler::NewL()
+// Two-phase constructor
+// -----------------------------------------------------------------------------
+//
+CSConInboxHandler* CSConInboxHandler::NewL()
+    {
+    TRACE_FUNC_ENTRY;
+    CSConInboxHandler* self = new (ELeave) CSConInboxHandler();
+    
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConInboxHandler::~CSConInboxHandler()
+// Default destructor
+// -----------------------------------------------------------------------------
+//
+CSConInboxHandler::~CSConInboxHandler()
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConInboxHandler::CreateInboxAttachmentL( CObexBufObject*& aObject,
+//                                              CBufFlat*& aBuffer )
+// Creates an attachment to device's Inbox
+// -----------------------------------------------------------------------------
+//  
+TInt CSConInboxHandler::CreateInboxAttachmentL( CObexBufObject*& aObject,
+                                                CBufFlat*& aBuffer )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    iDrive = GetMessageCenterDriveL();
+    
+    delete aObject;
+    aObject = CObexBufObject::NewL( NULL );
+    
+    iFile = RFile();
+    
+    TRAP( ret, TObexUtilsMessageHandler::CreateInboxAttachmentL( aObject, 
+    KUidMsgTypeBt, iMsvIdParent, iFile ) );
+        
+    if( aBuffer )
+        {
+        aBuffer->Reset();
+        delete aBuffer;
+        }
+        
+    aBuffer = CBufFlat::NewL( KSConBufferSize );
+    aBuffer->ResizeL( KSConBufferSize );
+    
+    TObexRFileBackedBuffer bufferdetails( *aBuffer, iFile, 
+    CObexBufObject::EDoubleBuffering );
+    aObject->SetDataBufL( bufferdetails );
+    LOGGER_WRITE_1( "CSConInboxHandler::CreateInboxAttachmentL() : returned %d", ret );
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConInboxHandler::SaveObjToInboxL( CObexBufObject*& aObject )
+// Saves the object to the Inbox
+// -----------------------------------------------------------------------------
+//  
+TInt CSConInboxHandler::SaveObjToInboxL( CObexBufObject*& aObject )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    
+    if( iDrive == EDriveE )
+        {
+        ret = TObexUtilsMessageHandler::GetMmcFileSystemStatus();
+        LOGGER_WRITE_1( "GetMmcFileSystemStatus returned %d", ret );
+        }
+    else
+        {
+        ret = TObexUtilsMessageHandler::GetFileSystemStatus();
+        LOGGER_WRITE_1( "GetFileSystemStatus returned %d", ret );
+        }
+       
+    if( ret == KErrNone )
+        {
+        TInt tempDrive = GetMessageCenterDriveL();
+    
+        if( tempDrive == iDrive )
+            {
+            LOGGER_WRITE_1( "before SaveObjToInboxL in SaveObjToInboxL %d", ret );
+            TRAP( ret, TObexUtilsMessageHandler::SaveObjToInboxL( aObject, 
+            iFile, iMsvIdParent ) );
+            LOGGER_WRITE_1( "after SaveObjToInboxL in SaveObjToInboxL %d", ret );
+            }
+        else
+            {
+            ret = KErrGeneral;
+            }   
+            
+        if( ret != KErrNone )
+            {
+            LOGGER_WRITE_1( "before RemoveInboxEntriesL in SaveObjToInboxL %d", ret );
+            TObexUtilsMessageHandler::RemoveInboxEntriesL( aObject, 
+            iMsvIdParent );
+            LOGGER_WRITE_1( "after RemoveInboxEntriesL in SaveObjToInboxL %d", ret );
+            }
+        }
+        
+    LOGGER_WRITE_1( "CSConInboxHandler::SaveObjToInboxL( CObexBufObject* aObject ) : returned %d", ret );
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConInboxHandler::AbortInboxOperation( CObexBufObject*& aObject )
+// Aborts the storing operation
+// -----------------------------------------------------------------------------
+//  
+TInt CSConInboxHandler::AbortInboxOperation( CObexBufObject*& aObject )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    TRAP( ret, TObexUtilsMessageHandler::RemoveInboxEntriesL( aObject, 
+    iMsvIdParent ) );
+    LOGGER_WRITE_1( "CSConInboxHandler::AbortInboxOperation() returned %d", ret );
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConInboxHandler::GetMessageCenterDriveL()
+// Returns the current message center drive
+// -----------------------------------------------------------------------------
+//  
+TInt CSConInboxHandler::GetMessageCenterDriveL()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt drive;
+    CMsvSession* msvSession = CMsvSession::OpenSyncL( *this );
+    CleanupStack::PushL( msvSession );
+    TDriveUnit driveUnit = msvSession->CurrentDriveL();
+    drive = driveUnit.operator TInt();
+    CleanupStack::PopAndDestroy( msvSession );
+    LOGGER_WRITE_1( "CSConInboxHandler::GetMessageCenterDriveL() returned %d", drive );
+    return drive;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConInboxHandler::HandleSessionEventL( TMsvSessionEvent aEvent, 
+//                              TAny* aArg1, 
+//                              TAny* aArg2, 
+//                              TAny* aArg3 )
+// Implementation of MMsvSessionObserver::HandleSessionEventL
+// -----------------------------------------------------------------------------
+//      
+void CSConInboxHandler::HandleSessionEventL( TMsvSessionEvent /*aEvent*/, 
+                                TAny* /*aArg1*/, 
+                                TAny* /*aArg2*/, 
+                                TAny* /*aArg3*/ )
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConInboxHandler::CSConInboxHandler()
+// Default constructor
+// -----------------------------------------------------------------------------
+//  
+CSConInboxHandler::CSConInboxHandler()
+    {
+    }   
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/bld/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*	 This file provides the information required for building the
+*    whole of a SConPCD
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT 
+
+PRJ_EXPORTS
+./sbeconfig.xml	/epoc32/data/Z/private/10202D56/sbeconfig.xml
+
+PRJ_MMPFILES
+sconpcd.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/bld/def/bwinscwu.def	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?CreateCSConPCDL@@YAPAVCSConPCD@@XZ @ 1 NONAME ; class CSConPCD * CreateCSConPCDL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/bld/def/eabiuu.def	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,5 @@
+EXPORTS
+	_Z15CreateCSConPCDLv @ 1 NONAME
+	_ZTI8CSConPCD @ 2 NONAME ; #<TI>#
+	_ZTV8CSConPCD @ 3 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/bld/sbeconfig.xml	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,7 @@
+<?xml version="1.0" standalone="yes"?>
+<sbe_config>
+	<heap size = "131072" max_retries = "5" reduction_factor = "2"/> 
+	<central_repository uid = "0x10202BE9"/>
+	<exclude_drives list = "z"/>
+	<app_close_delay delay = "4000000"/>
+</sbe_config>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/bld/sconpcd.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:  PC Connectivity Signaling Module
+*
+*/
+
+
+// To get the MW_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_GENERAL_DLL
+
+TARGETPATH      sys/bin
+
+TARGET          sconpcd.dll
+TARGETTYPE      DLL
+UID             0x10009D8D 0x101F968B
+
+#if defined(ARMCC)
+DEFFILE	./def/eabiu
+#elif defined(WINSCW) 
+DEFFILE	./def/bwinscw
+#elif defined(WINS)
+DEFFILE	./def/bwins
+#elif defined(ARM)
+DEFFILE	./def/bmarm
+#endif
+
+SOURCEPATH      ../src
+SOURCE          sconpcd.cpp
+SOURCE          sconqueue.cpp
+SOURCE          sconinstqueue.cpp
+SOURCE          sconbrqueue.cpp
+SOURCE          sconinstaller.cpp
+SOURCE          sconbackuprestore.cpp
+SOURCE          sconsbeclient.cpp
+SOURCE          sconpcdutility.cpp
+SOURCE          sconmetadata.cpp
+SOURCE          sconvideoparser.cpp
+SOURCE          cscontimeout.cpp
+
+SOURCEPATH      ../../../common/conmltask/src
+SOURCE          sconconmltask.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc
+USERINCLUDE     ../../../common/conmltask/inc
+
+// Default system include paths
+APP_LAYER_SYSTEMINCLUDE
+
+
+LIBRARY         euser.lib 
+LIBRARY         swinstcli.lib
+LIBRARY         sbeclient.lib
+LIBRARY         sisregistryclient.lib
+LIBRARY         javaregistryclient.lib
+LIBRARY         platformenv.lib
+LIBRARY         efsrv.lib
+LIBRARY         sysutil.lib
+LIBRARY         commonengine.lib        // For resource reader
+LIBRARY         WidgetRegistryClient.lib
+LIBRARY         metadatautility.lib
+LIBRARY         exiflib.lib
+LIBRARY         charconv.lib
+LIBRARY         caf.lib                 // for Content Access
+LIBRARY         MediaClientVideo.lib    // for CVideoPlayerUtility
+LIBRARY         ws32.lib                // for RWsSession
+LIBRARY         TNEEngine.lib           // for CTNEVideoClipInfo
+LIBRARY         ImageConversion.lib         // for CImageEncoder
+LIBRARY         MMFControllerFramework.lib  // for CMMFMetaDataEntry
+LIBRARY         bafl.lib                    // for BaflUtils
+DEBUGLIBRARY    flogger.lib
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/inc/cscontimeout.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSconTimeOut declaration
+*
+*/
+
+
+#ifndef CSCONTIMEOUT_H
+#define CSCONTIMEOUT_H
+
+#include <e32base.h>	// For CActive, link against: euser.lib
+#include <e32std.h>		// For RTimer, link against: euser.lib
+
+class MTimeOutObserver
+    {
+public:
+    virtual void TimeOut() = 0;
+    };
+
+NONSHARABLE_CLASS( CSconTimeOut ) : public CActive
+    {
+public:
+    // Cancel and destroy
+    ~CSconTimeOut();
+    static CSconTimeOut* NewL( MTimeOutObserver& aTimeOutObserver );
+    
+public:
+    // Function for making the timeout request
+    void Start(TTimeIntervalMicroSeconds32 aDelay);
+    
+private:
+    CSconTimeOut( MTimeOutObserver& aTimeOutObserver );
+    void ConstructL();
+    
+private: // From CActive
+    void RunL();
+    void DoCancel();
+    TInt RunError(TInt aError);
+    
+private:
+    RTimer              iTimer; // Provides async timing service
+    MTimeOutObserver&   iTimeOutObserver;
+    };
+
+#endif // CSCONTIMEOUT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconbackuprestore.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,113 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSConBackupRestore header file
+*
+*/
+
+
+#ifndef _SCONBACKUPRESTORE_H_
+#define _SCONBACKUPRESTORE_H_
+
+// INCLUDES
+
+#include <e32base.h>
+#include <e32cons.h>
+
+class CSConSBEClient;
+class CSConBackupRestoreQueue;
+class RFs;
+
+//============================================================
+// Class CSConBackupRestore declaration
+//============================================================	
+NONSHARABLE_CLASS( CSConBackupRestore ): public CActive
+	{
+	public:
+		/**
+		 * Two-phase constructor
+		 * @param aQueue The address of CSConBackupRestoreQueue
+		 * @param aMaxObjectSize Max object size
+		 * @param aFs aReference to RFs connection.
+    	 * @return CSConBackupRestore instance
+		 */
+		static CSConBackupRestore* NewL( 
+			CSConBackupRestoreQueue* aQueue, 
+			const TInt aMaxObjectSize, RFs& aFs );
+		/**
+		 * Destructor
+		 * @return none
+		 */
+		~CSConBackupRestore();
+		
+		/**
+		 * Starts backup-restore task
+		 * @param aTaskId The task number
+    	 * @return none
+		 */
+		void StartBackupRestore( TInt aTaskId );
+		/**
+		 * Stops executing backup-restore task
+		 * @param aTaskId
+    	 * @return none
+		 */
+		void StopBackupRestore( TInt aTaskId );
+		/**
+		 * Resets backup
+		 * @return none
+		 */
+		void Reset();
+		
+		/**
+		 * Returns the active status of the backup-restore
+		 * @return ETrue if backup-restore is active, else EFalse
+		 */
+		TBool BackupRestoreActive() const;
+		
+	private:
+		/**
+		 * Constructor
+		 * @param aQueue The address of CSConBackupRestoreQueue
+		 * @param aFs aReference to RFs connection.
+		 * @return none
+		 */
+		CSConBackupRestore( CSConBackupRestoreQueue* aQueue, RFs& aFs );
+		/**
+		 * Initializes member data
+		 * @param aMaxObjectSize Max object size
+		 * @return none
+		 */
+		void ConstructL( const TInt aMaxObjectSize );
+		/**
+		 * Implementation of CActive::DoCancel()
+		 * @return none
+		 */
+		void DoCancel();
+		/**
+		 * Implementation of CActive::RunL()
+		 * @return none
+		 */
+		void RunL();
+		
+	private:
+		CSConBackupRestoreQueue*		iQueue; 
+		CSConSBEClient*					iSBEClient;
+		TInt							iCurrentTask;
+		TInt							iMaxObjectSize;
+		TBool							iBackupRestoreActive;
+		RFs&                            iFs;
+	};
+	
+#endif // _SCONBACKUPRESTORE_H_
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconbrqueue.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,124 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Backup-Restore Queue header file
+*
+*/
+
+
+#ifndef _SCONBRQUEUE_H_
+#define _SCONBRQUEUE_H_
+
+#include "sconqueue.h"
+
+class CSConTaskQueue;
+
+//============================================================
+// Class CSConBackupRestoreQueue declaration
+//============================================================	
+NONSHARABLE_CLASS ( CSConBackupRestoreQueue ) : public CActive, public CSConTaskQueue
+	{
+	public:
+		/**
+		 * Two-phase constructor
+		 * @param aMaxObjectSize Max object size
+		 * @param aFs aReference to RFs connection.
+		 * @return CSConBackupRestoreQueue instance
+		 */
+		static CSConBackupRestoreQueue* NewL( const TInt aMaxObjectSize, RFs& aFs );
+		/**
+		 * Destructor
+		 * @return CSConBackupRestoreQueue instance
+		 */
+		~CSConBackupRestoreQueue();
+		/**
+		 * Adds a new task to queue
+		 * @param aNewTask A new task to be added
+		 * @param aTaskId The task number
+    	 * @return KErrNone if no errors, else system wide error codes
+		 */
+		TInt AddNewTask( CSConTask*& aNewTask, TInt aTaskId );
+		/**
+		 * Cancels a task
+		 * @param aTask The task number
+		 * @param aAllTasks If ETrue => cancel all tasks
+		 * @param aStatus The reply
+    	 * @return none
+		 */	
+		void CancelTask( TInt aTask, TBool aAllTasks );
+		/**
+		 * Resets the queue
+    	 * @return none
+		 */
+		void Reset();
+		/**
+		 * An address pointer to another queue
+		 * @param aTaskQueue The address to another queue
+    	 * @return none
+		 */
+		virtual void QueueAddress( CSConInstallerQueue*& aTaskQueue );
+		/**
+		 * Returns the task type
+		 * @param aTaskId The task number
+    	 * @return task type
+		 */	
+		TSConMethodName GetTaskMethodL( TInt aTaskId );
+		
+	private:
+		/**
+		 * Constructor
+		 * @return none
+		 */
+		CSConBackupRestoreQueue();
+		/**
+		 * Initializes member data
+		 * @param aMaxObjectSize Max object size
+		 * @param aFs aReference to RFs connection.
+		 * @return none
+		 */
+		void ConstructL( const TInt aMaxObjectSize, RFs& aFs );
+		/**
+		 * Polls queue
+		 * @return none
+		 */
+		void PollQueue();
+		/**
+		 * Starts queue polling
+		 * @return none
+		 */
+		void StartQueue();
+		/**
+		 * Stops queue polling
+		 * @return none
+		 */
+		void StopQueue();
+		/**
+		 * Implementation of CActive::DoCancel()
+		 * @return none
+		 */
+		void DoCancel();
+		/**
+		 * Implementation of CActive::RunL()
+		 * @return none
+		 */
+		void RunL();
+		
+	private:
+		CSConBackupRestore*			iBackupRestore;
+		CSConInstallerQueue*		iInstQueueAddress;
+	};
+
+
+#endif
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconinstaller.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:  CSConAppInstaller header file
+*
+*/
+
+
+#ifndef _SCONINSTALLER_H_
+#define _SCONINSTALLER_H_
+
+// INCLUDES
+
+#include <e32base.h>
+#include <e32cons.h>
+#include <SWInstApi.h>
+
+#include "sconinstqueue.h"
+
+class CSConUninstall;
+
+//============================================================
+// Class CSConAppInstaller declaration
+//============================================================	
+NONSHARABLE_CLASS ( CSConAppInstaller ): public CActive
+	{
+	public:
+		/**
+		 * Constructor
+		 * @param aQueue The address of CSConInstallerQueu
+    	 * @return none
+		 */
+		CSConAppInstaller( CSConInstallerQueue* aQueue, RFs& aFs );
+		
+		/**
+		 * Destructor
+		 * @return none
+		 */
+		~CSConAppInstaller();
+		
+		/**
+		 * Starts the installer task
+		 * @param aTaskId Task number
+    	 * @return none
+		 */
+		void StartInstaller( TInt& aTaskId );
+		/**
+		 * Stops the installer task
+    	 * @return none
+		 */
+		void StopInstaller( TInt& aTaskId );
+		
+		/**
+		 * Returns the active status of the installer
+		 * @return ETrue if installer is active, else EFalse
+		 */
+		TBool InstallerActive() const;
+		
+	private:
+		/**
+		 * Implementation of CActive::DoCancel()
+		 * @return none
+		 */
+		void DoCancel();
+		/**
+		 * Implementation of CActive::RunL()
+		 * @return none
+		 */
+		void RunL();
+		/**
+		 * Executes ListInstalledApps task
+		 * @return none
+		 */
+		void ProcessListInstalledAppsL();
+		/**
+		 * Execures UnInstall task
+		 * @param CSConUninstall uninstall params
+    	 * @return none
+		 */
+		void ProcessUninstallL( const CSConUninstall& aUninstallParams );
+		
+		void UninstallSisL( const CSConUninstall& aUninstallParams );
+		void UninstallJavaL( const TUid& aUid, const TSConInstallMode aMode );
+		void UninstallWidget( const TUid& aUid, const TSConInstallMode aMode );
+		void DeleteFile( const TDesC& aPath );
+		
+	private:
+	    enum TInstallerState
+	        {
+	        EIdle = 0,
+	        EInstalling,
+	        ESilentInstalling,
+	        EUninstalling,
+	        ESilentUninstalling,
+	        ECustomUninstalling,
+	        ESilentCustomUnistalling,
+	        EListingInstalledApps
+	        };
+	    TInstallerState                 iInstallerState;
+		CSConInstallerQueue*			iQueue; // Not owned
+		SwiUI::RSWInstLauncher			iSWInst;
+		SwiUI::TInstallOptions          iOptions;
+        SwiUI::TInstallOptionsPckg      iOptionsPckg;   
+		TInt							iCurrentTask;
+		RFs&                            iFs;
+	};
+	
+#endif // _SCONINSTALLER_H_
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconinstqueue.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Installer Queue header file
+*
+*/
+
+
+#ifndef _SCONINSTQUEUE_H_
+#define _SCONINSTQUEUE_H_
+
+#include "sconqueue.h"
+
+
+//============================================================
+// Class CSConInstallerQueue declaration
+//============================================================	
+NONSHARABLE_CLASS ( CSConInstallerQueue ): public CActive, public CSConTaskQueue
+	{
+	public:
+		/**
+		 * Two-phase constructor
+		 * @return CSConInstallerQueue instance
+		 */
+		static CSConInstallerQueue* NewL( RFs& aFs );
+		/**
+		 * Destructor
+		 * @return none
+		 */
+		~CSConInstallerQueue();
+		
+		/**
+		 * Cancels a task
+		 * @param aTask The task number
+		 * @param aAllTasks If ETrue => cancel all tasks
+		 * @param aStatus The reply
+    	 * @return none
+		 */	
+		void CancelTask( TInt aTask, TBool aAllTasks );
+		
+		/**
+		 * An address pointer to another queue
+		 * @param aTaskQueue The address to another queue
+    	 * @return none
+		 */			
+		void QueueAddress( CSConBackupRestoreQueue*& aTaskQueue );
+		
+	private:
+		/**
+		 * Constructor
+		 * @return none
+		 */
+		CSConInstallerQueue( RFs& aFs );
+		/**
+		 * Initializes member data
+		 * @return none
+		 */
+		void ConstructL();
+		/**
+		 * Polls queue
+		 * @return none
+		 */
+		void PollQueue();
+		/**
+		 * Starts queue polling
+		 * @return none
+		 */
+		void StartQueue();
+		/**
+		 * Stops queue polling
+		 * @return none
+		 */
+		void StopQueue();
+		/**
+		 * Implementation of CActive::DoCancel()
+		 * @return none
+		 */
+		void DoCancel();
+		/**
+		 * Implementation of CActive::RunL()
+		 * @return none
+		 */
+		void RunL();
+		
+	private:
+		CSConAppInstaller* 			iInstaller;	
+		CSConBackupRestoreQueue*	iBRQueueAddress;
+		RFs&                        iFs; 
+	};
+
+
+#endif
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconmetadata.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,148 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  SConMetadata header file
+*
+*/
+
+
+#ifndef _SCONMETADATA_H_
+#define _SCONMETADATA_H_
+
+#include <MetaDataField.hrh>
+
+class CSConTask;
+class CExifRead;
+class CExifTag;
+//============================================================
+// Class CSConMetadata declaration
+//============================================================  
+NONSHARABLE_CLASS( SConMetadata )
+    {
+    public:
+    
+    /**
+     * Start processing metadata task
+     * @param aTask used task
+     * @param aFs aReference to RFs connection.
+     * @return none
+     */
+    static void ProcessTask( CSConTask& aTask, RFs& aFs );
+    
+    private:
+    
+    /**
+    * Get audio metadata to task
+    * @return none
+    */
+    static void GetAudioMetadataL( CSConTask& aTask );
+    
+    /**
+    * Get video metadata to task
+    * @param aFs aReference to RFs connection.
+    * @return none
+    */
+    static void GetVideoMetadataL( CSConTask& aTask, RFs& aFs );
+    
+    /**
+    * parse exif field
+    * @return HBufC8* parsed data. Leaves if not found
+    */
+    static HBufC8* GetExifTagL( CExifRead* aReader, const TUint8 aTagID ) ;
+    
+    /**
+    * Parse TUint32 value from aData
+    * @return TUint32 value
+    */
+    static TUint32 ReadTUint32( const TDesC8& aData );
+    
+    /**
+     * Read data from file
+     * @param aFs aReference to RFs connection.
+     * @return file data
+     */
+    static HBufC8* GetFileDataLC( const TDesC& aFilename, RFs& aFs );
+    
+    /**
+    * Get exif metadata to task
+    * @param aFs aReference to RFs connection.
+    * @return none
+    */
+    static void ReadExifDataL( CSConTask& aTask, RFs& aFs );
+    
+    /**
+     * Convert latidute/longitude tag to TReal64 value
+     * @return KErrNone if successfully converted
+     */
+    static TInt ConvertRationalTag( const CExifTag& aTag, TDes& aPosDegrees );
+    
+    /**
+     * Get latidute value from Exif
+     * @param aExifRead ExifReader used to read
+     * @param aLatitude readed latidute
+     * @return KErrNone if found
+     */
+    static TInt GetExifGPSLatitudeL( CExifRead& aExifRead, TDes& aLatitude );
+    
+    /**
+     * Get longitude value from Exif
+     * @param aExifRead ExifReader used to read
+     * @param aLongitude readed longitude
+     * @return KErrNone if found
+     */
+    static TInt GetExifGPSLongitudeL( CExifRead& aExifRead, TDes& aLongitude );
+    
+    /**
+     * Get altidute value from Exif
+     * @param aExifRead ExifReader used to read
+     * @param aAltidute readed altidute
+     * @return KErrNone if found
+     */
+    static TInt GetExifGPSAltiduteL( CExifRead& aExifRead, TDes& aAltidute );
+    
+    /**
+    * Appends data field to buffer
+    * @return none
+    */
+    static void AppendUtf8DataFieldL( CBufFlat* aBuffer, const TPtrC aAppendData,
+        const TUint8 aFieldId );
+    
+    /**
+    * Appends data field to buffer
+    * @return none
+    */
+    static void AppendByteDataFieldL( CBufFlat* aBuffer, const TPtrC8 aAppendData,
+        const TUint8 aFieldId );
+    
+    /**
+    * Writes TUint32 value to buffer
+    * @return none
+    */
+    static void WriteTUint32( CBufFlat* aBuffer, TInt offset, TUint32 aValue );
+    
+    /**
+    * Appends data field to buffer
+    * @return none
+    */
+    static void AppendTUintDataFieldL( CBufFlat* aBuffer, TUint32 aValue,
+        const TUint8 aFieldId );
+    
+    /**
+    * Get AudioFieldId
+    * @return TUint8
+    */
+    static TUint8 AudioFieldId( const TMetaDataFieldId fieldId );
+    
+    };
+
+#endif // _SCONMETADATA_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconmetadatafielddefs.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,128 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Metadata field definitions
+*
+*/
+
+
+#ifndef _SCONMETADATAFIELDDEFS_H_
+#define _SCONMETADATAFIELDDEFS_H_
+
+// Content type header
+const TUint8 KSconMetadataHeaderAudio( 0x01 );
+const TUint8 KSconMetadataHeaderExif ( 0x02 );
+const TUint8 KSconMetadataHeaderVideo( 0x03 );
+
+const TUint8 KSconMetadataHeaderVersion ( 0x02 ); // format version = 2
+
+// fields for audio
+const TUint8 KSconAudioID3Version   ( 0x01 );
+const TUint8 KSconAudioTitle        ( 0x02 );
+const TUint8 KSconAudioArtist       ( 0x03 );
+const TUint8 KSconAudioAlbum        ( 0x04 );
+const TUint8 KSconAudioYear         ( 0x05 );
+const TUint8 KSconAudioComment      ( 0x06 );
+const TUint8 KSconAudioAlbumTrack   ( 0x07 );
+const TUint8 KSconAudioGenre        ( 0x08 );
+const TUint8 KSconAudioComposer     ( 0x09 );
+const TUint8 KSconAudioCopyright    ( 0x0a );
+const TUint8 KSconAudioOriginalArtist( 0x0b );
+const TUint8 KSconAudioUrl          ( 0x0c );
+const TUint8 KSconAudioUserUrl      ( 0x0d );
+const TUint8 KSconAudioJpeg         ( 0x0e );
+const TUint8 KSconAudioVendor       ( 0x0f );
+const TUint8 KSconAudioRating       ( 0x10 );
+const TUint8 KSconAudioUniqueFileIdentifier( 0x11 );
+const TUint8 KSconAudioDuration     ( 0x12 );
+const TUint8 KSconAudioDate         ( 0x13 );
+
+// fields for exif
+const TUint8 KSconExifThumbnail         ( 0x01 );
+const TUint8 KSconExifDescription       ( 0x02 );
+const TUint8 KSconExifMake              ( 0x03 );
+const TUint8 KSconExifModel             ( 0x04 );
+const TUint8 KSconExifDateTime          ( 0x05 );
+const TUint8 KSconExifSoftware          ( 0x06 );
+const TUint8 KSconExifCopyright         ( 0x07 );
+const TUint8 KSconExifOrientation       ( 0x08 );
+const TUint8 KSconExifXResolution1      ( 0x09 );
+const TUint8 KSconExifXResolution2      ( 0x0a );
+const TUint8 KSconExifYResolution1      ( 0x0b );
+const TUint8 KSconExifYResolution2      ( 0x0c );
+const TUint8 KSconExifResolutionUnit    ( 0x0d );
+const TUint8 KSconExifYCbCrPositioning  ( 0x0e );
+const TUint8 KSconExifIsoSpeedRatings   ( 0x0f );
+const TUint8 KSconExifDateTimeOriginal  ( 0x10 );
+const TUint8 KSconExifDateTimeDigitized ( 0x11 );
+const TUint8 KSconExifMakerNote         ( 0x12 );
+const TUint8 KSconExifUserComment       ( 0x13 );
+const TUint8 KSconExifRelatedSoundFile  ( 0x14 );
+const TUint8 KSconExifExposureTime1     ( 0x15 );
+const TUint8 KSconExifExposureTime2     ( 0x16 );
+const TUint8 KSconExifComponentsConfiguration ( 0x17 );
+const TUint8 KSconExifFlash             ( 0x18 );
+const TUint8 KSconExifColorSpace        ( 0x19 );
+const TUint8 KSconExifPixelXDimension   ( 0x1a );
+const TUint8 KSconExifPixelYDimension   ( 0x1b );
+const TUint8 KSconExifExposureMode      ( 0x1c );
+const TUint8 KSconExifWhiteBalance      ( 0x1d );
+const TUint8 KSconExifSceneCaptureType  ( 0x1e );
+const TUint8 KSconExifExposureProgram   ( 0x1f );
+const TUint8 KSconExifApertureValue1    ( 0x20 );
+const TUint8 KSconExifApertureValue2    ( 0x21 );
+const TUint8 KSconExifExposureBiasValue1 ( 0x22 );
+const TUint8 KSconExifExposureBiasValue2 ( 0x23 );
+const TUint8 KSconExifMeteringMode      ( 0x24 );
+const TUint8 KSconExifLightSource       ( 0x25 );
+const TUint8 KSconExifFileSource        ( 0x26 );
+const TUint8 KSconExifDigitalZoomRatio1 ( 0x27 );
+const TUint8 KSconExifDigitalZoomRatio2 ( 0x28 );
+const TUint8 KSconExifContrast          ( 0x29 );
+const TUint8 KSconExifSaturation        ( 0x2a );
+const TUint8 KSconExifSharpness         ( 0x2b );
+const TUint8 KSconExifExifVersion       ( 0x2c );
+const TUint8 KSconExifFlashPixVersion   ( 0x2d );
+const TUint8 KSconExifThumbXResolution1 ( 0x2e );
+const TUint8 KSconExifThumbXResolution2 ( 0x2f );
+const TUint8 KSconExifThumbYResolution1 ( 0x30 );
+const TUint8 KSconExifThumbYResolution2 ( 0x31 );
+const TUint8 KSconExifThumbResolutionUnit   ( 0x32 );
+const TUint8 KSconExifThumbCompression      ( 0x33 );
+const TUint8 KSconExifThumbJpegInterchangeFormat        ( 0x34 );
+const TUint8 KSconExifThumbJpegInterchangeFormatLength  ( 0x35 );
+const TUint8 KSconExifShutterSpeedValue1 ( 0x36 );
+const TUint8 KSconExifShutterSpeedValue2 ( 0x37 );
+const TUint8 KSconExifBrightnessValue1  ( 0x38 );
+const TUint8 KSconExifBrightnessValue2  ( 0x39 );
+const TUint8 KSconExifCustomRendered    ( 0x3a );
+const TUint8 KSconExifGainControl       ( 0x3b );
+const TUint8 KSconExifGpsVersion        ( 0x3c );
+const TUint8 KSconExifGPSLatitude    	( 0x3d );
+const TUint8 KSconExifGPSLongitude      ( 0x3e );
+const TUint8 KSconExifGPSAltitude       ( 0x3f );
+const TUint8 KSconExifBitDepth	        ( 0x40 );
+
+// fields for video
+const TUint8 KSconVideoFormat			( 0x01 );
+const TUint8 KSconVideoFrameRate		( 0x02 );
+const TUint8 KSconVideoFrameSizeWidth	( 0x03 );
+const TUint8 KSconVideoFrameSizeHeight	( 0x04 );
+const TUint8 KSconVideoVideoBitRate		( 0x05 );
+const TUint8 KSconVideoAudioBitRate		( 0x06 );
+const TUint8 KSconVideoDuration			( 0x07 );
+const TUint8 KSconVideoThumbnail		( 0x08 );
+const TUint8 KSconVideoAudioStreamMimetype	( 0x09 );
+const TUint8 KSconVideoVideoStreamMimetype	( 0x0a );
+
+#endif // _SCONMETADATAFIELDDEFS_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconpcd.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,163 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSConPCD service header
+*
+*/
+
+
+#ifndef _SCONPCD_H_
+#define _SCONPCD_H_
+
+// INCLUDES
+
+#include <e32base.h>
+#include <e32cons.h>
+
+#include "sconconmltask.h"
+
+class CSConInstallerQueue;
+class CSConBackupRestoreQueue;
+
+enum TSConLastConMLOperation
+    {
+    ENoTask = 0,
+    EPutTask,
+    EGetReply
+    };
+
+//============================================================
+// Class CSConPCD declaration
+//============================================================
+class CSConPCD : public CBase
+    {
+    public:
+        /**
+         * Two-phase constructor
+         * @return CSConPCD instance
+         */
+        static CSConPCD* NewL();
+        /**
+         * Destructor
+         * @return none
+         */
+        ~CSConPCD();
+        /**
+         * Receives a new task
+         * @param aTask A new task
+         * @return KErrNone if no errors, else system wide error codes
+         */
+        virtual TInt PutTaskL( CSConTask*& aTask );
+        /**
+         * Returns a reply to previous PutTaskL operation
+         * @return CSConStatusReply if reply exists, else return NULL
+         */
+        virtual CSConStatusReply* GetReply();
+        /**
+         * Resets the module to the initial state
+         * @return none
+         */
+        virtual void ResetPCD();
+    
+    private:        
+        /**
+         * Collects a status of a specified task / all tasks
+         * @param aTask The number of the specified task
+         * @param aAll If ETrue => receive status of all tasks
+         * @return KErrNone if no errors, else system wide error codes
+         */
+        TInt GetStatusL( TInt aTask, TBool aAll );
+        
+        /**
+         * Cancels a specified task / all tasks
+         * @param aTask The number of the specified task
+         * @param aAll If ETrue => receive status of all tasks
+         * @return KErrNone if no errors, else system wide error codes
+         */
+        TInt CancelL( TInt aTask, TBool aAll );
+        
+        /**
+         * Fills a reply with predefined supported task -information
+         * @param aTask The task
+         * @return KErrNone if no errors, else system wide error codes
+         */
+        TInt SupportedInstTaskL( CSConTask* aTask );
+        
+        /**
+         * Fills a reply with predefined supported task -information
+         * @param aTask The task
+         * @return KErrNone if no errors, else system wide error codes
+         */
+        TInt SupportedBRTaskL( CSConTask* aTask );
+        
+        /**
+         * Fills a reply with predefined Reboot task -information
+         * @param aTask The task
+         * @return KErrNone if no errors, else system wide error codes
+         */
+        TInt RebootTaskL( const CSConTask* aTask );
+        
+        /**
+         * Fills a reply with predefined GetMetadata task -information
+         * @param aTask The task
+         * @return none
+         */
+        void GetMetadataTaskL( CSConTask& aTask );
+        
+        /**
+         * Creates a reply for UpdateDeviceInfo task
+         * @param aMaxObjectSize A max object size to be used
+         * @return none
+         */
+        TInt UpdateDeviceInfoL( TInt aMaxObjectSize );
+        /**
+         * Gets the current max object size
+         * @param aClientObjectSize The object size of the client
+         * @return the max object size
+         */
+        TInt GetMaxObjectSize( TInt aClientObjectSize ) const;
+        
+        /**
+         * Stores a reply
+         * @param aReply The reply to be stored
+         * @return none
+         */
+        void StoreReply( CSConStatusReply*& aReply );
+        
+        /**
+         * Constructor
+         * @return none
+         */
+        CSConPCD();
+        /**
+         * Initializes member data
+         * @return none
+         */
+        virtual void ConstructL();
+        
+    private:
+        CSConInstallerQueue*        iInstallerQueue;
+        CSConBackupRestoreQueue*    iBackupRestoreQueue;
+        CSConStatusReply*           iLatestReply;
+        TInt                        iTaskNumber;
+        TInt                        iMaxObjectSize;
+        TSConLastConMLOperation     iLastOperation;
+        RFs                         iFs;
+    }; 
+    
+    IMPORT_C CSConPCD* CreateCSConPCDL();
+    typedef CSConPCD* (*TSConCreateCSConPCDFunc) (); 
+
+#endif // SCONPCD
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconpcdconsts.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,90 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSConPCD constants
+*
+*/
+
+
+#ifndef _SCONPCDCONSTS_H
+#define _SCONPCDCONSTS_H
+
+// Timer value used for queue polling
+const TInt KSConTimerValue( 20000 );
+// ConML Status code: Task completed
+const TInt KSConCodeTaskCompleted( 200 );
+// ConML Status code: Task created
+const TInt KSConCodeTaskCreated( 201 );
+// ConML Status code: Task prcosessing started
+const TInt KSConCodeProcessingStarted( 202 );
+// ConML Status code: Task partially completed
+const TInt KSConCodeTaskPartiallyCompleted( 206 );
+// ConML Status code: Not found
+const TInt KSConCodeNotFound( 404 );
+// ConML Status code: Conflict
+const TInt KSConCodeConflict( 409 );
+// ConML Status code: Not supported
+const TInt KSConCodeNotSupported( 501 );
+// ConML Status code: Incompatible version
+const TInt KSConCodeIncompatible( 507 );
+// ConML Status code: Cancelled
+const TInt KSConCodeCancelled( 514 );
+// ConML Status code: No memory
+const TInt KSConCodeNoMemory( 420 );
+
+// ConML Status codes in installer errorcases
+const TInt KSConCodeInstErrUserCancel = KSConCodeCancelled; // User cancelled the operation
+const TInt KSConCodeInstErrFileCorrupted = 600; // File is corrupted
+const TInt KSConCodeInstErrInsufficientMemory = KSConCodeNoMemory; // Insufficient free memory in the drive to perform the operation
+const TInt KSConCodeInstErrPackageNotSupported = KSConCodeIncompatible; // Installation of the package is not supported
+const TInt KSConCodeInstErrSecurityFailure = 601; // Package cannot be installed due to security error
+const TInt KSConCodeInstErrMissingDependency = 602; // Package cannot be installed due to missing dependency
+const TInt KSConCodeInstErrFileInUse = 603; // Mandatory file is in use and prevents the operation
+const TInt KSConCodeInstErrGeneralError = 604; // Unknown error
+const TInt KSConCodeInstErrNoRights = 605; // The package has no rights to perform the operation
+const TInt KSConCodeInstErrNetworkFailure = 606; // Indicates that network failure aborted the operation
+const TInt KSConCodeInstErrBusy = 607; // Installer is busy doing some other operation
+const TInt KSConCodeInstErrAccessDenied = 608;  // Target location of package is not accessible
+const TInt KSConCodeInstUpgradeError = 609;  // The package is an invalid upgrade
+
+struct SDeviceInfo
+	{
+	TSConMethodName method;
+	TBool support;
+	};
+
+// Supported Backup/Restore and Install methods	
+const SDeviceInfo KSupportedMethods[] =
+	{
+	{ EInstall, 			ETrue },
+	{ EUninstall, 			ETrue },
+	{ EListInstalledApps, 	ETrue },
+	{ EListDataOwners,		ETrue },
+	{ ESetBURMode, 			ETrue },
+	{ ESetInstParams,		ETrue },
+	{ EGetDataSize, 		ETrue },
+	{ ERequestData, 		ETrue },
+	{ ESupplyData, 			ETrue },
+	{ EReboot,				EFalse } // reboot not supported anymore (3.2 ->)
+	};
+	
+// Supported ConML version
+_LIT8( KCONMLVERSION, "2.0" );
+// SIS mime type for installer
+_LIT8( KSISMIMEType, "x-epoc/x-sisx-app" );
+// Java mime type for installer
+_LIT8( KMidletMIMEType, "application/java-archive" );
+
+#endif
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconpcdutility.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  SConPcdUtility header file
+*
+*/
+
+
+#ifndef __CSCONPCDUTILITY_H__
+#define __CSCONPCDUTILITY_H__
+
+
+class CSConTask;
+class CSConInstApp;
+class CSConListInstApps;
+//============================================================
+// Class TSConPcdUtility declaration
+//============================================================  
+NONSHARABLE_CLASS ( SConPcdUtility )
+    {
+    public:     // Methods
+        
+		static void ProcessListInstalledAppsL( CSConTask*& aTask );
+        
+    private:    // Methods
+    	static void AppendInstalledSisL( CSConListInstApps& aListInstApps );
+    	static void AppendInstalledJavaL( CSConListInstApps& aListInstApps );
+    	static void AppendInstalledWidgetsL( CSConListInstApps& aListInstApps );
+        
+        /**
+         * Checks if package is installed to selected drive
+         * @param aSelectedDriveList selected drives
+         * @param aInstalledDrives package drivemask
+         * @return ETrue if package is installed to one of the drives on aDriveList
+         */
+        static TBool IsInstalledToSelectedDrive( const TDriveList& aSelectedDriveList, TUint aInstalledDrives );
+        
+    };
+
+#endif      //  __CSCONPCDUTILITY_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconqueue.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,154 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Queue header file
+*
+*/
+
+
+#ifndef _SCONQUEUE_H_
+#define _SCONQUEUE_H_
+
+// INCLUDES
+
+#include <e32base.h>
+#include <e32cons.h>
+
+#include "sconconmltask.h"
+
+class CSConAppInstaller;
+class CSConBackupRestore;
+class CSConInstallerQueue;
+class CSConBackupRestoreQueue;
+
+//============================================================
+// Class CSConTaskQueue declaration
+//============================================================	
+NONSHARABLE_CLASS ( CSConTaskQueue )
+	{
+	public:
+		/**
+		 * Destructor
+		 * @return none
+		 */
+		virtual ~CSConTaskQueue();
+		/**
+		 * Returns the status of a specified task / all tasks
+		 * @param aTask The task number
+		 * @param aAllTasks If ETrue => Receive status of all tasks
+		 * @param aStatus The reply
+    	 * @return none
+		 */
+		virtual void GetQueueStatusL( TInt aTask, TBool aAllTasks, 
+									CSConStatusReply*& aStatus );
+		/**
+		 * Adds a new task to queue
+		 * @param aNewTask A new task to be added
+		 * @param aTaskId The task number
+    	 * @return KErrNone if no errors, else system wide error codes
+		 */
+		virtual TInt AddNewTask( CSConTask*& aNewTask, TInt aTaskId );
+		/**
+		 * Set the task to completed -mode
+		 * @param aTask The task number
+		 * @param aError The task error code
+    	 * @return none
+		 */
+		virtual void CompleteTask( TInt aTask, TInt aError );
+		/**
+		 * Set the task progress value
+		 * @param aTask The task number
+		 * @param aProgressValue The progress value
+    	 * @return none
+		 */
+		virtual void SetTaskProgress( TInt aTask, TInt aProgressValue );
+		/**
+		 * Receives a specified task
+		 * @param aTaskId The task number
+		 * @param aTask The address to the task
+    	 * @return KErrNone if no errors, else system wide error codes
+		 */
+		virtual TInt GetTask( TInt aTaskId, CSConTask*& aTask );
+		/**
+		 * Removes a task from the queue
+		 * @param aTask The task number
+    	 * @return none
+		 */
+		virtual void RemoveTask( TInt aTask );	
+		/**
+		 * Cancels a task
+		 * @param aTask The task number
+		 * @param aAllTasks If ETrue => cancel all tasks
+    	 * @return none
+		 */	
+		virtual void CancelTask( TInt aTask, TBool aAllTasks );
+		/**
+		 * The status of the process
+    	 * @return ETrue if process active, else EFalse
+		 */
+		virtual TBool QueueProcessActive() const;
+		/**
+		 * Changes the status of the queue process
+    	 * @return none
+		 */
+		virtual void ChangeQueueProcessStatus();
+		/**
+		 * Resets the queue
+    	 * @return none
+		 */
+		virtual void Reset();		
+		/**
+		 * Compares task numbers
+		 * @param aFirst The first task
+		 * @param aSecon The second task
+    	 * @return -1 if the first task number is smaller than the second, 
+    	 * 1 the first task number is greater than the second, 0 if task 
+    	 * numbers are equal
+		 */
+		static TInt Compare( const CSConTask& aFirst, 
+							 const CSConTask& aSecond );
+		/**
+		 * Matches the task numbers
+		 * @param aFirst The first task
+		 * @param aSecon The second task
+    	 * @return ETrue if task numbers match, else EFalse
+		 */
+		static TBool Match( const CSConTask& aFirst, 
+							const CSConTask& aSecond );
+		
+	private:
+		/**
+		 * Pure virtual function for starting the queue observation
+		 * @return none
+		 */
+		virtual void StartQueue() = 0;
+		/**
+		 * Pure virtual function for stoping the queue observation
+		 * @return none
+		 */
+		virtual void StopQueue() = 0;
+		/**
+		 * Pure virtual function for polling the queue
+		 * @return none
+		 */
+		virtual void PollQueue() = 0;
+		
+	protected:
+		RPointerArray<CSConTask>	iQueue;
+		RTimer 						iTimer;
+		TBool						iQueueProcessActive;
+	};
+	
+#endif
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconsbeclient.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:  CSConSBEClient header file
+*
+*/
+
+
+#ifndef _SCONSBECLIENT_H_
+#define _SCONSBECLIENT_H_
+
+// INCLUDES
+#include <connect/sbeclient.h>
+#include "sconconmltask.h"
+
+using namespace conn;
+
+//============================================================
+// Class CSConSBEClient declaration
+//============================================================
+NONSHARABLE_CLASS ( CSConSBEClient ) : public CActive
+    {
+    public:
+        /**
+         * Two-phase constructor
+         * @param aMaxObjectSize Max object size
+         * @param aFs aReference to RFs connection.
+         * @return CSConSBEClient instance
+         */
+        static CSConSBEClient* NewL( const TInt aMaxObjectSize, RFs& aFs );
+        /**
+         * Destructor
+         * @return none
+         */
+        ~CSConSBEClient();
+        /**
+         * Set backup/restore mode
+         * @param aStatus TRequestStatus of the request
+         * @param aTask Task parameters
+         * @return none
+         */
+        void SetBURMode( TRequestStatus& aStatus, CSConTask*& aTask );
+        /**
+         * Lists public files from data owners
+         * @param aStatus TRequestStatus of the request
+         * @param aTask Task parameters
+         * @return none
+         */
+        void ListPublicFiles( TRequestStatus& aStatus, CSConTask*& aTask );
+        /**
+         * Lists participant data owners
+         * @param aStatus TRequestStatus of the request
+         * @param aTask Task parameters
+         * @return none
+         */
+        void ListDataOwners( TRequestStatus& aStatus, CSConTask*& aTask );
+        /**
+         * Lists data sizes from data owners
+         * @param aStatus TRequestStatus of the request
+         * @param aTask Task parameters
+         * @return none
+         */
+        void GetDataSize( TRequestStatus& aStatus, CSConTask*& aTask );
+        /**
+         * Request a data from a data owner
+         * @param aStatus TRequestStatus of the request
+         * @param aTask Task parameters
+         * @return none
+         */
+        void RequestData( TRequestStatus& aStatus, CSConTask*& aTask );
+        /**
+         * Lists the status of data owners
+         * @param aStatus TRequestStatus of the request
+         * @param aTask Task parameters
+         * @return none
+         */
+        void GetDataOwnerStatus( TRequestStatus& aStatus, CSConTask*& aTask );
+        /**
+         * Supplies a data to a data owner
+         * @param aStatus TRequestStatus of the request
+         * @param aTask Task parameters
+         * @return none
+         */
+        void SupplyData( TRequestStatus& aStatus, CSConTask*& aTask );
+    
+    private:
+        /**
+         * Constructor
+         * @paran aMaxObjectSize Max object size
+         * @param aFs aReference to RFs connection.
+         * @return none
+         */
+        CSConSBEClient( const TInt aMaxObjectSize, RFs& aFs );
+        
+        /**
+         * Implementation of CActive::DoCancel()
+         * @return none
+         */
+        void DoCancel();
+        /**
+         * Implementation of CActive::RunL()
+         * @return none
+         */
+        void RunL();
+        
+        /**
+         * Executes SetBURMode task
+         * @return none
+         */
+        void ProcessSetBURModeL();
+        /**
+         * Executes ListPublicFiles task
+         * @return none
+         */
+        void ProcessListPublicFilesL();
+        /**
+         * Executes ListDataOwners task
+         * @return none
+         */
+        void ProcessListDataOwnersL();
+        /**
+         * Executes GetDataSize task
+         * @return none
+         */
+        void ProcessGetDataSizeL();
+        /**
+         * Executes RequestData task
+         * @return KErrNone if no erros. Else system wide error codes.
+         */
+        TInt ProcessRequestDataL();
+        /**
+         * Executes GetDataOwnerStatus task
+         * @return none
+         */
+        void ProcessGetDataOwnerStatusL();
+        /**
+         * Executes SupplyData task
+         * @return KErrNone if no errors. Else system wide error codes.
+         */
+        TInt ProcessSupplyDataL();
+        /**
+         * Maps TInt drive number to TDriveNumber
+         * @param aDrive Drive number as TInt
+         * @return drive number as TDriveNumber
+         */
+        TDriveNumber GetDriveNumber( const TInt& aDrive ) const;
+        /**
+         * Filters the drive list
+         * @param aDriveList Drive list to be filtered
+         * @return none
+         */     
+        void FilterDriveList( TDriveList& aDriveList ) const;
+        /**
+         * Matches the uids
+         * @param aFirst The first uid
+         * @param aSecon The second uid
+         * @return ETrue if uids match, else EFalse
+         */
+        static TBool Match( const TUid& aFirst, 
+                            const TUid& aSecond );
+        /**
+         * Handle error received from Secure Backup Engine
+         * @param aErr Error code from Secure Backup Engine
+         * @return none
+         */
+        void HandleSBEErrorL( TInt& aErr );
+        
+        /**
+         * Appends public files to CSConFile array.
+         * @param aFiles source files to append
+         * @param aSconFiles dataowner list where to add
+         * @return none
+         */
+        void AppendFilesToFilelistL( const RFileArray& aFiles, RPointerArray<CSConFile>& aSconFiles );
+        
+        /**
+         * Gets Package dataowner size
+         * @param aPackageId dataowner
+         * @param TDriveList drives to include
+         * @param TPackageDataType package data type 
+         * @return dataowner data size in specified drives
+         */
+        TUint PackageDataSizeL( TUid aPackageId, const TDriveList& aDriveList,
+                TPackageDataType aPackageDataType ) const;
+        
+        /**
+         * Gets Sid dataowner size
+         * @param aSid dataowner
+         * @param TDriveList drives to include
+         * @param TTransferDataType transfer data type 
+         * @return dataowner data size in specified drives
+         */
+        TUint SidDataSizeL( TUid aSid, const TDriveList& aDriveList,
+                TTransferDataType aTransferDataType ) const;
+        
+        /**
+         * Gets Java dataowner size
+         * @param aJavaHash Java hash value
+         * @param TDriveList drives to include
+         * @return dataowner data size in specified drives
+         */
+        TUint JavaDataSizeL( const TDesC& aJavaHash, const TDriveList& aDriveList ) const;
+        
+    private:
+        CSBEClient*                     iSBEClient;
+        TRequestStatus*                 iCallerStatus;
+        TBool                           iProcessComplete;
+        TInt                            iProcessIndex;
+        TInt                            iMaxObjectSize;
+        
+        CSConTask*                      iCurrentTask;
+        TInt                            iDataPos;
+        TBool                           iDataLeft;
+        TPtrC8                          iDataPtr;
+        TBool                           iLastChunk;
+        TBool                           iBURModeNormal;
+        TBool                           iRestoreMode;
+        RFs&                            iFs;
+        TBool                           iAllSnapshotsSuppliedCalled;
+    };
+
+#endif
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconvideoparser.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,162 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSConVideoParser header file
+*
+*/
+
+
+#ifndef SCONVIDEOPARSER_H
+#define SCONVIDEOPARSER_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <videoplayer.h>
+#include <TNEVideoClipInfo.h>
+#include "cscontimeout.h"
+
+// FORWARD DECLARATIONS
+class CVideoOperationObserver;
+class CVideoPlayerUtility;
+
+// CLASS DECLARATION
+
+//============================================================
+// Class CSConVideoParser declaration
+//============================================================  
+NONSHARABLE_CLASS( CSConVideoParser ) : public CBase,
+                                        public MVideoPlayerUtilityObserver,
+                                        public MTNEVideoClipInfoObserver,
+                                        public MTNEVideoClipThumbObserver,
+                                        private MTimeOutObserver
+{
+public: // Constructors and destructor
+
+    ~CSConVideoParser();
+    static CSConVideoParser* NewLC();
+    
+    /**
+    * Opens file
+    * @return none
+    */
+    void OpenFileL( const RFs& aFs, const TDesC& aFilename );
+    
+    /**
+    * Get video thumbnail
+    * @return video thumbnail in jpeg format,
+    *  return KNullDesC8 if thumbain could not found
+    */
+    const TDesC8& Thumbnail() const;
+    
+    /**
+    * Get video frame rate
+    * @return video frame rate frames/sec
+    */
+    TReal32 VideoFrameRateL() const;
+    
+    /**
+    * Get video frame size
+    * @return none
+    */
+    void VideoFrameSizeL(TSize& aSize) const;
+    
+    /**
+    * Get video format
+    * @return video format mimetype (example: video/mp4v-es) 
+    */
+    const TDesC8& VideoFormatMimeTypeL() const;
+    
+    /**
+    * Get videostream bitrate
+    * @return video bitrate bits/sec
+    */
+    TInt VideoBitRateL() const;
+    
+    /**
+    * Get audiostream bitrate
+    * @return audio bitrate bits/sec
+    */
+    TInt AudioBitRateL() const;
+    
+    /**
+    * Get video duration
+    * @return video duration in milliseconds.
+    */
+    TInt DurationL() const;
+    
+    /**
+    * Get videostream bitrate
+    * @return videostream mimetype
+    */
+    const TDesC& VideoMimeTypeL();
+    
+    /**
+    * Get audiostream mimetype
+    * @return audiostream mimetype
+    */
+    const TDesC& AudioMimeTypeL();
+    
+protected:  // from base classes
+    /** @see MVideoPlayerUtilityObserver::MvpuoOpenComplete */
+    void MvpuoOpenComplete(TInt aError);
+    
+    /** @see MVideoPlayerUtilityObserver::MvpuoPrepareComplete */
+    void MvpuoPrepareComplete(TInt aError);
+    
+    /** @see MVideoPlayerUtilityObserver::MvpuoFrameReady */
+    void MvpuoFrameReady(CFbsBitmap& aFrame,TInt aError);
+    
+    /** @see MVideoPlayerUtilityObserver::MvpuoPlayComplete */
+    void MvpuoPlayComplete(TInt aError);
+    
+    /** @see MVideoPlayerUtilityObserver::MvpuoEvent */
+    void MvpuoEvent(const TMMFEvent& aEvent);
+    
+    /** @see MTNEVideoClipInfoObserver::NotifyVideoClipInfoReady */
+    void NotifyVideoClipInfoReady(CTNEVideoClipInfo& aInfo, TInt aError);
+    
+    void NotifyVideoClipThumbCompleted(CTNEVideoClipInfo& aInfo, 
+            TInt aError, 
+            CFbsBitmap* aThumb);
+    
+    /** @see MTimeOutObserver::TimeOut */
+    void TimeOut();
+    
+private:
+    
+    CSConVideoParser();
+    void ConstructL();
+    
+private: // data
+    CVideoPlayerUtility* iVideoUtil;
+    CTNEVideoClipInfo*   iVideoClip;
+
+    RWsSession          iWsSession;
+    CWsScreenDevice*    iScreen;
+    TRequestStatus*     iCallerStatus;
+    CActiveSchedulerWait iWait;
+    CSconTimeOut*       iTimeOut;
+    
+    HBufC8* iThumbnail;
+    HBufC*  iVideoMimeType;
+    HBufC*  iAudioMimeType;
+    
+    TBool iVideoUtilReady;
+    TBool iVideoClipReady;
+    TInt iVideoUtilErr;
+    TInt iVideoClipErr;
+};
+
+#endif // SCONVIDEOPARSER_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/src/cscontimeout.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSconTimeOut implementation
+*
+*/
+
+
+#include "cscontimeout.h"
+
+CSconTimeOut::CSconTimeOut( MTimeOutObserver& aTimeOutObserver ) :
+    CActive(EPriorityStandard), // Standard priority
+    iTimeOutObserver(aTimeOutObserver)
+    {
+    }
+
+
+CSconTimeOut* CSconTimeOut::NewL( MTimeOutObserver& aTimeOutObserver )
+    {
+    CSconTimeOut* self = new (ELeave) CSconTimeOut( aTimeOutObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+void CSconTimeOut::ConstructL()
+    {
+    User::LeaveIfError(iTimer.CreateLocal()); // Initialize timer
+    CActiveScheduler::Add(this); // Add to scheduler
+    }
+
+CSconTimeOut::~CSconTimeOut()
+    {
+    Cancel(); // Cancel any request, if outstanding
+    iTimer.Close(); // Destroy the RTimer object
+    }
+
+void CSconTimeOut::DoCancel()
+    {
+    iTimer.Cancel();
+    }
+
+void CSconTimeOut::Start(TTimeIntervalMicroSeconds32 aDelay)
+    {
+    Cancel(); // Cancel any request, just to be sure
+    iTimer.After(iStatus, aDelay); // Set for later
+    SetActive(); // Tell scheduler a request is active
+    }
+
+void CSconTimeOut::RunL()
+    {
+    iTimeOutObserver.TimeOut();
+    }
+
+TInt CSconTimeOut::RunError(TInt aError)
+    {
+    return aError;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/src/sconbackuprestore.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,222 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSConBackupRestore implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include <pathinfo.h>
+
+#include "sconbackuprestore.h"
+#include "sconsbeclient.h"
+#include "sconbrqueue.h"
+#include "sconpcdconsts.h"
+
+#include "debug.h"
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CSConBackupRestore* CSConBackupRestore::NewL( CSConBackupRestoreQueue* aQueue,
+//                                          cost TInt& aMaxObjectSize )
+// Two-phase constructor
+// -----------------------------------------------------------------------------
+//
+CSConBackupRestore* CSConBackupRestore::NewL( CSConBackupRestoreQueue* aQueue,
+                                            const TInt aMaxObjectSize, RFs& aFs )
+    {
+    TRACE_FUNC_ENTRY;
+    CSConBackupRestore* self = new (ELeave) CSConBackupRestore( aQueue, aFs );
+    CleanupStack::PushL( self );
+    self->ConstructL( aMaxObjectSize );
+    CleanupStack::Pop( self );
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConBackupRestore::CSConBackupRestore( CSConBackupRestoreQueue* aQueue )
+// Constructor
+// -----------------------------------------------------------------------------
+//
+CSConBackupRestore::CSConBackupRestore( CSConBackupRestoreQueue* aQueue, RFs& aFs ) : 
+            CActive( EPriorityStandard ), iQueue( aQueue ), iFs( aFs )
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConBackupRestore::ConstructL( const TInt aMaxObjectSize )
+// Initializes member data
+// -----------------------------------------------------------------------------
+//
+void CSConBackupRestore::ConstructL( const TInt aMaxObjectSize )
+    {
+    iMaxObjectSize = aMaxObjectSize;
+    iSBEClient = CSConSBEClient::NewL( aMaxObjectSize, iFs );
+    CActiveScheduler::Add( iSBEClient );
+    }   
+    
+// -----------------------------------------------------------------------------
+// CSConBackupRestore::~CSConBackupRestore()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSConBackupRestore::~CSConBackupRestore()
+    {
+    TRACE_FUNC_ENTRY;
+    if( iSBEClient )
+        {
+        if( iSBEClient->IsActive() )
+            {
+            iSBEClient->Cancel();
+            }
+        
+        delete iSBEClient;
+        iSBEClient = NULL;
+        }
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConBackupRestore::StartBackupRestore( TInt aTaskId )
+// Starts backup-restore task
+// -----------------------------------------------------------------------------
+//
+void CSConBackupRestore::StartBackupRestore( TInt aTaskId )
+    {
+    iBackupRestoreActive = ETrue;
+    CSConTask* task = NULL;
+    
+    TInt ret = iQueue->GetTask( aTaskId, task );
+
+    if( aTaskId > 0 && ret != KErrNotFound )
+        {
+        iCurrentTask = aTaskId;
+        iQueue->SetTaskProgress( aTaskId, KSConCodeProcessingStarted );
+        }
+    
+    switch( task->GetServiceId() )
+        {
+        case ESetBURMode :
+            iQueue->ChangeQueueProcessStatus();
+            iSBEClient->SetBURMode( iStatus, task );
+            break;
+        case EListPublicFiles :
+            iSBEClient->ListPublicFiles( iStatus, task );
+            break;
+        case EListDataOwners :
+            iSBEClient->ListDataOwners( iStatus, task );
+            break;
+        case EGetDataSize :
+            iSBEClient->GetDataSize( iStatus, task );
+            break;
+        case ERequestData :
+            iSBEClient->RequestData( iStatus, task );
+            break;
+        case EGetDataOwnerStatus :
+            iSBEClient->GetDataOwnerStatus( iStatus, task );
+            break;
+        case ESupplyData :
+            iSBEClient->SupplyData( iStatus, task );
+            break;      
+        default :
+            break;
+        }
+    
+    SetActive();    
+    }
+
+// -----------------------------------------------------------------------------
+// CSConBackupRestore::StopBackupRestore( TInt aTaskId )
+// Stops executing backup-restore task
+// -----------------------------------------------------------------------------
+//
+void CSConBackupRestore::StopBackupRestore( TInt aTaskId )
+    {
+    TRACE_FUNC_ENTRY;
+     //if the task is active, do cancel
+     if( iCurrentTask == aTaskId )
+        {
+        iBackupRestoreActive = EFalse;
+        iSBEClient->Cancel();
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConBackupRestore::Reset()
+// Resets backup
+// -----------------------------------------------------------------------------
+//  
+void CSConBackupRestore::Reset()
+    {
+    TRACE_FUNC_ENTRY;
+    if( iSBEClient )
+        {
+        if( iSBEClient->IsActive() )
+            {
+            iSBEClient->Cancel();
+            }
+        
+        delete iSBEClient;
+        iSBEClient = NULL;
+        }
+        
+    TRAPD( err, iSBEClient = CSConSBEClient::NewL( iMaxObjectSize, iFs ) );
+    
+    if( err == KErrNone )
+        {
+        CActiveScheduler::Add( iSBEClient );
+        }
+    
+    iBackupRestoreActive = EFalse;
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConBackupRestore::BackupRestoreActive()
+// returns backup-restore activity status
+// -----------------------------------------------------------------------------
+//
+TBool CSConBackupRestore::BackupRestoreActive() const
+	{
+	return iBackupRestoreActive;
+	}
+// -----------------------------------------------------------------------------
+// CSConBackupRestore::DoCancel()
+// Implementation of CActive::DoCancel()
+// -----------------------------------------------------------------------------
+//  
+void CSConBackupRestore::DoCancel()
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConBackupRestore::RunL()
+// Implementation of CActive::RunL()
+// -----------------------------------------------------------------------------
+//          
+void CSConBackupRestore::RunL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iQueue->CompleteTask( iCurrentTask, iStatus.Int() );
+    iBackupRestoreActive = EFalse;
+    TRACE_FUNC_EXIT;
+    }
+    
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/src/sconbrqueue.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,266 @@
+/*
+* 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:  Backup-Restore Queue implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include "sconbrqueue.h"
+#include "sconbackuprestore.h"
+#include "sconpcdconsts.h"
+#include "sconinstqueue.h"
+#include "debug.h"
+
+// -----------------------------------------------------------------------------
+// CSConBackupRestoreQueue::NewL( const TInt aMaxObjectSize )
+// Two-phase constructor
+// -----------------------------------------------------------------------------
+//
+CSConBackupRestoreQueue* CSConBackupRestoreQueue::NewL( const TInt aMaxObjectSize, RFs& aFs )
+	{
+	TRACE_FUNC_ENTRY;
+	CSConBackupRestoreQueue* self = new (ELeave) CSConBackupRestoreQueue();
+	CleanupStack::PushL( self );
+	self->ConstructL( aMaxObjectSize, aFs );
+	CleanupStack::Pop( self );
+	TRACE_FUNC_EXIT;
+    return self;
+	}
+	
+// -----------------------------------------------------------------------------
+// CSConBackupRestoreQueue::CSConBackupRestoreQueue()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSConBackupRestoreQueue::CSConBackupRestoreQueue() : 
+					CActive( EPriorityStandard )
+	{
+	}
+	
+// -----------------------------------------------------------------------------
+// CSConBackupRestoreQueue::ConstructL( const TInt aMaxObjectSize )
+// Initializes member data
+// -----------------------------------------------------------------------------
+//
+void CSConBackupRestoreQueue::ConstructL( const TInt aMaxObjectSize, RFs& aFs )
+	{
+	TRACE_FUNC_ENTRY;
+	iBackupRestore = CSConBackupRestore::NewL( this, aMaxObjectSize, aFs );
+	CActiveScheduler::Add( iBackupRestore );
+	User::LeaveIfError( iTimer.CreateLocal() );
+	TRACE_FUNC_EXIT;
+	}
+	
+// -----------------------------------------------------------------------------
+// CSConBackupRestoreQueue::~CSConBackupRestoreQueue()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSConBackupRestoreQueue::~CSConBackupRestoreQueue()
+	{
+	TRACE_FUNC_ENTRY;
+	Cancel();
+	if( iBackupRestore )
+		{
+		delete iBackupRestore;
+		iBackupRestore = NULL;
+		}
+	
+	TRACE_FUNC_EXIT;
+	}
+	
+// -----------------------------------------------------------------------------
+// CSConBackupRestoreQueue::StartQueue()
+// Starts queue polling
+// -----------------------------------------------------------------------------
+//
+void CSConBackupRestoreQueue::StartQueue()	
+	{
+	TRACE_FUNC_ENTRY;
+	if( IsActive() )
+		{
+		Cancel();
+		}
+		
+	iTimer.After( iStatus, KSConTimerValue );
+	SetActive();
+	TRACE_FUNC_EXIT;
+	}
+	
+// -----------------------------------------------------------------------------
+// CSConBackupRestoreQueue::StopQueue()
+// Stops queue polling
+// -----------------------------------------------------------------------------
+//
+void CSConBackupRestoreQueue::StopQueue()	
+	{
+	TRACE_FUNC_ENTRY;
+	iTimer.Cancel();
+	TRACE_FUNC_EXIT;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConBackupRestoreQueue::AddNewTask( CSConTask*& aNewTask, TInt aTaskId )
+// Adds a new task to queue
+// -----------------------------------------------------------------------------
+//
+TInt CSConBackupRestoreQueue::AddNewTask( CSConTask*& aNewTask, TInt aTaskId )
+	{
+	LOGGER_WRITE_1( "CSConBackupRestoreQueue::AddNewTask aTaskId: %d", aTaskId );
+	TInt ret( KErrNone );
+	
+	aNewTask->iTaskId = aTaskId;
+	
+	//Set progress value "task accepted for execution"
+	aNewTask->SetProgressValue( KSConCodeTaskCreated );
+	aNewTask->SetCompleteValue( EFalse );
+	
+	//For RequestData and SupplyData
+	if( iQueue.Find( aNewTask, CSConTaskQueue::Match ) != KErrNotFound )
+		{
+		RemoveTask( aTaskId );
+		}
+	
+	if( iQueue.Count() == 0 )
+		{
+		StartQueue();
+		}
+
+	ret = iQueue.InsertInOrder( aNewTask, CSConTaskQueue::Compare );
+	LOGGER_WRITE_1( "CSConBackupRestoreQueue::AddNewTask() : returned %d", ret );
+	return ret;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConBackupRestoreQueue::CancelTask( TInt aTask, TBool aAllTasks )
+// Cancels a task
+// -----------------------------------------------------------------------------
+//
+void CSConBackupRestoreQueue::CancelTask( TInt aTask, TBool aAllTasks )
+	{
+	TRACE_FUNC_ENTRY;
+	//Stop backup/restore
+	if( aTask && !aAllTasks )
+		{
+		LOGGER_WRITE_1("CSConBackupRestoreQueue::CancelTask - Cancel task: %d", aTask);
+		iBackupRestore->StopBackupRestore( aTask );
+		}
+	
+	if( aAllTasks )
+		{
+		LOGGER_WRITE("CSConBackupRestoreQueue::CancelTask - Cancel All");
+		iBackupRestore->Cancel();
+		iBackupRestore->Reset();
+		}
+		
+	CSConTaskQueue::CancelTask( aTask, aAllTasks );
+	TRACE_FUNC_EXIT;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConBackupRestoreQueue::Reset()
+// Resets the queue
+// -----------------------------------------------------------------------------
+//
+void CSConBackupRestoreQueue::Reset()
+	{
+	TRACE_FUNC_ENTRY;
+	CSConTaskQueue::Reset();
+	iBackupRestore->Reset();
+	TRACE_FUNC_EXIT;
+	}
+	
+// -----------------------------------------------------------------------------
+// CSConBackupRestoreQueue::QueueAddress( CSConInstallerQueue*& aTaskQueue )
+// An address pointer to another queue
+// -----------------------------------------------------------------------------
+//
+void CSConBackupRestoreQueue::QueueAddress( CSConInstallerQueue*& aTaskQueue )
+	{
+	TRACE_FUNC;
+	iInstQueueAddress = aTaskQueue;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConBackupRestoreQueue::GetTaskMethod( TInt& aTaskId )
+// Returns the task type
+// -----------------------------------------------------------------------------
+//		
+TSConMethodName CSConBackupRestoreQueue::GetTaskMethodL( TInt aTaskId )
+	{
+	TRACE_FUNC_ENTRY;
+	CSConTask* task = NULL;
+	CSConTaskQueue::GetTask( aTaskId, task );
+	LOGGER_WRITE_1( "CSConBackupRestoreQueue::GetTaskMethodL( TInt aTaskId ) : returned %d",
+        task->GetServiceId() );
+	return task->GetServiceId();
+	}
+	
+// -----------------------------------------------------------------------------
+// CSConBackupRestoreQueue::PollQueue()
+// Polls queue
+// -----------------------------------------------------------------------------
+//
+void CSConBackupRestoreQueue::PollQueue()
+	{
+	// find and start next task if BR and installer is inactive
+	if( !iBackupRestore->BackupRestoreActive()
+		&& !iInstQueueAddress->QueueProcessActive() )
+		{
+		//find next task
+		for( TInt i = 0; i < iQueue.Count(); i++ )
+			{
+			TBool complete = iQueue[i]->GetCompleteValue();
+			
+			if( complete == EFalse )
+				{
+				iBackupRestore->StartBackupRestore( 
+				iQueue[i]->iTaskId );
+				i = iQueue.Count() + 1; // jump out from loop
+				}
+			}
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// Implementation of CActive::DoCancel()
+// Entry to CSConPCD
+// -----------------------------------------------------------------------------
+//
+void CSConBackupRestoreQueue::DoCancel()
+	{
+	TRACE_FUNC_ENTRY;
+	iTimer.Cancel();
+	TRACE_FUNC_EXIT;
+	}
+	
+// -----------------------------------------------------------------------------
+// Implementation of CActive::RunL()
+// Entry to CSConPCD
+// -----------------------------------------------------------------------------
+//
+void CSConBackupRestoreQueue::RunL()
+	{
+	TRACE_FUNC_ENTRY;
+	LOGGER_WRITE_1( "There are still %d tasks in this queue", iQueue.Count() );
+	if( iQueue.Count() > 0 )
+		{
+		PollQueue();
+		StartQueue();
+		}
+	TRACE_FUNC_EXIT;
+	}
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/src/sconinstaller.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,528 @@
+/*
+* 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:  CSConAppInstaller implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <pathinfo.h>
+#include <swi/sisregistryentry.h>
+#include <swi/sisregistrypackage.h>
+#include <swi/sisregistrysession.h>
+#include <SWInstDefs.h>
+#include <mmf/common/mmfcontrollerpluginresolver.h>
+#include <javaregistry.h>
+
+using namespace Java;
+
+#include "debug.h"
+#include "sconinstaller.h"
+#include "sconpcdconsts.h"
+#include "sconpcdutility.h"
+
+_LIT8( KWidgetMimeType, "application/x-nokia-widget");
+
+const TInt KSConSeConUidValue = 0x101f99f6;
+const TUid KSConSeConUid = {KSConSeConUidValue};
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CSConAppInstaller::CSConAppInstaller( CSConInstallerQueue* aQueue )
+// Constructor
+// -----------------------------------------------------------------------------
+//
+CSConAppInstaller::CSConAppInstaller( CSConInstallerQueue* aQueue, RFs& aFs ) :
+    CActive( EPriorityStandard ), iQueue( aQueue ), iFs( aFs )
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConAppInstaller::~CSConAppInstaller()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSConAppInstaller::~CSConAppInstaller()
+    {
+    TRACE_FUNC;
+    iSWInst.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CSConAppInstaller::StartInstaller( TInt& aTaskId )
+// Starts the installer task
+// -----------------------------------------------------------------------------
+//
+void CSConAppInstaller::StartInstaller( TInt& aTaskId )
+    {
+    TRACE_FUNC_ENTRY;
+    CSConTask* task = NULL;
+    TRequestStatus* status = NULL;
+    TInt err( KErrNone );
+    
+    TInt ret = iQueue->GetTask( aTaskId, task );
+    
+    if( aTaskId > 0 && ret != KErrNotFound )
+        {
+        if ( iInstallerState != EIdle || IsActive() )
+            {
+            LOGGER_WRITE("WARNING! SConAppInstaller was not on idle state!");
+            iQueue->CompleteTask( aTaskId, KErrInUse );
+            TRACE_FUNC_EXIT;
+            return;
+            }
+        
+        
+        iCurrentTask = aTaskId;
+        iQueue->SetTaskProgress( aTaskId, KSConCodeProcessingStarted );
+        
+        switch( task->GetServiceId() )
+            {
+            case EInstall :
+                iQueue->ChangeQueueProcessStatus();
+                err = iSWInst.Connect();
+                
+                if( err == KErrNone )
+                    {
+                    if ( task->iInstallParams->iMode == ESilentInstall )
+                    	{
+                    	LOGGER_WRITE( "Begin silent installation.. " );
+                    	iOptions.iUntrusted = SwiUI::EPolicyNotAllowed;
+                        iOptions.iOCSP = SwiUI::EPolicyNotAllowed;
+                        iOptionsPckg = iOptions;
+                        iInstallerState = ESilentInstalling;
+                    	iSWInst.SilentInstall( iStatus, task->iInstallParams->iPath, iOptionsPckg );
+                    	}
+                    else
+                    	{
+                    	LOGGER_WRITE( "Begin to install.. " );
+                    	iInstallerState = EInstalling;
+                        iSWInst.Install( iStatus, task->iInstallParams->iPath );
+                    	}
+                    }
+                
+                break;
+            case EUninstall :
+                iQueue->ChangeQueueProcessStatus();
+                err = iSWInst.Connect();
+                
+                if( err == KErrNone )
+                    {
+                    LOGGER_WRITE( "Begin to uninstall.. " );
+                    
+                    TRAP( err, ProcessUninstallL( *task->iUninstallParams ) );
+                    if( err != KErrNone )
+                        {
+                        LOGGER_WRITE_1( "StartInstaller ProcessUninstallL err: %d", err );
+                        status = &iStatus;
+                        User::RequestComplete( status, err );
+                        }
+                    }
+                
+                break;
+            case EListInstalledApps :
+                iQueue->ChangeQueueProcessStatus();
+                iInstallerState = EListingInstalledApps;
+                TRAP( err, ProcessListInstalledAppsL() );
+                status = &iStatus;
+                User::RequestComplete( status, err );
+                break;
+            default :
+                break;
+            }
+
+        SetActive();
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConAppInstaller::StopInstaller( TInt& aTaskId )
+// Stops the installer task
+// -----------------------------------------------------------------------------
+//
+void CSConAppInstaller::StopInstaller( TInt& aTaskId )
+    {
+    TRACE_FUNC_ENTRY;
+    //If the task is the current task, cancel it first
+    if( iCurrentTask == aTaskId )
+        {
+        Cancel();
+        iSWInst.Close();
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// TBool CSConAppInstaller::InstallerActive()
+// returns installer activity status
+// -----------------------------------------------------------------------------
+//
+TBool CSConAppInstaller::InstallerActive() const
+    {
+    if ( iInstallerState == EIdle )
+        {
+        return EFalse;
+        }
+    else
+        {
+        return ETrue;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSConAppInstaller::DoCancel()
+// Implementation of CActive::DoCancel()
+// -----------------------------------------------------------------------------
+//
+void CSConAppInstaller::DoCancel()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    switch (iInstallerState)
+        {
+        case EInstalling:
+            LOGGER_WRITE("Cancel normal install");
+            iSWInst.CancelAsyncRequest( SwiUI::ERequestInstall );
+            break;
+        case ESilentInstalling:
+            LOGGER_WRITE("Cancel silent install");
+            iSWInst.CancelAsyncRequest( SwiUI::ERequestSilentInstall );
+            break;
+        case EUninstalling:
+            LOGGER_WRITE("Cancel normal uninstall");
+            iSWInst.CancelAsyncRequest( SwiUI::ERequestUninstall );
+            break;
+        case ESilentUninstalling:
+            LOGGER_WRITE("Cancel silent uninstall");
+            iSWInst.CancelAsyncRequest( SwiUI::ERequestSilentUninstall );
+            break;
+        case ECustomUninstalling: 
+            LOGGER_WRITE("Cancel custom uninstall");
+            iSWInst.CancelAsyncRequest( SwiUI::ERequestCustomUninstall );
+            break;
+        case ESilentCustomUnistalling:
+            LOGGER_WRITE("Cancel silent custom uninstall");
+            iSWInst.CancelAsyncRequest( SwiUI::ERequestSilentCustomUninstall );
+            break;
+        default:
+            LOGGER_WRITE("WARNING! Unknown state");
+            break;
+        }
+    iInstallerState = EIdle;
+    
+    // find and complete current task
+    CSConTask* task = NULL;
+    TInt ret = iQueue->GetTask( iCurrentTask, task );
+
+    if ( iCurrentTask > 0 && ret != KErrNotFound )
+        {
+
+        switch( task->GetServiceId() )
+            {
+            case EInstall :
+                iQueue->CompleteTask( iCurrentTask, KErrCancel );
+                break;
+            case EUninstall :
+                iQueue->CompleteTask( iCurrentTask, KErrCancel );
+                break;
+            default :
+                break;
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConAppInstaller::RunL()
+// Implementation of CActive::RunL()
+// -----------------------------------------------------------------------------
+//
+void CSConAppInstaller::RunL()
+    {
+    TRACE_FUNC_ENTRY;
+    iInstallerState = EIdle;
+    iSWInst.Close();
+    iQueue->ChangeQueueProcessStatus();
+    TInt err( iStatus.Int() );
+    LOGGER_WRITE_1( "CSConAppInstaller::RunL() iStatus.Int() : returned %d", err );
+    
+    CSConTask* task = NULL;
+    TInt taskErr = iQueue->GetTask( iCurrentTask, task );
+    
+    LOGGER_WRITE_1( "CSConAppInstaller::RunL() GetTask %d", taskErr );
+        
+    if( taskErr == KErrNone )
+        {
+        if( task->GetServiceId() == EInstall && err == KErrNone )
+            {
+            LOGGER_WRITE( "CSConAppInstaller::RunL() : before DeleteFile" );
+            //delete sis after succesfull install
+            DeleteFile( task->iInstallParams->iPath );
+            }
+        }
+    
+    iQueue->CompleteTask( iCurrentTask, err );
+    TRACE_FUNC_EXIT;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSConAppInstaller::ProcessUninstallL( const CSConUninstall& aUninstallParams )
+// Execures UnInstall task
+// -----------------------------------------------------------------------------
+//
+void CSConAppInstaller::ProcessUninstallL( const CSConUninstall& aUninstallParams )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aUid: 0x%08x", aUninstallParams.iUid.iUid );
+    LOGGER_WRITE_1( "aName: %S", &aUninstallParams.iName );
+    LOGGER_WRITE_1( "aVendor: %S", &aUninstallParams.iVendor );
+    LOGGER_WRITE_1( "aType: %d", aUninstallParams.iType );
+    LOGGER_WRITE_1( "aMode: %d", aUninstallParams.iMode );
+    switch ( aUninstallParams.iType )
+	    {
+	    case ESisApplication:
+	    case ESisAugmentation:
+	    	UninstallSisL( aUninstallParams );
+	    	break;
+	    case EJavaApplication:
+	    	UninstallJavaL( aUninstallParams.iUid,
+    			aUninstallParams.iMode);
+	    	break;
+	    case EWidgetApplication:
+	    	UninstallWidget( aUninstallParams.iUid,
+	    		aUninstallParams.iMode );
+	    	break;
+	    default:
+	    	User::Leave( KErrNotSupported );
+	    }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConAppInstaller::UninstallSisL( const CSConUninstall& aUninstallParams )
+// Uninstall sis package or augmentation
+// -----------------------------------------------------------------------------
+//
+void CSConAppInstaller::UninstallSisL( const CSConUninstall& aUninstallParams )
+	{
+	TRACE_FUNC_ENTRY;
+
+	if ( aUninstallParams.iUid == KSConSeConUid )
+	    {
+	    LOGGER_WRITE("Cannot uninstall itself, leave");
+	    // cannot uninstall itself
+	    User::Leave( SwiUI::KSWInstErrFileInUse );
+	    }
+	
+	Swi::RSisRegistrySession sisRegistry;
+    User::LeaveIfError( sisRegistry.Connect() );
+    CleanupClosePushL( sisRegistry );
+    //Check if uid belongs to SIS package
+    if( !sisRegistry.IsInstalledL( aUninstallParams.iUid ) )
+        {
+        CleanupStack::PopAndDestroy( &sisRegistry );
+        User::Leave( KErrNotFound );
+        }
+    
+    Swi::RSisRegistryEntry entry;
+    CleanupClosePushL(entry);
+    User::LeaveIfError( entry.Open( sisRegistry, aUninstallParams.iUid ) );
+    if ( aUninstallParams.iType == ESisAugmentation )
+        {
+        // augmentation pkg
+        LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL ESisAugmentation" );
+        
+        TBool augmentationFound(EFalse);
+        // Get possible augmentations
+        RPointerArray<Swi::CSisRegistryPackage> augPackages;
+        CleanupResetAndDestroyPushL( augPackages );
+        entry.AugmentationsL( augPackages );
+        for ( TInt j( 0 ); j < augPackages.Count() && !augmentationFound; j++ )
+            {
+            Swi::RSisRegistryEntry augmentationEntry;
+            CleanupClosePushL( augmentationEntry );
+            augmentationEntry.OpenL( sisRegistry, *augPackages[j] );
+            
+            HBufC* augPackageName = augmentationEntry.PackageNameL();
+            CleanupStack::PushL( augPackageName );
+            HBufC* augUniqueVendorName = augmentationEntry.UniqueVendorNameL();
+            CleanupStack::PushL( augUniqueVendorName );
+            
+            if ( !augmentationEntry.IsInRomL() 
+                && augmentationEntry.IsPresentL()
+                && aUninstallParams.iName.Compare( *augPackageName ) == 0
+                && aUninstallParams.iVendor.Compare( *augUniqueVendorName ) == 0 )
+                {
+                // Correct augmentation found, uninstall it.
+                augmentationFound = ETrue;
+                TInt augmentationIndex = augPackages[j]->Index();
+                LOGGER_WRITE_1( "CSConAppInstaller::ProcessUninstallL augmentationIndex %d", augmentationIndex );
+        
+                SwiUI::TOpUninstallIndexParam params;
+                params.iUid = aUninstallParams.iUid;
+                params.iIndex = augmentationIndex;
+                SwiUI::TOpUninstallIndexParamPckg pckg( params );
+                SwiUI::TOperation operation( SwiUI::EOperationUninstallIndex );
+                if( aUninstallParams.iMode == ESilentInstall )
+                    {
+                    LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL : silent aug-sis-uninstall" );
+                    SwiUI::TUninstallOptionsPckg options;
+                    iInstallerState = ESilentCustomUnistalling;
+                    iSWInst.SilentCustomUninstall( iStatus, operation, options, pckg, KSISMIMEType );
+                    }
+                else
+                    {
+                    LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL : unsilent aug-sis-uninstall" )
+                    iInstallerState = ECustomUninstalling;
+                    iSWInst.CustomUninstall( iStatus, operation, pckg, KSISMIMEType );
+                    }
+                }
+            CleanupStack::PopAndDestroy( augUniqueVendorName );
+            CleanupStack::PopAndDestroy( augPackageName );
+            CleanupStack::PopAndDestroy( &augmentationEntry );
+            }  
+        CleanupStack::PopAndDestroy( &augPackages );
+        
+        if ( !augmentationFound )
+            {
+            LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL augmentation not found -> Leave" );
+            User::Leave( KErrNotFound );
+            }
+        }
+    else
+        {
+        // Only uninstall if not in rom and is present
+        if ( !entry.IsInRomL() && entry.IsPresentL() )
+            { 
+            if ( aUninstallParams.iMode == ESilentInstall )
+                {
+                LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL : silent sis-uninstall" );
+                SwiUI::TUninstallOptionsPckg options;
+                iInstallerState = ESilentUninstalling;
+                iSWInst.SilentUninstall( iStatus, aUninstallParams.iUid, options, KSISMIMEType );
+                }
+            else
+                {
+                LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL : unsilent sis-uninstall" )
+                iInstallerState = EUninstalling;
+                iSWInst.Uninstall( iStatus, aUninstallParams.iUid, KSISMIMEType );
+                }
+            }
+        else
+            {
+            LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL sis not present -> Leave" );
+            User::Leave( KErrNotFound );
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( &entry );
+	CleanupStack::PopAndDestroy( &sisRegistry );
+	TRACE_FUNC_EXIT;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConAppInstaller::UninstallJavaL( const TUid& aUid, const TSConInstallMode aMode )
+// Uninstall java package
+// -----------------------------------------------------------------------------
+//
+void CSConAppInstaller::UninstallJavaL( const TUid& aUid, const TSConInstallMode aMode )
+	{
+	TRACE_FUNC_ENTRY;
+	CJavaRegistry* javaRegistry = CJavaRegistry::NewLC( );
+	TBool entryExist = javaRegistry->RegistryEntryExistsL( aUid );
+	CleanupStack::PopAndDestroy( javaRegistry ); 
+	
+    if( entryExist )
+        {
+        if( aMode == ESilentInstall )
+            {
+            LOGGER_WRITE( "CSConAppInstaller::UninstallJavaL : silent midlet-uninstall" )
+            SwiUI::TUninstallOptionsPckg options;
+            iInstallerState = ESilentUninstalling;
+            iSWInst.SilentUninstall( iStatus, aUid, options, KMidletMIMEType );
+            }
+        else
+            {
+            LOGGER_WRITE( "CSConAppInstaller::UninstallJavaL : unsilent midlet-uninstall" )
+            iInstallerState = EUninstalling;
+            iSWInst.Uninstall( iStatus, aUid, KMidletMIMEType );
+            }
+        }
+    else
+        {
+        LOGGER_WRITE( "CSConAppInstaller::UninstallJavaL java entry does not exist -> Leave" )
+        User::Leave( KErrNotFound );
+        }
+    TRACE_FUNC_EXIT;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConAppInstaller::UninstallWidget( const TUid& aUid, const TSConInstallMode aMode )
+// Uninstall widget
+// -----------------------------------------------------------------------------
+//
+void CSConAppInstaller::UninstallWidget( const TUid& aUid, const TSConInstallMode aMode )
+	{
+	TRACE_FUNC_ENTRY;
+	if( aMode == ESilentInstall )
+        {
+        LOGGER_WRITE( "CSConAppInstaller::UninstallWidget : silent uninstall" )
+        SwiUI::TUninstallOptionsPckg options;
+        iInstallerState = ESilentUninstalling;
+        iSWInst.SilentUninstall( iStatus, aUid, options, KWidgetMimeType );
+        }
+    else
+        {
+        LOGGER_WRITE( "CSConAppInstaller::UninstallWidget : unsilent uninstall" )
+        iInstallerState = EUninstalling;
+        iSWInst.Uninstall( iStatus, aUid, KWidgetMimeType );
+        }
+	TRACE_FUNC_EXIT;
+	}
+
+    
+//--------------------------------------------------------------------------------
+//void CSConAppInstaller::ProcessListInstalledAppsL()
+//--------------------------------------------------------------------------------
+//
+void CSConAppInstaller::ProcessListInstalledAppsL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    CSConTask* task = NULL;
+    User::LeaveIfError( iQueue->GetTask( iCurrentTask, task ) );
+    
+    SConPcdUtility::ProcessListInstalledAppsL( task );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConAppInstaller::DeleteFile( const TDesC& aPath )
+// Deletes a file 
+// -----------------------------------------------------------------------------
+//  
+void CSConAppInstaller::DeleteFile( const TDesC& aPath )    
+    {
+    TRACE_FUNC;
+    iFs.Delete( aPath );
+    }
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/src/sconinstqueue.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,202 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Installer Queue implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include "sconinstqueue.h"
+#include "sconbrqueue.h"
+#include "sconinstaller.h"
+#include "sconpcdconsts.h"
+#include "debug.h"
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CCSConInstallerQueue* CSConInstallerQueue::NewL()
+// Two-phase constructor
+// -----------------------------------------------------------------------------
+//
+CSConInstallerQueue* CSConInstallerQueue::NewL( RFs& aFs )
+	{
+	TRACE_FUNC_ENTRY;
+	CSConInstallerQueue* self = new (ELeave) CSConInstallerQueue( aFs );
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	CleanupStack::Pop( self );
+	TRACE_FUNC_EXIT;
+    return self;
+	}
+	
+// -----------------------------------------------------------------------------
+// CSConInstallerQueue::CSConInstallerQueue()
+// Constructor
+// -----------------------------------------------------------------------------
+//
+CSConInstallerQueue::CSConInstallerQueue( RFs& aFs ) : CActive( EPriorityStandard ), iFs( aFs )
+	{
+	}
+	
+// -----------------------------------------------------------------------------
+// CSConInstallerQueue::ConstructL()
+// Initializes member data
+// -----------------------------------------------------------------------------
+//
+void CSConInstallerQueue::ConstructL()
+	{
+	TRACE_FUNC_ENTRY;
+	iInstaller = new (ELeave) CSConAppInstaller( this, iFs );
+	CActiveScheduler::Add( iInstaller );
+	User::LeaveIfError( iTimer.CreateLocal() );
+	TRACE_FUNC_EXIT;
+	}
+	
+// -----------------------------------------------------------------------------
+// CSConInstallerQueue::~CSConInstallerQueue()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSConInstallerQueue::~CSConInstallerQueue()
+	{
+	TRACE_FUNC_ENTRY;
+	Cancel();
+	if( iInstaller )
+		{
+		iInstaller->Cancel();
+		delete iInstaller;
+		iInstaller = NULL;
+		}
+	TRACE_FUNC_EXIT;
+	}
+	
+// -----------------------------------------------------------------------------
+// CSConInstallerQueue::StartQueue()
+// Starts queue polling
+// -----------------------------------------------------------------------------
+//
+void CSConInstallerQueue::StartQueue()
+	{
+	TRACE_FUNC;
+	if( IsActive() )
+		{
+		Cancel();
+		}
+		
+	iTimer.After( iStatus, KSConTimerValue );
+	SetActive();
+	}
+	
+// -----------------------------------------------------------------------------
+// CSConInstallerQueue::StartQueue()
+// Stops queue polling
+// -----------------------------------------------------------------------------
+//
+void CSConInstallerQueue::StopQueue()	
+	{
+	TRACE_FUNC_ENTRY;
+	iTimer.Cancel();
+	TRACE_FUNC_EXIT;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConInstallerQueue::CancelTask( TInt aTask, TBool aAllTasks )
+// Cancels a task
+// -----------------------------------------------------------------------------
+//
+void CSConInstallerQueue::CancelTask( TInt aTask, TBool aAllTasks )
+	{
+	TRACE_FUNC_ENTRY;
+	//Stop the installer
+	if( aTask && !aAllTasks )
+		{
+		iInstaller->StopInstaller( aTask );
+		}
+	
+	if( aAllTasks )
+		{
+		iInstaller->Cancel();
+		}
+	CSConTaskQueue::CancelTask( aTask, aAllTasks );
+	TRACE_FUNC_EXIT;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConInstallerQueue::QueueAddress( CSConBackupRestoreQueue*& aTaskQueue )
+// An address pointer to another queue
+// -----------------------------------------------------------------------------
+//
+void CSConInstallerQueue::QueueAddress( CSConBackupRestoreQueue*& aTaskQueue )
+	{
+	TRACE_FUNC;
+	iBRQueueAddress = aTaskQueue;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConInstallerQueue::PollQueue()
+// Polls queue
+// -----------------------------------------------------------------------------
+//
+void CSConInstallerQueue::PollQueue()
+	{
+	TRACE_FUNC_ENTRY;
+	// find and start next task if installer and BR is inactive
+	if( !iInstaller->InstallerActive()
+		&& !iBRQueueAddress->QueueProcessActive() )
+		{
+		//find next task
+		for( TInt i = 0; i < iQueue.Count(); i++ )
+			{
+			TBool complete = iQueue[i]->GetCompleteValue();
+			
+			if( complete == EFalse )
+				{
+				iInstaller->StartInstaller( iQueue[i]->iTaskId );
+				i = iQueue.Count() + 1; // jump out from loop
+				}
+			}
+		}
+	TRACE_FUNC_EXIT;
+	}
+
+// -----------------------------------------------------------------------------
+// CSConInstallerQueue::DoCancel()
+// Implementation of CActive::DoCancel()
+// -----------------------------------------------------------------------------
+//
+void CSConInstallerQueue::DoCancel()
+	{
+	TRACE_FUNC;
+	iTimer.Cancel();
+	}
+
+// -----------------------------------------------------------------------------
+// CSConInstallerQueue::RunL()
+// Implementation of CActive::RunL()
+// -----------------------------------------------------------------------------
+//
+void CSConInstallerQueue::RunL()
+	{
+	TRACE_FUNC_ENTRY;
+	LOGGER_WRITE_1( "There are still %d tasks in this queue", iQueue.Count() );
+	if( iQueue.Count() > 0 )
+		{
+		PollQueue();
+		StartQueue();
+		}
+	TRACE_FUNC_EXIT;
+	}
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/src/sconmetadata.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1351 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  SConMetadata implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <utf.h>  // for CnvUtfConverter
+#include <MetaDataUtility.h>
+#include <MetaDataFieldContainer.h>
+#include <MetaDataField.hrh>
+#include <caf/content.h>
+#include <caf/data.h>
+#include <ExifRead.h>
+#include <ExifTag.h>
+
+#include "sconmetadata.h"
+#include "sconconmltask.h"
+#include "sconpcdconsts.h"
+#include "sconvideoparser.h"
+#include "debug.h"
+#include "sconmetadatafielddefs.h"
+
+
+
+const TInt KBufferSize(1024);
+// Size of buffer to load from file start to get EXIF thumbnail
+const TInt KJpegLoadBufferSize = 65536; // 64k
+
+
+const TUint32 KFieldMaxLength = 0xFFFFFFFF; // four bytes reserved for "length" information
+
+// GPS related Exif IDs
+const TUint16 KGPSLatitudeRef	= 0x01;
+const TUint16 KGPSLatitude 	 	= 0x02;
+const TUint16 KGPSLongitudeRef	= 0x03;
+const TUint16 KGPSLongitude		= 0x04;
+const TUint16 KGPSAltitudeRef	= 0x05;
+const TUint16 KGPSAltitude		= 0x06;
+
+
+// extensions for exif parser
+_LIT(KJpgExt, ".jpg");
+_LIT(KJpegExt, ".jpeg");
+// extensions for audio metadata parser
+_LIT(KAacExt, ".aac");
+_LIT(KMp3Ext, ".mp3");
+_LIT(KMp4Ext, ".mp4");
+_LIT(KWmaExt, ".wma");
+// extensions for video metadata parser
+_LIT(KM4aExt, ".m4a");
+_LIT(K3gpExt, ".3gp");
+
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// SConMetadata::ProcessTask()
+// ProcessTask
+// -----------------------------------------------------------------------------
+//
+void SConMetadata::ProcessTask( CSConTask& aTask, RFs& aFs )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt err(KErrNone);
+    if ( aTask.GetServiceId() == EGetMetadata )
+        {
+        LOGGER_WRITE_1( "SConMetadata::ProcessTask() : file %S",
+            &aTask.iGetMetadataParams->iFilename );
+        
+#ifdef _DEBUG
+        LOGGER_WRITE( "start.. " );
+        TTimeIntervalMicroSeconds sec;
+        TTime start;
+        TTime end;
+        start.HomeTime();
+#endif
+        
+        TParsePtrC filename( aTask.iGetMetadataParams->iFilename );
+        
+        if ( filename.Ext().CompareF( KJpgExt ) == 0
+            || filename.Ext().CompareF( KJpegExt ) == 0 )
+            {
+            // jpg file, try to read exif
+            LOGGER_WRITE( "jpg file, Try to read exif" );
+            TRAP( err, ReadExifDataL( aTask, aFs ) );
+            }
+        else if ( filename.Ext().CompareF( KMp4Ext ) == 0
+            || filename.Ext().CompareF( K3gpExt ) == 0 )
+        	{
+        	LOGGER_WRITE( "Try to read video" );
+        	TRAP( err, GetVideoMetadataL( aTask, aFs ) );
+        	}
+        else if ( filename.Ext().CompareF( KAacExt ) == 0
+            || filename.Ext().CompareF( KM4aExt ) == 0
+            || filename.Ext().CompareF( KMp3Ext ) == 0
+            || filename.Ext().CompareF( KWmaExt ) == 0 )
+            {
+
+            // audio file, try to read audio
+            LOGGER_WRITE( "Try to read audio" );
+            TRAP( err, GetAudioMetadataL( aTask ) );
+            }
+        else
+            {
+            LOGGER_WRITE( "File extension not supported" );
+            err = KErrNotSupported;
+            }
+        
+#ifdef _DEBUG
+        end.HomeTime();
+        sec = end.MicroSecondsFrom( start );
+        
+        LOGGER_WRITE_1( "trapErr %d", err );
+        LOGGER_WRITE_1( "duration: %Ld", sec.Int64() );
+#endif
+        }
+    else
+        {
+        LOGGER_WRITE( "SConMetadata::ProcessTask() : not supported" );
+        err = KErrNotSupported;
+        }
+    
+    LOGGER_WRITE( "SConMetadata::ProcessTask() : CompleteTask" );
+    
+    TInt progress( KSConCodeTaskCompleted );        
+    TBool complete ( ETrue );
+    switch( err )
+        {
+        case KErrNone :
+            progress =  KSConCodeTaskCompleted;
+            break;
+        case KErrNotFound :
+        case KErrBadName :
+            progress =  KSConCodeNotFound;
+            break;
+        default :
+            progress = KSConCodeConflict;
+            break;
+        }
+        
+    aTask.SetCompleteValue( complete );
+    aTask.SetProgressValue( progress );
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// SConMetadata::GetAudioMetadataL()
+// Read audio metadata
+// -----------------------------------------------------------------------------
+//
+void SConMetadata::GetAudioMetadataL( CSConTask& aTask )
+    {
+    TRACE_FUNC_ENTRY;
+    CMetaDataUtility* metadataUtil = CMetaDataUtility::NewL();
+    CleanupStack::PushL( metadataUtil );
+    
+    LOGGER_WRITE( "SConMetadata::GetAudioMetadataL() : OpenFileL" );
+    metadataUtil->OpenFileL( aTask.iGetMetadataParams->iFilename );
+    
+    TInt count = metadataUtil->MetaDataCount();
+    LOGGER_WRITE_1( "SConMetadata::GetAudioMetadataL() : MetaDataCount %d", count );
+    if ( count > 0 )
+        {
+        const CMetaDataFieldContainer& fields = metadataUtil->MetaDataFieldsL();
+        count = fields.Count();
+        
+        CBufFlat* buffer = CBufFlat::NewL( KBufferSize );
+        CleanupStack::PushL( buffer );
+        buffer->Reset();
+        
+        
+        TInt offset(0);
+        // write object header
+        // Item type (1 byte) + Version (1 byte) = 2 bytes
+        buffer->ExpandL( offset, 2 );
+    
+        // header id
+        TUint8 value( KSconMetadataHeaderAudio );
+        buffer->Write( offset, TPtrC8(&value, 1) );
+        offset++;
+        
+        // header version
+        value = KSconMetadataHeaderVersion;
+        buffer->Write( offset, TPtrC8(&value, 1) );
+        offset++;
+        
+        // Add ID3 field
+        value = metadataUtil->ID3Version();
+        AppendTUintDataFieldL( buffer, value, KSconAudioID3Version );
+        
+        TMetaDataFieldId fieldId;
+        TPtrC fieldData;
+        
+        for ( TInt i = 0; i < count; i++ )
+            {
+            // get field id
+            fields.FieldIdAt( i , fieldId );
+            LOGGER_WRITE_2( "AudioFieldId( %d ): 0x%02x", i, fieldId );
+            
+            if ( fieldId == EMetaDataJpeg )
+                {
+                TPtrC8 field8( fields.Field8( fieldId ) );
+                AppendByteDataFieldL(
+                    buffer,
+                    field8,
+                    AudioFieldId( fieldId ) );
+                }
+            else
+                {
+                // get field data and add UTF-8 formatted text to buffer
+                fieldData.Set( fields.At( i , fieldId ) );
+                AppendUtf8DataFieldL( buffer, fieldData, AudioFieldId( fieldId ) );
+                }
+            
+            }
+        
+        if ( buffer->Size() > 0 )
+            {
+            LOGGER_WRITE_1( "SConMetadata::GetAudioMetadataL() : buffer->Size() %d", buffer->Size() );
+            if ( aTask.iGetMetadataParams->iData )
+                {
+                delete aTask.iGetMetadataParams->iData;
+                aTask.iGetMetadataParams->iData = NULL;
+                }
+            //Initialize the task data buffer
+            aTask.iGetMetadataParams->iData = HBufC8::NewL( buffer->Size() );
+            TPtr8 dataPtr = aTask.iGetMetadataParams->iData->Des();
+            
+            buffer->Read( 0, dataPtr, buffer->Size() );
+            LOGGER_WRITE_1( "SConMetadata::GetAudioMetadataL() dataPtr len: %d", dataPtr.Length());
+            }
+        CleanupStack::PopAndDestroy( buffer );
+        }
+    
+    CleanupStack::PopAndDestroy( metadataUtil );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// SConMetadata::GetVideoMetadataL()
+// Read video metadata
+// -----------------------------------------------------------------------------
+//
+void SConMetadata::GetVideoMetadataL( CSConTask& aTask, RFs& aFs )
+	{
+	TRACE_FUNC_ENTRY;
+	CBufFlat* buffer = CBufFlat::NewL( KBufferSize );
+    CleanupStack::PushL( buffer );
+    buffer->Reset();
+    
+    TInt offset(0);
+    // write object header
+    // Item type (1 byte) + Version (1 byte) = 2 bytes
+    buffer->ExpandL( offset, 2 );
+
+    // header id
+    TUint8 value( KSconMetadataHeaderVideo );
+    buffer->Write( offset, TPtrC8(&value, 1) );
+    offset++;
+    
+    // header version
+    value = KSconMetadataHeaderVersion;
+    buffer->Write( offset, TPtrC8(&value, 1) );
+    offset++;
+    
+	
+	CSConVideoParser* videoParser = CSConVideoParser::NewLC();
+	
+	videoParser->OpenFileL( aFs, aTask.iGetMetadataParams->iFilename );
+	LOGGER_WRITE( "Open completed" );
+	
+	const TUint KFormatMaxLength = 100;
+	TBuf<KFormatMaxLength> formatMimeType;
+    formatMimeType.Copy( videoParser->VideoFormatMimeTypeL() );
+    LOGGER_WRITE_1( "formatMimeType: %S", &formatMimeType);
+    AppendUtf8DataFieldL( buffer, formatMimeType, KSconVideoFormat );
+	
+    // we can't use TReal format, so convert frame rate to frames/ms (or 1000 frames/s)
+	TReal32 frameRate = videoParser->VideoFrameRateL();
+	const TUint KFrameRateMultiplier = 1000;
+    TInt frm = frameRate * KFrameRateMultiplier; 
+    LOGGER_WRITE_1( "frameRate: %f", frameRate );
+    LOGGER_WRITE_1( "frm: %d", frm );
+    AppendTUintDataFieldL( buffer, frm, KSconVideoFrameRate );
+    
+    TSize size;
+    videoParser->VideoFrameSizeL( size );
+    LOGGER_WRITE_2( "VideoFrameSizeL: %d, %d", size.iWidth, size.iHeight);
+    AppendTUintDataFieldL( buffer, size.iWidth, KSconVideoFrameSizeWidth );
+    AppendTUintDataFieldL( buffer, size.iHeight, KSconVideoFrameSizeHeight );
+    
+
+
+    const TUint8 KSconVideoAudioStreamMimetype	( 0x09 );
+    const TUint8 KSconVideoVideoStreamMimetype	( 0x0a );
+    
+    TInt videoBitRate =  videoParser->VideoBitRateL();
+    LOGGER_WRITE_1( "videoBitRate: %d", videoBitRate);
+    AppendTUintDataFieldL( buffer, videoBitRate, KSconVideoVideoBitRate );
+    
+	TInt audioBitRate = videoParser->AudioBitRateL();
+	LOGGER_WRITE_1( "audioBitRate: %d", audioBitRate);
+	AppendTUintDataFieldL( buffer, audioBitRate, KSconVideoAudioBitRate );
+
+	TInt durationMs = videoParser->DurationL();
+	LOGGER_WRITE_1( "duration ms: %d", durationMs);
+	AppendTUintDataFieldL( buffer, durationMs, KSconVideoDuration );
+	
+	TPtrC8 thumbnail = videoParser->Thumbnail();
+	if ( thumbnail.Length() > 0 )
+	    {
+	    AppendByteDataFieldL( buffer, thumbnail, KSconVideoThumbnail );
+	    }
+	
+	TPtrC audioMimeType = videoParser->AudioMimeTypeL();
+	if ( audioMimeType.Length() > 0 )
+		{
+		AppendUtf8DataFieldL( buffer, audioMimeType, KSconVideoAudioStreamMimetype );
+		}
+	
+	TPtrC videoMimeType = videoParser->VideoMimeTypeL();
+	if ( videoMimeType.Length() > 0 )
+		{
+		AppendUtf8DataFieldL( buffer, formatMimeType, KSconVideoVideoStreamMimetype );
+		}
+	
+	CleanupStack::PopAndDestroy( videoParser );
+	LOGGER_WRITE( "videoParser deleted" );
+	
+	
+	if ( buffer->Size() > 0 )
+        {
+        if ( aTask.iGetMetadataParams->iData )
+            {
+            delete aTask.iGetMetadataParams->iData;
+            aTask.iGetMetadataParams->iData = NULL;
+            }
+        //Initialize the task data buffer
+        aTask.iGetMetadataParams->iData = HBufC8::NewL( buffer->Size() );
+        TPtr8 dataPtr = aTask.iGetMetadataParams->iData->Des();
+        
+        buffer->Read( 0, dataPtr, buffer->Size() );
+        }
+    CleanupStack::PopAndDestroy( buffer );
+	
+	
+    TRACE_FUNC_EXIT;
+	}
+
+// -----------------------------------------------------------------------------
+// SConMetadata::AudioFieldId()
+// Map TMetaDataFieldId to KSconAudio field id
+// -----------------------------------------------------------------------------
+//
+TUint8 SConMetadata::AudioFieldId( const TMetaDataFieldId fieldId )
+    {
+    TUint8 ret(NULL);
+    switch( fieldId )
+        {
+        case EMetaDataSongTitle :
+            ret = KSconAudioTitle;
+            break;
+        case EMetaDataArtist :
+            ret = KSconAudioArtist;
+            break;
+        case EMetaDataAlbum :
+            ret = KSconAudioAlbum;
+            break;
+        case EMetaDataYear :
+            ret = KSconAudioYear;
+            break;
+        case EMetaDataComment :
+            ret = KSconAudioComment;
+            break;
+        case EMetaDataAlbumTrack :
+            ret = KSconAudioAlbumTrack;
+            break;
+        case EMetaDataGenre :
+            ret = KSconAudioGenre;
+            break;
+        case EMetaDataComposer :
+            ret = KSconAudioComposer;
+            break;
+        case EMetaDataCopyright :
+            ret = KSconAudioCopyright;
+            break;
+        case EMetaDataOriginalArtist :
+            ret = KSconAudioOriginalArtist;
+            break;
+        case EMetaDataUrl :
+            ret = KSconAudioUrl;
+            break;
+        case EMetaDataUserUrl :
+            ret = KSconAudioUserUrl;
+            break;
+        case EMetaDataJpeg :
+            ret = KSconAudioJpeg;
+            break;
+        case EMetaDataVendor :
+            ret = KSconAudioVendor;
+            break;
+        case EMetaDataRating :
+            ret = KSconAudioRating;
+            break;
+        case EMetaDataUniqueFileIdentifier :
+            ret = KSconAudioUniqueFileIdentifier;
+            break;
+        case EMetaDataDuration :
+            ret = KSconAudioDuration;
+            break;
+        case EMetaDataDate :
+            ret = KSconAudioDate;
+            break;
+        default :
+            LOGGER_WRITE( "SConMetadata::AudioFieldId : ERR field not defined!" );
+            break;
+        }
+    return ret;
+    }
+
+
+// -----------------------------------------------------------------------------
+// SConMetadata::GetExifTagL( CExifRead* aReader, const TUint8 aTagID )
+// This function is used to read exif data that might leave.
+// -----------------------------------------------------------------------------
+//
+HBufC8* SConMetadata::GetExifTagL( CExifRead* aReader, const TUint8 aTagID )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( " aTagID: 0x%02x", aTagID );
+    HBufC8* tempBuf( NULL );
+    
+    switch( aTagID )
+        {
+        case KSconExifThumbnail:
+            tempBuf = aReader->GetThumbnailL();
+            break;
+        case KSconExifDescription:
+            tempBuf = aReader->GetImageDescriptionL();
+            break;
+        case KSconExifMake:
+            tempBuf = aReader->GetMakeL();
+            break;
+        case KSconExifModel:
+            tempBuf = aReader->GetModelL();
+            break;
+        case KSconExifDateTime:
+            tempBuf = aReader->GetDateTimeL();
+            break;
+        case KSconExifSoftware:
+            tempBuf = aReader->GetSoftwareL();
+            break;
+        case KSconExifCopyright:
+            tempBuf = aReader->GetCopyrightL();
+            break;
+        case KSconExifIsoSpeedRatings:
+            tempBuf = aReader->GetIsoSpeedRatingsL();
+            if ( tempBuf )
+                {
+                TInt isoSpeed = ReadTUint32( tempBuf->Des() );
+                LOGGER_WRITE_1(" isoSpeed: %d", isoSpeed);
+                delete tempBuf;
+                
+                const TInt maxLength(5);
+                // no need to push on cleanupstack as leave cannot
+                // happen before returning tempBuf.
+                tempBuf = HBufC8::NewL(maxLength);
+                TPtr8 temp = tempBuf->Des();
+                temp.Num( isoSpeed );
+                }
+            break;
+        case KSconExifDateTimeOriginal:
+            tempBuf = aReader->GetDateTimeOriginalL();
+            break;
+        case KSconExifDateTimeDigitized:
+            tempBuf = aReader->GetDateTimeDigitizedL();
+            break;
+        case KSconExifMakerNote:
+            // makernote contents are up to the manufacturer
+            // not needed.
+            User::Leave( KErrNotSupported );
+            break;
+        case KSconExifUserComment:
+            tempBuf = aReader->GetUserCommentL();
+            break;
+        case KSconExifRelatedSoundFile:
+            tempBuf = aReader->GetRelatedSoundFileL();
+            break;
+        default:
+            User::Leave( KErrNotSupported );
+        }
+    TRACE_FUNC_EXIT;
+    return tempBuf;
+    }
+
+// -----------------------------------------------------------------------------
+// SConMetadata::ReadTUint32()
+// Convert 8-bit binary data to unsigned integer 
+// -----------------------------------------------------------------------------
+//
+TUint32 SConMetadata::ReadTUint32( const TDesC8& aData )
+    {
+    TRACE_FUNC_ENTRY;
+    TUint32 result = 0;
+    TUint8 c;
+    
+    for (TInt i=aData.Length()-1; i>=0; i--)
+        {
+        c = aData[i];
+        result = (result << 8) | c;
+        }
+    
+    LOGGER_WRITE_1( "SConMetadata::ReadTUint32() : returned %d ", result );
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// SConMetadata::GetFileDataLC()
+// Read data from file
+// -----------------------------------------------------------------------------
+//
+HBufC8* SConMetadata::GetFileDataLC( const TDesC& aFilename, RFs& aFs )
+	{
+	TRACE_FUNC_ENTRY;
+    RFile file;
+    
+    User::LeaveIfError( file.Open( aFs, aFilename,
+        EFileRead | EFileShareReadersOnly ) );
+    CleanupClosePushL( file );
+    
+    LOGGER_WRITE( "SConMetadata::GetFileDataLC() : file opened" );
+    
+    TInt dataSize(0);
+    ContentAccess::CContent* content;
+    content = ContentAccess::CContent::NewLC( file );
+    ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek );
+    data->DataSizeL(dataSize);
+    
+    LOGGER_WRITE( "SConMetadata::GetFileDataLC() : content opened" );
+    // Read 64k from the beginning of the file
+    if ( dataSize > KJpegLoadBufferSize )
+        {
+        dataSize = KJpegLoadBufferSize;
+        }
+    HBufC8* readBuffer = HBufC8::NewLC( dataSize );
+    TPtr8 readPtr = readBuffer->Des();
+    User::LeaveIfError( data->Read( readPtr, dataSize ) );
+    
+    LOGGER_WRITE( "SConMetadata::GetFileDataLC() : data readed" );
+    CleanupStack::Pop( readBuffer );
+    CleanupStack::PopAndDestroy( data );
+    CleanupStack::PopAndDestroy( content );
+    CleanupStack::PopAndDestroy( &file );
+    
+    CleanupStack::PushL( readBuffer );
+    
+    return readBuffer;
+	}
+
+// -----------------------------------------------------------------------------
+// SConMetadata::ReadExifDataL()
+// Read Exif data
+// -----------------------------------------------------------------------------
+//
+void SConMetadata::ReadExifDataL( CSConTask& aTask, RFs& aFs )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // read data from file
+    HBufC8* jpegReadBuffer = GetFileDataLC( aTask.iGetMetadataParams->iFilename, aFs );
+    
+    CExifRead* reader = CExifRead::NewL(
+        *jpegReadBuffer, CExifRead::ENoJpeg | CExifRead::ENoTagChecking );
+    
+    LOGGER_WRITE( "SConMetadata::ReadExifDataL() : reader created" );
+    CleanupStack::PopAndDestroy( jpegReadBuffer );
+    CleanupStack::PushL( reader );
+    
+
+    CBufFlat* buffer = CBufFlat::NewL( KBufferSize );
+    CleanupStack::PushL( buffer );
+    buffer->Reset();
+    
+    
+    TInt offset(0);
+    // header id (1 byte) + head.version (1 byte) = 2 bytes
+    
+    buffer->ExpandL( offset, 2 );
+    
+    // header id
+    TUint8 value( KSconMetadataHeaderExif );
+    buffer->Write( offset, TPtrC8(&value, 1) );
+    offset++;
+    
+    // header version
+    value = KSconMetadataHeaderVersion;
+    buffer->Write( offset, TPtrC8(&value, 1) );
+    offset++;
+    
+    
+    HBufC8* tempBuf(NULL);
+    
+    TInt err;
+    
+    for ( TInt tagID = KSconExifThumbnail; tagID < KSconExifGpsVersion; tagID++ )
+        {
+        // GetExifTagL function is used only to tags that leaves if data is not found
+        TRAP( err, tempBuf = GetExifTagL( reader, tagID ) );
+        if ( !err )
+            {
+            LOGGER_WRITE("write to buffer");
+            CleanupStack::PushL( tempBuf );
+            AppendByteDataFieldL( buffer, tempBuf->Des(), tagID );
+            CleanupStack::PopAndDestroy( tempBuf );
+            tempBuf = NULL;
+            }
+        else
+            {
+            LOGGER_WRITE_1( "GetExifTagL Leave code %d", err );
+            }
+        }
+    
+    
+    TUint16 value16a;
+    TUint32 value32a;
+    TUint32 value32b;
+    TInt32 val32a;
+    TInt32 val32b;
+    
+    // Orientation
+    err = reader->GetOrientation( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifOrientation );
+        }
+    
+    // XResolution
+    err = reader->GetXResolution( value32a, value32b );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value32a, KSconExifXResolution1 );
+        AppendTUintDataFieldL( buffer, value32b, KSconExifXResolution2 );
+        }
+    
+    // YResolution
+    err = reader->GetYResolution( value32a, value32b );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value32a, KSconExifYResolution1 );
+        AppendTUintDataFieldL( buffer, value32b, KSconExifYResolution2 );
+        }
+    
+    // ResolutionUnit
+    err = reader->GetResolutionUnit( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifResolutionUnit );
+        }
+    
+    // YCbCrPositioning
+    err = reader->GetYCbCrPositioning( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifYCbCrPositioning );
+        }
+    
+    // YCbCrPositioning
+    err = reader->GetYCbCrPositioning( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifYCbCrPositioning );
+        }
+    
+    
+    // ExposureTime
+    err = reader->GetExposureTime( value32a, value32b );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value32a, KSconExifExposureTime1 );
+        AppendTUintDataFieldL( buffer, value32b, KSconExifExposureTime2 );
+        }
+    
+    // ComponentsConfiguration
+    TUint8 value8a;
+    TUint8 value8b;
+    TUint8 value8c;
+    TUint8 value8d;
+    err = reader->GetComponentsConfiguration( value8a, value8b, value8c, value8d );
+    if ( !err )
+        {
+        TInt offset;
+        offset = buffer->Size();
+        
+        // field ID (1 byte) + field lenght (4 bytes) + field data (4bytes) = 9 bytes
+        buffer->ExpandL( offset, 9 );
+        
+        // field id (one byte)
+        TUint8 fieldId( KSconExifComponentsConfiguration );
+        buffer->Write( offset, TPtrC8( &fieldId, 1 ) );
+        offset++;
+        
+        // field lenght
+        WriteTUint32( buffer, offset, 4);
+        offset += 4;
+        
+        buffer->Write( offset, TPtrC8(&value8a, 1) );
+        offset++;
+        buffer->Write( offset, TPtrC8(&value8b, 1) );
+        offset++;
+        buffer->Write( offset, TPtrC8(&value8c, 1) );
+        offset++;
+        buffer->Write( offset, TPtrC8(&value8d, 1) );
+        offset++;
+        }
+    
+    // Flash
+    err = reader->GetFlash( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifFlash );
+        }
+    
+    // ColorSpace
+    err = reader->GetColorSpace( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifColorSpace );
+        }
+    
+    // PixelXDimension
+    err = reader->GetPixelXDimension( value32a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value32a, KSconExifPixelXDimension );
+        }
+    
+    // PixelYDimension
+    err = reader->GetPixelYDimension( value32a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value32a, KSconExifPixelYDimension );
+        }
+    
+    // ExposureMode
+    err = reader->GetExposureMode( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifExposureMode );
+        }
+    
+    // WhiteBalance
+    err = reader->GetWhiteBalance( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifWhiteBalance );
+        }
+    
+    // SceneCaptureType
+    err = reader->GetSceneCaptureType( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifSceneCaptureType );
+        }
+    
+    // ExposureProgram
+    err = reader->GetExposureProgram( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifExposureProgram );
+        }
+    
+    // GetApertureValue
+    err = reader->GetApertureValue( value32a, value32b );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value32a, KSconExifApertureValue1 );
+        AppendTUintDataFieldL( buffer, value32b, KSconExifApertureValue2 );
+        }
+    
+    // GetExposureBiasValue
+    err = reader->GetExposureBiasValue( val32a, val32b );
+    if ( !err )
+        {
+        value32a = val32a;
+        value32b = val32b;
+        AppendTUintDataFieldL( buffer, value32a, KSconExifExposureBiasValue1 );
+        AppendTUintDataFieldL( buffer, value32b, KSconExifExposureBiasValue2 );
+        }
+    
+    // GetMeteringMode
+    err = reader->GetMeteringMode( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifMeteringMode );
+        }
+    
+    // GetLightSource
+    err = reader->GetLightSource( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifLightSource );
+        }
+    
+    // GetFileSource
+    TInt8 val8;
+    err = reader->GetFileSource( val8 );
+    if ( !err )
+        {
+        value8a = val8;
+        AppendTUintDataFieldL( buffer, value8a, KSconExifFileSource );
+        }
+    
+    // GetDigitalZoomRatio
+    err = reader->GetDigitalZoomRatio( value32a, value32b );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value32a, KSconExifDigitalZoomRatio1 );
+        AppendTUintDataFieldL( buffer, value32b, KSconExifDigitalZoomRatio2 );
+        }
+    
+    // GetContrast
+    err = reader->GetContrast( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifContrast );
+        }
+    
+    // GetSaturation
+    err = reader->GetSaturation( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifSaturation );
+        }
+    
+    // GetSharpness
+    err = reader->GetSharpness( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifSharpness );
+        }
+    
+    // GetExifVersion
+    err = reader->GetExifVersion( value32a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value32a, KSconExifExifVersion );
+        }
+    
+    // GetFlashPixVersion
+    err = reader->GetFlashPixVersion( value32a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value32a, KSconExifFlashPixVersion );
+        }
+    
+    // GetThumbnailXResolution
+    err = reader->GetThumbnailXResolution( value32a, value32b );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value32a, KSconExifThumbXResolution1 );
+        AppendTUintDataFieldL( buffer, value32b, KSconExifThumbXResolution2 );
+        }
+    
+    // GetThumbnailYResolution
+    err = reader->GetThumbnailYResolution( value32a, value32b );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value32a, KSconExifThumbYResolution1 );
+        AppendTUintDataFieldL( buffer, value32b, KSconExifThumbYResolution2 );
+        }
+    
+    // GetThumbnailResolutionUnit
+    err = reader->GetThumbnailResolutionUnit( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifThumbResolutionUnit );
+        }
+    
+    // GetThumbnailCompression
+    err = reader->GetThumbnailCompression( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifThumbCompression );
+        }
+    
+    // GetJpegInterchangeFormat
+    err = reader->GetJpegInterchangeFormat( value32a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value32a, KSconExifThumbJpegInterchangeFormat );
+        }
+    
+    // GetJpegInterchangeFormatLength
+    err = reader->GetJpegInterchangeFormatLength( value32a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value32a, KSconExifThumbJpegInterchangeFormatLength );
+        }
+    
+    // GetShutterSpeedValue
+    err = reader->GetShutterSpeedValue( val32a, val32b );
+    if ( !err )
+        {
+        value32a = val32a;
+        value32b = val32b;
+        AppendTUintDataFieldL( buffer, value32a, KSconExifShutterSpeedValue1 );
+        AppendTUintDataFieldL( buffer, value32b, KSconExifShutterSpeedValue2 );
+        }
+    
+    // GetBrightnessValue
+    err = reader->GetBrightnessValue( val32a, val32b );
+    if ( !err )
+        {
+        value32a = val32a;
+        value32b = val32b;
+        AppendTUintDataFieldL( buffer, value32a, KSconExifBrightnessValue1 );
+        AppendTUintDataFieldL( buffer, value32b, KSconExifBrightnessValue2 );
+        }
+    
+    // GetCustomRendered
+    err = reader->GetCustomRendered( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifCustomRendered );
+        }
+    
+    // GetGainControl
+    err = reader->GetGainControl( value16a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value16a, KSconExifGainControl );
+        }
+    
+    // GetGpsVersion
+    err = reader->GetGpsVersion( value32a );
+    if ( !err )
+        {
+        AppendTUintDataFieldL( buffer, value32a, KSconExifGpsVersion );
+        }
+    
+    // Get GPS coordinates
+    const TUint KCoordinatesMaxLength = 50;
+    TBuf<KCoordinatesMaxLength> gpsInfo;
+    // Latidute
+    err = GetExifGPSLatitudeL( *reader, gpsInfo );
+    if ( !err )
+    	{
+    	AppendUtf8DataFieldL( buffer, gpsInfo ,KSconExifGPSLatitude );
+    	}
+    
+    // Longitude
+    err = GetExifGPSLongitudeL( *reader, gpsInfo );
+    if ( !err )
+    	{
+    	AppendUtf8DataFieldL( buffer, gpsInfo ,KSconExifGPSLongitude );
+    	}
+    
+    // Altidute
+    err = GetExifGPSAltiduteL( *reader, gpsInfo );
+    if ( !err )
+    	{
+    	AppendUtf8DataFieldL( buffer, gpsInfo ,KSconExifGPSAltitude );
+    	}
+    
+    LOGGER_WRITE( "SConMetadata::ReadExifDataL() : All data collected" );
+    
+    if ( buffer->Size() > 0 )
+        {
+        LOGGER_WRITE_1( "SConMetadata::ReadExifDataL() : buffer->Size() %d", buffer->Size() );
+        if ( aTask.iGetMetadataParams->iData )
+            {
+            delete aTask.iGetMetadataParams->iData;
+            aTask.iGetMetadataParams->iData = NULL;
+            }
+        //Initialize the task data buffer
+        aTask.iGetMetadataParams->iData = HBufC8::NewL( buffer->Size() );
+        TPtr8 dataPtr = aTask.iGetMetadataParams->iData->Des();
+        
+        buffer->Read( 0, dataPtr, buffer->Size() );
+        LOGGER_WRITE_1( "SConMetadata::ReadExifDataL() dataPtr len: %d", dataPtr.Length());
+        }
+    CleanupStack::PopAndDestroy( buffer );
+    
+    LOGGER_WRITE( "SConMetadata::ReadExifDataL() : task updated" );
+    
+    CleanupStack::PopAndDestroy( reader );
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// void SConMetadata::ConvertRationalTag( const CExifTag& aTag, TDes& aPosDegrees )
+// parses degrees, minutes and seconds from CExifTag and converts it to string format
+// -----------------------------------------------------------------------------
+//
+TInt SConMetadata::ConvertRationalTag( const CExifTag& aTag, TDes& aPosDegrees )
+	{
+	TRACE_FUNC_ENTRY;
+	TInt numer(0);
+	TInt denom(0);
+	TReal64 degrees(0);
+	TReal64 minutes(0);
+	TReal64 seconds(0);
+	
+	const TUint8* ratData = aTag.Data().Ptr();
+	for ( TUint y=0; y < aTag.TagInfo().iDataCount; y++ )
+		{
+		numer = 0;
+		denom = 0;
+		Mem::Copy(&numer, ratData + ((y * 2) * sizeof(numer)), sizeof(numer));
+		Mem::Copy(&denom, ratData + (((y * 2) + 1) * sizeof(numer)), sizeof(denom));	
+		
+		if ( y == 0 )// degrees
+			{
+			degrees = numer/denom;
+			}
+		else if ( y == 1 )// minutes
+			{
+			minutes = numer/denom;
+			}
+		else if ( y == 2 )// seconds
+			{
+			seconds = numer/denom;
+			}
+		}
+	_LIT(KFormat, "%.0f°%.0f'%.2f\"" );
+	aPosDegrees.Format( KFormat, degrees, minutes, seconds );
+	TRACE_FUNC_EXIT;
+	return KErrNone;
+	}
+
+// -----------------------------------------------------------------------------
+// void SConMetadata::GetExifGPSLatitudeL( CExifRead& aExifRead, TDes& aLatitude )
+// Read latidute from ExifReader 
+// -----------------------------------------------------------------------------
+//
+TInt SConMetadata::GetExifGPSLatitudeL( CExifRead& aExifRead, TDes& aLatitude )
+	{
+	TRACE_FUNC_ENTRY;
+	TInt ret(KErrNone);
+	if ( aExifRead.TagExists( KGPSLatitudeRef, EIfdGps )
+		&& aExifRead.TagExists( KGPSLatitude, EIfdGps) )
+		{
+		// get latidute
+		const CExifTag* lat = aExifRead.GetTagL( 
+				EIfdGps, 
+				KGPSLatitude );
+		User::LeaveIfError( ConvertRationalTag( *lat, aLatitude ) );
+		if ( aLatitude.Length()+2 > aLatitude.MaxLength() )
+			{
+			User::Leave( KErrTooBig );
+			}
+		
+		// south or north
+		const CExifTag* latRef = aExifRead.GetTagL( 
+				EIfdGps, 
+				KGPSLatitudeRef );
+		_LIT8( KNorthTagDef8, "N" );
+		_LIT( KNorth, "N " );
+		_LIT( KSouth, "S " );
+		if ( latRef->Data().Find( KNorthTagDef8 ) != KErrNotFound )
+			{
+			aLatitude.Insert( 0, KNorth );
+			}
+		else
+			{
+			aLatitude.Insert( 0, KSouth );
+			}
+		}
+	else
+		{
+		ret=KErrNotFound;
+		}
+	TRACE_FUNC_EXIT;
+	return ret;
+	}
+
+// -----------------------------------------------------------------------------
+// void SConMetadata::GetExifGPSLongitudeL( CExifRead& aExifRead, TDes& aLongitude )
+// Read longitude from ExifReader 
+// -----------------------------------------------------------------------------
+//
+TInt SConMetadata::GetExifGPSLongitudeL( CExifRead& aExifRead, TDes& aLongitude )
+	{
+	TRACE_FUNC_ENTRY;
+	TInt ret(KErrNone);
+	if ( aExifRead.TagExists( KGPSLongitudeRef, EIfdGps )
+		&& aExifRead.TagExists( KGPSLongitude, EIfdGps) )
+		{
+		// get longitude
+		const CExifTag* lon = aExifRead.GetTagL( 
+				EIfdGps, 
+				KGPSLongitude );
+		User::LeaveIfError( ConvertRationalTag( *lon, aLongitude ) );
+		if ( aLongitude.Length()+2 > aLongitude.MaxLength() )
+			{
+			User::Leave( KErrTooBig );
+			}
+		
+		// east or west
+		const CExifTag* lonref = aExifRead.GetTagL( 
+				EIfdGps, 
+				KGPSLongitudeRef );
+		_LIT8( KEastTagDef8, "E" );
+		_LIT( KEast, "E " );
+		_LIT( KWest, "W " );
+		if ( lonref->Data().Find( KEastTagDef8 ) != KErrNotFound )
+			{
+			aLongitude.Insert( 0, KEast );
+			}
+		else
+			{
+			aLongitude.Insert( 0, KWest );
+			}
+		}
+	else
+		{
+		ret = KErrNotFound;
+		}
+	TRACE_FUNC_EXIT;
+	return ret;
+	}
+
+// -----------------------------------------------------------------------------
+// void SConMetadata::GetExifGPSAltiduteL( CExifRead& aExifRead, TDes& aAltidute )
+// Read altidute from ExifReader 
+// -----------------------------------------------------------------------------
+//
+TInt SConMetadata::GetExifGPSAltiduteL( CExifRead& aExifRead, TDes& aAltidute )
+	{
+	TRACE_FUNC_ENTRY;
+	
+	TInt ret(KErrNone);
+	if ( aExifRead.TagExists( KGPSAltitudeRef, EIfdGps )
+		&& aExifRead.TagExists( KGPSAltitude, EIfdGps) )
+		{
+		if ( aAltidute.MaxLength() < 5 )
+			{
+			User::Leave( KErrTooBig );
+			}
+		
+		// get altidute
+		const CExifTag* alt = aExifRead.GetTagL( 
+				EIfdGps, 
+				KGPSAltitude );
+		const TUint8* ratData = alt->Data().Ptr();
+		
+		TInt numer;
+		TInt denom;
+		Mem::Copy(&numer, ratData , sizeof(numer));
+		Mem::Copy(&denom, ratData + (sizeof(numer)), sizeof(denom));
+		
+		TReal32 tmp = numer / denom;
+		
+		// sea level
+		const CExifTag* altref = aExifRead.GetTagL( 
+				EIfdGps, 
+				KGPSAltitudeRef );
+		_LIT8( KAltSealevelDef8, "1" );
+		if ( altref->Data().Find( KAltSealevelDef8 ) != KErrNotFound )
+			{
+			// seaLevelReference -> negative value
+			tmp *= -1;
+			}
+		TRealFormat format;
+		format.iType = KRealFormatFixed;
+		format.iPlaces=1;
+		User::LeaveIfError( aAltidute.Num( tmp, format ) );
+		}
+	else
+		{
+		ret = KErrNotFound;
+		}
+	TRACE_FUNC_EXIT;
+	return ret;
+	}
+
+// -----------------------------------------------------------------------------
+// void SConMetadata::AppendUtf8DataFieldL( CBufFlat* aBuffer,
+//     const TPtrC aAppendData, const TUint8 aFieldId )
+// Write 8bit field id value, data length (32bit) and UTF8 data to buffer 
+// -----------------------------------------------------------------------------
+//
+void SConMetadata::AppendUtf8DataFieldL( CBufFlat* aBuffer,
+    const TPtrC aAppendData, const TUint8 aFieldId )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aFieldId: 0x%02x", aFieldId);
+    HBufC8* tempBuf = HBufC8::NewLC( aAppendData.Size() );
+    TPtr8 temp = tempBuf->Des();
+    
+    CnvUtfConverter::ConvertFromUnicodeToUtf8( temp, aAppendData );
+    LOGGER_WRITE_1( "lenght: %d", temp.Length() );
+    
+    if ( temp.Length() > KFieldMaxLength )
+        {
+        LOGGER_WRITE("Data length is too big, field skipped");
+        CleanupStack::PopAndDestroy( tempBuf );
+        return;
+        }
+    
+    TInt offset;
+    offset = aBuffer->Size();
+    // field ID (1 byte) + field lenght (4 bytes) + field data
+    aBuffer->ExpandL( offset, temp.Length() + 5 );
+    
+    // field id (one byte)
+    aBuffer->Write( offset, TPtrC8(&aFieldId, 1) );
+    offset++;
+    
+    WriteTUint32( aBuffer, offset, temp.Length());
+    offset += 4;
+    
+    // field data
+    aBuffer->Write( offset, temp, temp.Length() );
+    offset += temp.Length();
+    
+    CleanupStack::PopAndDestroy( tempBuf );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// void SConMetadata::AppendByteDataFieldL( CBufFlat* aBuffer,
+//     const TPtrC8 aAppendData, const TUint8 aFieldId )
+// Write 8bit field id value, data length (32bit) and n*8bit data to buffer 
+// -----------------------------------------------------------------------------
+//
+void SConMetadata::AppendByteDataFieldL( CBufFlat* aBuffer,
+    const TPtrC8 aAppendData, const TUint8 aFieldId )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aFieldId: 0x%02x", aFieldId);
+    LOGGER_WRITE_1( "lenght: %d", aAppendData.Length() );
+    if ( aAppendData.Length() > KFieldMaxLength )
+        {
+        LOGGER_WRITE("Data length is too big, field skipped");
+        return;
+        }
+    TInt offset;
+    offset = aBuffer->Size();
+    
+    // field id (1) + field len (4) + datalen = 5 + datalen
+    aBuffer->ExpandL( offset, aAppendData.Length() + 5 );
+    
+    // field id (one byte)
+    aBuffer->Write( offset, TPtrC8(&aFieldId, 1) );
+    offset++;
+    
+    // field data length (32bit unsigned integer, two byte)
+    WriteTUint32( aBuffer, offset, aAppendData.Length() );
+    offset += 4;
+    
+    // field data
+    aBuffer->Write( offset, aAppendData );
+    offset += aAppendData.Length();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// void SConMetadata::AppendTUintDataFieldL( CBufFlat* aBuffer,
+//     const TUint32 aValue, const TUint8 aFieldId )
+// Write 8bit field id value, data length (16bit) and n*8bit data to buffer 
+// -----------------------------------------------------------------------------
+//
+void SConMetadata::AppendTUintDataFieldL( CBufFlat* aBuffer,
+    TUint32 aValue, const TUint8 aFieldId )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aFieldId: 0x%02x", aFieldId);
+    LOGGER_WRITE_1( "aValue dec: %u", aValue);
+    TInt offset;
+    offset = aBuffer->Size();
+    TInt dataLen(1);
+    TUint8 temp[4];
+    TInt i(0);
+    
+    temp[i] = aValue & 0xFF;
+    
+    aValue >>= 8;
+    while( aValue > 0 )
+        {
+        i++;
+        temp[i] = aValue & 0xFF;
+        aValue >>= 8;
+        dataLen++;
+        }
+    // field id (1) + field len (4) + datalen = 5 + datalen
+    aBuffer->ExpandL( offset, 5 + dataLen );
+    
+    // field id (one byte)
+    aBuffer->Write( offset, TPtrC8(&aFieldId, 1) );
+    offset++;
+    
+    // field data length (32bit unsigned integer, two byte)
+    WriteTUint32( aBuffer, offset, dataLen );
+    offset += 4;
+    
+    // field data
+    for( TInt i = dataLen-1; i>=0; i-- )
+        {
+        aBuffer->Write( offset, TPtrC8(&temp[i], 1) );
+        offset++;
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// void SConMetadata::WriteTUint32( CBufFlat* aBuffer, TInt offset, TUint32 aValue )
+// Write 32bit unsigned integer value to buffer.
+// -----------------------------------------------------------------------------
+//
+void SConMetadata::WriteTUint32( CBufFlat* aBuffer, TInt offset, TUint32 aValue )
+    {
+    TUint8 temp[4];
+    TInt i(0);
+    
+    temp[i] = aValue & 0xFF;
+    
+    aValue >>= 8;
+    for ( TInt i=1; i<4; i++ )
+        {
+        temp[i] = aValue & 0xFF;
+        aValue >>= 8;
+        }
+    
+    // high to low
+    for ( TInt i=3; i>=0; i-- )
+        {
+        aBuffer->Write( offset, TPtrC8(&temp[i], 1) );
+        offset++;
+        }
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/src/sconpcd.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,586 @@
+/*
+* 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:  CSConPCD implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "sconpcd.h"
+#include "sconpcdconsts.h"
+#include "sconinstqueue.h"
+#include "sconbrqueue.h"
+#include "sconmetadata.h"
+#include "debug.h"
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CreateCSConPCDL()
+// Entry to CSConPCD
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSConPCD* CreateCSConPCDL()
+    {
+    TRACE_FUNC;
+    return CSConPCD::NewL();
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCD::NewL()
+// Two-phase constructor
+// -----------------------------------------------------------------------------
+//
+CSConPCD* CSConPCD::NewL()
+    {
+    TRACE_FUNC_ENTRY;
+    CSConPCD* self = new (ELeave) CSConPCD();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCD::CSConPCD()
+// Constructor
+// -----------------------------------------------------------------------------
+//
+CSConPCD::CSConPCD() : iInstallerQueue( NULL ), iBackupRestoreQueue( NULL ), 
+    iLatestReply(NULL), iTaskNumber( 0 ), iMaxObjectSize( 65536 ), 
+    iLastOperation( ENoTask )
+    {
+    TRACE_FUNC;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCD::ConstructL()
+// Initializes member data
+// -----------------------------------------------------------------------------
+//
+void CSConPCD::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    User::LeaveIfError( iFs.Connect() );
+    iInstallerQueue = CSConInstallerQueue::NewL( iFs );
+    iBackupRestoreQueue = CSConBackupRestoreQueue::NewL( iMaxObjectSize, iFs );
+    iInstallerQueue->QueueAddress( iBackupRestoreQueue );
+    iBackupRestoreQueue->QueueAddress( iInstallerQueue );
+    
+    if ( !CActiveScheduler::Current() )
+        {
+        CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
+        CActiveScheduler::Install( scheduler );
+        }
+    CActiveScheduler::Add( iInstallerQueue );
+    CActiveScheduler::Add( iBackupRestoreQueue );
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCD::~CSConPCD()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSConPCD::~CSConPCD()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iInstallerQueue )
+        {
+        iInstallerQueue->Cancel();
+        delete iInstallerQueue;
+        iInstallerQueue = NULL;
+        }
+        
+    if ( iBackupRestoreQueue )
+        {
+        iBackupRestoreQueue->Cancel();
+        delete iBackupRestoreQueue;
+        iBackupRestoreQueue = NULL;
+        }
+    
+    if ( iLatestReply )
+        {
+        delete iLatestReply;
+        iLatestReply = NULL;
+        }
+    
+    iFs.Close();
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCD::PutTaskL( CSConTask* aTask )
+// Receives a new task
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCD::PutTaskL( CSConTask*& aTask )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    TInt maxObjectSize( 0 );
+    
+    if ( iLastOperation == EPutTask )
+        {
+        LOGGER_WRITE( "CSConPCD::PutTaskL() : Two Puts in a row -> Reset()" );
+        ResetPCD();
+        }
+    else
+        {
+        LOGGER_WRITE( "CSConPCD::PutTaskL() : Protocol procedure ok" );
+        iLastOperation = EPutTask;
+        }
+    
+    switch( aTask->GetServiceId() )
+        {
+        case ECancel :
+            ret = CancelL( aTask->iCancelTaskId, aTask->iCancelTaskAll );
+            delete aTask;
+            break;
+        case EGetDataOwnerStatus :
+            ret = SupportedBRTaskL( aTask );
+            break;
+        case EGetDataSize :
+            ret = SupportedBRTaskL( aTask );
+            break;
+        case EGetStatus :
+            ret = GetStatusL( aTask->iGetStatusParams->iTaskId, 
+            		aTask->iGetStatusParams->iAll );
+            delete aTask;
+            break;
+        case EInstall :
+            ret = SupportedInstTaskL( aTask );
+            break;
+        case EListDataOwners :
+            ret = SupportedBRTaskL( aTask );
+            break;
+        case EListInstalledApps :
+            ret = SupportedInstTaskL( aTask );
+            break;
+        case EListPublicFiles :
+            ret = SupportedBRTaskL( aTask );          
+            break;
+        case ERequestData :
+            ret = SupportedBRTaskL( aTask );
+            break;
+        case ESetBURMode :
+            ret = SupportedBRTaskL( aTask );
+            break;
+        case ESetInstParams :
+            ret = SupportedInstTaskL( aTask );
+            break;
+        case ESupplyData :
+            ret = SupportedBRTaskL( aTask );
+            break;
+        case EUninstall :
+            ret = SupportedInstTaskL( aTask );
+            break;
+        case EUpdateDeviceInfo :
+            maxObjectSize = aTask->iDevInfoParams->iMaxObjectSize;
+            ret = UpdateDeviceInfoL( maxObjectSize );
+            iTaskNumber++;
+            delete aTask;
+            break;
+        case EReboot :
+            RebootTaskL( aTask );
+            delete aTask;
+            break;
+        case EGetMetadata :
+        	ret = KErrNone;
+            GetMetadataTaskL( *aTask );
+            delete aTask;
+            break;
+        default :
+            break;
+        }
+    LOGGER_WRITE_1( "CSConPCD::PutTaskL() : returned %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCD::GetReply()
+// Returns a reply to previous PutTaskL operation
+// -----------------------------------------------------------------------------
+//
+CSConStatusReply* CSConPCD::GetReply()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    if ( iLastOperation == EGetReply )
+        {
+        LOGGER_WRITE( "CSConPCD::GetReply() : Two Gets in a row -> Reset()" );
+        ResetPCD();
+        }
+    else
+        {
+        LOGGER_WRITE( "CSConPCD::GetReply() : Protocol procedure ok" );
+        iLastOperation = EGetReply;
+        }
+    CSConStatusReply* reply = iLatestReply;
+    iLatestReply = NULL;
+    TRACE_FUNC_EXIT;
+    return reply;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCD::ResetPCD()
+// Resets the module to the initial state
+// -----------------------------------------------------------------------------
+//
+void CSConPCD::ResetPCD()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iInstallerQueue )
+        {
+        LOGGER_WRITE( "CSConPCD::ResetPCD() : Reseting installer queue" );
+        iInstallerQueue->Reset();
+        }
+        
+    if ( iBackupRestoreQueue )
+        {
+        LOGGER_WRITE( "CSConPCD::ResetPCD() : Reseting backup queue" );
+        iBackupRestoreQueue->Reset();
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCD::SupportedInstTaskL( CSConTask* aTask )
+// Fills a reply with predefined supported task -information
+// -----------------------------------------------------------------------------
+//  
+TInt CSConPCD::SupportedInstTaskL( CSConTask* aTask )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    iTaskNumber++;
+    ret = iInstallerQueue->AddNewTask( aTask, iTaskNumber );
+    
+    //Get status for this task
+    TBool all( EFalse );
+    CSConStatusReply* reply = new (ELeave) CSConStatusReply();
+    CleanupStack::PushL( reply );
+    iInstallerQueue->GetQueueStatusL( iTaskNumber, all, reply );
+    CleanupStack::Pop( reply );
+    
+    StoreReply( reply );    
+        
+    LOGGER_WRITE_1( "CSConPCD::SupportedInstTaskL() : returned %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCD::SupportedBRTask( CSConTask* aTask )
+// Fills a reply with predefined supported task -information
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCD::SupportedBRTaskL( CSConTask* aTask )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    
+    TInt taskId;
+    
+    taskId = ++iTaskNumber;
+        
+    ret = iBackupRestoreQueue->AddNewTask( aTask, taskId );
+    LOGGER_WRITE_1( "iBackupRestoreQueue->AddNewTask : ret %d", ret );
+    //Get status for this task
+    TBool all( EFalse );
+    CSConStatusReply* reply = new (ELeave) CSConStatusReply();
+    CleanupStack::PushL( reply );
+    iBackupRestoreQueue->GetQueueStatusL( iTaskNumber, all, reply );
+    CleanupStack::Pop( reply );
+    
+    StoreReply( reply );    
+    
+    TRACE_FUNC_EXIT;
+    return ret;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSConPCD::RebootTask( const CSConTask* aTask )
+// Fills a reply with predefined unsupported task -information
+// -----------------------------------------------------------------------------
+//  
+TInt CSConPCD::RebootTaskL( const CSConTask* aTask )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNotSupported );
+    iTaskNumber++;
+    TSConMethodName method( aTask->GetServiceId() );
+    CSConStatusReply* reply = new (ELeave) CSConStatusReply();
+    CleanupStack::PushL( reply );
+    CSConTaskReply* taskReply = new (ELeave) CSConTaskReply();
+    CleanupStack::PushL( taskReply );
+    
+    TBool complete( ETrue );
+    taskReply->InitializeL( method, KSConCodeNotSupported, complete );
+    taskReply->iTaskId = iTaskNumber;
+    
+    reply->iNoTasks = EFalse;
+    User::LeaveIfError( reply->iTasks.Append( taskReply ) );
+    CleanupStack::Pop( taskReply );
+    
+    StoreReply( reply );
+    CleanupStack::Pop( reply );
+        
+    LOGGER_WRITE_1( "CSConPCD::RebootTask() : returned %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCD::GetMetadataTask( const CSConTask* aTask )
+// Fills a reply with predefined GetMetadata task -information
+// -----------------------------------------------------------------------------
+//
+void CSConPCD::GetMetadataTaskL( CSConTask& aTask )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    aTask.iTaskId = ++iTaskNumber;
+    
+    //Set progress value "task accepted for execution"
+    aTask.SetProgressValue( KSConCodeTaskCreated );
+    aTask.SetCompleteValue( EFalse );
+    
+    SConMetadata::ProcessTask( aTask, iFs );
+    
+    //Get status for this task
+ 
+    CSConStatusReply* reply = new (ELeave) CSConStatusReply();
+    CleanupStack::PushL( reply );
+    CSConTaskReply* taskReply = new (ELeave) CSConTaskReply();
+    CleanupStack::PushL( taskReply );
+    taskReply->InitializeL( aTask );
+    User::LeaveIfError( reply->iTasks.Append( taskReply ) );
+    CleanupStack::Pop( taskReply );
+    
+    if ( !aTask.GetComplete() )
+        {
+        // clean all unneccessary data from the reply packet
+        taskReply->CleanTaskData();
+        }
+    
+    
+    StoreReply( reply );
+    CleanupStack::Pop( reply ); 
+ 
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCD::GetStatus( TInt aTask, TBool aAll )
+// Collects a status of a specified task / all tasks
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCD::GetStatusL( TInt aTask, TBool aAll )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    
+    // create mergeReply object. Store installer and br replys here.
+    CSConStatusReply* mergeReply = new (ELeave) CSConStatusReply();
+    CleanupStack::PushL( mergeReply );
+            
+    
+    CSConStatusReply* brReply = new (ELeave) CSConStatusReply();
+    CleanupStack::PushL( brReply );
+    iBackupRestoreQueue->GetQueueStatusL( aTask, aAll, brReply );
+    
+    
+    // Create installerReply and populate it
+    CSConStatusReply* installerReply = new (ELeave) CSConStatusReply();
+    CleanupStack::PushL( installerReply );
+    iInstallerQueue->GetQueueStatusL( aTask, aAll, installerReply );
+    
+    if ( !installerReply->iNoTasks || !brReply->iNoTasks )
+        {
+        mergeReply->iNoTasks = EFalse;
+        }
+    else
+        {
+        mergeReply->iNoTasks = ETrue;
+        }
+        
+    for ( TInt i = 0; i < installerReply->iTasks.Count(); i++ )
+        {
+        mergeReply->iTasks.Append( installerReply->iTasks[i]->CopyAndFreeL() );
+        }
+    
+    // installer replys are copied to mergereply, delete installerReply
+    CleanupStack::PopAndDestroy( installerReply );
+    
+    // do same for br reply
+    for ( TInt j = 0; j < brReply->iTasks.Count(); j++ )
+        {
+        mergeReply->iTasks.Append( brReply->iTasks[j]->CopyAndFreeL() );
+        }
+    
+    CleanupStack::PopAndDestroy( brReply );
+    
+    CleanupStack::Pop( mergeReply );
+    // store reply
+    StoreReply( mergeReply );
+    
+    LOGGER_WRITE_1( "CSConPCD::GetStatus() : returned %d", ret );
+    return ret;
+    }
+        
+// -----------------------------------------------------------------------------
+// CSConPCD::Cancel( TInt aTask, TBool aAll )
+// Cancels a specified task / all tasks
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCD::CancelL( TInt aTask, TBool aAll )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    
+    CSConStatusReply* reply = new (ELeave) CSConStatusReply();
+    iInstallerQueue->CancelTask( aTask, aAll );
+    iBackupRestoreQueue->CancelTask( aTask, aAll );
+    
+    reply->iNoTasks = ETrue;
+    
+    StoreReply( reply );
+    
+    LOGGER_WRITE_1( "CSConPCD::CancelL() : returned %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCD::StoreReply( CSConStatusReply*& aReply )
+// Stores a reply
+// -----------------------------------------------------------------------------
+//
+void CSConPCD::StoreReply( CSConStatusReply*& aReply )  
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iLatestReply )
+        {
+        delete iLatestReply;
+        iLatestReply = NULL;
+        }
+        
+    iLatestReply = aReply;
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCD::UpdateDeviceInfo( TInt aMaxObjectSize )
+// Creates a reply for UpdateDeviceInfo task
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCD::UpdateDeviceInfoL( TInt aMaxObjectSize )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    TSConMethodName method( EUpdateDeviceInfo );
+    
+    CSConStatusReply* reply = new (ELeave) CSConStatusReply();
+    CleanupStack::PushL( reply );
+    CSConTaskReply* taskReply = new (ELeave) CSConTaskReply();
+    CleanupStack::PushL( taskReply );
+    
+    
+    TBool complete( ETrue );
+    TInt progress( KSConCodeTaskCompleted );
+    
+    taskReply->InitializeL( method, progress, complete );
+    taskReply->iTaskId = iTaskNumber;
+        
+    TInt arrayLength = sizeof KSupportedMethods / sizeof KSupportedMethods[0];
+    
+    for ( TInt i = 0; i < arrayLength; i++ )
+        {
+        switch( KSupportedMethods[i].method )
+            {
+            case EGetDataSize :
+                taskReply->iDevInfoParams->iGetSizeSupp = 
+                KSupportedMethods[i].support;
+                break;
+            case EInstall :
+                taskReply->iDevInfoParams->iInstallSupp = 
+                KSupportedMethods[i].support;
+                break;
+            case EListDataOwners :
+                taskReply->iDevInfoParams->iDataOwnersSupp = 
+                KSupportedMethods[i].support;
+                break;
+            case EListInstalledApps :
+                taskReply->iDevInfoParams->iInstAppsSupp = 
+                KSupportedMethods[i].support;
+                break;
+            case ERequestData :
+                taskReply->iDevInfoParams->iReqDataSupp = 
+                KSupportedMethods[i].support;
+                break;
+            case ESetBURMode :
+                taskReply->iDevInfoParams->iSetBURModeSupp = 
+                KSupportedMethods[i].support;
+                break;
+            case ESetInstParams :
+                taskReply->iDevInfoParams->iInstParamsSupp = 
+                KSupportedMethods[i].support;
+                break;
+            case ESupplyData :
+                taskReply->iDevInfoParams->iSupplyDataSupp = 
+                KSupportedMethods[i].support;
+                break;
+            case EUninstall :
+                taskReply->iDevInfoParams->iUninstallSupp = 
+                KSupportedMethods[i].support;
+                break;
+            case EReboot :
+                taskReply->iDevInfoParams->iRebootSupp = 
+                KSupportedMethods[i].support;
+                break;
+            default :
+                break;
+            }
+        }
+    
+    taskReply->iDevInfoParams->iVersion.Copy( KCONMLVERSION );
+    taskReply->iDevInfoParams->iMaxObjectSize = 
+        GetMaxObjectSize( aMaxObjectSize );
+    
+    reply->iNoTasks = EFalse;
+
+    User::LeaveIfError( reply->iTasks.Append( taskReply ) );
+    StoreReply( reply );
+    
+    CleanupStack::Pop( taskReply );
+    CleanupStack::Pop( reply );
+    LOGGER_WRITE_1( "CSConPCD::UpdateDeviceInfo() : returned %d", ret );
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConPCD::GetMaxObjectSize( TInt /*aClientObjectSize*/ ) const
+// Gets the current max object size
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCD::GetMaxObjectSize( TInt /*aClientObjectSize*/ ) const
+    {
+    LOGGER_WRITE_1( "CSConPCD::GetMaxObjectSize() : returned %d", iMaxObjectSize );
+    return iMaxObjectSize;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/src/sconpcdutility.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,411 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  SConPcdUtility implementation
+*
+*/
+
+
+//  CLASS HEADER
+#include <swi/sisregistryentry.h>
+#include <swi/sisregistrysession.h>
+#include <swi/sisregistrypackage.h>
+#include <stringresourcereader.h>
+#include <WidgetRegistryClient.h>
+#include <javaregistryincludes.h>
+#include <appversion.h>
+#include <mmf/common/mmfcontrollerpluginresolver.h>
+#include <sconftp.rsg>              // Resource to be read header 
+
+using namespace Java;
+
+#include "debug.h"
+#include "sconpcdutility.h"
+#include "sconconmltask.h"
+
+// localized "unknown vendor".
+_LIT( KSConResourceName, "z:\\Resource\\sconftp.rsc" );
+
+
+
+//  METHODS
+//----------------------------------------------------------------------------
+// void SConPcdUtility::ProcessListInstalledAppsL( CSConTask*& aTask )
+//----------------------------------------------------------------------------
+//
+void SConPcdUtility::ProcessListInstalledAppsL( CSConTask*& aTask )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    LOGGER_WRITE_1("iAllApps: %d",(TInt)aTask->iListAppsParams->iAllApps);
+    LOGGER_WRITE8_1("driveList: %S", &aTask->iListAppsParams->iDriveList);
+    
+    AppendInstalledSisL( *aTask->iListAppsParams );
+    AppendInstalledJavaL( *aTask->iListAppsParams );
+    AppendInstalledWidgetsL( *aTask->iListAppsParams );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+//----------------------------------------------------------------------------
+// void SConPcdUtility::AppendInstalledSisL( RPointerArray<CSConInstApp> &aApps )
+// Appends installed sis packages and augmentations to aApps array.
+//----------------------------------------------------------------------------
+//
+void SConPcdUtility::AppendInstalledSisL( CSConListInstApps& aListInstApps )
+    {
+    TRACE_FUNC_ENTRY;
+    // Get installed applications from sis registry
+    Swi::RSisRegistrySession sisRegistry;
+    CleanupClosePushL( sisRegistry );
+    User::LeaveIfError( sisRegistry.Connect() );
+    
+    RArray<TUid> uids;
+    CleanupClosePushL(uids);
+    sisRegistry.InstalledUidsL( uids );
+    
+    
+    //Read package information
+    for( TInt i = 0; i < uids.Count(); i++ )
+        {
+        Swi::RSisRegistryEntry entry;
+        CleanupClosePushL(entry);
+        User::LeaveIfError( entry.Open( sisRegistry, uids[i] ) );
+        
+        TBool showIt( EFalse );
+        if ( aListInstApps.iAllApps )
+            {
+            // show all apps -param defined, exlude stubs on ROM
+            if ( !entry.IsInRomL() )
+                {
+                showIt = ETrue;
+                }
+            }
+        else
+            {
+            // show if installed one of the specified drives
+            // don't exlude stubs on ROM
+            showIt = IsInstalledToSelectedDrive( aListInstApps.iDriveList,
+                                                 entry.InstalledDrivesL() );
+            }
+        
+        // Only show if not in rom
+        if ( showIt && entry.IsPresentL() )
+            {    
+            // Add the created object to the list
+            LOGGER_WRITE_1( "SConPcdUtility::ProcessListInstalledAppsL : add pkg, index %d", i );
+            CSConInstApp* app = new (ELeave) CSConInstApp();
+            CleanupStack::PushL( app );
+            
+            HBufC* temp = entry.PackageNameL();
+            TPtrC tempPtr = temp->Des();
+            LOGGER_WRITE_1("PackageNameL: %S", &tempPtr);
+            CleanupStack::PushL( temp );
+            if ( temp->Length() > app->iName.MaxLength() )
+            	{
+            	User::Leave( KErrTooBig );
+            	}
+            app->iName.Copy( *temp );
+            CleanupStack::PopAndDestroy( temp );
+            temp = NULL;
+            
+            temp = entry.UniqueVendorNameL();
+            CleanupStack::PushL( temp );
+            if ( temp->Length() > app->iVendor.MaxLength() )
+            	{
+            	User::Leave( KErrTooBig );
+            	}
+            app->iVendor.Copy( *temp );
+            CleanupStack::PopAndDestroy( temp );
+            temp = NULL;
+            
+            app->iVersion.Copy( entry.VersionL().Name() );
+            app->iType = ESisApplication;
+            app->iSize = entry.SizeL();
+            app->iUid = entry.UidL();
+            
+            User::LeaveIfError( aListInstApps.iApps.Append( app ) );
+            CleanupStack::Pop( app );
+            }
+        
+        // Get possible augmentations
+        RPointerArray<Swi::CSisRegistryPackage> augPackages;
+        CleanupResetAndDestroyPushL( augPackages );
+        entry.AugmentationsL( augPackages );
+        for ( TInt j( 0 ); j < augPackages.Count(); j++ )
+            {
+            Swi::RSisRegistryEntry augmentationEntry;
+            CleanupClosePushL( augmentationEntry );
+            augmentationEntry.OpenL( sisRegistry, *augPackages[j] );
+            
+            TBool showIt( EFalse );
+            if ( aListInstApps.iAllApps )
+                {
+                // show all apps -param defined, exlude stubs on ROM
+                if ( !augmentationEntry.IsInRomL() )
+                    {
+                    showIt = ETrue;
+                    }
+                }
+            else
+                {
+                // show if installed one of the specified drives
+                // don't exlude stubs on ROM
+                showIt = IsInstalledToSelectedDrive( aListInstApps.iDriveList,
+                                        augmentationEntry.InstalledDrivesL() );
+                }
+            
+            // Only show if not in rom
+            if ( showIt && augmentationEntry.IsPresentL() )
+                {
+                CSConInstApp* augApp = new (ELeave) CSConInstApp();
+                CleanupStack::PushL( augApp );
+                augApp->iName.Copy( augPackages[j]->Name() );
+                
+                HBufC* temp = entry.PackageNameL();
+                CleanupStack::PushL( temp );
+                if ( temp->Length() > augApp->iParentName.MaxLength() )
+                	{
+                	User::Leave( KErrTooBig );
+                	}
+                augApp->iParentName.Copy( *temp );
+                CleanupStack::PopAndDestroy( temp );
+                temp = NULL;
+                
+                augApp->iVendor.Copy( augPackages[j]->Vendor() );
+                augApp->iVersion.Copy( augmentationEntry.VersionL().Name() );
+                augApp->iType = ESisAugmentation;
+                augApp->iSize = augmentationEntry.SizeL();
+                augApp->iUid = augmentationEntry.UidL();
+                
+                LOGGER_WRITE_1( "SConPcdUtility::ProcessListInstalledAppsL : add augmentation, index: %d", j );
+                LOGGER_WRITE_1( "SConPcdUtility::ProcessListInstalledAppsL : add augmentation, basepkg: %d", i );
+                TInt augindex = augPackages[j]->Index();
+                LOGGER_WRITE_1( "SConPcdUtility::ProcessListInstalledAppsL : augindex: %d",augindex );
+                User::LeaveIfError( aListInstApps.iApps.Append( augApp ) );
+                CleanupStack::Pop( augApp );   
+                }
+            CleanupStack::PopAndDestroy( &augmentationEntry );
+            }  
+        CleanupStack::PopAndDestroy( &augPackages ); 
+        CleanupStack::PopAndDestroy( &entry );
+        }
+    
+    CleanupStack::PopAndDestroy(&uids);
+    CleanupStack::PopAndDestroy(&sisRegistry);
+    TRACE_FUNC_EXIT;
+    }
+
+//----------------------------------------------------------------------------
+// void SConPcdUtility::AppendInstalledJavaL( RPointerArray<CSConInstApp> &aApps )
+// Appends installed java packages to aApps array.
+//----------------------------------------------------------------------------
+//
+void SConPcdUtility::AppendInstalledJavaL( CSConListInstApps& aListInstApps )
+    {
+    TRACE_FUNC_ENTRY;
+    CJavaRegistry* javaRegistry = CJavaRegistry::NewLC( );
+    RArray<TUid> packageUids;
+    CleanupClosePushL( packageUids );
+    javaRegistry->GetRegistryEntryUidsL( /*EGeneralPackage,*/ packageUids );
+    LOGGER_WRITE_1("packageUids.Count(): %d", packageUids.Count());
+    for (TInt i=0; i<packageUids.Count(); i++ )
+        {
+        LOGGER_WRITE_1("RegistryEntryL: %d",i);
+        LOGGER_WRITE_1("handle entry uid: 0x%08X",packageUids[i].iUid);
+        CJavaRegistryEntry* entry = javaRegistry->RegistryEntryL( packageUids[i] );
+        if ( entry )
+            {
+            CleanupStack::PushL( entry );
+            if ( entry->Type() >= EGeneralPackage && entry->Type() < EGeneralApplication )
+                {
+                // entry was correct type
+                CJavaRegistryPackageEntry* packageEntry = ( CJavaRegistryPackageEntry* ) entry;
+                
+                // check do we need to filter it out
+                TBool showIt( EFalse );
+                if ( aListInstApps.iAllApps )
+                    {
+                    showIt = ETrue;
+                    }
+                else
+                    {
+                    TDriveNumber drive = packageEntry->Drive();
+                    if ( aListInstApps.iDriveList.Length() > drive
+                            && aListInstApps.iDriveList[ drive ] )
+                        {
+                        showIt = ETrue;
+                        }
+                    }
+                
+                if ( showIt )
+                    {
+                    CSConInstApp* app = new (ELeave) CSConInstApp();
+                    CleanupStack::PushL( app );
+                    // Get Uid, name, type, vendor
+                    app->iUid =  packageEntry->Uid();
+                    app->iName.Copy ( packageEntry->Name() );
+                    LOGGER_WRITE_1( "Name: %S", &app->iName );
+                    app->iType = EJavaApplication;
+                    
+                    // Get version
+                    TAppVersion midletVersion( packageEntry->Version() );
+                    TVersion verType(midletVersion.iMajor, midletVersion.iMinor, midletVersion.iBuild);    
+                    app->iVersion.Copy( verType.Name() );
+                    
+                    // Get vendor
+                    if ( entry->NumberOfCertificateChains() > 0 && packageEntry->Vendor().Length() > 0 )
+                        {
+                        app->iVendor.Copy( packageEntry->Vendor() );
+                        }
+                    else
+                        {
+                        // untrusted applications do not have certificates.
+                        // if the application has a certificate, it is installed either as 
+                        // trusted or not installed at all.
+                        
+                        // unknown vendor
+                        TFileName myFileName( KSConResourceName );
+                        CStringResourceReader* resReader = CStringResourceReader::NewL( myFileName );
+                        TPtrC bufUnknownSuplier;
+                        bufUnknownSuplier.Set( resReader->ReadResourceString( R_SECON_UNKNOWN_SUPPLIER ) );
+                        
+                        app->iVendor.Copy( bufUnknownSuplier );
+                        
+                        delete resReader;
+                        }
+                    
+                    // Get size
+                    app->iSize = packageEntry->UsedUserDiskSpace();
+                    
+                    User::LeaveIfError( aListInstApps.iApps.Append( app ) );
+                    CleanupStack::Pop( app );
+                    }
+                }
+            CleanupStack::PopAndDestroy( entry );
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( &packageUids );
+    CleanupStack::PopAndDestroy( javaRegistry );
+    TRACE_FUNC_EXIT;
+    }
+
+//----------------------------------------------------------------------------
+// void SConPcdUtility::AppendInstalledWidgetsL( RPointerArray<CSConInstApp> &aApps )
+// Appends installed widgets to aApps array.
+//----------------------------------------------------------------------------
+//
+void SConPcdUtility::AppendInstalledWidgetsL( CSConListInstApps& aListInstApps )
+    {
+    TRACE_FUNC_ENTRY;
+    RWidgetRegistryClientSession widgetSession;
+    CleanupClosePushL( widgetSession );
+    User::LeaveIfError( widgetSession.Connect() );
+    
+    // Get the list of installed widgets
+    RWidgetInfoArray widgetInfoArr;
+    CleanupClosePushL( widgetInfoArr );
+    widgetSession.InstalledWidgetsL( widgetInfoArr );
+    
+    for ( TInt i = 0; i < widgetInfoArr.Count(); i++ )
+        {
+        CWidgetInfo *item = widgetInfoArr[i];
+        CleanupStack::PushL( item );
+        
+        
+        TBool showIt( EFalse );
+        if ( aListInstApps.iAllApps )
+            {
+            // show all apps -param defined
+            showIt = ETrue;
+            }
+        else
+            {
+            TDriveUnit locationDrive = item->iDriveName->Des();
+            // show if installed one of the specified drives
+            if (  aListInstApps.iDriveList.Length() > locationDrive
+                    && aListInstApps.iDriveList[locationDrive] )
+                {
+                showIt = ETrue;
+                }
+            }
+        
+        if ( showIt )
+            {
+            
+            CSConInstApp* app = new (ELeave) CSConInstApp();
+            CleanupStack::PushL( app );
+            app->iName.Copy( *(item->iBundleName) );
+            app->iType = EWidgetApplication;
+            app->iSize = item->iFileSize;
+            app->iUid = item->iUid;
+            
+            CWidgetPropertyValue* propValue = widgetSession.GetWidgetPropertyValueL(
+                    item->iUid, EBundleVersion );
+            if ( propValue && propValue->iType == EWidgetPropTypeString )
+                {
+                app->iVersion.Copy( *(propValue->iValue.s) );
+                }
+            delete propValue;
+            propValue = NULL;
+            
+            User::LeaveIfError( aListInstApps.iApps.Append( app ) );
+            CleanupStack::Pop( app ); // ownership transferred, do not delete
+            }
+        CleanupStack::PopAndDestroy( item );
+        }
+    User::LeaveIfError( widgetSession.Disconnect() );
+    
+    CleanupStack::PopAndDestroy( &widgetInfoArr );
+    CleanupStack::PopAndDestroy( &widgetSession );
+    TRACE_FUNC_EXIT;
+    }
+
+// ---------------------------------------------------------
+// SConPcdUtility::IsInstalledToSelectedDrive
+// Solve highest drive from aInstalledDrives and check
+// if that drive is selected
+// ---------------------------------------------------------
+//
+TBool SConPcdUtility::IsInstalledToSelectedDrive( const TDriveList& aSelectedDriveList, TUint aInstalledDrives )
+    {
+    TInt locationDrive;
+    if( aInstalledDrives )
+         {
+         // Select the highest drive as location drive
+         TInt drive = EDriveA;
+         while( aInstalledDrives >>= 1 )
+             {
+             drive++;
+             }
+         locationDrive = drive;
+         }
+     else
+         {
+         // No installed files, select C: as location drive
+         locationDrive = EDriveC;
+         }
+    
+    if ( aSelectedDriveList.Length() > locationDrive && aSelectedDriveList[locationDrive] )
+        {
+        LOGGER_WRITE("SConPcdUtility::IsInstalledToSelectedDrive : return ETrue");
+        return ETrue;
+        }
+    else
+        {
+        LOGGER_WRITE("SConPcdUtility::IsInstalledToSelectedDrive : return EFalse");
+        return EFalse;
+        }
+    }
+//  END OF FILE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/src/sconqueue.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,442 @@
+/*
+* 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:  Queue implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "sconqueue.h"
+#include "sconpcdconsts.h"
+#include "debug.h"
+#include <SWInstDefs.h> // installer errors
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CSConTaskQueue::~CSConTaskQueue()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSConTaskQueue::~CSConTaskQueue()
+    {
+    TRACE_FUNC;
+    iQueue.ResetAndDestroy();
+    iQueue.Close(); 
+    iTimer.Close();
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConTaskQueue::GetQueueStatus( TInt aTask, TBool aAllTasks, 
+//                                  CSConStatusReply*& aStatus )
+// Returns the status of a specified task / all tasks
+// -----------------------------------------------------------------------------
+//
+void CSConTaskQueue::GetQueueStatusL( TInt aTask, TBool aAllTasks, 
+                                    CSConStatusReply*& aStatus )
+    {
+    RArray<TInt> completedTasks;
+    CleanupClosePushL( completedTasks );
+    if ( aAllTasks )
+        {
+        //if there are tasks
+        if ( iQueue.Count() > 0 )
+            {
+            //set iNoTasks as EFalse
+            aStatus->iNoTasks = EFalse;
+            for ( TInt i = 0; i < iQueue.Count(); i++ )
+                {
+                //Fill reply object
+                CSConTaskReply* taskReply = new (ELeave) CSConTaskReply();
+                CleanupStack::PushL( taskReply );
+                taskReply->InitializeL( *iQueue[i] );
+                User::LeaveIfError( aStatus->iTasks.Append( taskReply ) );
+                CleanupStack::Pop( taskReply );
+                TBool complete = iQueue[i]->GetComplete();
+
+                //Collect completed task numbers to array for deleting
+                if ( complete )
+                    {
+                    completedTasks.Append( iQueue[i]->iTaskId );
+                    }
+                //Otherwise clean all unneccessary data from the reply packet
+                else
+                    {
+                    taskReply->CleanTaskData(); 
+                    }
+                }
+            }
+        else
+            {
+            //no task in the queue
+            aStatus->iNoTasks = ETrue;
+            }
+
+        //Remove completed tasks from queue
+        for ( TInt j = 0; j < completedTasks.Count(); j++ )
+            {
+            RemoveTask( completedTasks[j] );
+            }
+        }
+    else if ( aTask > 0 )
+        {
+        CSConTask* temp = new (ELeave) CSConTask();
+        temp->iTaskId = aTask;
+        TInt index = iQueue.Find( temp, CSConTaskQueue::Match );
+        delete temp;
+        
+        TBool complete = EFalse;
+        CSConTaskReply* taskReply(NULL);
+
+        if ( index != KErrNotFound )
+            {
+            aStatus->iNoTasks = EFalse;
+            //Fill reply object
+            taskReply = new (ELeave) CSConTaskReply();
+            CleanupStack::PushL( taskReply );
+            taskReply->InitializeL( *iQueue[index] );
+            User::LeaveIfError( aStatus->iTasks.Append( taskReply ) );
+            CleanupStack::Pop( taskReply );
+            complete = iQueue[index]->GetComplete();
+            }
+        else
+            {
+            //no task in the queue
+            aStatus->iNoTasks = ETrue;
+            }        
+        
+        //Delete completed tasks from queue
+        if ( complete )
+            {
+            RemoveTask( aTask );
+            }
+        //Otherwise clean all unneccessary data from the reply packet
+        else if ( taskReply )
+            {
+            taskReply->CleanTaskData(); 
+            }
+        }
+    else
+        {
+        //no task in the queue
+        aStatus->iNoTasks = ETrue;
+        }
+    CleanupStack::PopAndDestroy( &completedTasks ); // close
+    }   
+    
+// -----------------------------------------------------------------------------
+// CSConTaskQueue::AddNewTask( CSConTask*& aNewTask, TInt aTaskId )
+// Adds a new task to queue
+// -----------------------------------------------------------------------------
+//
+TInt CSConTaskQueue::AddNewTask( CSConTask*& aNewTask, TInt aTaskId )
+    {
+    TInt ret( KErrNone );
+    
+    aNewTask->iTaskId = aTaskId;
+    
+    //Set progress value "task accepted for execution"
+    aNewTask->SetProgressValue( KSConCodeTaskCreated );
+    aNewTask->SetCompleteValue( EFalse );
+    
+    if ( iQueue.Count() == 0 )
+        {
+        StartQueue();
+        }
+    ret = iQueue.InsertInOrder( aNewTask, CSConTaskQueue::Compare );
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConTaskQueue::CompleteTask( TInt aTask, TInt aError )
+// Set the task to completed -mode
+// -----------------------------------------------------------------------------
+//
+void CSConTaskQueue::CompleteTask( TInt aTask, TInt aError )
+    {
+    LOGGER_WRITE_1( "CSConTaskQueue::CompleteTask aError: %d", aError );
+    TInt index( KErrNotFound );
+    
+    CSConTask* temp = new CSConTask();
+    temp->iTaskId = aTask;
+    index = iQueue.Find( temp, CSConTaskQueue::Match );
+    delete temp;
+    
+    if ( index != KErrNotFound )
+        {
+        TBool complete( ETrue );
+        TBool notComplete( EFalse );
+        TInt progress( KSConCodeTaskCompleted );        
+        
+        switch( aError )
+            {
+            case KErrNone :
+                iQueue[index]->SetCompleteValue( complete );
+                progress =  KSConCodeTaskCompleted;
+                break;
+            case KErrNotFound :
+                iQueue[index]->SetCompleteValue( complete );
+                progress =  KSConCodeNotFound;
+                break;
+            case KErrCompletion :
+                iQueue[index]->SetCompleteValue( notComplete );
+                progress = KSConCodeTaskPartiallyCompleted;
+                break;
+
+            // installer specific errors
+            case SwiUI::KSWInstErrUserCancel:
+            	LOGGER_WRITE("User cancelled the operation");
+            	iQueue[index]->SetCompleteValue( complete );
+            	progress = KSConCodeInstErrUserCancel;
+            	break;
+            case SwiUI::KSWInstErrFileCorrupted:
+            	LOGGER_WRITE("File is corrupted");
+            	iQueue[index]->SetCompleteValue( complete );
+            	progress = KSConCodeInstErrFileCorrupted;
+            	break;
+            case SwiUI::KSWInstErrInsufficientMemory:
+            	LOGGER_WRITE("Insufficient free memory in the drive to perform the operation");
+	            iQueue[index]->SetCompleteValue( complete );
+	            progress = KSConCodeInstErrInsufficientMemory;	
+	            break;
+            case SwiUI::KSWInstErrPackageNotSupported:
+            	LOGGER_WRITE("Installation of the package is not supported");
+            	iQueue[index]->SetCompleteValue( complete );
+            	progress = KSConCodeInstErrPackageNotSupported;
+            	break;
+            case SwiUI::KSWInstErrSecurityFailure:
+            	LOGGER_WRITE("Package cannot be installed due to security error");
+            	iQueue[index]->SetCompleteValue( complete );
+            	progress = KSConCodeInstErrSecurityFailure;
+            	break;
+            case SwiUI::KSWInstErrMissingDependency:
+            	LOGGER_WRITE("Package cannot be installed due to missing dependency");
+            	iQueue[index]->SetCompleteValue( complete );
+            	progress = KSConCodeInstErrMissingDependency;
+            	break;
+            case SwiUI::KSWInstErrFileInUse:
+            	LOGGER_WRITE("Mandatory file is in use and prevents the operation");
+            	iQueue[index]->SetCompleteValue( complete );
+            	progress = KSConCodeInstErrFileInUse;
+            	break;
+            case SwiUI::KSWInstErrGeneralError:
+            	LOGGER_WRITE("Unknown error");
+            	iQueue[index]->SetCompleteValue( complete );
+            	progress = KSConCodeInstErrGeneralError;
+            	break;
+            case SwiUI::KSWInstErrNoRights:
+            	LOGGER_WRITE("The package has no rights to perform the operation");
+            	iQueue[index]->SetCompleteValue( complete );
+            	progress = KSConCodeInstErrNoRights;
+            	break;
+            case SwiUI::KSWInstErrNetworkFailure:
+            	LOGGER_WRITE("Indicates that network failure aborted the operation");
+            	iQueue[index]->SetCompleteValue( complete );
+            	progress = KSConCodeInstErrNetworkFailure;
+            	break;
+            case SwiUI::KSWInstErrBusy:
+            	LOGGER_WRITE("Installer is busy doing some other operation");
+            	iQueue[index]->SetCompleteValue( complete );
+        		progress = KSConCodeInstErrBusy;
+            	break;
+            case SwiUI::KSWInstErrAccessDenied:
+            	LOGGER_WRITE("Target location of package is not accessible");
+            	iQueue[index]->SetCompleteValue( complete );
+            	progress = KSConCodeInstErrAccessDenied;
+            	break;
+            case SwiUI::KSWInstUpgradeError:
+            	LOGGER_WRITE("The package is an invalid upgrade");
+            	iQueue[index]->SetCompleteValue( complete );
+            	progress = KSConCodeInstUpgradeError;
+            	break;
+            
+            default :
+                iQueue[index]->SetCompleteValue( complete );
+                progress = KSConCodeConflict;
+                break;
+            }
+            
+        iQueue[index]->SetProgressValue( progress );
+        }
+    StartQueue();
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConTaskQueue::SetTaskProgress( TInt aTask, TInt aProgressValue )
+// Set the task progress value
+// -----------------------------------------------------------------------------
+//
+void CSConTaskQueue::SetTaskProgress( TInt aTask, TInt aProgressValue )
+    {
+    TInt index( KErrNotFound );
+
+    CSConTask* temp = new CSConTask();
+    temp->iTaskId = aTask;
+    index = iQueue.Find( temp, CSConTaskQueue::Match );
+    delete temp;
+    
+    if ( index != KErrNotFound )
+        {
+        iQueue[index]->SetProgressValue( aProgressValue );
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConTaskQueue::GetTask( TInt aTaskId, CSConTask*& aTask )
+// Receives a specified task
+// -----------------------------------------------------------------------------
+//
+TInt CSConTaskQueue::GetTask( TInt aTaskId, CSConTask*& aTask )
+    {
+    TInt ret( KErrNone );
+    TInt index;
+    
+    CSConTask* temp = new CSConTask();
+    temp->iTaskId = aTaskId;
+    index = iQueue.Find( temp, CSConTaskQueue::Match );
+    delete temp;
+
+    if ( index != KErrNotFound )
+        {
+        aTask = iQueue[index];
+        }
+    else
+        {
+        ret = KErrNotFound;
+        }
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConTaskQueue::RemoveTask( TInt aTask )
+// Removes a task from the queue
+// -----------------------------------------------------------------------------
+//
+void CSConTaskQueue::RemoveTask( TInt aTask )
+    {
+    TInt index( KErrNotFound );
+    
+    CSConTask* temp = new CSConTask();
+    temp->iTaskId = aTask;
+    index = iQueue.Find( temp, CSConTaskQueue::Match );
+    delete temp;
+    
+    if ( index != KErrNotFound ) 
+        {
+        delete iQueue[index];
+        iQueue.Remove( index );
+        iQueue.Compress();
+        }
+    
+    if ( iQueue.Count() == 0 )
+        {
+        StopQueue();
+        iQueue.Reset();
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConTaskQueue::CancelTask( TInt aTask, TBool aAllTasks )
+// Cancels a task
+// -----------------------------------------------------------------------------
+//
+void CSConTaskQueue::CancelTask( TInt aTask, TBool aAllTasks )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    //Remove the task from the queue
+    if ( aTask > 0 && !aAllTasks )
+        {
+        RemoveTask( aTask );
+        }
+        
+    //Remove all tasks from the queue
+    if ( aAllTasks )
+        {
+        iQueue.ResetAndDestroy();
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConTaskQueue::QueueProcessActive()
+// The status of the process
+// -----------------------------------------------------------------------------
+//  
+TBool CSConTaskQueue::QueueProcessActive() const
+    {
+    return iQueueProcessActive;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConTaskQueue::ChangeQueueProcessStatus()
+// Changes the status of the queue process
+// -----------------------------------------------------------------------------
+//  
+void CSConTaskQueue::ChangeQueueProcessStatus()
+    {
+    iQueueProcessActive = !iQueueProcessActive;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConTaskQueue::Reset()
+// Resets the queue
+// -----------------------------------------------------------------------------
+//
+void CSConTaskQueue::Reset()
+    {
+    TRACE_FUNC_ENTRY;
+    iTimer.Cancel();
+    iQueue.ResetAndDestroy();
+    TRACE_FUNC_EXIT;
+    }
+
+// ---------------------------------------------------------
+// CSConTaskQueue::Compare( const CSConTask& aFirst, 
+//                          const CSConTask& aSecond )
+// Compares task numbers
+// ---------------------------------------------------------    
+TInt CSConTaskQueue::Compare( const CSConTask& aFirst, 
+                            const CSConTask& aSecond )
+    {
+    if ( aFirst.iTaskId < aSecond.iTaskId )
+        {
+        return -1;
+        }
+    else if ( aFirst.iTaskId > aSecond.iTaskId )
+        {
+        return 1;
+        }
+    
+    return 0;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConTaskQueue::Match( const CSConTask& aFirst, const CSConTask& aSecond )
+// Matches the task numbers
+// -----------------------------------------------------------------------------
+//
+TInt CSConTaskQueue::Match( const CSConTask& aFirst, const CSConTask& aSecond )
+    {
+    if ( aFirst.iTaskId == aSecond.iTaskId )
+        {
+        return ETrue;
+        }
+        
+    return EFalse;
+    }
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/src/sconsbeclient.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1725 @@
+/*
+* 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:  CSConSBEClient implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <pathinfo.h>
+#include <mmf/common/mmfcontrollerpluginresolver.h>
+
+#include "sconsbeclient.h"
+#include "debug.h"
+
+
+_LIT( KSConNoDrive, "\x0" );
+_LIT( KSConDriveExists, "\x1" );
+// ============================= MEMBER FUNCTIONS ==============================
+
+// -----------------------------------------------------------------------------
+// CSConSBEClient::NewL( cosnt TInt aMaxObjectSize )
+// Two-phase constructor
+// -----------------------------------------------------------------------------
+//  
+CSConSBEClient* CSConSBEClient::NewL( const TInt aMaxObjectSize, RFs& aFs )
+    {
+    TRACE_FUNC;
+    CSConSBEClient* self = new (ELeave) CSConSBEClient( aMaxObjectSize, aFs );
+    return self;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConSBEClient::CSConSBEClient( const TInt aMaxObjectSize )
+// Constructor
+// -----------------------------------------------------------------------------
+//
+CSConSBEClient::CSConSBEClient( const TInt aMaxObjectSize, RFs& aFs ) : 
+        CActive( EPriorityStandard ), iSBEClient(NULL), 
+        iProcessComplete(EFalse), iProcessIndex( 0 ), iDataPos( 0 ),
+        iDataLeft( EFalse ), iBURModeNormal( ETrue ),
+        iRestoreMode( EFalse ), iFs( aFs )
+    {
+    iMaxObjectSize = aMaxObjectSize;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConSBEClient::~CSConSBEClient()
+// Initializes member data
+// -----------------------------------------------------------------------------
+//  
+CSConSBEClient::~CSConSBEClient()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt err( KErrNone );
+    
+    if( !iBURModeNormal && iSBEClient )
+        {
+        TDriveList driveList;
+        
+        for( TInt i = 0; i<KMaxDrives; i++ )
+            {
+            if( i == EDriveC || i == EDriveE )
+                {
+                driveList.Append( KSConDriveExists );
+                }
+            else
+                {
+                driveList.Append( KSConNoDrive );
+                }
+            }
+        
+        TRAP( err, iSBEClient->SetBURModeL( driveList, EBURNormal, ENoBackup ) );
+        }
+    
+    if( iSBEClient )
+        {
+        delete iSBEClient;
+        iSBEClient = NULL;
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConSBEClient::SetBURMode( TRequestStatus& aStatus, CSConTask*& aTask )
+// Set backup/restore mode
+// -----------------------------------------------------------------------------
+//  
+void CSConSBEClient::SetBURMode( TRequestStatus& aStatus, CSConTask*& aTask )
+    {
+    TRACE_FUNC_ENTRY;
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    iCurrentTask = aTask;
+
+    TRequestStatus* status = &iStatus; 
+    User::RequestComplete( status, KErrNone ); 
+    SetActive();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConSBEClient::ListPublicFiles( TRequestStatus& aStatus, 
+//                                  CSConTask*& aTask )
+// Lists public files from data owners
+// -----------------------------------------------------------------------------
+//  
+void CSConSBEClient::ListPublicFiles( TRequestStatus& aStatus, 
+                                    CSConTask*& aTask )
+    {
+    TRACE_FUNC_ENTRY;
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    iCurrentTask = aTask;
+    
+    TRequestStatus* status = &iStatus; 
+    User::RequestComplete( status, KErrNone ); 
+    SetActive();    
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConSBEClient::ListDataOwners( TRequestStatus& aStatus, CSConTask*& aTask )
+// Lists participant data owners
+// -----------------------------------------------------------------------------
+//  
+void CSConSBEClient::ListDataOwners( TRequestStatus& aStatus, CSConTask*& aTask )
+    {
+    TRACE_FUNC_ENTRY;
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    iCurrentTask = aTask;
+    
+    TRequestStatus* status = &iStatus; 
+    User::RequestComplete( status, KErrNone ); 
+    SetActive();
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConSBEClient::GetDataSize( TRequestStatus& aStatus, CSConTask*& aTask )
+// Lists data sizes from data owners
+// -----------------------------------------------------------------------------
+//  
+void CSConSBEClient::GetDataSize( TRequestStatus& aStatus, CSConTask*& aTask )
+    {
+    TRACE_FUNC_ENTRY;
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    iCurrentTask = aTask;
+    
+    TRequestStatus* status = &iStatus; 
+    User::RequestComplete( status, KErrNone ); 
+    SetActive();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConSBEClient::RequestData( TRequestStatus& aStatus, CSConTask*& aTask )
+// Request a data from a data owner
+// -----------------------------------------------------------------------------
+//  
+void CSConSBEClient::RequestData( TRequestStatus& aStatus, CSConTask*& aTask )
+    {
+    TRACE_FUNC_ENTRY;
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    iCurrentTask = aTask;
+    
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete( status, KErrNone );          
+    SetActive();    
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConSBEClient::GetDataOwnerStatus( TRequestStatus& aStatus, 
+//                                      CSConTask*& aTask )
+// Lists the status of data owners
+// -----------------------------------------------------------------------------
+//  
+void CSConSBEClient::GetDataOwnerStatus( TRequestStatus& aStatus, 
+                                        CSConTask*& aTask )
+    {
+    TRACE_FUNC_ENTRY;
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    iCurrentTask = aTask;
+    
+    TRequestStatus* status = &iStatus; 
+    User::RequestComplete( status, KErrNone ); 
+    SetActive();
+        
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConSBEClient::SupplyData( TRequestStatus& aStatus, CSConTask*& aTask )
+// Supplies a data to a data owner
+// -----------------------------------------------------------------------------
+//  
+void CSConSBEClient::SupplyData( TRequestStatus& aStatus, CSConTask*& aTask )
+    {
+    TRACE_FUNC_ENTRY;
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    iCurrentTask = aTask;
+    
+    TRequestStatus* status = &iStatus; 
+    User::RequestComplete( status, KErrNone ); 
+    SetActive();    
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConSBEClient::DoCancel()
+// Implementation of CActive::DoCancel()
+// -----------------------------------------------------------------------------
+//          
+void CSConSBEClient::DoCancel()
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConSBEClient::RunL()
+// Implementation of CActive::RunL()
+// -----------------------------------------------------------------------------
+//              
+void CSConSBEClient::RunL()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt err( KErrNone );
+    TInt ret( KErrNone );
+    
+    //Initialize a connection to the backup server
+    if( !iSBEClient )
+        {
+        iSBEClient = CSBEClient::NewL();
+        }   
+    
+    switch( iCurrentTask->GetServiceId() )
+        {
+        case ESetBURMode :
+            LOGGER_WRITE( "CSConSBEClient::RunL() : ESetBURMode" );
+            TRAP( err, ProcessSetBURModeL() );
+            LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessSetBURModeL() : returned %d", err );
+            HandleSBEErrorL( err );
+            User::RequestComplete( iCallerStatus, err );
+            break;
+        case EListPublicFiles :
+            LOGGER_WRITE( "CSConSBEClient::RunL() : EListPublicFiles" );
+            TRAP( err, ProcessListPublicFilesL() );
+            LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessListPublicFilesL() : returned %d", err );
+            HandleSBEErrorL( err );
+            User::RequestComplete( iCallerStatus, err );
+            break;
+        case EListDataOwners :
+            LOGGER_WRITE( "CSConSBEClient::RunL() : EListDataOwners" ); 
+            TRAP( err, ProcessListDataOwnersL() );
+            LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessListDataOwnersL() : returned %d", err );
+            HandleSBEErrorL( err );
+            User::RequestComplete( iCallerStatus, err );
+            break;
+        case EGetDataSize :
+            LOGGER_WRITE( "CSConSBEClient::RunL() : EGetDataSize" );    
+            TRAP( err, ProcessGetDataSizeL() );
+            LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessGetDataSizeL() : returned %d", err );
+            HandleSBEErrorL( err );
+            User::RequestComplete( iCallerStatus, err );
+            break;
+        case ERequestData :
+            LOGGER_WRITE( "CSConSBEClient::RunL() : ERequestData" );
+            TRAP( err, ret = ProcessRequestDataL() );
+            LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessRequestDataL() : returned %d", err );
+            HandleSBEErrorL( err );
+            
+            if( err == KErrNone )
+                {
+                err = ret;
+                }
+            
+            User::RequestComplete( iCallerStatus, err );
+            break;  
+        case EGetDataOwnerStatus :
+            LOGGER_WRITE( "CSConSBEClient::RunL() : EGetDataOwnerStatus" );
+            TRAP( err, ProcessGetDataOwnerStatusL() );
+            LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessGetDataOwnerStatusL() : returned %d", err );
+            HandleSBEErrorL( err );
+            User::RequestComplete( iCallerStatus, err );
+            break;
+        case ESupplyData :
+            LOGGER_WRITE( "CSConSBEClient::RunL() : ESupplyData" ); 
+            TRAP( err, ret = ProcessSupplyDataL() );
+            LOGGER_WRITE_1( "CSConSBEClient::RunL() : SupplyDataL() : returned %d", err );
+            HandleSBEErrorL( err );
+            
+            if( err == KErrNone )
+                {
+                err = ret;
+                }
+            
+            User::RequestComplete( iCallerStatus, err );
+            break;
+        default :
+            LOGGER_WRITE( "CSConSBEClient::RunL() : ERROR! Unknown!" ); 
+            break;
+        }
+            
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConSBEClient::ProcessSetBURModeL()
+// Executes SetBURMode task
+// -----------------------------------------------------------------------------
+//  
+void CSConSBEClient::ProcessSetBURModeL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iAllSnapshotsSuppliedCalled = EFalse;
+    
+    TDriveList driveList = iCurrentTask->iBURModeParams->iDriveList;
+    
+    TBURPartType partialType = EBURUnset;
+    iRestoreMode = EFalse;
+    
+    switch( iCurrentTask->iBURModeParams->iPartialType )
+        {
+        case ESConBurNormal :
+            partialType = EBURNormal;
+            break;
+        case ESConBurBackupFull :
+            partialType = EBURBackupFull;
+            break;
+        case ESConBurBackupPartial :
+            partialType = EBURBackupPartial;
+            break;
+        case ESConBurRestoreFull :
+            partialType = EBURRestoreFull;
+            iRestoreMode = ETrue;
+            break;
+        case ESConBurRestorePartial :
+            partialType = EBURRestorePartial;
+            iRestoreMode = ETrue;
+            break;
+        default :
+            partialType = EBURUnset;
+            break;
+        }
+    
+    TBackupIncType incType = ENoBackup;
+    
+    switch( iCurrentTask->iBURModeParams->iIncType )    
+        {
+        case ESConNoBackup :
+            incType = ENoBackup;
+            break;
+        case ESConBackupBase :
+            incType = EBackupBase;
+            break;
+        case ESConBackupIncrement :
+            incType = EBackupIncrement;
+            break;
+        default :
+            incType = ENoBackup;
+            break;
+        }
+    
+    iSBEClient->SetBURModeL( driveList, partialType, incType );
+    
+    if( partialType != EBURNormal )
+        {
+        iBURModeNormal = EFalse;
+        }
+    else
+        {
+        iBURModeNormal = ETrue;
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConSBEClient::ProcessListPublicFilesL()
+// Executes ListPublicFiles task
+// -----------------------------------------------------------------------------
+//
+void CSConSBEClient::ProcessListPublicFilesL()
+    {
+    TRACE_FUNC_ENTRY;
+    //Get the secure id
+    TSecureId sid = iCurrentTask->iPubFilesParams->iDataOwners[0]->iUid;
+    TSecureId packageSid;
+    LOGGER_WRITE_1("DO: 0x%08x", sid.iId);
+    TPtrC packageName(KNullDesC);
+    const TUint KSConUidLength = 8; // 8 digits (hex)
+    const TUint KSConUidPrefixLength = 3; // prefix is '#0x'
+    
+    TInt packageNameLength = iCurrentTask->iPubFilesParams->iDataOwners[0]->iPackageName.Length();
+    
+    if ( packageNameLength > KSConUidLength )
+        {
+        // remove uid from package name
+        packageName.Set( 
+                iCurrentTask->iPubFilesParams->iDataOwners[0]->
+                iPackageName.Left( packageNameLength - (KSConUidLength + KSConUidPrefixLength) ) );
+        LOGGER_WRITE_1("PackageName: %S", &packageName );
+        
+        TPtrC sidPtr( iCurrentTask->iPubFilesParams->iDataOwners[0]->
+                iPackageName.Right( KSConUidLength ) );
+        TLex lex(sidPtr);
+        TInt err = lex.Val( packageSid.iId, EHex );
+        if ( err )
+            {
+            LOGGER_WRITE_1("lex.Val error: %d", err);
+            packageName.Set( KNullDesC );
+            packageSid.iId = 0;
+            }
+        LOGGER_WRITE_1("packageSid: 0x%08x", packageSid.iId );
+        }
+    
+    //Get the drive list
+    TDriveList driveList = 
+    iCurrentTask->iPubFilesParams->iDataOwners[0]->iDriveList;
+    
+    RFileArray files;
+    CleanupClosePushL( files );
+    //Go through all the drives in the list
+    for( TInt i = 0; i < KMaxDrives; i++ )
+        {
+        if( driveList[i] )
+            {
+            //Get files from the drive
+            TDriveNumber driveNumber = GetDriveNumber( i );
+            LOGGER_WRITE_1("driveNumber: %d", driveNumber);
+            
+            LOGGER_WRITE("List public files using CSBSecureId");
+            CSBSecureId* secureId = CSBSecureId::NewL( sid );
+            CleanupStack::PushL( secureId );
+            
+            TRAPD( err, iSBEClient->PublicFileListL( driveNumber, *secureId, files ) );
+            
+            if( err != KErrNone && err != KErrNotFound )
+                {
+                LOGGER_WRITE_1("iSBEClient->PublicFileListL leaved: %d", err);
+                User::LeaveIfError( err );
+                }
+            
+            CleanupStack::PopAndDestroy( secureId );
+            LOGGER_WRITE_1("public files: %d", files.Count());
+            AppendFilesToFilelistL( files, iCurrentTask->iPubFilesParams->iFiles) ;
+            
+            if ( packageName.Length() > 0 )
+                {
+                LOGGER_WRITE("Append files registered to packages. Using CSBPackageId");
+                
+                CSBPackageId* packageId = CSBPackageId::NewL(
+                        iCurrentTask->iPubFilesParams->iDataOwners[0]->iUid,
+                        packageSid,
+                        packageName );
+                CleanupStack::PushL( packageId );
+                
+                TRAPD( err, iSBEClient->PublicFileListL( driveNumber, *packageId, files ) );
+                if( err != KErrNone && err != KErrNotFound )
+                    {
+                    LOGGER_WRITE_1("iSBEClient->PublicFileListL leaved: %d", err);
+                    User::LeaveIfError( err );
+                    }
+                CleanupStack::PopAndDestroy( packageId );
+                
+                LOGGER_WRITE_1("public files: %d", files.Count());
+                AppendFilesToFilelistL( files, iCurrentTask->iPubFilesParams->iFiles) ;
+                }
+            
+            files.Reset();
+            }
+        }
+    CleanupStack::PopAndDestroy( &files );
+    TRACE_FUNC_EXIT;
+    }
+
+    
+// -----------------------------------------------------------------------------
+// CSConSBEClient::ProcessListDataOwnersL()
+// Executes ListDataOwners task
+// -----------------------------------------------------------------------------
+//
+void CSConSBEClient::ProcessListDataOwnersL()
+    {
+    TRACE_FUNC_ENTRY;
+    TBool includeToList( ETrue );
+    RPointerArray<CDataOwnerInfo> dataOwners;
+    RArray<TUid> packageArray;
+    CleanupResetAndDestroyPushL( dataOwners );
+    CleanupClosePushL( packageArray );
+    
+    iSBEClient->ListOfDataOwnersL( dataOwners );
+    LOGGER_WRITE_1( "dataOwners count: %d", dataOwners.Count() );
+    
+    
+    for( TInt i = 0; i < dataOwners.Count(); i++ )
+        {
+        LOGGER_WRITE_2("handling do: %d, count: %d", i, dataOwners.Count());
+        CSConDataOwner* dataOwner = new (ELeave) CSConDataOwner();
+        // default values
+        TSecureId sid( 0 );
+        includeToList = ETrue;
+        
+        TCommonBURSettings commonOptions = dataOwners[i]->CommonSettings();
+        TPassiveBURSettings passiveOptions = dataOwners[i]->PassiveSettings();
+        TActiveBURSettings activeOptions = dataOwners[i]->ActiveSettings();
+        
+        //active, passive or hybrid? (common)
+        if( commonOptions & EActiveBUR && commonOptions & EPassiveBUR )
+            {
+            dataOwner->iType = EHybridDataOwner;
+            }       
+        else if( commonOptions & EActiveBUR )
+            {
+            dataOwner->iType = EActiveDataOwner;
+            }
+        else if( commonOptions & EPassiveBUR )
+            {
+            dataOwner->iType = EPassiveDataOwner;
+            }
+                
+        //requires reboot? (common)
+        if( commonOptions & ERequiresReboot )
+            {
+            dataOwner->iReqReboot = ETrue;
+            }
+        else
+            {
+            dataOwner->iReqReboot = EFalse;
+            }
+            
+        //has system files? (common)
+        if( commonOptions & EHasSystemFiles )
+            {
+            dataOwner->iHasFiles = ESystemFiles;
+            }
+            
+        //supports selective? (common)
+        if( commonOptions & ESupportsSelective )
+            {
+            dataOwner->iSupportsSel = ETrue;
+            }
+        else
+            {
+            dataOwner->iSupportsSel = EFalse;
+            }
+            
+        //has public files? (passive)
+        if( passiveOptions & EHasPublicFiles )
+            {
+            if( dataOwner->iHasFiles == ESystemFiles )
+                {
+                dataOwner->iHasFiles = EPublicSystemFiles;
+                }
+            else
+                {
+                dataOwner->iHasFiles = EPublicFiles;    
+                }
+            }
+            
+        //supports incremental? (active and passive)
+        if( activeOptions & EActiveSupportsInc || 
+                passiveOptions & EPassiveSupportsInc  )
+            {
+            dataOwner->iSupportsInc = ETrue;
+            }
+        else
+            {
+            dataOwner->iSupportsInc = EFalse;
+            }
+            
+        //delay to prepare data? (active)
+        if( activeOptions & EDelayToPrepareData )
+            {
+            dataOwner->iDelayToPrep = ETrue;
+            }
+        else
+            {
+            dataOwner->iDelayToPrep = EFalse;
+            }
+            
+        //fill drivelist
+        dataOwner->iDriveList = dataOwners[i]->DriveList();
+        //filter the drive list
+        FilterDriveList( dataOwner->iDriveList );
+                        
+        CSBGenericDataType* genericData = &( dataOwners[i]->Identifier() );
+        TSBDerivedType derived = genericData->DerivedTypeL();
+        
+        if( derived == ESIDDerivedType )
+            {
+            //Uif of the data owner
+            CSBSecureId* secureId = CSBSecureId::NewL( genericData );
+            CleanupStack::PushL( secureId );
+            sid = secureId->SecureIdL();
+        
+            dataOwner->iUid.iUid = (TInt32)sid.iId;
+            LOGGER_WRITE_1("ESIDDerivedType, sid: 0x%08x", dataOwner->iUid.iUid );
+        
+            CleanupStack::PopAndDestroy( secureId );
+            }
+        else if( derived == EPackageDerivedType )
+            {
+            //Package name and uid of the data owner
+            CSBPackageId* packageId = CSBPackageId::NewL( genericData );
+            CleanupStack::PushL( packageId );
+        
+            dataOwner->iPackageName = packageId->PackageNameL();
+            dataOwner->iUid.iUid = packageId->PackageIdL().iUid;
+            LOGGER_WRITE_1("EPackageDerivedType, uid: 0x%08x", dataOwner->iUid.iUid );
+            sid = packageId->SecureIdL();
+            LOGGER_WRITE_1("sid: 0x%08x", sid.iId );
+            
+            // owerload the package name, also add sid information.
+            _LIT(KSidFormat, "#0x%08x");
+            const TInt KSidFormatLength = 11;
+            TBuf<KSidFormatLength> sidFormat;
+            sidFormat.Format( KSidFormat, sid.iId );
+            if ( dataOwner->iPackageName.Length() + sidFormat.Length()
+                <= dataOwner->iPackageName.MaxLength() )
+                {
+                dataOwner->iPackageName.Append( sidFormat );
+                }
+            else
+                {
+                LOGGER_WRITE("WARNING: Package name too long, sid not included.");
+                }
+            
+            LOGGER_WRITE_1("Package name: %S", &dataOwner->iPackageName );
+            if( sid )
+                {
+                //Find if the package is already included to dataowner list
+                if( packageArray.Find( packageId->PackageIdL(), 
+                                        CSConSBEClient::Match ) != KErrNotFound )
+                    {
+                    LOGGER_WRITE("dataowner was already included to list");
+                    //Don't include dataowner to list again
+                    includeToList = EFalse;
+                    }
+                else
+                    {
+                    //Store package's id for filtering
+                    LOGGER_WRITE_1( "Storing package id for filtering, uid: 0x%08x", dataOwner->iUid.iUid );
+                    packageArray.Append( dataOwner->iUid ); 
+                    }
+                }
+            
+            CleanupStack::PopAndDestroy( packageId );
+            }
+        else if( derived == EJavaDerivedType )
+            {
+            //Hash
+            CSBJavaId* javaId = CSBJavaId::NewL( genericData );
+            CleanupStack::PushL( javaId );
+            
+            //Initialize with hash data length and copy hash
+            dataOwner->iJavaHash = HBufC::NewL( javaId->SuiteHashL().Length() );
+            dataOwner->iJavaHash->Des().Copy( javaId->SuiteHashL() );
+            
+            //For ConML: set as passive package
+            dataOwner->iType = EPassiveDataOwner;
+            dataOwner->iPackageName.Copy( javaId->SuiteNameL() );
+            
+#ifdef _DEBUG
+            LOGGER_WRITE("EJavaDerivedType" );
+            LOGGER_WRITE_1("Package name: %S", &dataOwner->iPackageName );
+            TPtrC hash( dataOwner->iJavaHash->Des() );
+            LOGGER_WRITE_1("JavaHash: %S", &hash );
+#endif
+            
+            CleanupStack::PopAndDestroy( javaId );
+            }
+        else
+            {
+            LOGGER_WRITE("Unknown type, ignored from list" );
+            //Unknown type => ignore from list
+            includeToList = EFalse;
+            }
+        
+        if( includeToList ) 
+            {
+            LOGGER_WRITE_1( "Appending to list, uid: 0x%08x", dataOwner->iUid.iUid );
+            iCurrentTask->iListDataOwnersParams->iDataOwners.Append( dataOwner );
+            }
+        
+        if( sid )
+            {
+            LOGGER_WRITE_1( "Appending package sid to list, sid: 0x%08x", sid.iId );
+            CSConDataOwner* packageDataOwner = dataOwner->CopyL();
+            //Clear package name
+            packageDataOwner->iPackageName = KNullDesC();
+            //Add sid
+            packageDataOwner->iUid.iUid = sid.iId;
+            iCurrentTask->iListDataOwnersParams->iDataOwners.Append( packageDataOwner );
+            }
+        
+        if( !includeToList )
+            {
+            //Not included to list => delete memory allocation
+            delete dataOwner;
+            }
+        }
+        
+    packageArray.Reset();
+    CleanupStack::PopAndDestroy( &packageArray );
+    CleanupStack::PopAndDestroy( &dataOwners );
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConSBEClient::ProcessGetDataSizeL()
+// Executes GetDataSize task
+// -----------------------------------------------------------------------------
+//  
+void CSConSBEClient::ProcessGetDataSizeL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    if ( !iAllSnapshotsSuppliedCalled )
+        {
+        TInt err(KErrNone);
+        // we have to call AllSnapshotsSupplied() to inform active
+        // data owners to start prepare their base data.
+        TRAP( err, iSBEClient->AllSnapshotsSuppliedL() );
+        LOGGER_WRITE_1( "AllSnapshotsSuppliedL() leaved: %d", err );
+        iAllSnapshotsSuppliedCalled = ETrue;
+        }
+    
+    
+    TBool packageData( EFalse );
+    
+    //Calculate data size for every data owner received from the task
+    for( TInt i = 0; i < iCurrentTask->iGetDataSizeParams->iDataOwners.Count();
+        i++ )
+        {
+        packageData = EFalse;
+        CSConDataOwner* dataOwner = 
+            iCurrentTask->iGetDataSizeParams->iDataOwners[i];
+            
+        TTransferDataType tdt( ERegistrationData );
+        TPackageDataType pdt( ESystemData );
+        
+        LOGGER_WRITE_2( "ProcessGetDataSizeL DO %d of %d", i, iCurrentTask->iGetDataSizeParams->iDataOwners.Count() );
+        LOGGER_WRITE_1( "ProcessGetDataSizeL SID 0x%08x", dataOwner->iUid );
+        switch( dataOwner->iTransDataType )
+            {
+            case ESConRegistrationData :
+                LOGGER_WRITE( "CSConSBEClient::ProcessGetDataSize() : ERegistrationData" );
+                tdt = ERegistrationData;
+                break;
+            case ESConPassiveSnapshotData :
+                LOGGER_WRITE( "CSConSBEClient::ProcessGetDataSize() : EPassiveSnapshotData" );
+                tdt = EPassiveSnapshotData;
+                break;
+            case ESConPassiveBaseData :
+                LOGGER_WRITE( "CSConSBEClient::ProcessGetDataSize() : EPassiveBaseData" );
+                tdt = EPassiveBaseData;
+                break;
+            case ESConPassiveIncrementalData :
+                LOGGER_WRITE( "CSConSBEClient::ProcessGetDataSize() : EPassiveIncrementalData" );
+                tdt = EPassiveIncrementalData;
+                break;
+            case ESConActiveSnapshotData :
+                LOGGER_WRITE( "CSConSBEClient::ProcessGetDataSize() : EActiveSnapshotData" );
+                tdt = EActiveSnapshotData;
+                break;
+            case ESConActiveBaseData :
+                LOGGER_WRITE( "CSConSBEClient::ProcessGetDataSize() : EActiveBaseData" );
+                tdt = EActiveBaseData;
+                break;
+            case ESConActiveIncrementalData :
+                LOGGER_WRITE( "CSConSBEClient::ProcessGetDataSize() : EActiveIncrementalData" );
+                tdt = EActiveIncrementalData;
+                break;
+            case ESConSystemData :
+                LOGGER_WRITE( "CSConSBEClient::ProcessGetDataSize() : ESystemData" );
+                pdt = ESystemData;
+                packageData = ETrue;
+                break;
+            case ESConSystemSnapshotData :
+                LOGGER_WRITE( "CSConSBEClient::ProcessGetDataSize() : ESystemSnapshotData" );
+                pdt = ESystemSnapshotData;
+                packageData = ETrue;
+                break;
+            default :
+                break;
+            }
+        
+        if( packageData && !dataOwner->iJavaHash )
+            {
+            dataOwner->iSize = PackageDataSizeL( dataOwner->iUid, dataOwner->iDriveList, pdt );
+            }
+        else if( !dataOwner->iJavaHash )
+            {
+            dataOwner->iSize = SidDataSizeL( dataOwner->iUid, dataOwner->iDriveList, tdt );
+            }
+        else
+            {
+            dataOwner->iSize = JavaDataSizeL( dataOwner->iJavaHash->Des(),
+                    dataOwner->iDriveList );
+            }
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSConSBEClient::ProcessRequestDataL()
+// Executes RequestData task
+// -----------------------------------------------------------------------------
+//      
+TInt CSConSBEClient::ProcessRequestDataL()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret( KErrNone );
+    
+    if( iMaxObjectSize <= 1 )
+        {
+        User::Leave( KErrGeneral );
+        }
+        
+    TBool packageData = EFalse;
+    TTransferDataType transferDataType( ERegistrationData );
+    TPackageDataType packageDataType( ESystemSnapshotData );    
+    LOGGER_WRITE_1("CSConSBEClient::ProcessRequestDataL() iTransDataType: %d",
+        (TInt)iCurrentTask->iRequestDataParams->iDataOwner->iTransDataType);
+    
+    switch( iCurrentTask->iRequestDataParams->iDataOwner->iTransDataType )
+        {
+        case ESConRegistrationData :
+            transferDataType = ERegistrationData;
+            break;
+        case ESConPassiveSnapshotData :
+            transferDataType = EPassiveSnapshotData;
+            break;
+        case ESConPassiveBaseData :
+            transferDataType = EPassiveBaseData;
+            break;
+        case ESConPassiveIncrementalData :
+            transferDataType = EPassiveIncrementalData;
+            break;
+        case ESConActiveSnapshotData :
+            transferDataType = EActiveSnapshotData;
+            break;
+        case ESConActiveBaseData :
+            transferDataType = EActiveBaseData;
+            break;
+        case ESConActiveIncrementalData :
+            transferDataType = EActiveIncrementalData;
+            break;
+        case ESConSystemData :
+            packageDataType = ESystemData;
+            packageData = ETrue;
+            break;
+        case ESConSystemSnapshotData:
+            packageDataType = ESystemSnapshotData;
+            packageData = ETrue;
+            break;
+        default :
+            break;
+        }
+        
+    
+    //Get the drive number  
+    TDriveNumber driveNumber = EDriveC;
+    TDriveList driveList = iCurrentTask->iRequestDataParams->
+        iDataOwner->iDriveList;
+    
+    for( TInt i = 0; i < KMaxDrives; i++ )
+        {
+        if( driveList[i] )
+            {
+            driveNumber = GetDriveNumber( i );
+            break;
+            }
+        }
+        
+    //Get UID, SID or Java hash
+    TUid uid;
+    TSecureId sid;
+            
+    uid.iUid = 0;
+    sid.iId = 0;
+    
+    if( packageData && !iCurrentTask->iRequestDataParams->iDataOwner->iJavaHash )
+        {
+        uid = iCurrentTask->iRequestDataParams->iDataOwner->iUid;
+        LOGGER_WRITE_1("CSConSBEClient::ProcessRequestDataL() uid: 0x%08x", uid.iUid);
+        }
+    else if( !iCurrentTask->iRequestDataParams->iDataOwner->iJavaHash )
+        {
+        sid = iCurrentTask->iRequestDataParams->iDataOwner->iUid;
+        LOGGER_WRITE_1("CSConSBEClient::ProcessRequestDataL() sid: 0x%08x", sid.iId);
+        }
+            
+    CSBPackageTransferType* ptt( NULL );
+    CSBSIDTransferType* stt( NULL );
+    CSBJavaTransferType* jtt( NULL );
+    
+    LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \
+    Begin - Data left: %d", iDataLeft );
+    LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \
+    Begin - Package data: %d", packageData );
+    LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \
+    Begin - iDataPos: %d", iDataPos );
+        
+    //Are there old data left to be transfered?
+    if( !iDataLeft ) 
+        {
+        //No data left, request more from the server
+        if( packageData && !iCurrentTask->iRequestDataParams->iDataOwner->iJavaHash )
+            {
+            ptt = CSBPackageTransferType::NewL( uid, driveNumber, 
+                packageDataType );
+            CleanupStack::PushL( ptt );
+            LOGGER_WRITE( "iSBEClient->RequestDataL( ptt ) : start" );
+            TRequestStatus status;
+            iSBEClient->RequestDataL( *ptt, status );
+            User::WaitForRequest( status );
+            LOGGER_WRITE( "iSBEClint->RequestDataL( ptt ) : stop" );
+            
+            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : status.Int() %d", status.Int() );
+            User::LeaveIfError( status.Int() );
+                                    
+            //Get the data and store the handle
+            CSBGenericTransferType* gtt = NULL;
+            LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ) : start" );
+            iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iLastChunk ) );
+            LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ) : stop" );
+            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
+             Received data size %d", iDataPtr.Length() );
+            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
+             Received from DO 0x%08x", uid );
+            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
+             Is last chunk %d", iLastChunk );
+            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
+             Transfertype %d", iCurrentTask->iRequestDataParams->iDataOwner->iTransDataType );
+             
+             if( gtt )
+                {
+                delete gtt;
+                }
+             
+            CleanupStack::PopAndDestroy( ptt );
+            }
+        else if( !iCurrentTask->iRequestDataParams->iDataOwner->iJavaHash )
+            {
+            stt = CSBSIDTransferType::NewL( sid, driveNumber, transferDataType );
+            CleanupStack::PushL( stt );
+            LOGGER_WRITE( "iSBEClient->RequestDataL( stt ) : start" );
+            TRequestStatus status;
+            iSBEClient->RequestDataL( *stt, status );
+            User::WaitForRequest( status );
+            LOGGER_WRITE( "iSBEClient->RequestDataL( stt ) : stop" );
+            
+            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
+             status.Int() %d", status.Int() );
+            User::LeaveIfError( status.Int() );
+                        
+            //Get the data and store the handle
+            CSBGenericTransferType* gtt = NULL;
+            LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ) : start" );
+            iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iLastChunk ) );
+            LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ) : stop" );
+            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
+             Received data size %d", iDataPtr.Length() );
+            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
+             Is last chunk %d", iLastChunk );
+            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
+             Transfertype %d", 
+             iCurrentTask->iRequestDataParams->iDataOwner->iTransDataType );
+             
+            if( gtt )
+                {
+                delete gtt;
+                }
+             
+            CleanupStack::PopAndDestroy( stt );
+            }
+        else
+            {
+            TPtr javaHashPtr = iCurrentTask->iRequestDataParams->iDataOwner->iJavaHash->Des();
+            
+            //When ESystemData is requested, request EJavaMIDlet
+            if( packageDataType == ESystemData )
+                {
+                jtt = CSBJavaTransferType::NewL( javaHashPtr, driveNumber, EJavaMIDlet );
+                }
+            //When EPassiveBaseData is requested, request EJavaMIDletData
+            else if( transferDataType == EPassiveBaseData )
+                {
+                jtt = CSBJavaTransferType::NewL( javaHashPtr, driveNumber, EJavaMIDletData );
+                }
+                        
+            if( packageDataType == ESystemData || transferDataType == EPassiveBaseData )
+                {
+                CleanupStack::PushL( jtt );
+                LOGGER_WRITE( "iSBEClient->RequestDataL( jtt ) : start" );
+                TRequestStatus status;
+                iSBEClient->RequestDataL( *jtt, status );
+                User::WaitForRequest( status );
+                LOGGER_WRITE( "iSBEClient->RequestDataL( jtt ) : stop" );
+                
+                LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
+                 status.Int() %d", status.Int() );
+                User::LeaveIfError( status.Int() );
+                            
+                //Get the data and store the handle
+                CSBGenericTransferType* gtt = NULL;
+                LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ) : start" );
+                iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iLastChunk ) );
+                LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ): stop" );
+                LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
+                 Received data size %d", iDataPtr.Length() );
+                LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
+                 Is last chunk %d", iLastChunk );
+                LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
+                 Transfertype %d", 
+                 iCurrentTask->iRequestDataParams->iDataOwner->iTransDataType );
+                 
+                if( gtt )
+                    {
+                    delete gtt;
+                    }
+                 
+                CleanupStack::PopAndDestroy( jtt );   
+                }
+            else
+                {
+                //No data
+                iDataPtr.Set( KNullDesC8 );
+                iLastChunk = ETrue;
+                }
+            }
+        }   
+        
+    TInt dataBufLength = iDataPtr.Length();
+    LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \
+    Data received: %d", dataBufLength );
+    
+    TInt maxLength = iMaxObjectSize - 1024;
+    LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \
+    Max length: %d", maxLength );
+    
+    if( iCurrentTask->iRequestDataParams->iBackupData )
+        {
+        delete iCurrentTask->iRequestDataParams->iBackupData;
+        iCurrentTask->iRequestDataParams->iBackupData = NULL;
+        }
+    
+    //Initialize the task data buffer
+    iCurrentTask->iRequestDataParams->iBackupData = HBufC8::NewL( maxLength );
+    //Get descriptor task's buffer
+    TPtr8 backupDataPtr = iCurrentTask->iRequestDataParams->iBackupData->Des();
+    
+    TInt copyPos = 0;
+    
+    //Copy data to task buffer
+    for( ; iDataPos < dataBufLength && copyPos < maxLength;
+     iDataPos++ )
+        {
+        backupDataPtr.Append( iDataPtr[iDataPos] );
+        copyPos++;
+        }
+        
+    LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \
+    End - copyPos: %d", copyPos );
+    LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \
+    End - iDataPos: %d", iDataPos );
+            
+    //Are there more data left in the buffer
+    if( iDataPos < dataBufLength )
+        {
+        LOGGER_WRITE( "iSBEClient->RequestDataL( stt ) : There is more data in buffer" );
+        iDataLeft = ETrue;
+        iCurrentTask->iRequestDataParams->iMoreData = ETrue;
+        //Another task is needed to transfer the data to the client
+        ret = KErrCompletion;
+        }
+    else
+        {
+        //Check if the backup server has more data from the dataowner
+        if( !iLastChunk )
+            {
+            iCurrentTask->iRequestDataParams->iMoreData = ETrue; 
+            //Another task is needed to transfer the data to the client
+            ret = KErrCompletion;
+            LOGGER_WRITE( "iSBEClient->RequestDataL( stt ) : There are more data available from SBE" );
+            }
+        else
+            {
+            iCurrentTask->iRequestDataParams->iMoreData = EFalse;
+            }
+            
+        iDataPos = 0;   
+        iDataLeft = EFalse; 
+        }
+        
+    LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :  returned %d", ret );
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConSBEClient::ProcessGetDataOwnerStatusL()
+// Executes GetDataOwnerStatus task
+// -----------------------------------------------------------------------------
+//  
+void CSConSBEClient::ProcessGetDataOwnerStatusL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    //If restore-mode, call AllSystemFilesRestored()
+    if( iRestoreMode )
+        {
+        LOGGER_WRITE( "CSConSBEClient::ProcessGetDataOwnerStatusL() : iSBEClient->AllSystemFilesRestored() start" );
+        iSBEClient->AllSystemFilesRestored();
+        LOGGER_WRITE( "CSConSBEClient::ProcessGetDataOwnerStatusL() : iSBEClient->AllSystemFilesRestored() end" );
+        }
+    
+    RSIDStatusArray sidStatus;
+    CleanupClosePushL(sidStatus);
+        
+    for( TInt i = 0; i < iCurrentTask->iGetDataOwnerParams->iDataOwners.Count();
+     i++ )
+        {
+        CSConDataOwner* dataOwner = 
+            iCurrentTask->iGetDataOwnerParams->iDataOwners[i];
+        TSecureId sid( dataOwner->iUid );
+        TDataOwnerStatus dataOwnerStatus = EUnset;
+        TInt dataOwnerError = 0;
+        
+        TDataOwnerAndStatus dataOwnerAndStatus( sid, dataOwnerStatus, 
+            dataOwnerError );
+                
+        sidStatus.Append( dataOwnerAndStatus );
+        }
+    
+    iSBEClient->SIDStatusL( sidStatus );
+    
+    for( TInt j = 0; j < sidStatus.Count(); j++ )
+        {
+        switch( sidStatus[j].iStatus )
+            {
+            case EUnset :
+                iCurrentTask->iGetDataOwnerParams->iDataOwners[j]->
+                iDataOwnStatus = ESConUnset;
+                break;
+            case EDataOwnerNotFound :
+                iCurrentTask->iGetDataOwnerParams->iDataOwners[j]->
+                iDataOwnStatus = ESConNotFound;
+                break;
+            case EDataOwnerReady :
+                iCurrentTask->iGetDataOwnerParams->iDataOwners[j]->
+                iDataOwnStatus = ESConReady;
+                break;
+            case EDataOwnerNotReady :
+                iCurrentTask->iGetDataOwnerParams->iDataOwners[j]->
+                iDataOwnStatus = ESConNotReady;
+                break;
+            case EDataOwnerFailed :
+                iCurrentTask->iGetDataOwnerParams->iDataOwners[j]->
+                iDataOwnStatus = ESConFailed;
+                break;
+            case EDataOwnerNotConnected :
+                iCurrentTask->iGetDataOwnerParams->iDataOwners[j]->
+                iDataOwnStatus = ESConNotConnected;
+                break;
+            case EDataOwnerReadyNoImpl :
+                iCurrentTask->iGetDataOwnerParams->iDataOwners[j]->
+                iDataOwnStatus = ESConNotImplemented;
+                break;
+            default :
+                break;
+            }
+        }
+    sidStatus.Reset();  
+    CleanupStack::PopAndDestroy( &sidStatus );
+
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConSBEClient::ProcessSupplyDataL()
+// Executes SupplyData task
+// -----------------------------------------------------------------------------
+//  
+TInt CSConSBEClient::ProcessSupplyDataL()
+    {
+    TRACE_FUNC_ENTRY;
+    TBool packageData = EFalse;
+    TBool lastChunk = ETrue;
+    TTransferDataType transferDataType( ERegistrationData );
+    TPackageDataType packageDataType( ESystemSnapshotData );    
+    LOGGER_WRITE_1("CSConSBEClient::ProcessSupplyDataL() iTransDataType: %d",
+        (TInt)iCurrentTask->iSupplyDataParams->iDataOwner->iTransDataType);
+    switch( iCurrentTask->iSupplyDataParams->iDataOwner->iTransDataType )
+        {
+        case ESConRegistrationData :
+            transferDataType = ERegistrationData;
+            break;
+        case ESConPassiveSnapshotData :
+            transferDataType = EPassiveSnapshotData;
+            break;
+        case ESConPassiveBaseData :
+            transferDataType = EPassiveBaseData;
+            break;
+        case ESConPassiveIncrementalData :
+            transferDataType = EPassiveIncrementalData;
+            break;
+        case ESConActiveSnapshotData :
+            transferDataType = EActiveSnapshotData;
+            break;
+        case ESConActiveBaseData :
+            transferDataType = EActiveBaseData;
+            break;
+        case ESConActiveIncrementalData :
+            transferDataType = EActiveIncrementalData;
+            break;
+        case ESConSystemData :
+            packageDataType = ESystemData;
+            packageData = ETrue;
+            break;
+        case ESConSystemSnapshotData:
+            packageDataType = ESystemSnapshotData;
+            packageData = ETrue;
+            break;
+        default :
+            break;
+        }
+        
+    //Get the drive number  
+    TDriveNumber driveNumber = EDriveC;
+    TDriveList driveList = iCurrentTask->iSupplyDataParams->iDataOwner->
+        iDriveList;
+    
+    for( TInt i = 0; i < KMaxDrives; i++ )
+        {
+        if( driveList[i] )
+            {
+            driveNumber = GetDriveNumber( i );
+            break;
+            }
+        }
+        
+    //Get UID or SID
+    TUid uid;
+    TSecureId sid;  
+    
+    uid.iUid = 0;
+    sid.iId = 0;
+    
+    if( packageData && !iCurrentTask->iSupplyDataParams->iDataOwner->iJavaHash )
+        {
+        uid = iCurrentTask->iSupplyDataParams->iDataOwner->iUid;
+        LOGGER_WRITE_1( "CSConSBEClient::ProcessSupplyDataL() uid: 0x%08x", uid.iUid );
+        }
+    else if( !iCurrentTask->iSupplyDataParams->iDataOwner->iJavaHash )
+        {
+        sid = iCurrentTask->iSupplyDataParams->iDataOwner->iUid;
+        LOGGER_WRITE_1( "CSConSBEClient::ProcessSupplyDataL() sid: 0x%08x", sid.iId );
+        }
+    
+    
+    if( packageData && !iCurrentTask->iSupplyDataParams->iDataOwner->iJavaHash )
+        {
+        CSBPackageTransferType* ptt = CSBPackageTransferType::NewL( uid, driveNumber, 
+            packageDataType );
+        CleanupStack::PushL( ptt );
+        
+        //Write restore data to chunk
+        LOGGER_WRITE( "iSBEClient->TransferDataAddressL().Copy() : start" );
+        LOGGER_WRITE_1( "CSConSBEClient::ProcessSupplyDataL() :\
+         Received data length: %d", iCurrentTask->iSupplyDataParams->iRestoreData->Length() );
+        iSBEClient->TransferDataAddressL().Copy( iCurrentTask->
+        iSupplyDataParams->iRestoreData->Des() );
+        LOGGER_WRITE( "iSBEClient->TransferDataAddressL().Copy()" );
+        
+        delete iCurrentTask->iSupplyDataParams->iRestoreData;
+        iCurrentTask->iSupplyDataParams->iRestoreData = NULL;
+        
+        //Supply data
+        lastChunk = !( iCurrentTask->iSupplyDataParams->iMoreData );
+        LOGGER_WRITE( "iSBEClient->SupplyDataL( ptt, lastChunk ) : start" );
+        TRequestStatus status;
+        iSBEClient->SupplyDataL( *ptt, lastChunk, status );
+        User::WaitForRequest( status );
+        LOGGER_WRITE( "iSBEClient->SupplyDataL( ptt, lastChunk ) : stop" );
+        
+        User::LeaveIfError( status.Int() );
+        
+        CleanupStack::PopAndDestroy( ptt );
+        }
+    else if( !iCurrentTask->iSupplyDataParams->iDataOwner->iJavaHash )
+        {
+        CSBSIDTransferType* stt = CSBSIDTransferType::NewL( sid, driveNumber, transferDataType );
+        CleanupStack::PushL( stt );
+        
+        //Write restore data to chunk
+        LOGGER_WRITE( "iSBEClient->TransferDataAddressL().Copy() : start" );
+        LOGGER_WRITE_1( "CSConSBEClient::ProcessSupplyDataL() : Received data length: %d",
+         iCurrentTask->iSupplyDataParams->iRestoreData->Length() );
+        iSBEClient->TransferDataAddressL().Copy( iCurrentTask->
+        iSupplyDataParams->iRestoreData->Des() );
+        LOGGER_WRITE( "iSBEClient->TransferDataAddressL().Copy()" );
+        
+        delete iCurrentTask->iSupplyDataParams->iRestoreData;
+        iCurrentTask->iSupplyDataParams->iRestoreData = NULL;
+        
+        //Supply data
+        lastChunk = !( iCurrentTask->iSupplyDataParams->iMoreData );
+        LOGGER_WRITE( "iSBEClient->SupplyDataL( stt, lastChunk ) : start" );
+        TRequestStatus status;
+        iSBEClient->SupplyDataL( *stt, lastChunk, status );
+        User::WaitForRequest( status );
+        LOGGER_WRITE( "iSBEClient->SupplyDataL( stt, lastChunk ) : stop" );
+        
+        User::LeaveIfError( status.Int() );
+        
+        CleanupStack::PopAndDestroy( stt );
+        }
+    else
+        {
+        TPtr javaHashPtr = iCurrentTask->iSupplyDataParams->iDataOwner->iJavaHash->Des();
+        CSBJavaTransferType* jtt( NULL );
+        if( packageDataType == ESystemData )
+            {
+            LOGGER_WRITE( "iSBEClient->SupplyDataL java ESystemData" );
+            jtt = CSBJavaTransferType::NewL( javaHashPtr, driveNumber, EJavaMIDlet );
+            }
+        else if( transferDataType == EPassiveBaseData )
+            {
+            LOGGER_WRITE( "iSBEClient->SupplyDataL java EPassiveBaseData" );
+            jtt = CSBJavaTransferType::NewL( javaHashPtr, driveNumber, EJavaMIDletData );
+            }
+                
+        if( packageDataType == ESystemData || transferDataType == EPassiveBaseData )
+            {
+            CleanupStack::PushL( jtt );
+            //Write restore data to chunk
+            LOGGER_WRITE( "iSBEClient->TransferDataAddressL().Copy() : start" );
+            LOGGER_WRITE_1( "CSConSBEClient::ProcessSupplyDataL() : Received data length: %d",
+             iCurrentTask->iSupplyDataParams->iRestoreData->Length() );
+            iSBEClient->TransferDataAddressL().Copy( iCurrentTask->
+            iSupplyDataParams->iRestoreData->Des() );
+            LOGGER_WRITE( "iSBEClient->TransferDataAddressL().Copy()" );
+            
+            delete iCurrentTask->iSupplyDataParams->iRestoreData;
+            iCurrentTask->iSupplyDataParams->iRestoreData = NULL;
+            
+            //Supply data
+            lastChunk = !( iCurrentTask->iSupplyDataParams->iMoreData );
+            LOGGER_WRITE( "iSBEClient->SupplyDataL( jtt, lastChunk ) : start" );
+            TRequestStatus status;
+            iSBEClient->SupplyDataL( *jtt, lastChunk, status );
+            User::WaitForRequest( status );
+            LOGGER_WRITE( "iSBEClient->SupplyDataL( jtt, lastChunk ) : stop" );
+            
+            User::LeaveIfError( status.Int() );
+            
+            CleanupStack::PopAndDestroy( jtt );
+            }
+        }
+    
+    TInt ret( KErrNone );
+        
+    if( !lastChunk )
+        {
+        ret = KErrCompletion;
+        }
+    
+    LOGGER_WRITE_1( "CSConSBEClient::ProcessSupplyDataL() : returned %d", ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConSBEClient::GetDriveNumber( const TInt& aDrive ) const
+// Maps TInt drive number to TDriveNumber
+// -----------------------------------------------------------------------------
+//  
+TDriveNumber CSConSBEClient::GetDriveNumber( const TInt& aDrive ) const
+    {
+    TDriveNumber driveNumber;
+    switch( aDrive )
+        {
+        case 0 :
+            driveNumber = EDriveA;
+            break;
+        case 1 :
+            driveNumber = EDriveB;
+            break;
+        case 2 : 
+            driveNumber = EDriveC;
+            break;
+        case 3 :
+            driveNumber = EDriveD;
+            break;
+        case 4 : 
+            driveNumber = EDriveE;
+            break;
+        case 5 :
+            driveNumber = EDriveF;
+            break;
+        case 6 :
+            driveNumber = EDriveG;
+            break;
+        case 7 :
+            driveNumber = EDriveH;
+            break;
+        case 8 :
+            driveNumber = EDriveI;
+            break;
+        case 9 :
+            driveNumber = EDriveJ;
+            break;
+        case 10 :
+            driveNumber = EDriveK;
+            break;
+        case 11 :
+            driveNumber = EDriveL;
+            break;
+        case 12 :
+            driveNumber = EDriveM;
+            break;
+        case 13 :
+            driveNumber = EDriveN;
+            break;
+        case 14 :
+            driveNumber = EDriveO;
+            break;
+        case 15 :
+            driveNumber = EDriveP;
+            break;
+        case 16 :
+            driveNumber = EDriveQ;
+            break;
+        case 17 :
+            driveNumber = EDriveR;
+            break;
+        case 18 :
+            driveNumber = EDriveS;
+            break;
+        case 19 :
+            driveNumber = EDriveT;
+            break;
+        case 20 :
+            driveNumber = EDriveU;
+            break;
+        case 21 :
+            driveNumber = EDriveV;
+            break;
+        case 22 :
+            driveNumber = EDriveW;
+            break;
+        case 23 :
+            driveNumber = EDriveX;
+            break;
+        case 24 :
+            driveNumber = EDriveY;
+            break;
+        case 25 :
+            driveNumber = EDriveZ;
+            break;
+        default :
+            driveNumber = EDriveC;
+            break;
+        }
+        
+    return driveNumber;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConSBEClient::FilterDriveList( TDriveList& aDriveList ) const
+// Filters the drive list
+// -----------------------------------------------------------------------------
+//  
+void CSConSBEClient::FilterDriveList( TDriveList& aDriveList ) const
+    {
+    TDriveInfo info;
+    
+    for ( TInt i = 0; i < aDriveList.Length(); i++ )
+        {
+        if ( aDriveList[i] )
+            {
+            iFs.Drive( info, i );
+#ifdef __WINS__
+            if ( i == EDriveD )
+                {
+                LOGGER_WRITE( "EDriveD skipped on WINS build" );
+                aDriveList[i] = '\x0';
+                }
+#else
+            if ( info.iType == EMediaRam )
+                {
+                aDriveList[i] = '\x0';
+                }
+#endif
+            }
+        }
+    
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConSBEClient::Match( const CSConTask& aFirst, const CSConTask& aSecond )
+// Matches the uids
+// -----------------------------------------------------------------------------
+//
+TInt CSConSBEClient::Match( const TUid& aFirst, const TUid& aSecond )
+    {
+    if( aFirst == aSecond )
+        {
+        return ETrue;
+        }
+        
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConSBEClient::HandleSBEErrorL( TInt& aErr )
+// Handle error received from Secure Backup Engine
+// -----------------------------------------------------------------------------
+//  
+void CSConSBEClient::HandleSBEErrorL( TInt& aErr )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( " aErr: %d", aErr );
+    if( aErr == KErrServerTerminated )
+        {
+        LOGGER_WRITE( "Re-connecting to SBE..." );
+        //Session has been terminated, recreate it..
+        delete iSBEClient;
+        iSBEClient = NULL;
+        iSBEClient = CSBEClient::NewL();
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConSBEClient::AppendFilesToFilelistL()
+// Appends files from RFileArray to RPointerArray<CSConFile>
+// -----------------------------------------------------------------------------
+//
+void CSConSBEClient::AppendFilesToFilelistL( const RFileArray& aFiles, RPointerArray<CSConFile>& aSconFiles )
+    {
+    TRACE_FUNC_ENTRY;
+    _LIT( KSConXmlDate, "%F%Y%M%DT%H%T%SZ" );
+    for( TInt j = 0; j < aFiles.Count(); j++ )
+        {
+        CSConFile* fileInfo = new (ELeave) CSConFile();
+        CleanupStack::PushL( fileInfo );
+        fileInfo->iPath = aFiles[j].iName;
+        LOGGER_WRITE_1("file: %S", &fileInfo->iPath );                    
+        
+        fileInfo->iSize = aFiles[j].iSize;
+        
+        switch( aFiles[j].iAtt )
+            {
+            case KEntryAttNormal :
+                fileInfo->iUserPerm = EPermNormal;
+                break;
+            case KEntryAttReadOnly :
+                fileInfo->iUserPerm = EPermReadOnly;
+                break;
+            default :
+                fileInfo->iUserPerm = EPermNormal;
+                break;
+            }
+                        
+        TTime time( aFiles[j].iModified );
+        HBufC* timeBuf = HBufC::NewLC( KMaxTimeFormatSpec );
+        TPtr timePtr = timeBuf->Des();
+        time.FormatL( timePtr, KSConXmlDate );
+
+        fileInfo->iModified.Copy( timePtr );
+
+        CleanupStack::PopAndDestroy( timeBuf );    
+
+        aSconFiles.Append( fileInfo );
+        CleanupStack::Pop( fileInfo );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSConSBEClient::PackageDataSizeL()
+// Gets Package dataowner size
+// -----------------------------------------------------------------------------
+//
+TUint CSConSBEClient::PackageDataSizeL( TUid aPackageId, const TDriveList& aDriveList,
+        TPackageDataType aPackageDataType ) const
+    {
+    TUint dataSize(0);
+    //Ask data size from every drive
+    for( TInt j = 0; j < KMaxDrives; j++ )
+        {
+        if( aDriveList[j] )
+            {
+            CSBPackageTransferType* ptt( NULL );
+            TDriveNumber driveNumber = GetDriveNumber( j );
+            LOGGER_WRITE_1( "Drive %d", driveNumber );
+            ptt = CSBPackageTransferType::NewL( aPackageId, driveNumber, aPackageDataType );
+            CleanupStack::PushL( ptt );
+            //Get the size and store it to a variable
+            TRAPD( err, dataSize += iSBEClient->ExpectedDataSizeL( *ptt ) );
+            CleanupStack::PopAndDestroy( ptt );
+            LOGGER_WRITE_1( "ExpectedDataSizeL returned for package %d", err );
+            if( err != KErrNone && err != KErrNotFound )
+                {
+                LOGGER_WRITE_1( "ExpectedDataSizeL LEAVE %d", err );
+                User::Leave( err );
+                }
+            }
+        }
+    return dataSize;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConSBEClient::SidDataSizeL()
+// Gets Sid (SecureId) dataowner size
+// -----------------------------------------------------------------------------
+//
+TUint CSConSBEClient::SidDataSizeL( TUid aSid, const TDriveList& aDriveList,
+        TTransferDataType aTransferDataType ) const
+    {
+    TUint dataSize(0);
+    //Ask data size from every drive
+    for( TInt j = 0; j < KMaxDrives; j++ )
+        {
+        if( aDriveList[j] )
+            {
+            CSBSIDTransferType* stt( NULL );
+            TDriveNumber driveNumber = GetDriveNumber( j );
+            LOGGER_WRITE_1( "Drive %d", driveNumber );
+            stt = CSBSIDTransferType::NewL( aSid, driveNumber, aTransferDataType );
+            CleanupStack::PushL( stt );
+            //Get the size and store it to a variable
+            TRAPD( err, dataSize += iSBEClient->ExpectedDataSizeL( *stt ) ); 
+            CleanupStack::PopAndDestroy( stt );
+            LOGGER_WRITE_1( "ExpectedDataSizeL returned for DO %d", err );
+            if( err != KErrNone && err != KErrNotFound )
+                {
+                LOGGER_WRITE_1( "ExpectedDataSizeL LEAVE %d", err );
+                User::Leave( err );
+                }
+            }
+        }
+    return dataSize;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConSBEClient::JavaDataSizeL()
+// Gets Java dataowner size
+// -----------------------------------------------------------------------------
+//
+TUint CSConSBEClient::JavaDataSizeL( const TDesC& aJavaHash, const TDriveList& aDriveList ) const
+    {
+    TUint dataSize(0);
+    //Ask data size from every drive
+    for( TInt j = 0; j < KMaxDrives; j++ )
+        {
+        if( aDriveList[j] )
+            {
+            CSBJavaTransferType* jtt( NULL );
+            
+            TDriveNumber driveNumber = GetDriveNumber( j );
+            LOGGER_WRITE_1( "Drive %d", driveNumber );
+            jtt = CSBJavaTransferType::NewL( aJavaHash, 
+                                            driveNumber, 
+                                            EJavaMIDlet );
+            CleanupStack::PushL( jtt );
+            //Get the size and store it to a variable
+            TRAPD( err, dataSize += iSBEClient->ExpectedDataSizeL( *jtt ) ); 
+            CleanupStack::PopAndDestroy( jtt );
+            LOGGER_WRITE_1( "ExpectedDataSizeL returned for Java(EJavaMIDlet) DO %d", err );
+            if( err != KErrNone && err != KErrNotFound )
+                {
+                LOGGER_WRITE_1( "ExpectedDataSizeL LEAVE %d", err );
+                User::Leave( err );
+                }
+            
+            jtt = NULL;
+            jtt = CSBJavaTransferType::NewL( aJavaHash, 
+                                            driveNumber, 
+                                            EJavaMIDletData );
+            CleanupStack::PushL( jtt );
+            //Get the size and store it to a variable
+            TRAP( err, dataSize += iSBEClient->ExpectedDataSizeL( *jtt ) ); 
+            CleanupStack::PopAndDestroy( jtt );
+            LOGGER_WRITE_1( "ExpectedDataSizeL returned for Java(EJavaMIDletData) DO %d", err );
+            if( err != KErrNone && err != KErrNotFound )
+                {
+                LOGGER_WRITE_1( "ExpectedDataSizeL LEAVE %d", err );
+                User::Leave( err );
+                }
+            }
+        }
+    
+    return dataSize;
+    }
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/src/sconvideoparser.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,534 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSConVideoParser implementation
+*
+*/
+
+
+#include <coedef.h> 
+#include <bautils.h>
+#include <imageconversion.h>
+#include "sconvideoparser.h"
+#include "debug.h"
+
+_LIT( KMimeType, "MimeType" );
+_LIT8( KImageEncoderMimeType, "image/jpeg" );
+_LIT( KMimeTypeAudio, "audio/*" );
+_LIT( KMimeTypeVideo, "video/*" );
+
+const TInt KVideoClipTimeout( 10000000 ); // 10 sec.
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::CSConVideoParser()
+// -----------------------------------------------------------------------------
+//
+CSConVideoParser::CSConVideoParser()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::~CSConVideoParser()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSConVideoParser::~CSConVideoParser()
+    {
+    TRACE_FUNC_ENTRY;
+    delete iTimeOut;
+    if ( iVideoClip )
+        {
+        iVideoClip->CancelThumb();
+        }
+    delete iVideoClip;
+    
+    if ( iVideoUtil )
+        {
+        iVideoUtil->Close();
+        }
+    delete iVideoUtil;
+    delete iScreen;
+    iWsSession.Close();
+    
+    delete iThumbnail;
+    delete iVideoMimeType;
+    delete iAudioMimeType;
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::NewLC()
+// -----------------------------------------------------------------------------
+//
+CSConVideoParser* CSConVideoParser::NewLC()
+    {
+    CSConVideoParser* self = new (ELeave)CSConVideoParser();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::ConstructL()
+// Constructor
+// -----------------------------------------------------------------------------
+//
+void CSConVideoParser::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    User::LeaveIfError( iWsSession.Connect() );
+    
+    iScreen = new(ELeave) CWsScreenDevice( iWsSession );
+    iScreen->Construct();
+    
+    RWindowGroup wg( iWsSession );
+    User::LeaveIfError( wg.Construct(reinterpret_cast<TUint32>(&wg), EFalse) );
+    CleanupClosePushL( wg );
+    
+    CWindowGc* gc;
+    User::LeaveIfError( iScreen->CreateContext(gc) );
+    CleanupStack::PushL(gc);
+    
+    RWindow window( iWsSession );
+    User::LeaveIfError( window.Construct(wg, reinterpret_cast<TUint32>(&wg) + 1) );
+    CleanupClosePushL( window );
+    
+    TRect temp(0,0,320,240); // dummy parameter
+    iVideoUtil = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal, EMdaPriorityPreferenceNone, iWsSession, *(iScreen), window, temp, temp);
+    
+    CleanupStack::PopAndDestroy( &window );
+    CleanupStack::PopAndDestroy( gc );
+    CleanupStack::PopAndDestroy( &wg );
+    
+    iTimeOut = CSconTimeOut::NewL( *this );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::OpenFileL( const RFs& aFs, const TDesC& aFileName )
+// Opens video file
+// -----------------------------------------------------------------------------
+//
+void CSConVideoParser::OpenFileL( const RFs& aFs, const TDesC& aFileName )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iVideoUtilReady = EFalse;
+    iVideoClipReady = EFalse;
+    iVideoUtilErr = KErrNone;
+    iVideoClipErr = KErrNone;
+    
+    delete iThumbnail;
+    iThumbnail = NULL;
+    delete iVideoMimeType;
+    iVideoMimeType=NULL;
+    delete iAudioMimeType;
+    iAudioMimeType=NULL;
+    
+    if ( iVideoClip )
+        {
+        iVideoClip->CancelThumb();
+        delete iVideoClip;
+        iVideoClip = NULL;
+        }
+    if ( iVideoUtil )
+        {
+        iVideoUtil->Close();
+        }
+    
+    TBool fileExist = BaflUtils::FileExists( aFs, aFileName );
+    if ( !fileExist )
+        {
+        User::Leave( KErrNotFound );
+        }
+    
+    iVideoClip = CTNEVideoClipInfo::NewL( aFileName, *this );
+    
+    iVideoUtil->OpenFileL( aFileName );
+    
+    
+    LOGGER_WRITE("iWait.Start()");
+    iWait.Start();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::Thumbnail()
+// returns video thumbnail in jpg format
+// -----------------------------------------------------------------------------
+//
+const TDesC8& CSConVideoParser::Thumbnail() const
+    {
+    TRACE_FUNC;
+    if ( !iThumbnail )
+        {
+        return KNullDesC8;
+        }
+    return *iThumbnail;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::VideoFrameRateL()
+// returns video frame rate
+// -----------------------------------------------------------------------------
+//
+TReal32 CSConVideoParser::VideoFrameRateL() const
+    {
+    TRACE_FUNC;
+    if ( !iVideoUtil )
+        {
+        User::Leave( KErrNotReady );
+        }
+    return iVideoUtil->VideoFrameRateL();
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::VideoFrameSizeL()
+// returns video frame size
+// -----------------------------------------------------------------------------
+//
+void CSConVideoParser::VideoFrameSizeL(TSize& aSize) const
+    {
+    TRACE_FUNC;
+    if ( !iVideoUtil )
+        {
+        User::Leave( KErrNotReady );
+        }
+    return iVideoUtil->VideoFrameSizeL( aSize );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::VideoFormatMimeTypeL()
+// returns video format
+// -----------------------------------------------------------------------------
+//
+const TDesC8& CSConVideoParser::VideoFormatMimeTypeL() const 
+    {
+    TRACE_FUNC;
+    if ( !iVideoUtil )
+        {
+        User::Leave( KErrNotReady );
+        }
+    return iVideoUtil->VideoFormatMimeType();
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::VideoBitRateL()
+// returns videostream bitrate
+// -----------------------------------------------------------------------------
+//
+TInt CSConVideoParser::VideoBitRateL() const
+    {
+    TRACE_FUNC;
+    if ( !iVideoUtil )
+        {
+        User::Leave( KErrNotReady );
+        }
+    return iVideoUtil->VideoBitRateL();
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::AudioBitRateL()
+// returns audiostream bitrate
+// -----------------------------------------------------------------------------
+//
+TInt CSConVideoParser::AudioBitRateL() const
+    {
+    TRACE_FUNC;
+    if ( !iVideoUtil )
+        {
+        User::Leave( KErrNotReady );
+        }
+    return iVideoUtil->AudioBitRateL();
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::DurationL()
+// returns video duration in milliseconds
+// -----------------------------------------------------------------------------
+//
+TInt CSConVideoParser::DurationL() const
+    {
+    TRACE_FUNC;
+    if ( !iVideoUtil )
+        {
+        User::Leave( KErrNotReady );
+        }
+    return iVideoUtil->DurationL().Int64()/1000;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::VideoMimeTypeL()
+// returns video mime type
+// -----------------------------------------------------------------------------
+//
+const TDesC& CSConVideoParser::VideoMimeTypeL()
+    {
+    TRACE_FUNC;
+    if ( !iVideoUtil )
+        {
+        User::Leave( KErrNotReady );
+        }
+    delete iVideoMimeType;
+    iVideoMimeType = NULL;
+    
+    TInt metadataEntries = iVideoUtil->NumberOfMetaDataEntriesL();
+    LOGGER_WRITE_1( "metadataEntries: %d", metadataEntries);
+    
+    for (TInt i=0; i < metadataEntries ; i++)
+        {
+        CMMFMetaDataEntry* entry = iVideoUtil->MetaDataEntryL(i);
+        CleanupStack::PushL( entry );
+        if ( entry->Name().Compare( KMimeType ) == 0 )
+            {
+            if ( entry->Value().MatchF( KMimeTypeVideo ) == 0 )
+                {
+                LOGGER_WRITE_1( "video mimetype found: %S", &entry->Value());
+                iVideoMimeType = HBufC::NewL(entry->Value().Length());
+                TPtr videoMimeTypePtr = iVideoMimeType->Des();
+                videoMimeTypePtr.Copy( entry->Value() );
+                CleanupStack::PopAndDestroy( entry );
+                return *iVideoMimeType;
+                }
+            }
+        CleanupStack::PopAndDestroy( entry );
+        }
+    return KNullDesC;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::AudioMimeTypeL()
+// returns audio mime type
+// -----------------------------------------------------------------------------
+//
+const TDesC& CSConVideoParser::AudioMimeTypeL()
+    {
+    TRACE_FUNC;
+    if ( !iVideoUtil )
+        {
+        User::Leave( KErrNotReady );
+        }
+    delete iAudioMimeType;
+    iAudioMimeType = NULL;
+    TInt metadataEntries = iVideoUtil->NumberOfMetaDataEntriesL();
+    LOGGER_WRITE_1( "metadataEntries: %d", metadataEntries);
+    
+    for (TInt i=0; i < metadataEntries ; i++)
+        {
+        CMMFMetaDataEntry* entry = iVideoUtil->MetaDataEntryL(i);
+        CleanupStack::PushL( entry );
+        
+        if ( entry->Name().Compare( KMimeType ) == 0 )
+            {
+            if ( entry->Value().MatchF( KMimeTypeAudio ) == 0 )
+                {
+                LOGGER_WRITE_1( "video mimetype found: %S", &entry->Value());
+                iAudioMimeType = HBufC::NewL(entry->Value().Length());
+                TPtr audioMimeTypePtr = iAudioMimeType->Des();
+                audioMimeTypePtr.Copy( entry->Value() );
+                CleanupStack::PopAndDestroy( entry );
+                return *iAudioMimeType;
+                }
+            }
+        CleanupStack::PopAndDestroy( entry );
+        }
+    return KNullDesC;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::MvpuoOpenComplete( TInt aError )
+// MVideoPlayerUtilityObserver implementation
+// -----------------------------------------------------------------------------
+//
+void CSConVideoParser::MvpuoOpenComplete( TInt aError )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aError: %d", aError );
+    if ( aError == KErrNone )
+        {
+        iVideoUtil->Prepare();
+        }
+    else
+        {
+        iVideoUtilReady = ETrue;
+        iVideoUtilErr = aError;
+        }
+    
+    if ( iVideoUtilReady && iVideoClipReady )
+        {
+        LOGGER_WRITE("AsyncStop");
+        iWait.AsyncStop();
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::MvpuoPrepareComplete( TInt aError )
+// MVideoPlayerUtilityObserver implementation
+// -----------------------------------------------------------------------------
+//
+void CSConVideoParser::MvpuoPrepareComplete( TInt aError )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aError: %d", aError );
+    
+    iVideoUtilReady = ETrue;
+    iVideoUtilErr = aError;
+    
+    if ( iVideoUtilReady && iVideoClipReady )
+        {
+        LOGGER_WRITE("AsyncStop");
+        iWait.AsyncStop();
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::MvpuoFrameReady()
+// MVideoPlayerUtilityObserver implementation
+// -----------------------------------------------------------------------------
+//
+void CSConVideoParser::MvpuoFrameReady( CFbsBitmap& /*aFrame*/,TInt /*aError*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::MvpuoPlayComplete()
+// MVideoPlayerUtilityObserver implementation
+// -----------------------------------------------------------------------------
+//
+void CSConVideoParser::MvpuoPlayComplete( TInt /*aError*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::MvpuoEvent()
+// MVideoPlayerUtilityObserver implementation
+// -----------------------------------------------------------------------------
+//
+void CSConVideoParser::MvpuoEvent( const TMMFEvent& /*aEvent*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::NotifyVideoClipInfoReady(CTNEVideoClipInfo& aInfo, TInt aError)
+// MTNEVideoClipInfoObserver implementation
+// -----------------------------------------------------------------------------
+//
+void CSConVideoParser::NotifyVideoClipInfoReady(CTNEVideoClipInfo& aInfo, TInt aError)
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aError: %d", aError);
+    if ( aError == KErrNone )
+        {
+        TSize resolution(320,240);
+        TRAPD( err, aInfo.GetThumbL(*this,KBestThumbIndex, &resolution ) );
+        
+        if ( err )
+            {
+            LOGGER_WRITE_1("aInfo.GetThumbL err: %d", err);
+            iVideoClipReady = ETrue;
+            iVideoClipErr = err;
+            }
+        else
+            {
+            LOGGER_WRITE("Start timeout");
+            iTimeOut->Start( KVideoClipTimeout );
+            }
+        }
+    else
+        {
+        iVideoClipReady = ETrue;
+        iVideoClipErr = aError;
+        }
+    
+    if ( iVideoUtilReady && iVideoClipReady )
+        {
+        LOGGER_WRITE("AsyncStop");
+        iWait.AsyncStop();
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::NotifyVideoClipThumbCompleted()
+// MTNEVideoClipInfoObserver implementation
+// -----------------------------------------------------------------------------
+//
+void CSConVideoParser::NotifyVideoClipThumbCompleted(CTNEVideoClipInfo& /*aInfo*/, 
+        TInt aError, 
+        CFbsBitmap* aThumb)
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aError: %d", aError);
+    iTimeOut->Cancel();
+    if ( aError == KErrNone)
+        {
+        delete iThumbnail;
+        iThumbnail = NULL;
+        LOGGER_WRITE("create CImageEncoder");
+        CImageEncoder* encoder = NULL;
+        TRAPD( err, encoder = CImageEncoder::DataNewL( iThumbnail, KImageEncoderMimeType, CImageEncoder::EOptionAlwaysThread ) );
+        LOGGER_WRITE_1("err: %d", err );
+        if ( err == KErrNone )
+            {
+            LOGGER_WRITE("Start Convert");
+            TRequestStatus status;
+            encoder->Convert( &status, *aThumb, NULL );
+            
+            User::WaitForRequest( status );
+            LOGGER_WRITE_1("Convert status: %d", status.Int());
+            LOGGER_WRITE_1("buf Length: %d", iThumbnail->Length());
+            err = status.Int();
+            }
+        delete encoder;
+        }
+    delete aThumb;
+    iVideoClipReady = ETrue;
+    iVideoClipErr = aError;
+    
+    if ( iVideoUtilReady && iVideoClipReady )
+        {
+        LOGGER_WRITE("AsyncStop");
+        iWait.AsyncStop();
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConVideoParser::TimeOut()
+// Called when timeout has occured, cancels videoclip generation
+// -----------------------------------------------------------------------------
+//
+void CSConVideoParser::TimeOut()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( !iVideoClipReady )
+        {
+        iVideoClip->CancelThumb();
+        LOGGER_WRITE("videoclip cancelled");
+        iVideoClipReady = ETrue;
+        iVideoClipErr = KErrCancel;
+        }
+    
+    if ( iVideoUtilReady && iVideoClipReady )
+        {
+        LOGGER_WRITE("AsyncStop");
+        iWait.AsyncStop();
+        }
+    TRACE_FUNC_EXIT;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/bld/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser and generator
+*	 This file provides the information required for building the
+*    whole of a SConConMLHandler
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT 
+
+PRJ_MMPFILES
+sconconmlhandler.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/bld/def/bwinscwu.def	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?CreateCSConConMLHandlerL@@YAPAVCSConConMLHandler@@XZ @ 1 NONAME ; class CSConConMLHandler * CreateCSConConMLHandlerL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/bld/def/eabiu.def	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,7 @@
+EXPORTS
+	_Z24CreateCSConConMLHandlerLv @ 1 NONAME
+	_ZTI13CXMLWorkspace @ 2 NONAME ; #<TI>#
+	_ZTI17CSConConMLHandler @ 3 NONAME ; #<TI>#
+	_ZTV13CXMLWorkspace @ 4 NONAME ; #<VT>#
+	_ZTV17CSConConMLHandler @ 5 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/bld/sconconmlhandler.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML Parser and generator
+*
+*/
+
+
+// To get the MW_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+
+VENDORID        VID_DEFAULT
+CAPABILITY      CAP_GENERAL_DLL
+
+TARGETPATH      sys/bin
+
+TARGET          sconconmlhandler.dll
+TARGETTYPE      DLL
+UID             0x10009D8D 0x101F99FA
+
+#if defined(ARMCC)
+DEFFILE	./def/eabi
+#elif defined(WINSCW) 
+DEFFILE	./def/bwinscw
+#elif defined(WINS)
+DEFFILE	./def/bwins
+#elif defined(ARM)
+DEFFILE	./def/bmarm
+#endif
+
+SOURCEPATH      ../src
+SOURCE          sconconmlhandler.cpp
+SOURCE          sconxmlelement.cpp
+SOURCE          sconconmlgenerator.cpp
+SOURCE          sconconmldtd.cpp
+SOURCE          sconxmlworkspace.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/libc 
+
+LANG            SC
+
+LIBRARY         euser.lib
+LIBRARY         estor.lib
+DEBUGLIBRARY    flogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconconmldtd.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,750 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser/generator
+*
+*/
+
+
+#ifndef __SCONCONMLDTD_H__
+#define __SCONCONMLDTD_H__
+
+#include "sconxmlelement.h"
+
+typedef void *voidPtr_t;
+typedef long memSize_t;
+
+typedef enum 
+    {
+    SML_PCDATA_UNDEFINED = 0,
+    SML_PCDATA_STRING,                   // String type
+    SML_PCDATA_OPAQUE,                   // Opaque type
+    SML_PCDATA_EXTENSION,                // Extention type
+    SML_PCDATA_CDATA                     // XML CDATA type   
+    } pcdataType_t;
+
+typedef enum 
+    {
+    SML_EXT_UNDEFINED = 0,
+    } pcdataExtension_t;
+
+// -----------------------------------------------------------------------------
+// GenericListAddL
+// -----------------------------------------------------------------------------
+template<class T>
+void GenericListAddL( T* aList, T aNewItem )
+    {
+    if( *aList == 0 )
+        {
+        *aList = aNewItem;
+        }
+    else
+        {
+        T c;
+        for( c = *aList; c->next; c = c->next )
+            {}; 
+        c->next = aNewItem;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// pcdata_s
+// -----------------------------------------------------------------------------
+typedef NONSHARABLE_STRUCT( pcdata_s ) : public CXMLElement
+    {
+public:
+    pcdataType_t      contentType;   // The type of data 
+    pcdataExtension_t  extension;     // PCData Extension type
+    memSize_t             length;        // length of the data 
+    voidPtr_t             content;       // Pointer to the data itself
+public:
+    pcdata_s();
+    ~pcdata_s();
+    pcdata_s( const pcdataType_t aType, 
+        const pcdataExtension_t aExt =  SML_EXT_UNDEFINED );
+    void FreeContent();
+    void SetDataL( const TDesC8& aData );
+    TPtrC8 Data() const;
+    void TruncateL( TInt aConsumed );
+    } *pcdataPtr_t, pcdata_t;
+
+// -----------------------------------------------------------------------------
+// pcdata_list_s
+// -----------------------------------------------------------------------------
+typedef NONSHARABLE_STRUCT( pcdata_list_s ) : public CBase
+    {
+    pcdataPtr_t data;
+    struct pcdata_list_s *next;
+
+    pcdata_list_s();
+    ~pcdata_list_s();
+    } *pcdataListPtr_t, pcdataList_t;
+
+// -----------------------------------------------------------------------------
+// ConML_Param_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_Param_s ) : public CXMLElement
+    {
+public:
+    pcdataPtr_t name;
+    pcdataPtr_t value;
+public:
+    ConML_Param_s();
+    ~ConML_Param_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );    
+    }*ConML_ParamPtr_t, ConML_Param_t;
+
+// -----------------------------------------------------------------------------
+// ConML_ParamList_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_ParamList_s ) : public CBase
+    {
+public:
+    ConML_ParamPtr_t data;
+    struct ConML_ParamList_s *next;
+public:
+    ConML_ParamList_s();
+    ~ConML_ParamList_s();
+    }*ConML_ParamListPtr_t, ConML_ParamList_t;  
+    
+// -----------------------------------------------------------------------------
+// ConML_InstParams_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_InstParams_s ) : public CXMLElement
+    {
+public:
+    ConML_ParamListPtr_t param;
+public:
+    ConML_InstParams_s();
+    ~ConML_InstParams_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_InstParamsPtr_t, ConML_InstParams_t;
+
+// -----------------------------------------------------------------------------
+// ConML_Progress_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_Progress_s ) : public CXMLElement
+    {
+public:
+    pcdataPtr_t value;
+public:
+    ConML_Progress_s();
+    ~ConML_Progress_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );    
+    }*ConML_ProgressPtr_t, ConML_Progress_t;
+
+// -----------------------------------------------------------------------------
+// ConML_Application_s
+// -----------------------------------------------------------------------------        
+typedef NONSHARABLE_STRUCT( ConML_Application_s ) : public CXMLElement
+    {
+public:
+    pcdataPtr_t name;
+    pcdataPtr_t uid;
+public:
+    ConML_Application_s();
+    ~ConML_Application_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_ApplicationPtr_t, ConML_Application_t;
+
+// -----------------------------------------------------------------------------
+// ConML_ApplicationList_s
+// -----------------------------------------------------------------------------        
+    
+typedef NONSHARABLE_STRUCT( ConML_ApplicationList_s ) : public CBase
+    {
+public:
+    ConML_ApplicationPtr_t data;
+    struct ConML_ApplicationList_s *next;
+public:
+    ConML_ApplicationList_s();
+    ~ConML_ApplicationList_s();
+    }*ConML_ApplicationListPtr_t, ConML_ApplicationList_t;
+
+// -----------------------------------------------------------------------------
+// ConML_Applications_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_Applications_s ) : public CXMLElement
+    {
+public:
+    ConML_ApplicationListPtr_t application;
+    
+public:
+    ConML_Applications_s();
+    ~ConML_Applications_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_ApplicationsPtr_t, ConML_Applications_t;
+
+// -----------------------------------------------------------------------------
+// ConML_Drive_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_Drive_s ) : public CXMLElement
+    {
+public:
+    pcdataPtr_t name;
+public:
+    ConML_Drive_s();
+    ~ConML_Drive_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_DrivePtr_t, ConML_Drive_t;
+
+// -----------------------------------------------------------------------------
+// ConML_DriveList_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_DriveList_s ) : public CBase
+    {
+public:
+    ConML_DrivePtr_t data;
+    struct ConML_DriveList_s *next;
+public:
+    ConML_DriveList_s();
+    ~ConML_DriveList_s();
+    }*ConML_DriveListPtr_t, ConML_DriveList_t;
+    
+// -----------------------------------------------------------------------------
+// ConML_Drives_s
+// -----------------------------------------------------------------------------        
+typedef NONSHARABLE_STRUCT( ConML_Drives_s ) : public CXMLElement
+    {
+public:
+    ConML_DriveListPtr_t drive;
+public:
+    ConML_Drives_s();
+    ~ConML_Drives_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_DrivesPtr_t, ConML_Drives_t;
+
+// -----------------------------------------------------------------------------
+// ConML_BUROptions_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_BUROptions_s ) : public CXMLElement
+    {
+public:
+    pcdataPtr_t requiresReboot;
+    pcdataPtr_t hasFiles;
+    pcdataPtr_t supportsInc;
+    pcdataPtr_t delayToPrepareData;
+public:
+    ConML_BUROptions_s();
+    ~ConML_BUROptions_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_BUROptionsPtr_t, ConML_BUROptions_t;
+
+// -----------------------------------------------------------------------------
+// ConML_PackageInfo_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_PackageInfo_s ) : public CXMLElement
+    {
+public:
+    pcdataPtr_t name;
+public:
+    ConML_PackageInfo_s();
+    ~ConML_PackageInfo_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_PackageInfoPtr_t, ConML_PackageInfo_t;
+
+// -----------------------------------------------------------------------------
+// ConML_SID_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_SID_s ) : public CXMLElement
+    {
+public:
+    pcdataPtr_t type;
+    pcdataPtr_t uid;
+    ConML_DrivesPtr_t drives;
+    ConML_PackageInfoPtr_t packageInfo;
+    ConML_BUROptionsPtr_t burOptions;
+    pcdataPtr_t size;
+    pcdataPtr_t transferDataType;
+    pcdataPtr_t data;
+    pcdataPtr_t moreData;
+    pcdataPtr_t dataOwnerStatus;
+    
+public:
+    ConML_SID_s();
+    ~ConML_SID_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );    
+    }*ConML_SIDPtr_t, ConML_SID_t;
+
+// -----------------------------------------------------------------------------
+// ConML_SIDList_s
+// -----------------------------------------------------------------------------
+typedef NONSHARABLE_STRUCT( ConML_SIDList_s ) : public CBase
+    {
+public:
+    ConML_SIDPtr_t data;
+    struct ConML_SIDList_s *next;
+public:
+    ConML_SIDList_s();
+    ~ConML_SIDList_s();
+    }*ConML_SIDListPtr_t, ConML_SIDList_t;
+    
+// -----------------------------------------------------------------------------
+// ConML_SupportedMethods_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_SupportedMethods_s ) : public CXMLElement
+    {
+public:
+    pcdataPtr_t install;
+    pcdataPtr_t unInstall;
+    pcdataPtr_t setInstParams;
+    pcdataPtr_t listInstalledApps;
+    pcdataPtr_t listDataOwners;
+    pcdataPtr_t setBurMode;
+    pcdataPtr_t getDataSize;
+    pcdataPtr_t requestData;
+    pcdataPtr_t supplyData;
+    pcdataPtr_t reboot;
+public:
+    ConML_SupportedMethods_s();
+    ~ConML_SupportedMethods_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_SupportedMethodsPtr_t, ConML_SupportedMethods_t;
+    
+// -----------------------------------------------------------------------------
+// ConML_DeviceInfo_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_DeviceInfo_s ) : public CXMLElement
+        {
+public:
+    pcdataPtr_t version;
+    ConML_SupportedMethodsPtr_t supportedMethods;
+    pcdataPtr_t maxObjectSize;
+public:
+    ConML_DeviceInfo_s();
+    ~ConML_DeviceInfo_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );    
+    }*ConML_DeviceInfoPtr_t, ConML_DeviceInfo_t;
+
+// -----------------------------------------------------------------------------
+// ConML_File_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_File_s ) : public CXMLElement
+    {
+public:
+    pcdataPtr_t name;
+    pcdataPtr_t modified;
+    pcdataPtr_t size;
+    pcdataPtr_t userPerm;
+public:
+    ConML_File_s();
+    ~ConML_File_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );    
+    }*ConML_FilePtr_t, ConML_File_t;
+
+// -----------------------------------------------------------------------------
+// ConML_FileList_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_FileList_s ) : public CBase
+    {
+public:
+    ConML_FilePtr_t data;
+    struct ConML_FileList_s *next;
+public:
+    ConML_FileList_s();
+    ~ConML_FileList_s();
+    }*ConML_FileListPtr_t, ConML_FileList_t;
+
+// -----------------------------------------------------------------------------
+// ConML_Files_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_Files_s ) : public CXMLElement
+    {
+public:
+    ConML_FileListPtr_t  file;
+public:
+    ConML_Files_s();
+    ~ConML_Files_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_FilesPtr_t, ConML_Files_t;
+    
+// -----------------------------------------------------------------------------
+// ConML_DataOwners_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_DataOwners_s ) : public CXMLElement
+    {
+public:
+    ConML_SIDListPtr_t sid;
+public:
+    ConML_DataOwners_s();
+    ~ConML_DataOwners_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );    
+    }*ConML_DataOwnersPtr_t, ConML_DataOwners_t;
+
+// -----------------------------------------------------------------------------
+// ConML_Results_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_Results_s ) : public CXMLElement
+    {
+public:
+    pcdataPtr_t complete;
+    ConML_ProgressPtr_t  progress;
+    ConML_ApplicationsPtr_t applications;
+    ConML_DataOwnersPtr_t dataOwners;
+    pcdataPtr_t filename;
+    pcdataPtr_t moreData;
+    pcdataPtr_t data;
+    ConML_DeviceInfoPtr_t deviceInfo;
+    ConML_FilesPtr_t files; 
+public:
+    ConML_Results_s();
+    ~ConML_Results_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );    
+    }*ConML_ResultsPtr_t, ConML_Results_t;
+
+// -----------------------------------------------------------------------------
+// ConML_Install_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_Install_s ) : public CXMLElement
+    {
+public:
+    pcdataPtr_t name;
+    ConML_InstParamsPtr_t  instParams;
+    ConML_ResultsPtr_t results; 
+public:
+    ConML_Install_s();
+    ~ConML_Install_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_InstallPtr_t, ConML_Install_t;
+
+// -----------------------------------------------------------------------------
+// ConML_UnInstall_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_UnInstall_s ) : public CXMLElement
+    {
+public:
+    ConML_ApplicationsPtr_t applications;
+    ConML_InstParamsPtr_t instParams;
+    ConML_ResultsPtr_t results;
+public:
+    ConML_UnInstall_s();
+    ~ConML_UnInstall_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_UnInstallPtr_t, ConML_UnInstall_t;
+
+// -----------------------------------------------------------------------------
+// ConML_ListInstalledApps_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_ListInstalledApps_s ) : public CXMLElement
+    {
+public:
+    ConML_DrivesPtr_t drives;
+    pcdataPtr_t all;
+    ConML_ResultsPtr_t results;
+public:
+    ConML_ListInstalledApps_s();
+    ~ConML_ListInstalledApps_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_ListInstalledAppsPtr_t, ConML_ListInstalledApps_t;
+    
+// -----------------------------------------------------------------------------
+// ConML_ListDataOwners_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_ListDataOwners_s ) : public CXMLElement
+    {
+public:
+    ConML_ResultsPtr_t results;
+public:
+    ConML_ListDataOwners_s();
+    ~ConML_ListDataOwners_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_ListDataOwnersPtr_t, ConML_ListDataOwners_t;
+
+// -----------------------------------------------------------------------------
+// ConML_SetBURMode_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_SetBURMode_s ) : public CXMLElement
+    {
+public:
+    ConML_DrivesPtr_t drives;
+    pcdataPtr_t partialType;
+    pcdataPtr_t incType;
+    ConML_ResultsPtr_t results;
+public:
+    ConML_SetBURMode_s();
+    ~ConML_SetBURMode_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_SetBURModePtr_t, ConML_SetBURMode_t;
+
+// -----------------------------------------------------------------------------
+// ConML_GetDataSize_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_GetDataSize_s ) : public CXMLElement
+    {
+public:
+    ConML_DataOwnersPtr_t dataOwners;
+    ConML_ResultsPtr_t results;
+public:
+    ConML_GetDataSize_s();
+    ~ConML_GetDataSize_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_GetDataSizePtr_t, ConML_GetDataSize_t;
+
+// -----------------------------------------------------------------------------
+// ConML_RequestData_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_RequestData_s ) : public CXMLElement
+    {
+public:
+    ConML_SIDListPtr_t sid;
+    ConML_ResultsPtr_t results;
+public:
+    ConML_RequestData_s();
+    ~ConML_RequestData_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_RequestDataPtr_t, ConML_RequestData_t;
+
+// -----------------------------------------------------------------------------
+// ConML_UpdateDeviceInfo_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_UpdateDeviceInfo_s ) : public CXMLElement
+    {
+public:
+    ConML_DeviceInfoPtr_t deviceInfo;
+    ConML_ResultsPtr_t results;
+public:
+    ConML_UpdateDeviceInfo_s();
+    ~ConML_UpdateDeviceInfo_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );    
+    }*ConML_UpdateDeviceInfoPtr_t, ConML_UpdateDeviceInfo_t;
+
+// -----------------------------------------------------------------------------
+// ConML_ListPublicFiles_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_ListPublicFiles_s ) : public CXMLElement
+    {
+public:
+    ConML_ResultsPtr_t results;
+    ConML_SIDListPtr_t sid;
+public:
+    ConML_ListPublicFiles_s();
+    ~ConML_ListPublicFiles_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );    
+    }*ConML_ListPublicFilesPtr_t, ConML_ListPublicFiles_t;
+
+// -----------------------------------------------------------------------------
+// ConML_SupplyData_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_SupplyData_s ) : public CXMLElement
+    {
+public:
+    ConML_SIDListPtr_t sid;
+    ConML_ResultsPtr_t results;
+public:
+    ConML_SupplyData_s();
+    ~ConML_SupplyData_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_SupplyDataPtr_t, ConML_SupplyData_t;
+
+// -----------------------------------------------------------------------------
+// ConML_GetDataOwnerStatus_s
+// -----------------------------------------------------------------------------        
+typedef NONSHARABLE_STRUCT( ConML_GetDataOwnerStatus_s ) : public CXMLElement
+    {
+public:
+    ConML_DataOwnersPtr_t dataOwners;
+    ConML_ResultsPtr_t results;
+public:
+    ConML_GetDataOwnerStatus_s();
+    ~ConML_GetDataOwnerStatus_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_GetDataOwnerStatusPtr_t, ConML_GetDataOwnerStatus_t;
+
+// -----------------------------------------------------------------------------
+// ConML_GetMetadata_s
+// -----------------------------------------------------------------------------
+typedef NONSHARABLE_STRUCT( ConML_GetMetadata_s ) : public CXMLElement
+    {
+public:
+    pcdataPtr_t filename;
+    ConML_ResultsPtr_t results;
+public:
+    ConML_GetMetadata_s();
+    ~ConML_GetMetadata_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_GetMetadataPtr_t, ConML_GetMetadata_t;
+
+// -----------------------------------------------------------------------------
+// ConML_Execute_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_Execute_s ) : public CXMLElement
+    {
+public:
+    pcdataPtr_t id;
+    ConML_InstallPtr_t install;
+    ConML_UnInstallPtr_t  unInstall;
+    ConML_ListInstalledAppsPtr_t listInstalledApps;
+    ConML_ListDataOwnersPtr_t listDataOwners;
+    ConML_SetBURModePtr_t setBurMode;
+    ConML_GetDataSizePtr_t getDataSize;
+    ConML_RequestDataPtr_t requestData;
+    ConML_UpdateDeviceInfoPtr_t updateDeviceInfo;
+    ConML_ListPublicFilesPtr_t listPublicFiles;
+    ConML_SupplyDataPtr_t supplyData;
+    pcdataPtr_t reboot;
+    ConML_GetDataOwnerStatusPtr_t getDataOwnerStatus;
+    ConML_GetMetadataPtr_t getMetadata;
+public:
+    ConML_Execute_s();
+    ~ConML_Execute_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_ExecutePtr_t, ConML_Execute_t;
+    
+// -----------------------------------------------------------------------------
+// ConML_GetStatus_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_GetStatus_s ) : public CXMLElement
+    {
+public:
+    pcdataPtr_t id;
+    pcdataPtr_t all;
+public:
+    ConML_GetStatus_s();
+    ~ConML_GetStatus_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_GetStatusPtr_t, ConML_GetStatus_t;
+
+// -----------------------------------------------------------------------------
+// ConML_Cancel_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_Cancel_s ) : public CXMLElement
+    {
+public:
+    pcdataPtr_t id;
+    pcdataPtr_t all;
+public:
+    ConML_Cancel_s();
+    ~ConML_Cancel_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_CancelPtr_t, ConML_Cancel_t;
+
+// -----------------------------------------------------------------------------
+// ConML_Reboot_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_Reboot_s ) : public CXMLElement
+    {
+public:
+    ConML_ResultsPtr_t results;
+public:
+    ConML_Reboot_s();
+    ~ConML_Reboot_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    }*ConML_RebootPtr_t, ConML_Reboot_t;
+    
+// -----------------------------------------------------------------------------
+// ConML_Task_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_Task_s ) : public CXMLElement
+    {
+public:
+    pcdataPtr_t id;
+    ConML_InstallPtr_t install;
+    ConML_UnInstallPtr_t unInstall;
+    ConML_ListInstalledAppsPtr_t listInstalledApps;
+    ConML_ListDataOwnersPtr_t listDataOwners;
+    ConML_SetBURModePtr_t setBurMode;
+    ConML_GetDataSizePtr_t getDataSize;
+    ConML_RequestDataPtr_t requestData;
+    ConML_UpdateDeviceInfoPtr_t updateDeviceInfo;
+    ConML_ListPublicFilesPtr_t listPublicFiles;
+    ConML_GetDataOwnerStatusPtr_t getDataOwnerStatus;
+    ConML_SupplyDataPtr_t supplyData;
+    ConML_RebootPtr_t reboot;
+    ConML_GetMetadataPtr_t getMetadata;
+public:
+    ConML_Task_s();
+    ~ConML_Task_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );    
+    }*ConML_TaskPtr_t, ConML_Task_t;
+
+// -----------------------------------------------------------------------------
+// ConML_TaskList_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_TaskList_s ) : public CBase
+    {
+public:
+    ConML_TaskPtr_t data;
+    struct ConML_TaskList_s *next;
+public:
+    ConML_TaskList_s();
+    ~ConML_TaskList_s();
+    }*ConML_TaskListPtr_t, ConML_TaskList_t;
+
+// -----------------------------------------------------------------------------
+// ConML_Status_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_Status_s ) : public CXMLElement
+    {
+public:
+    ConML_TaskListPtr_t task;
+public:
+    ConML_Status_s();
+    ~ConML_Status_s();
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );    
+    }*ConML_StatusPtr_t, ConML_Status_t;
+
+// -----------------------------------------------------------------------------
+// ConML_ConML_s
+// -----------------------------------------------------------------------------    
+typedef NONSHARABLE_STRUCT( ConML_ConML_s ) : public CXMLElement
+    {
+public:
+    ConML_ExecutePtr_t execute;
+    ConML_GetStatusPtr_t getStatus;
+    ConML_CancelPtr_t cancel;
+    ConML_StatusPtr_t status;   
+        
+public:
+    ConML_ConML_s();
+    ~ConML_ConML_s();
+    TBool NeedsCleanup() const;
+    CXMLElement* BeginElementL
+        ( TUint8 aTag, const TXMLElementParams& aParams = TXMLElementParams() );
+    CXMLElement::TAction EndElementL( TAny* aCallbacks, TUint8 aTag );
+    } *ConML_ConMLPtr_t, ConML_ConML_t;
+                                                                                    
+#endif // __SCONCONMLDTD_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconconmlgenerator.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,232 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser/generator
+*
+*/
+
+
+#ifndef __SCONCONMLGENERATOR_H__
+#define __SCONCONMLGENERATOR_H__
+
+// -----------------------------------------------------------------------------
+// Includes
+// -----------------------------------------------------------------------------
+#include "sconxmlelement.h"
+#include "sconconmldtd.h"
+#include "sconconmltags.h"
+#include "sconwbxmldefs.h"
+#include "sconxmlworkspace.h"
+
+// -----------------------------------------------------------------------------
+// MWBXMLConMLCallback - Call back for parsed data
+// -----------------------------------------------------------------------------
+class MWBXMLConMLCallback
+    {
+public:
+     /**
+    * Call back function for delivering the parsed data
+    * @param aContent contains the parsed data
+    * @return none
+    */
+
+    virtual void ConMLL( ConML_ConMLPtr_t aContent ) = 0;
+    };
+
+// -----------------------------------------------------------------------------
+// TWBXMLContentFormat
+// -----------------------------------------------------------------------------
+enum TWBXMLContentFormat
+    {
+    EWBXMLContentFormatOpaque,
+    EWBXMLContentFormatInlineString
+    };
+    
+// -----------------------------------------------------------------------------
+// CSConConMLGenerator - Generates XBXML and XML documents
+// -----------------------------------------------------------------------------
+NONSHARABLE_CLASS( CSConConMLGenerator ) : public CBase
+    {
+public:
+
+    static CSConConMLGenerator* NewL();
+    ~CSConConMLGenerator();
+        
+    /**
+    * Returns the generated WBXML document
+    * @param none 
+    * @return the document as TPtrC8
+    */
+    TPtrC8 WBXMLDocument();
+
+    /**
+    * Returns the generated XML document
+    * @param none 
+    * @return the document as TPtrC8
+    */
+    TPtrC8 XMLDocument();
+    
+    
+    // WBXML Parser
+    
+    /**
+    * Sets the callback function to call after parsing
+    * @param aCallback callback function to call when parsing finished
+    * @return none
+    */
+    void SetCallback ( MWBXMLConMLCallback* aCallbakc );
+    
+    /**
+    * Starts the document after header has been parsed 
+    * @param aVersion - version of WBXML document
+    * @param aPublicId - public ID of WBXML document as known public ID
+    * @param aCharset - Character set of WBXML document
+    * @return none
+    */
+    void StartDocument( TUint8 aVersion, TInt32 aPublicId, TUint32 aCharset );
+
+    /**
+    * Starts the document after header has been parsed 
+    * @param aVersion - version of WBXML document
+    * @param aPublicIdStr - public ID of WBXML document as a inline string 
+    * @param aCharset - Character set of WBXML document
+    * @return none
+    */
+    void StartDocument( 
+        TUint8 aVersion, const TDesC8& aPublicIdStr, TUint32 aCharset );
+    
+    /**
+    * Starts a new element in the document
+    * @param aTag - Tag of the element
+    * @return none
+    */
+    void StartElementL( TWBXMLTag aTag );
+
+    /**
+    * Starts a character data in the document
+    * @param aBuffer - Character data
+    * @return none
+    */
+    void CharactersL( const TDesC8& aBuffer );
+
+    /**
+    * Document has been parsed - the end of document
+    * @param none
+    * @return none
+    */
+    void EndDocument();
+        
+    /**
+    * End tag of an element has been found
+    * @param aTag - tag of the element to be closed 
+    * @return none
+    */
+    void EndElementL( TWBXMLTag aTag );
+    
+    // Generator
+    
+    /**
+    * Starts the generation of a document
+    * @param aContent - data for the document
+    * @return none
+    */
+    TInt GenerateConMLDocument ( ConML_ConMLPtr_t aContent );
+
+private:
+
+    // WBXML Generator
+    void WriteMUint32L( TUint32 aValue );
+    void WriteOpaqueDataL( const TDesC8& aData );
+    void WriteInlineStringL( const TDesC8& aData );
+    
+    // XML Generator
+    void IndentL();
+    TPtrC8 TranslateElement( TUint8 aElement );
+
+    // WBXML / XML Generator
+    void BeginDocumentL( TUint8 aVersion, TInt32 aPublicId, TUint32 aCharset, 
+        const TDesC8& aStringTbl = TPtrC8() );
+    void BeginElementL( TUint8 aElement, TBool aHasContent = EFalse, 
+        TBool aHasAttributes = EFalse );
+    void EndElementL();
+    void AddElementL( 
+        TUint8 aElement, const TDesC8& aContent, 
+        const TWBXMLContentFormat aFormat = EWBXMLContentFormatOpaque );
+    void AppendPCDataL( TUint8 aElement, pcdataPtr_t aContent );
+    void AppendConMLL( ConML_ConMLPtr_t aContent );
+    void AppendExecuteL( ConML_ExecutePtr_t aContent );
+    void AppendSupplyDataL( ConML_SupplyDataPtr_t aContent );
+    void AppendInstallL( ConML_InstallPtr_t aContent );
+    void AppendCancelL ( ConML_CancelPtr_t aContent );
+    void AppendStatusL ( ConML_StatusPtr_t aContent );
+    void AppendGetStatusL( ConML_GetStatusPtr_t aContent );
+    void AppendRebootL( ConML_RebootPtr_t aContent );
+    void AppendTaskL( ConML_TaskPtr_t aContent );
+    void AppendTaskListL( ConML_TaskListPtr_t aContent );
+    void AppendUnInstallL( ConML_UnInstallPtr_t aContent );
+    void AppendListInstalledAppsL ( ConML_ListInstalledAppsPtr_t aContent );
+    void AppendListDataOwnersL ( ConML_ListDataOwnersPtr_t aContent );
+    void AppendBUROptionsL( ConML_BUROptionsPtr_t aContent );
+    void AppendSetBURModeL( ConML_SetBURModePtr_t aContent );
+    void AppendGetDataSizeL( ConML_GetDataSizePtr_t aContent );
+    void AppendRequestDataL( ConML_RequestDataPtr_t aContent );
+    void AppendUpdateDeviceInfoL( ConML_UpdateDeviceInfoPtr_t aContent );
+    void AppendListPublicFilesL( ConML_ListPublicFilesPtr_t aContent );
+    void AppendApplicationL( ConML_ApplicationPtr_t aContent );
+    void AppendApplicationListL( ConML_ApplicationListPtr_t aContent );
+    void AppendApplicationsL( ConML_ApplicationsPtr_t aContent );
+    void AppendParamL( ConML_ParamPtr_t aContent );
+    void AppendParamListL( ConML_ParamListPtr_t aContent );
+    void AppendInstParamsL( ConML_InstParamsPtr_t aContent );
+    void AppendProgressL( ConML_ProgressPtr_t aContent );
+    void AppendResultsL( ConML_ResultsPtr_t aContent );
+    void AppendDriveL( ConML_DrivePtr_t aContent );
+    void AppendDriveListL( ConML_DriveListPtr_t aContent );
+    void AppendDrivesL( ConML_DrivesPtr_t aContent );
+    void AppendDataOwnersL( ConML_DataOwnersPtr_t aContent );
+    void AppendPackageInfoL ( ConML_PackageInfoPtr_t aContent );
+    void AppendSIDL( ConML_SIDPtr_t aContent );
+    void AppendSIDListL( ConML_SIDListPtr_t aContent );
+    void AppendDeviceInfoL( ConML_DeviceInfoPtr_t aContent );
+    void AppendFilesL( ConML_FilesPtr_t aContent );
+    void AppendSupportedMethodsL( ConML_SupportedMethodsPtr_t aContent );
+    void AppendFileListL( ConML_FileListPtr_t  aContent );
+    void AppendFileL( ConML_FilePtr_t aContent );
+    void AppendGetDataOwnerStatusL( ConML_GetDataOwnerStatusPtr_t aContent );
+    void AppendGetMetadataL( ConML_GetMetadataPtr_t aContent );
+    
+    TInt HandleResult( TInt aResult, TInt aTreshold = 0 );
+    
+private:
+    void ConstructL();
+    CSConConMLGenerator();
+    void AddElement( CXMLElement* aElement );
+
+private:
+    // Parser
+    CXMLStack<CXMLElement>* iCmdStack;
+    CXMLStack<CXMLElement>* iCleanupStack;
+    MWBXMLConMLCallback* iCallback;
+
+    // Generator workspaces 
+    CXMLWorkspace* iWBXMLWorkspace;
+    CXMLWorkspace* iXMLWorkspace;
+
+    // XML
+    RArray<TUint8> iElemStack;
+    TInt iInitialIndentLevel;
+    TBool iDontNewLine;
+    TBool iDontIndent;
+    }; 
+
+#endif // __SCONCONMLGENERATOR_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconconmlhandler.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,123 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser/generator
+*
+*/
+
+
+#ifndef _SCONCONMLHANDLER_H
+#define _SCONCONMLHANDLER_H
+
+// -----------------------------------------------------------------------------
+// Includes
+// -----------------------------------------------------------------------------
+#include "sconconmlgenerator.h"
+#include "sconwbxmldefs.h"
+#include "sconconmlhandlererror.h"
+#include "sconconmldtd.h"
+
+// -----------------------------------------------------------------------------
+// Definitions and constants
+// -----------------------------------------------------------------------------
+
+_LIT8(KWBXMLNull, "\x00");
+
+const TInt KSConBufferGranularity( 32 );
+const TInt KSConDefaultDocumentSize( 2048 );
+
+// -----------------------------------------------------------------------------
+// TWBXMLStackItem
+// -----------------------------------------------------------------------------
+NONSHARABLE_STRUCT( TWBXMLStackItem )
+    {
+public:
+    inline TWBXMLStackItem( TUint8 aTag );
+    inline TUint8 Tag() const;
+
+private:
+    TUint8 iTag;
+    };
+
+#include "sconwbxmlparser.inl"
+
+// -----------------------------------------------------------------------------
+// CSConConMLHandler - WBXML parsing
+// -----------------------------------------------------------------------------
+class CSConConMLHandler : public CBase
+    {
+public:
+    static CSConConMLHandler* NewL();
+    ~CSConConMLHandler();
+    
+    /**
+    * Starts the parsing of a WBXML document
+    * @param aInput - the WBXML document to be parsed
+    * @param aCallback - Call back function to call 
+    * after the document is parsed
+    * @return An error code
+    */
+    virtual TInt ParseDocumentL( CBufFlat& aInput,  
+        MWBXMLConMLCallback* aCallback  );
+    
+    /**
+    * Starts the generating of a WBXML and XML document
+    * @param aContent - the data to be generated into the document
+    * @return An error code
+    */
+    virtual TInt GenerateDocument( ConML_ConMLPtr_t aContent );
+    
+    /**
+    * Returns the generated document in XML -format
+    * @param none
+    * @return The document as TPtrC8
+    */
+    virtual TPtrC8 XMLDocument();
+    
+    /**
+    * Returns the generated document in WBXML -format
+    * @param none
+    * @return The document as TPtrC8
+    */
+    virtual TPtrC8 WBXMLDocument();
+    
+private:
+    CSConConMLHandler();
+    void ConstructL();
+    
+    TInt ParseL();
+    TConMLParserError DoParseDocumentHeaderL();
+    TConMLParserError DoParseDocumentBodyL();
+    TUint8 ReadUint8L();
+    TUint32 ReadMUint32L();
+    TPtrC8 ReadStrIL();
+    TPtrC8 StringTableString( TUint32 aIndex );
+    void ReadStringTableL();    
+    TPtrC8 ReadOpaqueL();
+    void HandleElementL( TUint8 aId );
+    
+private:
+    CSConConMLGenerator* iGenerator;
+    HBufC8* iStringTable;
+    CBufBase* iBuffer;
+    TBool iHeaderParsed;
+    RArray< TUint > iElemStack;
+    TInt iPos;
+    CBufFlat* iParseBuffer;
+    MWBXMLConMLCallback* iCallback;
+    };
+
+    IMPORT_C CSConConMLHandler* CreateCSConConMLHandlerL();
+    typedef CSConConMLHandler* (*TSConCreateCSConConMLHandlerFunc) (); 
+    
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconconmlhandlererror.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser/generator
+*
+*/
+
+
+#ifndef __SCONCONMLHANDLERERROR_H__
+#define __SCONCONMLHANDLERERROR_H__
+
+// -----------------------------------------------------------------------------
+// Parser error base
+// -----------------------------------------------------------------------------
+
+#define PERRBASE 0x2000
+
+enum TConMLParserError
+	{
+	KWBXMLParserErrorOk = 0,
+	KWBXMLParserErrorEof = PERRBASE,
+	KWBXMLParserErrorEofTooEarly,
+	KWBXMLParserErrorInvalidTag,
+	KWBXMLParserErrorWrongWBXMLVersion,
+	KWBXMLParserErrorWrongPublicId,
+	KWBXMLParserErrorinvalidDocument
+	};
+
+#define GERRBASE 0x3000
+
+enum TWBXMLGeneratorError
+	{
+	KWBXMLGeneratorOk = 0,
+	KWBXMLGeneratorBufferFull = GERRBASE
+	};
+	
+#endif // __SCONCONMLHANDLERERROR_H__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconconmltags.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,120 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser/generator
+*
+*/
+
+
+
+#ifndef __SCONCONMLTAGS_H__
+#define __SCONCONMLTAGS_H__
+
+// -----------------------------------------------------------------------------
+// Constants
+// -----------------------------------------------------------------------------
+const TInt32 KSConConMLPublicId = 0x8F;
+const TUint8 KSConConMLVersion = 0x02;
+const TUint32 KSConConMLUTF8 = 0x6a;
+
+_LIT8(KSConConMLPublicIdStr, "-//CONML//DTD ConML 1.0//EN");
+
+// -----------------------------------------------------------------------------
+// TConMLTags
+// -----------------------------------------------------------------------------
+enum TConMLTags
+    {
+        EConMLAll = 5,
+        EConMLApplication,
+        EConMLApplications,
+        EConMLBUROptions,
+        EConMLCancel,
+        EConMLComplete,
+        EConML,
+        EConMLData,
+        EConMLDataOwners,
+        EConMLDataOwnerStatus,
+        EConMLDelayToPrepareData,
+        EConMLDeviceInfo,
+        EConMLDrive,
+        EConMLDrives,
+        EConMLExecute,
+        EConMLFile,
+        EConMLFiles,
+        EConMLGetDataOwnerStatus,
+        EConMLGetDataSize,
+        EConMLGetStatus,
+        EConMLHasFiles,
+        EConMLID,
+        EConMLIncType,
+        EConMLInstall,
+        EConMLInstParams,
+        EConMLListDataOwners,
+        EConMLListInstalledApps,
+        EConMLListPublicFiles,
+        EConMLMaxObjectSize,
+        EConMLModified,
+        EConMLMoreData,
+        EConMLName,
+        EConMLPackageInfo,
+        EConMLParam,
+        EConMLPartialType,
+        EConMLProgress,
+        EConMLReboot,
+        EConMLRequestData,
+        EConMLRequiresReboot,
+        EConMLResults,
+        EConMLSetBURMode,
+        EConMLSetInstParams,
+        EConMLSID,
+        EConMLSize,
+        EConMLStatus,
+        EConMLSupplyData,
+        EConMLSupportedMethods,
+        EConMLSupportsInc,
+        EConMLTask,
+        EConMLTransferDataType,
+        EConMLType,
+        EConMLUID,
+        EConMLUnInstall,
+        EConMLUpdateDeviceInfo,
+        EConMLUserPerm,
+        EConMLValue,
+        EConMLVersion,
+        EConMLGetMetadata,
+        EConMLFilename
+        };
+// -----------------------------------------------------------------------------
+_LIT8( KConMLElements, 
+       "<0>|<1>|<2>|<3>|<4>|All|Application|Applications|BUROptions|Cancel"
+       "|Complete|ConML|Data|DataOwners|DataOwnerStatus|DelayToPrepareData"
+       "|DeviceInfo|Drive|Drives|Execute|File|Files|GetDataOwnerStatus"
+       "|GetDataSize|GetStatus|HasFiles|ID|IncType|Install|InstParams"
+       "|ListDataOwners|ListInstalledApps|ListPublicFiles|MaxObjectSize|"
+       "Modified|MoreData|Name|PackageInfo|Param|PartialType|Progress|"
+       "Reboot|RequestData|RequiresReboot|Results|SetBURMode|SetInstParams|SID|"
+       "Size|Status|SupplyData|SupportedMethods|SupportsInc|Task|"
+       "TransferDataType|Type|UID|UnInstall|UpdateDeviceInfo|UserPerm|"
+       "Value|Version|GetMetadata|Filename" );
+       
+_LIT8(KXMLTagStart, "<");
+_LIT8(KXMLTagStartEndTag, "</");
+_LIT8(KXMLTagEndNoContent, "/>");
+_LIT8(KXMLTagEnd, ">");
+_LIT8(KXMLElemenentSeparator, "|");
+_LIT8(KXMLNamespaceBegin, " xmlns='");
+_LIT8(KXMLNamespaceEnd, "'");
+_LIT8(KXMLIndent, "   ");
+_LIT8(KXMLNewLine, "\r\n");
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconwbxmldefs.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser/generator
+*
+*/
+
+
+#ifndef __SCONWBXMLDEFS_H__
+#define __SCONWBXMLDEFS_H__
+
+// -----------------------------------------------------------------------------
+// Typedefs
+// -----------------------------------------------------------------------------
+typedef TUint8 TWBXMLTag;
+
+// -----------------------------------------------------------------------------
+// Constants
+// -----------------------------------------------------------------------------
+const TWBXMLTag SWITCH_PAGE = 0;
+const TWBXMLTag END = 1;
+const TWBXMLTag ENTITY = 2;
+const TWBXMLTag STR_I = 3;
+const TWBXMLTag LITERAL = 4;
+const TWBXMLTag OPAQUE = 0xc3; 
+
+const TUint8 KWBXMLHasAttributes = (1<<7);
+const TUint8 KWBXMLHasContent = (1<<6);
+
+
+#endif // __SCONWBXMLDEFS_H__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconwbxmlparser.inl	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser/generator
+*
+*/
+
+
+#ifndef __SCONWBXMLPARSER_INL__
+#define __SCONWBXMLPARSER_INL__
+
+
+inline TWBXMLStackItem::TWBXMLStackItem( TUint8 aTag )  : iTag(aTag)
+	{
+	}
+
+inline TUint8 TWBXMLStackItem::Tag() const
+	{
+	return iTag;
+	}
+
+#endif // __SCONWBXMLPARSER_INL__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconxmlelement.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,137 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser/generator
+*
+*/
+
+
+#ifndef __SCONXMLELEMENT_H__
+#define __SCONXMLELEMENT_H__
+
+// -----------------------------------------------------------------------------
+// Includes
+// -----------------------------------------------------------------------------
+
+#include <e32base.h>
+#include "sconxmlstack.h"
+
+// -----------------------------------------------------------------------------
+// Class forwards
+// -----------------------------------------------------------------------------
+class MWBXMLConMLCallback;
+struct TXMLElementParams;
+
+// -----------------------------------------------------------------------------
+// CXMLElement - Base class for XML -elements
+// -----------------------------------------------------------------------------
+NONSHARABLE_CLASS( CXMLElement ) : public CBase
+    {
+public:
+    enum TAction 
+        {
+        ENone,
+        EPop,
+        EPopAndDestroy // Pop from stack, callback, delete
+        };
+
+    /**
+    * Sets the data of an element
+    * @param aData - Data of the element
+    * @return none
+    */
+    virtual void SetDataL( const TDesC8& aData );
+    
+    /**
+    * Returns data of an element
+    * @param none
+    * @return Data of the element as TPtrC8
+    */
+    virtual TPtrC8 Data() const;
+        
+    /**
+    * Validates an element's instance 
+    * @param none
+    * @return ETrue if element current instance is valid, 
+    * EFalse if not 
+    */
+    virtual TBool Validate();
+    
+    /**
+    * Checks if instance needs cleanup
+    * @param none
+    * @return ETrue if instance pushed into 
+    * parser's cleanupstack , EFalse if not
+    */
+    virtual TBool NeedsCleanup() const;
+    
+    /**
+    * Offers a new element to this element
+    * @param aTag - tag of the element to be started 
+    * @param aParams - Element parameters
+    * @return new Element instance as CXMLElement
+    */
+    virtual CXMLElement* BeginElementL( 
+        TUint8 aTag, const TXMLElementParams& aParams );
+
+    /**
+    * Offers a new element to this element
+    * @param aTag - tag of the element to be started 
+    * @param aParams - Element parameters
+    * @return new Element instance as CXMLElement
+    */
+    virtual TAction EndElementL( TAny* aCallbacks, TUint8 aTag );
+    };
+
+// -----------------------------------------------------------------------------
+// TElementParams
+// -----------------------------------------------------------------------------
+NONSHARABLE_STRUCT( TXMLElementParams )
+    {
+public:
+    inline TXMLElementParams();
+    TXMLElementParams( 
+        TAny* aCallbacks, 
+        CXMLStack<CXMLElement>* aCmdStack = 0, 
+        CXMLStack<CXMLElement>* aCleanupStack = 0 );
+        
+    /**
+    * Returns the call back function of parameters
+    * @param nonoe
+    * @return call back function as TAny
+    */
+    inline TAny* Callbacks() const;
+    
+    /**
+    * Returns the command stack of the parameters
+    * @param none
+    * @return command stack as CXMLStack
+    */
+    inline CXMLStack<CXMLElement>* CmdStack() const;
+
+    /**
+    * Returns the clean up stack of the parameters
+    * @param none
+    * @return clean up stack as CXMLStack
+    */
+    inline CXMLStack<CXMLElement>* CleanupStack() const;
+
+private:
+    TAny* iCallbacks;
+    CXMLStack<CXMLElement>* iCmdStack;
+    CXMLStack<CXMLElement>* iCleanupStack;
+    };
+
+#include "sconxmlelement.inl"
+
+#endif // __SCONXMLELEMENT_H__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconxmlelement.inl	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser/generator
+*
+*/
+
+
+#ifndef __SCONXMLELEMENT_INL__
+#define __SCONXMLELEMENT_INL__
+
+// ------------------------------------------------------------------------------------------------
+inline TXMLElementParams::TXMLElementParams() : iCallbacks(0), iCmdStack(0), iCleanupStack(0)
+	{
+	}
+
+// ------------------------------------------------------------------------------------------------
+inline TAny* TXMLElementParams::Callbacks() const
+	{
+	return iCallbacks;
+	}
+
+// ------------------------------------------------------------------------------------------------
+inline CXMLStack<CXMLElement>* TXMLElementParams::CmdStack() const
+	{
+	return iCmdStack;
+	}
+
+// ------------------------------------------------------------------------------------------------
+inline CXMLStack<CXMLElement>* TXMLElementParams::CleanupStack() const
+	{
+	return iCleanupStack;
+	}
+
+#endif // __SCONXMLELEMENT_INL__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconxmlstack.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser/generator
+*
+*/
+
+
+#ifndef __SCONXMLSTACK_H__
+#define __SCONXMLSTACK_H__
+
+// -----------------------------------------------------------------------------
+// CNSmlStack - Stack for WBXML / XML elements
+// ----------------------------------------------------------------------------
+
+template <class T>
+class CXMLStack  : public CBase
+	{
+public:
+	static inline CXMLStack* NewL();
+	inline ~CXMLStack();
+        
+        /**
+        *  Removes latest item from the stack
+        * @param none
+        * @return none
+        */
+	inline T* Pop();
+	
+	/**
+        *  Return the latest item from the stack
+        * @param none
+        * @return the item
+        */
+	inline T* Top();
+	
+	/**
+        *  Adds an item to the stack
+        * @param none
+        * @return none
+        */
+	inline void Push( T* aItem );
+	
+	/**
+        * Returns the number of items in the stack
+        * @param none
+        * @return number of items as TInt
+        */
+	inline TInt Count();
+	
+	/**
+        *  Resets the stack
+        * @param none
+        * @return none
+        */
+	inline void Reset();
+	
+	/**
+        *  Resets and destroys the stack
+        * @param none
+        * @return none
+        */
+	inline void ResetAndDestroy();
+
+
+protected:
+	inline CXMLStack<T>();
+
+private:
+	RPointerArray<T>* iStack;
+	};
+
+#include "sconxmlstack.inl"
+
+#endif // __SCONXMLSTACK_H__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconxmlstack.inl	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,99 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser/generator
+*
+*/
+
+
+#ifndef __SCONXMLSTACK_INL__
+#define __SCONXMLSTACK_INL__
+
+
+// ------------------------------------------------------------------------------------------------
+// CXMLStack
+// ------------------------------------------------------------------------------------------------
+template<class T>
+inline CXMLStack<T>::CXMLStack()
+	{
+	}
+
+// ------------------------------------------------------------------------------------------------
+template<class T>
+inline CXMLStack<T>::~CXMLStack()
+	{
+	iStack->ResetAndDestroy();
+	delete iStack;
+	}
+
+// ------------------------------------------------------------------------------------------------
+template<class T>
+inline CXMLStack<T>* CXMLStack<T>::NewL()
+	{
+	CXMLStack<T>* self = new (ELeave) CXMLStack<T>();
+	CleanupStack::PushL(self);
+	self->iStack = new (ELeave) RPointerArray<T>();
+	CleanupStack::Pop(); // self
+	return self;
+	}
+
+// ------------------------------------------------------------------------------------------------
+template<class T>
+inline T* CXMLStack<T>::Pop()
+	{
+	T* temp = iStack->operator[](iStack->Count() - 1);
+	iStack->Remove(iStack->Count() - 1);
+	return temp;
+	}
+
+// ------------------------------------------------------------------------------------------------
+template<class T>
+inline T* CXMLStack<T>::Top()
+	{
+	if( Count() > 0 )
+		{
+		return iStack->operator[](iStack->Count() - 1);
+		}
+	return 0;
+	}
+
+// ------------------------------------------------------------------------------------------------
+template<class T>
+inline void CXMLStack<T>::Push( T* aItem )
+	{
+	iStack->Append(aItem);
+	}
+
+// ------------------------------------------------------------------------------------------------
+template<class T>
+inline TInt CXMLStack<T>::Count()
+	{
+	return iStack->Count();
+	}
+
+// ------------------------------------------------------------------------------------------------
+template<class T>
+inline void CXMLStack<T>::Reset()
+	{
+	iStack->Reset();
+	}
+
+// ------------------------------------------------------------------------------------------------
+template<class T>
+inline void CXMLStack<T>::ResetAndDestroy()
+	{
+	iStack->ResetAndDestroy();
+	}
+
+#endif  // __SCONXMLSTACK_INL__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconxmlworkspace.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,120 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser/generator
+*
+*/
+
+
+#ifndef __SCONXMLWORKSPACE_H__
+#define __SCONXMLWORKSPACE_H__
+
+// -----------------------------------------------------------------------------
+// Includes
+// -----------------------------------------------------------------------------
+#include <e32base.h>
+
+// -----------------------------------------------------------------------------
+// CXMLWorkspace - workspace for WBXML / XML -documents
+// -----------------------------------------------------------------------------
+class CXMLWorkspace : public CBase
+	{
+public:
+	~CXMLWorkspace();
+	static CXMLWorkspace* NewL();
+
+	// transaction handling
+	/**
+        * Function to Begin transaction
+        * @param none
+        * @return none
+        */
+	void BeginTransaction();
+	
+	/**
+        * Commits the transactions done
+        * @param none
+        * @return none
+        */
+	void CommitAll();
+	
+	/**
+        *  Commits the latest transacion done
+        * @param none
+        * @return KErrNone or an error code
+        */
+	TInt Commit();
+	
+	/**
+        *  Deletes the latest transacion done
+        * @param none
+        * @return KErrNone or an error code
+        */
+	TInt Rollback();
+
+        /**
+        *  Resets the buffer
+        * @param none
+        * @return KErrNone or an error code
+        */
+	void Reset();
+	
+	/**
+        *  Writes to the buffer
+        * @param none
+        * @return none
+        */
+	void WriteL( const TDesC8& aData );
+	void WriteL( const TUint8 aData );
+	
+	/**
+        * Returns the buffer
+        * @param none
+        * @return the buffer
+        */
+	TPtrC8 Buffer();
+        
+        /**
+        *  Returns the free space left in the buffer
+        * @param none
+        * @return free space of the buffer
+        */
+	TInt FreeSize();
+	
+	/**
+        *  Returns the maximum size of the buffer
+        * @param none
+        * @return Buffer maximum size
+        */
+	TInt MaxSize();
+	
+	/**
+        *  Returns the size of the buffer space used
+        * @param none
+        * @return Size of the buffer used
+        */
+	TInt Size();
+
+protected:
+	void ConstructL();
+
+private:
+	void Delete( TInt aPos, TInt aLength );
+	CXMLWorkspace();
+private:
+	CBufFlat* iBuffer;
+	RArray<TUint>* iTransactions;
+	};
+
+#endif // __SCONXMLWORKSPACE_H__
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/src/sconconmldtd.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1783 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser/generator
+*
+*/
+
+
+#include "sconconmldtd.h"
+#include "sconconmltags.h"
+#include "sconconmlhandler.h"
+#include "sconconmlhandlererror.h"
+#include "debug.h"
+
+// -----------------------------------------------------------------------------
+// Macros
+// -----------------------------------------------------------------------------
+#define CHECK_NO_DUPLICATE(a) if( a ) { User::Leave( KWBXMLParserErrorinvalidDocument ); }
+
+// -----------------------------------------------------------------------------
+// pcdata_s
+// -----------------------------------------------------------------------------
+pcdata_s::pcdata_s( const pcdataType_t aType, const pcdataExtension_t aExt )
+	: contentType(aType), extension(aExt)
+    {
+    }
+
+pcdata_s::pcdata_s() : contentType(SML_PCDATA_OPAQUE), 
+                       extension(SML_EXT_UNDEFINED)
+    {
+    }
+
+pcdata_s::~pcdata_s()
+    {
+    FreeContent();
+    }
+
+void pcdata_s::FreeContent()
+    {
+    User::Free(content);
+    content = 0;
+    }
+
+void pcdata_s::SetDataL( const TDesC8& aData )
+    {
+    FreeContent();
+    length = aData.Length();
+    content = User::AllocL(length);
+    Mem::Copy(content, aData.Ptr(), length);
+    }
+
+TPtrC8 pcdata_s::Data() const
+    {
+    return TPtrC8((TUint8*)content, length);
+    }
+
+void pcdata_s::TruncateL( TInt aConsumed )
+    {
+    HBufC8* buffer = TPtrC8((TUint8*)content + aConsumed, 
+                             length - aConsumed).AllocLC();
+    SetDataL(*buffer);
+    CleanupStack::PopAndDestroy(); // buffer
+    }
+
+pcdata_list_s::pcdata_list_s()
+    {
+    }
+
+pcdata_list_s::~pcdata_list_s()
+    {
+    delete data;
+    delete next;
+    }
+
+// -----------------------------------------------------------------------------
+// AddDriveL
+// -----------------------------------------------------------------------------
+CXMLElement* AddDriveL(  ConML_DriveListPtr_t* aList )
+    {
+    ConML_DriveListPtr_t itemL = new ( ELeave ) ConML_DriveList_t();
+    CleanupStack::PushL( itemL );
+    itemL->data = new ( ELeave ) ConML_Drive_t();
+    GenericListAddL(aList, itemL);
+    CleanupStack::Pop(); // itemL
+    return itemL->data;
+    }
+
+// -----------------------------------------------------------------------------
+// AddSIDL
+// -----------------------------------------------------------------------------
+CXMLElement* AddSIDL( ConML_SIDListPtr_t * aList )
+    {
+    ConML_SIDListPtr_t itemL = new ( ELeave ) ConML_SIDList_t();
+    CleanupStack::PushL( itemL );
+    itemL->data = new ( ELeave ) ConML_SID_t();
+    GenericListAddL(aList, itemL);
+    CleanupStack::Pop(); // itemL
+    return itemL->data;
+    }
+		
+// -----------------------------------------------------------------------------
+// AddFileL
+// -----------------------------------------------------------------------------
+CXMLElement* AddFileL( ConML_FileListPtr_t * aList )
+    {
+    ConML_FileListPtr_t itemL = new ( ELeave ) ConML_FileList_t();
+    CleanupStack::PushL( itemL );
+    itemL->data = new ( ELeave ) ConML_File_t();
+    GenericListAddL(aList, itemL);
+    CleanupStack::Pop(); // itemL
+    return itemL->data;
+    }
+
+// -----------------------------------------------------------------------------
+// AddApplicationL
+// -----------------------------------------------------------------------------
+CXMLElement* AddApplicationL( ConML_ApplicationListPtr_t * aList )
+    {   
+    ConML_ApplicationListPtr_t itemL = new ( ELeave ) ConML_ApplicationList_t();
+    CleanupStack::PushL( itemL );
+    itemL->data = new ( ELeave ) ConML_Application_t();
+    GenericListAddL(aList, itemL);
+    CleanupStack::Pop(); // itemL
+    return itemL->data;
+    }
+
+// -----------------------------------------------------------------------------
+// AddTaskL
+// -----------------------------------------------------------------------------
+CXMLElement* AddTaskL( ConML_TaskListPtr_t * aList )
+    {
+    ConML_TaskListPtr_t itemL = new ( ELeave ) ConML_TaskList_t();
+    CleanupStack::PushL( itemL );
+    itemL->data = new ( ELeave ) ConML_Task_t();
+    GenericListAddL(aList, itemL);
+    CleanupStack::Pop(); // itemL
+    return itemL->data;
+    }
+	
+// -----------------------------------------------------------------------------
+// AddParamL
+// -----------------------------------------------------------------------------
+CXMLElement* AddParamL( ConML_ParamListPtr_t * aList )
+    {
+    ConML_ParamListPtr_t itemL = new ( ELeave ) ConML_ParamList_t();
+    CleanupStack::PushL( itemL );
+    itemL->data = new ( ELeave ) ConML_Param_t();
+    GenericListAddL(aList, itemL);
+    CleanupStack::Pop(); // itemL
+    return itemL->data;
+    }
+	
+// -----------------------------------------------------------------------------
+// ConML_Drive_s
+// -----------------------------------------------------------------------------
+ConML_Drive_s::ConML_Drive_s()
+    {
+    }
+
+ConML_Drive_s::~ConML_Drive_s()
+    {
+    delete name;
+    }
+
+CXMLElement* ConML_Drive_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )
+    {
+    switch ( aTag )
+        {
+        case EConMLName:
+            CHECK_NO_DUPLICATE ( name );
+            name = new ( ELeave ) pcdata_t();
+            return name;
+				
+        default:
+            LOGGER_WRITE_1( "ConML_Drive_s::BeginElement() : Unknown element  %02x", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_DriveList_s
+// -----------------------------------------------------------------------------
+ConML_DriveList_s::ConML_DriveList_s()	
+    {
+    }
+
+ConML_DriveList_s::~ConML_DriveList_s()	
+    {
+    delete data;
+    delete next;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_Drives_s
+// -----------------------------------------------------------------------------
+ConML_Drives_s::ConML_Drives_s()
+    {
+    }
+	
+ConML_Drives_s::~ConML_Drives_s()
+    {
+    delete drive;
+    }
+	
+CXMLElement* ConML_Drives_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )
+    {
+    switch ( aTag )
+        {
+        case EConMLDrive:
+            return AddDriveL ( &drive );
+	
+        default:
+            LOGGER_WRITE_1( "ConML_Drives_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+	
+// -----------------------------------------------------------------------------
+// ConML_BUROptions_s
+// -----------------------------------------------------------------------------
+ConML_BUROptions_s::ConML_BUROptions_s()
+    {
+    }
+
+ConML_BUROptions_s::~ConML_BUROptions_s()
+    {
+    delete requiresReboot;
+    delete hasFiles;
+    delete supportsInc;
+    delete delayToPrepareData;
+    }
+
+CXMLElement* ConML_BUROptions_s::BeginElementL ( 
+        TUint8 aTag, const TXMLElementParams& /*aParams*/ )
+    {
+    switch ( aTag )
+        {
+        case EConMLRequiresReboot:
+            CHECK_NO_DUPLICATE ( requiresReboot );
+            requiresReboot = new ( ELeave ) pcdata_t();
+            return requiresReboot;
+		
+        case EConMLHasFiles:
+            CHECK_NO_DUPLICATE ( hasFiles );
+            hasFiles = new ( ELeave ) pcdata_t();
+            return hasFiles;
+			
+        case EConMLSupportsInc:
+            CHECK_NO_DUPLICATE ( supportsInc );
+            supportsInc = new ( ELeave ) pcdata_t();
+            return supportsInc;
+		
+        case EConMLDelayToPrepareData:
+            CHECK_NO_DUPLICATE ( delayToPrepareData );
+            delayToPrepareData = new ( ELeave ) pcdata_t();
+            return delayToPrepareData;
+				
+        default:
+            LOGGER_WRITE_1( "ConML_BUROptions_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_PackageInfo_s
+// -----------------------------------------------------------------------------
+ConML_PackageInfo_s::ConML_PackageInfo_s()
+    {
+    }
+
+ConML_PackageInfo_s::~ConML_PackageInfo_s()
+    {
+    delete name;
+    }
+
+CXMLElement* ConML_PackageInfo_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLName:
+            CHECK_NO_DUPLICATE ( name )
+            name = new ( ELeave ) pcdata_t();
+            return name;
+								
+        default:
+            LOGGER_WRITE_1( "ConML_PackageInfo_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// ConML_SID_s
+// -----------------------------------------------------------------------------
+ConML_SID_s::ConML_SID_s()
+    {
+    }
+
+ConML_SID_s::~ConML_SID_s()
+    {
+    delete type;
+    delete uid;
+    delete drives;
+    delete packageInfo;
+    delete burOptions;
+    delete size;
+    delete transferDataType;
+    delete data;
+    delete moreData;
+    delete dataOwnerStatus;
+    }
+
+CXMLElement* ConML_SID_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLType:
+            CHECK_NO_DUPLICATE ( type );
+            type = new ( ELeave ) pcdata_t();
+            return type;
+		
+        case EConMLUID:
+            CHECK_NO_DUPLICATE ( uid )
+            uid = new ( ELeave ) pcdata_t();
+            return uid;
+		
+        case EConMLDrives:
+            drives = new ( ELeave ) ConML_Drives_t();
+            return drives;
+		
+        case EConMLPackageInfo:
+            CHECK_NO_DUPLICATE ( packageInfo );
+            packageInfo = new ( ELeave ) ConML_PackageInfo_t();
+            return packageInfo;
+		
+        case EConMLBUROptions:
+            CHECK_NO_DUPLICATE ( burOptions )
+            burOptions = new ( ELeave )	ConML_BUROptions_t();
+            return burOptions;
+			
+        case EConMLSize:
+            CHECK_NO_DUPLICATE ( size );
+            size = new ( ELeave ) pcdata_t();
+            return size;
+		
+        case EConMLTransferDataType:
+            CHECK_NO_DUPLICATE ( transferDataType );
+            transferDataType = new ( ELeave ) pcdata_t();
+            return transferDataType;
+		
+        case EConMLData:
+            CHECK_NO_DUPLICATE ( data );
+            data = new ( ELeave ) pcdata_t();
+            return data;
+		
+        case EConMLMoreData:
+            CHECK_NO_DUPLICATE ( moreData );
+            moreData = new ( ELeave ) pcdata_t();
+            return moreData;
+		
+        case EConMLDataOwnerStatus:
+            CHECK_NO_DUPLICATE ( dataOwnerStatus );
+            dataOwnerStatus = new ( ELeave ) pcdata_t();
+            return dataOwnerStatus;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_SID_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+	
+// -----------------------------------------------------------------------------
+// ConML_SIDList_s
+// -----------------------------------------------------------------------------
+ConML_SIDList_s::ConML_SIDList_s()
+    {
+    }
+	
+ConML_SIDList_s::~ConML_SIDList_s()
+    {
+    delete data;
+    delete next;
+    }
+	
+// -----------------------------------------------------------------------------
+// ConML_DataOwners_s
+// -----------------------------------------------------------------------------
+ConML_DataOwners_s::ConML_DataOwners_s()
+    {
+    }
+
+ConML_DataOwners_s::~ConML_DataOwners_s()
+    {
+    delete sid;
+    }
+
+CXMLElement* ConML_DataOwners_s::BeginElementL(
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLSID:
+            return AddSIDL( &sid );
+				
+        default:
+            LOGGER_WRITE_1( "ConML_DataOwners_s::BeginElement()\
+             : Unknown element  %02x ", aTag);
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_Application_s
+// -----------------------------------------------------------------------------
+ConML_Application_s::ConML_Application_s()
+    {
+    }
+	
+ConML_Application_s::~ConML_Application_s()
+    {
+    delete name;
+    delete uid;
+    }
+
+CXMLElement* ConML_Application_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+    	{
+    	case EConMLName:
+            CHECK_NO_DUPLICATE ( name );
+            name = new ( ELeave ) pcdata_t();
+            return name;
+		
+        case EConMLUID:
+            CHECK_NO_DUPLICATE ( uid );
+            uid = new ( ELeave ) pcdata_t();
+            return uid;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_Application_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_ApplicationList_s
+// -----------------------------------------------------------------------------
+ConML_ApplicationList_s::ConML_ApplicationList_s()
+    {
+    }
+
+ConML_ApplicationList_s::~ConML_ApplicationList_s()
+    {
+    delete data;
+    delete next;
+    }
+	
+// -----------------------------------------------------------------------------
+// ConML_Applications_s
+// -----------------------------------------------------------------------------
+ConML_Applications_s::ConML_Applications_s()	
+    {
+    }
+
+ConML_Applications_s::~ConML_Applications_s()	
+    {
+    delete application;
+    }
+	
+CXMLElement* ConML_Applications_s::BeginElementL(
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLApplication:
+            return AddApplicationL( &application );
+				
+        default:
+            LOGGER_WRITE_1( "ConML_DataOwners_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+	
+// -----------------------------------------------------------------------------
+// ConML_SupportedMethod_s
+// -----------------------------------------------------------------------------
+ConML_SupportedMethods_s::ConML_SupportedMethods_s()
+    {
+    }
+
+ConML_SupportedMethods_s::~ConML_SupportedMethods_s()
+    {
+    delete install;
+    delete unInstall;
+    delete setInstParams;
+    delete listInstalledApps;
+    delete listDataOwners;
+    delete setBurMode;
+    delete getDataSize;
+    delete requestData;
+    delete supplyData;
+    delete reboot;
+    }
+
+CXMLElement* ConML_SupportedMethods_s::BeginElementL(
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )
+    {
+    switch ( aTag )
+        {
+        case EConMLInstall:
+            CHECK_NO_DUPLICATE ( install );
+            install = new ( ELeave ) pcdata_t();
+            return install;
+		
+        case EConMLUnInstall:
+            CHECK_NO_DUPLICATE ( unInstall );
+            unInstall = new ( ELeave ) pcdata_t();
+            return unInstall;
+	
+        case EConMLListInstalledApps:
+            CHECK_NO_DUPLICATE ( listInstalledApps );
+            listInstalledApps = new ( ELeave ) pcdata_t();
+            return listInstalledApps;
+		
+        case EConMLListDataOwners:
+            CHECK_NO_DUPLICATE ( listDataOwners );
+            listDataOwners = new ( ELeave ) pcdata_t();
+            return listDataOwners;
+		
+        case EConMLSetBURMode:
+            CHECK_NO_DUPLICATE ( setBurMode );
+            setBurMode = new ( ELeave ) pcdata_t();
+            return setBurMode;
+		
+        case EConMLGetDataSize:
+            CHECK_NO_DUPLICATE ( getDataSize );
+            getDataSize = new ( ELeave ) pcdata_t();
+            return getDataSize;
+		
+        case EConMLRequestData:
+            CHECK_NO_DUPLICATE ( requestData );
+            requestData = new ( ELeave ) pcdata_t();
+            return requestData;
+		
+        case EConMLSupplyData:
+            CHECK_NO_DUPLICATE (supplyData );
+            supplyData = new ( ELeave ) pcdata_t();
+            return supplyData;
+		
+        case EConMLReboot:
+            CHECK_NO_DUPLICATE ( reboot );
+            reboot = new ( ELeave ) pcdata_t();
+            return reboot;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_SupportedMethods_s::\
+            BeginElement() : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_DeviceInfo_s
+// -----------------------------------------------------------------------------
+ConML_DeviceInfo_s::ConML_DeviceInfo_s()
+    {
+    }
+
+ConML_DeviceInfo_s::~ConML_DeviceInfo_s()
+    {
+    delete version;
+    delete supportedMethods;
+    delete maxObjectSize;
+    }
+
+CXMLElement* ConML_DeviceInfo_s::BeginElementL(
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLVersion:
+            CHECK_NO_DUPLICATE (version);
+            version = new ( ELeave ) pcdata_t();
+            return version;
+		
+        case EConMLSupportedMethods:
+            CHECK_NO_DUPLICATE ( supportedMethods);
+            supportedMethods = new ( ELeave ) ConML_SupportedMethods_t();
+            return supportedMethods;
+		
+        case EConMLMaxObjectSize:
+            CHECK_NO_DUPLICATE ( maxObjectSize );
+            maxObjectSize = new ( ELeave ) pcdata_t();
+            return maxObjectSize;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_DeviceInfo_s::BeginElement()\
+             : Unknown element %d", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_DeviceInfo_s
+// -----------------------------------------------------------------------------
+ConML_File_s::ConML_File_s()	
+    {
+    }
+
+ConML_File_s::~ConML_File_s()	
+    {
+    delete name;
+    delete modified;
+    delete size;
+    delete userPerm;
+    }
+
+CXMLElement* ConML_File_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLName:
+            CHECK_NO_DUPLICATE ( name );
+            name = new ( ELeave ) pcdata_t();
+            return name;
+		
+        case EConMLModified:
+            CHECK_NO_DUPLICATE ( modified );
+            modified = new ( ELeave ) pcdata_t();
+            return modified;
+		
+        case EConMLSize:
+            CHECK_NO_DUPLICATE ( size );
+            size = new ( ELeave ) pcdata_t();
+            return size;
+		
+        case EConMLUserPerm:
+            CHECK_NO_DUPLICATE ( userPerm );
+            userPerm = new ( ELeave ) pcdata_t();
+            return userPerm;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_File_s::BeginElement()\
+             : Unknown element %d", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_FileList_s
+// -----------------------------------------------------------------------------
+ConML_FileList_s::ConML_FileList_s()
+    {
+    }
+	
+ConML_FileList_s::~ConML_FileList_s()
+    {
+    delete data;
+    delete next;
+    }	
+
+// -----------------------------------------------------------------------------
+// ConML_Files_s
+// -----------------------------------------------------------------------------
+ConML_Files_s::ConML_Files_s()
+    {
+    }
+
+ConML_Files_s::~ConML_Files_s()
+    {
+    delete file;
+    }
+
+CXMLElement* ConML_Files_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLFile:
+            return AddFileL( &file );
+		
+        default:
+            LOGGER_WRITE_1( "ConML_File_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_Progress_s
+// -----------------------------------------------------------------------------
+ConML_Progress_s::ConML_Progress_s()
+    {
+    }
+	
+// -----------------------------------------------------------------------------
+// ~ConML_Progress_s
+// -----------------------------------------------------------------------------
+ConML_Progress_s::~ConML_Progress_s()
+    {
+    delete value;
+    }
+	
+CXMLElement* ConML_Progress_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLValue:
+            CHECK_NO_DUPLICATE ( value );
+            value = new ( ELeave ) pcdata_t();
+            return value;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_Progress_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+	
+// -----------------------------------------------------------------------------
+// ConML_Results_s
+// -----------------------------------------------------------------------------
+ConML_Results_s::ConML_Results_s()
+    {
+    }
+
+ConML_Results_s::~ConML_Results_s()
+    {
+    delete complete;
+    delete progress;
+    delete applications;
+    delete dataOwners;
+    delete filename;
+    delete moreData;
+    delete data;
+    delete deviceInfo;
+    delete files;
+    }
+
+CXMLElement* ConML_Results_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+    {
+        case EConMLComplete:
+            CHECK_NO_DUPLICATE ( complete );
+            complete = new ( ELeave ) pcdata_t();
+            return complete;
+		
+        case EConMLProgress:
+            CHECK_NO_DUPLICATE ( progress );
+            progress = new ( ELeave ) ConML_Progress_t();
+            return progress;
+		
+        case EConMLApplications:
+            CHECK_NO_DUPLICATE ( applications );
+            applications = new ( ELeave ) ConML_Applications_t();
+            return applications;
+		
+        case EConMLDataOwners:
+            CHECK_NO_DUPLICATE ( dataOwners );
+            dataOwners = new ( ELeave ) ConML_DataOwners_t();
+            return dataOwners;
+		
+        case EConMLMoreData:
+            CHECK_NO_DUPLICATE ( moreData );
+            moreData = new ( ELeave ) pcdata_t();
+            return moreData;
+		
+        case EConMLData:
+            CHECK_NO_DUPLICATE ( data );
+            data = new ( ELeave ) pcdata_t();
+            return data;
+		
+        case EConMLDeviceInfo:
+            CHECK_NO_DUPLICATE ( deviceInfo )
+            deviceInfo = new ( ELeave ) ConML_DeviceInfo_t();
+            return deviceInfo;
+		
+        case EConMLFiles:
+            CHECK_NO_DUPLICATE ( files )
+            files = new ( ELeave ) ConML_Files_t();
+            return files;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_Results_s::BeginElement()\
+             : Unknown element  %02x ", aTag);
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_Param_s
+// -----------------------------------------------------------------------------
+ConML_Param_s::ConML_Param_s()
+    {
+    }
+	
+ConML_Param_s::~ConML_Param_s()
+    {
+    delete name;
+    delete value;
+    }
+	
+CXMLElement* ConML_Param_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLName:
+            CHECK_NO_DUPLICATE ( name );
+            name = new ( ELeave ) pcdata_t();
+            return name;
+		
+        case EConMLValue:
+            CHECK_NO_DUPLICATE ( value );
+            value = new ( ELeave ) pcdata_t();
+            return value;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_Param_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_ParamList_s
+// -----------------------------------------------------------------------------
+ConML_ParamList_s::ConML_ParamList_s()
+    {
+    }
+
+ConML_ParamList_s::~ConML_ParamList_s()
+    {
+    delete data;
+    delete next;
+    }
+	
+// -----------------------------------------------------------------------------
+// ConML_InstParams_s
+// -----------------------------------------------------------------------------
+ConML_InstParams_s::ConML_InstParams_s()
+    {
+    }
+
+ConML_InstParams_s::~ConML_InstParams_s()
+    {
+    delete param;
+    }
+	
+CXMLElement* ConML_InstParams_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLParam:
+            return AddParamL( &param );
+			
+        default:
+            LOGGER_WRITE_1( "ConML_InstParams_s::BeginElement()\
+             : Unknown element  %02x ", aTag);
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_UnInstall_s
+// -----------------------------------------------------------------------------
+ConML_UnInstall_s::ConML_UnInstall_s()
+    {
+    }
+
+ConML_UnInstall_s::~ConML_UnInstall_s()
+    {
+    delete applications;
+    delete instParams;
+    delete results;
+    }
+
+CXMLElement* ConML_UnInstall_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLApplications:
+            CHECK_NO_DUPLICATE ( applications );
+            applications = new ( ELeave ) ConML_Applications_t();
+            return applications;
+		
+        case EConMLInstParams:
+            CHECK_NO_DUPLICATE ( instParams );
+            instParams = new ( ELeave ) ConML_InstParams_t();
+            return instParams;
+				
+        case EConMLResults:
+            CHECK_NO_DUPLICATE ( results );
+            results = new ( ELeave ) ConML_Results_t();
+            return results;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_UnInstall_s::BeginElement()\
+             : Unknown element  %02x ", aTag);
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// ConML_ListDataOwners_s
+// -----------------------------------------------------------------------------
+ConML_ListDataOwners_s::ConML_ListDataOwners_s()
+    {
+    }
+
+ConML_ListDataOwners_s::~ConML_ListDataOwners_s()
+    {
+    delete results;
+    }
+
+CXMLElement* ConML_ListDataOwners_s::BeginElementL(
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLResults:
+            CHECK_NO_DUPLICATE ( results );
+            results = new ( ELeave ) ConML_Results_t();
+            return results;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_ListDataOwners_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_Install_s
+// -----------------------------------------------------------------------------
+ConML_Install_s::ConML_Install_s()
+    {
+    }
+
+ConML_Install_s::~ConML_Install_s()
+    {
+    delete name;
+    delete instParams;
+    delete results;
+    }
+
+CXMLElement* ConML_Install_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLName:
+            CHECK_NO_DUPLICATE ( name );
+            name = new ( ELeave ) pcdata_t();
+            return name;
+			
+        case EConMLInstParams:
+            CHECK_NO_DUPLICATE ( instParams );
+            instParams = new ( ELeave ) ConML_InstParams_t();
+            return instParams;
+		
+        case EConMLResults:
+            CHECK_NO_DUPLICATE ( results );
+            results = new ( ELeave ) ConML_Results_t();
+            return results;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_Install_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_ListInstalledApps
+// -----------------------------------------------------------------------------
+ConML_ListInstalledApps_s::ConML_ListInstalledApps_s()
+    {
+    }
+
+ConML_ListInstalledApps_s::~ConML_ListInstalledApps_s()
+    {
+    delete drives;
+    delete all;
+    delete results;
+    }
+
+CXMLElement* ConML_ListInstalledApps_s::BeginElementL(
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLDrives:
+            CHECK_NO_DUPLICATE ( drives );
+            drives = new ( ELeave ) ConML_Drives_t();
+            return drives;
+		
+        case EConMLAll:
+            CHECK_NO_DUPLICATE ( all );
+            all = new ( ELeave ) pcdata_t();
+            return all;
+		
+        case EConMLResults:
+            CHECK_NO_DUPLICATE ( results );
+            results = new ( ELeave ) ConML_Results_t();
+            return results;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_ListInstalledApps_s::\
+            BeginElement() : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+	
+// -----------------------------------------------------------------------------
+// ConML_SetBURMode_s
+// -----------------------------------------------------------------------------
+ConML_SetBURMode_s::ConML_SetBURMode_s()
+    {
+    }
+
+ConML_SetBURMode_s::~ConML_SetBURMode_s()
+    {
+    delete drives;
+    delete partialType;
+    delete incType;
+    delete results;
+    }
+
+CXMLElement* ConML_SetBURMode_s::BeginElementL(
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLDrives:
+            drives = new ( ELeave ) ConML_Drives_t();
+            return drives;
+		
+        case EConMLPartialType:
+            CHECK_NO_DUPLICATE ( partialType );
+            partialType = new ( ELeave ) pcdata_t();
+            return partialType;
+		
+        case EConMLIncType:
+            CHECK_NO_DUPLICATE ( incType );
+            incType = new ( ELeave ) pcdata_t();
+            return incType;
+		
+        case EConMLResults:
+            CHECK_NO_DUPLICATE ( results );
+            results = new ( ELeave ) ConML_Results_t();
+            return results;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_SetBURMode_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+            }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_GetDataSize_s
+// -----------------------------------------------------------------------------
+ConML_GetDataSize_s::ConML_GetDataSize_s()
+    {
+    }
+
+ConML_GetDataSize_s::~ConML_GetDataSize_s()
+    {
+    delete dataOwners;
+    delete results;
+    }
+
+CXMLElement* ConML_GetDataSize_s::BeginElementL(
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLDataOwners:
+            CHECK_NO_DUPLICATE ( dataOwners );
+            dataOwners = new ( ELeave ) ConML_DataOwners_t();
+            return dataOwners;
+		
+        case EConMLResults:
+            CHECK_NO_DUPLICATE ( results );
+            results = new ( ELeave ) ConML_Results_t();
+            return results;
+	
+        default:
+            LOGGER_WRITE_1( "ConML_GetDataSize_s::BeginElement()\
+             : Unknown element  %02x ", aTag);
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }	
+	
+// -----------------------------------------------------------------------------
+// ConML_RequestData_s
+// -----------------------------------------------------------------------------
+ConML_RequestData_s::ConML_RequestData_s()
+    {
+    }
+
+ConML_RequestData_s::~ConML_RequestData_s()
+    {
+    delete sid;
+    delete results;
+    }
+
+CXMLElement* ConML_RequestData_s::BeginElementL(
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLSID:
+            return AddSIDL( &sid );
+		
+        case EConMLResults:
+            CHECK_NO_DUPLICATE ( results );
+            results = new ( ELeave ) ConML_Results_t();
+            return results;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_RequestData_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+	
+// -----------------------------------------------------------------------------
+// ConML_UpdateDeviceInfo_s
+// -----------------------------------------------------------------------------
+ConML_UpdateDeviceInfo_s::ConML_UpdateDeviceInfo_s()
+    {
+    }
+
+ConML_UpdateDeviceInfo_s::~ConML_UpdateDeviceInfo_s()
+    {
+    delete deviceInfo;
+    delete results;
+    }
+
+CXMLElement* ConML_UpdateDeviceInfo_s::BeginElementL(
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLDeviceInfo:
+            CHECK_NO_DUPLICATE ( deviceInfo )
+            deviceInfo = new ( ELeave ) ConML_DeviceInfo_t();
+            return deviceInfo;
+		
+        case EConMLResults:
+            CHECK_NO_DUPLICATE ( results )
+            results = new ( ELeave ) ConML_Results_t();
+            return results;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_UpdateDeviceInfo_s::\
+            BeginElement() : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_ListPublicFiles_s
+// -----------------------------------------------------------------------------
+ConML_ListPublicFiles_s::ConML_ListPublicFiles_s()
+    {
+    }
+
+ConML_ListPublicFiles_s::~ConML_ListPublicFiles_s()
+    {
+    delete results;
+    delete sid;
+    }
+
+CXMLElement* ConML_ListPublicFiles_s::BeginElementL(
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLResults:
+            CHECK_NO_DUPLICATE ( results );
+            results = new ( ELeave ) ConML_Results_t();
+            return results;
+		
+        case EConMLSID:
+            return AddSIDL ( &sid );
+	
+        default:
+            LOGGER_WRITE_1( "ConML_ListPublicFiles_s::\
+            BeginElement() : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+	
+// -----------------------------------------------------------------------------
+// ConML_Task_s
+// -----------------------------------------------------------------------------
+ConML_GetDataOwnerStatus_s::ConML_GetDataOwnerStatus_s()
+    {
+    }
+
+ConML_GetDataOwnerStatus_s::~ConML_GetDataOwnerStatus_s()
+    {
+    delete dataOwners;
+    delete results;
+    }
+    
+CXMLElement* ConML_GetDataOwnerStatus_s::BeginElementL(
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )
+    {   
+    switch ( aTag )
+        {
+        case EConMLResults:
+            CHECK_NO_DUPLICATE ( results );
+            results = new ( ELeave ) ConML_Results_t();
+            return results;
+		
+        case EConMLDataOwners:
+            CHECK_NO_DUPLICATE ( dataOwners );
+            dataOwners = new ( ELeave ) ConML_DataOwners_t();
+            return dataOwners;
+
+        default:
+            LOGGER_WRITE_1( "ConML_GetDataOwnerStatus_s::\
+            BeginElement() : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_GetMetadata_s
+// -----------------------------------------------------------------------------
+ConML_GetMetadata_s::ConML_GetMetadata_s()
+    {
+    }
+
+ConML_GetMetadata_s::~ConML_GetMetadata_s()
+    {
+    delete filename;
+    delete results;
+    }
+    
+CXMLElement* ConML_GetMetadata_s::BeginElementL(
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )
+    {   
+    switch ( aTag )
+        {
+        case EConMLResults:
+            CHECK_NO_DUPLICATE ( results );
+            results = new ( ELeave ) ConML_Results_t();
+            return results;
+		
+        case EConMLFilename:
+            CHECK_NO_DUPLICATE ( filename );
+            filename = new ( ELeave ) pcdata_t();
+            return filename;
+
+        default:
+            LOGGER_WRITE_1( "ConML_GetMetadata_s::\
+            BeginElement() : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+	
+// -----------------------------------------------------------------------------
+// ConML_Reboot_s
+// -----------------------------------------------------------------------------
+ConML_Reboot_s::ConML_Reboot_s()
+    {
+    }
+
+ConML_Reboot_s::~ConML_Reboot_s()
+    {
+    delete results;
+    }
+
+CXMLElement* ConML_Reboot_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )
+    {
+    switch ( aTag )
+        {
+        case EConMLResults:
+            CHECK_NO_DUPLICATE ( results );
+            results = new ( ELeave ) ConML_Results_t();
+            return results;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_Reboot_s::BeginElementL()\
+             : Unknown element %d ", aTag );
+            User::Leave ( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+	
+// -----------------------------------------------------------------------------
+// ConML_Task_s
+// -----------------------------------------------------------------------------
+ConML_Task_s::ConML_Task_s()
+    {
+    }
+
+ConML_Task_s::~ConML_Task_s()
+    {
+    delete id;
+    delete install;
+    delete unInstall;
+    delete listInstalledApps;
+    delete listDataOwners;
+    delete setBurMode;
+    delete getDataSize;
+    delete requestData;
+    delete updateDeviceInfo;
+    delete listPublicFiles;
+    delete getDataOwnerStatus;
+    delete supplyData;
+    delete reboot;
+    delete getMetadata;
+    }
+
+CXMLElement* ConML_Task_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLID:
+            CHECK_NO_DUPLICATE ( id )
+            id = new ( ELeave ) pcdata_t();
+            return id;
+		
+        case EConMLInstall:
+            CHECK_NO_DUPLICATE ( install );
+            install = new ( ELeave ) ConML_Install_t();
+            return install;
+		
+        case EConMLUnInstall:
+            CHECK_NO_DUPLICATE ( unInstall );
+            unInstall = new ( ELeave ) ConML_UnInstall_t();
+            return unInstall;
+		
+        case EConMLListInstalledApps:
+            CHECK_NO_DUPLICATE ( listInstalledApps );
+            listInstalledApps = new ( ELeave ) ConML_ListInstalledApps_t();
+            return listInstalledApps;
+		
+        case EConMLListDataOwners:
+            CHECK_NO_DUPLICATE ( listDataOwners );
+            listDataOwners = new ( ELeave ) ConML_ListDataOwners_t();
+            return listDataOwners;
+		
+        case EConMLSetBURMode:
+            CHECK_NO_DUPLICATE ( setBurMode );
+            setBurMode = new ( ELeave ) ConML_SetBURMode_t();
+            return setBurMode;
+		
+        case EConMLGetDataSize:
+            CHECK_NO_DUPLICATE ( getDataSize );
+            getDataSize = new ( ELeave ) ConML_GetDataSize_t();
+            return getDataSize;
+		
+        case EConMLRequestData:
+            CHECK_NO_DUPLICATE ( requestData )
+            requestData = new ( ELeave ) ConML_RequestData_t();
+            return requestData;
+		
+        case EConMLUpdateDeviceInfo:
+            CHECK_NO_DUPLICATE ( updateDeviceInfo );
+            updateDeviceInfo = new ( ELeave ) ConML_UpdateDeviceInfo_t();
+            return updateDeviceInfo;
+		
+        case EConMLListPublicFiles:
+            CHECK_NO_DUPLICATE ( listPublicFiles );
+            listPublicFiles = new ( ELeave ) ConML_ListPublicFiles_t();
+            return listPublicFiles;
+		
+        case EConMLGetDataOwnerStatus:
+            CHECK_NO_DUPLICATE ( getDataOwnerStatus );
+            getDataOwnerStatus = new ( ELeave ) ConML_GetDataOwnerStatus_t();
+            return getDataOwnerStatus;
+		
+        case EConMLSupplyData:
+            CHECK_NO_DUPLICATE ( supplyData );
+            supplyData = new ( ELeave ) ConML_SupplyData_t();
+            return supplyData;
+		
+        case EConMLReboot:
+            CHECK_NO_DUPLICATE ( reboot );
+            reboot = new ( ELeave ) ConML_Reboot_t();
+            return reboot;
+        case EConMLGetMetadata:
+            CHECK_NO_DUPLICATE ( getMetadata );
+            getMetadata = new ( ELeave ) ConML_GetMetadata_t();
+            return getMetadata;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_Task_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_TaskList_s
+// -----------------------------------------------------------------------------
+ConML_TaskList_s::ConML_TaskList_s()
+    {
+    }
+	
+ConML_TaskList_s::~ConML_TaskList_s()
+    {
+    delete data;
+    delete next;
+    }	
+
+// -----------------------------------------------------------------------------
+// ConML_Status_s
+// -----------------------------------------------------------------------------
+ConML_Status_s::ConML_Status_s()
+    {
+    }
+	
+ConML_Status_s::~ConML_Status_s()
+    {
+    delete task;
+    }
+
+CXMLElement* ConML_Status_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLTask:
+            return AddTaskL( &task );
+				
+        default:
+            LOGGER_WRITE_1( "ConML_Status_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_Cancel_s
+// -----------------------------------------------------------------------------
+ConML_Cancel_s::ConML_Cancel_s()
+    {
+    }
+
+ConML_Cancel_s::~ConML_Cancel_s()
+    {
+    delete id;
+    delete all;
+    }
+
+CXMLElement* ConML_Cancel_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLID:
+            CHECK_NO_DUPLICATE ( id );
+            id = new ( ELeave ) pcdata_t();
+            return id;
+		
+        case EConMLAll:
+            CHECK_NO_DUPLICATE ( all );
+            all = new ( ELeave ) pcdata_t();
+            return all;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_Cancel_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_GetStatus_s
+// -----------------------------------------------------------------------------
+ConML_GetStatus_s::ConML_GetStatus_s()
+    {
+    }
+
+ConML_GetStatus_s::~ConML_GetStatus_s()
+    {
+    delete id;
+    delete all;
+    }
+
+CXMLElement* ConML_GetStatus_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLID:
+        CHECK_NO_DUPLICATE ( id );
+        id = new ( ELeave ) pcdata_t();
+        return id;
+		
+        case EConMLAll:
+            CHECK_NO_DUPLICATE ( all );
+            all = new ( ELeave ) pcdata_t();
+            return all;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_GetStatus_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_SupplyData_s
+// -----------------------------------------------------------------------------
+ConML_SupplyData_s::ConML_SupplyData_s()
+    {
+    }
+
+ConML_SupplyData_s::~ConML_SupplyData_s()
+    {
+    delete sid;
+    delete results;
+    }
+
+CXMLElement* ConML_SupplyData_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    switch ( aTag )
+        {
+        case EConMLSID:
+            return AddSIDL ( &sid );
+		
+        case EConMLResults:
+            results = new ( ELeave ) ConML_Results_t();
+            return results;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_SupplyData_s::BeginElement() :\
+             Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// ConML_Execute_
+// -----------------------------------------------------------------------------
+ConML_Execute_s::ConML_Execute_s()
+    {
+    }
+
+ConML_Execute_s::~ConML_Execute_s()
+    {
+    delete id;
+    delete install;
+    delete unInstall;
+    delete listInstalledApps;
+    delete listDataOwners;
+    delete setBurMode;
+    delete getDataSize;
+    delete requestData;
+    delete updateDeviceInfo;
+    delete listPublicFiles;
+    delete supplyData;
+    delete reboot;
+    delete getDataOwnerStatus;
+    delete getMetadata;
+    }
+
+CXMLElement* ConML_Execute_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )	
+    {
+    
+    switch ( aTag )
+        {
+        case EConMLID:
+            CHECK_NO_DUPLICATE ( id );
+            id = new ( ELeave ) pcdata_t();
+            return id;
+		
+        case EConMLInstall:
+            CHECK_NO_DUPLICATE ( install );
+            install = new ( ELeave ) ConML_Install_t();
+            return install;
+
+        case EConMLUpdateDeviceInfo:
+            CHECK_NO_DUPLICATE (updateDeviceInfo);
+            updateDeviceInfo = new ( ELeave ) ConML_UpdateDeviceInfo_t();
+            return updateDeviceInfo;
+		
+        case EConMLUnInstall:
+            CHECK_NO_DUPLICATE ( unInstall );
+            unInstall = new ( ELeave ) ConML_UnInstall_t();
+            return unInstall;
+			
+        case EConMLListInstalledApps:
+            CHECK_NO_DUPLICATE ( listInstalledApps );
+            listInstalledApps = new ( ELeave ) ConML_ListInstalledApps_t();
+            return listInstalledApps;
+		
+        case EConMLListDataOwners:
+            CHECK_NO_DUPLICATE ( listDataOwners );
+            listDataOwners = new ( ELeave ) ConML_ListDataOwners_t();
+            return listDataOwners;
+		
+        case EConMLSetBURMode:
+            CHECK_NO_DUPLICATE ( setBurMode );
+            setBurMode = new ( ELeave ) ConML_SetBURMode_t();
+            return setBurMode;
+		
+        case EConMLGetDataSize:
+            CHECK_NO_DUPLICATE ( getDataSize );
+            getDataSize = new ( ELeave ) ConML_GetDataSize_t();
+            return getDataSize;
+		
+        case EConMLRequestData:
+            CHECK_NO_DUPLICATE ( requestData );
+            requestData = new ( ELeave ) ConML_RequestData_t();
+            return requestData;
+		
+        case EConMLListPublicFiles:
+            CHECK_NO_DUPLICATE ( listPublicFiles );
+            listPublicFiles = new ( ELeave ) ConML_ListPublicFiles_t();
+            return listPublicFiles;
+		
+        case EConMLSupplyData:
+            CHECK_NO_DUPLICATE ( supplyData );
+            supplyData = new ( ELeave ) ConML_SupplyData_t();
+            return supplyData;
+		
+        case EConMLReboot:
+            CHECK_NO_DUPLICATE ( reboot );
+            reboot = new ( ELeave ) pcdata_t();
+            return reboot;
+		
+        case EConMLGetDataOwnerStatus:
+            CHECK_NO_DUPLICATE ( getDataOwnerStatus );
+            getDataOwnerStatus = new ( ELeave ) ConML_GetDataOwnerStatus_t();
+            return getDataOwnerStatus;
+        
+        case EConMLGetMetadata:
+            CHECK_NO_DUPLICATE ( getMetadata );
+            getMetadata = new ( ELeave ) ConML_GetMetadata_t();
+            return getMetadata;
+		
+        default:
+            LOGGER_WRITE_1( "ConML_Execute_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+	
+// -----------------------------------------------------------------------------
+// ConML_ConML_s
+// -----------------------------------------------------------------------------
+ConML_ConML_s::ConML_ConML_s()
+    {
+    }
+
+ConML_ConML_s::~ConML_ConML_s()
+    {
+    delete execute;
+    delete getStatus;
+    delete cancel;
+    delete status;
+    }
+
+CXMLElement* ConML_ConML_s::BeginElementL( 
+    TUint8 aTag, const TXMLElementParams& /*aParams*/ )
+    {
+    switch( aTag )
+        {
+        case EConMLExecute:
+            CHECK_NO_DUPLICATE( execute );
+            execute = new (ELeave) ConML_Execute_t();
+            return execute;
+		
+        case EConMLGetStatus:
+            CHECK_NO_DUPLICATE ( getStatus );
+            getStatus = new ( ELeave) ConML_GetStatus_t();
+            return getStatus;
+		
+        case EConMLCancel:
+            CHECK_NO_DUPLICATE ( cancel );
+            cancel = new ( ELeave ) ConML_Cancel_t();
+            return cancel;
+		
+        case EConMLStatus:
+            CHECK_NO_DUPLICATE ( status )
+            status = new ( ELeave ) ConML_Status_t();
+            return status;
+			
+        default:
+            LOGGER_WRITE_1( "ConML_ConML_s::BeginElement()\
+             : Unknown element  %02x ", aTag );
+            User::Leave( KWBXMLParserErrorInvalidTag );
+        }
+    return KErrNone;
+    }
+
+CXMLElement::TAction ConML_ConML_s::EndElementL( TAny* aCallbacks, TUint8 aTag )
+    {
+    switch( aTag)
+        {
+        case EConML:
+            ((MWBXMLConMLCallback*) aCallbacks)->ConMLL(this);
+            return EPopAndDestroy;
+				
+        default:
+            return EPop;
+        }
+    }
+
+TBool ConML_ConML_s::NeedsCleanup() const
+    {
+    return ETrue;
+    }
+	
+
+	
+		
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/src/sconconmlgenerator.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1285 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser/generator
+*
+*/
+
+// -----------------------------------------------------------------------------
+// Includes
+// -----------------------------------------------------------------------------    
+#include "sconconmlgenerator.h"
+#include "sconconmlhandlererror.h"
+#include "sconconmldtd.h"
+#include "sconxmlelement.h"
+#include "debug.h"
+
+// -----------------------------------------------------------------------------
+// CSConConMLGenerator
+// -----------------------------------------------------------------------------
+CSConConMLGenerator::CSConConMLGenerator()
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// ~CSConConMLGenerator
+// -----------------------------------------------------------------------------
+CSConConMLGenerator::~CSConConMLGenerator()
+    {
+    if (iCmdStack)
+        {
+        iCmdStack->Reset();
+        delete iCmdStack;
+        iCmdStack = NULL;
+        }
+        
+    if ( iWBXMLWorkspace )
+        {
+        delete iWBXMLWorkspace;
+        iWBXMLWorkspace = NULL;
+        }
+        
+    if ( iXMLWorkspace )
+        {
+        delete iXMLWorkspace;
+        iXMLWorkspace = NULL;
+        }
+        
+    if (iCleanupStack)
+        {
+        iCleanupStack->ResetAndDestroy();
+        delete iCleanupStack;
+        iCleanupStack = NULL;
+        }
+
+    iElemStack.Close();
+    }
+    
+// -----------------------------------------------------------------------------
+// NewL
+// -----------------------------------------------------------------------------
+CSConConMLGenerator* CSConConMLGenerator::NewL ()
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::NewL()" );
+    CSConConMLGenerator* self = new ( ELeave ) CSConConMLGenerator();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(); // self
+    LOGGER_LEAVEFN( "CSConConMLGenerator::NewL()" );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// ConstructL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::ConstructL()
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::ConstructL()" );
+    iCmdStack = CXMLStack<CXMLElement>::NewL();
+    iCleanupStack = CXMLStack<CXMLElement>::NewL();
+    iWBXMLWorkspace = CXMLWorkspace::NewL();
+    iXMLWorkspace = CXMLWorkspace::NewL();
+    LOGGER_LEAVEFN( "CSConConMLGenerator::ConstructL()" );
+    }
+    
+// -----------------------------------------------------------------------------
+// SetCallbacks
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::SetCallback ( MWBXMLConMLCallback* aCallback )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::SetCallbacks()" );
+    iCallback = aCallback;
+    LOGGER_LEAVEFN( "CSConConMLGenerator::SetCallbacks()" );
+    }
+
+// -----------------------------------------------------------------------------
+// StartDocument
+// -----------------------------------------------------------------------------    
+void CSConConMLGenerator::StartDocument( 
+    TUint8 /*aVersion*/, TInt32 /*aPublicId*/, TUint32 /*aCharset*/ )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::StartDocumentL()" );
+    iCmdStack->Reset();
+    LOGGER_LEAVEFN( "CSConConMLGenerator::StartDocumentL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// StartDocument
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::StartDocument( 
+    TUint8 /*aVersion*/, const TDesC8& /*aPublicIdStr*/, TUint32 /*aCharset*/ )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::StartDocumentL()" );
+    iCmdStack->Reset();
+    LOGGER_LEAVEFN( "CSConConMLGenerator::StartDocumentL()" );
+    }
+    
+// -----------------------------------------------------------------------------
+// StartElementL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::StartElementL( TWBXMLTag aTag )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::StartElementL()" );
+    if( iCmdStack->Top() != 0 )
+        {
+        AddElement(iCmdStack->Top()->BeginElementL( 
+            aTag, TXMLElementParams(iCallback, iCmdStack, iCleanupStack ) ) );
+        }
+    else
+        {
+        if( aTag == EConML )
+            {
+            AddElement(new (ELeave) ConML_ConML_t());
+            }
+        else
+            {
+            LOGGER_WRITE( "CSConConMLGenerator::StartElementL() : Leave KWBXMLParserErrorInvalidTag" );
+            User::Leave(KWBXMLParserErrorInvalidTag);
+            }
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::StartElementL()" );
+    }
+    
+// -----------------------------------------------------------------------------
+// AddElement
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AddElement( CXMLElement* aElement )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AddElement()" );
+    if( aElement )
+        {
+        iCmdStack->Push(aElement);
+        if( aElement->NeedsCleanup() )
+            {
+            iCleanupStack->Push(aElement);
+            }
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AddElement()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CharactersL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::CharactersL( const TDesC8& aBuffer )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::CharactersL()" );
+    if( iCmdStack->Top() != 0 )
+        {
+        iCmdStack->Top()->SetDataL(aBuffer);
+        }
+    else
+        {
+        LOGGER_WRITE( "CSConConMLGenerator::CharactersL() : Leave KWBXMLParserErrorInvalidTag" );
+        User::Leave(KWBXMLParserErrorInvalidTag);
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::CharactersL()" );
+    }
+    
+// -----------------------------------------------------------------------------
+// EndElementL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::EndElementL( TWBXMLTag aTag )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::EndElementL()" );
+    if( iCmdStack->Top() != 0 )
+        {
+        CXMLElement::TAction action = iCmdStack->Top()->EndElementL( 
+            iCallback, aTag );
+        if( action != CXMLElement::ENone )
+            {
+            CXMLElement* elem = iCmdStack->Pop();
+            if( iCleanupStack->Top() == elem )
+                {
+                iCleanupStack->Pop();
+                }
+            if( action == CXMLElement::EPopAndDestroy )
+                {
+                delete elem;
+                }
+            }
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::EndElementL()" );
+    }
+    
+// -----------------------------------------------------------------------------
+// WriteMUint32L
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::WriteMUint32L( TUint32 aValue )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::WriteMUint32L()" );
+    TUint8 temp[5];
+    TInt i(4);
+    
+    temp[i--] = TUint8(aValue & 0x7F);
+    aValue >>= 7;
+    while( aValue > 0 )
+        {
+        temp[i--] = TUint8((aValue & 0x7F) | 0x80);
+        aValue >>= 7;
+        }
+            
+    while( i < 4 )
+        {
+        iWBXMLWorkspace->WriteL(temp[++i]);
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::WriteMUint32L()" );
+    }
+
+// -----------------------------------------------------------------------------
+// WriteOpaqueDataL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::WriteOpaqueDataL( const TDesC8& aData )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::WriteOpaqueDataL()" );
+    iWBXMLWorkspace->WriteL( OPAQUE );
+    WriteMUint32L( aData.Size() );
+    iWBXMLWorkspace->WriteL( aData );
+    iXMLWorkspace->WriteL( aData );
+    LOGGER_LEAVEFN( "CSConConMLGenerator::WriteOpaqueDataL()" );
+    }
+    
+// -----------------------------------------------------------------------------
+// WriteInlineStringL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::WriteInlineStringL( const TDesC8& aData )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::WriteInlineStringL()" );
+    iWBXMLWorkspace->WriteL( STR_I );
+    iWBXMLWorkspace->WriteL( aData );
+    iWBXMLWorkspace->WriteL( 0 );
+    iXMLWorkspace->WriteL( aData );
+    LOGGER_LEAVEFN( "CSConConMLGenerator::WriteInlineStringL()" );
+    }
+    
+// -----------------------------------------------------------------------------
+// IndentL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::IndentL()
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::IndentL()" );
+    for( TInt i = 0; i < iElemStack.Count() + iInitialIndentLevel; i++ )
+        {
+        iXMLWorkspace->WriteL(KXMLIndent());
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::IndentL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// TranslateElement
+// -----------------------------------------------------------------------------    
+TPtrC8 CSConConMLGenerator::TranslateElement( TUint8 aElement )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::TranslateElement()" );
+    TPtrC8 buf( KConMLElements );
+    while( aElement-- )
+        {
+        TInt pos = buf.Find(KXMLElemenentSeparator());
+        if( pos == KErrNotFound )
+            {
+            return TPtrC8();
+            }
+        buf.Set(buf.Right(buf.Length() - pos - 1));
+        }
+
+    TInt pos = buf.Find(KXMLElemenentSeparator());
+    
+    if( pos != KErrNotFound )
+        {
+        buf.Set(buf.Left(pos));
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::TranslateElement()" );
+    return buf;
+    }
+    
+// -----------------------------------------------------------------------------
+// EndDocument
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::EndDocument()
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::EndDocument()" );
+    LOGGER_LEAVEFN( "CSConConMLGenerator::EndDocument()" );
+    }
+
+    
+// -----------------------------------------------------------------------------
+// GenerateConMLDocument
+// -----------------------------------------------------------------------------
+TInt CSConConMLGenerator::GenerateConMLDocument ( ConML_ConMLPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::GenerateConMLDocument()" );
+    iWBXMLWorkspace->Reset();
+    iWBXMLWorkspace->BeginTransaction();
+    iXMLWorkspace->Reset();
+    iXMLWorkspace->BeginTransaction();
+    TRAPD(result, AppendConMLL(aContent));
+    LOGGER_WRITE_1( "CSConConMLGenerator::GenerateConMLDocument()\
+     : returned %d", result );
+    return HandleResult(result);
+    }
+    
+// -----------------------------------------------------------------------------
+// AppendConMLL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendConMLL( ConML_ConMLPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendConMLL()" );
+    BeginDocumentL(KSConConMLVersion, KSConConMLPublicId, KSConConMLUTF8);
+    BeginElementL(EConML, ETrue);
+    AppendExecuteL( aContent->execute );
+    AppendGetStatusL( aContent->getStatus );
+    AppendCancelL( aContent->cancel );
+    AppendStatusL( aContent->status );
+    EndElementL(); // EConML
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendConMLL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendExecuteL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendExecuteL( ConML_ExecutePtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendExecuteL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLExecute, ETrue );
+        AppendPCDataL( EConMLID, aContent->id );
+        AppendInstallL( aContent->install );
+        AppendUnInstallL( aContent->unInstall );
+        AppendListInstalledAppsL( aContent->listInstalledApps );
+        AppendListDataOwnersL( aContent->listDataOwners );
+        AppendSetBURModeL( aContent->setBurMode );
+        AppendGetDataSizeL( aContent->getDataSize );
+        AppendRequestDataL( aContent->requestData );
+        AppendUpdateDeviceInfoL( aContent->updateDeviceInfo );
+        AppendListPublicFilesL( aContent->listPublicFiles );
+        AppendSupplyDataL( aContent->supplyData );
+        AppendGetDataOwnerStatusL( aContent->getDataOwnerStatus );
+        AppendGetMetadataL( aContent->getMetadata );
+        
+        if ( aContent->reboot )
+            {
+            BeginElementL( EConMLReboot );
+            }
+        EndElementL(); // EConMLExecute
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendExecuteL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendSupplyDataL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendSupplyDataL( ConML_SupplyDataPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendSupplyDataL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLSupplyData, ETrue );
+        AppendSIDListL( aContent->sid );
+        AppendResultsL( aContent->results );
+        EndElementL(); // EConMLSupplyData
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendSupplyDataL()" );
+    }
+// -----------------------------------------------------------------------------
+// AppendInstallL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendInstallL( ConML_InstallPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendInstallL()" );
+    if ( aContent)
+        {
+        BeginElementL( EConMLInstall, ETrue );
+        AppendPCDataL( EConMLName, aContent->name );
+        if ( aContent->instParams) 
+            {
+            if ( aContent->instParams->param )
+                {
+                AppendInstParamsL( aContent->instParams );  
+                }
+            else 
+                {
+                BeginElementL( EConMLInstParams );
+                }
+            }
+        AppendResultsL( aContent->results );
+        EndElementL(); // EConMLInstall
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendInstallL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendCancelL
+// -----------------------------------------------------------------------------    
+void CSConConMLGenerator::AppendCancelL ( ConML_CancelPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendCancelL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLCancel, ETrue );
+        AppendPCDataL ( EConMLID, aContent->id );
+        AppendPCDataL( EConMLAll, aContent->all);
+        EndElementL(); // EConMLCancel
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendCancelL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendStatusL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendStatusL ( ConML_StatusPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendStatusL()" );
+    if ( aContent )
+        {
+        if ( aContent->task )
+            {
+            BeginElementL( EConMLStatus, ETrue );
+            AppendTaskListL( aContent->task );
+            EndElementL(); // EConMLStatus
+            }
+        else
+            {
+            BeginElementL( EConMLStatus );  
+            }
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendStatusL()" );
+    }
+    
+// -----------------------------------------------------------------------------
+// AppendGetStatusL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendGetStatusL( ConML_GetStatusPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendGetStatusL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLGetStatus, ETrue );
+        AppendPCDataL( EConMLID, aContent->id);
+        if ( aContent->all )
+            {
+            BeginElementL( EConMLAll );
+            }
+        EndElementL(); // EConMLGetStatus
+        }
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendGetStatusL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendRebootL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendRebootL( ConML_RebootPtr_t aContent )
+    {
+    if ( aContent )
+        {
+        BeginElementL( EConMLReboot, ETrue );
+        AppendResultsL( aContent->results );
+        EndElementL(); // EConMLReboot
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// AppendTaskL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendTaskL( ConML_TaskPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendTaskL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLTask, ETrue );
+        AppendPCDataL( EConMLID, aContent->id );
+        AppendInstallL(aContent->install );
+        AppendUnInstallL( aContent->unInstall );
+        AppendListInstalledAppsL ( aContent->listInstalledApps );
+        AppendListDataOwnersL ( aContent->listDataOwners );
+        AppendSetBURModeL ( aContent->setBurMode );
+        AppendGetDataSizeL ( aContent->getDataSize );
+        AppendRequestDataL ( aContent->requestData );
+        AppendUpdateDeviceInfoL ( aContent->updateDeviceInfo);
+        AppendListPublicFilesL ( aContent->listPublicFiles );
+        AppendGetDataOwnerStatusL( aContent->getDataOwnerStatus );
+        AppendSupplyDataL( aContent->supplyData );
+        AppendRebootL( aContent->reboot );
+        AppendGetMetadataL( aContent->getMetadata );
+        EndElementL();
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendTaskL()" );
+    }
+    
+// -----------------------------------------------------------------------------
+// AppendTaskListL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendTaskListL( ConML_TaskListPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendTaskListL()" );
+    for ( ConML_TaskListPtr_t p = aContent; p && p->data; p=p->next )
+        {
+        AppendTaskL( p->data );
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendTaskListL()" );
+    }
+    
+// -----------------------------------------------------------------------------
+// AppendListInstalledAppsL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendListInstalledAppsL ( 
+    ConML_ListInstalledAppsPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendListInstalledAppsL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLListInstalledApps, ETrue );
+        AppendDrivesL( aContent->drives );
+        if ( aContent ->all )
+            {
+            BeginElementL( EConMLAll );
+            }
+        AppendResultsL( aContent->results );
+        EndElementL(); // EConMLListInstalledApps
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendListInstalledAppsL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendListDataOwnersL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendListDataOwnersL ( 
+    ConML_ListDataOwnersPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendListDataOwnersL()" );
+    if ( aContent )
+        {
+        if ( aContent->results )
+            {
+            BeginElementL( EConMLListDataOwners, ETrue );
+            AppendResultsL( aContent->results );
+            EndElementL(); // EConMLListDataOwners
+            }
+        else
+            {
+            BeginElementL( EConMLListDataOwners );          
+            }
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendListDataOwnersL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConConMLGanerator::AppendBUROptionsL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendBUROptionsL( ConML_BUROptionsPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendBUROptionsL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLBUROptions, ETrue );
+        if ( aContent->requiresReboot )
+            {
+            BeginElementL( EConMLRequiresReboot );
+            }
+        if ( aContent->hasFiles )
+            {
+            AppendPCDataL( EConMLHasFiles, aContent->hasFiles );
+            }
+        if ( aContent->supportsInc )
+            {
+            BeginElementL( EConMLSupportsInc );
+            }
+        if ( aContent->delayToPrepareData )
+            {
+            BeginElementL( EConMLDelayToPrepareData );
+            }
+        EndElementL(); // EConMLBUROptions
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendBUROptionsL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendSetBURModeL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendSetBURModeL( ConML_SetBURModePtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendSetBURModeL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLSetBURMode, ETrue );
+        AppendDrivesL( aContent->drives );
+        AppendPCDataL( EConMLPartialType, aContent->partialType );
+        AppendPCDataL( EConMLIncType, aContent->incType );
+        AppendResultsL( aContent->results );
+        EndElementL(); //EConMLSetBURMode
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendSetBURModeL()" );
+    }
+    
+// -----------------------------------------------------------------------------
+// AppendUnInstallL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendUnInstallL( ConML_UnInstallPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendUnInstallL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLUnInstall, ETrue );
+        AppendApplicationsL( aContent->applications );
+        AppendInstParamsL( aContent->instParams );
+        AppendResultsL( aContent->results );
+        EndElementL(); // EConMLUnInstall
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendUnInstallL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendGetDataSizeL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendGetDataSizeL( ConML_GetDataSizePtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendGetDataSizeL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLGetDataSize, ETrue );
+        AppendDataOwnersL( aContent->dataOwners );
+        AppendResultsL( aContent->results );
+        EndElementL(); //EConMLGetDataSize
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendGetDataSizeL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendRequestDataL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendRequestDataL( ConML_RequestDataPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendRequestDataL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLRequestData, ETrue );
+        AppendSIDListL( aContent->sid );
+        AppendResultsL( aContent->results );
+        EndElementL();//EConMLRequestData
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendRequestDataL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendUpdateDeviceInfoL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendUpdateDeviceInfoL( 
+    ConML_UpdateDeviceInfoPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendUpdateDeviceInfoL()" );
+    if ( aContent )
+        {
+        BeginElementL(EConMLUpdateDeviceInfo, ETrue);
+        AppendDeviceInfoL( aContent-> deviceInfo );
+        AppendResultsL( aContent->results );
+        EndElementL();// EConMLUpdateDeviceInfo
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendUpdateDeviceInfoL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendListPublicFilesL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendListPublicFilesL( 
+    ConML_ListPublicFilesPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendListPublicFilesL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLListPublicFiles, ETrue );
+        AppendSIDListL ( aContent->sid );
+        AppendResultsL( aContent->results );
+        EndElementL(); // EConMLListPublicFiles
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendListPublicFilesL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendApplicationL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendApplicationL( ConML_ApplicationPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendApplicationL()" );
+    if ( aContent )
+        {
+        BeginElementL(EConMLApplication, ETrue );
+        AppendPCDataL( EConMLName, aContent->name );
+        AppendPCDataL( EConMLUID, aContent->uid );
+        EndElementL(); //EConMLApplication
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendApplicationL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendApplicationListL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendApplicationListL( 
+    ConML_ApplicationListPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendApplicationListL()" );
+    for ( ConML_ApplicationListPtr_t p = aContent; p && p->data; p = p->next )
+        {
+        AppendApplicationL( p->data );
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendApplicationListL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendApplicationsL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendApplicationsL( 
+    ConML_ApplicationsPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendApplicationsL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLApplications, ETrue );
+        AppendApplicationListL( aContent->application );
+        EndElementL(); // EConMLApplications
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendApplicationsL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendParamL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendParamL( ConML_ParamPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendParamL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLParam, ETrue );
+        AppendPCDataL( EConMLName, aContent->name );
+        AppendPCDataL( EConMLValue, aContent->value );
+        EndElementL(); // EConMLParam
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendParamL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendParamListL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendParamListL( ConML_ParamListPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendParamListL()" );
+    for ( ConML_ParamListPtr_t p = aContent; p && p->data; p = p->next )
+        {
+        AppendParamL( p-> data );
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendParamListL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendInstParamsL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendInstParamsL( ConML_InstParamsPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendInstParamsLionsL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLInstParams, ETrue );
+        AppendParamListL( aContent->param );
+        EndElementL(); //EConMLInstParams
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendInstParamsL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendProgressL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendProgressL( ConML_ProgressPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendProgressL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLProgress, ETrue );
+        AppendPCDataL( EConMLValue, aContent->value );
+        EndElementL(); // EconMLProgress
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendProgressL()" );
+    }
+    
+// -----------------------------------------------------------------------------
+// AppendResultsL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendResultsL( ConML_ResultsPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendResultsL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLResults, ETrue );
+        if ( aContent->complete )
+            {
+            BeginElementL( EConMLComplete );
+            }
+        AppendProgressL( aContent->progress );
+        AppendApplicationsL( aContent->applications );
+        AppendDataOwnersL( aContent->dataOwners );
+        if ( aContent->filename )
+            {
+            AppendPCDataL( EConMLFilename, aContent->filename );
+            }
+        AppendPCDataL( EConMLData, aContent->data );
+        if ( aContent->moreData )
+            {
+            BeginElementL( EConMLMoreData );
+            }
+        AppendDeviceInfoL( aContent->deviceInfo );
+        AppendFilesL( aContent->files );
+        EndElementL(); //EConMLResults
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendResultsL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendDriveL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendDriveL( ConML_DrivePtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendDriveL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLDrive, ETrue );
+        AppendPCDataL( EConMLName, aContent->name );
+        EndElementL(); //EConMLDrive
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendDriveL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendDriveListL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendDriveListL( ConML_DriveListPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendDriveListL()" );
+    for ( ConML_DriveListPtr_t p =  aContent; p && p->data; p=p->next )
+        {
+        AppendDriveL( p->data );
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendDriveListL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendDrivesL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendDrivesL( ConML_DrivesPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendDrivesL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLDrives, ETrue );
+        AppendDriveListL( aContent->drive );
+        EndElementL(); // EConMLDrives
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendDrivesL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendDataOwnersL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendDataOwnersL( ConML_DataOwnersPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendDataOwnersL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLDataOwners, ETrue );
+        AppendSIDListL( aContent->sid );
+        EndElementL(); //EConMLDataOwners
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendDataOwnersL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendGetDataOwnerStatusL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendGetDataOwnerStatusL
+    ( ConML_GetDataOwnerStatusPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendDataOwnerStatusL()" );
+    if ( aContent)
+        {
+        BeginElementL( EConMLGetDataOwnerStatus, ETrue );
+        AppendDataOwnersL( aContent->dataOwners );
+        AppendResultsL( aContent->results );
+        EndElementL(); // EconMLGetDataOwnerStatus
+        }
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendDataOwnerStatusL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendGetMetadataL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendGetMetadataL
+    ( ConML_GetMetadataPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendGetMetadataL()" );
+    if ( aContent)
+        {
+        BeginElementL( EConMLGetMetadata, ETrue );
+        AppendPCDataL( EConMLFilename, aContent->filename );
+        AppendResultsL( aContent->results );
+        EndElementL(); // EConMLGetMetadata
+        }
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendGetMetadataL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendPackageInfoL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendPackageInfoL ( ConML_PackageInfoPtr_t aContent )
+    {
+    if ( aContent )
+        {
+        BeginElementL( EConMLPackageInfo, ETrue );
+        AppendPCDataL( EConMLName, aContent->name );
+        EndElementL(); // EConMLPackageInfo
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// AppendSIDL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendSIDL( ConML_SIDPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendSIDL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLSID, ETrue );
+        AppendPCDataL( EConMLType, aContent->type );
+        AppendPCDataL( EConMLUID, aContent->uid );
+        AppendPCDataL( EConMLDataOwnerStatus, aContent->dataOwnerStatus );
+        AppendDrivesL( aContent->drives );
+        if ( aContent->size )
+            {
+            AppendPCDataL( EConMLSize, aContent->size ); 
+            }
+        AppendPackageInfoL( aContent->packageInfo );
+        AppendBUROptionsL( aContent->burOptions );
+        AppendPCDataL( EConMLTransferDataType, aContent->transferDataType );
+        AppendPCDataL( EConMLData, aContent->data );
+        if ( aContent->moreData)
+            {
+            BeginElementL(EConMLMoreData );
+            }
+        EndElementL(); // EconMLSID
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendSIDL()" );
+    }
+    
+// -----------------------------------------------------------------------------
+// AppendSIDListL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendSIDListL( ConML_SIDListPtr_t aContent )
+    {
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendSIDListL()" );
+    for ( ConML_SIDListPtr_t p = aContent; p && p->data; p=p->next )
+        {
+        AppendSIDL( p->data );
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendSIDListL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendDeviceInfoL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendDeviceInfoL( ConML_DeviceInfoPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendDeviceInfoL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLDeviceInfo, ETrue );
+        AppendPCDataL( EConMLVersion, aContent->version );
+        AppendSupportedMethodsL ( aContent->supportedMethods );
+        AppendPCDataL(EConMLMaxObjectSize, aContent->maxObjectSize );
+        EndElementL(); // EConMLDeviceInfo
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendDeviceInfoL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendFilesL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendFilesL( ConML_FilesPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendFilesL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLFiles, ETrue );
+        AppendFileListL( aContent->file );
+        EndElementL(); // EConMLFiles
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendFilesL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendSupportedMethodsL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendSupportedMethodsL
+    ( ConML_SupportedMethodsPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendSupportedMethodsL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLSupportedMethods, ETrue );
+        if  ( aContent->install )
+            {
+            BeginElementL( EConMLInstall );
+            }
+        if ( aContent->unInstall )
+            {
+            BeginElementL( EConMLUnInstall );
+            }
+        if ( aContent->listInstalledApps )
+            {
+            BeginElementL( EConMLListInstalledApps );
+            }
+        if ( aContent->listDataOwners )
+            {
+            BeginElementL( EConMLListDataOwners );
+            }
+        if ( aContent->setBurMode )
+            {
+            BeginElementL( EConMLSetBURMode );
+            }
+        if ( aContent->getDataSize )
+            {
+            BeginElementL( EConMLGetDataSize );
+            }
+        if ( aContent->requestData )
+            {
+            BeginElementL( EConMLRequestData );
+            }
+        if ( aContent->supplyData )
+            {
+            BeginElementL( EConMLSupplyData );
+            }
+        if ( aContent->reboot )
+            {
+            BeginElementL( EConMLReboot );
+            }
+        EndElementL(); // EConMLSupportedMethods
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendSupportedMethodsL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendFileListL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendFileListL( ConML_FileListPtr_t  aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendFileListL()" );
+    if ( aContent )
+        {
+        for ( ConML_FileListPtr_t p = aContent; p && p->data; p = p->next )
+            {
+            AppendFileL(p->data );
+            }
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendFileListL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendFileL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendFileL( ConML_FilePtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendFileL()" );
+    if ( aContent )
+        {
+        BeginElementL( EConMLFile, ETrue );
+        AppendPCDataL( EConMLName, aContent->name );
+        AppendPCDataL( EConMLModified, aContent->modified );
+        AppendPCDataL( EConMLSize, aContent->size );
+        AppendPCDataL( EConMLUserPerm, aContent->userPerm );
+        EndElementL(); // EConMLFile
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendFileL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// HandleResult
+// -----------------------------------------------------------------------------
+TInt CSConConMLGenerator::HandleResult( TInt aResult, TInt aTreshold )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::HandleResult()" );
+    switch( aResult )
+        {
+        case KErrNone:
+            if( iWBXMLWorkspace->FreeSize() < aTreshold )
+                {               
+                iWBXMLWorkspace->Rollback();
+                return KWBXMLGeneratorBufferFull;
+                }
+            iWBXMLWorkspace->Commit();
+            return KWBXMLGeneratorOk;
+
+        case KErrTooBig:
+            iWBXMLWorkspace->Rollback();
+            return KWBXMLGeneratorBufferFull;
+        }
+    LOGGER_WRITE_1( "CSConConMLGenerator::HandleResult()\
+     : returned %d", aResult);
+    return aResult;
+    }
+
+// -----------------------------------------------------------------------------
+// BeginDocumentL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::BeginDocumentL( 
+    TUint8 aVersion, 
+    TInt32 aPublicId, 
+    TUint32 aCharset, 
+    const TDesC8& aStringTbl )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::BeginDocumentL()" );
+    iWBXMLWorkspace->WriteL(aVersion);
+
+    if( aPublicId <= 0 )
+        {
+        iWBXMLWorkspace->WriteL(0);
+        WriteMUint32L(-aPublicId);
+        }
+    else
+        {
+        WriteMUint32L(aPublicId);
+        }
+    WriteMUint32L(aCharset);
+    WriteMUint32L(aStringTbl.Size());
+    iWBXMLWorkspace->WriteL(aStringTbl);
+    LOGGER_LEAVEFN( "CSConConMLGenerator::BeginDocumentL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// BeginElementL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::BeginElementL( 
+    TUint8 aElement, TBool aHasContent, TBool aHasAttributes )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::BeginElementL()" );
+    IndentL();
+    iXMLWorkspace->WriteL(KXMLTagStart());
+    iXMLWorkspace->WriteL(TranslateElement(aElement));
+        
+    if( aHasAttributes )
+        {
+        aElement |= KWBXMLHasAttributes;
+        }
+        
+    if( aHasContent )
+        {
+        iXMLWorkspace->WriteL(KXMLTagEnd());
+        iElemStack.Insert(aElement, 0);
+        aElement |= KWBXMLHasContent;
+        }
+    else
+        {
+        iXMLWorkspace->WriteL(KXMLTagEndNoContent());
+        }
+
+    if( !iDontNewLine )
+        {
+        iXMLWorkspace->WriteL(KXMLNewLine());
+        }
+    iDontNewLine = EFalse;
+
+    WriteMUint32L(aElement);
+    LOGGER_LEAVEFN( "CSConConMLGenerator::BeginElementL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// EndElementL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::EndElementL()
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::EndElementL()" );
+    TUint8 elem = iElemStack[0];
+    iElemStack.Remove(0);
+    if( !iDontIndent )
+        {
+        IndentL();
+        }
+    iDontIndent = EFalse;
+    iXMLWorkspace->WriteL(KXMLTagStartEndTag());
+    iXMLWorkspace->WriteL(TranslateElement(elem));
+    iXMLWorkspace->WriteL(KXMLTagEnd());
+    iXMLWorkspace->WriteL(KXMLNewLine());
+    
+    iWBXMLWorkspace->WriteL(END);
+    
+    LOGGER_LEAVEFN( "CSConConMLGenerator::EndElementL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AddElementL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AddElementL( 
+    TUint8 aElement, const TDesC8& aContent, const TWBXMLContentFormat aFormat )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AddElementL()" );
+    iDontNewLine = ETrue;
+    BeginElementL(aElement, ETrue);
+    if( aFormat == EWBXMLContentFormatOpaque )
+        {
+        WriteOpaqueDataL(aContent);
+        }
+    else
+        {
+        WriteInlineStringL(aContent);
+        }
+    iDontIndent = ETrue;
+    EndElementL();
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AddElementL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// AppendPCDataL
+// -----------------------------------------------------------------------------
+void CSConConMLGenerator::AppendPCDataL( TUint8 aElement, pcdataPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::AppendPCDataL()" );
+    if( !aContent )
+        {
+        return;
+        }
+
+    if( aContent->contentType == SML_PCDATA_OPAQUE )
+        {
+        AddElementL(aElement, 
+                    TPtrC8((TUint8*)aContent->content, 
+                    aContent->length));
+        }
+    else
+        {
+        LOGGER_WRITE( "CSConConMLGenerator::AppendPCDataL() : Data type not Opaque - ignoring " );
+        }
+    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendPCDataL()" );
+    }
+    
+// -----------------------------------------------------------------------------
+// WBXMLDocument
+// -----------------------------------------------------------------------------
+TPtrC8 CSConConMLGenerator::WBXMLDocument()
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::WBXMLDocument()" );
+    LOGGER_LEAVEFN( "CSConConMLGenerator::WBXMLDocument()" );
+    return iWBXMLWorkspace->Buffer();
+    }
+    
+// -----------------------------------------------------------------------------
+// XMLDocument
+// -----------------------------------------------------------------------------
+TPtrC8 CSConConMLGenerator::XMLDocument()
+    {
+    LOGGER_ENTERFN( "CSConConMLGenerator::XMLDocument()" );
+    LOGGER_LEAVEFN( "CSConConMLGenerator::XMLDocument()" );
+    return iXMLWorkspace->Buffer();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/src/sconconmlhandler.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,474 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser/generator
+*
+*/
+
+
+// -----------------------------------------------------------------------------
+// Includes
+// -----------------------------------------------------------------------------
+#include <s32mem.h>
+
+#include "sconconmlhandler.h"
+#include "debug.h"
+
+// -----------------------------------------------------------------------------
+// CreateCSConConMLHandlerL
+// Creates a new instance of CSConConMLHandler
+// -----------------------------------------------------------------------------
+//  
+EXPORT_C CSConConMLHandler* CreateCSConConMLHandlerL()
+    {
+    LOGGER_ENTERFN( "CreateCSConConMLHandlerL()" );
+    LOGGER_LEAVEFN( "CreateCSConConMLHandlerL()" );
+    return CSConConMLHandler::NewL();
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::CSConConMLHandler()
+// Default constructor
+// -----------------------------------------------------------------------------
+//  
+CSConConMLHandler::CSConConMLHandler()
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::CSConConMLHandler()
+// Default constructor
+// -----------------------------------------------------------------------------
+//  
+CSConConMLHandler::~CSConConMLHandler()
+    {
+    LOGGER_ENTERFN( "CSConConMLHandler::~CSConConMLHandler()" );
+    
+    if ( iParseBuffer )
+        {
+        LOGGER_WRITE( "CSConConMLHandler::~CSConConMLHandler() : phase 1/4 " );
+        delete iParseBuffer;
+        iParseBuffer = NULL;
+        }
+    
+    if ( iBuffer )
+        {
+        LOGGER_WRITE( "CSConConMLHandler::~CSConConMLHandler() : phase 2/4 " );
+        delete iBuffer;
+        iBuffer = NULL;
+        }
+    
+    if ( iGenerator )
+        {
+        LOGGER_WRITE( "CSConConMLHandler::~CSConConMLHandler() : phase 3/4 " );
+        delete iGenerator;
+        iGenerator = NULL;
+        }
+
+    if ( iStringTable )
+        {
+        LOGGER_WRITE( "CSConConMLHandler::~CSConConMLHandler() : phase 4/4 " );
+        delete iStringTable;
+        iStringTable = NULL;
+        }
+
+    iElemStack.Close();
+    
+    LOGGER_LEAVEFN( "CSConConMLHandler::~CSConConMLHandler()" );
+    }
+        
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::CSConConMLHaNewL()
+// Creates a new instance of CSConConMLHandler
+// -----------------------------------------------------------------------------
+//  
+CSConConMLHandler* CSConConMLHandler::NewL()
+    {
+    LOGGER_ENTERFN( "CSConConMLHandler::NewL()" );
+    CSConConMLHandler* self = new ( ELeave ) CSConConMLHandler();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(); // self
+    LOGGER_LEAVEFN( "CSConConMLHandler::NewL()" );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::ConstructL()
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+//  
+void CSConConMLHandler::ConstructL()
+    {
+    LOGGER_ENTERFN( "CSConConMLHandler::ConstructL()" );
+    iGenerator = CSConConMLGenerator::NewL();
+    iBuffer = CBufFlat::NewL( KSConBufferGranularity );
+    iParseBuffer = CBufFlat::NewL( KSConDefaultDocumentSize );
+    LOGGER_LEAVEFN( "CSConConMLHandler::ConstructL()" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::ParseDocumentL()
+// Handles the document parsing, document in aInput
+// -----------------------------------------------------------------------------
+//  
+TInt CSConConMLHandler::ParseDocumentL( 
+    CBufFlat& aInput, MWBXMLConMLCallback* aCallback )
+    {
+    LOGGER_ENTERFN( "CSConConMLHandler::ParseDocument()" );
+    TInt ret ( KErrNone );
+        
+    iPos = 0;
+    iParseBuffer->Reset();
+    iParseBuffer->ResizeL( aInput.Size() );
+    iParseBuffer->Write( 0, aInput.Ptr(0) );
+    iHeaderParsed = EFalse;
+    iGenerator->SetCallback( aCallback );
+
+    while (ret == KWBXMLParserErrorOk )
+        {
+        ret = ParseL();
+        }
+
+    if ( ret == KWBXMLParserErrorEof ) 
+        {
+        ret = KErrNone;
+        }
+    LOGGER_WRITE_1( "CSConConMLHandler::ParseDocument()\
+     returned %d", ret );   
+    return ( ret );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::GenerateDocument()
+// Starts the generating of a document
+// -----------------------------------------------------------------------------
+//  
+TInt CSConConMLHandler::GenerateDocument( ConML_ConMLPtr_t aContent )
+    {
+    LOGGER_ENTERFN( "CSConConMLHandler::GenerateDocument()" );
+    iGenerator->GenerateConMLDocument ( aContent );
+    LOGGER_LEAVEFN( "CSConConMLHandler::GenerateDocument()" );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::WBXMLDocument()
+// Returns the generated WBXML -document
+// -----------------------------------------------------------------------------
+//  
+TPtrC8 CSConConMLHandler::WBXMLDocument()
+    {
+    LOGGER_ENTERFN( "CSConConMLHandler::WBXMLDocument()" );
+    LOGGER_LEAVEFN( "CSConConMLHandler::WBXMLDocument()" );
+    return iGenerator->WBXMLDocument();
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::XMLDocument()
+// Returns the generated XML -document
+// -----------------------------------------------------------------------------
+//  
+TPtrC8 CSConConMLHandler::XMLDocument()
+    {
+    LOGGER_ENTERFN( "CSConConMLHandler::XMLDocument()" );
+    LOGGER_LEAVEFN( "CSConConMLHandler::XMLDocument()" );
+    return iGenerator->XMLDocument();
+    }
+
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::ParseL()
+// Parses the next document tag / header if not parsed yet
+// -----------------------------------------------------------------------------
+//  
+TInt CSConConMLHandler::ParseL()
+    {
+    LOGGER_ENTERFN( "CSConConMLHandler::ParseL()" );
+    if( !iHeaderParsed )
+        {
+        TConMLParserError result(KWBXMLParserErrorOk);
+        TRAPD(err,  result = DoParseDocumentHeaderL());
+        if( err == KErrEof )
+            {
+            LOGGER_WRITE( "CSConConMLHandler::ParseL() : KWBXMLParserErrorEofTooEarly " );
+            return KWBXMLParserErrorEofTooEarly;
+            }
+        return result;
+        }
+    LOGGER_LEAVEFN( "CSConConMLHandler::ParseL()" );
+    return DoParseDocumentBodyL();
+    }
+
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::DoParseDocumentHeaderL()
+// Parses the document header
+// -----------------------------------------------------------------------------
+//  
+TConMLParserError CSConConMLHandler::DoParseDocumentHeaderL()
+    {
+    LOGGER_ENTERFN( "CSConConMLParser::DoParseDocumentHeaderL()" );
+    iHeaderParsed = ETrue;
+
+    // Version
+    TUint8 version = ReadUint8L();
+    
+    // PublicId
+    TInt32 publicId = ReadMUint32L();
+
+    if( publicId == 0 )
+        {
+        publicId = ReadMUint32L();
+        }
+    else
+        {
+        publicId = -publicId;
+        }
+
+    // Charset
+    TUint32 charSet = ReadMUint32L();
+
+    // String table
+    ReadStringTableL();
+
+    // Document begins now
+    if( publicId < 0 )
+        {
+        iGenerator->StartDocument(version, -publicId, charSet);
+        }
+    else
+        {
+        iGenerator->StartDocument(version, 
+            StringTableString(publicId), charSet);
+        }
+    LOGGER_LEAVEFN( "CSConConMLHandler::DoParseDocumentHeaderL()" );
+    return KWBXMLParserErrorOk;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::DoParseDocumentBodyL()
+// Parses the next element of the document
+// -----------------------------------------------------------------------------
+//  
+TConMLParserError CSConConMLHandler::DoParseDocumentBodyL()
+    {
+    LOGGER_ENTERFN( "CSConConMLHandler::DoParseDocumentBodyL()" );
+    TUint8 id(0);
+    TRAPD(err, id = ReadUint8L());
+
+    if( err != KErrNone )
+        {
+        if( err == KErrEof )
+            {
+            iGenerator->EndDocument();
+            if( iElemStack.Count() > 0 )
+                {
+                LOGGER_WRITE( "CSConConMLHandler::DoParseDocumentBodyL() : KWBXMLParserErrorEofTooEarly " );
+                return KWBXMLParserErrorEofTooEarly;
+                }
+            return KWBXMLParserErrorEof;
+            }
+        User::Leave(err);
+        }
+    
+    switch (id) 
+        {
+        case END:
+            {
+            if( !iElemStack.Count() )
+                {
+                LOGGER_WRITE( "CSConConMLHandler::DoParseDocumentBodyL() : KWBXMLParserErrorinvalidDocument " );
+                User::Leave( KWBXMLParserErrorinvalidDocument );
+                }
+            TUint8 tag( iElemStack.operator[](iElemStack.Count() - 1 ));
+            iGenerator->EndElementL( tag );
+            iElemStack.Remove(iElemStack.Count() - 1);
+            }
+            break;
+    
+        case STR_I: 
+            iGenerator->CharactersL(ReadStrIL());
+            break;
+        
+        case OPAQUE:
+            iGenerator->CharactersL(ReadOpaqueL());
+            break;
+
+        default: 
+            HandleElementL(id);
+            break;
+        }
+    LOGGER_LEAVEFN( "CSConConMLHandler::DoParseDocumentBodyL()" );
+    return KWBXMLParserErrorOk;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::ReadUint8L()
+// Reads one byte from the document
+// -----------------------------------------------------------------------------
+//  
+TUint8 CSConConMLHandler::ReadUint8L()
+    {
+    LOGGER_ENTERFN( "CSConConMLHandler::ReadUint8L()" );
+    if ( iPos == iParseBuffer->Size()) 
+        {
+        User::Leave ( KErrEof );
+        }
+    TUint8 value;
+    HBufC8* data = HBufC8::NewLC( sizeof(TUint8) );
+    TPtr8 ptr = data->Des();
+    iParseBuffer->Read(iPos, ptr, sizeof(TUint8));
+    iPos+= sizeof(TUint8);
+    value = ptr[0];
+    CleanupStack::PopAndDestroy(1); //data 
+    LOGGER_WRITE_1( "CSConConMLHandler::ReadUint8L()\
+     : returned %d ", value );
+    return value;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::ReadMUint32L()
+// Reads multibyte coding from the document
+// -----------------------------------------------------------------------------
+//  
+TUint32 CSConConMLHandler::ReadMUint32L()
+    {
+    LOGGER_ENTERFN( "CSConConMLHandler::ReadMUint32L()" );
+    TUint32 result = 0;
+    TUint8 c;
+    
+    do  {
+        c = ReadUint8L();
+        result = (result << 7) | (c & 0x7f);
+        } while ( c & 0x80 );
+    
+    LOGGER_WRITE_1( "CSConConMLHandler::ReadMUint32L()\
+     : returned %d ", result );
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::ReadStrIL()
+// Reads string data from the document
+// -----------------------------------------------------------------------------
+//  
+TPtrC8 CSConConMLHandler::ReadStrIL()
+    {
+    LOGGER_ENTERFN( "CSConConMLHandler::ReadStrIL()" );
+    iBuffer->Reset();
+    RBufWriteStream bws(*iBuffer);
+    TUint8 c;
+    while( (c = ReadUint8L()) != 0 )
+        {
+        bws.WriteUint8L(c);
+        }
+    bws.CommitL();
+    LOGGER_LEAVEFN( "CSConConMLParser::ReadStrIL()" );
+    return iBuffer->Ptr(0);
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::ReadStringTableL()
+// Handles the document's string table
+// -----------------------------------------------------------------------------
+//  
+void CSConConMLHandler::ReadStringTableL()
+    {
+    LOGGER_ENTERFN( "CSConConMLHandler::ReadStringTableL()" );
+    delete iStringTable;
+    iStringTable = NULL;
+    TUint32 strTblLen = ReadMUint32L();
+
+    if( strTblLen > 0 )
+        {
+        if( iPos+strTblLen > iParseBuffer->Size()) 
+            {
+            LOGGER_WRITE( "CSConConMLHandler::ReadStringTableL() : LEAVE KErrEof " );
+            User::Leave ( KErrEof );
+            }
+        iStringTable = HBufC8::NewL(strTblLen);
+        TPtr8 ptr = iStringTable->Des();
+        iParseBuffer->Read(iPos, ptr, strTblLen);
+        iPos+=strTblLen;
+        }
+    LOGGER_LEAVEFN( "CSConConMLHandler::ReadStringTableL()" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::StringTableString()
+// Returns a value from the string table according to the given index
+// -----------------------------------------------------------------------------
+//  
+TPtrC8 CSConConMLHandler::StringTableString( TUint32 aIndex )
+    {
+    LOGGER_ENTERFN( "CSConConMLHandler::StringTableString()" );
+    TPtrC8 temp(iStringTable->Mid(aIndex));
+    TInt pos = temp.Find(KWBXMLNull());
+    if( pos != KErrNotFound )
+        {
+        temp.Set(temp.Left(pos));
+        }
+    LOGGER_LEAVEFN( "CSConConMLHandler::StringTableString()" );
+    return temp;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::HandleElementL()
+// Starts a new element in the document
+// -----------------------------------------------------------------------------
+//  
+void CSConConMLHandler::HandleElementL( TUint8 aId )
+    {
+    LOGGER_ENTERFN( "CSConConMLHandler::HandleElementL()" );
+    TUint8 tag(TUint8(aId & 0x3f));
+        
+    iGenerator->StartElementL( tag );
+
+    if( aId & 0x40 ) 
+        {
+        iElemStack.Append( tag );
+        }
+    else 
+        {
+        iGenerator->EndElementL(tag);
+        }
+    LOGGER_LEAVEFN( "CSConConMLHandler::HandleElementL()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CSConConMLHandler::ReadOpaqueL()
+// Reads opaque data from the document
+// -----------------------------------------------------------------------------
+//  
+TPtrC8 CSConConMLHandler::ReadOpaqueL()
+    {
+    LOGGER_ENTERFN( "CSConConMLHandler::ReadOpaqueL()" );
+    iBuffer->Reset();
+    RBufWriteStream bws(*iBuffer);
+    TUint32 length = ReadMUint32L();
+    if( iPos+length > iParseBuffer->Size()) 
+        {
+        LOGGER_WRITE( "CSConConMLHandler::ReadOpaqueL() : LEAVE KErrEof " );
+        User::Leave ( KErrEof );
+        }
+    HBufC8* data = HBufC8::NewLC( length );
+    TPtr8 ptr = data->Des();
+    iParseBuffer->Read( iPos, ptr, length );
+    iPos+= length;
+    bws.WriteL(ptr, length);
+    bws.CommitL();
+    CleanupStack::PopAndDestroy(1); // data
+    
+    LOGGER_LEAVEFN( "CSConConMLHandler::ReadOpaqueL()" );
+    return iBuffer->Ptr(0);
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/src/sconxmlelement.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser/generator
+*
+*/
+
+
+// -----------------------------------------------------------------------------
+// Includes
+// -----------------------------------------------------------------------------
+
+#include "sconxmlelement.h"
+#include "sconconmldtd.h"
+
+// -----------------------------------------------------------------------------
+// TElementParams
+// -----------------------------------------------------------------------------
+TXMLElementParams::TXMLElementParams( 
+    TAny* aCallbacks, 
+    CXMLStack<CXMLElement>* aCmdStack, 
+    CXMLStack<CXMLElement>* aCleanupStack ) :
+	iCallbacks(aCallbacks), 
+	iCmdStack(aCmdStack), 
+	iCleanupStack(aCleanupStack)
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CXMLElement
+// -----------------------------------------------------------------------------
+CXMLElement* CXMLElement::BeginElementL( 
+    TUint8 /*aTag*/, const TXMLElementParams& /*Params*/ )
+	{
+	return 0;
+	}
+
+// -----------------------------------------------------------------------------
+CXMLElement::TAction CXMLElement::EndElementL( TAny* /*aCallbacks*/, 
+    TUint8 /*aTag*/ )
+	{
+	return EPop;
+	}
+
+
+// -----------------------------------------------------------------------------
+TBool CXMLElement::NeedsCleanup() const
+	{
+	return EFalse;
+	}
+
+// -----------------------------------------------------------------------------
+void CXMLElement::SetDataL( const TDesC8& /*aData*/ )
+	{
+	}
+
+// -----------------------------------------------------------------------------
+TPtrC8 CXMLElement::Data() const
+	{
+	return TPtrC8();
+	}
+
+// -----------------------------------------------------------------------------
+TBool CXMLElement::Validate()
+	{
+	return ETrue;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/src/sconxmlworkspace.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,175 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ConML parser/generator
+*
+*/
+
+
+// -----------------------------------------------------------------------------
+// Includes
+// -----------------------------------------------------------------------------
+#include "sconxmlworkspace.h"
+
+// -----------------------------------------------------------------------------
+// CXMLWorkspace
+// -----------------------------------------------------------------------------
+CXMLWorkspace::CXMLWorkspace()
+	{
+	}
+	
+// -----------------------------------------------------------------------------
+// NewL
+// -----------------------------------------------------------------------------
+CXMLWorkspace* CXMLWorkspace::NewL()
+	{
+	CXMLWorkspace* self = new (ELeave) CXMLWorkspace();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(); // self
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// ConstructL
+// -----------------------------------------------------------------------------
+void CXMLWorkspace::ConstructL()
+	{
+	iBuffer = CBufFlat::NewL(32);
+	iTransactions = new (ELeave) RArray<TUint>();
+	}
+
+// -----------------------------------------------------------------------------
+// ~CXMLWorkspace
+// -----------------------------------------------------------------------------
+CXMLWorkspace::~CXMLWorkspace()
+	{
+	delete iBuffer;
+	if( iTransactions )
+		{
+		iTransactions->Reset();
+		}
+	delete iTransactions;
+	}
+
+// -----------------------------------------------------------------------------
+// BeginTransaction
+// -----------------------------------------------------------------------------
+void CXMLWorkspace::BeginTransaction()
+	{
+	iTransactions->Append(Size());
+	}
+	
+// -----------------------------------------------------------------------------
+// Commit
+// -----------------------------------------------------------------------------
+TInt CXMLWorkspace::Commit()
+	{
+	if( iTransactions->Count() == 0 )
+		{
+		return KErrGeneral;
+		}
+	iTransactions->Remove(iTransactions->Count() - 1);
+	return KErrNone;
+	}
+
+// -----------------------------------------------------------------------------
+// CommitAll
+// -----------------------------------------------------------------------------
+void CXMLWorkspace::CommitAll()
+	{
+	iTransactions->Reset();
+	}
+
+// -----------------------------------------------------------------------------
+// Rollback
+// -----------------------------------------------------------------------------
+TInt CXMLWorkspace::Rollback()
+	{
+	if( iTransactions->Count() == 0 )
+		{
+		return KErrGeneral;
+		}
+	TUint begin = iTransactions->operator[](iTransactions->Count() - 1);
+	Delete(begin, Size() - begin);
+	iTransactions->Remove(iTransactions->Count() - 1);
+	return KErrNone;
+	}
+	
+// -----------------------------------------------------------------------------
+// Reset
+// -----------------------------------------------------------------------------
+void CXMLWorkspace::Reset()
+	{
+	iBuffer->Reset();
+	}
+
+// -----------------------------------------------------------------------------
+// WriteL
+// -----------------------------------------------------------------------------
+void CXMLWorkspace::WriteL( const TDesC8& aData )
+	{
+	TRAPD(err, iBuffer->InsertL(iBuffer->Size(), aData));
+	if( err != KErrNone )
+		{
+		User::Leave(KErrTooBig);
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// WriteL
+// -----------------------------------------------------------------------------
+void CXMLWorkspace::WriteL( const TUint8 aData )
+	{
+	WriteL(TPtrC8(&aData, 1));
+	}
+
+// -----------------------------------------------------------------------------
+// Buffer
+// -----------------------------------------------------------------------------
+TPtrC8 CXMLWorkspace::Buffer()
+	{
+	return iBuffer->Ptr(0);
+	}
+
+// -----------------------------------------------------------------------------
+// FreeSize
+// -----------------------------------------------------------------------------
+TInt CXMLWorkspace::FreeSize()
+	{
+	return (KMaxTInt32 - Size());
+	}
+
+// -----------------------------------------------------------------------------
+// MaxSize
+// -----------------------------------------------------------------------------
+TInt CXMLWorkspace::MaxSize()
+	{
+	return KMaxTInt32;
+	}
+
+// -----------------------------------------------------------------------------
+// Size
+// -----------------------------------------------------------------------------
+TInt CXMLWorkspace::Size()
+	{
+	return iBuffer->Size();
+	}
+
+// -----------------------------------------------------------------------------
+// Delete
+// -----------------------------------------------------------------------------
+void CXMLWorkspace::Delete( TInt aPos, TInt aLength )
+	{
+	iBuffer->Delete(aPos, aLength);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,19 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file
+*
+*/
+
+
+#include "../SeCon/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file
+*
+*/
+
+
+
+#include "../remoteconn_plat/group/bld.inf"
+#include "../connectivitymodules/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layers.sysdef.xml	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_4_0.dtd" [
+  <!ENTITY layer_real_source_path "sf/mw/remoteconn" >
+]>
+
+<SystemDefinition name="remoteconn" schema="1.4.0">
+  <systemModel>
+    <layer name="mw_layer">
+      <module name="remoteconn">
+        <unit name="remoteconn" unitID="sydo.remoteconn" bldFile="&layer_real_source_path;/group" mrp="" />
+      </module>
+    </layer>
+  </systemModel>
+</SystemDefinition>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,31 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// bld.inf for mtpfiledp
+// Media Transfer Protocol file data provider
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+mtp_filedp.iby                      /epoc32/rom/include/mtp_filedp.iby
+../inc/mtpfiledp_config.rh          SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mtpfiledp_config.rh)
+
+PRJ_MMPFILES 
+mtpfiledp.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/group/mtp_filedp.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,32 @@
+// 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 MTP_FILEDP_IBY
+#define MTP_FILEDP_IBY
+
+#if !defined(SYMBIAN_EXCLUDE_MTP)
+
+#include <mtp_framework.iby>
+
+// MTP Data Provider API
+ECOM_PLUGIN(mtpfiledp.dll, mtpfiledp.rsc)
+
+// MTP plugin registration resource file
+data=EPOCROOT##epoc32\data\Z\resource\mtp\102827B0.rsc  resource\mtp\102827B0.rsc 
+
+#endif // SYMBIAN_EXCLUDE_MTP
+
+#endif // MTP_FILEDP_IBY
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/group/mtp_filedp.mrp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	mtp_filedp
+source \sf\mw\remoteconn\mtpdataproviders\mtpfileandfolderdp
+
+binary	\sf\mw\remoteconn\mtpdataproviders\mtpfileandfolderdp\group all
+exports	\sf\mw\remoteconn\mtpdataproviders\mtpfileandfolderdp\group
+
+notes_source	\component_defs\release.src
+
+ipr E 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/group/mtpfiledp.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,64 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <comms-infras/commsdebugutility.mmh> 
+
+TARGET              mtpfiledp.dll
+TARGETTYPE          PLUGIN
+UID                 0x10009D8D 0x102827A5
+VENDORID             0x70000001
+
+CAPABILITY          CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+USERINCLUDE         ../inc
+USERINCLUDE         ../../../mtpfws/mtpfw/dataproviders/dputility/inc
+USERINCLUDE         ../../../mtpfws/mtpfw/common/inc
+USERINCLUDE         ../../../mtpfws/mtpfw/inc
+
+SOURCEPATH          ../src 
+SOURCE              cmtpfiledp.cpp
+SOURCE				cmtpfiledpconfigmgr.cpp
+SOURCE				cmtpfiledpexclusionmgr.cpp
+SOURCE              mtpfiledpimplementations.cpp
+SOURCE              mtpfiledpprocessor.cpp
+SOURCE				rmtpfiledpsingletons.cpp
+
+SOURCEPATH          ../src 
+START RESOURCE      mtpfiledp.rss    
+TARGET              mtpfiledp.rsc
+END
+
+// Data provider configuration resource file. 
+// The target filename corresponds to the implementation UID.
+START RESOURCE      mtpfiledp_config.rss   
+TARGETPATH          /resource/mtp
+TARGET              102827b0.rsc
+END
+
+LIBRARY             euser.lib
+LIBRARY             bafl.lib
+LIBRARY             edbms.lib
+LIBRARY             efsrv.lib
+LIBRARY             estor.lib
+LIBRARY             ecom.lib 
+
+LIBRARY             mtpdataproviderapi.lib
+LIBRARY             mtpdataproviderutility.lib
+LIBRARY             mtpdatatypes.lib
+LIBRARY             mtpframework.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/inc/cmtpfiledp.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,123 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPFILEDP_H
+#define CMTPFILEDP_H
+
+#include <mtp/cmtpdataproviderplugin.h>
+
+#include "mmtpenumerationcallback.h"
+#include "mtpdebug.h"
+#include "rmtpfiledpsingletons.h"
+#include "rmtpdpsingletons.h"
+
+class CMTPFileDpExclusionMgr;
+class CMTPFSEnumerator;
+class MMTPRequestProcessor;
+
+/** 
+Implements the file data provider plugin.
+@internalComponent
+
+*/
+class CMTPFileDataProvider : 
+    public CMTPDataProviderPlugin, 
+    public MMTPEnumerationCallback
+    {
+public:
+
+    static TAny* NewL(TAny* aParams);
+    ~CMTPFileDataProvider();
+    
+private: // From CMTPDataProviderPlugin
+
+    void Cancel();
+    void ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection);
+    void ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams);
+    void ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    void StartObjectEnumerationL(TUint32 aStorageId, TBool aPersistentFullEnumeration);
+    void StartStorageEnumerationL();
+    void Supported(TMTPSupportCategory aCategory, RArray<TUint>& aArray) const;
+         
+private: // From MMTPEnumerationCallback
+
+    void NotifyEnumerationCompleteL(TUint32 aStorageId, TInt aError);
+
+private:
+     
+    CMTPFileDataProvider(TAny* aParams);
+    void ConstructL();
+
+    TInt LocateRequestProcessorL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    TInt LocateRequestProcessorL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection);    
+    void SessionClosedL(const TMTPNotificationParamsSessionChange& aSession);
+    void SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession);
+    
+    /**
+     * [SP-Format-0x3002]Special processing for PictBridge DP which own 6 dps file with format 0x3002, 
+     * but it does not really own the format 0x3002.
+     * 
+     * Check whether the Pictbridgedp exists or not.
+     */
+    TBool PictbridgeDpExistL() const;
+    static void ImplementationsCleanup(TAny* aData);
+    
+private:
+	/**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    /**
+    The active request processors table.
+    */ 
+    RPointerArray<MMTPRequestProcessor> iActiveProcessors;
+    
+    /**
+    The storage enumerator.
+    */
+    CMTPFSEnumerator*              		iFileEnumerator;
+    
+    /**
+    The file dp exclusion manager.
+    */
+    CMTPFileDpExclusionMgr*				iExclusionMgr;
+    
+    /**
+    The list of storages to be enumerated.
+    */
+    RArray<TUint32>                     iPendingEnumerations;
+    
+    /**
+    File data provider singletons
+    */
+    RMTPFileDpSingletons 				iFileDPSingletons;
+    
+    /**
+    DP utility singletons
+    */
+    RMTPDpSingletons					iDpSingletons;
+    
+    TInt								iActiveProcessor;
+    TBool								iActiveProcessorRemoved;
+
+    };
+    
+#endif // CMTPFILEDP_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/inc/cmtpfiledpconfigmgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,87 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPFILEDPCONFIGMGR_H
+#define CMTPFILEDPCONFIGMGR_H
+
+#include <e32base.h>
+#include <badesca.h>
+
+#include <mtp/mtpprotocolconstants.h>
+
+class MMTPDataProviderFramework;
+
+class CMTPFileDpConfigMgr : 
+	public CBase
+	{
+public:
+	enum TParameter
+	    {
+    	/**
+    	The object format code exclusion list parameter.
+    	*/
+    	EFormatExclusionList,
+    	
+    	/**
+    	The object format code mappings.
+    	*/
+    	EFormatMappings,
+ 
+    	/**
+    	The maximum number of data objects that are enumerated on each 
+    	iteration of the file data provider's object enumerator.
+    	
+    	Setting this to a smaller < 128 number will reduce the running time of the
+    	enumerator ActiveObject RunL as to allow other ActiveObjects to run. 
+    	The downside is that the enumerator will take longer to iterate over 
+    	directory entries due less objects being added in each RunL call.
+    	
+    	Setting this to a larger number > 128 will increase the running time of the
+    	enumerator ActiveObject RunL decreasing total enumerator running time but
+    	potentially starving out other ActiveObjects.
+    	*/
+    	EEnumerationIterationLength,
+    	};
+	
+public:
+	static CMTPFileDpConfigMgr* NewL(MMTPDataProviderFramework& aFramework);
+	~CMTPFileDpConfigMgr();
+	
+	TUint UintValueL(TParameter aParam) const;
+	
+	void GetArrayValueL(TParameter aParam, RArray<TUint>& aArray) const;
+	
+	static TInt FormatCompare(const TUint& aFirst, const TUint& aSecond);
+	
+private:
+	CMTPFileDpConfigMgr(MMTPDataProviderFramework& aFramework);
+	void ConstructL();
+	
+	void ReadFormatExclusionListL(RArray<TUint>& aArray) const;
+	
+private:
+	MMTPDataProviderFramework& iFramework;
+	TUint iResourceId;
+	
+	TUint iEnumItrLength;
+	RArray<TUint> iExcludedFormats;
+	};
+
+#endif // CMTPFILEDPCONFIGMGR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/inc/cmtpfiledpexclusionmgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,61 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPFILEDPEXCLUSIONMGR_H
+#define CMTPFILEDPEXCLUSIONMGR_H
+
+#include <e32base.h>
+#include "cmtpfsexclusionmgr.h"
+#include "rmtpframework.h"
+#include "rmtpdpsingletons.h"
+
+
+/** 
+@internalTechnology
+
+*/
+class CMTPFileDpExclusionMgr : public CMTPFSExclusionMgr
+	{
+public:
+	static CMTPFileDpExclusionMgr* NewL(MMTPDataProviderFramework& aFramework);
+	~CMTPFileDpExclusionMgr();
+	
+	// CMTPFSExclusionMgr
+	TBool IsFormatValid(TMTPFormatCode aFormat) const;
+    TBool IsExtensionValid(const TDesC& aPath) const;
+    
+    //Append all DPs format exclusion list string in File DP
+    void AppendFormatExclusionListL();
+private:
+    CMTPFileDpExclusionMgr(MMTPDataProviderFramework& aFramework);
+    void ConstructL();
+private:
+    RArray<TUint> iExcludedFormats;
+
+
+private:
+    /**
+    The MTP framework singletons.
+    */
+    RMTPFramework iFrameworkSingletons;
+    RMTPDpSingletons        iDpSingletons;
+    };
+
+#endif // CMTPFILEDPEXCLUSIONMGR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/inc/mmtpfileexclusionmgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,46 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __MMTPFILEEXCLUSIONMGR_H__
+#define __MMTPFILEEXCLUSIONMGR_H__
+
+#include <e32std.h>
+
+/** 
+Defines an interface to check if a filename is excluded or not.
+
+@internalTechnology
+
+*/
+class MMTPFileExclusionMgr
+	{
+public:
+	/**
+	check wheather a filename is excluded or not
+	@param aFileName The full path name of the file
+	@return ETrue if the file is not excluded, otherwise EFalse
+	*/
+	virtual TBool IsItemAccepted(const TDesC& aFileName) const = 0;
+	};
+	
+
+
+#endif // __MMTPFILEEXCLUSIONMGR_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/inc/mtpfiledp_config.rh	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,35 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Defines the resource type for filedp specific configuration data
+// 
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+STRUCT MTP_FILEDP_EXTENSION_MAP
+	{
+	LTEXT file_extension; // File extension to map
+	WORD mtp_object_format; // MTP object format code for file extension
+	}
+
+STRUCT MTP_FILEDP_CONFIG
+	{
+	WORD enumeration_iteration_length = 64; // Iterate through max 64 file entries each RunL
+	WORD format_exclusion_list[]; // Formats to exclude as MTP object format code values
+	STRUCT extension_map[]; // Map defining file extension to MTP object format code translation - of MTP_FILEDP_EXTENSION_MAP type
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/inc/mtpfiledpconst.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,103 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mmtpfiledpconst.h
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __MTPFILEDPCONST_H__
+#define __MTPFILEDPCONST_H__
+
+#include <mtp/mtpprotocolconstants.h>
+
+
+/**
+define all the operations that are supported by the file data provider
+@internalTechnology
+
+*/
+static const TUint16 KMTPFileDpSupportedOperations[] = 
+	{
+	EMTPOpCodeGetObjectInfo,
+	EMTPOpCodeGetObject,
+	EMTPOpCodeDeleteObject,
+	EMTPOpCodeSendObjectInfo,
+	EMTPOpCodeSendObject,
+	EMTPOpCodeMoveObject,
+	EMTPOpCodeCopyObject,
+	EMTPOpCodeGetPartialObject,
+		
+	//MTP op codes
+	EMTPOpCodeGetObjectPropsSupported,
+	EMTPOpCodeGetObjectPropDesc,
+	EMTPOpCodeGetObjectPropValue,
+	EMTPOpCodeSetObjectPropValue,
+	EMTPOpCodeGetObjectReferences,
+	EMTPOpCodeSetObjectReferences,
+	//EMTPOpCodeSkip,
+	
+	//MTP enhanced operation codes
+	EMTPOpCodeGetObjectPropList,
+	EMTPOpCodeSetObjectPropList,
+	EMTPOpCodeSendObjectPropList,
+	EMTPOpCodeGetFormatCapabilities,
+	EMTPOpCodeSetObjectProtection
+	};	
+
+/**
+define all the object properties that are supported by the file data provider
+@internalTechnology
+
+*/
+static const TUint16 KMTPFileDpSupportedProperties[] =
+	{
+	EMTPObjectPropCodeStorageID,
+	EMTPObjectPropCodeObjectFormat,
+	EMTPObjectPropCodeProtectionStatus,
+	EMTPObjectPropCodeObjectSize,
+	EMTPObjectPropCodeObjectFileName,
+	EMTPObjectPropCodeDateModified,
+	EMTPObjectPropCodeParentObject,
+	EMTPObjectPropCodePersistentUniqueObjectIdentifier,
+	EMTPObjectPropCodeName,
+	EMTPObjectPropCodeNonConsumable	
+	};
+
+/**
+define the granularity from drive list
+@internalTechnology
+
+*/
+static const TInt KMTPDriveGranularity = 5;
+
+/**
+define the granularity for the exclusion list
+@internalTechnology
+
+*/
+static const TInt KMTPExclusionListGranularity = 5;
+
+/**
+define the drive root path length
+@internalTechnology
+
+*/
+static const TInt KMTPDriveLetterPrefixLength = 3; //c:\
+	
+#endif // __MTPFILEDPCONST_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/inc/mtpfiledppanic.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,54 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mmtpfiledppanic.h
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __MTPFILEDPPANIC_H__
+#define __MTPFILEDPPANIC_H__
+
+#include <e32std.h>
+
+/**
+define the file data provider panic code
+@internalTechnology
+
+*/
+enum TMTPFileDpPanic
+	{
+	EMTPFileDpNoMatchingProcessor = 0,
+	EMTPFileDpObjectNull = 1,
+	EMTPFileDpFormatNotSupported = 2,
+	EMTPFileDpSendObjectStateInvalid = 3,
+	EMTPFileDpRequestCheckNull = 4,
+	EMTPFileDpHandlesNull = 5,
+	EMTPFileDpUnsupportedProperty = 6,
+	EMTPFileDpObjectPropertyNull = 7,
+	EMTPFileDpCannotRenameDir = 8,
+	};
+
+_LIT(KMTPFileDpPanic, "MTP File Data Provider");
+inline void Panic(TMTPFileDpPanic aCode)
+	{
+	User::Panic(KMTPFileDpPanic, aCode);
+	};
+	
+
+#endif // __MTPDEVDPPANIC_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/inc/mtpfiledpprocessor.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,46 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __MTPFILEDPPROCESSOR_H__
+#define __MTPFILEDPPROCESSOR_H__
+
+class MMTPConnection;
+class TMTPTypeRequest;
+class CMTPDataProviderPlugin;
+class MMTPDataProviderFramework;
+class MMTPRequestProcessor;
+
+/** 
+Defines file data provider request processor factory
+
+@internalTechnology
+
+*/
+class MTPFileDpProcessor
+	{
+public:
+	static MMTPRequestProcessor* CreateL(
+										MMTPDataProviderFramework& aFramework,
+										const TMTPTypeRequest& aRequest, 
+										MMTPConnection& aConnection);	
+	};
+	
+#endif // __MTPFILEDPPROCESSOR_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/inc/rmtpfiledpsingletons.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,86 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef RMTPFILEDPSINGLETONS_H
+#define RMTPFILEDPSINGLETONS_H
+
+#include "mtpdebug.h"
+
+/** 
+Implements the MTP file data processor singletons reference manager.
+@internalComponent
+
+*/
+
+class CMTPFileDpConfigMgr;
+class MMTPDataProviderFramework;
+
+class RMTPFileDpSingletons
+    {
+public:  
+    RMTPFileDpSingletons();  
+
+    void OpenL(MMTPDataProviderFramework& aFramework);
+    void Close();
+    
+    CMTPFileDpConfigMgr& FrameworkConfig();
+    
+private:
+    
+    /**
+    Implements the singletons reference block.
+    */
+    class CSingletons : public CObject
+        {
+    public: 
+
+        static CSingletons& OpenL(MMTPDataProviderFramework& aFramework);
+        void Close();
+
+    private: // From CObject
+
+    private:
+
+        static CSingletons* NewL(MMTPDataProviderFramework& aFramework);
+        virtual ~CSingletons();
+        void ConstructL(MMTPDataProviderFramework& aFramework);
+
+    public: // Owned
+
+        /**
+        FLOGGER debug trace member variable.
+        */
+        __FLOG_DECLARATION_MEMBER_MUTABLE;
+            
+        /**
+        The file config manager.
+        */
+        CMTPFileDpConfigMgr*    iConfigMgr;
+    	};
+    
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+    /**
+    The singletons reference block.
+    */
+    CSingletons*    iSingletons;
+};
+
+#endif // RMTPFILEDPSINGLETONS_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/src/cmtpfiledp.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,399 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtpstoragemetadata.h>
+#include <mtp/mmtpconnection.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpdataproviderapitypes.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <ecom/ecom.h>
+
+#include "cmtpfiledp.h"
+#include "cmtpfiledpexclusionmgr.h"
+#include "cmtpfsenumerator.h"
+#include "cmtpfiledpconfigmgr.h"
+#include "cmtprequestprocessor.h"
+#include "mtpfiledpconst.h"
+#include "mtpfiledppanic.h"
+#include "mtpfiledpprocessor.h"
+
+// Class constants
+static const TInt KArrayGranularity = 3;
+static const TInt KActiveEnumeration = 0;
+__FLOG_STMT(_LIT8(KComponent,"CMTPFileDataProvider");)
+
+/**
+File data provider factory method.
+@return A pointer to a file data provider object. Ownership IS transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+TAny* CMTPFileDataProvider::NewL(TAny* aParams)
+    {
+    CMTPFileDataProvider* self = new (ELeave) CMTPFileDataProvider(aParams);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+CMTPFileDataProvider::~CMTPFileDataProvider()
+    {
+    __FLOG(_L8("~CMTPFileDataProvider - Entry"));
+    iPendingEnumerations.Close();
+    TUint count(iActiveProcessors.Count());
+    while (count--)
+        {
+        iActiveProcessors[count]->Release();
+        }
+    iActiveProcessors.Close();
+    iDpSingletons.Close();
+	iFileDPSingletons.Close();
+    delete iFileEnumerator;
+    delete iExclusionMgr;
+    __FLOG(_L8("~CMTPFileDataProvider - Exit"));
+    __FLOG_CLOSE; 
+    }
+
+void CMTPFileDataProvider::Cancel()
+    {
+    __FLOG(_L8("Cancel - Entry"));
+    iFileEnumerator->Cancel();
+    __FLOG(_L8("Cancel - Exit"));
+    }
+        
+void CMTPFileDataProvider::ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection)
+    {
+    __FLOG(_L8("ProcessEventL - Entry"));
+    TInt idx(LocateRequestProcessorL(aEvent, aConnection));
+    
+    if (idx != KErrNotFound)
+        {
+        iActiveProcessors[idx]->HandleEventL(aEvent);
+        }
+    __FLOG(_L8("ProcessEventL - Exit"));
+    }
+     
+void CMTPFileDataProvider::ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams)
+    {
+    __FLOG(_L8("ProcessNotificationL - Entry"));
+    switch (aNotification)
+        {
+    case EMTPSessionClosed:
+        SessionClosedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams));
+        break;
+        
+    case EMTPSessionOpened:
+        SessionOpenedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams));
+        break;
+        
+    default:
+        // Ignore all other notifications.
+        break;
+        }
+    __FLOG(_L8("ProcessNotificationL - Exit"));
+    }
+        
+void CMTPFileDataProvider::ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {    
+    __FLOG(_L8("ProcessRequestPhaseL - Entry"));
+    TInt idx(LocateRequestProcessorL(aRequest, aConnection));
+    __ASSERT_DEBUG((idx != KErrNotFound), Panic(EMTPFileDpNoMatchingProcessor));
+    MMTPRequestProcessor* processor(iActiveProcessors[idx]);
+    iActiveProcessor = idx;
+    iActiveProcessorRemoved = EFalse;
+    TBool result(processor->HandleRequestL(aRequest, aPhase));
+    if (iActiveProcessorRemoved)
+	    {
+	    processor->Release(); // destroy the processor
+	    }
+    else if (result)
+	    {
+	    processor->Release();    	
+	    iActiveProcessors.Remove(idx);
+	    }
+    iActiveProcessor = -1;
+
+    __FLOG(_L8("ProcessRequestPhaseL - Exit"));
+    }
+    
+void CMTPFileDataProvider::StartObjectEnumerationL(TUint32 aStorageId, TBool /*aPersistentFullEnumeration*/)
+    {
+    __FLOG(_L8("StartObjectEnumerationL - Entry"));
+
+    iExclusionMgr->AppendFormatExclusionListL();
+    iDpSingletons.MTPUtility().FormatExtensionMapping();
+    iPendingEnumerations.AppendL(aStorageId);
+    if (iPendingEnumerations.Count() == 1)
+        {
+        iFileEnumerator->StartL(iPendingEnumerations[KActiveEnumeration]);
+        }
+    __FLOG(_L8("StartObjectEnumerationL - Exit"));
+    }
+    
+void CMTPFileDataProvider::StartStorageEnumerationL()
+    {
+    __FLOG(_L8("StartStorageEnumerationL - Entry"));
+    Framework().StorageEnumerationCompleteL();
+    __FLOG(_L8("StartStorageEnumerationL - Exit"));
+    }
+    
+void CMTPFileDataProvider::Supported(TMTPSupportCategory aCategory, RArray<TUint>& aArray) const
+    {
+    __FLOG(_L8("Supported - Entry"));
+    switch (aCategory) 
+        {        
+    case EEvents:
+        break;
+        
+    case EObjectCaptureFormats:
+    case EObjectPlaybackFormats:
+        aArray.Append(EMTPFormatCodeUndefined);
+        
+        /**
+         * [SP-Format-0x3002]Special processing for PictBridge DP which own 6 dps file with format 0x3002, 
+         * but it does not really own the format 0x3002.
+         */
+        if( PictbridgeDpExistL() )
+        	{
+        	aArray.Append(EMTPFormatCodeScript);
+        	}
+        break;
+        
+    case EObjectProperties:
+        {
+        TInt count(sizeof(KMTPFileDpSupportedProperties) / sizeof(KMTPFileDpSupportedProperties[0]));
+        for (TInt i(0); (i < count); i++)
+            {
+            aArray.Append(KMTPFileDpSupportedProperties[i]);
+            }   
+        }
+        break; 
+        
+    case EOperations:
+        {
+        TInt count(sizeof(KMTPFileDpSupportedOperations) / sizeof(KMTPFileDpSupportedOperations[0]));
+        for (TInt i(0); (i < count); i++)
+            {
+            aArray.Append(KMTPFileDpSupportedOperations[i]);
+            }   
+        }
+        break;  
+        
+    case EStorageSystemTypes:
+        aArray.Append(CMTPStorageMetaData::ESystemTypeDefaultFileSystem);
+        break; 
+        
+    default:
+    
+        // Unrecognised category, leave aArray unmodified.
+        break;
+        }
+    __FLOG(_L8("Supported - Exit"));
+    }    
+       
+#ifdef __FLOG_ACTIVE  
+void CMTPFileDataProvider::NotifyEnumerationCompleteL(TUint32 aStorageId, TInt aError)
+#else
+void CMTPFileDataProvider::NotifyEnumerationCompleteL(TUint32 /*aStorageId*/, TInt /*aError*/)
+#endif // __FLOG_ACTIVE
+    {
+    __FLOG(_L8("HandleEnumerationCompletedL - Entry"));
+    __FLOG_VA((_L8("Enumeration of storage 0x%08X completed with error status %d"), aStorageId, aError));
+    __ASSERT_DEBUG((aStorageId == iPendingEnumerations[KActiveEnumeration]), User::Invariant());
+    
+    Framework().ObjectEnumerationCompleteL(iPendingEnumerations[KActiveEnumeration]);
+    iPendingEnumerations.Remove(KActiveEnumeration);
+    if (iPendingEnumerations.Count())
+        {
+        iFileEnumerator->StartL(iPendingEnumerations[KActiveEnumeration]);
+        }
+    __FLOG(_L8("HandleEnumerationCompletedL - Exit"));
+    }
+    
+/**
+Standard C++ constructor
+*/
+CMTPFileDataProvider::CMTPFileDataProvider(TAny* aParams) :
+    CMTPDataProviderPlugin(aParams),
+    iActiveProcessors(KArrayGranularity),
+    iPendingEnumerations(KArrayGranularity),
+    iActiveProcessor(-1)
+    {
+
+    }
+
+/**
+Second-phase constructor.
+*/    
+void CMTPFileDataProvider::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);  
+    __FLOG(_L8("ConstructL - Entry"));
+  	iDpSingletons.OpenL(Framework());
+  	iFileDPSingletons.OpenL(Framework());
+  	
+  	iExclusionMgr = CMTPFileDpExclusionMgr::NewL(Framework());
+  	iDpSingletons.SetExclusionMgrL(*iExclusionMgr);
+  	
+  	TUint processLimit = iFileDPSingletons.FrameworkConfig().UintValueL(CMTPFileDpConfigMgr::EEnumerationIterationLength);
+    iFileEnumerator = CMTPFSEnumerator::NewL(Framework(), iDpSingletons.ExclusionMgrL(), *this, processLimit);
+    __FLOG(_L8("ConstructL - Exit"));
+    }
+
+/**
+Find or create a request processor that can process the specified request.
+@param aRequest    The request to be processed
+@param aConnection The connection from which the request comes
+@return the idx of the found/created request processor
+*/    
+TInt CMTPFileDataProvider::LocateRequestProcessorL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {
+    __FLOG(_L8("LocateRequestProcessorL - Entry"));  
+    TInt idx(KErrNotFound);
+    TInt count(iActiveProcessors.Count());
+    for (TInt i(0); (i < count); i++)
+        {
+        if (iActiveProcessors[i]->Match(aRequest, aConnection))
+            {
+            idx = i;
+            break;
+            }
+        }
+        
+    if (idx == KErrNotFound)
+        {
+        MMTPRequestProcessor* processor = MTPFileDpProcessor::CreateL(Framework(), aRequest, aConnection);
+        CleanupReleasePushL(*processor);
+        iActiveProcessors.AppendL(processor);
+        CleanupStack::Pop();
+        idx = count;
+        }
+        
+    __FLOG(_L8("LocateRequestProcessorL - Exit"));
+    return idx;
+    }
+
+/**
+Find or create a request processor that can process the specified event.
+@param aEvent    The event to be processed
+@param aConnection The connection from which the request comes
+@return the idx of the found request processor, KErrNotFound if not found
+*/    
+TInt CMTPFileDataProvider::LocateRequestProcessorL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection)
+    {
+    __FLOG(_L8("LocateRequestProcessorL - Entry"));
+    TInt idx(KErrNotFound);
+    TInt count(iActiveProcessors.Count());
+    for (TInt i(0); (i < count); i++)
+        {
+        if (iActiveProcessors[i]->Match(aEvent, aConnection))
+            {
+            idx = i;
+            break;
+            }
+        }    
+    __FLOG(_L8("LocateRequestProcessorL - Exit"));
+    return idx;    
+    }
+
+/**
+Cleans up outstanding request processors when a session is closed.
+@param aSession notification parameter block
+*/
+void CMTPFileDataProvider::SessionClosedL(const TMTPNotificationParamsSessionChange& aSession)
+    {
+    __FLOG(_L8("SessionClosedL - Entry"));
+    TInt count = iActiveProcessors.Count();
+    while(count--)
+        {
+        MMTPRequestProcessor* processor = iActiveProcessors[count];
+        TUint32 sessionId = processor->SessionId();
+        if((sessionId == aSession.iMTPId) && (processor->Connection().ConnectionId() == aSession.iConnection.ConnectionId()))
+            {
+            iActiveProcessors.Remove(count);
+            if (count == iActiveProcessor)
+        		{
+        		iActiveProcessorRemoved = ETrue;
+        		}
+        	else
+	       		{
+        		processor->Release();
+	       		}
+            }
+        } 
+    __FLOG(_L8("SessionClosedL - Exit"));   
+    }
+
+/**
+Prepares for a newly-opened session.
+@param aSession notification parameter block
+*/
+#ifdef __FLOG_ACTIVE
+void CMTPFileDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession)
+#else
+void CMTPFileDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& /*aSession*/)
+#endif
+    {
+    __FLOG(_L8("SessionOpenedL - Entry"));
+    __FLOG_VA((_L8("SessionID = %d"), aSession.iMTPId));
+    __FLOG(_L8("SessionOpenedL - Exit"));
+    }
+
+/**
+ * [SP-Format-0x3002]Special processing for PictBridge DP which own 6 dps file with format 0x3002, 
+ * but it does not really own the format 0x3002.
+ * 
+ * Check whether the Pictbridgedp exists or not.
+ */
+TBool CMTPFileDataProvider::PictbridgeDpExistL() const
+	{
+    __FLOG(_L8("PictbridgeDpExistL - Entry"));
+    
+	RImplInfoPtrArray   implementations;
+	TCleanupItem        cleanup(ImplementationsCleanup, reinterpret_cast<TAny*>(&implementations));
+	CleanupStack::PushL(cleanup);
+	REComSession::ListImplementationsL(KMTPDataProviderPluginInterfaceUid, implementations);
+	
+	TBool ret = EFalse;
+	const TUint KUidPictBridge = 0x2001fe3c;
+	TInt count = implementations.Count();
+	while(--count)
+		{
+		if(implementations[count]->ImplementationUid().iUid == KUidPictBridge)
+			{
+			ret = ETrue;
+			break;
+			}
+		}
+    CleanupStack::PopAndDestroy(&implementations);
+    
+    __FLOG_VA((_L8("return value ret = %d"), ret));
+    __FLOG(_L8("PictbridgeDpExistL - Exit"));
+    return ret;
+	}
+
+/**
+ * [SP-Format-0x3002]Special processing for PictBridge DP which own 6 dps file with format 0x3002, 
+ * but it does not really own the format 0x3002.
+ * 
+ * Cleanup function
+ */
+void CMTPFileDataProvider::ImplementationsCleanup(TAny* aData)
+    {
+    reinterpret_cast<RImplInfoPtrArray*>(aData)->ResetAndDestroy();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/src/cmtpfiledpconfigmgr.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,117 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <barsc.h>
+#include <barsread.h>
+
+#include "cmtpfiledpconfigmgr.h"
+
+#include <mtp/mmtpdataproviderconfig.h>
+#include <mtp/mmtpdataproviderframework.h>
+
+
+#define UNUSED_VAR(v) (v = v)
+
+CMTPFileDpConfigMgr* CMTPFileDpConfigMgr::NewL(MMTPDataProviderFramework& aFramework)
+	{
+	CMTPFileDpConfigMgr* self = new (ELeave) CMTPFileDpConfigMgr(aFramework);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+CMTPFileDpConfigMgr::CMTPFileDpConfigMgr(MMTPDataProviderFramework& aFramework) :
+	iFramework(aFramework)
+	{
+	}
+	
+void CMTPFileDpConfigMgr::ConstructL()
+	{
+	iResourceId = iFramework.DataProviderConfig().UintValue(MMTPDataProviderConfig::EOpaqueResource);
+	
+	RResourceFile resFile;
+	CleanupClosePushL(resFile);
+	
+	resFile.OpenL(iFramework.Fs(), iFramework.DataProviderConfig().DesCValue(MMTPDataProviderConfig::EResourceFileName));
+	HBufC8* res = resFile.AllocReadLC(iResourceId);
+	
+	TResourceReader reader;
+	reader.SetBuffer(res);
+	
+	// WORD - enumeration_iteration_length
+	iEnumItrLength = reader.ReadInt16();
+	
+	// Do not read format_exclusion_list and extension_map 
+	// to conserve memory - instead read it in dynamically when requested
+	
+	CleanupStack::PopAndDestroy(res);
+	CleanupStack::PopAndDestroy(&resFile);
+	}
+	
+CMTPFileDpConfigMgr::~CMTPFileDpConfigMgr()
+	{
+	}
+	
+TUint CMTPFileDpConfigMgr::UintValueL(TParameter aParam) const
+	{
+	__ASSERT_DEBUG(aParam == CMTPFileDpConfigMgr::EEnumerationIterationLength, User::Invariant());
+	UNUSED_VAR(aParam);
+	return iEnumItrLength;
+	}
+
+void CMTPFileDpConfigMgr::GetArrayValueL(TParameter aParam, RArray<TUint>& aArray) const
+	{
+	__ASSERT_DEBUG(aParam == CMTPFileDpConfigMgr::EFormatExclusionList, User::Invariant());
+	UNUSED_VAR(aParam);
+	ReadFormatExclusionListL(aArray);
+	}
+	
+void CMTPFileDpConfigMgr::ReadFormatExclusionListL(RArray<TUint>& aArray) const
+	{
+	RResourceFile resFile;
+	CleanupClosePushL(resFile);
+	
+	resFile.OpenL(iFramework.Fs(), iFramework.DataProviderConfig().DesCValue(MMTPDataProviderConfig::EResourceFileName));
+	HBufC8* res = resFile.AllocReadLC(iResourceId);
+	
+	TResourceReader reader;
+	reader.SetBuffer(res);
+	
+	// WORD - enumeration_iteration_length, skip it
+	reader.ReadInt16();
+	
+	// WORD - length of format_exclusion_list
+	TInt16 len = reader.ReadInt16();
+	
+	TInt err(KErrNone);
+	// WORD[] - of len items
+	while(len--)
+		{
+		err = aArray.InsertInOrder(TUint(reader.ReadUint16()));
+		if( (err != KErrNone) && (err != KErrAlreadyExists) )
+			{
+			User::Leave(err);
+			}
+		}
+	
+	CleanupStack::PopAndDestroy(res);
+	CleanupStack::PopAndDestroy(&resFile);
+	}
+
+TInt CMTPFileDpConfigMgr::FormatCompare(const TUint& aFirst, const TUint& aSecond)
+	{
+	return (aFirst - aSecond);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/src/cmtpfiledpexclusionmgr.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,113 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <badesca.h>
+#include <mtp/cmtpdataproviderplugin.h>
+#include <mtp/mmtpdataproviderframework.h>
+
+
+#include "cmtpfiledpexclusionmgr.h"
+#include "rmtpfiledpsingletons.h"
+#include "cmtpfiledpconfigmgr.h"
+#include "cmtpextensionmapping.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpdataprovider.h"
+#include "mtpframeworkconst.h"
+
+
+CMTPFileDpExclusionMgr* CMTPFileDpExclusionMgr::NewL(MMTPDataProviderFramework& aFramework)
+	{
+	CMTPFileDpExclusionMgr* self = new (ELeave) CMTPFileDpExclusionMgr(aFramework);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+CMTPFileDpExclusionMgr::CMTPFileDpExclusionMgr(MMTPDataProviderFramework& aFramework) :
+	CMTPFSExclusionMgr(aFramework)
+	{
+	}
+	
+void CMTPFileDpExclusionMgr::ConstructL()
+	{
+    iFrameworkSingletons.OpenL();
+
+    RMTPFileDpSingletons singletons;
+    singletons.OpenL(iFramework);
+    CleanupClosePushL(singletons);
+    singletons.FrameworkConfig().GetArrayValueL(CMTPFileDpConfigMgr::EFormatExclusionList, iExcludedFormats);
+    CleanupStack::PopAndDestroy(&singletons);
+    iDpSingletons.OpenL(iFramework);
+
+	}
+	
+CMTPFileDpExclusionMgr::~CMTPFileDpExclusionMgr()
+    {
+    iExcludedFormats.Close();
+    iFrameworkSingletons.Close();
+    iDpSingletons.Close();
+
+    }
+		
+TBool CMTPFileDpExclusionMgr::IsFormatValid(TMTPFormatCode aFormat) const
+	{
+	TInt found = iExcludedFormats.FindInOrder(aFormat);
+	return (found == KErrNotFound);
+	}
+
+TBool CMTPFileDpExclusionMgr::IsExtensionValid(const TDesC& aPath) const
+	{
+	return IsFormatValid(iDpSingletons.MTPUtility().GetFormatByExtension(aPath));
+	}
+
+//Append all DPs format exclusion list strings in File DP
+void CMTPFileDpExclusionMgr::AppendFormatExclusionListL()
+    {
+    CMTPDataProviderController& dps(iFrameworkSingletons.DpController());
+    TUint count = dps.Count();
+    TUint currentDpIndex = 0, formatcode = 0;
+    RArray<TUint> capFormatExclusionList;
+    RArray<TUint> playbackFormatExclusionList;
+    CleanupClosePushL(capFormatExclusionList);
+    CleanupClosePushL(playbackFormatExclusionList);
+    while (currentDpIndex < count)
+        {
+        CMTPDataProvider& dp(dps.DataProviderByIndexL(currentDpIndex));
+        if(KMTPImplementationUidFileDp != dp.ImplementationUid().iUid)
+            {	  		
+            dp.Plugin().Supported(EObjectCaptureFormats, capFormatExclusionList);
+            dp.Plugin().Supported(EObjectPlaybackFormats, playbackFormatExclusionList);
+            capFormatExclusionList.Sort();
+            for(TInt index = 0; index < playbackFormatExclusionList.Count(); ++index)
+                {
+                formatcode = playbackFormatExclusionList[index];
+                if(KErrNotFound == capFormatExclusionList.FindInOrder(formatcode))
+                    {
+                    capFormatExclusionList.InsertInOrder(formatcode);
+                    }
+                }
+
+            //Append all DPs format exclusion list in File DP
+            for (TInt i = 0; i < capFormatExclusionList.Count(); ++i)
+                {
+                iExcludedFormats.InsertInOrder(capFormatExclusionList[i]);
+                }
+            }
+        currentDpIndex++;
+        }
+    CleanupStack::PopAndDestroy(&playbackFormatExclusionList);
+    CleanupStack::PopAndDestroy(&capFormatExclusionList);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/src/mtpfiledp.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,39 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <ecom/registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theInfo
+    {
+    dll_uid = 0x102827A5;
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            interface_uid = 0x102827AD;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x102827B0;
+                    version_no = 1;
+                    display_name = "MTP File Data Provider plug-in.";
+                    default_data = "";
+                    opaque_data = "";
+                    }
+                };
+            }
+        };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/src/mtpfiledp_config.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,137 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/mtpdataproviderconfig.rh>
+#include "mtpfiledp_config.rh"
+
+RESOURCE MTP_DATA_PROVIDER dpConfig
+    {
+    type = KMTPDataProviderTypeECOM;
+    major_version = 1;
+    object_enumeration_persistent = 0;
+    supported_modes = KMTPModeMTP;  
+    server_name = "";
+    server_image_name = "";
+    opaque_resource = fileConfig;
+    }
+
+RESOURCE MTP_FILEDP_CONFIG fileConfig
+	{
+	enumeration_iteration_length = 32;
+	format_exclusion_list = 
+        {
+        // Association 
+        0x3001
+        };
+
+	extension_map = 
+        {
+        MTP_FILEDP_EXTENSION_MAP
+            {
+            file_extension = "wav";
+            mtp_object_format = 0x3008;
+            },
+        MTP_FILEDP_EXTENSION_MAP
+			{
+		    file_extension = "mp3";
+		    mtp_object_format = 0x3009;
+		    },
+        MTP_FILEDP_EXTENSION_MAP
+		    {
+		    file_extension = "wma";
+		    mtp_object_format = 0xb901;
+		    },
+		MTP_FILEDP_EXTENSION_MAP
+            {
+	        file_extension = "aac";
+	        mtp_object_format = 0xb903;
+		    },
+        MTP_FILEDP_EXTENSION_MAP
+		    {
+		   file_extension = "jpg";
+		   mtp_object_format = 0x3801;
+		    },
+		MTP_FILEDP_EXTENSION_MAP
+		    {
+		    file_extension = "gif";
+		    mtp_object_format = 0x3807;
+		    },
+		MTP_FILEDP_EXTENSION_MAP
+		    {
+		    file_extension = "png";
+		    mtp_object_format = 0x380b;
+		    },
+		MTP_FILEDP_EXTENSION_MAP
+		    {
+		    file_extension = "bmp";
+		    mtp_object_format = 0x3804;
+		    },
+		MTP_FILEDP_EXTENSION_MAP
+		    {
+		    file_extension = "wpl";
+		    mtp_object_format = 0xba10;
+		    },
+		MTP_FILEDP_EXTENSION_MAP
+		    {
+		    file_extension = "m3u";
+		    mtp_object_format = 0xba11;
+		    },
+		MTP_FILEDP_EXTENSION_MAP
+		    {
+		    file_extension = "mp4";
+		    mtp_object_format = 0xb982;
+		    },
+		MTP_FILEDP_EXTENSION_MAP
+		    {
+		    file_extension = "m4a";
+		    mtp_object_format = 0xb982;
+		    },
+		MTP_FILEDP_EXTENSION_MAP
+		    {
+		    file_extension = "m4b";
+		    mtp_object_format = 0xb982;
+		    },
+		MTP_FILEDP_EXTENSION_MAP
+	        {
+	        file_extension = "m4v";
+	        mtp_object_format = 0xb982;
+	        },
+	    MTP_FILEDP_EXTENSION_MAP
+	        {
+	        file_extension = "3gp";
+	        mtp_object_format = 0xb984;
+	        },
+	    MTP_FILEDP_EXTENSION_MAP
+	        {
+	        file_extension = "3gpp";
+	        mtp_object_format = 0xb984;
+	        },
+	    MTP_FILEDP_EXTENSION_MAP
+	        {
+	        file_extension = "3ga";
+	        mtp_object_format = 0xb984;
+	        },
+	    MTP_FILEDP_EXTENSION_MAP
+	        {
+	        file_extension = "asf";
+	        mtp_object_format = 0x300C;
+	        },
+	    MTP_FILEDP_EXTENSION_MAP
+	        {
+	        file_extension = "wmv";
+	        mtp_object_format = 0xB981;				
+	        }
+	    };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/src/mtpfiledpimplementations.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,39 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cmtpfiledp.h
+// 
+//
+
+#include <ecom/implementationproxy.h>
+#include "cmtpfiledp.h"
+
+
+// Define the interface UIDs
+static const TImplementationProxy ImplementationTable[] =
+    {
+        {
+        {0x102827B0}, (TProxyNewLPtr)(CMTPFileDataProvider::NewL)
+        }
+    };
+
+/**
+ECOM entry point
+*/
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/src/mtpfiledpprocessor.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,100 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mtpdevicedpprocessor.h
+// 
+//
+
+#include <mtp/tmtptyperequest.h>
+
+#include "mtpfiledpprocessor.h"
+#include "cmtprequestprocessor.h"
+#include "cmtpgetobjectinfo.h"
+#include "cmtpgetobject.h"
+#include "cmtpdeleteobject.h"
+#include "cmtpsendobjectinfo.h"
+#include "cmtpcopyobject.h"
+#include "cmtpmoveobject.h"
+#include "cmtpgetobjectpropssupported.h"
+#include "cmtpgetobjectpropdesc.h"
+#include "cmtpgetobjectpropvalue.h"
+#include "cmtpsetobjectpropvalue.h"
+#include "cmtprequestunknown.h"
+#include "cmtpgetobjectproplist.h"
+#include "cmtpsetobjectproplist.h"
+#include "cmtpgetreferences.h"
+#include "cmtpsetreferences.h"
+#include "cmtpgetformatcapabilities.h"
+#include "cmtpgetpartialobject.h"
+#include "cmtpsetobjectprotection.h"
+/**
+A mapping table from the operation code to the request processor factory method
+*/
+static const TMTPRequestProcessorEntry KMTPFileDpRequestProcessorTable[] = 
+	{
+		{EMTPOpCodeGetObjectInfo, CMTPGetObjectInfo::NewL},
+		{EMTPOpCodeGetObject, CMTPGetObject::NewL},
+		{EMTPOpCodeDeleteObject, CMTPDeleteObject::NewL},		
+		{EMTPOpCodeSendObjectInfo, CMTPSendObjectInfo::NewL},
+		{EMTPOpCodeSendObject, CMTPSendObjectInfo::NewL},	//force the SendObject request to be processed by the SendObjectInfo processor 
+		{EMTPOpCodeSendObjectPropList, CMTPSendObjectInfo::NewL},	//force the SendObjectPropList request to be processed by the SendObjectInfo processor 
+		{EMTPOpCodeMoveObject, CMTPMoveObject::NewL},	
+		{EMTPOpCodeCopyObject, CMTPCopyObject::NewL},
+		{EMTPOpCodeGetObjectPropsSupported, CMTPGetObjectPropsSupported::NewL},
+		{EMTPOpCodeGetObjectPropDesc, CMTPGetObjectPropDesc::NewL},
+		{EMTPOpCodeGetObjectPropValue, CMTPGetObjectPropValue::NewL},
+		{EMTPOpCodeSetObjectPropValue, CMTPSetObjectPropValue::NewL},
+		{EMTPOpCodeSetObjectPropList, CMTPSetObjectPropList::NewL},
+		{EMTPOpCodeGetObjectPropList, CMTPGetObjectPropList::NewL},
+		{EMTPOpCodeGetObjectReferences, CMTPGetReferences::NewL},
+		{EMTPOpCodeSetObjectReferences, CMTPSetReferences::NewL},
+        {EMTPOpCodeGetFormatCapabilities,CMTPGetFormatCapabilities::NewL},
+        {EMTPOpCodeGetPartialObject, CMTPGetPartialObject::NewL},
+	 {EMTPOpCodeSetObjectProtection, CMTPSetObjectProtection::NewL}				
+	};
+
+/**
+Create a request processor that matches the request
+@param aPlugin	The reference to the data provider plugin 
+@param aFramework The reference to the data provider framework
+@param aRequest	The request to be processed
+@param aConnection The connection from which the request comes from
+@return a pointer to the request processor
+*/	
+MMTPRequestProcessor* MTPFileDpProcessor::CreateL(
+													MMTPDataProviderFramework& aFramework,
+													const TMTPTypeRequest& aRequest, 
+													MMTPConnection& aConnection)
+	{
+	TMTPRequestProcessorCreateFunc createFunc = NULL; 
+	TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
+	TInt count = sizeof(KMTPFileDpRequestProcessorTable) / sizeof(TMTPRequestProcessorEntry);
+	for(TInt i = 0; i < count; i++)
+		{
+		if(KMTPFileDpRequestProcessorTable[i].iOperationCode == operationCode)
+			{
+			createFunc = KMTPFileDpRequestProcessorTable[i].iCreateFunc;
+			break;
+			}
+		}
+		
+	if(!createFunc)	
+		{
+		createFunc = CMTPRequestUnknown::NewL;
+		}
+		
+	return (*createFunc)(aFramework, aConnection);
+	}
+	
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpfileandfolderdp/src/rmtpfiledpsingletons.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,137 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "rmtpfiledpsingletons.h"
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/cmtpobjectmetadata.h>
+
+#include "cmtpfiledpconfigmgr.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"FileDpSingletons");)
+
+/**
+Constructor.
+*/
+RMTPFileDpSingletons::RMTPFileDpSingletons() :
+    iSingletons(NULL)
+    {
+    }
+
+/**
+Opens the singletons reference.
+*/
+void RMTPFileDpSingletons::OpenL(MMTPDataProviderFramework& aFramework)
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("OpenL - Entry"));
+    iSingletons = &CSingletons::OpenL(aFramework);
+    __FLOG(_L8("OpenL - Exit"));
+    }
+    
+/**
+Closes the singletons reference.
+*/
+void RMTPFileDpSingletons::Close()
+    {
+    __FLOG(_L8("Close - Entry"));
+    if (iSingletons)
+        {
+        iSingletons->Close();
+        iSingletons = NULL;
+        }
+    __FLOG(_L8("Close - Exit"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Provides a handle to the MTP file data provider's configuration manager.
+@return The file data provider configuration manager.
+*/
+
+CMTPFileDpConfigMgr& RMTPFileDpSingletons::FrameworkConfig()
+    {
+    __FLOG(_L8("FrameworkConfig - Entry"));
+    __ASSERT_DEBUG(iSingletons, User::Invariant());
+    __ASSERT_DEBUG(iSingletons->iConfigMgr, User::Invariant());
+    __FLOG(_L8("FrameworkConfig - Exit"));
+    return *iSingletons->iConfigMgr;
+    }
+
+RMTPFileDpSingletons::CSingletons* RMTPFileDpSingletons::CSingletons::NewL(MMTPDataProviderFramework& aFramework)
+    {
+    CSingletons* self(new(ELeave) CSingletons());
+    CleanupStack::PushL(self);
+    self->ConstructL(aFramework);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+RMTPFileDpSingletons::CSingletons& RMTPFileDpSingletons::CSingletons::OpenL(MMTPDataProviderFramework& aFramework)
+    {
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("CSingletons::OpenL - Entry"));
+    CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
+    if (!self)
+        {
+        self = CSingletons::NewL(aFramework);
+        Dll::SetTls(reinterpret_cast<TAny*>(self));
+        }
+    else
+        {        
+        self->Inc();
+        }
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("CSingletons::OpenL - Exit"));
+    return *self;
+    }
+    
+void RMTPFileDpSingletons::CSingletons::Close()
+    {
+    CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
+    if (self)
+        {
+        __FLOG(_L8("CSingletons::Close - Entry"));
+        self->Dec();
+        if (self->AccessCount() == 0)
+            {
+            __FLOG(_L8("CSingletons::Close - Exit"));
+            delete self;
+            Dll::SetTls(NULL);
+            }
+        else
+            {
+            __FLOG(_L8("CSingletons::Close - Exit"));
+            }
+        }
+    }
+    
+RMTPFileDpSingletons::CSingletons::~CSingletons()
+    {
+    __FLOG(_L8("CSingletons::~CSingletons - Entry"));
+    delete iConfigMgr;
+    __FLOG(_L8("CSingletons::~CSingletons - Exit"));
+    __FLOG_CLOSE;
+    }
+    
+void RMTPFileDpSingletons::CSingletons::ConstructL(MMTPDataProviderFramework& aFramework)
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("CSingletons::ConstructL - Entry"));
+    iConfigMgr = CMTPFileDpConfigMgr::NewL(aFramework);
+    __FLOG(_L8("CSingletons::ConstructL - Exit"));
+    }
+
+
+
Binary file mtpdataproviders/mtpimagedp/group/2001FCA2.txt has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,43 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#if !defined(GCCXML)  // NO GCCXML
+
+#include "../mediasyncserver/group/bld.inf"
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+../group/mtpimagedp.mmp
+
+PRJ_EXPORTS
+// Note: these files are exported for testing and techview only. Not used in a device
+2001FCA2.txt /epoc32/data/z/private/10202be9/2001FCA2.txt
+2001FCA2.txt /epoc32/release/winscw/udeb/z/private/10202be9/2001FCA2.txt
+2001FCA2.txt /epoc32/release/winscw/urel/z/private/10202be9/2001FCA2.txt
+
+../group/mtp_imagedp.iby  /epoc32/rom/include/mtp_imagedp.iby
+
+// ConfML files
+../conf/mtp_imagedp.confml          MW_LAYER_EXPORTS_CONFML(mtp_imagedp.confml)
+../conf/mtp_imagedp_2001fca2.crml   MW_LAYER_EXPORTS_CRML(mtp_imagedp_2001fca2.crml)
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/group/mtp_imagedp.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,30 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+
+#ifndef MTPIMAGEDP_IBY
+#define MTPIMAGEDP_IBY
+
+// MTP data provider
+ECOM_PLUGIN(mtpimagedp.dll,mtpimagedp.rsc)
+
+data=EPOCROOT##epoc32\data\Z\resource\mtp\2001FCAE.rsc  resource\mtp\2001FCAE.rsc 
+
+#endif MTPIMAGEDP_IBY
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/group/mtp_imagedp.mrp	Tue Feb 02 01:11:40 2010 +0200
@@ -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: 
+#
+
+component	mtp_imagedp
+source \sf\mw\remoteconn\mtpdataproviders\mtpimagedp
+
+binary	\sf\mw\remoteconn\mtpdataproviders\mtpimagedp\group all
+exports	\sf\mw\remoteconn\mtpdataproviders\mtpimagedp\group
+
+notes_source	\component_defs\release.src
+
+ipr E 
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/group/mtpimagedp.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,103 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <comms-infras/commsdebugutility.mmh> 
+
+TARGET          mtpimagedp.dll
+TARGETTYPE      PLUGIN
+UID             0x10009D8D 0x2001FCA2
+VENDORID        0x70000001
+
+CAPABILITY      CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData
+epocstacksize   0x5000 
+
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../mtpfws/mtpfw/dataproviders/dputility/inc
+USERINCLUDE     ../../../mtpfws/mtpfw/common/inc
+USERINCLUDE     ../../../mtpfws/mtpfw/inc
+USERINCLUDE     ../../../mtpfws/mtpfw/datatypes/inc
+USERINCLUDE     ../../../mtpfws/mtpfw/transports/transportapi/inc
+USERINCLUDE     ../mediasyncserver/inc/
+
+SOURCEPATH      ../src
+
+SOURCE          cmtpimagedp.cpp
+SOURCE          mtpimagedpimplementations.cpp
+
+SOURCE          cmtpimagedpgetobjectproplist.cpp
+SOURCE          cmtpimagedpgetobjectpropssupported.cpp
+SOURCE          cmtpimagedpgetobjectpropdesc.cpp
+SOURCE          cmtpimagedpobjectpropertymgr.cpp
+SOURCE          cmtpimagedpgetobject.cpp
+SOURCE          cmtpimagedpgetobjectreferences.cpp
+SOURCE          cmtpimagedpgetpartialobject.cpp
+SOURCE          cmtpimagedpgetobjectinfo.cpp
+SOURCE          cmtpimagedpgetobjectpropvalue.cpp
+SOURCE          cmtpimagedpgetthumb.cpp
+SOURCE          cmtpimagedpthumbnailcreator.cpp
+SOURCE          cmtpimagedpsendobjectinfo.cpp
+SOURCE          cmtpimagedpdeleteobject.cpp
+SOURCE          cmtpimagedpmoveobject.cpp
+SOURCE          cmtpimagedpcopyobject.cpp
+SOURCE          cmtpimagedpsetobjectpropvalue.cpp
+SOURCE          cmtpimagedpsetobjectproplist.cpp
+SOURCE          cmtpimagedpmdeobserver.cpp
+SOURCE          mtpimagedputilits.cpp
+SOURCE          mtpimagedpgetformatcapabilities.cpp
+SOURCE          cmtpimagedpsetobjectreferences.cpp
+SOURCE          mtpimagedprequestprocessor.cpp 
+SOURCE          cmtpimagedpsetobjectprotection.cpp
+SOURCE          cmtpimagedprenameobject.cpp
+
+// ECOM resource
+START RESOURCE     mtpimagedp.rss    
+TARGET             mtpimagedp.rsc
+END
+
+// Data provider configuration resource file. 
+// The target filename corresponds to the implementation UID.
+START RESOURCE      mtpimagedp_config.rss   
+TARGETPATH          /resource/mtp
+TARGET              2001fcae.rsc
+END
+
+LIBRARY             mtpdataproviderapi.lib
+LIBRARY             mtpdataproviderutility.lib
+LIBRARY             mtpdatatypes.lib
+
+LIBRARY             centralrepository.lib
+LIBRARY		        euser.lib  
+LIBRARY             bafl.lib        // BaflUtils
+LIBRARY		        efsrv.lib 
+LIBRARY             estor.lib       // CFileStore
+LIBRARY             platformenv.lib // PathInfo
+
+// for thumbnail creation related things
+LIBRARY             imageconversion.lib
+LIBRARY             bitmaptransforms.lib
+LIBRARY             fbscli.lib  
+LIBRARY             sysutil.lib
+LIBRARY             mdeclient.lib
+LIBRARY             thumbnailmanager.lib
+LIBRARY             rmediasyncserver.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedp.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,134 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+
+#ifndef CMTPIMAGEDP_H
+#define CMTPIMAGEDP_H
+
+#include <e32property.h> 
+#include <w32std.h> // PTP server/stack
+#include <e32hashtab.h> 
+#include <e32def.h>
+#include <mtp/cmtpdataproviderplugin.h>
+#include <comms-infras/commsdebugutility.h>
+
+#include <mtp/cmtpdataproviderplugin.h>
+#include "mmtpenumerationcallback.h"
+#include "cmtpimagedpobjectpropertymgr.h"
+
+class MMTPRequestProcessor;
+class CMTPImageDpThumbnailCreator;
+class CMTPImageDpObjectPropertyMgr;
+class CMTPImageDpMdeObserver;
+class CRepository;
+class CMTPImageDpRenameObject;
+
+const TInt KMaxExtNameLength = 4;
+
+/** 
+Implements the picture data provider plugin.
+@internalComponent
+*/
+class CMTPImageDataProvider : public CMTPDataProviderPlugin,
+                              public MMTPEnumerationCallback
+    {
+public:
+
+    static TAny* NewL(TAny* aParams);
+    ~CMTPImageDataProvider();
+    
+public:
+    CMTPImageDpObjectPropertyMgr& PropertyMgr()const;
+    CMTPImageDpThumbnailCreator&  ThumbnailManager() const;
+    CRepository& Repository() const;
+    
+    TMTPFormatCode FindFormatL(const TDesC& aExtension);
+    TBool GetCacheParentHandle(const TDesC& aParentPath, TUint32& aParentHandle);
+    void  SetCacheParentHandle(const TDesC& aParentPath, TUint32 aParentHandle);
+    void AppendDeleteObjectsArrayL(const TDesC& aSuid);
+    void HandleDeleteObjectsArray();
+    
+public: // From CMTPDataProviderPlugin
+    void Cancel();
+    void ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection);
+    void ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams);
+    void ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    void StartObjectEnumerationL(TUint32 aStorageId, TBool aPersistentFullEnumeration);
+    void StartStorageEnumerationL();
+    void Supported(TMTPSupportCategory aCategory, RArray<TUint>& aArray) const;
+    void SupportedL(TMTPSupportCategory aCategory, CDesCArray& aStrings) const;
+    
+public: // From MMTPEnumerationCallback    
+    void NotifyStorageEnumerationCompleteL();
+    void NotifyEnumerationCompleteL(TUint32 aStorageId, TInt aError);
+           
+private:
+    CMTPImageDataProvider(TAny* aParams);
+    void ConstructL();
+
+    TInt LocateRequestProcessorL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    TInt LocateRequestProcessorL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection);    
+    void SessionClosedL(const TMTPNotificationParamsSessionChange& aSession);
+    void SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession);
+    void RenameObjectL(const TMTPNotificationParamsHandle& aParam);
+    
+    TUint QueryImageObjectCountL();
+    
+private:
+    struct SMTPImageDpParentCache
+        {        
+        TPath   iPath;
+        TUint32 iHandle;
+        };
+    
+private:
+	/**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    CMTPImageDpObjectPropertyMgr*       iPropertyMgr;    
+    CMTPImageDpThumbnailCreator*        iThumbnailManager;
+    CMTPImageDpMdeObserver*             iMdeObserver;
+    CRepository*                        iRepository;
+    CMTPImageDpRenameObject*            iRenameObject;
+    
+    /**
+    The active request processors table.
+    */ 
+    RPointerArray<MMTPRequestProcessor> iActiveProcessors;
+    
+    /**
+     * contain the image mapping of extenstion to formatcode
+     */
+    RHashMap<TBuf<KMaxExtNameLength>, TMTPFormatCode> iFormatMappings;
+    
+    SMTPImageDpParentCache  iParentCache;
+    
+    TUint                   iPrePictures;
+    
+    TInt                    iActiveProcessor;
+    TBool                   iActiveProcessorRemoved;    
+    TBool                   iEnumerated;
+	
+	RPointerArray<HBufC>    iDeleteObjectsArray;
+    };
+    
+#endif // CMTPIMAGEDP_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpcopyobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,95 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPCOPYOBJECT_H
+#define CMTPIMAGEDPCOPYOBJECT_H
+
+#include "cmtprequestprocessor.h"
+#include "cmtpimagedpobjectpropertymgr.h"
+
+class RFs;
+class CFileMan;
+class CMTPObjectMetaData;
+class CMTPImageDataProvider;
+
+
+class CMTPImageDpCopyObject : public CMTPRequestProcessor
+    {
+public:
+    static MMTPRequestProcessor* NewL(
+                                    MMTPDataProviderFramework& aFramework,
+                                    MMTPConnection& aConnection,
+                                    CMTPImageDataProvider& aDataProvider);
+    ~CMTPImageDpCopyObject();
+    
+private:	
+    CMTPImageDpCopyObject(
+                    MMTPDataProviderFramework& aFramework,
+                    MMTPConnection& aConnection,
+                    CMTPImageDataProvider& aDataProvider);
+
+private:	//from CMTPRequestProcessor
+    virtual void ServiceL();
+    virtual TMTPResponseCode CheckRequestL();
+    static void FailRecover(TAny* aCopyOperation);
+    void RollBack();
+    void RollBackFromFsL();
+    static void RollBackFromFsL(CMTPImageDpCopyObject* aObject);
+    
+private:
+    void ConstructL();
+    void GetParametersL();
+    void SetDefaultParentObjectL();
+    TMTPResponseCode CopyObjectL(TUint32& aNewHandle);
+    TMTPResponseCode CanCopyObjectL(const TDesC& aOldName, const TDesC& aNewName) const;
+    void GetPreviousPropertiesL(const TDesC& aOldFileName);
+    void SetPreviousPropertiesL(const TDesC& aNewFileName);
+    TUint32 CopyFileL(const TDesC& aOldFileName, const TDesC& aNewFileName);
+    void FailRecover();	
+    TUint32 UpdateObjectInfoL(const TDesC& aNewObject);
+    
+private:
+    typedef                 void (*RollbackFuncL)(CMTPImageDpCopyObject* aObject);
+    RArray<RollbackFuncL>   iRollbackActionL;
+    CFileMan*               iFileMan;
+    CMTPObjectMetaData*     iSrcObjectInfo;
+    CMTPObjectMetaData*     iTargetObjectInfo;
+    HBufC*                  iDest;
+    TUint32                 iNewParentHandle;
+    TUint32                 iStorageId;
+    TFileName               iNewFileName;
+    CMTPImageDataProvider&  iDataProvider;
+    
+    /*
+    TUint16					iSampleFormat;
+    TUint32					iSampleSize;
+    TUint32					iSampleHeight;
+    TUint32					iSampleWidth;
+    this is currently hard coded so doesn't copy these
+    */
+    TTime                   iDateModified;
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+    
+#endif //CMTPIMAGEDPCOPYOBJECT_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpdeleteobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,111 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPDELETEOBJECT_H
+#define CMTPIMAGEDPDELETEOBJECT_H
+
+#include <badesca.h>
+#include <f32file.h>
+
+#include "cmtprequestprocessor.h"
+
+class MMTPObjectMgr;
+class CMTPImageDataProvider;
+class CMTPImageDpObjectPropertyMgr;
+/** 
+Defines data provider GetObject request processor.
+@internalComponent
+*/
+class CMTPImageDpDeleteObject : public CMTPRequestProcessor
+	{
+public:
+
+	static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);
+	~CMTPImageDpDeleteObject();    
+
+private: // From CMTPRequestProcessor
+
+	TMTPResponseCode CheckRequestL();
+	void ServiceL();
+	
+    /**
+    * AO Run method, deletes a selection of files on the system
+    */
+	void RunL();
+	
+    /**
+    * Used to cancel the deletion of the files
+    */
+	void DoCancel();
+
+private:    
+
+	CMTPImageDpDeleteObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);
+	void ConstructL();
+	TMTPResponseCode CheckStorageL(TUint32 aObjectHandle);
+	
+    /**
+    * Gets all object handles (for GetObjectHandlesL)
+    */
+	void GetObjectHandlesL( TUint32 aStorageId, TUint32 aFormatCode, TUint32 aParentHandle );
+	
+	/**
+	* Deletes an object from the file system and the object store
+	*/
+	void DeleteObjectL( TUint32 aHandle );
+	
+	/**
+	AO start
+	 */
+	void StartL();
+	
+	/**
+	Send response to PC
+	 */
+	void SendResponseL();
+	
+private:
+
+	/**
+	FLOGGER debug trace member variable.
+	 */
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+
+	CMTPImageDataProvider& iDataProvider;
+	CMTPObjectMetaData*		iObjectMeta;
+	
+	/**
+	Array of all the objects to delete
+	 */
+	RArray<TUint> iObjectsToDelete;
+	
+    /**
+    The response code
+     */
+	TMTPResponseCode iResponseCode;
+	
+    /**
+    The number of Objects to delete
+     */
+    TInt iObjectsNotDelete;
+	};
+	
+#endif //CMTPIMAGEDPDELETEOBJECT_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetformatcapabilities.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,71 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+#ifndef CMTPIMAGEDPGETFORMATCAPABILITIES_H_
+#define CMTPIMAGEDPGETFORMATCAPABILITIES_H_
+
+#include <mtp/cmtptypeformatcapabilitylist.h>
+#include "cmtprequestprocessor.h"
+
+
+class CMTPTypeObjectPropDesc;
+class CMTPImageDataProvider;
+
+/** 
+Implements the file data provider CMTPGetFormatCapabilities request processor.
+@internalComponent
+*/
+class CMTPImageDpGetFormatCapabilities : public CMTPRequestProcessor
+    {
+public:
+    
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);    
+    ~CMTPImageDpGetFormatCapabilities();    
+    
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+    TMTPResponseCode CheckRequestL();
+    
+private:
+
+    CMTPImageDpGetFormatCapabilities(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+    void BuildFormatExifJpegL();
+    CMTPTypeObjectPropDesc* ServiceProtectionStatusL();
+    CMTPTypeObjectPropDesc* ServiceNonConsumableL();
+    
+    TUint16 GetPropertyGroupNumber(const TUint16 aPropCode) const;
+    
+private: // Owned
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    TUint                                        iFormatCode;
+    /* 
+     * CMTPTypeCapabilityList dataset.
+     */
+    CMTPTypeFormatCapabilityList*                iCapabilityList;
+    };
+
+
+#endif /* CMTPIMAGEDPGETFORMATCAPABILITIES_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,63 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPGETOBJECT_H
+#define CMTPIMAGEDPGETOBJECT_H
+
+#include "cmtprequestprocessor.h"
+
+class CMTPTypeFile;
+class CMTPImageDataProvider;
+
+/** 
+Defines file data provider GetObject request processor
+@internalComponent
+*/
+class CMTPImageDpGetObject : public CMTPRequestProcessor
+	{
+public:
+
+	static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);    
+	~CMTPImageDpGetObject();    
+
+private: // From CMTPRequestProcessor
+
+	void ServiceL();
+	TBool DoHandleCompletingPhaseL();
+	
+private: 
+
+	CMTPImageDpGetObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider);
+	void ConstructL();
+
+	void BuildFileObjectL(const TDesC& aFileName);
+
+private: // Owned
+
+	/**
+	FLOGGER debug trace member variable.
+	 */
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	
+	CMTPTypeFile*          iFileObject;
+	CMTPImageDataProvider& iDataProvider;
+	};
+#endif // CMTPIMAGEDPGETOBJECT_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobjectinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,69 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPGETOBJECTINFO_H
+#define CMTPIMAGEDPGETOBJECTINFO_H
+
+#include <f32file.h>
+
+#include "cmtprequestprocessor.h"
+
+class CMTPTypeObjectInfo;
+class CMTPImageDpObjectPropertyMgr;
+class CMTPImageDataProvider;
+
+/** 
+Defines file data provider GetObjectInfo request processor
+
+@internalTechnology
+*/
+class CMTPImageDpGetObjectInfo : public CMTPRequestProcessor
+	{
+public:
+	
+	static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);	
+	~CMTPImageDpGetObjectInfo();	
+	
+private:
+
+    CMTPImageDpGetObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);
+	void ConstructL();
+
+private: // From CMTPRequestProcessor
+	
+	void ServiceL();
+	TMTPResponseCode CheckRequestL();
+
+private:
+
+	void BuildObjectInfoL();
+	void SetFileNameL();
+	void SetFileSizeDateL();
+	void SetKeywordL();
+		
+private:
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	
+	CMTPTypeObjectInfo*           iObjectInfoToBuild;
+	CMTPObjectMetaData*           iObjectMeta;
+	CMTPImageDpObjectPropertyMgr& iObjectPropertyMgr;
+	};
+	
+#endif CMTPIMAGEDPGETOBJECTINFO_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobjectpropdesc.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,84 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPGETOBJECTPROPDESC_H
+#define CMTPIMAGEDPGETOBJECTPROPDESC_H
+
+#include "cmtprequestprocessor.h"
+
+class CMTPImageDpObjectPropertyMgr;
+class CMTPTypeObjectPropDesc;
+class CMTPImageDataProvider;
+
+/** 
+Defines file data provider GetObjectPropDesc request processor
+
+*/
+class CMTPImageDpGetObjectPropDesc : public CMTPRequestProcessor
+    {
+public:
+    static MMTPRequestProcessor* NewL(
+                                    MMTPDataProviderFramework& aFramework,
+                                    MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);	
+    ~CMTPImageDpGetObjectPropDesc();	
+    
+private:	
+    CMTPImageDpGetObjectPropDesc(
+                    MMTPDataProviderFramework& aFramework,
+                    MMTPConnection& aConnection);
+    void ConstructL();
+
+private:	//from CMTPRequestProcessor
+    virtual TMTPResponseCode CheckRequestL();
+    virtual void ServiceL();	
+
+private:
+    //helper
+    void ServiceStorageIdL();
+    void ServiceObjectFormatL();
+    void ServiceProtectionStatusL();
+    void ServiceObjectSizeL();
+    void ServiceFileNameL();
+    void ServiceDateCreatedL();
+    void ServiceDateModifiedL();
+    void ServiceParentObjectL();
+    void ServicePuidL();
+    void ServiceNameL();
+    void ServiceWidthL();
+    void ServiceHeightL();
+    void ServiceImageBitDepthL();
+    void ServiceRepresentativeSampleFormatL();
+    void ServiceRepresentativeSampleSizeL();
+    void ServiceRepresentativeSampleHeightL();
+    void ServiceRepresentativeSampleWidthL();   
+    void ServiceNonConsumableL();
+    TUint16 GetPropertyGroupNumber(const TUint16 aPropCode) const;
+    
+private:
+    CMTPTypeObjectPropDesc*	iObjectProperty;
+    
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+    
+#endif //CMTPIMAGEDPGETOBJECTPROPDESC_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobjectproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,100 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPGETOBJECTPROPLIST_H
+#define CMTPIMAGEDPGETOBJECTPROPLIST_H
+
+#include "cmtprequestprocessor.h"
+
+class CMTPImageDpObjectPropertyMgr;
+class CMTPTypeArray;
+class CMTPTypeObjectPropList;
+class CMTPImageDataProvider;
+
+/** 
+Implements the file data provider GetObjectPropList request processor.
+@internalComponent
+*/
+class CMTPImageDpGetObjectPropList : public CMTPRequestProcessor
+    {
+public:
+    
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);    
+    ~CMTPImageDpGetObjectPropList(); 
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+    TMTPResponseCode CheckRequestL();
+    
+private:
+
+    CMTPImageDpGetObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);
+    void ConstructL();
+
+    TMTPResponseCode CheckPropCode() const;
+    TMTPResponseCode CheckDepth() const;
+    
+    void GetObjectHandlesL();
+    void GetObjectHandlesL(TUint32 aStorageId, TUint32 aFormatCode, TUint32 aParentHandle);
+    void GetRootObjectHandlesL(TUint32 aFormatCode, TUint32 aDepth);
+    
+    void ServicePropertiesL( TUint32 aHandle );
+    void ServiceAllPropertiesL(TUint32 aHandle);
+    void ServiceGroupPropertiesL(TUint32 aHandle,TUint16 aGroupCode);
+    void ServiceOneObjectPropertyL(TUint32 aHandle, TUint32 aPropCode);
+    
+private:
+	
+    /**
+    * Cancel the enumeration process
+    */
+    void DoCancel();
+
+    /**
+    * Handle completed request
+    */
+    void RunL();
+
+    /**
+    * Ignore the error, continue with the next one
+    */
+    TInt RunError( TInt aError );
+
+    /**
+    * Control the getobjectproplist
+    */
+    void StartL();
+	
+private: // Owned
+
+    CMTPImageDpObjectPropertyMgr&  iPropertyMgr;
+    RArray<TUint>                  iHandles;
+    CMTPTypeObjectPropList*        iPropertyList;  
+    CMTPObjectMetaData*            iObjectMeta;
+    
+    /**
+     FLOGGER debug trace member variable.
+     */
+     __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+    
+#endif // CMTPIMAGEDPGETOBJECTPROPLIST_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobjectpropssupported.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,61 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPGETOBJECTPROPSSUPPORTED_H
+#define CMTPIMAGEDPGETOBJECTPROPSSUPPORTED_H
+
+#include "cmtprequestprocessor.h"
+
+class CMTPTypeArray;
+class CMTPImageDataProvider;
+
+/** 
+Defines file data provider GetObjectPropsSupported request processor
+
+@internalTechnology
+*/
+class CMTPImageDpGetObjectPropsSupported : public CMTPRequestProcessor
+    {
+public:
+    static MMTPRequestProcessor* NewL(
+                                    MMTPDataProviderFramework& aFramework,
+                                    MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);	
+    ~CMTPImageDpGetObjectPropsSupported();	
+    
+private:	
+    CMTPImageDpGetObjectPropsSupported(
+                    MMTPDataProviderFramework& aFramework,
+                    MMTPConnection& aConnection);
+    void ConstructL();
+
+private:	//from CMTPRequestProcessor
+    virtual void ServiceL();
+    
+private:
+    CMTPTypeArray*			iObjectPropsSupported;
+    
+    /**
+      FLOGGER debug trace member variable.
+      */
+      __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+    
+#endif  //CMTPIMAGEDPGETOBJECTPROPSSUPPORTED_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobjectpropvalue.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,92 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPGETOBJECTPROPVALUE_H
+#define CMTPIMAGEDPGETOBJECTPROPVALUE_H
+
+#include "cmtprequestprocessor.h"
+
+class CMTPImageDpObjectPropertyMgr;
+class TMTPTypeUint8;
+class TMTPTypeUint16;
+class TMTPTypeUint32;
+class TMTPTypeUint64;
+class TMTPTypeUint128;
+class CMTPTypeString;
+class CMTPImageDataProvider;
+
+
+class CMTPImageDpGetObjectPropValue : public CMTPRequestProcessor
+    {
+public:
+    static MMTPRequestProcessor* NewL(
+                                    MMTPDataProviderFramework& aFramework,
+                                    MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);	
+    ~CMTPImageDpGetObjectPropValue();	
+    
+private:	
+    CMTPImageDpGetObjectPropValue(
+                    MMTPDataProviderFramework& aFramework,
+                    MMTPConnection& aConnection,
+                    CMTPImageDataProvider& aDataProvider);
+    void ConstructL();
+
+private:	//from CMTPRequestProcessor
+    virtual TMTPResponseCode CheckRequestL();
+    virtual void ServiceL();
+
+private:
+    void ServiceStorageIdL();
+    void ServiceObjectFormatL();
+    void ServiceProtectionStatusL();
+    void ServiceObjectSizeL();
+    void ServiceFileNameL();
+    void ServiceDateCreatedL();
+    void ServiceDateModifiedL();
+    void ServiceParentObjectL();
+    void ServicePuidL();
+    void ServiceNameL();
+    void ServiceWidthL();
+    void ServiceHeightL();
+    void ServiceImageBitDepthL();
+    void ServiceRepresentativeSampleFormatL();
+    void ServiceRepresentativeSampleSizeL();
+    void ServiceRepresentativeSampleHeightL();
+    void ServiceRepresentativeSampleWidthL();
+    void ServiceNonConsumableL();
+
+private:
+    CMTPImageDpObjectPropertyMgr&	iObjectPropertyMgr;
+    TMTPTypeUint8			iMTPTypeUint8;
+    TMTPTypeUint16			iMTPTypeUint16;
+    TMTPTypeUint32			iMTPTypeUint32;
+    TMTPTypeUint64			iMTPTypeUint64;
+    TMTPTypeUint128			iMTPTypeUint128;
+    CMTPTypeString*			iMTPTypeString;
+    CMTPObjectMetaData*     iObjectMeta;
+    
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;    
+    };
+    
+#endif  //CMTPIMAGEDPGETOBJECTPROPVALUE_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobjectreferences.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,57 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPGETOBJECTREFERENCES_H
+#define CMTPIMAGEDPGETOBJECTREFERENCES_H
+
+#include "cmtprequestprocessor.h"
+
+class CMTPTypeArray;
+class CMTPImageDataProvider;
+
+/** 
+Defines generic file system object GetObjectReferences request processor.
+@internalTechnology
+*/
+class CMTPImageDpGetObjectReferences : public CMTPRequestProcessor
+    {
+public:
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider); 
+    ~CMTPImageDpGetObjectReferences();  
+    
+private:    
+    CMTPImageDpGetObjectReferences(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+    
+private: // From CMTPRequestProcessor
+    virtual TMTPResponseCode CheckRequestL();
+    virtual void ServiceL();    
+    
+private:
+    /**
+    FLOGGER debug trace member variable.
+    **/
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    CMTPTypeArray*          iReferences;
+    };
+    
+#endif // CMTPIMAGEDPGETOBJECTREFERENCES_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetpartialobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,70 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPGETPARTIALOBJECT_H
+#define CMTPIMAGEDPGETPARTIALOBJECT_H
+
+#include "cmtprequestprocessor.h"
+
+class MMTPObjectMgr;
+class RFs;
+class CMTPTypePartialFile;
+class CMTPImageDataProvider;
+class CMTPImageDpObjectPropertyMgr;
+/** 
+Defines file data provider GetObject request processor
+
+@internalTechnology
+*/
+class CMTPImageDpGetPartialObject : public CMTPRequestProcessor
+    {
+public:
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);	
+    ~CMTPImageDpGetPartialObject();	
+    
+private:	
+    CMTPImageDpGetPartialObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider);
+    void ConstructL();
+
+private:	//from CMTPRequestProcessor
+    virtual TMTPResponseCode CheckRequestL();
+    virtual void ServiceL();
+    virtual TBool DoHandleResponsePhaseL();
+
+private:
+    //helper
+    TBool VerifyParametersL();
+    void BuildPartialDataL();
+    
+private:
+    /**
+    FLOGGER debug trace member variable.
+     */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+    RFs&                  iFs;
+    TUint32               iOffset;
+    TUint32               iMaxLength;
+    TUint32               iPartialDataLength;
+    CMTPTypeFile*         iFileObject;
+    CMTPObjectMetaData*   iObjectMeta;
+    };
+    
+#endif  //CMTPIMAGEDPGETPARTIALOBJECT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetthumb.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,65 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPGETTHUMB_H
+#define CMTPIMAGEDPGETTHUMB_H
+
+#include "cmtprequestprocessor.h"
+
+
+class CMTPImageDpThumbnailCreator;
+class CMTPImageDataProvider;
+class CMTPTypeOpaqueData;
+
+/** 
+Defines file data provider GetObject request processor
+@internalComponent
+*/
+
+class CMTPImageDpGetThumb : public CMTPRequestProcessor
+    {
+public:
+
+	static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);
+	~CMTPImageDpGetThumb();    
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+    TMTPResponseCode CheckRequestL();
+    TBool DoHandleCompletingPhaseL();
+private: 
+   
+    CMTPImageDpGetThumb(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);
+    void ConstructL();
+        
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    CMTPImageDataProvider& imgDp;
+    CMTPTypeOpaqueData*    iThumb;
+    CMTPObjectMetaData*    iObjectMeta;
+    };
+    
+#endif // CMTPIMAGEDPGETTHUMB_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpmdeobserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,81 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPMDEOBSERVER_H
+#define CMTPIMAGEDPMDEOBSERVER_H
+
+#include <e32cmn.h>
+#include <e32base.h>
+#include <e32def.h>
+
+#include <comms-infras/commsdebugutility.h>
+
+#include "rmediasyncserver.h"
+#include "cmtpimagedpobjectpropertymgr.h"
+
+class MMTPDataProviderFramework;
+class CMTPImageDataProvider;
+
+/** 
+Implements the observer interfaces of MDE.
+@internalComponent
+*/
+class CMTPImageDpMdeObserver : public CBase, 
+                               public MMdEObjectObserver
+    {
+public:
+
+    static CMTPImageDpMdeObserver* NewL(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider);
+    ~CMTPImageDpMdeObserver();
+    
+public:
+    // From MMdEObjectObserver
+    void HandleObjectNotification(CMdESession& aSession,
+                                 TObserverNotificationType aType,
+                                 const RArray<TItemId>& aObjectIdArray);
+    
+    void SubscribeForChangeNotificationL();
+    void UnsubscribeForChangeNotificationL();
+    
+private:
+    CMTPImageDpMdeObserver(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider);
+    void ConstructL();   
+    
+private:    
+    void HandleObjectNotificationL(CMdESession& aSession,
+                                   TObserverNotificationType aType,
+                                   const RArray<TItemId>& aObjectIdArray);
+            
+    void ProcessMdeNotificationL(const RArray<TItemId>& aObjectIdArray, TObserverNotificationType aType);     
+    void CreateMetadataL(const CMdEObject& aMdeObject, CMTPObjectMetaData& aMetaData); 
+    
+private:
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    MMTPDataProviderFramework&    iFramework;    
+    CMTPImageDataProvider&        iDataProvider;
+    TBool                         iSubscribed;
+    TInt                          iNewPics;
+    };
+
+#endif // CMTPIMAGEDPMDEOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpmoveobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,75 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPMOVEOBJECT_H
+#define CMTPIMAGEDPMOVEOBJECT_H
+
+#include "cmtprequestprocessor.h"
+#include "cmtpimagedpobjectpropertymgr.h"
+
+class CFileMan;
+class CMTPObjectMetaData;
+class CMTPImageDpThumbnailCreator;
+class CMTPImageDataProvider;
+
+class CMTPImageDpMoveObject : public CMTPRequestProcessor
+	{
+public:
+	static MMTPRequestProcessor* NewL(
+									MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);	
+	~CMTPImageDpMoveObject();	
+
+private:	
+	CMTPImageDpMoveObject(
+					MMTPDataProviderFramework& aFramework,
+					MMTPConnection& aConnection,
+					CMTPImageDataProvider& aDataProvider);
+	
+private:	//from CMTPRequestProcessor
+	virtual void ServiceL();
+	virtual TMTPResponseCode CheckRequestL();
+	
+private:
+	void ConstructL();
+	void GetParametersL();
+	void SetDefaultParentObjectL();
+	TMTPResponseCode MoveObjectL();
+	TMTPResponseCode CanMoveObjectL(const TDesC& aOldName, const TDesC& aNewName) const;
+	TMTPResponseCode MoveFileL(const TDesC& aOldFileName, const TDesC& aNewFileName);
+	TInt MoveImageFile(const TDesC& aOldImageName, const TDesC& aNewImageName);
+	
+private:	
+	CFileMan*				iFileMan;
+	CMTPObjectMetaData*		iObjectInfo;
+	HBufC*					iDest;
+	HBufC*					iNewRootFolder;
+	TUint32					iNewParentHandle;
+	TUint32					iStorageId;
+	TTime					iPreviousModifiedTime;
+	CMTPImageDataProvider& iDataProvider;
+	/**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+	
+#endif  //CMTPIMAGEDPMOVEOBJECT_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpobjectpropertymgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,203 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+
+#ifndef CMTPIMAGEDPOBJECTPROPERTYMGR_H
+#define CMTPIMAGEDPOBJECTPROPERTYMGR_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <e32std.h>
+
+#include <mdesession.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptypeuint32.h>
+
+#include "mtpimagedpconst.h"
+
+class MMTPObjectMgr;
+class MMTPPuidMgr;
+class TMTPTypeUint128;
+class CMTPTypeString;
+class MMTPDataProviderFramework;
+class CFileStore;
+class CMTPTypeString;
+class CMTPObjectMetaData;
+
+/** 
+Manage picture object properties
+
+@internalTechnology
+@released
+*/
+class CMTPImageDpObjectPropertyMgr : public CBase, public MMdESessionObserver
+   {    
+   
+public:
+    static CMTPImageDpObjectPropertyMgr* NewL(MMTPDataProviderFramework& aFramework);
+    ~CMTPImageDpObjectPropertyMgr();
+    void SetCurrentObjectL(CMTPObjectMetaData& aObjectInfo, TBool aRequireForModify, TBool aSaveToCache = EFalse);
+    
+    void SetPropertyL(TMTPObjectPropertyCode aProperty, const TUint8 aValue);
+    void SetPropertyL(TMTPObjectPropertyCode aProperty, const TUint16 aValue);
+    void SetPropertyL(TMTPObjectPropertyCode aProperty, const TUint32 aValue);
+    void SetPropertyL(TMTPObjectPropertyCode aProperty, const TUint64 aValue);
+    void SetPropertyL(TMTPObjectPropertyCode aProperty, const TDesC& aValue);
+    
+    void GetPropertyL(TMTPObjectPropertyCode aProperty, TUint8& aValue);
+    void GetPropertyL(TMTPObjectPropertyCode aProperty, TUint16& aValue);
+    void GetPropertyL(TMTPObjectPropertyCode aProperty, TUint32& aValue);
+    void GetPropertyL(TMTPObjectPropertyCode aProperty, TUint64& aValue);
+    void GetPropertyL(TMTPObjectPropertyCode aProperty, TMTPTypeUint128& aValue);
+    void GetPropertyL(TMTPObjectPropertyCode aProperty, CMTPTypeString& aValue);    
+    
+    //clear the cache
+    void ClearCacheL();
+    void ConvertMTPTimeStr2TTimeL(const TDesC& aTimeString, TTime& aModifiedTime) const;
+    
+public:
+    void SetMdeSessionError(TInt aError);
+    CMdESession& MdeSession();
+    
+    // from MMdESessionObserver
+    void HandleSessionOpened(CMdESession& aSession, TInt aError);
+    void HandleSessionError(CMdESession& aSession, TInt aError);
+   
+private:
+    CMTPImageDpObjectPropertyMgr(MMTPDataProviderFramework& aFramework);
+    void ConstructL(MMTPDataProviderFramework& aFramework);
+    
+    TBool GetYear(const TDesC& aDateString, TInt& aYear) const;
+    TBool GetMonth(const TDesC& aDateString, TMonth& aMonth) const;
+    TBool GetDay(const TDesC& aDateString, TInt& aDay) const;
+    TBool GetHour(const TDesC& aDateString, TInt& aHour) const;
+    TBool GetMinute(const TDesC& aDateString, TInt& aMinute) const;
+    TBool GetSecond(const TDesC& aDateString, TInt& aSecond) const;
+    TBool GetTenthSecond(const TDesC& aDateString, TInt& aTenthSecond) const;     
+    
+    void SetProperty2CacheL(TMTPObjectPropertyCode aProperty, TAny* aValue);
+    void GetPropertyFromMdsL(TMTPObjectPropertyCode aProperty, TAny* aValue);
+
+    TUint32 ParseImageFileL(const TDesC& aUri, TMTPObjectPropertyCode aPropCode);
+    void RemoveProperty(CMdEObject& aObject, CMdEPropertyDef& aPropDef);
+    
+private:
+    
+    //define property cache object
+    class CMTPImagePropertiesCache : public CBase
+    {
+    public:
+        /**
+        MTP image cache properites identifiers.
+        */      
+        enum TElementId
+            {        
+            EImagePixWidth        = 0,
+            EImagePixHeight       = 1,
+            EImageBitDepth        = 2,
+            EDateCreated          = 3,
+            
+            /**
+            The number of elements.        
+            */
+            ENumProperties,
+            };
+        
+    public:
+        static CMTPImagePropertiesCache* NewL();
+        virtual ~CMTPImagePropertiesCache();
+        
+        void ResetL();
+        
+        const TDesC& DesC(TUint aId) const;
+        TUint Uint(TUint aId) const;
+        TUint ObjectHandle() const;
+        
+        void SetDesCL(TUint aId, const TDesC& aValue);
+        void SetUint(TUint aId, TUint aValue);  
+        void SetObjectHandle(TUint aObjectHandle);
+        
+    private:
+        
+        enum TType
+            {
+            EUint       = 0,
+            EDesC       = 1,
+            };
+        
+        struct TElementMetaData
+            {
+            TUint   iOffset;
+            TType   iType;
+            };                
+        
+    private:        
+        CMTPImagePropertiesCache(const TElementMetaData* aElements, TUint aCount);
+        void ConstructL();
+        
+    private:
+        /**
+        The element meta-data.
+        */        
+        const RArray<TElementMetaData>  iElements;
+        
+        /**
+        The DesC element data.
+        */
+        RPointerArray<HBufC>            iElementsDesC;
+        
+        /**
+        The Uint element data.
+        */
+        RArray<TUint>                   iElementsUint;
+        
+        /**
+        The object handle of owner
+        */
+        TUint                           iObjectHandle;
+        
+        static const TElementMetaData   KElements[];        
+    };
+    
+private:
+    /**
+    FLOGGER debug trace member variable.
+    */    
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    CActiveSchedulerWait*       iActiveSchedulerWait;
+    CMdESession*                iMetaDataSession;
+    TInt                        iMdeSessionError;
+    CMdEObject*                 iObject;
+
+    RFs&                        iFs;
+    MMTPObjectMgr&              iObjectMgr;
+    CMTPObjectMetaData*         iObjectInfo;  //not owned
+    TBool                       iCacheHit;//flag to indicate cache is available
+    
+    /**
+     * Cache the latest image properties which PC send to device,
+     * it can optimize synce/reverse-sync performance due to reduction of object properties generation
+     */
+    CMTPImagePropertiesCache*     iPropertiesCache; 
+    };
+   
+#endif // CMTPIMAGEDPOBJECTPROPERTYMGR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedprenameobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,73 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+
+#ifndef CMTPIMAGEDPRENAMEOBJECT_H
+#define CMTPIMAGEDPRENAMEOBJECT_H
+
+#include "mtpdebug.h"
+
+// Forward declarations
+class MMTPDataProviderFramework;
+class CMTPImageDataProvider;
+class MMTPObjectMgr;
+class CMTPObjectMetaData;
+
+class CMTPImageDpRenameObject: public CActive
+    {
+public:
+    static CMTPImageDpRenameObject* NewL(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider);
+    virtual ~CMTPImageDpRenameObject();
+
+    void StartL( const TUint32 aParentHandle, const TDesC& aOldFolderName );
+    
+protected:
+    /**
+    * Standard C++ Constructor
+    */
+    CMTPImageDpRenameObject(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider);
+    void ConstructL();
+
+protected:
+    // from CActive
+    void DoCancel();
+    void RunL();
+    TInt RunError( TInt aError );
+
+private:    
+    void GenerateObjectHandleListL(TUint32 aParentHandle);    
+
+private:    
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    MMTPDataProviderFramework& iFramework;
+    CMTPImageDataProvider&  iDataProvider;
+    RArray<TUint> iObjectHandles;
+    CMTPObjectMetaData* iObjectInfo;
+    CMTPObjectMetaData* iParentObjectInfo;
+    TInt iCount;
+    TInt iIndex;
+    RBuf iNewFileName;
+    
+    CActiveSchedulerWait* iRenameWaiter;
+    TUint32 iParentHandle;
+    };
+
+#endif // CMTPIMAGEDPRENAMEOBJECT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpsendobjectinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,190 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPSENDOBJECTINFO_H
+#define CMTPIMAGEDPSENDOBJECTINFO_H
+
+#include <mdccommon.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/tmtptypenull.h>
+
+#include "cmtprequestprocessor.h"
+
+class CMTPTypeFile;
+class CMTPTypeObjectInfo;
+class CMTPTypeObjectPropList;
+class CMTPTypeObjectPropListElement;
+class CMTPImageDpObjectPropertyMgr;
+class CMTPImageDataProvider;
+
+/** 
+Implements the file data provider's SendObjectInfo request processor.
+@internalComponent
+*/
+class CMTPImageDpSendObjectInfo : public CMTPRequestProcessor
+    {
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider);
+    ~CMTPImageDpSendObjectInfo();    
+    
+private:
+
+    CMTPImageDpSendObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider);
+    void ConstructL();
+
+private: // From CMTPRequestProcessor
+
+    TBool Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const;
+    TMTPResponseCode CheckRequestL();
+    void ServiceL();
+    TBool DoHandleCompletingPhaseL();
+    TBool DoHandleResponsePhaseL();
+    TBool HasDataphase() const;
+
+private:    
+    enum TMTPSendingObjectEvent
+        {
+        EObjectInfoEvent = 0,
+        EObjectPropListEvent,
+        EObjectEvent,
+        EEventEnd
+        }; 
+    
+    enum TMTPSendingObjectState
+        {
+        EStateIdle = 0,        //initail state
+        EObjectInfoCheck,       
+        EObjectInfoServ,    
+        EObjectInfoSucceed,
+        EObjectCheck,
+        EObjectServ,
+        EStateEnd
+        };         
+   
+    typedef TBool (*FsmAction)(CMTPImageDpSendObjectInfo*, TAny*);    
+    struct TInternalFSM
+        {
+        TMTPSendingObjectState iNextSuccessState;
+        TMTPSendingObjectState iNextFailedState;        
+        FsmAction              iFsmAction;               
+        };           
+    
+    typedef void (*RollbackAction)(CMTPImageDpSendObjectInfo*);
+    
+private:
+    void GetDefaultParentObjectL();
+    TMTPResponseCode GetParentObjectAndStorageIdL();   
+    
+    // check specific request parameters
+    TBool CheckObjectInfoParamsL(TAny *aPtr);
+    TBool CheckObjectPropListParamsL(TAny *aPtr);
+    TBool CheckObjectParams(TAny *aPtr);
+    
+    // static function pointer of FSM
+    static TBool FsmCheckObjectInfoParamsL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);
+    static TBool FsmCheckObjectPropListParamsL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);
+    static TBool FsmCheckObjectParams(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);    
+    
+    // service functions
+    TBool ServiceSendObjectInfoL(TAny *aPtr);
+    TBool ServiceSendObjectPropListL(TAny *aPtr);
+    TBool ServiceSendObjectL(TAny *aPtr);
+    
+    // static function pointer of FSM
+    static TBool FsmServiceSendObjectInfoL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);
+    static TBool FsmServiceSendObjectPropListL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);
+    static TBool FsmServiceSendObjectL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);    
+    
+    // response functions
+    TBool DoHandleSendObjectInfoCompleteL(TAny *aPtr);
+    TBool DoHandleSendObjectPropListCompleteL(TAny *aPtr);
+    TBool DoHandleSendObjectCompleteL(TAny *aPtr);
+    
+    // static function pointer of FSM
+    static TBool FsmDoHandleSendObjectInfoCompleteL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);
+    static TBool FsmDoHandleSendObjectPropListCompleteL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);
+    static TBool FsmDoHandleSendObjectCompleteL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);    
+    
+    TBool GetFullPathName(const TDesC& aFileName);    
+    TBool CanStoreFileL(TUint32 aStorageId, TInt64 aObjectSize) const;
+    TBool Exists(const TDesC& aName) const;
+        
+    void ReserveObjectL();
+    void Rollback();
+    void CleanUndoList();
+    
+    // rollback functions
+    void UnreserveObject();
+    void RemoveObjectFromDb();
+    void RemoveObjectFromFs();
+    
+    static void UnreserveObject(CMTPImageDpSendObjectInfo* aObject);
+    static void RemoveObjectFromDb(CMTPImageDpSendObjectInfo* aObject); 
+    static void RemoveObjectFromFs(CMTPImageDpSendObjectInfo* aObject);    
+    
+    TMTPResponseCode ExtractPropertyL(const CMTPTypeObjectPropListElement& aElement);
+    TMTPResponseCode VerifyObjectPropListL(TInt& aInvalidParameterIndex);
+    TMTPResponseCode CheckPropCodeL(const CMTPTypeObjectPropListElement& aElement) const; 
+    
+    void ReturnResponseL();
+    void SetPropertiesL();
+    TBool IsFormatValid(TMTPFormatCode aFormat) const;
+    
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+    CMTPImageDataProvider&   iDataProvider;    
+    CMTPTypeFile*            iFileReceived;
+    CMTPTypeObjectInfo*      iObjectInfo;
+    CMTPTypeObjectPropList*  iObjectPropList;
+    TMTPSendingObjectState   iCurrentState;
+    TMTPSendingObjectEvent   iEvent;
+    TUint16                  iOperationCode;
+    TUint32                  iStorageId;
+    TUint32                  iParentHandle;
+    TUint64                  iObjectSize;
+    HBufC*                   iParentSuid;
+    TFileName                iFullPath;
+    HBufC*                   iDateMod;// To carry modified date extracted from PropertyList
+    HBufC*                   iDateCreated;// To carry created date extracted from PropertyList
+    CMTPObjectMetaData*      iReceivedObject;
+    TMTPTypeRequest          iExpectedSendObjectRequest;
+    TUint16                  iProtectionStatus;
+    TUint16                  iFormatCode;
+    TUint32                  iPreviousTransactionID;
+    CMTPImageDpObjectPropertyMgr&  iObjectPropertyMgr;
+    TFileName                iName;
+    TItemId                  iObjectId;
+    RArray<RollbackAction>   iRollbackList;
+    TBool                    iSuccessful;
+    TInternalFSM             iStateMachine[EStateEnd][EEventEnd];
+    TUint32                  imageWidth;
+    TUint32                  imageHeight;
+    TUint32                  imageBitDepth;    
+    TUint8                   iNonConsumable;
+    };
+    
+#endif //CMTPIMAGEDPSENDOBJECTINFO_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpsetobjectproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,69 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPSETOBJECTPROPLIST_H
+#define CMTPIMAGEDPSETOBJECTPROPLIST_H
+
+#include "cmtprequestprocessor.h"
+
+class CMTPImageDpObjectPropertyMgr;
+class CMTPTypeObjectPropList;
+class CMTPImageDataProvider;
+
+/** 
+Implements the file data provider SetObjectPropsList request processor.
+*/
+class CMTPImageDpSetObjectPropList : public CMTPRequestProcessor
+    {
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);    
+    ~CMTPImageDpSetObjectPropList();    
+    
+private:
+
+    CMTPImageDpSetObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);
+    void ConstructL();
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+    TBool DoHandleResponsePhaseL();
+    TBool HasDataphase() const;
+    
+private:
+
+    TMTPResponseCode CheckPropCode(TUint16 aPropertyCode, TUint16 aDataType) const;
+
+private:
+
+    /**
+    FLOGGER debug trace member variable.
+    **/
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    CMTPImageDataProvider&         iDataProvider;
+    CMTPImageDpObjectPropertyMgr&  iPropertyMgr;
+    CMTPTypeObjectPropList* iPropertyList;
+    CMTPObjectMetaData*		iObjectMeta;
+    };
+    
+#endif // CMTPIMAGEDPSETOBJECTPROPLIST_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpsetobjectpropvalue.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,70 @@
+
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+#ifndef CMTPIMAGEDPSETOBJECTPROPVALUE_H
+#define CMTPIMAGEDPSETOBJECTPROPVALUE_H
+
+#include "cmtprequestprocessor.h"
+
+class CMTPImageDpObjectPropertyMgr;
+class CMTPTypeString;
+class TMTPTypeUint8;
+class CMTPImageDataProvider;
+
+
+class CMTPImageDpSetObjectPropValue : public CMTPRequestProcessor
+	{
+public:
+	static MMTPRequestProcessor* NewL(
+									MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider);	
+	~CMTPImageDpSetObjectPropValue();	
+	
+private:	
+	CMTPImageDpSetObjectPropValue(
+					MMTPDataProviderFramework& aFramework,
+					MMTPConnection& aConnection,
+					CMTPImageDataProvider& aDataProvider);
+	void ConstructL();
+	TBool IsPropCodeReadonly(TUint32 aObjectPropCode);
+
+private:	//from CMTPRequestProcessor
+	virtual TMTPResponseCode CheckRequestL();
+	virtual void ServiceL();
+	virtual TBool DoHandleResponsePhaseL();
+	TBool HasDataphase() const;
+
+private:
+	/**
+	FLOGGER debug trace member variable.
+	**/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	
+	CMTPImageDataProvider&          iDataProvider;
+	CMTPImageDpObjectPropertyMgr&	iObjectPropertyMgr;
+	CMTPTypeString*			iMTPTypeString;
+	TMTPTypeUint8			iMTPTypeUint8;
+	TMTPTypeUint16			iMTPTypeUint16;
+	TMTPTypeUint32			iMTPTypeUint32;
+	CMTPObjectMetaData*		iObjectMeta;
+	};
+	
+#endif  //CMTPIMAGEDPSETOBJECTPROPVALUE_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpsetobjectprotection.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,59 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPSETOBJECTPROTECTION_H
+#define CMTPIMAGEDPSETOBJECTPROTECTION_H
+
+#include "cmtprequestprocessor.h"
+
+class CMTPTypeArray;
+class CMTPImageDataProvider;
+
+/** 
+Defines generic file system object GetObjectReferences request processor.
+@internalTechnology
+*/
+class CMTPImageDpSetObjectProtection : public CMTPRequestProcessor
+    {
+public:
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider); 
+    ~CMTPImageDpSetObjectProtection();  
+    
+private:    
+    CMTPImageDpSetObjectProtection(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+    
+private: // From CMTPRequestProcessor
+    virtual TMTPResponseCode CheckRequestL();
+    virtual void ServiceL();   
+    TBool DoHandleResponsePhaseL();
+       
+private:
+    /**
+    FLOGGER debug trace member variable.
+    **/
+    TMTPTypeUint16          iMTPTypeUint16;
+    RFs&                    iRfs;
+    CMTPObjectMetaData*     iObjMeta;
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+    
+#endif // CMTPIMAGEDPSETOBJECTPROTECTION_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpsetobjectreferences.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,62 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPSETOBJECTREFERENCES_H
+#define CMTPIMAGEDPSETOBJECTREFERENCES_H
+
+#include "cmtprequestprocessor.h"
+
+class CMTPTypeArray;
+class CMTPImageDataProvider;
+
+/** 
+Defines generic file system object GetObjectReferences request processor.
+@internalTechnology
+*/
+class CMTPImageDpSetObjectReferences : public CMTPRequestProcessor
+    {
+public:
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider); 
+    ~CMTPImageDpSetObjectReferences();  
+    
+private:    
+    CMTPImageDpSetObjectReferences(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+    
+private: // From CMTPRequestProcessor
+    virtual TMTPResponseCode CheckRequestL();
+    virtual void ServiceL();   
+    TBool HasDataphase() const;
+    TBool DoHandleResponsePhaseL();
+    
+private:
+    TBool VerifyReferenceHandlesL() const;
+    
+private:
+    /**
+    FLOGGER debug trace member variable.
+    **/
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    CMTPTypeArray*          iReferences;
+    };
+    
+#endif // CMTPIMAGEDPSETOBJECTREFERENCES_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpthumbnailcreator.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,141 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPTHUMBNAILCREATOR_H
+#define CMTPIMAGEDPTHUMBNAILCREATOR_H
+
+// INCLUDES
+#include <e32base.h>
+
+#include <thumbnailmanager.h>
+#include <thumbnailmanagerobserver.h>
+#include <thumbnailobjectsource.h>
+#include <thumbnaildata.h>
+#include <imageconversion.h>
+#include <bitmaptransforms.h>
+
+class CMTPTypeOpaqueData;
+
+#include "mtpdebug.h"
+
+#define MTPTHUMBSCALING
+
+// CLASS DECLARATION
+/**
+*  A class for reading image related info and creating a thumbnail from 
+*  an image.
+*
+*  @lib ptpstack.lib
+*  @since S60 3.2
+*/
+class CMTPImageDpThumbnailCreator : public CActive, public MThumbnailManagerObserver
+    {
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param None.
+     * @return An instance of CMTPImageDpThumbnailCreator.
+     */
+    static CMTPImageDpThumbnailCreator* NewL();
+
+    /**
+     * C++ destructor.
+     */
+    ~CMTPImageDpThumbnailCreator();
+    
+public:
+
+    /**
+     * Gets a thumbnail from the image.
+     * @since S60 3.2
+     * @param aSession, Reference to file server.
+     * @param aFileName, Name of the image file. Caller must ensure that the referenced object exists until the asynchronous call is completed.
+     * @param aThumbName, Name of the thumbnail file to be created. Caller must ensure that the referenced object exists until the asynchronous call is completed.
+     * @param aGetThumbnailStatus, status when 
+     */
+    void GetThumbnailL(const TDesC& aFileName, CMTPTypeOpaqueData& aThumbName, TInt& result);
+
+
+    void ClearThumbnailData();
+    CThumbnailManager*  GetThumbMgr() { return iThumbMgr;}
+
+private: // From MThumbnailManagerObserver
+    void ThumbnailReady( TInt aError, MThumbnailData& aThumbnail, TThumbnailRequestId aId );
+    void ThumbnailPreviewReady( MThumbnailData& aThumbnail, TThumbnailRequestId aId );
+
+private: // From CActive
+    void DoCancel();
+    void RunL();
+    TInt RunError(TInt aError);    
+ 
+private:
+    void EncodeImageL();    
+    /**
+     * Scales the image as a thumbnail size.
+     * @since S60 3.2
+     * @param None.
+     * @return None.
+     */
+#ifdef MTPTHUMBSCALING
+    void ScaleBitmap();
+#endif
+    void QueueThumbCreationL( const TDesC& aFileName );
+    void CreateThumbL(const TDesC& aFileName );
+    void GetThumbL(const TDesC& aFileName);
+
+private:
+    /**
+     * Default C++ constructor. Not used.
+     */
+    CMTPImageDpThumbnailCreator();
+
+    /**
+     * 2nd phase constructor.
+     */
+    void ConstructL();
+
+private:
+    /**
+    FLOGGER debug trace member variable.
+    **/
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    enum{
+        EIdle,
+        EGetting,
+        EGetted,
+        EScaling,
+        EEncoding}          iState;
+    TThumbnailRequestId     iCurrentReq;
+    TInt*                   iCreationErr;
+    CFbsBitmap*             iBitmap;
+    CImageEncoder*          iImgEnc;
+#ifdef MTPTHUMBSCALING
+    CBitmapScaler*          iScaler;
+#endif
+    HBufC8*                 iData;
+    CThumbnailManager*      iThumbMgr;
+    CThumbnailObjectSource* iObjectSource;
+    CMTPTypeOpaqueData*     iBuffer;             //not owned
+    CActiveSchedulerWait*   iActiveSchedulerWait;
+    };
+
+#endif // CMTPIMAGEDPTHUMBNAILCREATOR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/mtpimagedpconst.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,195 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#ifndef MTPIMAGEDPCONST_H
+#define MTPIMAGEDPCONST_H
+
+#include <e32std.h>
+
+#include <mtp/mtpprotocolconstants.h>
+#include <comms-infras/commsdebugutility.h> // for __FLOG debugging
+
+// for thumb creation
+const TUint32 KThumbWidht=160;
+const TUint32 KThumbHeigth=120;
+const TUint32 KThumbCompressedSize=KThumbWidht * KThumbHeigth * 4; // from TNM
+const TUint32 KThumbFormatCode = 0x3801;
+const TUint32 KFileSizeMax = 10 * 1000 * 1000;
+
+_LIT(KJpegMimeType, "image/jpeg");
+_LIT8(KPtpMimeJPEG, "image/jpeg");
+
+/**
+Define all the operations that are supported by the picture data provider
+*/
+static const TUint16 KMTPImageDpSupportedOperations[] = 
+  	{
+  	EMTPOpCodeGetObjectInfo,
+  	EMTPOpCodeGetObject,
+  	EMTPOpCodeGetPartialObject,	
+    EMTPOpCodeGetThumb,	
+  	EMTPOpCodeDeleteObject,
+  	EMTPOpCodeSendObjectInfo,
+  	EMTPOpCodeSendObject,
+  	EMTPOpCodeMoveObject,
+  	EMTPOpCodeCopyObject,
+  	EMTPOpCodeGetObjectReferences,
+  		
+  	//MTP op codes
+  	EMTPOpCodeGetObjectPropsSupported,
+  	EMTPOpCodeGetObjectPropDesc,
+  	EMTPOpCodeGetObjectPropValue,
+  	EMTPOpCodeSetObjectPropValue,
+  	EMTPOpCodeSetObjectReferences,
+
+  	//MTP enhanced operation codes
+  	EMTPOpCodeGetObjectPropList,
+  	EMTPOpCodeSetObjectPropList,
+  	EMTPOpCodeSendObjectPropList,
+
+    EMTPOpCodeGetFormatCapabilities,
+    
+    //Deprecated operation
+    EMTPOpCodeSetObjectProtection
+  	};	
+
+/**
+Define all the object properties that are supported by the picture data provider
+*/
+static const TUint16 KMTPImageDpSupportedProperties[] =
+  	{
+    //Stored in MTP MetaData Object
+  	EMTPObjectPropCodeStorageID,
+  	EMTPObjectPropCodeObjectFormat,
+    EMTPObjectPropCodeProtectionStatus,	
+  	EMTPObjectPropCodeObjectFileName,
+  	EMTPObjectPropCodeParentObject,
+  	EMTPObjectPropCodePersistentUniqueObjectIdentifier,
+
+    //Stored in MDE object
+    EMTPObjectPropCodeName,
+    EMTPObjectPropCodeObjectSize,
+    EMTPObjectPropCodeDateCreated, 
+    EMTPObjectPropCodeDateModified,
+  	EMTPObjectPropCodeWidth,
+  	EMTPObjectPropCodeHeight,
+  	EMTPObjectPropCodeImageBitDepth,
+  	EMTPObjectPropCodeRepresentativeSampleFormat,
+  	EMTPObjectPropCodeRepresentativeSampleSize,
+  	EMTPObjectPropCodeRepresentativeSampleHeight,
+  	EMTPObjectPropCodeRepresentativeSampleWidth,
+  	EMTPObjectPropCodeNonConsumable
+  	};
+
+/**
+Define the supported property group number .
+*/
+static const TUint16 KMTPImageDpPropertyGroupOneNumber = 1;
+
+/**
+Define the group one supported properties.
+The properties in group one are same as all properties which image dp supported,
+It can avoid PC get all properties and group one properties twice while sendobjectproplist/sendobject
+*/
+static const TUint16 KMTPImageDpGroupOneProperties[] =
+    {
+    //Stored in MTP MetaData Object
+    EMTPObjectPropCodeStorageID,
+    EMTPObjectPropCodeObjectFormat,
+    EMTPObjectPropCodeProtectionStatus, 
+    EMTPObjectPropCodeObjectFileName,
+    EMTPObjectPropCodeParentObject,
+    EMTPObjectPropCodePersistentUniqueObjectIdentifier,
+
+    //Stored in MDE object
+    EMTPObjectPropCodeName,
+    EMTPObjectPropCodeNonConsumable,
+    EMTPObjectPropCodeObjectSize,
+    EMTPObjectPropCodeDateCreated, 
+    EMTPObjectPropCodeDateModified,
+    EMTPObjectPropCodeWidth,
+    EMTPObjectPropCodeHeight,
+    EMTPObjectPropCodeImageBitDepth,
+    EMTPObjectPropCodeRepresentativeSampleFormat,
+    EMTPObjectPropCodeRepresentativeSampleSize,
+    EMTPObjectPropCodeRepresentativeSampleHeight,
+    EMTPObjectPropCodeRepresentativeSampleWidth
+    };
+
+/**
+Define the group one supported property number.
+*/
+static const TUint16 KMTPImageDpGroupOneSize = sizeof(KMTPImageDpGroupOneProperties)/sizeof(KMTPImageDpGroupOneProperties[0]); 
+
+/**
+Define all events that are supported by the picture data provider
+*/
+static const TUint16 KMTPImageDpSupportedEvents[] =
+    {
+    EMTPEventCodeObjectAdded,
+    EMTPEventCodeObjectRemoved,
+    EMTPEventCodeObjectInfoChanged
+    };
+
+static const TUint32 KPtpNoValue = 0xFFFFFF00;
+
+static const TInt KExtensionBufferSize=5; //related to the size of strings in SMTPValidCodeExtensionMapping
+typedef TBufC<KExtensionBufferSize> TMTPImageFileExtension;
+
+// extensions of image files that are shared via MTP Picture Data Provider
+struct SMTPValidCodeExtensionMapping
+    {
+    public:
+    TMTPFormatCode iFormatCode;
+    const TText*   iExtension;
+    };
+
+// Note when adding extensions: 
+// same value for iExtension can be in the file only once, 
+// values for iFormatCode code can be multiple times
+
+#if defined(_UNICODE)
+#define CASTING(a) ((const TText*)L ## a)
+#else
+#define CASTING(a) ((const TText*)(a))
+#endif
+
+static const SMTPValidCodeExtensionMapping KMTPValidCodeExtensionMappings[] =
+    {
+    {EMTPFormatCodeEXIFJPEG, CASTING("jpg")},   // jpeg
+    {EMTPFormatCodeEXIFJPEG, CASTING("jpe")},   // jpeg
+    {EMTPFormatCodeEXIFJPEG, CASTING("jpeg")}  // jpeg
+    };
+
+/**
+Defines the image dp parameters.
+*/
+enum TImageDpParameter
+    {
+    /**
+    This parameter defines the new images property value. 
+    
+    This parameter value can be retrieved as an @see TInt value.
+    */        
+    ENewImagesCount                 = 0x00000000,
+    };
+
+#endif // MTPIMAGEDPCONST_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/mtpimagedppanic.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,56 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef MTPIMAGEDPPANIC_H
+#define MTPIMAGEDPPANIC_H
+
+#include <e32std.h>
+
+/**
+define the file data provider panic code
+@internalTechnology
+
+*/
+enum TMTPImageDpPanic
+	{
+	EMTPImageDpNoMatchingProcessor = 0,
+	EMTPImageDpObjectNull = 1,
+	EMTPImageDpFormatNotSupported = 2,
+	EMTPImageDpSendObjectStateInvalid = 3,
+	EMTPImageDpRequestCheckNull = 4,
+	EMTPImageDpHandlesNull = 5,
+	EMTPImageDpUnsupportedProperty = 6,
+	EMTPImageDpObjectPropertyNull = 7,
+	EMTPImageDpCannotRenameDir = 8,
+	EMTPImageDpIPropertyNotSupported = 9,
+	EMTPImageDpBadLayout     = 10,
+	EMTPImageDpTypeMismatch  = 11,
+	};
+
+_LIT(KMTPImageDpPanic, "MTP Image Data Provider");
+
+inline void Panic(TMTPImageDpPanic aCode)
+	{
+	User::Panic(KMTPImageDpPanic, aCode);
+	};
+	
+
+#endif // MTPIMAGEDPPANIC_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/mtpimagedprequestprocessor.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,46 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+#ifndef MTPIMAGEDPPROCESSOR_H_
+#define MTPIMAGEDPPROCESSOR_H_
+
+class MMTPConnection;
+class TMTPTypeRequest;
+class CMTPDataProviderPlugin;
+class MMTPDataProviderFramework;
+class MMTPRequestProcessor;
+class CMTPImageDataProvider;
+
+/** 
+Defines task data provider request processor factory
+
+@internalTechnology
+*/
+class MTPImageDpProcessor
+	{
+public:
+	static MMTPRequestProcessor* CreateL(
+	                                    MMTPDataProviderFramework& aFramework,
+	                                    const TMTPTypeRequest& aRequest, 
+	                                    MMTPConnection& aConnection,
+	                                    CMTPImageDataProvider& aDataProvider);    
+	};
+
+#endif /*MTPIMAGEDPPROCESSOR_H_*/
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/mtpimagedputilits.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,59 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef MTPIMAGEDPUTILITS_H
+#define MTPIMAGEDPUTILITS_H
+
+#include <e32base.h>
+
+#include <mtp/mtpprotocolconstants.h>
+
+#include "rmediasyncserver.h"
+
+class MMTPDataProviderFramework;
+class CMTPObjectMetaData;
+class TMTPTypeUint32;
+class CMTPImageDataProvider;
+
+/** 
+Defines static utility functions
+**/
+
+class MTPImageDpUtilits 
+    {
+public:
+    
+    static TMTPResponseCode VerifyObjectHandleL(MMTPDataProviderFramework& aFramework, const TMTPTypeUint32& aHandle, CMTPObjectMetaData& aMetaData);
+    
+    static TInt32  FindStorage(MMTPDataProviderFramework& aFramework, const TDesC& aPath);
+    
+    static TUint32 FindParentHandleL(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider, const TDesC& aFullPath);
+    
+    /**
+     * Calculate the new pictures value and set RProperty.
+     
+       @param aDataProvider  The image data provider reference
+       @param aNewPics       The new pictures count
+       @param aSetRProperty  Whether should set RProperty value to notify all subscribers.
+     */
+    static void UpdateNewPicturesValue(CMTPImageDataProvider& aDataProvider, TInt aNewPics, TBool aSetRProperty);
+    };
+    
+#endif MTPIMAGEDPUTILITS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,29 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+../group/rmediasyncserver.mmp
+../group/mediasyncserver.mmp
+
+PRJ_EXPORTS
+../group/mediasyncserver.iby /epoc32/rom/include/mediasyncserver.iby
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/group/mediasyncserver.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,30 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef MEDIASYNCSERVER_IBY
+#define MEDIASYNCSERVER_IBY
+
+#include <bldvariant.hrh>
+
+file=ABI_DIR\BUILD_DIR\rmediasyncserver.dll		SHARED_LIB_DIR\rmediasyncserver.dll
+
+file=ABI_DIR\BUILD_DIR\mediasyncserver.exe		PROGRAMS_DIR\mediasyncserver.exe
+
+#endif // MEDIASYNCSERVER_IBY
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/group/mediasyncserver.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,50 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <comms-infras/commsdebugutility.mmh>
+#include "defaultcaps.hrh"
+
+TARGET        	mediasyncserver.exe
+TARGETTYPE      EXE
+UID             0 0x20024331
+CAPABILITY 	    CAP_SERVER
+VENDORID 	    VID_DEFAULT
+
+SOURCEPATH      ../src
+SOURCE          main.cpp
+SOURCE          cmediasyncserver.cpp
+SOURCE			cmediasyncserversession.cpp 
+SOURCE          cmediasyncobserver.cpp 
+SOURCE          cmediasyncdatabase.cpp
+SOURCE          cmediasyncdatawriter.cpp
+
+USERINCLUDE		  ../inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY		euser.lib
+LIBRARY		edbms.lib
+LIBRARY		efsrv.lib
+LIBRARY		bafl.lib
+LIBRARY		mdeclient.lib
+LIBRARY     ecom.lib
+LIBRARY     flogger.lib     // RFileLogger
+
+SMPSAFE
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/group/rmediasyncserver.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,37 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include "defaultcaps.hrh"
+
+TARGET        	rmediasyncserver.dll
+TARGETTYPE      dll
+UID             0x1000008d 0x20024332
+CAPABILITY 	    CAP_CLIENT_DLL
+VENDORID 	    VID_DEFAULT
+
+MW_LAYER_SYSTEMINCLUDE
+USERINCLUDE		../inc
+
+SOURCEPATH      ../src
+SOURCE          rmediasyncserver.cpp
+
+LIBRARY		    euser.lib
+
+SMPSAFE
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/inc/cmediasyncdatabase.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,126 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMEDIASYNCDATABASE_H
+#define CMEDIASYNCDATABASE_H
+
+#include <d32dbms.h>
+#include <comms-infras/commsdebugutility.h>
+#include <mdesession.h>
+#include <mdccommon.h>
+#include <comms-infras/commsdebugutility.h>
+
+class CMediaSyncDataWriter;
+class CMdESession;
+
+class CMediaSyncDatabase : public CBase
+    {
+public:
+    static CMediaSyncDatabase* NewL(RFs& aFs);
+    ~CMediaSyncDatabase();
+
+    /**        
+    * Save MDS notification to database
+    *
+    * @param aObjectIdArray array of changed object id
+    * @param aChangeType type of change related with this changed object
+    *
+    */
+    void SaveNotificationsL(const RArray<TItemId>& aObjectIdArray, TObserverNotificationType aType, CMdESession& aSession); 
+    
+    /**        
+    * Save MDS notification to database
+    *
+    * @param aObjectIdArray object IDs which are set to present statect
+    * @param aPresent state: ETrue - present or  EFales - not present
+    *
+    */
+    void SaveNotificationsL(const RArray<TItemId>& aObjectIdArray, TBool aPresent, CMdESession& aSession);     
+    
+    /**        
+    * Delete all notification record from database
+    * 
+    */ 
+    void RemoveAllNotificationsL();    
+    
+    /**
+     * Delete specific notificaion by object id
+     * 
+     * @param aObjectId changed object id
+     * 
+     */
+    TBool RemoveNotificationL(TItemId aObjectId, TUint aType);
+    
+    /**        
+    * Get notification record from database
+    *
+    * @param aResulWriter on return contains serialized results
+    * @param aIsFinished flag indicate whether all record has been fetched
+    */    
+    void FetchNotificationsL(CMediaSyncDataWriter& aResulWriter, TInt aMaxtFetchCount, TBool& aIsFinished);
+    
+    /**
+     * Rollback the current transaction
+     */
+    void Rollback();
+    
+    /**
+     * Check whether DB file is corrupt
+     */
+    inline TBool IsMssDbCorrupt() { return iDbCorrupt; }
+    
+    /**
+     * Clear DB corrupt flag
+     */    
+    inline void ClearMssDbCorrupt() { iDbCorrupt = EFalse; }
+    
+private:
+    CMediaSyncDatabase(RFs& aFs);
+    void ConstructL();
+    void CreateTableL(const TDesC& aDbFile);
+    void CreateTabIndexL();
+    
+    void SaveAddNotificationsL(const RArray<TItemId>& aObjectIdArray, CMdESession& aSession);        
+    void SaveAndCheckWithUriL(const RArray<TItemId>& aObjectIdArray, TUint aType, CMdESession& aSession);
+    void SaveWithoutUriL(const RArray<TItemId>& aObjectIdArray, TUint aType);         
+    void CompactDatabase();
+    
+    TBool UpdateUriColumnL(TItemId aObjectId, TUint aType, const TDesC& aUri);     
+    TBool OptimizeL(TItemId aObjectId, TUint aType, const TDesC& aUri);
+    inline TBool OptimizeL(TItemId aObjectId, TUint aType);
+    
+    static void RollbackTable(TAny* aTable);
+    
+private:
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    RFs&             iFs;
+    RDbNamedDatabase iDatabase;
+    RDbTable         iBatched;    
+    TBool            iDbCorrupt;// flag that indicate whether database is corrupt
+    TBool            iSavePosition;
+    TDbBookmark      iBookmark;   
+    TInt             iCompactCounter;
+    };
+
+#endif /*CMEDIASYNCDATABASE_H*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/inc/cmediasyncdatawriter.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,52 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMEDIASYNCDATAWRITER_H
+#define CMEDIASYNCSERVERSESSION_H
+
+#include <e32std.h>
+
+#include "cmediasyncserverdef.h"
+
+class CMediaSyncDataWriter : public CBase
+    {
+public:
+    static CMediaSyncDataWriter* NewLC(const RChunk& aChunk);
+    /** virtual C++ destructor */
+    ~CMediaSyncDataWriter();    
+    
+    TInt FreeSpaceBytes();
+    void AppendEntryL(TUint32 aObjectId, TUint8 aType, const TDesC& aUri);
+    
+private:
+    /** C++ constructor initialises */
+    CMediaSyncDataWriter();
+    void ConstructL(const RChunk& aChunk);
+    
+    inline void CheckBufferCapacityL(TInt aReqSize);
+    
+private:
+    TDataHeaderInfo* iHeaderInfo;
+    TUint8*          iWriteBase;
+    TInt             iOffset;
+    TInt             iMaxSize;
+    };
+
+#endif /*CMEDIASYNCSERVERSESSION_H*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/inc/cmediasyncobserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,86 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+
+#ifndef CMEDIASYNCOBSERVER_H
+#define CMEDIASYNCOBSERVER_H
+
+#include "cmediasyncserverdef.h"
+#include "cmediasyncdatabase.h"
+
+class CMediaSyncDatabase;
+
+class CMediaSyncObserver : public CBase,
+                           public MMdESessionObserver,
+                           public MMdEObjectObserver,
+                           public MMdEObjectPresentObserver
+  {
+public:
+    static CMediaSyncObserver* NewL(CMediaSyncDatabase* aDb);
+    virtual ~CMediaSyncObserver();
+  
+    void SubscribeForChangeNotificationL();
+    
+    void UnsubscribeForChangeNotificationL();
+    
+public:
+    // From MMdESessionObserver
+    void HandleSessionOpened(CMdESession& aSession, TInt aError);
+    void HandleSessionError(CMdESession& aSession, TInt aError);
+    
+    // From MMdEObjectObserver
+    void HandleObjectNotification(CMdESession& aSession,
+                                 TObserverNotificationType aType,
+                                 const RArray<TItemId>& aObjectIdArray);
+    
+    // From MMdEObjectPresentObserver
+    void HandleObjectPresentNotification(CMdESession& aSession, 
+                                        TBool aPresent, 
+                                        const RArray<TItemId>& aObjectIdArray);
+    
+private:
+    
+    CMediaSyncObserver(CMediaSyncDatabase* aDb);
+    void ConstructL();
+    
+    void HandleSessionCallback(TInt aError);
+    
+    void HandleObjectNotificationL(CMdESession& aSession,
+                                   TObserverNotificationType aType,
+                                   const RArray<TItemId>& aObjectIdArray);  
+    
+    void HandleObjectPresentNotificationL(CMdESession& aSession, 
+                                        TBool aPresent, 
+                                        const RArray<TItemId>& aObjectIdArray);
+    
+private: //not has ownership
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    CMdESession*           iSession;    
+    CMediaSyncDatabase*    iDb;    
+    CActiveSchedulerWait*  iSessionWait;  
+    TInt                   iMdeSessionError;
+    TBool iSubscribed;  
+  };
+
+#endif /*CMEDIASYNCOBSERVER_H*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/inc/cmediasyncserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,70 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMEDIASYNCSERVER_H
+#define CMEDIASYNCSERVER_H
+
+#include <e32base.h>
+#include <e32std.h>
+
+#include "cmediasyncserverdef.h"
+
+class RFs;
+class CMediaSyncObserver;
+class CMediaSyncDatabase;
+
+class CMediaSyncServer : public CPolicyServer
+    {
+public:
+
+    ~CMediaSyncServer();
+
+    static void RunServerL();
+    static CMediaSyncServer* NewLC(RFs& aFs);
+    
+    CMediaSyncObserver* MediaSyncObserver() const;
+    CMediaSyncDatabase* MediaSyncDatabase() const;
+  //  void AddSession();
+  //  void DropSession();
+    
+    TBool NeedFullSync();
+    void ClearFullSyncFlag();
+    
+private: // From CPolicyServer
+    
+   CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
+    
+private:
+    
+    CMediaSyncServer();
+    void ConstructL(RFs& aFs);
+    
+private: //has ownership
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    CMediaSyncDatabase* iDb;
+    CMediaSyncObserver* iObserver;
+    TBool               iNeedFullSync; 
+    };
+
+#endif /*CMEDIASYNCSERVER_H*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/inc/cmediasyncserverdef.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,83 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMEDIASYNCSERVERDEF_H
+#define CMEDIASYNCSERVERDEF_H
+
+#include <comms-infras/commsdebugutility.h>
+
+__FLOG_STMT(_LIT8(KMSSSubsystem, "MSS");)
+
+_LIT(KFinderMSSName, "mediasyncserver*");
+_LIT(KMediaSyncServerName, "mediasyncserver");
+ 
+_LIT(KMssDbName, "mediasync.db");
+_LIT(KImageTableName, "ImageStore");
+_LIT(KSQLCombinedIndex, "CombinedIndex");
+_LIT(KMssLockName, "mss.lock");
+
+_LIT(KMediaSyncClientPanicCategory, "MediaSyncServ-Client");
+
+// MIME definition
+_LIT(KJpegMime, "image/jpeg");
+
+const TInt KCustomSqlMaxLength = 512;
+
+const TInt KMediaSyncServerVersionMinor = 0;
+const TInt KMediaSyncServerVersionMajor = 1;
+
+/**
+The Media Sync Server process UID3.
+*/
+const TUid KMediaSyncServerUid3 = {0x20024331};
+
+enum TMediaSyncPanicsClient
+    {
+    ECannotStartServer,
+    EBadRequest,
+    ERequestPending
+    };
+
+enum TMediaSyncClientMessage 
+    {
+    EMediaSyncClientGetGSHHandle,
+    EMediaSyncClientGetChanges,    
+    EMediaSyncClientRemoveAllRecords,
+    EMediaSyncClientEnableMonitor,
+    EMediaSyncClientDisableMonitor,
+    EMediaSyncClientNeedFullSync,
+    EMediaSyncClientClearFullSync,
+    EMediaSyncClientShutdown,
+    EMediaSyncClientNotSupported
+    };
+
+const TUint KMssRemoval     = 1;
+const TUint KMssAddition    = 2;
+const TUint KMssChange      = 3;
+const TUint KMssPresent     = 4;
+const TUint KMssNotPresent  = 5;
+
+class TDataHeaderInfo
+    {
+public:
+    TInt iCount;
+    };
+
+#endif /* CMEDIASYNCSERVERDEF_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/inc/cmediasyncserversession.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,69 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+
+#ifndef CMEDIASYNCSERVERSESSION_H
+#define CMEDIASYNCSERVERSESSION_H
+
+#include <e32base.h>
+#include "cmediasyncserverdef.h"
+
+class CMediaSyncServer;
+
+class CMediaSyncServerSession : public CSession2
+    {
+public:
+
+    CMediaSyncServerSession(CMediaSyncServer* aServer);
+    ~CMediaSyncServerSession();
+    
+public: // From CSession2
+    void ServiceL(const RMessage2& aMessage);
+
+private:
+    
+    void DispatchMessageL(const RMessage2& aMessage);
+    
+    TInt GetChangesL(const RMessage2& aMessage);   
+    
+    TInt GetFullSyncFlag(const RMessage2& aMessage);
+    
+    void AllocateGlobalSharedHeapL(const RMessage2& aMessage);
+    
+private: //not have ownership
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    CMediaSyncServer* iServer;
+    
+    /**
+     * Indicate wheter global shared heap has been allocated.
+     */
+    TBool iAllocated; 
+    
+    /** Global shared heap for passing large amounts of data between client and server
+    without having to use IPC */
+    RChunk iGlobalSharedHeap;
+    };
+
+
+#endif /*CMEDIASYNCSERVERSESSION_H*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/inc/rmediasyncserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,156 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#ifndef RMEDIASYNCSERVER_H_
+#define RMEDIASYNCSERVER_H_
+
+#include <e32std.h>
+#include "cmediasyncserverdef.h"
+
+struct TMDSNotification
+    {
+    TUint  objectId;
+    TUint8 changeType;
+    TUint8 activeSchedulerWait;
+    TUint8 reserved[2];
+    };
+
+class CMediaSyncDataReader : public CBase
+    {
+public:
+    static CMediaSyncDataReader* NewL(const RChunk& aChunk);
+    /** virtual C++ destructor */
+    IMPORT_C ~CMediaSyncDataReader();    
+    
+    IMPORT_C TInt  Count();
+    IMPORT_C TBool HasNext();
+    IMPORT_C void  GetNextL(TUint32& aObjectId, TUint8& aType, TPtr16& aUri);
+    
+private:
+    /** C++ constructor initialises */
+    CMediaSyncDataReader();
+    void ConstructL(const RChunk& aChunk);
+    
+private:
+    TDataHeaderInfo* iHeaderInfo;
+    TUint8*          iReadBase;
+    TInt             iOffset;
+    TInt             iCurrentIdx;
+    };
+
+class RMediaSyncServer : public RSessionBase
+    {    
+public:
+    IMPORT_C RMediaSyncServer();
+    
+    /**
+    * Starts up MediaSyncServer
+    */
+    IMPORT_C TInt Startup();
+    
+    /**
+    * Shut down MediaSyncServer
+    */
+    IMPORT_C void Shutdown();    
+
+    /**
+    * Connects to MediaSyncServer, does not start up MediaSyncServer if it is
+    * not running
+    * @return KErrNone on successfull connection, 
+    *         KMediaSyncServerCleanupYourDatabase on successful connection, 
+    *         but the database needs to be resynched. The client must empty
+    *         MTP database on the objects under its control before reading 
+    *         the change information since it will get everything that is in
+    *         MDS.
+    *         Systen wide error code if the connection fails.
+    */        
+    IMPORT_C TInt Connect();
+    
+    /**
+    * Client should call this when it has detected that the databases are 
+    * out of sync or that its database is corrupted. This will lead MSS to 
+    * reread everything from the MDS after all the session were closed and 
+    * at next connection Connect to return KMediaSyncServerCleanupYourDatabase 
+    * to all dataproviders.
+    * @param aNeedFullSync ETrue if the MSS DB file is corrupt and the client need to fully sync with MDE    
+    * @return KErrNone if successful, otherwise one of the system-wide error codes
+    *     
+    */
+    IMPORT_C TInt NeedFullSync(TBool& aNeedFullSync);
+    
+    /**
+    * Clear full synchronization flag from MSS   
+    * @return KErrNone if successful, otherwise one of the system-wide error codes
+    *     
+    */        
+    IMPORT_C TInt ClearFullSync();
+
+    /**        
+    * This methods returns changes and their type. It only returns one type of 
+    * changes at one call. Removals will be returned first then Additions, 
+    * then Changes. The change information will be deleted from the DB when returned.
+    * If an object is both added, changed and then deleted between the 
+    * connections, no information on it is returned, on the other hand if 
+    * object is first deleted the object with a same name is added, both 
+    * deletion and addition entry are available.
+    *
+    * Moving objects are treated as deletion and addition (keeping the metadata if possible)
+    *
+    * @param aNotifications on return the array of MDE notifications 
+    * @param aIsFinished ETrue if this array is the last one for MDE notifications    
+    * @param aStatus async call, KErrNone if changes received, 
+    *                            KErrNotFound if there are no changes,  
+    *                            otherwise another system wide error code.
+    *
+    */
+    IMPORT_C void GetChangesL(CMediaSyncDataReader*& aDataReader, TBool& aIsFinished, TRequestStatus& aStatus, TInt aMaxFetchCount = 512);
+
+    /**
+    * Remove all recodes from MSS
+    */        
+    IMPORT_C void RemoveAllRecords();
+    
+    /**
+    * Enable MSS subscribes MDS notifications
+    * @return KErrNone if successful, otherwise one of the system-wide error codes
+    */         
+    IMPORT_C TInt EnableMonitor();
+    
+    /**
+    * Disable MSS subscribes MDS notifications
+    * @return KErrNone if successful, otherwise one of the system-wide error codes
+    */        
+    IMPORT_C TInt DisableMonitor();
+    
+    IMPORT_C void Close();
+        
+private:    
+    TInt GetGlobalSharedHeapHandle();
+    void RelaseGlobalSharedHeap();
+    
+private:
+    TBool  iHasSharedHeap; 
+    
+    /** Handle to the Global Shared Heap */
+    RChunk iGlobalSharedHeap;    
+    };
+
+
+#endif /*RMEDIASYNCSERVER_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/src/cmediasyncdatabase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,501 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#include <bautils.h>
+#include <mdesession.h>
+#include <mdequery.h>
+#include <mdeconstants.h>
+
+#include "cmediasyncserverdef.h"
+#include "cmediasyncdatabase.h"
+#include "cmediasyncdatawriter.h"
+
+__FLOG_STMT(_LIT8(KComponent,"MediaSyncDatabase");)
+
+const TInt KCompactThreshold = 50;
+const TInt KMaxRetryTimes = 3;
+const TInt KDelayPeriod = 3 * 1000000;
+
+CMediaSyncDatabase* CMediaSyncDatabase::NewL(RFs& aFs)
+    {
+    CMediaSyncDatabase* self = new (ELeave) CMediaSyncDatabase(aFs);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+void CMediaSyncDatabase::ConstructL()
+    {
+    __FLOG_OPEN(KMSSSubsystem, KComponent);
+    __FLOG(_L8("CMediaSyncDatabase::ConstructL - Entry"));
+
+    //Connect to the file server
+    User::LeaveIfError(iFs.Connect());
+
+    TFileName databasePath;
+    iFs.PrivatePath(databasePath);
+    TDriveUnit driveNum = RFs::GetSystemDrive();
+    databasePath.Insert(0, driveNum.Name());
+    databasePath.Append(KMssDbName);
+
+    CreateTableL(databasePath);    
+    
+    User::LeaveIfError(iBatched.Open(iDatabase, KImageTableName, RDbRowSet::EUpdatable));
+    
+    __FLOG(_L8("CMediaSyncDatabase::ConstructL - Exit"));
+    }
+
+CMediaSyncDatabase::CMediaSyncDatabase(RFs& aFs) :
+    iFs(aFs),
+    iDbCorrupt(EFalse),
+    iSavePosition(EFalse)
+    {
+    }
+
+CMediaSyncDatabase::~CMediaSyncDatabase()
+    {
+    __FLOG(_L8("CMediaSyncDatabase::~CMediaSyncDatabase - Entry"));
+    
+    iBatched.Close();
+    iDatabase.Close();
+    
+    __FLOG(_L8("CMediaSyncDatabase::~CMediaSyncDatabase - Exit"));
+    __FLOG_CLOSE;
+    }
+
+void CMediaSyncDatabase::CreateTableL(const TDesC& aDbFile)
+    {
+    __FLOG(_L8("CMediaSyncDatabase::CreateTableL - Entry"));
+    
+    _LIT(KSQLCreateTable, "CREATE TABLE ImageStore(ObjectId UNSIGNED INTEGER, NotificationType UNSIGNED INTEGER, URI VARCHAR(255))");           
+    
+    TInt err = KErrNone;
+    if (!BaflUtils::FileExists(iFs, aDbFile))
+        {
+        __FLOG(_L8("CreateTableL - Table ImageStore does not exist"));
+        
+        BaflUtils::EnsurePathExistsL(iFs, aDbFile);
+        
+        User::LeaveIfError(iDatabase.Create(iFs, aDbFile));
+        User::LeaveIfError(iDatabase.Execute(KSQLCreateTable));
+        TRAP_IGNORE(CreateTabIndexL());
+        }    
+    else
+        {
+        //Open the database
+        TBool recreateDbFile = EFalse;
+        err = iDatabase.Open(iFs, aDbFile);
+        if (err == KErrNone)
+            {
+            if (iDatabase.IsDamaged())
+                {
+                recreateDbFile = (iDatabase.Recover() == KErrNone) ? EFalse : ETrue;
+                }
+            }
+        else
+            {
+            recreateDbFile = ETrue;
+            }
+        
+        if (recreateDbFile)
+            {
+            __FLOG_VA((_L8("CreateTableL - Open Table ImageStore failed: %d"), err));
+            iDatabase.Close();
+
+            TInt retryCount = KMaxRetryTimes;
+            TInt result = KErrNone;            
+            for (; retryCount > 0; retryCount--)
+                {
+                result = BaflUtils::DeleteFile(iFs, aDbFile);
+                if (result == KErrNone)
+                    {
+                    // We have succesfully delete corrupt database file
+                    break;
+                    }       
+                else
+                    {
+                    User::After(KDelayPeriod);
+                    }
+                }
+            
+            User::LeaveIfError(result);
+            User::LeaveIfError(iDatabase.Create(iFs, aDbFile));
+            User::LeaveIfError(iDatabase.Execute(KSQLCreateTable));
+            TRAP_IGNORE(CreateTabIndexL());
+            iDbCorrupt = ETrue;          
+            }
+        }    
+    
+    __FLOG(_L8("CMediaSyncDatabase::CreateTableL - Exit"));
+    }
+
+void CMediaSyncDatabase::CreateTabIndexL()
+    {    
+    __FLOG(_L8("CMediaSyncDatabase::CreateTabIndexL - Entry"));
+    
+    _LIT(KSQLCreateCombinedIndexText,"CREATE UNIQUE INDEX CombinedIndex on ImageStore (ObjectId, NotificationType)");      
+    User::LeaveIfError(iDatabase.Execute(KSQLCreateCombinedIndexText));
+    
+    __FLOG(_L8("CMediaSyncDatabase::CreateTabIndexL - Exit"));
+    }
+
+void CMediaSyncDatabase::SaveNotificationsL(const RArray<TItemId>& aObjectIdArray, TObserverNotificationType aType, CMdESession& aSession)
+    {    
+    iDatabase.Begin();  
+
+    switch (aType)
+        {
+        case ENotifyAdd:
+            __FLOG(_L8("CMediaSyncDatabase::SaveNotificationsL Addition - Entry"));
+            SaveAddNotificationsL(aObjectIdArray, aSession);
+            break;
+            
+        case ENotifyRemove:
+            __FLOG(_L8("CMediaSyncDatabase::SaveNotificationsL Remove - Entry"));
+            SaveWithoutUriL(aObjectIdArray, KMssRemoval);
+            break;
+            
+        case ENotifyModify:
+            __FLOG(_L8("CMediaSyncDatabase::SaveNotificationsL Modify - Entry"));
+            SaveAndCheckWithUriL(aObjectIdArray, KMssChange, aSession);
+            break;
+            
+        default:
+            __FLOG_VA((_L8("SaveNotificationsL - Unknown argument: %d"), aType));
+            User::Leave(KErrArgument);
+            break;
+        }
+   
+    iDatabase.Commit();
+    
+    __FLOG(_L8("CMediaSyncDatabase::SaveNotificationsL - Exit"));
+    }
+
+inline TBool CMediaSyncDatabase::OptimizeL(TItemId aObjectId, TUint aType)
+    {    
+    return OptimizeL(aObjectId, aType, KNullDesC);
+    }
+
+void CMediaSyncDatabase::Rollback()
+    {
+    __ASSERT_DEBUG(iDatabase.InTransaction(), User::Invariant());
+    iDatabase.Rollback();
+    }
+
+TBool CMediaSyncDatabase::OptimizeL(TItemId aObjectId, TUint aType, const TDesC& aUri)
+    {
+    __FLOG(_L8("CMediaSyncDatabase::OptimizeL - Entry"));
+    
+    TBool saveNotification = ETrue;
+    
+    switch (aType)
+        {                
+    case KMssChange:
+        if ( UpdateUriColumnL(aObjectId, KMssAddition, aUri) ||
+             UpdateUriColumnL(aObjectId, KMssChange, aUri) )
+            {
+            saveNotification = EFalse;// ignore this update notification
+            }
+        __FLOG_VA((_L8("OptimizeL - KMssChange ObjectId: %u, Ignore saving: %d"), aObjectId, saveNotification));
+        break;
+                
+    case KMssPresent:
+        if (RemoveNotificationL(aObjectId, KMssNotPresent))
+            {
+            saveNotification = EFalse;// ignore this present notification
+            }
+        __FLOG_VA((_L8("OptimizeL - KMssPresent ObjectId: %u, Ignore saving: %d"), aObjectId, saveNotification));
+        break;        
+        
+    case KMssRemoval:
+        if (RemoveNotificationL(aObjectId, KMssAddition))
+            {
+            saveNotification = EFalse;// ignore this removal notification
+            }        
+        else
+            {
+            RemoveNotificationL(aObjectId, KMssChange);
+            }
+        __FLOG_VA((_L8("OptimizeL - KMssRemoval ObjectId: %u, Ignore saving: %d"), aObjectId, saveNotification));
+        break;
+        
+    case KMssNotPresent:
+        if (RemoveNotificationL(aObjectId, KMssPresent))
+            {
+            saveNotification = EFalse;// ignore this not present notification
+            }
+        __FLOG_VA((_L8("OptimizeL - KMssNotPresent ObjectId: %u, Ignore saving: %d"), aObjectId, saveNotification));
+        break;
+        
+    default:
+        // Nothing to do
+        break;
+        }
+    
+    __FLOG(_L8("CMediaSyncDatabase::OptimizeL - Exit"));
+    
+    return saveNotification;
+    }
+
+void CMediaSyncDatabase::SaveNotificationsL(const RArray<TItemId>& aObjectIdArray, TBool aPresent, CMdESession& aSession)
+    {        
+    iDatabase.Begin();
+   
+    if (aPresent)
+        {
+        __FLOG(_L8("CMediaSyncDatabase::SaveNotificationsL Present - Entry"));
+        SaveAndCheckWithUriL(aObjectIdArray, KMssPresent, aSession);
+        }
+    else
+        {
+        __FLOG(_L8("CMediaSyncDatabase::SaveNotificationsL Not Present - Entry"));
+        SaveWithoutUriL(aObjectIdArray, KMssNotPresent);
+        }      
+    
+    iDatabase.Commit();  
+    
+    __FLOG(_L8("CMediaSyncDatabase::SaveNotificationsL Present - Exit"));
+    }
+
+void CMediaSyncDatabase::SaveAddNotificationsL(const RArray<TItemId>& aObjectIdArray, CMdESession& aSession)
+    {
+    __FLOG(_L8("CMediaSyncDatabase::SaveAddNotificationsL - Entry"));
+    
+    CMdENamespaceDef& defaultNamespaceDef = aSession.GetDefaultNamespaceDefL();
+    CMdEObjectDef& imageObjDef = defaultNamespaceDef.GetObjectDefL(MdeConstants::Image::KImageObject); 
+
+    TInt objectCount = aObjectIdArray.Count();   
+    for (TInt i(0);i < objectCount;i++)
+        {       
+        TItemId objectId = aObjectIdArray[i];
+        CMdEObject* addObject = aSession.GetObjectL(objectId, imageObjDef);
+        if (addObject)
+            {
+            CleanupStack::PushL(addObject);
+            CleanupStack::PushL(TCleanupItem(CMediaSyncDatabase::RollbackTable, &iBatched));
+            iBatched.InsertL();
+            iBatched.SetColL(1, (TUint32)objectId);
+            iBatched.SetColL(2, KMssAddition);
+            iBatched.SetColL(3, addObject->Uri());
+            iBatched.PutL();
+            CleanupStack::Pop(&iBatched);            
+            __FLOG_VA((_L16("CMediaSyncDatabase::SaveAndCheckWithUriL - ObjectId:%u, Type:%u, URI:%S"), objectId, KMssAddition, &addObject->Uri()));
+            CleanupStack::PopAndDestroy(addObject); 
+            }                                 
+        }      
+    
+    __FLOG(_L8("CMediaSyncDatabase::SaveAddNotificationsL - Exit"));
+    }
+
+void CMediaSyncDatabase::SaveAndCheckWithUriL(const RArray<TItemId>& aObjectIdArray, TUint aType, CMdESession& aSession)
+    {
+    __FLOG(_L8("CMediaSyncDatabase::SaveAndCheckWithUriL - Entry"));
+    
+    CMdENamespaceDef& defaultNamespaceDef = aSession.GetDefaultNamespaceDefL();
+    CMdEObjectDef& imageObjDef = defaultNamespaceDef.GetObjectDefL(MdeConstants::Image::KImageObject); 
+    CMdEPropertyDef& itemTypePropDef = imageObjDef.GetPropertyDefL(MdeConstants::Object::KItemTypeProperty);    
+
+    TInt objectCount = aObjectIdArray.Count();   
+    for (TInt i(0);i < objectCount;i++)
+        {       
+        TItemId objectId = aObjectIdArray[i];          
+        CMdEObject* changeObject = aSession.GetObjectL(objectId, imageObjDef);
+        if (changeObject)
+            {
+            CleanupStack::PushL(changeObject);            
+            //only support jpeg format image files             
+            CMdEProperty* itemType = NULL;
+            TInt err = changeObject->Property(itemTypePropDef, itemType);
+            
+            if (err >= KErrNone && itemType != NULL && itemType->TextValueL().Compare(KJpegMime) == 0)
+                {                        
+                if (OptimizeL(objectId, aType, changeObject->Uri()))
+                    {                    
+                    CleanupStack::PushL(TCleanupItem(CMediaSyncDatabase::RollbackTable, &iBatched));
+                    iBatched.InsertL();
+                    iBatched.SetColL(1, (TUint32)objectId);
+                    iBatched.SetColL(2, aType);                    
+                    iBatched.SetColL(3, changeObject->Uri());
+                    iBatched.PutL();                    
+                    CleanupStack::Pop(&iBatched);
+                    __FLOG_VA((_L16("CMediaSyncDatabase::SaveAndCheckWithUriL - ObjectId:%u, Type:%u, URI:%S"), objectId, aType, &changeObject->Uri()));
+                    }
+                }
+            CleanupStack::PopAndDestroy(changeObject);            
+            }
+        }  
+    
+    __FLOG(_L8("CMediaSyncDatabase::SaveAndCheckWithUriL - Exit"));
+    }
+
+void CMediaSyncDatabase::SaveWithoutUriL(const RArray<TItemId>& aObjectIdArray, TUint aType)
+    {
+    TInt objectCount = aObjectIdArray.Count();   
+    for (TInt i(0);i < objectCount;i++)
+        {       
+        TItemId objectId = aObjectIdArray[i];        
+        if (OptimizeL(objectId, aType))
+            {
+            CleanupStack::PushL(TCleanupItem(CMediaSyncDatabase::RollbackTable, &iBatched));
+            iBatched.InsertL();
+            iBatched.SetColL(1, (TUint32)objectId);
+            iBatched.SetColL(2, aType);
+            iBatched.PutL();
+            __FLOG_VA((_L8("CMediaSyncDatabase::SaveWithoutUriL - ObjectId:%u, Type: %u"), objectId, aType));
+            CleanupStack::Pop(&iBatched);
+            }
+        }
+    
+    __FLOG(_L8("CMediaSyncDatabase::SaveWithoutUriL - Exit"));
+    }
+
+TBool CMediaSyncDatabase::UpdateUriColumnL(TItemId aObjectId, TUint aType, const TDesC& aUri)
+    {
+    __FLOG(_L8("CMediaSyncDatabase::UpdateUriColumnL - Entry"));
+    
+    TBool update = EFalse;
+    
+    iBatched.SetIndex(KSQLCombinedIndex);
+    TDbSeekMultiKey<2> seekKey;
+    seekKey.Add((TUint)aObjectId);
+    seekKey.Add(aType);
+    if (iBatched.SeekL(seekKey))
+        {
+        CleanupStack::PushL(TCleanupItem(CMediaSyncDatabase::RollbackTable, &iBatched));
+        iBatched.UpdateL();                 
+        iBatched.SetColL(3, aUri);
+        iBatched.PutL();        
+        CleanupStack::Pop(&iBatched);
+        update = ETrue;
+        __FLOG_VA((_L16("CMediaSyncDatabase::UpdateUriColumnL - ObjectId:%u, Type:%u, URI:%S"), aObjectId, aType, &aUri));
+        }    
+    
+    __FLOG(_L8("CMediaSyncDatabase::UpdateUriColumnL - Exit"));
+    return update;
+    }
+
+void CMediaSyncDatabase::RemoveAllNotificationsL()
+    {        
+    _LIT(KSQLDeleteAllNotifications, "DELETE FROM ImageStore");
+  
+    User::LeaveIfError(iDatabase.Execute(KSQLDeleteAllNotifications));    
+    iDatabase.Compact();    
+    iSavePosition = EFalse;    
+    
+    __FLOG_VA((_L8("CMediaSyncDatabase::RemoveAllNotificationsL")));
+    }
+
+TBool CMediaSyncDatabase::RemoveNotificationL(TItemId aObjectId, TUint aType)
+    {
+    TBool remove = EFalse;
+    
+    iBatched.SetIndex(KSQLCombinedIndex);
+    TDbSeekMultiKey<2> seekKey;
+    seekKey.Add((TUint)aObjectId);
+    seekKey.Add(aType);
+    if (iBatched.SeekL(seekKey))
+        {
+        iBatched.DeleteL();
+        CompactDatabase();
+        iSavePosition = EFalse;
+        remove = ETrue;
+        __FLOG_VA((_L8("CMediaSyncDatabase::RemoveNotificationL - ObjectId:%u, Type: %u"), aObjectId, aType));
+        }    
+    return remove;
+    }
+
+void CMediaSyncDatabase::CompactDatabase()
+    {
+    if (++iCompactCounter > KCompactThreshold)
+        {
+        iDatabase.Compact();
+        iCompactCounter = 0;
+        }    
+    }
+
+void CMediaSyncDatabase::FetchNotificationsL(CMediaSyncDataWriter& aResulWriter, TInt aMaxtFetchCount, TBool& aIsFinished)
+    {
+    __FLOG(_L8("CMediaSyncDatabase::FetchNotificationsL - Entry"));
+    
+    _LIT(KSQLQuery, "SELECT ObjectId, NotificationType, URI FROM ImageStore");
+    
+    RDbView view;
+    CleanupClosePushL(view);
+    
+    view.Prepare(iDatabase, TDbQuery(KSQLQuery));
+    view.EvaluateAll();
+    
+    //goto the last fetch position
+    if (iSavePosition)
+        {
+        view.GotoL(iBookmark);
+        }
+    else        
+        {
+        view.FirstL();   
+        }
+    
+    TInt entrySize = 0;
+    //tranvers records
+    while (view.AtRow() && (aMaxtFetchCount > 0))
+        {
+        view.GetL();        
+        TPtrC16 uri = view.ColDes16(3);
+        
+        entrySize = uri.Size();
+        entrySize += sizeof(TUint32);//object id size
+        entrySize += sizeof(TUint8);//type size 
+        entrySize += sizeof(TUint8);//uri size
+        
+        if (entrySize > aResulWriter.FreeSpaceBytes())
+            {
+            //there is no enought space to save entry
+            break;
+            }
+        else
+            {
+            aResulWriter.AppendEntryL(view.ColUint32(1), (TUint8)view.ColUint32(2), uri);
+            view.NextL();
+            --aMaxtFetchCount;
+            }                                       
+        }
+    
+    //save current fetch position
+    if (view.AtEnd())
+        {
+        iSavePosition = EFalse;
+        aIsFinished = ETrue;
+        }
+    else
+        {
+        iBookmark = view.Bookmark();
+        iSavePosition = ETrue;
+        aIsFinished = EFalse;
+        }
+    CleanupStack::PopAndDestroy(&view);
+    
+    __FLOG(_L8("CMediaSyncDatabase::FetchNotificationsL - Exit"));
+    }
+
+void CMediaSyncDatabase::RollbackTable(TAny* aTable)
+    {
+    reinterpret_cast<RDbTable*> (aTable)->Cancel();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/src/cmediasyncdatawriter.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,101 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <e32base.h> 
+
+#include "cmediasyncdatawriter.h"
+
+CMediaSyncDataWriter* CMediaSyncDataWriter::NewLC(const RChunk& aChunk)
+    {
+    CMediaSyncDataWriter* self = new(ELeave) CMediaSyncDataWriter();
+    CleanupStack::PushL(self);
+    self->ConstructL(aChunk);
+    return self;
+    }
+
+CMediaSyncDataWriter::~CMediaSyncDataWriter()
+    {
+    
+    }
+
+CMediaSyncDataWriter::CMediaSyncDataWriter()
+    {
+    
+    }
+
+void CMediaSyncDataWriter::ConstructL(const RChunk& aChunk)
+    {
+    TUint8* base = aChunk.Base();    
+    User::LeaveIfNull(base);
+    
+    iHeaderInfo = reinterpret_cast<TDataHeaderInfo*>(base);
+    iHeaderInfo->iCount = 0;
+    iWriteBase = base + sizeof(TDataHeaderInfo);
+    iMaxSize = aChunk.MaxSize() - sizeof(TDataHeaderInfo);    
+    iOffset = 0;
+    }
+
+TInt CMediaSyncDataWriter::FreeSpaceBytes()
+    {
+    return (iMaxSize - iOffset);
+    }
+
+inline void CMediaSyncDataWriter::CheckBufferCapacityL(TInt aReqSize)
+    {
+    if (aReqSize > (iMaxSize - iOffset))
+        {
+        User::Leave(KErrOverflow);
+        }
+    }
+
+void CMediaSyncDataWriter::AppendEntryL(TUint32 aObjectId, TUint8 aType, const TDesC& aUri)
+    {    
+    //copy object id       
+    CheckBufferCapacityL(sizeof(TUint32));
+    Mem::Copy((iWriteBase + iOffset), &aObjectId, sizeof(TUint32));
+    iOffset += sizeof(TUint32);
+    
+    //copy notification type
+    CheckBufferCapacityL(sizeof(TUint8));
+    Mem::Copy((iWriteBase + iOffset), &aType, sizeof(TUint8));
+    iOffset += sizeof(TUint8);
+    
+    //copy uri length
+    CheckBufferCapacityL(sizeof(TUint8));
+    TUint8 uriLen = aUri.Length();
+    Mem::Copy((iWriteBase + iOffset), &uriLen, sizeof(TUint8));
+    iOffset += sizeof(TUint8);
+    if (uriLen > 0)
+        {
+        //copy uri content
+        CheckBufferCapacityL(aUri.Size());
+        TPtr8 ptr(reinterpret_cast<TUint8*>(const_cast<TUint16*>(aUri.Ptr())), aUri.Size(), aUri.Size());
+        Mem::Copy((iWriteBase + iOffset), ptr.Ptr(), ptr.Size());
+        iOffset += ptr.Size();
+        }
+    
+    ++iHeaderInfo->iCount;
+    }
+
+    
+    
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/src/cmediasyncobserver.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,216 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+//
+#include <mdequery.h>
+#include <mdeconstants.h>
+
+#include "cmediasyncdatabase.h"
+#include "cmediasyncobserver.h"
+
+__FLOG_STMT(_LIT8(KComponent,"MediaSyncObserver");)
+
+CMediaSyncObserver*  CMediaSyncObserver::NewL(CMediaSyncDatabase* aDb)
+    {       
+    CMediaSyncObserver* self = new (ELeave) CMediaSyncObserver(aDb);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+void CMediaSyncObserver::ConstructL()
+    {
+    __FLOG_OPEN(KMSSSubsystem, KComponent);
+    __FLOG(_L8("CMediaSyncObserver::ConstructL - Entry"));
+    
+    iSessionWait = new (ELeave) CActiveSchedulerWait();
+    iSession = CMdESession::NewL(*this);
+    iSessionWait->Start();
+    
+    User::LeaveIfError(iMdeSessionError);    
+    
+//    SubscribeForChangeNotificationL();
+    
+    __FLOG(_L8("CMediaSyncObserver::ConstructL - Exit"));
+    }
+
+CMediaSyncObserver::CMediaSyncObserver(CMediaSyncDatabase* aDb)
+    :iDb(aDb),
+    iSubscribed(EFalse)
+    {    
+    }
+
+CMediaSyncObserver::~CMediaSyncObserver()
+    {
+    __FLOG(_L8("CMediaSyncObserver::~CMediaSyncObserver - Entry"));  
+    
+//    TRAP_IGNORE(UnsubscribeForChangeNotificationL());
+    
+    delete iSession;
+    delete iSessionWait;
+	
+    __FLOG(_L8("CMediaSyncObserver::~CMediaSyncObserver - Exit"));
+    __FLOG_CLOSE;
+    }
+
+void CMediaSyncObserver::SubscribeForChangeNotificationL()
+    {
+    __FLOG(_L8("CMediaSyncObserver::SubscribeForChangeNotificationL - Entry"));
+    
+    if (!iSubscribed)
+        {        
+        CMdENamespaceDef& def = iSession->GetDefaultNamespaceDefL();
+        CMdEObjectDef& imageObjDef = def.GetObjectDefL(MdeConstants::Image::KImageObject);
+        
+        // add observer        
+        CMdELogicCondition* addCondition = CMdELogicCondition::NewLC(ELogicConditionOperatorAnd);          
+        CMdEPropertyDef& itemTypePropDef = imageObjDef.GetPropertyDefL(MdeConstants::Object::KItemTypeProperty);       
+        addCondition->AddPropertyConditionL(itemTypePropDef, ETextPropertyConditionCompareEndsWith, _L("jpeg"));                       
+        iSession->AddObjectObserverL(*this, addCondition, ENotifyAdd);
+        CleanupStack::Pop(addCondition);
+        
+        // modify observer
+        CMdELogicCondition* modifyCondition = CMdELogicCondition::NewLC(ELogicConditionOperatorAnd);          
+        CMdEPropertyDef& titlePropDef = imageObjDef.GetPropertyDefL(MdeConstants::Object::KTitleProperty);
+        modifyCondition->AddPropertyConditionL(titlePropDef);
+        iSession->AddObjectObserverL(*this, modifyCondition, ENotifyModify);
+        CleanupStack::Pop(modifyCondition);
+        
+        // remove observer
+        iSession->AddObjectObserverL(*this, NULL, ENotifyRemove);
+        
+        // present observer
+        iSession->AddObjectPresentObserverL(*this);
+                        
+        iSubscribed = ETrue;               
+        }
+
+    __FLOG(_L8("CMediaSyncObserver::SubscribeForChangeNotificationL - Exit"));
+    }
+
+void CMediaSyncObserver::UnsubscribeForChangeNotificationL()
+    {
+    __FLOG(_L8("CMediaSyncObserver::UnsubscribeForChangeNotificationL - Entry"));
+    
+    if (iSubscribed)
+        {
+        iSession->RemoveObjectObserverL(*this);//add observer
+        iSession->RemoveObjectObserverL(*this);//modify observer
+        iSession->RemoveObjectObserverL(*this);//remove observer
+        iSession->RemoveObjectPresentObserverL(*this);
+        iSubscribed = EFalse;
+        }
+    
+    __FLOG(_L8("CMediaSyncObserver::UnsubscribeForChangeNotificationL - Exit"));
+    }
+
+// From MMdESessionObserver
+void CMediaSyncObserver::HandleSessionOpened(CMdESession& /*aSession*/, TInt aError)
+    {
+    __FLOG(_L8("CMediaSyncObserver::HandleSessionOpened - Entry"));
+    
+    HandleSessionCallback(aError);
+    
+    __FLOG(_L8("CMediaSyncObserver::HandleSessionOpened - Exit"));
+    }
+
+void CMediaSyncObserver::HandleSessionError(CMdESession& /*aSession*/, TInt aError)
+    {
+    __FLOG(_L8("CMediaSyncObserver::HandleSessionError - Entry"));
+    
+    HandleSessionCallback(aError);
+    
+    __FLOG(_L8("CMediaSyncObserver::HandleSessionError - Exit"));
+    }
+
+void CMediaSyncObserver::HandleSessionCallback(TInt aError)
+    {
+    __ASSERT_DEBUG(iSessionWait, User::Invariant());
+    iMdeSessionError = aError;    
+    if (iSessionWait->IsStarted())
+        {
+        iSessionWait->AsyncStop();
+        }
+    }
+
+/*
+ * After receiving object change notification, check if there is any dp subscribed right now.
+ * if none, store change into database
+ * if yes, check the type of file with subscribed providers, if there is any match, just forward
+ * the change to that dp, if none, store change into database.
+ */
+void CMediaSyncObserver::HandleObjectNotification(CMdESession& aSession,
+                                            TObserverNotificationType aType,
+                                            const RArray<TItemId>& aObjectIdArray)
+    {
+    TRAPD(err, HandleObjectNotificationL(aSession, aType, aObjectIdArray));
+    
+    if (err != KErrNone)
+        {
+        __FLOG(_L8("CMediaSyncObserver::HandleObjectNotification - Rollback database"));        
+        iDb->Rollback();
+        }
+    }
+
+/*
+ * L Function
+ */
+void CMediaSyncObserver::HandleObjectNotificationL(CMdESession& /*aSession*/,
+                                                   TObserverNotificationType aType,
+                                                   const RArray<TItemId>& aObjectIdArray)
+    {
+    __FLOG(_L8("CMediaSyncObserver::HandleObjectNotificationL - Entry"));
+    
+    iDb->SaveNotificationsL(aObjectIdArray, aType, *iSession);
+    
+    __FLOG(_L8("CMediaSyncObserver::HandleObjectNotificationL - Exit"));
+    }
+
+/*
+ * Called to notify the observer that objects has been set
+ * to present or not present state in the metadata engine database.
+ */
+void CMediaSyncObserver::HandleObjectPresentNotification(CMdESession& aSession,
+                                                        TBool aPresent, 
+                                                        const RArray<TItemId>& aObjectIdArray)
+    {
+    TRAPD(err, HandleObjectPresentNotificationL(aSession, aPresent, aObjectIdArray));
+    
+    if (err != KErrNone)
+        {
+        __FLOG(_L8("CMediaSyncObserver::HandleObjectPresentNotification - Rollback database"));
+        iDb->Rollback();
+        }    
+    }
+
+/*
+ * L Function
+ */
+void CMediaSyncObserver::HandleObjectPresentNotificationL(CMdESession& /*aSession*/,
+                                                        TBool aPresent, 
+                                                        const RArray<TItemId>& aObjectIdArray)
+    {
+    __FLOG(_L8("CMediaSyncObserver::HandleObjectPresentNotificationL - Entry"));
+     
+    iDb->SaveNotificationsL(aObjectIdArray, aPresent, *iSession);
+       
+    __FLOG(_L8("CMediaSyncObserver::HandleObjectPresentNotificationL - Exit"));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/src/cmediasyncserver.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,202 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <e32base.h>
+#include <bautils.h>
+
+#include "cmediasyncserver.h"
+#include "cmediasyncserversession.h"
+#include "cmediasyncobserver.h"
+#include "cmediasyncserverdef.h"
+
+__FLOG_STMT(_LIT8(KComponent, "MediaSyncServer");)
+
+const TInt KMediaSyncFunctionCodeRanges[] = 
+    {    
+    EMediaSyncClientGetGSHHandle,
+    EMediaSyncClientShutdown,
+    EMediaSyncClientNotSupported,
+    };
+
+const TUint KMediaSyncFunctionCodeRangeCount = (sizeof(KMediaSyncFunctionCodeRanges) 
+                                            / sizeof(KMediaSyncFunctionCodeRanges[0]));
+
+
+const TUint8 KMediaSyncPolicyElementNetworkAndLocal = 0;
+const TUint8 KMediaSyncPolicyElementPowerMgmt = 1;
+
+const TUint8 KMediaSyncElementsIndex[KMediaSyncFunctionCodeRangeCount] =
+    {
+    KMediaSyncPolicyElementNetworkAndLocal,
+    KMediaSyncPolicyElementPowerMgmt,
+    CPolicyServer::ENotSupported,
+    };
+
+const CPolicyServer::TPolicyElement KMediaSyncPolicyElements[] = 
+    { 
+    {_INIT_SECURITY_POLICY_C2(ECapabilityNetworkServices, ECapabilityLocalServices), CPolicyServer::EFailClient},
+    {_INIT_SECURITY_POLICY_C1(ECapabilityPowerMgmt), CPolicyServer::EFailClient},
+    };
+
+const CPolicyServer::TPolicy KMediaSyncServerPolicy =
+    {
+    CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass
+    KMediaSyncFunctionCodeRangeCount,
+    KMediaSyncFunctionCodeRanges,
+    KMediaSyncElementsIndex,     // what each range is compared to 
+    KMediaSyncPolicyElements     // what policies range is compared to
+    };
+
+
+/**
+Creates and executes a new CMTPServer instance.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMediaSyncServer::RunServerL()
+    {           
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    
+    TFileName lockFileName;
+    fs.PrivatePath(lockFileName);
+    TDriveUnit driveNum = RFs::GetSystemDrive();
+    lockFileName.Insert(0, driveNum.Name());
+    lockFileName.Append(KMssLockName);
+    
+    RFile lockFile;
+    CleanupClosePushL(lockFile);
+    TInt ret = KErrNone;
+    if (!BaflUtils::FileExists(fs, lockFileName))
+        {        
+        BaflUtils::EnsurePathExistsL(fs, lockFileName);
+        ret = lockFile.Create(fs, lockFileName, EFileShareExclusive|EFileWrite);
+        }
+    else
+        {
+        ret = lockFile.Open(fs, lockFileName, EFileShareExclusive|EFileWrite);
+        }
+    
+    if (ret == KErrNone)
+        {
+        // Naming the server thread after the server helps to debug panics
+        User::LeaveIfError(User::RenameProcess(KMediaSyncServerName));
+        
+        // Create and install the active scheduler.
+        CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
+        CleanupStack::PushL(scheduler);
+        CActiveScheduler::Install(scheduler);
+        
+        // Create the server and leave it on the cleanup stack.
+        CMediaSyncServer* server = CMediaSyncServer::NewLC(fs);
+        
+        // Initialisation complete, signal the client
+        RProcess::Rendezvous(KErrNone);
+        
+        // Execute the server.
+        CActiveScheduler::Start();
+
+        // Server shutting down. 
+        CleanupStack::PopAndDestroy(server);
+            
+        CleanupStack::PopAndDestroy(scheduler); // scheduler        
+        }
+    else
+        {
+        RProcess::Rendezvous(KErrNone);
+        }
+    
+    CleanupStack::PopAndDestroy(&lockFile);
+    CleanupStack::PopAndDestroy(&fs);    
+    }
+
+CMediaSyncServer* CMediaSyncServer::NewLC(RFs& aFs)
+    {
+    CMediaSyncServer* self = new (ELeave) CMediaSyncServer;
+    CleanupStack::PushL(self);
+    self->ConstructL(aFs);
+    return self;
+    }
+
+CMediaSyncServer::CMediaSyncServer() : 
+    CPolicyServer(CActive::EPriorityStandard, KMediaSyncServerPolicy)
+    {   
+    
+    }
+
+CMediaSyncServer::~CMediaSyncServer()
+    {
+    __FLOG(_L8("CMediaSyncServer::~CMediaSyncServer - Entry")); 
+    
+    delete iDb;
+    delete iObserver;    
+    
+    __FLOG(_L8("CMediaSyncServer::~CMediaSyncServer - Exit"));
+    __FLOG_CLOSE;
+    }
+
+void CMediaSyncServer::ConstructL(RFs& aFs)
+    {  
+    __FLOG_OPEN(KMSSSubsystem, KComponent);
+    __FLOG(_L8("CMediaSyncServer::ConstructL - Entry"));
+    
+    iDb = CMediaSyncDatabase::NewL(aFs);
+    iObserver = CMediaSyncObserver::NewL(iDb);
+    iNeedFullSync = iDb->IsMssDbCorrupt();
+    
+    StartL(KMediaSyncServerName);
+
+    __FLOG(_L8("CMediaSyncObserver::ConstructL - Exit"));    
+    }
+
+CSession2* CMediaSyncServer::NewSessionL(const TVersion&,const RMessage2&) const
+    {
+    __FLOG(_L8("CMediaSyncServer::NewSessionL - Entry"));
+    
+    CMediaSyncServer* ncThis = const_cast<CMediaSyncServer*>(this);
+    
+    __FLOG(_L8("CMediaSyncObserver::NewSessionL - Exit"));    
+    return new(ELeave) CMediaSyncServerSession(ncThis);
+    }
+
+CMediaSyncObserver* CMediaSyncServer::MediaSyncObserver() const
+    {
+    return iObserver;
+    }
+
+CMediaSyncDatabase* CMediaSyncServer::MediaSyncDatabase() const
+    {
+    return iDb;
+    }
+
+TBool CMediaSyncServer::NeedFullSync()
+    {
+    return iNeedFullSync;
+    }
+
+void CMediaSyncServer::ClearFullSyncFlag()
+    {
+    __FLOG(_L8("CMediaSyncServer::ClearFullSyncFlag - Entry"));
+    
+    iNeedFullSync = EFalse;
+    iDb->ClearMssDbCorrupt();
+    
+    __FLOG(_L8("CMediaSyncObserver::ClearFullSyncFlag - Exit"));    
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/src/cmediasyncserversession.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,198 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#include "cmediasyncserversession.h"
+#include "cmediasyncserver.h"
+#include "cmediasyncdatabase.h"
+#include "cmediasyncobserver.h"
+#include "cmediasyncdatawriter.h"
+
+__FLOG_STMT(_LIT8(KComponent,"MediaSyncServerSession");)
+
+const TInt KDefGlobalSharedHeapSize = 64 * 1024;//64K byte memory
+const TInt KReduceFactor  = 2; 
+const TInt KMaxRetryTimes = 3; 
+
+CMediaSyncServerSession::CMediaSyncServerSession(CMediaSyncServer* aServer) : 
+    iServer(aServer),
+    iAllocated(EFalse)
+    {
+    __FLOG_OPEN(KMSSSubsystem, KComponent);
+    __FLOG(_L8("CMediaSyncServerSession::CMediaSyncServerSession - Entry"));
+    __FLOG(_L8("CMediaSyncServerSession::CMediaSyncServerSession - Exit"));    
+    }
+    
+/**
+Destructor.
+*/
+CMediaSyncServerSession::~CMediaSyncServerSession()
+    {
+    __FLOG(_L8("CMediaSyncServerSession::~CMediaSyncServerSession - Entry"));
+    
+    if (iAllocated)
+        {
+        iGlobalSharedHeap.Close();
+        }
+    
+    __FLOG(_L8("CMediaSyncServerSession::~CMediaSyncServerSession - Exit"));
+    __FLOG_CLOSE;    
+    }
+
+// --------------------------------------------------------------------------
+// 
+// From CSession2, passes the request forward to DispatchMessageL.
+// --------------------------------------------------------------------------
+//
+void CMediaSyncServerSession::ServiceL(const RMessage2& aMessage)
+    {
+    __FLOG_VA((_L8("CMediaSyncServerSession::ServiceL - Function: %d"), aMessage.Function()));
+    
+    DispatchMessageL(aMessage);
+    }
+
+void CMediaSyncServerSession::DispatchMessageL(const RMessage2& aMessage)
+    {
+    __FLOG(_L8("CMediaSyncServerSession::DispatchMessageL - Entry"));
+       
+    switch( aMessage.Function() )
+        {
+        case EMediaSyncClientGetGSHHandle:
+            {
+            AllocateGlobalSharedHeapL(aMessage);            
+            aMessage.Complete(iGlobalSharedHeap);
+            }
+            break;
+            
+        case EMediaSyncClientGetChanges:
+            aMessage.Complete(GetChangesL(aMessage));
+            break;
+            
+        case EMediaSyncClientRemoveAllRecords:
+            {
+            iServer->MediaSyncDatabase()->RemoveAllNotificationsL();
+            iGlobalSharedHeap.Close();
+            iAllocated = EFalse;
+            aMessage.Complete(KErrNone);
+            }
+            break;
+            
+        case EMediaSyncClientEnableMonitor:
+            iServer->MediaSyncObserver()->SubscribeForChangeNotificationL();
+            aMessage.Complete(KErrNone);
+            break;
+            
+        case EMediaSyncClientDisableMonitor:
+            iServer->MediaSyncObserver()->UnsubscribeForChangeNotificationL();
+            aMessage.Complete(KErrNone);
+            break;
+            
+        case EMediaSyncClientNeedFullSync:
+            aMessage.Complete(GetFullSyncFlag(aMessage));
+            break;
+            
+        case EMediaSyncClientClearFullSync:
+            iServer->ClearFullSyncFlag();
+            aMessage.Complete(KErrNone);
+            break;
+            
+        case EMediaSyncClientShutdown:
+            CActiveScheduler::Stop();
+            aMessage.Complete(KErrNone);
+            break;
+            
+        default:
+            aMessage.Panic(KMediaSyncClientPanicCategory, EBadRequest);
+            break;
+        }
+
+    __FLOG(_L8("CMediaSyncServerSession::DispatchMessageL - Exit"));
+    }
+
+void CMediaSyncServerSession::AllocateGlobalSharedHeapL(const RMessage2& aMessage)
+    {
+    __FLOG(_L8("CMediaSyncServerSession::AllocateGlobalSharedHeapL - Entry"));
+    
+    if (!iAllocated)
+        {
+        TInt attemptedSize = aMessage.Int0();
+        if (attemptedSize > KDefGlobalSharedHeapSize || attemptedSize <= 0)
+            {
+            attemptedSize = KDefGlobalSharedHeapSize;
+            }
+        
+        TInt retryCount = KMaxRetryTimes;
+        TInt redFactor = KReduceFactor;    
+        TInt result = KErrNone;
+        
+        for (; retryCount > 0; retryCount--)
+            {
+            result = iGlobalSharedHeap.CreateGlobal(KNullDesC, attemptedSize, attemptedSize);
+            
+            if (result == KErrNone)
+                {
+                // We have succesfully allocated a GSH
+                break;
+                }
+            else
+                {
+                // Reduce the size of the GSH by a scale factor
+                attemptedSize = attemptedSize / redFactor;
+                }
+            }
+            
+        User::LeaveIfError(result); 
+        iAllocated = ETrue;
+        }
+    
+    __FLOG(_L8("CMediaSyncServerSession::AllocateGlobalSharedHeapL - Exit"));
+    }
+
+TInt CMediaSyncServerSession::GetChangesL(const RMessage2& aMessage)
+    {
+    __FLOG(_L8("CMediaSyncServerSession::GetChangesL - Entry"));
+
+    TInt maxFetchCount = aMessage.Int0();
+    CMediaSyncDataWriter* writer = CMediaSyncDataWriter::NewLC(iGlobalSharedHeap);
+    TBool finished = EFalse;
+    
+    iServer->MediaSyncDatabase()->FetchNotificationsL(*writer, maxFetchCount, finished);
+    TPtr8 finishPtr((TUint8*)&finished, sizeof(TBool), sizeof(TBool));
+    
+    aMessage.Write(1, finishPtr);
+    
+    CleanupStack::PopAndDestroy(writer);        
+    
+    __FLOG(_L8("CMediaSyncServerSession::GetChangesL - Exit"));
+    
+    return KErrNone;
+    }
+
+TInt CMediaSyncServerSession::GetFullSyncFlag(const RMessage2& aMessage)
+    {
+    __FLOG(_L8("CMediaSyncServerSession::GetFullSyncFlagL - Entry"));
+        
+    TBool needFullSync = iServer->NeedFullSync();
+    TPtr8 finishPtr((TUint8*)&needFullSync, sizeof(TBool), sizeof(TBool)); 
+    aMessage.Write(0, finishPtr);    
+    
+    __FLOG(_L8("CMediaSyncServerSession::GetFullSyncFlagL - Exit"));
+    
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/src/main.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,43 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <e32base.h>
+#include "cmediasyncserver.h"
+
+
+//  Global Functions
+/**
+Process entry point
+*/
+TInt E32Main()
+    {
+    // Create cleanup stack
+    __UHEAP_MARK;
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    TInt ret = KErrNoMemory;
+    if (cleanup)
+        {
+        // Run application code inside TRAP harness, wait keypress when terminated
+        TRAP(ret, CMediaSyncServer::RunServerL());
+        delete cleanup;
+        }    
+    __UHEAP_MARKEND;
+    return ret;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/mediasyncserver/src/rmediasyncserver.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,262 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <e32base.h>
+
+#include "rmediasyncserver.h"
+
+const TInt KDefGlobalSharedHeapSize = 64 * 1024;//64K byte memory
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+//
+EXPORT_C RMediaSyncServer::RMediaSyncServer() :
+    iHasSharedHeap(EFalse)
+    {
+    }
+
+EXPORT_C TInt RMediaSyncServer::Startup()
+    {
+    const TUidType serverUid(KNullUid, KNullUid, KMediaSyncServerUid3);
+    
+    // Create the server process.
+    RProcess server;
+    TInt err(server.Create(KMediaSyncServerName, KNullDesC, serverUid));
+  
+    // Loading failed.
+    if ( err != KErrNone )
+        {
+        return err;
+        }
+    
+    TRequestStatus status;
+    server.Rendezvous(status);
+
+    if (status != KRequestPending)
+        {
+        server.Kill(0);     // abort startup
+        server.Close();
+        return KErrGeneral;
+        }
+    else
+        {
+        server.Resume();    // Logon OK - start the server.
+        }
+        
+    User::WaitForRequest(status);
+    server.Close();
+    
+    return status.Int();    
+    }
+
+EXPORT_C void RMediaSyncServer::Shutdown()
+    {
+    SendReceive(EMediaSyncClientShutdown);
+    }
+
+EXPORT_C TInt RMediaSyncServer::Connect()
+    {      
+    TFindProcess findMdEServer(KFinderMSSName);
+    TFullName name;
+    TInt result = findMdEServer.Next(name);
+    if(result == KErrNotFound)
+        {
+        // Server is not running
+        result = Startup();
+        }
+    else if(KErrNone == result)
+        {
+        RProcess mss;
+        result = mss.Open(findMdEServer, EOwnerProcess);
+        if((result != KErrNone) && (mss.ExitReason() != KErrNone))
+            {
+            result = Startup();           
+            }
+        mss.Close();
+        }    
+    
+    if(KErrNone == result)
+        {
+        TVersion version(KMediaSyncServerVersionMajor, KMediaSyncServerVersionMinor, 0);
+        result = CreateSession( KMediaSyncServerName, version );
+        }
+ 
+	return result;
+    }
+
+EXPORT_C void RMediaSyncServer::Close()
+    {
+    RSessionBase::Close();
+    
+    if (iHasSharedHeap)
+        {
+        iGlobalSharedHeap.Close();
+        iHasSharedHeap = EFalse;
+        }    
+    }
+
+EXPORT_C TInt RMediaSyncServer::NeedFullSync(TBool& aNeedFullSync)
+    {
+    TPtr8 finishPtr((TUint8*)&aNeedFullSync, sizeof(TBool), sizeof(TBool));
+    
+    TIpcArgs args;    
+    args.Set(0, &finishPtr);
+    
+    return SendReceive(EMediaSyncClientNeedFullSync, args);
+    }
+
+EXPORT_C TInt RMediaSyncServer::ClearFullSync()
+    {
+    return SendReceive(EMediaSyncClientClearFullSync);    
+    }
+
+EXPORT_C void RMediaSyncServer::GetChangesL(CMediaSyncDataReader*& aDataReader, TBool& aIsFinished, TRequestStatus& aStatus, TInt aMaxFetchCount)
+    {
+    if (!iHasSharedHeap)
+        {
+        User::LeaveIfError(GetGlobalSharedHeapHandle());
+        iHasSharedHeap = ETrue;
+        }
+    
+    TPtr8 finishPtr((TUint8*)&aIsFinished, sizeof(TBool), sizeof(TBool));
+    
+    TIpcArgs args;
+    args.Set(0, aMaxFetchCount);       
+    args.Set(1, &finishPtr);
+    
+    TInt ret = SendReceive(EMediaSyncClientGetChanges, args);    
+    User::LeaveIfError(ret);
+    
+    aDataReader = CMediaSyncDataReader::NewL(iGlobalSharedHeap);
+    
+    TRequestStatus* pClient = &aStatus;
+    User::RequestComplete(pClient, ret);   
+    }
+
+EXPORT_C void RMediaSyncServer::RemoveAllRecords()
+    {
+    SendReceive(EMediaSyncClientRemoveAllRecords);
+    RelaseGlobalSharedHeap();
+    return;
+    }
+
+EXPORT_C TInt RMediaSyncServer::EnableMonitor()
+    {
+    return SendReceive(EMediaSyncClientEnableMonitor);
+    }
+
+EXPORT_C TInt RMediaSyncServer::DisableMonitor()
+    {
+    return SendReceive(EMediaSyncClientDisableMonitor);
+    }
+
+TInt RMediaSyncServer::GetGlobalSharedHeapHandle()
+    {
+    TIpcArgs args;
+    args.Set(0, KDefGlobalSharedHeapSize);    
+    
+    TInt ret = SendReceive(EMediaSyncClientGetGSHHandle, args);    
+    ret = iGlobalSharedHeap.SetReturnedHandle(ret);
+    
+    return ret;    
+    }
+
+void RMediaSyncServer::RelaseGlobalSharedHeap()
+    {
+    iGlobalSharedHeap.Close();
+    iHasSharedHeap = EFalse;
+    }
+
+CMediaSyncDataReader* CMediaSyncDataReader::NewL(const RChunk& aChunk)
+    {
+    CMediaSyncDataReader* self = new(ELeave) CMediaSyncDataReader();
+    CleanupStack::PushL(self);    
+    self->ConstructL(aChunk);  
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+EXPORT_C CMediaSyncDataReader::~CMediaSyncDataReader()
+    {
+    
+    }
+
+CMediaSyncDataReader::CMediaSyncDataReader() :
+    iOffset(0),
+    iCurrentIdx(0)
+    {
+    
+    }
+
+void CMediaSyncDataReader::ConstructL(const RChunk& aChunk)
+    {
+    TUint8* base = aChunk.Base();
+    User::LeaveIfNull(base);
+    
+    iHeaderInfo = reinterpret_cast<TDataHeaderInfo*>(base);
+    iReadBase   = base + sizeof(TDataHeaderInfo);
+    }
+
+EXPORT_C TInt CMediaSyncDataReader::Count()
+    {
+    return iHeaderInfo->iCount;
+    }
+
+EXPORT_C TBool CMediaSyncDataReader::HasNext()
+    {
+    return (iCurrentIdx < iHeaderInfo->iCount);
+    }
+
+EXPORT_C void CMediaSyncDataReader::GetNextL(TUint32& aObjectId, TUint8& aType, TPtr16& aUri)
+    {
+    if (iCurrentIdx < iHeaderInfo->iCount)
+        {
+        //read object id
+        Mem::Copy(&aObjectId, (iReadBase + iOffset), sizeof(TUint32));
+        iOffset += sizeof(TUint32);
+        
+        //read notification type
+        Mem::Copy(&aType, (iReadBase + iOffset), sizeof(TUint8));
+        iOffset += sizeof(TUint8);
+        
+        //read uri length
+        TUint8 uriLen = 0;
+        Mem::Copy(&uriLen, (iReadBase + iOffset), sizeof(TUint8));
+        iOffset += sizeof(TUint8);
+        if (uriLen > 0)
+            {
+            //read uri content
+            TUint16* ptr = (TUint16*)(iReadBase + iOffset);
+            aUri.Set(ptr, uriLen, uriLen);
+            iOffset += (uriLen * sizeof(TUint16));
+            }
+        else
+            {
+            aUri.Set(NULL, 0, 0);
+            }
+        
+        ++iCurrentIdx;        
+        }
+    else
+        {
+        User::Leave(KErrOverflow);
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,658 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#include <e32cmn.h>
+#include <centralrepository.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/cmtpstoragemetadata.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpconnection.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpdataproviderapitypes.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/tmtptypeevent.h>
+
+#include "cmtpimagedp.h"
+#include "mtpimagedpconst.h"
+#include "mtpimagedppanic.h"
+#include "cmtprequestprocessor.h"
+#include "mtpimagedprequestprocessor.h"
+#include "cmtpimagedpthumbnailcreator.h"
+#include "mtpimagedputilits.h"
+#include "cmtpimagedpmdeobserver.h"
+#include "cmtpimagedprenameobject.h"
+
+__FLOG_STMT(_LIT8(KComponent,"CMTPImageDataProvider");)
+
+static const TInt KArrayGranularity = 3;
+static const TInt KDeleteObjectGranularity = 2;
+
+//used by hashmap & hashset class
+LOCAL_C TUint32 TBuf16Hash(const TBuf<KMaxExtNameLength>& aPtr)
+    {
+    return DefaultHash::Des16(aPtr);
+    }
+
+LOCAL_C TBool TBuf16Ident(const TBuf<KMaxExtNameLength>& aL, const TBuf<KMaxExtNameLength>& aR)
+    {
+    return DefaultIdentity::Des16(aL, aR);
+    }
+
+/**
+ Image data provider factory method.
+ @return A pointer to a Image data provider object. Ownership is transfered.
+ @leave One of the system wide error codes, if a processing failure occurs.
+*/
+TAny* CMTPImageDataProvider::NewL(TAny* aParams)
+    {
+    CMTPImageDataProvider* self = new (ELeave) CMTPImageDataProvider(aParams);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+ Standard C++ constructor
+ 
+ @param aParams  pointer to MMTPDataProviderFramework
+*/
+CMTPImageDataProvider::CMTPImageDataProvider(TAny* aParams) :
+    CMTPDataProviderPlugin(aParams),
+    iActiveProcessors(KArrayGranularity),
+    iFormatMappings(&TBuf16Hash, &TBuf16Ident),
+    iActiveProcessor(-1),
+    iEnumerated(EFalse),
+	iDeleteObjectsArray(KDeleteObjectGranularity)
+    {
+    }
+
+/**
+Second-phase construction
+*/
+void CMTPImageDataProvider::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8(">> CMTPImageDataProvider::ConstructL"));
+    
+    iPropertyMgr = CMTPImageDpObjectPropertyMgr::NewL(Framework());
+    iThumbnailManager = CMTPImageDpThumbnailCreator::NewL();
+    iMdeObserver = CMTPImageDpMdeObserver::NewL(Framework(), *this);
+    iMdeObserver->SubscribeForChangeNotificationL();
+    
+    //Setup central repository connection
+    const TUint32 KUidMTPImageRepositoryValue(0x2001FCA2);
+    const TUid KUidMTPImageRepository = {KUidMTPImageRepositoryValue};
+    iRepository = CRepository::NewL(KUidMTPImageRepository);    
+    
+    //Initialize hash map of extention to format code
+    TInt count(sizeof(KMTPValidCodeExtensionMappings) / sizeof(KMTPValidCodeExtensionMappings[0]));
+    for(TInt i(0); i<count; i++)
+        {
+        iFormatMappings.Insert(KMTPValidCodeExtensionMappings[i].iExtension, KMTPValidCodeExtensionMappings[i].iFormatCode);
+        }    
+    
+    //Define RProperty of new pictures for status data provider
+    _LIT_SECURITY_POLICY_PASS(KAllowReadAll);
+    TInt error = RProperty::Define(TUid::Uid(KMTPServerUID), KMTPNewPicKey, RProperty::EInt, KAllowReadAll, KAllowReadAll);
+    if (error != KErrNone && error != KErrAlreadyExists)
+        {
+        __FLOG_1(_L8("CMTPImageDataProvider::ConstructL - RProperty define error:%d"), error);
+        User::LeaveIfError(error);
+        }    
+    
+    __FLOG(_L8("<< CMTPImageDataProvider::ConstructL"));
+    }
+
+/**
+ Destructor
+*/
+CMTPImageDataProvider::~CMTPImageDataProvider()
+    {
+    __FLOG(_L8(">> ~CMTPImageDataProvider"));      
+    
+    // delete all processor instances
+    TUint count(iActiveProcessors.Count());
+    while (count--)
+        {
+        iActiveProcessors[count]->Release();
+        }
+    iActiveProcessors.Close();
+     
+    // image dp unsubscribe from MDS
+    if(iMdeObserver)
+        {
+        TRAP_IGNORE(iMdeObserver->UnsubscribeForChangeNotificationL());
+        delete iMdeObserver;
+        }        
+    delete iThumbnailManager;
+    delete iPropertyMgr;       
+    delete iRepository;   
+    delete iRenameObject;
+    
+    iFormatMappings.Close();
+    
+    //Try to delete objects in array
+    HandleDeleteObjectsArray();
+    iDeleteObjectsArray.ResetAndDestroy();
+    
+    __FLOG(_L8("<< ~CMTPImageDataProvider"));
+    __FLOG_CLOSE;
+    }
+
+void CMTPImageDataProvider::Cancel()
+    {
+    __FLOG(_L8(">> Cancel"));
+    __FLOG(_L8("<< Cancel"));
+    }
+
+/**
+ Process the event from initiator
+ 
+ @param aEvent       The event to be processed
+ @param aConnection  The connection from which the event comes
+*/
+void CMTPImageDataProvider::ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection)
+    {
+    __FLOG(_L8(">> ProcessEventL"));
+    
+    //Try to delete objects in array
+    HandleDeleteObjectsArray();
+    
+    TInt idx(LocateRequestProcessorL(aEvent, aConnection));
+    
+    if (idx != KErrNotFound)
+        {
+        iActiveProcessors[idx]->HandleEventL(aEvent);
+        }
+
+    __FLOG(_L8("<< ProcessEventL"));
+    }
+
+/**
+Process the notification from framework
+@param aNotification  The notification to be processed
+@param aParams        Notification parmenter
+*/
+void CMTPImageDataProvider::ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams)
+    {
+    __FLOG(_L8(">> ProcessNotificationL"));
+
+    switch (aNotification)
+        {
+    case EMTPSessionClosed:
+        SessionClosedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams));
+        break;
+        
+    case EMTPSessionOpened:
+        SessionOpenedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams));
+        break;
+        
+    case EMTPRenameObject:
+        RenameObjectL(*reinterpret_cast<const TMTPNotificationParamsHandle*>(aParams));
+        break;
+        
+    default:
+        // Ignore all other notifications.
+        break;
+        }
+ 
+    __FLOG(_L8("<< ProcessNotificationL"));
+    }
+
+/**
+ Process the request from initiator
+ 
+ @param aPhase       The request transaction phase
+ @param aRequest     The request to be processed
+ @param aConnection  The connection from which the request comes
+*/   
+void CMTPImageDataProvider::ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {    
+    __FLOG(_L8(">> ProcessRequestPhaseL"));    
+    
+    //Try to handle objects which need to be deleted
+    HandleDeleteObjectsArray();
+    
+    TInt idx(LocateRequestProcessorL(aRequest, aConnection));
+    __ASSERT_DEBUG((idx != KErrNotFound), Panic(EMTPImageDpNoMatchingProcessor));
+    MMTPRequestProcessor* processor(iActiveProcessors[idx]);
+    iActiveProcessor = idx;
+    iActiveProcessorRemoved = EFalse;    
+    TBool result(processor->HandleRequestL(aRequest, aPhase));
+    if (iActiveProcessorRemoved)
+        {
+        processor->Release(); // destroy the processor
+        }    
+    else if (result)    //destroy the processor
+        {
+        processor->Release();
+        iActiveProcessors.Remove(idx);
+        }
+ 
+    iActiveProcessor = -1;
+    __FLOG(_L8("<< ProcessRequestPhaseL"));
+    }
+
+/**
+ Starts the enumeration of the image dp
+*/
+void CMTPImageDataProvider::StartObjectEnumerationL(TUint32 aStorageId, TBool /*aPersistentFullEnumeration*/)
+    {
+    __FLOG(_L8(">> StartObjectEnumerationL"));
+    
+    if (aStorageId == KMTPStorageAll)
+        {
+        /*
+         * Query previous image object count for calculation of new pictures when MTP startup
+         * 
+         */
+        iPrePictures = QueryImageObjectCountL();
+        iEnumerated = ETrue;
+        __FLOG_1(_L16("CMTPImageDpEnumerator::CompleteEnumeration - Previous Pics: %d"), iPrePictures);
+        }
+
+    NotifyEnumerationCompleteL(aStorageId, KErrNone);
+    
+    __FLOG(_L8("<< StartObjectEnumerationL"));
+    }
+
+
+/**
+Starts enumerate imagedp storage, just declare complete
+*/
+void CMTPImageDataProvider::StartStorageEnumerationL()
+    {
+    __FLOG(_L8(">> StartStorageEnumerationL"));   
+    NotifyStorageEnumerationCompleteL();
+    __FLOG(_L8("<< StartStorageEnumerationL"));        
+    }
+
+/**
+Defines the supported operations and formats of the data provider
+
+@param aCategory Defines what MTP is quering the DP about
+@param aArray Supported() edits array to append supported features
+*/
+void CMTPImageDataProvider::Supported(TMTPSupportCategory aCategory, RArray<TUint>& aArray) const
+    {
+    __FLOG(_L8(">> Supported"));
+
+    switch (aCategory) 
+        {        
+    case EEvents:
+        {
+        TInt count(sizeof(KMTPImageDpSupportedEvents) / sizeof(KMTPImageDpSupportedEvents[0]));
+        for (TInt i(0); (i < count); i++)
+            {
+            aArray.Append(KMTPImageDpSupportedEvents[i]);
+            __FLOG_VA((_L("   CMTPImageDataProvider::Supported Events %d added"), KMTPImageDpSupportedEvents[i]));
+            }  
+        }
+        break;
+    case EObjectPlaybackFormats: // formats that can be placed on the device
+	/*intentional fall through*/ 
+    case EObjectCaptureFormats: // formats the device generates
+        {
+        TInt count(sizeof(KMTPValidCodeExtensionMappings) / sizeof(KMTPValidCodeExtensionMappings[0]));
+        for(TInt i(0); (i < count); i++)
+            {
+            __FLOG_VA((_L("   CMTPImageDataProvider::Supported we have formatCode %d"), KMTPValidCodeExtensionMappings[i].iFormatCode ));
+            if(aArray.Find(KMTPValidCodeExtensionMappings[i].iFormatCode)==KErrNotFound) // KMTPValidCodeExtensionMappings may contain format code more than once
+                {
+                aArray.Append(KMTPValidCodeExtensionMappings[i].iFormatCode);
+                __FLOG_VA((_L("   CMTPImageDataProvider::Supported formatCode %d added"), KMTPValidCodeExtensionMappings[i].iFormatCode));
+                }
+            }
+        }
+        break;
+    case EObjectProperties:
+        {
+        TInt count(sizeof(KMTPImageDpSupportedProperties) / sizeof(KMTPImageDpSupportedProperties[0]));
+        for (TInt i(0); (i < count); i++)
+            {
+            aArray.Append(KMTPImageDpSupportedProperties[i]);
+            __FLOG_VA((_L("   CMTPImageDataProvider::Supported property %d added"), KMTPImageDpSupportedProperties[i]));
+            }   
+        }
+        break; 
+
+    case EOperations:
+        {
+        TInt count(sizeof(KMTPImageDpSupportedOperations) / sizeof(KMTPImageDpSupportedOperations[0]));
+        for (TInt i(0); (i < count); i++)
+            {
+            aArray.Append(KMTPImageDpSupportedOperations[i]);
+            __FLOG_VA((_L("   CMTPImageDataProvider::Supported operation %d added"), KMTPImageDpSupportedOperations[i]));
+            }   
+        }
+        break;  
+
+    case EStorageSystemTypes:
+        aArray.Append(CMTPStorageMetaData::ESystemTypeDefaultFileSystem);
+        break; 
+
+    default:    
+        // Unrecognised category, leave aArray unmodified.
+        break;
+        }
+
+    __FLOG(_L8("<< Supported"));
+    }
+
+/**
+Defines the supported vendor extension info of the data provider
+
+@param aCategory Defines what MTP is quering the DP about
+@param aStrings Supported() edits array to append supported vendor info
+*/
+void CMTPImageDataProvider::SupportedL(TMTPSupportCategory aCategory, CDesCArray& aStrings) const
+    {
+    switch (aCategory) 
+        {
+    case EFolderExclusionSets:
+        {
+        //do nothing
+        }
+        break;
+        
+    case EFormatExtensionSets:
+        {
+        _LIT(KFormatExtensionJpg, "0x3801:jpg::3");//3 means file dp will enumerate all image files instead of image dp.
+        aStrings.AppendL(KFormatExtensionJpg);
+        _LIT(KFormatExtensionJpe, "0x3801:jpe::3");
+        aStrings.AppendL(KFormatExtensionJpe);
+        _LIT(KFormatExtensionJpeg, "0x3801:jpeg::3");
+        aStrings.AppendL(KFormatExtensionJpeg);   
+        }
+        break;
+        
+    default:
+        // Unrecognised category, leave aArray unmodified.
+        break;
+        }
+    }
+
+/**
+Notify framework the image dp has completed enumeration
+*/
+void CMTPImageDataProvider::NotifyStorageEnumerationCompleteL()
+    {
+    __FLOG(_L8(">> NotifyStorageEnumerationCompleteL"));    
+    Framework().StorageEnumerationCompleteL();    
+    __FLOG(_L8("<< NotifyStorageEnumerationCompleteL"));        
+    }
+
+CMTPImageDpThumbnailCreator& CMTPImageDataProvider::ThumbnailManager() const
+	{
+    __ASSERT_DEBUG(iThumbnailManager, User::Invariant());
+	return *iThumbnailManager;
+	}
+
+CMTPImageDpObjectPropertyMgr& CMTPImageDataProvider::PropertyMgr()const
+	{
+	__ASSERT_DEBUG(iPropertyMgr, User::Invariant());
+	return *iPropertyMgr;	
+	}
+
+CRepository& CMTPImageDataProvider::Repository() const
+    {
+    __ASSERT_DEBUG(iRepository, User::Invariant());
+    return *iRepository;
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+#ifdef __FLOG_ACTIVE  
+void CMTPImageDataProvider::NotifyEnumerationCompleteL(TUint32 aStorageId, TInt aError)
+#else
+void CMTPImageDataProvider::NotifyEnumerationCompleteL(TUint32 aStorageId, TInt /*aError*/)
+#endif // __FLOG_ACTIVE
+    {
+    __FLOG(_L8(">> NotifyEnumerationCompletedL"));
+    __FLOG_VA((_L8("Enumeration of storage 0x%08X completed with error status %d"), aStorageId, aError));
+        
+    Framework().ObjectEnumerationCompleteL(aStorageId);
+    
+    __FLOG(_L8("<< HandleEnumerationCompletedL"));
+    }
+
+/**
+Find or create a request processor that can process the request
+
+@param aRequest    The request to be processed
+@param aConnection The connection from which the request comes
+
+@return the index of the found/created request processor
+*/
+TInt CMTPImageDataProvider::LocateRequestProcessorL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {
+    __FLOG(_L8(">> LocateRequestProcessorL"));        
+    
+    TInt idx(KErrNotFound);
+    TInt count(iActiveProcessors.Count());
+    for (TInt i(0); (i < count); i++)
+        {
+        if (iActiveProcessors[i]->Match(aRequest, aConnection))
+            {
+            idx = i;
+            break;
+            }
+        }
+        
+    if (idx == KErrNotFound)
+        {
+        MMTPRequestProcessor* processor = MTPImageDpProcessor::CreateL(Framework(), aRequest, aConnection,*this);
+        CleanupReleasePushL(*processor);
+        iActiveProcessors.AppendL(processor);
+        CleanupStack::Pop();
+        idx = count;
+        }
+ 
+    __FLOG(_L8("<< LocateRequestProcessorL"));
+    return idx;
+    }
+
+/**
+Find or create a request processor that can process the event
+
+@param aEvent    The event to be processed
+@param aConnection The connection from which the request comes
+
+@return the index of the found/created request processor
+*/
+TInt CMTPImageDataProvider::LocateRequestProcessorL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection)
+    {
+    __FLOG(_L8(">> LocateRequestProcessorL"));
+        
+    TInt idx(KErrNotFound);
+    TInt count(iActiveProcessors.Count());
+    for (TInt i(0); (i < count); i++)
+        {
+        if (iActiveProcessors[i]->Match(aEvent, aConnection))
+            {
+            idx = i;
+            break;
+            }
+        }    
+
+    __FLOG(_L8("<< LocateRequestProcessorL"));
+    return idx;
+    }
+
+/**
+ Notify the data provider that the session has been closed
+
+ @param aSessionId    The session Id closed
+ @param aConnection   The connection of the sesssion
+*/
+void CMTPImageDataProvider::SessionClosedL(const TMTPNotificationParamsSessionChange& aSession)
+    {
+    __FLOG_VA((_L8(">> SessionClosedL SessionID = %d"), aSession.iMTPId));
+    
+    TInt count = iActiveProcessors.Count();
+    while(count--)
+        {
+        MMTPRequestProcessor* processor = iActiveProcessors[count];
+        TUint32 sessionId = processor->SessionId();
+        if((sessionId == aSession.iMTPId) && (processor->Connection().ConnectionId() == aSession.iConnection.ConnectionId()))
+            {
+            iActiveProcessors.Remove(count);
+            if (count == iActiveProcessor)
+                {
+                iActiveProcessorRemoved = ETrue;
+                }
+            else
+                {
+                processor->Release();
+                }
+            }
+        }
+    
+    __FLOG(_L8("<< SessionClosedL"));
+    }
+
+/**
+ Notify the data provider that the session opened
+ 
+ @param aSessionId    The session Id opened
+ @param aConnection   The connection of the sesssion
+*/
+#ifdef __FLOG_ACTIVE
+void CMTPImageDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession)
+#else
+void CMTPImageDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& /*aSession*/)
+#endif
+    {
+    __FLOG_VA((_L8(">> SessionOpenedL SessionID = %d"), aSession.iMTPId));
+    
+    if (iEnumerated)
+        {
+        /**
+         * Get image object count from framework and calculate the new pictures
+         */
+        TUint curPictures = QueryImageObjectCountL();
+        TInt  newPictures = curPictures - iPrePictures;
+        
+        __FLOG_2(_L16("CMTPImageDpEnumerator::CompleteEnumeration - Previous Pics:%d, New Pics: %d"), iPrePictures, newPictures);
+        if (newPictures >= 0)
+            {
+            MTPImageDpUtilits::UpdateNewPicturesValue(*this, newPictures, ETrue);  
+            }
+        else
+            {
+            MTPImageDpUtilits::UpdateNewPicturesValue(*this, 0, ETrue);  
+            }
+        
+        iEnumerated = EFalse;
+        }
+    
+    __FLOG(_L8("<< SessionOpenedL "));
+    }
+
+/**
+ Notify the data provider that the folder name has been changed
+ 
+ @param aParam   The Rename notification
+*/
+void CMTPImageDataProvider::RenameObjectL(const TMTPNotificationParamsHandle& aParam)
+    {
+    __FLOG_VA((_L16(">> RenameObjectL Handle: %u, Old name: %S"), aParam.iHandleId, &aParam.iFileName));
+    
+    if (!iRenameObject)
+        {
+        iRenameObject = CMTPImageDpRenameObject::NewL(Framework(), *this);
+        }
+
+    iRenameObject->StartL(aParam.iHandleId, aParam.iFileName);    
+    
+    __FLOG(_L8("<< RenameObjectL "));
+    }
+
+/**
+ Find format code according to its extension name 
+*/
+TMTPFormatCode CMTPImageDataProvider::FindFormatL(const TDesC& aExtension)
+    {
+    TMTPFormatCode* ret = iFormatMappings.Find(aExtension);
+    User::LeaveIfNull(ret);
+    
+    return *ret;
+    }
+
+/**
+ Query image object count from current framework 
+*/
+TUint CMTPImageDataProvider::QueryImageObjectCountL()
+    { 
+    TMTPObjectMgrQueryParams params(KMTPStorageAll, EMTPFormatCodeEXIFJPEG, KMTPHandleNone);    
+    return Framework().ObjectMgr().CountL(params);
+    }
+
+TBool CMTPImageDataProvider::GetCacheParentHandle(const TDesC& aParentPath, TUint32& aParentHandle)
+    {
+    TBool ret = EFalse;
+    
+    if (iParentCache.iPath.Compare(aParentPath) == 0)
+        {
+        aParentHandle = iParentCache.iHandle;
+        ret = ETrue;
+        }
+    else
+        {
+        aParentHandle = KMTPHandleNone;
+        }
+    
+    return ret;
+    }
+
+void CMTPImageDataProvider::SetCacheParentHandle(const TDesC& aParentPath, TUint32 aParentHandle)
+    {
+    iParentCache.iPath.Copy(aParentPath);
+    iParentCache.iHandle = aParentHandle;
+    }
+
+void CMTPImageDataProvider::AppendDeleteObjectsArrayL(const TDesC& aSuid)
+    {
+    iDeleteObjectsArray.AppendL(aSuid.AllocLC());
+    CleanupStack::Pop();
+    }
+
+void CMTPImageDataProvider::HandleDeleteObjectsArray()
+    {
+    for ( TInt i = 0; i < iDeleteObjectsArray.Count(); i++ )
+        {
+        HBufC* object = iDeleteObjectsArray[i];
+        TInt err = Framework().Fs().Delete(object->Des());
+        __FLOG_2(_L8("delete left objects %d error code is %d \n"), i, err );
+        
+        if ( err == KErrNone )
+            {
+            iDeleteObjectsArray.Remove(i);
+            --i;
+            delete object;
+            object = NULL;
+            }
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpcopyobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,332 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#include <f32file.h>
+#include <bautils.h>
+#include <pathinfo.h> // PathInfo
+#include <sysutil.h>
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/cmtptypestring.h>
+
+#include "cmtpimagedpcopyobject.h"
+#include "mtpimagedppanic.h"
+#include "mtpimagedputilits.h"
+#include "cmtpimagedp.h"
+
+__FLOG_STMT(_LIT8(KComponent,"CopyObject");)
+
+const TInt RollbackFuncCnt = 1;
+
+/**
+Verification data for the CopyObject request
+*/
+const TMTPRequestElementInfo KMTPCopyObjectPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter2, EMTPElementTypeStorageId, EMTPElementAttrWrite, 0, 0, 0},
+        {TMTPTypeRequest::ERequestParameter3, EMTPElementTypeObjectHandle, EMTPElementAttrDir | EMTPElementAttrWrite, 1, 0, 0}
+    };
+    
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/     
+MMTPRequestProcessor* CMTPImageDpCopyObject::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider)
+    {
+    CMTPImageDpCopyObject* self = new (ELeave) CMTPImageDpCopyObject(aFramework, aConnection,aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+    
+/**
+Destructor
+*/	
+CMTPImageDpCopyObject::~CMTPImageDpCopyObject()
+    {	
+    __FLOG(_L8(">> CMTPImageDpCopyObject::~CMTPImageDpCopyObject"));
+    delete iDest;
+    delete iFileMan;
+    delete iSrcObjectInfo;
+    delete iTargetObjectInfo;
+    iRollbackActionL.Close();
+    __FLOG(_L8("<< CMTPImageDpCopyObject::~CMTPImageDpCopyObject"));
+    __FLOG_CLOSE;
+    
+    }
+    
+/**
+Standard c++ constructor
+*/	
+CMTPImageDpCopyObject::CMTPImageDpCopyObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider) :
+    CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPCopyObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPCopyObjectPolicy),
+    iDataProvider(aDataProvider)
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    }
+    
+/**
+Second phase constructor
+*/
+void CMTPImageDpCopyObject::ConstructL()
+    {
+    __FLOG(_L8(">> CMTPImageDpCopyObject::ConstructL"));
+    iFileMan = CFileMan::NewL(iFramework.Fs());
+    iSrcObjectInfo = CMTPObjectMetaData::NewL();
+    iRollbackActionL.ReserveL(RollbackFuncCnt);
+    __FLOG(_L8("<< CMTPImageDpCopyObject::ConstructL"));
+    }
+
+TMTPResponseCode CMTPImageDpCopyObject::CheckRequestL()
+    {
+    __FLOG(_L8(">> CMTPImageDpCopyObject::CheckRequestL"));
+    TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+    if (EMTPRespCodeOK == responseCode)
+        {
+        TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+        // Check whether object handle is valid
+        responseCode = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, objectHandle, *iSrcObjectInfo);
+        }
+    else if(EMTPRespCodeInvalidObjectHandle == responseCode) //we only check the parent handle
+        {
+        responseCode = EMTPRespCodeInvalidParentObject;
+        }
+    
+    __FLOG_VA((_L8("CheckRequestL - Exit with responseCode = 0x%04X"), responseCode));
+    __FLOG(_L8("<< CMTPImageDpCopyObject::CheckRequestL"));
+    return responseCode;
+    }
+
+/**
+CopyObject request handler
+*/      
+void CMTPImageDpCopyObject::ServiceL()
+    {   
+    __FLOG(_L8(">> CMTPImageDpCopyObject::ServiceL"));
+    TUint32 handle = KMTPHandleNone;
+    TMTPResponseCode responseCode = CopyObjectL(handle);
+    if(responseCode == EMTPRespCodeOK)
+        {
+        SendResponseL(EMTPRespCodeOK, 1, &handle);
+        }
+    else
+        {
+        SendResponseL(responseCode);
+        }
+    __FLOG(_L8("<< CMTPImageDpCopyObject::ServiceL"));
+    }
+    
+/**
+Copy object operation
+@return the object handle of the resulting object.
+*/
+TMTPResponseCode CMTPImageDpCopyObject::CopyObjectL(TUint32& aNewHandle)
+    {
+    __FLOG(_L8(">> CMTPImageDpCopyObject::CopyObjectL"));
+    TMTPResponseCode responseCode = EMTPRespCodeOK;
+    aNewHandle = KMTPHandleNone;
+    
+    GetParametersL();
+    
+    iNewFileName.Append(*iDest);
+    const TDesC& oldFileName = iSrcObjectInfo->DesC(CMTPObjectMetaData::ESuid);
+    TParsePtrC fileNameParser(oldFileName);
+    
+    if((iNewFileName.Length() + fileNameParser.NameAndExt().Length()) <= iNewFileName.MaxLength())
+        {
+        iNewFileName.Append(fileNameParser.NameAndExt());
+        responseCode = CanCopyObjectL(oldFileName, iNewFileName);	
+        }
+    else
+        {
+        responseCode = EMTPRespCodeGeneralError;
+        }
+        
+    
+    if(responseCode == EMTPRespCodeOK)
+        {
+        aNewHandle = CopyFileL(oldFileName, iNewFileName);
+        }
+    __FLOG(_L8("<< CMTPImageDpCopyObject::CopyObjectL"));
+    return responseCode;
+    }
+
+/**
+A helper function of CopyObjectL.
+@param aNewFileName the new full filename after copy.
+@return objectHandle of new copy of object.
+*/
+TUint32 CMTPImageDpCopyObject::CopyFileL(const TDesC& aOldFileName, const TDesC& aNewFileName)
+    {
+    __FLOG(_L8(">> CMTPImageDpCopyObject::CopyFileL"));
+    TCleanupItem anItem(FailRecover, reinterpret_cast<TAny*>(this));
+    CleanupStack::PushL(anItem);
+    
+    GetPreviousPropertiesL(aOldFileName);
+    User::LeaveIfError(iFileMan->Copy(aOldFileName, *iDest));
+    iRollbackActionL.Append(RollBackFromFsL);
+    SetPreviousPropertiesL(aNewFileName);
+    
+    iFramework.ObjectMgr().InsertObjectL(*iTargetObjectInfo);
+    __FLOG(_L8("<< CMTPImageDpCopyObject::CopyFileL"));
+    CleanupStack::Pop(this);
+    return iTargetObjectInfo->Uint(CMTPObjectMetaData::EHandle);
+    }
+
+/**
+Retrieve the parameters of the request
+*/	
+void CMTPImageDpCopyObject::GetParametersL()
+    {
+    __FLOG(_L8(">> CMTPImageDpCopyObject::GetParametersL"));
+    __ASSERT_DEBUG(iRequestChecker, Panic(EMTPImageDpRequestCheckNull));
+    
+    TUint32 objectHandle  = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+    TUint32 parentObjectHandle  = Request().Uint32(TMTPTypeRequest::ERequestParameter3);       
+    
+    if(parentObjectHandle == 0)
+        {
+        SetDefaultParentObjectL();
+        }
+    else	
+        {
+        CMTPObjectMetaData* parentObjectInfo = iRequestChecker->GetObjectInfo(parentObjectHandle);
+        __ASSERT_DEBUG(parentObjectInfo, Panic(EMTPImageDpObjectNull));
+        delete iDest;
+        iDest = NULL;
+        iDest = parentObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocL();        
+        iNewParentHandle = parentObjectHandle;
+        }
+    __FLOG(_L8("<< CMTPImageDpCopyObject::GetParametersL"));	
+    }
+    
+/**
+Get a default parent object, ff the request does not specify a parent object, 
+*/
+void CMTPImageDpCopyObject::SetDefaultParentObjectL()
+    {
+    __FLOG(_L8(">> CMTPImageDpCopyObject::SetDefaultParentObjectL"));
+    TDriveNumber drive(static_cast<TDriveNumber>(iFramework.StorageMgr().DriveNumber(iStorageId)));
+    User::LeaveIfError(drive);
+    TChar driveLetter;
+    iFramework.Fs().DriveToChar(drive, driveLetter);
+    TFileName driveBuf;
+    driveBuf.Append(driveLetter);
+    driveBuf = BaflUtils::RootFolderPath(driveBuf.Left(1));
+    delete iDest;
+    iDest = NULL;
+    iDest = driveBuf.AllocL();
+    iNewParentHandle = KMTPHandleNoParent;
+    __FLOG(_L8("<< CMTPImageDpCopyObject::SetDefaultParentObjectL"));
+    }
+    
+/**
+Check if we can copy the file to the new location
+*/
+TMTPResponseCode CMTPImageDpCopyObject::CanCopyObjectL(const TDesC& aOldName, const TDesC& aNewName) const
+    {
+    __FLOG(_L8(">> CMTPImageDpCopyObject::CanCopyObjectL"));
+    TMTPResponseCode result = EMTPRespCodeOK;
+    
+    TEntry fileEntry;
+    User::LeaveIfError(iFramework.Fs().Entry(aOldName, fileEntry));
+    TDriveNumber drive(static_cast<TDriveNumber>(iFramework.StorageMgr().DriveNumber(iStorageId)));
+    User::LeaveIfError(drive);
+    TVolumeInfo volumeInfo;
+    User::LeaveIfError(iFramework.Fs().Volume(volumeInfo, drive));
+    
+    if(volumeInfo.iFree < fileEntry.iSize)
+        {
+        result = EMTPRespCodeStoreFull;
+        }
+    else if (BaflUtils::FileExists(iFramework.Fs(), aNewName))			
+        {
+        result = EMTPRespCodeInvalidParentObject;
+        }
+    __FLOG_VA((_L8("CanCopyObjectL - Exit with response code 0x%04X"), result));
+    __FLOG(_L8("<< CMTPImageDpCopyObject::CanCopyObjectL"));  	
+    return result;	
+    }
+    
+/**
+Save the object properties before doing the copy
+*/
+void CMTPImageDpCopyObject::GetPreviousPropertiesL(const TDesC& aOldFileName)
+    {
+    __FLOG(_L8("GetPreviousPropertiesL - Entry"));
+    User::LeaveIfError(iFramework.Fs().Modified(aOldFileName, iDateModified));
+    __FLOG(_L8("GetPreviousPropertiesL - Exit"));
+    }
+    
+/**
+Set the object properties after doing the copy
+*/
+void CMTPImageDpCopyObject::SetPreviousPropertiesL(const TDesC& aNewFileName)
+    {
+    __FLOG(_L8("SetPreviousPropertiesL - Entry"));        
+    User::LeaveIfError(iFramework.Fs().SetModified(aNewFileName, iDateModified));
+    
+    iTargetObjectInfo = CMTPObjectMetaData::NewL();
+    iTargetObjectInfo->SetUint(CMTPObjectMetaData::EDataProviderId, iSrcObjectInfo->Uint(CMTPObjectMetaData::EDataProviderId));
+    iTargetObjectInfo->SetUint(CMTPObjectMetaData::EFormatCode, iSrcObjectInfo->Uint(CMTPObjectMetaData::EFormatCode));
+    iTargetObjectInfo->SetDesCL(CMTPObjectMetaData::EName, iSrcObjectInfo->DesC(CMTPObjectMetaData::EName));
+    iTargetObjectInfo->SetUint(CMTPObjectMetaData::ENonConsumable, iSrcObjectInfo->Uint(CMTPObjectMetaData::ENonConsumable));
+    iTargetObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle);
+    iTargetObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
+    iTargetObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, aNewFileName);
+    __FLOG(_L8("SetPreviousPropertiesL - Exit"));
+    }
+
+void CMTPImageDpCopyObject::FailRecover(TAny* aCopyOperation)
+    {
+    reinterpret_cast<CMTPImageDpCopyObject*>(aCopyOperation)->RollBack();
+    }
+
+void CMTPImageDpCopyObject::RollBack()
+    {
+    TInt i = iRollbackActionL.Count();
+    while(-- i >= 0)
+        {
+        TRAP_IGNORE((*iRollbackActionL[i])(this));
+        }
+    iRollbackActionL.Reset();
+    }
+
+void CMTPImageDpCopyObject::RollBackFromFsL()
+    {
+    User::LeaveIfError(iFramework.Fs().Delete(iNewFileName));
+    }
+
+void CMTPImageDpCopyObject::RollBackFromFsL(CMTPImageDpCopyObject* aObject)
+    {
+    aObject->RollBackFromFsL();
+    }
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpdeleteobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,292 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+ */
+#include <bautils.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/tmtptyperequest.h>
+#include "cmtpimagedpdeleteobject.h"
+#include "mtpimagedpconst.h"
+#include "mtpimagedppanic.h"
+#include "cmtpimagedpobjectpropertymgr.h"
+#include "mtpimagedputilits.h"
+#include "cmtpimagedp.h"
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"ImageDeleteObject");)
+/**
+ Standard c++ constructor
+ */
+CMTPImageDpDeleteObject::CMTPImageDpDeleteObject(
+        MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,
+        CMTPImageDataProvider& aDataProvider) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
+    iDataProvider(aDataProvider),
+    iResponseCode( EMTPRespCodeOK )
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8(">> CMTPImageDpDeleteObject"));
+    __FLOG(_L8("<< CMTPImageDpDeleteObject"));
+    }
+
+/**
+ Two-phase construction method
+ @param aFramework	The data provider framework
+ @param aConnection	The connection from which the request comes
+ @return a pointer to the created request processor object
+ */
+MMTPRequestProcessor* CMTPImageDpDeleteObject::NewL(
+        MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,
+        CMTPImageDataProvider& aDataProvider)
+    {
+    CMTPImageDpDeleteObject* self = new (ELeave) CMTPImageDpDeleteObject(
+            aFramework, aConnection, aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+void CMTPImageDpDeleteObject::ConstructL()
+    {
+    __FLOG(_L8(">> CMTPImageDpDeleteObject::ConstructL"));
+    iObjectMeta = CMTPObjectMetaData::NewL();
+    __FLOG(_L8("<< CMTPImageDpDeleteObject::ConstructL"));
+    }
+/**
+ Destructor
+ */
+CMTPImageDpDeleteObject::~CMTPImageDpDeleteObject()
+    {
+    __FLOG(_L8("~CMTPImageDpDeleteObject - Entry"));
+    Cancel();
+    delete iObjectMeta;
+    iObjectsToDelete.Close();
+    __FLOG(_L8("~CMTPImageDpDeleteObject - Exit"));
+    __FLOG_CLOSE;
+    }
+
+/**
+ Verify the request
+ @return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
+ */
+
+TMTPResponseCode CMTPImageDpDeleteObject::CheckRequestL()
+    {
+    __FLOG(_L8(">> CMTPImageDpDeleteObject::CheckRequestL"));
+    TMTPResponseCode result = EMTPRespCodeOK;
+    TUint32 handle(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
+    if ( handle != KMTPHandleAll )
+        {
+        result = CheckStorageL( handle );
+        }
+    __FLOG(_L8("<< CMTPImageDpDeleteObject::CheckRequestL"));
+    return result;
+    }
+
+/**
+ DeleteObject request handler
+ */
+void CMTPImageDpDeleteObject::ServiceL()
+    {
+    __FLOG(_L8(">> CMTPImageDpDeleteObject::ServiceL"));
+    
+    //begin to find object
+    iObjectsToDelete.Reset();
+    iResponseCode = EMTPRespCodeOK;
+    iObjectsNotDelete = 0;
+    TUint32 objectHandle( Request().Uint32( TMTPTypeRequest::ERequestParameter1 ));
+    TUint32 formatCode( Request().Uint32( TMTPTypeRequest::ERequestParameter2 ));
+    
+    // Check to see whether the request is to delete all images or a specific image
+    if ( objectHandle == KMTPHandleAll )
+        {
+        //add for test
+        __FLOG(_L8("delete all objects"));
+        GetObjectHandlesL( KMTPStorageAll, formatCode, KMTPHandleNone );
+        iObjectsNotDelete = iObjectsToDelete.Count();
+        StartL();
+        }
+    else
+        {
+        //add for test
+        __FLOG(_L8("delete only one object"));
+        iObjectsNotDelete = 1;
+        DeleteObjectL( objectHandle );
+        
+        SendResponseL();
+        }
+    
+    __FLOG(_L8("<< CMTPImageDpDeleteObject::ServiceL"));
+    }
+
+void CMTPImageDpDeleteObject::RunL()
+    {
+    __FLOG(_L8(">> CMTPImageDpDeleteObject::RunL"));
+    
+    TInt numObjectsToDelete = iObjectsToDelete.Count();
+    
+    if ( numObjectsToDelete > 0 )
+        {
+        DeleteObjectL( iObjectsToDelete[0] );
+        iObjectsToDelete.Remove( 0 );
+        }
+    
+    // Start the process again to read the next row...
+    StartL();
+    
+    __FLOG(_L8("<< CMTPImageDpDeleteObject::RunL"));
+    }
+
+void CMTPImageDpDeleteObject::DoCancel()
+    {
+    __FLOG(_L8(">> CMTPImageDpDeleteObject::DoCancel"));
+    
+    TRAP_IGNORE( SendResponseL());
+    
+    __FLOG(_L8("<< CMTPImageDpDeleteObject::DoCancel"));
+    }
+
+/**
+ Check whether the store on which the object resides is read only.
+ @return ETrue if the store is read only, EFalse if read-write
+ */
+TMTPResponseCode CMTPImageDpDeleteObject::CheckStorageL(TUint32 aObjectHandle)
+    {
+    __FLOG(_L8(">> CMTPImageDpDeleteObject::CheckStorageL"));
+    TMTPResponseCode result = MTPImageDpUtilits::VerifyObjectHandleL(
+            iFramework, aObjectHandle, *iObjectMeta);
+    if (EMTPRespCodeOK == result)
+        {
+        TDriveNumber drive= static_cast<TDriveNumber>(iFramework.StorageMgr().DriveNumber(
+                                                      iObjectMeta->Uint(CMTPObjectMetaData::EStorageId)));
+        User::LeaveIfError(drive);
+        TVolumeInfo volumeInfo;
+        User::LeaveIfError(iFramework.Fs().Volume(volumeInfo, drive));
+        if (volumeInfo.iDrive.iMediaAtt == KMediaAttWriteProtected)
+            {
+            result = EMTPRespCodeStoreReadOnly;
+            }
+        }
+    __FLOG(_L8("<< CMTPImageDpDeleteObject::CheckStorageL"));
+    return result;
+    }
+
+void CMTPImageDpDeleteObject::GetObjectHandlesL( TUint32 aStorageId, TUint32 aFormatCode, TUint32 aParentHandle )
+    {
+    __FLOG(_L8(">> CMTPImageDpDeleteObject::GetObjectHandlesL"));
+    
+    RMTPObjectMgrQueryContext context;
+    RArray<TUint> handles;
+    TMTPObjectMgrQueryParams params( aStorageId, aFormatCode, aParentHandle, iFramework.DataProviderId());
+    CleanupClosePushL( context ); // + context
+    CleanupClosePushL( handles ); // + handles
+    
+    do
+        {
+        iFramework.ObjectMgr().GetObjectHandlesL( params, context, handles );
+        for ( TInt i = 0; i < handles.Count(); i++)
+            {
+            iObjectsToDelete.Append( handles[i] );
+            }
+        }
+    while ( !context.QueryComplete() );
+    
+    CleanupStack::PopAndDestroy( &handles ); // - handles
+    CleanupStack::PopAndDestroy( &context ); // - context
+    
+    __FLOG(_L8("<< CMTPImageDpDeleteObject::GetObjectHandlesL"));
+    }
+
+void CMTPImageDpDeleteObject::DeleteObjectL( TUint32 aHandle )
+    {
+    __FLOG(_L8(">> CMTPImageDpDeleteObject::DeleteObjectL"));
+    
+    iFramework.ObjectMgr().ObjectL( aHandle, *iObjectMeta);
+    iDataProvider.PropertyMgr().SetCurrentObjectL(*iObjectMeta, EFalse);
+    TUint16 protectionStatus = EMTPProtectionNoProtection;
+    iDataProvider.PropertyMgr().GetPropertyL(EMTPObjectPropCodeProtectionStatus, protectionStatus);
+    if(EMTPProtectionNoProtection == protectionStatus)
+        {
+        TInt err = iFramework.Fs().Delete(iObjectMeta->DesC(CMTPObjectMetaData::ESuid));
+        __FLOG_1(_L8("delete file error is %d"), err );
+        switch ( err )
+            {
+            case KErrInUse:
+            case KErrAccessDenied:
+                //add for test 
+                __FLOG_1(_L8("err:%d"), err);
+                //add Suid to deleteobjectlist
+                iDataProvider.AppendDeleteObjectsArrayL(iObjectMeta->DesC(CMTPObjectMetaData::ESuid));
+            case KErrNone:
+                //add for test
+                __FLOG(_L8("KErrNone"));
+                iFramework.ObjectMgr().RemoveObjectL( iObjectMeta->Uint(CMTPObjectMetaData::EHandle ));
+                iObjectsNotDelete--;
+                iResponseCode = EMTPRespCodePartialDeletion;
+                break;
+            default:
+                //add for test
+                __FLOG(_L8("default"));
+                User::LeaveIfError( err );
+                break;
+            }
+        }
+    else if ( iResponseCode != EMTPRespCodePartialDeletion )
+        {
+        iResponseCode = EMTPRespCodeObjectWriteProtected;
+        }
+    __FLOG(_L8("<< CMTPImageDpDeleteObject::DeleteObjectL"));
+    }
+
+void CMTPImageDpDeleteObject::StartL()
+    {
+    __FLOG(_L8(">> CMTPImageDpDeleteObject::StartL"));
+    
+    TInt numObjectsToDelete = iObjectsToDelete.Count();
+
+    if ( numObjectsToDelete > 0 )
+        {
+        //Set the active object going to delete the file
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, KErrNone );
+        SetActive();
+        }
+    else
+        {
+        SendResponseL();
+        }
+    __FLOG(_L8("<< CMTPImageDpDeleteObject::StartL"));
+    }
+
+void CMTPImageDpDeleteObject::SendResponseL()
+    {
+    __FLOG(_L8(">> CMTPImageDpDeleteObject::SendResponseL"));
+    
+    if ( iResponseCode == EMTPRespCodePartialDeletion && iObjectsNotDelete == 0 )
+        {
+        iResponseCode = EMTPRespCodeOK;
+        }
+    CMTPRequestProcessor::SendResponseL( iResponseCode );
+    
+    __FLOG(_L8("<< CMTPImageDpDeleteObject::SendResponseL"));
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,148 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <f32file.h>
+#include <centralrepository.h>
+
+#include <mtp/cmtptypefile.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpimagedpgetobject.h"
+#include "mtpimagedppanic.h"
+#include "cmtpimagedp.h"
+#include "mtpimagedpconst.h"
+#include "mtpimagedputilits.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"ImageDpGetObject");)
+
+/**
+Verification data for the GetNumObjects request
+*/
+const TMTPRequestElementInfo KMTPGetObjectPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrFile, 0, 0, 0}
+    };
+
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/     
+MMTPRequestProcessor* CMTPImageDpGetObject::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider)
+    {
+    CMTPImageDpGetObject* self = new (ELeave) CMTPImageDpGetObject(aFramework, aConnection, aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/	
+CMTPImageDpGetObject::~CMTPImageDpGetObject()
+    {
+    __FLOG(_L8(">> ~CMTPImageDpGetObject"));
+    delete iFileObject;
+    __FLOG(_L8("<< ~CMTPImageDpGetObject"));
+    __FLOG_CLOSE;
+    }
+	
+/**
+Standard c++ constructor
+*/	
+CMTPImageDpGetObject::CMTPImageDpGetObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider) : 
+    CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetObjectPolicy), 
+    iDataProvider(aDataProvider)
+    {
+    
+    }
+
+/**
+Second-phase constructor.
+*/        
+void CMTPImageDpGetObject::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8(">> CMTPImageDpGetObject::ConstructL"));   
+    __FLOG(_L8("<< CMTPImageDpGetObject::ConstructL"));
+    }
+
+/**
+GetObject request handler
+*/		
+void CMTPImageDpGetObject::ServiceL()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObject::ServiceL"));
+    
+    TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    //does not take ownership    
+    CMTPObjectMetaData* objectInfo = iRequestChecker->GetObjectInfo(objectHandle);
+    __ASSERT_DEBUG(objectInfo, Panic(EMTPImageDpObjectNull));
+    
+    BuildFileObjectL(objectInfo->DesC(CMTPObjectMetaData::ESuid));
+    SendDataL(*iFileObject);
+    __FLOG(_L8("<< CMTPImageDpGetObject::ServiceL"));
+    }
+		
+
+/**
+Build the file object data set for the file requested
+@param aFileName	The file name of the requested object
+*/
+void CMTPImageDpGetObject::BuildFileObjectL(const TDesC& aFileName)
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObject::BuildFileObjectL"));
+    delete iFileObject;
+    iFileObject = NULL;
+    iFileObject = CMTPTypeFile::NewL(iFramework.Fs(), aFileName, EFileShareReadersOnly);
+    __FLOG(_L8("<< CMTPImageDpGetObject::BuildFileObjectL"));
+    }
+
+TBool CMTPImageDpGetObject::DoHandleCompletingPhaseL()
+    {
+    __FLOG(_L8(" CMTPImageDpGetObject::DoHandleResponsePhaseL - Entry"));        
+    TInt currentNewPics = 0;
+    iDataProvider.Repository().Get(ENewImagesCount, currentNewPics);
+    if (currentNewPics != 0)
+        {
+        /**
+		Zero the new pictures of RProperty.
+		Because we think the end-use has import all pictures as long as MTP receive one getobject operation
+
+        There are two different phases to collect new pictures:
+		1. In enumeration phase, calculate new pictures value from MSS in one go.
+		2. After enumeration phase, dynamically calculate new pictures value from MdS by Notifications
+		*/
+        iDataProvider.Repository().Set(ENewImagesCount, 0);
+        RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, 0);        
+        }    
+    
+    __FLOG(_L8("CMTPImageDpGetObject::DoHandleResponsePhaseL - Exit"));
+    return CMTPRequestProcessor::DoHandleCompletingPhaseL();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,238 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtptypeobjectinfo.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypestring.h>
+
+#include "cmtpimagedpgetobjectinfo.h"
+#include "cmtpimagedpobjectpropertymgr.h"
+#include "mtpimagedpconst.h"
+#include "mtpimagedppanic.h"
+#include "cmtpimagedp.h"
+#include "mtpimagedputilits.h"
+
+__FLOG_STMT(_LIT8(KComponent,"CMTPImageDpGetObjectInfo");)
+
+/**
+Two-phase construction method
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/    
+MMTPRequestProcessor* CMTPImageDpGetObjectInfo::NewL(MMTPDataProviderFramework& aFramework,											
+                                            MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider)
+    {
+    CMTPImageDpGetObjectInfo* self = new (ELeave) CMTPImageDpGetObjectInfo(aFramework, aConnection,aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+    
+/**
+Destructor
+*/	
+CMTPImageDpGetObjectInfo::~CMTPImageDpGetObjectInfo()
+    {
+    __FLOG(_L8(">> ~CMTPImageDpGetObjectInfo"));
+    delete iObjectInfoToBuild;
+    delete iObjectMeta;
+    __FLOG(_L8("<< ~CMTPImageDpGetObjectInfo"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Standard c++ constructor
+*/	
+CMTPImageDpGetObjectInfo::CMTPImageDpGetObjectInfo(MMTPDataProviderFramework& aFramework,
+                                    MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider) : 
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
+    iObjectPropertyMgr(aDataProvider.PropertyMgr())
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("CMTPImageDpGetObjectInfo::CMTPImageDpGetObjectInfo"));
+    }
+
+TMTPResponseCode CMTPImageDpGetObjectInfo::CheckRequestL()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObject::CheckRequestL"));
+    TMTPResponseCode result = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, Request().Uint32(TMTPTypeRequest::ERequestParameter1), *iObjectMeta);
+    __FLOG(_L8("<< CMTPImageDpGetObject::CheckRequestL"));
+    return result;
+    }
+    
+/**
+GetObjectInfo request handler
+*/		
+void CMTPImageDpGetObjectInfo::ServiceL()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectInfo::ServiceL"));
+    BuildObjectInfoL();
+    SendDataL(*iObjectInfoToBuild);	
+    __FLOG(_L8("<< CMTPImageDpGetObjectInfo::ServiceL"));
+    }
+    
+/**
+Second-phase construction
+*/		
+void CMTPImageDpGetObjectInfo::ConstructL()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectInfo::ConstructL"));
+    iObjectInfoToBuild = CMTPTypeObjectInfo::NewL();
+    iObjectMeta = CMTPObjectMetaData::NewL();
+    __FLOG(_L8("<< CMTPImageDpGetObjectInfo::ConstructL"));
+    }
+    
+/**
+Populate the object info dataset
+*/		
+void CMTPImageDpGetObjectInfo::BuildObjectInfoL()	
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectInfo::BuildObjectInfoL"));
+    iObjectPropertyMgr.SetCurrentObjectL(*iObjectMeta, EFalse);
+    
+    //1. storage id
+    TUint32 storageId;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeStorageID, storageId);
+    iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EStorageID, storageId);	
+    
+    //2. object format
+    TUint16 format;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeObjectFormat, format);
+    iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EObjectFormat, format);
+    
+    //3. protection status,
+    TUint16 protection;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeProtectionStatus, protection);
+    iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EProtectionStatus, protection);
+    
+    //4. object compressed size
+    // see SetFileSizeDateL
+    
+    //5. thumb format	
+    //6. thumb compressed size
+    //7. thumb pix width
+    //8, thumb pix height
+    //9. image pix width
+    //10. image pix height
+    //11. image bit depth
+    TUint16 thumbFormat;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleFormat, thumbFormat);
+    iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EThumbFormat, thumbFormat);
+    TUint32 value;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleSize, value);
+    iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EThumbCompressedSize, value);
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleWidth, value);
+    iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EThumbPixWidth, value);
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleHeight, value);
+    iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EThumbPixHeight, value);
+    
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeWidth, value);
+    iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EImagePixWidth, value);
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeHeight, value);
+    iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EImagePixHeight, value);
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeImageBitDepth, value);
+    iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EImageBitDepth, value);
+    
+    //12. Parent object
+    TUint32 parent;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeParentObject, parent);
+    if(KMTPHandleNoParent == parent)
+        {
+        parent = KMTPHandleNone;
+        }
+    iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EParentObject, parent);
+        
+    //13 and 14. Association type and description
+    iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EAssociationType, 0);
+    iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EAssociationDescription, 0);
+        
+    //15. sequence number
+    //TUint32 sequenceNum;
+    //iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeAssociationDesc, sequenceNum);
+    iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::ESequenceNumber, 0);
+    
+    //16. file name
+    SetFileNameL();
+    
+    //4, compressed size, 17 Date created, and 18 Date modified
+    SetFileSizeDateL();
+    
+    //18. keyword
+    SetKeywordL();
+    __FLOG(_L8("<< CMTPImageDpGetObjectInfo::BuildObjectInfoL"));
+    }
+/**
+Set the file name of the current object in the data set
+@param aObjectInfo The object info of the current object
+*/	
+void CMTPImageDpGetObjectInfo::SetFileNameL()
+    {
+    //use the name without full path specification
+    __FLOG(_L8(">> CMTPImageDpGetObjectInfo::SetFileNameL"));
+    CMTPTypeString* fileName = CMTPTypeString::NewLC();
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeObjectFileName, *fileName);
+    iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EFilename, fileName->StringChars());
+    CleanupStack::PopAndDestroy(fileName);
+    __FLOG(_L8("<< CMTPImageDpGetObjectInfo::SetFileNameL"));
+    }
+    
+/**
+Set the file size and modified/created date in the data set
+@param aObjectInfo The object info of the current object
+*/	
+void CMTPImageDpGetObjectInfo::SetFileSizeDateL()
+    {
+    //file size
+    __FLOG(_L8(">> CMTPImageDpGetObjectInfo::SetFileSizeDateL"));
+    TUint64 fileSize;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeObjectSize, fileSize);
+    TUint32 shortFileSize = (fileSize > KMaxTUint32) ? KMaxTUint32 : static_cast<TUint32>(fileSize);
+    iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EObjectCompressedSize, shortFileSize);
+    
+    //file modified time
+    CMTPTypeString* dateString = CMTPTypeString::NewLC();
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeDateModified, *dateString);
+    iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EDateModified, dateString->StringChars());
+    
+    CMTPTypeString* createdString = CMTPTypeString::NewLC();
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeDateCreated, *createdString);
+    iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EDateCreated, createdString->StringChars());	
+    
+    CleanupStack::PopAndDestroy(2); // createdString, dateString
+    __FLOG(_L8("<< CMTPImageDpGetObjectInfo::SetFileSizeDateL"));
+    }
+    
+/**
+Set the keyword of the current object in the data set
+@param aObjectInfo The object info of the current object
+*/	
+void CMTPImageDpGetObjectInfo::SetKeywordL()
+    {
+    //empty keyword
+    __FLOG(_L8(">> CMTPImageDpGetObjectInfo::SetKeywordL"));
+    iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EKeywords, KNullDesC);
+    __FLOG(_L8("<< CMTPImageDpGetObjectInfo::SetKeywordL"));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectpropdesc.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,434 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <f32file.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtptypeobjectpropdesc.h>
+#include <mtp/cmtptypestring.h>
+
+#include "mtpdpconst.h"
+#include "cmtpimagedpgetobjectpropdesc.h"
+#include "mtpimagedpconst.h"
+#include "mtpimagedppanic.h"
+#include "cmtpimagedp.h"
+
+__FLOG_STMT(_LIT8(KComponent,"GetObjectPropDesc");)
+
+_LIT(KMtpObjDescObjFileName, "[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 7}\\.[[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 2}]?");
+
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+MMTPRequestProcessor* CMTPImageDpGetObjectPropDesc::NewL(
+                                            MMTPDataProviderFramework& aFramework,
+                                            MMTPConnection& aConnection,CMTPImageDataProvider& /*aDataProvider*/)
+    {
+    CMTPImageDpGetObjectPropDesc* self = new (ELeave) CMTPImageDpGetObjectPropDesc(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+
+    }
+
+/**
+Destructor
+*/		
+CMTPImageDpGetObjectPropDesc::~CMTPImageDpGetObjectPropDesc()
+    {	
+    __FLOG(_L8(">> ~CMTPImageDpGetObjectPropDesc"));
+    __FLOG(_L8(">> CMTPImageDpCopyObject::~CMTPImageDpCopyObject"));
+    delete iObjectProperty;
+    __FLOG(_L8("<< ~CMTPImageDpGetObjectPropDesc"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Standard c++ constructor
+*/	
+CMTPImageDpGetObjectPropDesc::CMTPImageDpGetObjectPropDesc(
+                                    MMTPDataProviderFramework& aFramework,
+                                    MMTPConnection& aConnection)
+    :CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    }
+
+/**
+check property code
+*/
+TMTPResponseCode CMTPImageDpGetObjectPropDesc::CheckRequestL()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectPropDesc::CheckRequestL"));
+    TMTPResponseCode response = CMTPRequestProcessor::CheckRequestL(); 
+    TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    TUint32 formatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+
+    const TInt count = sizeof(KMTPImageDpSupportedProperties) / sizeof(TUint16);
+    TInt i = 0;
+    for(i = 0; i < count; i++)
+        {
+        if(KMTPImageDpSupportedProperties[i] == propCode)
+            {
+            break;
+            }
+        }
+    if(i == count)
+        {
+        response = EMTPRespCodeInvalidObjectPropCode;
+        }
+
+    __FLOG(_L8("<< CMTPImageDpGetObjectPropDesc::CheckRequestL"));
+    return response;	
+    }
+
+    
+/**
+GetObjectPropDesc request handler
+*/	
+void CMTPImageDpGetObjectPropDesc::ServiceL()
+    {
+    delete iObjectProperty;
+    iObjectProperty = NULL;	
+    
+    TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    __FLOG_VA((_L8(">> CMTPImageDpGetObjectPropDesc::ServiceL propcode %d"), propCode));	    
+    switch(propCode)
+        {
+        case EMTPObjectPropCodeStorageID:
+            ServiceStorageIdL();
+            break;
+        case EMTPObjectPropCodeObjectFormat:
+            ServiceObjectFormatL();
+            break;
+        case EMTPObjectPropCodeProtectionStatus:
+            ServiceProtectionStatusL();
+            break;
+        case EMTPObjectPropCodeObjectSize:
+            ServiceObjectSizeL();
+            break;
+        case EMTPObjectPropCodeObjectFileName:
+            ServiceFileNameL();
+            break;
+        case EMTPObjectPropCodeDateCreated:
+            ServiceDateCreatedL();
+            break;
+        case EMTPObjectPropCodeDateModified:
+            ServiceDateModifiedL();
+            break;
+        case EMTPObjectPropCodeParentObject:
+            ServiceParentObjectL();
+            break;
+        case EMTPObjectPropCodePersistentUniqueObjectIdentifier:
+            ServicePuidL();
+            break;
+        case EMTPObjectPropCodeName:
+            ServiceNameL();
+            break;
+        case EMTPObjectPropCodeWidth:
+            ServiceWidthL();
+            break;
+       case EMTPObjectPropCodeHeight:
+            ServiceHeightL();
+            break;
+        case EMTPObjectPropCodeImageBitDepth:
+            ServiceImageBitDepthL();
+            break;
+        case EMTPObjectPropCodeRepresentativeSampleFormat:
+            ServiceRepresentativeSampleFormatL();
+            break;
+        case EMTPObjectPropCodeRepresentativeSampleSize:
+            ServiceRepresentativeSampleSizeL();
+            break;
+        case EMTPObjectPropCodeRepresentativeSampleHeight:
+            ServiceRepresentativeSampleHeightL();
+            break;
+        case EMTPObjectPropCodeRepresentativeSampleWidth:
+            ServiceRepresentativeSampleWidthL();
+            break;
+        case EMTPObjectPropCodeNonConsumable:
+            ServiceNonConsumableL();
+            break;            
+        default:
+            {
+            //Leave 
+            User::Leave(KErrGeneral);
+            }
+            break;
+        }
+
+    __ASSERT_DEBUG(iObjectProperty, Panic(EMTPImageDpObjectPropertyNull));
+    
+    iObjectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(propCode));
+    SendDataL(*iObjectProperty);
+
+    __FLOG(_L8("<< CMTPImageDpGetObjectPropDesc::ServiceL"));
+    }
+
+
+/**
+Second-phase construction
+*/			
+void CMTPImageDpGetObjectPropDesc::ConstructL()
+    {	    
+    }
+        
+
+void CMTPImageDpGetObjectPropDesc::ServiceStorageIdL()
+    {
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeStorageID);	
+    }
+    
+void CMTPImageDpGetObjectPropDesc::ServiceObjectFormatL()
+    {	
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectFormat);	
+    }
+    
+void CMTPImageDpGetObjectPropDesc::ServiceProtectionStatusL()
+    {
+    CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT16);
+    CleanupStack::PushL(expectedForm);
+    //Currently, we only support EMTPProtectionNoProtection and EMTPProtectionReadOnly
+//  TUint16 values[] = {EMTPProtectionNoProtection, EMTPProtectionReadOnly, EMTPProtectionReadOnlyData, EMTPProtectionNonTransferable};
+    TUint16 values[] = {EMTPProtectionNoProtection, EMTPProtectionReadOnly};
+    TUint   numValues((sizeof(values) / sizeof(values[0])));
+    for (TUint i = 0; i < numValues; i++)
+        {
+        TMTPTypeUint16 data(values[i]);
+        expectedForm->AppendSupportedValueL(data);
+        }  
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeProtectionStatus, *expectedForm);      	
+    CleanupStack::PopAndDestroy(expectedForm);
+    }
+    
+void CMTPImageDpGetObjectPropDesc::ServiceObjectSizeL()
+    {
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectSize);	
+    }
+    
+void CMTPImageDpGetObjectPropDesc::ServiceFileNameL()
+    {
+    CMTPTypeString* form = CMTPTypeString::NewLC( KMtpObjDescObjFileName );
+    // Althrough iObjectProperty is released in ServiceL(), release it here maybe a more safer way.
+    if ( iObjectProperty != NULL )
+	    {
+	    delete iObjectProperty;
+	    iObjectProperty = NULL;
+	    }
+
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectFileName, CMTPTypeObjectPropDesc::ERegularExpressionForm, form);
+
+    CleanupStack::PopAndDestroy( form );
+    }
+
+void CMTPImageDpGetObjectPropDesc::ServiceDateCreatedL()
+    {
+    CMTPTypeObjectPropDesc::TPropertyInfo info;
+    info.iDataType     = EMTPTypeString;
+    info.iFormFlag     = CMTPTypeObjectPropDesc::EDateTimeForm;
+    info.iGetSet       = CMTPTypeObjectPropDesc::EReadOnly;
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeDateCreated, info, NULL);
+    }
+    
+void CMTPImageDpGetObjectPropDesc::ServiceDateModifiedL()
+    {
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeDateModified);
+    }
+    
+void CMTPImageDpGetObjectPropDesc::ServiceParentObjectL()
+    {
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeParentObject);
+    }
+    
+void CMTPImageDpGetObjectPropDesc::ServicePuidL()
+    {
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodePersistentUniqueObjectIdentifier);
+    }
+    
+void CMTPImageDpGetObjectPropDesc::ServiceNameL()
+    {
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeName);	
+    }
+    
+void CMTPImageDpGetObjectPropDesc::ServiceWidthL()
+    {    
+    CMTPTypeObjectPropDesc::TPropertyInfo info;
+    info.iDataType     = EMTPTypeUINT32;
+    info.iFormFlag     = CMTPTypeObjectPropDesc::ERangeForm;
+    info.iGetSet       = CMTPTypeObjectPropDesc::EReadOnly;
+   
+    CMTPTypeObjectPropDescRangeForm* expectedForm = CMTPTypeObjectPropDescRangeForm::NewLC(EMTPTypeUINT32);
+
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EMinimumValue, 0x00000001);
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EMaximumValue, 0x20000000);
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EStepSize, 0x00000001);
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeWidth, info, expectedForm);
+    CleanupStack::PopAndDestroy(expectedForm);
+    }
+
+void CMTPImageDpGetObjectPropDesc::ServiceHeightL()
+    {
+    CMTPTypeObjectPropDesc::TPropertyInfo info;
+    info.iDataType     = EMTPTypeUINT32;
+    info.iFormFlag     = CMTPTypeObjectPropDesc::ERangeForm;
+    info.iGetSet       = CMTPTypeObjectPropDesc::EReadOnly;
+    
+    CMTPTypeObjectPropDescRangeForm* expectedForm = CMTPTypeObjectPropDescRangeForm::NewLC(EMTPTypeUINT32);
+
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EMinimumValue, 0x00000001);
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EMaximumValue, 0x20000000);
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EStepSize, 0x00000001);
+    
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeHeight, info, expectedForm);
+    
+    CleanupStack::PopAndDestroy(expectedForm);    
+    }
+
+void CMTPImageDpGetObjectPropDesc::ServiceImageBitDepthL()
+    {
+    CMTPTypeObjectPropDesc::TPropertyInfo info;
+    info.iDataType     = EMTPTypeUINT32;
+    info.iFormFlag     = CMTPTypeObjectPropDesc::ERangeForm;
+    info.iGetSet       = CMTPTypeObjectPropDesc::EReadOnly;
+    
+    CMTPTypeObjectPropDescRangeForm* expectedForm = CMTPTypeObjectPropDescRangeForm::NewLC(EMTPTypeUINT32);
+
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EMinimumValue, 0x00000001);
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EMaximumValue, 0x20000000);
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EStepSize, 0x00000001);
+    
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeImageBitDepth, info, expectedForm);
+    
+    CleanupStack::PopAndDestroy(expectedForm); 
+    
+    //to do: deine the Group code
+    //iObjectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, 1);
+    }
+
+void CMTPImageDpGetObjectPropDesc::ServiceRepresentativeSampleFormatL()
+    {
+    CMTPTypeObjectPropDesc::TPropertyInfo info;
+    info.iDataType     = EMTPTypeUINT16;
+    info.iFormFlag     = CMTPTypeObjectPropDesc::EEnumerationForm;
+    info.iGetSet       = CMTPTypeObjectPropDesc::EReadOnly;
+    
+    CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT16);
+    CleanupStack::PushL(expectedForm);
+    TUint16 values[] = {EMTPFormatCodeEXIFJPEG};
+    TUint   numValues((sizeof(values) / sizeof(values[0])));
+    for (TUint i = 0; i < numValues; i++)
+        {
+        TMTPTypeUint16 data(values[i]);
+        expectedForm->AppendSupportedValueL(data);
+        }  
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeRepresentativeSampleFormat, info, expectedForm);
+    
+    CleanupStack::PopAndDestroy(expectedForm);
+    }
+
+void CMTPImageDpGetObjectPropDesc::ServiceRepresentativeSampleSizeL()
+    {
+    CMTPTypeObjectPropDesc::TPropertyInfo info;
+    info.iDataType     = EMTPTypeUINT32;
+    info.iFormFlag     = CMTPTypeObjectPropDesc::ERangeForm;
+    info.iGetSet       = CMTPTypeObjectPropDesc::EReadOnly;
+    
+    CMTPTypeObjectPropDescRangeForm* expectedForm = CMTPTypeObjectPropDescRangeForm::NewLC(EMTPTypeUINT32);
+
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EMinimumValue, 0x00000001);
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EMaximumValue, 0x20000000);
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EStepSize, 0x00000001);
+    
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeRepresentativeSampleSize, info, expectedForm);
+    
+    CleanupStack::PopAndDestroy(expectedForm); 
+    }
+
+void CMTPImageDpGetObjectPropDesc::ServiceRepresentativeSampleHeightL()
+    {
+    CMTPTypeObjectPropDesc::TPropertyInfo info;
+    info.iDataType     = EMTPTypeUINT32;
+    info.iFormFlag     = CMTPTypeObjectPropDesc::ERangeForm;
+    info.iGetSet       = CMTPTypeObjectPropDesc::EReadOnly;
+    
+    CMTPTypeObjectPropDescRangeForm* expectedForm = CMTPTypeObjectPropDescRangeForm::NewLC(EMTPTypeUINT32);
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EMinimumValue, 0x00000001);
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EMaximumValue, 0x20000000);
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EStepSize, 0x00000001);
+    
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeRepresentativeSampleHeight, info, expectedForm);
+    
+    CleanupStack::PopAndDestroy(expectedForm);   
+     
+    }
+
+void CMTPImageDpGetObjectPropDesc::ServiceRepresentativeSampleWidthL()
+    {
+    CMTPTypeObjectPropDesc::TPropertyInfo info;
+    info.iDataType     = EMTPTypeUINT32;
+    info.iFormFlag     = CMTPTypeObjectPropDesc::ERangeForm;
+    info.iGetSet       = CMTPTypeObjectPropDesc::EReadOnly;
+    
+    CMTPTypeObjectPropDescRangeForm* expectedForm = CMTPTypeObjectPropDescRangeForm::NewLC(EMTPTypeUINT32);
+
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EMinimumValue, 0x00000001);
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EMaximumValue, 0x20000000);
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EStepSize, 0x00000001);
+    
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeRepresentativeSampleWidth, info, expectedForm);
+    
+    CleanupStack::PopAndDestroy(expectedForm);
+    }
+
+void CMTPImageDpGetObjectPropDesc::ServiceNonConsumableL()
+    {
+    CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT8);
+    CleanupStack::PushL(expectedForm);
+    TUint8 values[] = {0,1};
+    TUint   numValues((sizeof(values) / sizeof(values[0])));
+    for (TUint i = 0; i < numValues; i++)
+        {
+        TMTPTypeUint8 data(values[i]);
+        expectedForm->AppendSupportedValueL(data);
+        }   
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeNonConsumable, *expectedForm);     
+    CleanupStack::PopAndDestroy(expectedForm);
+    }
+
+TUint16 CMTPImageDpGetObjectPropDesc::GetPropertyGroupNumber(const TUint16 aPropCode) const
+    {
+    for( TInt propCodeIndex = 0 ; propCodeIndex < KMTPImageDpGroupOneSize ; propCodeIndex++)
+        {
+            if(KMTPImageDpGroupOneProperties[propCodeIndex] == aPropCode)
+                {
+                return KMTPImageDpPropertyGroupOneNumber;
+                }
+        }
+    
+    // if not foud, the group number should be 0.
+    return 0;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,475 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <bautils.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/cmtptypeobjectproplist.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptyperequest.h>
+
+#include "mtpdpconst.h"
+#include "cmtpimagedpgetobjectproplist.h"
+#include "cmtpimagedpobjectpropertymgr.h"
+#include "mtpimagedpconst.h"
+#include "mtpimagedppanic.h"
+#include "cmtpimagedp.h"
+#include "mtpimagedputilits.h"
+
+__FLOG_STMT(_LIT8(KComponent,"ImageDpGetObjectPropList");)
+
+
+MMTPRequestProcessor* CMTPImageDpGetObjectPropList::NewL(MMTPDataProviderFramework& aFramework, 
+                                                               MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider)
+    {
+    CMTPImageDpGetObjectPropList* self = new (ELeave) CMTPImageDpGetObjectPropList(aFramework, aConnection,aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/*
+ * Constructor
+ */  
+CMTPImageDpGetObjectPropList::CMTPImageDpGetObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider) :
+    CMTPRequestProcessor(aFramework, aConnection, 0,NULL),
+    iPropertyMgr(aDataProvider.PropertyMgr())
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    }
+    
+/*
+ * Constructor
+ */   
+void CMTPImageDpGetObjectPropList::ConstructL()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectPropList::ConstructL"));
+    
+    iPropertyList = CMTPTypeObjectPropList::NewL();
+    iObjectMeta = CMTPObjectMetaData::NewL();
+    
+    __FLOG(_L8("<< CMTPImageDpGetObjectPropList::ConstructL"));
+    }
+
+/*
+ * Destructor
+ */       
+CMTPImageDpGetObjectPropList::~CMTPImageDpGetObjectPropList()
+    {
+    __FLOG(_L8("~CMTPImageDpGetObjectPropList"));
+    Cancel();
+    
+    iHandles.Close();
+    delete iPropertyList;
+    delete iObjectMeta;
+    __FLOG_CLOSE;
+    }
+
+/*
+ * 
+ */ 
+void CMTPImageDpGetObjectPropList::ServiceL()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectPropList::ServiceL"));
+    
+    //get all the handles
+    GetObjectHandlesL();
+    
+    if ( iHandles.Count() > 0 )
+        {
+        ServicePropertiesL( iHandles[0] );
+        iHandles.Remove( 0 );
+        }
+    
+    StartL();
+    
+    __FLOG(_L8("<< CMTPImageDpGetObjectPropList::ServiceL"));
+    }
+    
+/*
+ * Check object Handle, prop code and Depth, Group Code
+ */   
+TMTPResponseCode CMTPImageDpGetObjectPropList::CheckRequestL()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectPropList::CheckRequestL"));        
+
+    TMTPResponseCode result = EMTPRespCodeOK;
+    TUint32 handle(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
+    
+    //getobjectproplist support KMTPHandleAll and KMTPHandleNone
+    if ( handle != KMTPHandleAll && handle != KMTPHandleNone )
+        {
+        CMTPObjectMetaData* object(CMTPObjectMetaData::NewLC());
+        result = MTPImageDpUtilits::VerifyObjectHandleL( iFramework, handle, *object );
+        CleanupStack::PopAndDestroy(object);
+        }
+    if (EMTPRespCodeOK == result)
+        {        
+        result = CheckPropCode();        
+        }
+
+    if (EMTPRespCodeOK == result)
+        {
+        result = CheckDepth();
+        }    
+    
+    __FLOG_VA((_L8("<< CMTPImageDpGetObjectPropList::CheckRequestL result: %d"), result));
+    return result;    
+    }
+
+TMTPResponseCode CMTPImageDpGetObjectPropList::CheckPropCode() const
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectPropList::CheckPropCode"));
+    
+    TMTPResponseCode response = EMTPRespCodeOK; 
+    TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
+    if (propCode == 0)
+        {
+            TUint32 groupCode = Request().Uint32(TMTPTypeRequest::ERequestParameter4);
+            if(groupCode != KMTPImageDpPropertyGroupOneNumber)
+            {
+            //Only supported group one
+            response = EMTPRespCodeSpecificationByGroupUnsupported;
+            }
+        }
+    else if (propCode != KMaxTUint)
+        {
+        const TInt count = sizeof(KMTPImageDpSupportedProperties)/sizeof(KMTPImageDpSupportedProperties[0]);
+		TInt i(0);
+        for (i = 0; i < count; i++)
+            {
+            if (KMTPImageDpSupportedProperties[i] == propCode)
+                {
+                break;
+                }
+            }
+        if (i == count)
+            {
+            response = EMTPRespCodeInvalidObjectPropCode;
+            }
+        }
+    __FLOG(_L8("<< CMTPImageDpGetObjectPropList::CheckPropCode"));
+    return response;
+    }
+ 
+TMTPResponseCode CMTPImageDpGetObjectPropList::CheckDepth() const
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectPropList::CheckDepth"));
+    
+    TMTPResponseCode response = EMTPRespCodeSpecificationByDepthUnsupported;
+    
+    // We either support no depth at all, or 1 depth or (0xFFFFFFFF) with objecthandle as 0x00000000
+    TUint32 handle(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
+    TUint32 depth = Request().Uint32(TMTPTypeRequest::ERequestParameter5);        
+    if ( (depth == 0) || (depth == 1 ) ||
+            (depth == KMaxTUint && handle == KMTPHandleNone ) ) 
+        {
+        response = EMTPRespCodeOK; 
+        }
+    
+    __FLOG(_L8("<< CMTPImageDpGetObjectPropList::CheckDepth"));
+    return response;    
+    }
+
+void CMTPImageDpGetObjectPropList::GetObjectHandlesL()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectPropList::GetObjectHandlesL"));
+    
+    TUint32 handle(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
+    TUint32 formatCode(Request().Uint32(TMTPTypeRequest::ERequestParameter2));
+    TUint32 depth(Request().Uint32(TMTPTypeRequest::ERequestParameter5));
+    
+    iHandles.Reset();
+    
+    if (handle == KMTPHandleAll)
+        {
+        GetObjectHandlesL(KMTPStorageAll, formatCode, KMTPHandleNone);
+        }
+    else if (handle == KMTPHandleNone)
+        {
+        GetRootObjectHandlesL(formatCode, depth);
+        }
+    else
+        {
+        iHandles.Append( handle );
+        }
+    
+    __FLOG(_L8("<< CMTPImageDpGetObjectPropList::GetObjectHandlesL"));
+    }
+
+void CMTPImageDpGetObjectPropList::GetObjectHandlesL(TUint32 aStorageId, TUint32 aFormatCode, TUint32 aParentHandle)
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectPropList::GetObjectHandlesL"));
+    
+    RMTPObjectMgrQueryContext   context;
+    RArray<TUint>               handles;
+    TMTPObjectMgrQueryParams    params(aStorageId, aFormatCode, aParentHandle, iFramework.DataProviderId());
+    CleanupClosePushL(context);
+    CleanupClosePushL(handles);
+    
+    iHandles.Reset();
+    
+    do
+        {
+        iFramework.ObjectMgr().GetObjectHandlesL(params, context, handles);
+        for ( TInt i = 0; i < handles.Count(); i++ )
+            {
+            iHandles.AppendL(handles[i]);
+            }
+        }
+    while(!context.QueryComplete());
+    
+    CleanupStack::PopAndDestroy(&handles);
+    CleanupStack::PopAndDestroy(&context);
+    
+    __FLOG(_L8("<< CMTPImageDpGetObjectPropList::GetObjectHandlesL"));
+    }
+    
+void CMTPImageDpGetObjectPropList::GetRootObjectHandlesL(TUint32 aFormatCode, TUint32 aDepth)
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectPropList::GetRootObjectHandlesL"));
+    
+    if (aDepth == KMaxTUint)
+        {
+        GetObjectHandlesL(KMTPStorageAll, aFormatCode, KMTPHandleNone);
+        }
+    else if (aDepth == 0)
+        {
+        __FLOG(_L8("depth is 0, iHandles is an empty array"));
+        iHandles.Reset();
+        }
+    else
+        {
+        GetObjectHandlesL(KMTPStorageAll, aFormatCode, KMTPHandleNoParent);
+        }
+    
+    __FLOG(_L8("<< CMTPImageDpGetObjectPropList::GetRootObjectHandlesL"));
+    }
+
+void CMTPImageDpGetObjectPropList::ServicePropertiesL( TUint32 aHandle )
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectPropList::ServicePropertiesL"));
+    
+    TUint32 propCode  = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
+    TUint32 groupCode = Request().Uint32(TMTPTypeRequest::ERequestParameter4);
+    
+    iFramework.ObjectMgr().ObjectL(aHandle, *iObjectMeta);
+    iPropertyMgr.SetCurrentObjectL(*iObjectMeta, EFalse);
+    
+    if (propCode == KMaxTUint)
+        {
+        ServiceAllPropertiesL(aHandle);
+        }
+    else if( propCode == 0)
+        {
+        ServiceGroupPropertiesL(aHandle, groupCode);
+        }
+    else
+        {
+        ServiceOneObjectPropertyL(aHandle, propCode);
+        }
+    __FLOG(_L8("<< CMTPImageDpGetObjectPropList::ServicePropertiesL"));
+    }
+
+void CMTPImageDpGetObjectPropList::ServiceAllPropertiesL(TUint32 aHandle)
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectPropList::ServiceAllPropertiesL"));
+    
+    if (iFramework.ObjectMgr().ObjectOwnerId(aHandle) == iFramework.DataProviderId())
+        {
+        for (TUint i(0); (i < (sizeof(KMTPImageDpSupportedProperties) / sizeof(TUint16))); i++)
+            {
+            ServiceOneObjectPropertyL(aHandle, KMTPImageDpSupportedProperties[i]);
+            }
+        }
+    __FLOG(_L8("<< CMTPImageDpGetObjectPropList::ServiceAllPropertiesL"));
+    }
+    
+void CMTPImageDpGetObjectPropList::ServiceGroupPropertiesL(TUint32 aHandle,TUint16 /*aGroupCode*/)
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectPropList::ServiceGroupPropertiesL"));
+    
+    if (iFramework.ObjectMgr().ObjectOwnerId(aHandle) == iFramework.DataProviderId())
+        {
+        for (TUint propCodeIndex(0); propCodeIndex < KMTPImageDpGroupOneSize; propCodeIndex++)
+            {
+            TUint16 propCode = KMTPImageDpGroupOneProperties[propCodeIndex];  
+            if(propCode != 0)
+                {
+                ServiceOneObjectPropertyL(aHandle, propCode);
+                }
+            }
+        }
+    __FLOG(_L8("<< CMTPImageDpGetObjectPropList::ServiceGroupPropertiesL"));
+    }
+ 
+void CMTPImageDpGetObjectPropList::ServiceOneObjectPropertyL(TUint32 aHandle, TUint32 aPropCode)
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectPropList::ServiceOneObjectPropertyL"));
+    
+    if (iFramework.ObjectMgr().ObjectOwnerId(aHandle) == iFramework.DataProviderId())
+        {
+        TUint16 propCode(static_cast<TUint16>(aPropCode));        
+        switch(aPropCode)
+            {   
+        case EMTPObjectPropCodeObjectFormat:
+        case EMTPObjectPropCodeRepresentativeSampleFormat:
+        case EMTPObjectPropCodeProtectionStatus:
+            {
+            TUint16 value;
+            iPropertyMgr.GetPropertyL(TMTPObjectPropertyCode(aPropCode), value);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, propCode); 
+            propElem.SetUint16L(CMTPTypeObjectPropListElement::EValue, value);
+            iPropertyList->CommitPropElemL(propElem);
+            }
+            break;
+        case EMTPObjectPropCodeParentObject:
+            {
+            TUint32 value;
+            iPropertyMgr.GetPropertyL(TMTPObjectPropertyCode(aPropCode), value);
+            if (value == KMTPHandleNoParent)
+                {
+                value = 0;
+                }
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, propCode); 
+            propElem.SetUint32L(CMTPTypeObjectPropListElement::EValue, value);
+            iPropertyList->CommitPropElemL(propElem);
+            }
+            break;
+        case EMTPObjectPropCodeStorageID:
+        case EMTPObjectPropCodeWidth:
+        case EMTPObjectPropCodeHeight:
+        case EMTPObjectPropCodeImageBitDepth:
+        case EMTPObjectPropCodeRepresentativeSampleSize:
+        case EMTPObjectPropCodeRepresentativeSampleHeight:
+        case EMTPObjectPropCodeRepresentativeSampleWidth:
+            {
+            TUint32 value;
+            iPropertyMgr.GetPropertyL(TMTPObjectPropertyCode(aPropCode), value);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, propCode); 
+            propElem.SetUint32L(CMTPTypeObjectPropListElement::EValue, value);
+            iPropertyList->CommitPropElemL(propElem);
+            }
+            break;
+            
+        case EMTPObjectPropCodeObjectSize:
+            {
+            TUint64 value;
+            iPropertyMgr.GetPropertyL(TMTPObjectPropertyCode(aPropCode), value);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, propCode); 
+            propElem.SetUint64L(CMTPTypeObjectPropListElement::EValue, value);
+            iPropertyList->CommitPropElemL(propElem);
+            }
+            break;
+            
+        case EMTPObjectPropCodePersistentUniqueObjectIdentifier:
+            {
+            TMTPTypeUint128 value;
+            iPropertyMgr.GetPropertyL(TMTPObjectPropertyCode(aPropCode), value);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, propCode); 
+            propElem.SetUint128L(CMTPTypeObjectPropListElement::EValue, value.UpperValue(), value.LowerValue());
+            iPropertyList->CommitPropElemL(propElem);
+            }        
+            break;
+            
+        case EMTPObjectPropCodeDateCreated:            
+        case EMTPObjectPropCodeDateModified:
+        case EMTPObjectPropCodeObjectFileName:
+        case EMTPObjectPropCodeName:
+            {
+            CMTPTypeString* value = CMTPTypeString::NewLC();
+            iPropertyMgr.GetPropertyL(TMTPObjectPropertyCode(aPropCode), *value);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, propCode); 
+            propElem.SetStringL(CMTPTypeObjectPropListElement::EValue, value->StringChars());
+            iPropertyList->CommitPropElemL(propElem);
+            CleanupStack::PopAndDestroy(value);
+            }
+            break;
+        case EMTPObjectPropCodeNonConsumable:
+            {
+            
+            TUint8 value;
+            iPropertyMgr.GetPropertyL(TMTPObjectPropertyCode(aPropCode), value);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetUint8L(CMTPTypeObjectPropListElement::EValue, value);
+            iPropertyList->CommitPropElemL(propElem);
+            }        
+            break;               
+        default:
+            //Leave 
+            {
+            User::Leave(KErrGeneral); 
+            }
+            break;
+          }
+        }
+    __FLOG(_L8("<< CMTPImageDpGetObjectPropList::ServiceOneObjectPropertyL"));
+    }
+
+void CMTPImageDpGetObjectPropList::DoCancel()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectPropList::DoCancel"));
+    __FLOG(_L8("<< CMTPImageDpGetObjectPropList::DoCancel"));
+    }
+
+void CMTPImageDpGetObjectPropList::RunL()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectPropList::RunL"));
+    
+    if ( iHandles.Count() > 0 )
+        {
+        ServicePropertiesL( iHandles[0] );
+        iHandles.Remove( 0 );
+        }
+    StartL();
+    __FLOG(_L8("<< CMTPImageDpGetObjectPropList::RunL"));
+    }
+
+TInt CMTPImageDpGetObjectPropList::RunError( TInt aError )
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectPropList::RunError"));
+    
+    TRAP_IGNORE( SendResponseL( EMTPRespCodeGeneralError ) );
+    
+    __FLOG(_L8("<< CMTPImageDpGetObjectPropList::RunError"));
+    return aError;
+    }
+
+void CMTPImageDpGetObjectPropList::StartL()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectPropList::StartL"));
+    
+    if ( iHandles.Count() > 0 )
+        {
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, iStatus.Int() );
+        SetActive();
+        }
+    else
+        {
+        SendDataL(*iPropertyList);
+        }
+    
+    __FLOG(_L8("<< CMTPImageDpGetObjectPropList::StartL"));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectpropssupported.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,100 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+
+#include <f32file.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/mtpdatatypeconstants.h>
+
+#include "cmtpimagedpgetobjectpropssupported.h"
+#include "mtpimagedpconst.h"
+#include "cmtpimagedp.h"
+
+__FLOG_STMT(_LIT8(KComponent,"GetObjectPropsSupported");)
+
+/**
+Verification data for the GetObjectPropSupported request
+*/
+const TMTPRequestElementInfo KMTPGetObjectPropSupportedPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeFormatCode, EMTPElementAttrNone, 1, EMTPFormatCodeUndefined, 0},
+    };
+ 
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/     
+MMTPRequestProcessor* CMTPImageDpGetObjectPropsSupported::NewL(
+                                            MMTPDataProviderFramework& aFramework,
+                                            MMTPConnection& aConnection,CMTPImageDataProvider& /*aDataProvider*/)
+    {
+    CMTPImageDpGetObjectPropsSupported* self = new (ELeave) CMTPImageDpGetObjectPropsSupported(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/	
+CMTPImageDpGetObjectPropsSupported::~CMTPImageDpGetObjectPropsSupported()
+    {
+    delete iObjectPropsSupported;
+    __FLOG_CLOSE;
+    }
+
+/**
+Standard c++ constructor
+*/		
+CMTPImageDpGetObjectPropsSupported::CMTPImageDpGetObjectPropsSupported(
+                                    MMTPDataProviderFramework& aFramework,
+                                    MMTPConnection& aConnection)
+    :CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetObjectPropSupportedPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetObjectPropSupportedPolicy)
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    }
+    
+/**
+GetObjectPropSupported request handler
+*/
+void CMTPImageDpGetObjectPropsSupported::ServiceL()
+    {
+    TInt count = sizeof(KMTPImageDpSupportedProperties) / sizeof(TUint16);
+    for(TInt i = 0; i < count; i++)
+        {
+        iObjectPropsSupported->AppendUintL(KMTPImageDpSupportedProperties[i]);
+        }
+    SendDataL(*iObjectPropsSupported);	
+    }
+
+/**
+Second-phase construction
+*/		
+void CMTPImageDpGetObjectPropsSupported::ConstructL()
+    {
+    iObjectPropsSupported = CMTPTypeArray::NewL(EMTPTypeAUINT16);	
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectpropvalue.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,342 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#include <f32file.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/tmtptypeuint8.h>
+#include <mtp/tmtptypeuint32.h>
+#include <mtp/tmtptypeuint64.h>
+#include <mtp/tmtptypeuint128.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtpobjectmetadata.h>
+
+#include "cmtpimagedpgetobjectpropvalue.h"
+#include "mtpimagedpconst.h"
+#include "cmtpimagedpobjectpropertymgr.h"
+#include "mtpimagedppanic.h"
+#include "cmtpimagedp.h"
+#include "mtpimagedputilits.h"
+
+
+__FLOG_STMT(_LIT8(KComponent,"GetObjectPropValue");)
+
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+MMTPRequestProcessor* CMTPImageDpGetObjectPropValue::NewL(
+                                            MMTPDataProviderFramework& aFramework,
+                                            MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider)
+    {
+    CMTPImageDpGetObjectPropValue* self = new (ELeave) CMTPImageDpGetObjectPropValue(aFramework, aConnection,aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/		
+CMTPImageDpGetObjectPropValue::~CMTPImageDpGetObjectPropValue()
+    {
+    delete iMTPTypeString;	
+    delete iObjectMeta;
+    __FLOG_CLOSE;
+    }
+
+/**
+Standard c++ constructor
+*/		
+CMTPImageDpGetObjectPropValue::CMTPImageDpGetObjectPropValue(
+                                    MMTPDataProviderFramework& aFramework,
+                                    MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider)
+    :CMTPRequestProcessor(aFramework, aConnection,0, NULL),
+    iObjectPropertyMgr(aDataProvider.PropertyMgr())
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);	
+    }
+
+/**
+Second-phase construction
+*/                  
+void CMTPImageDpGetObjectPropValue::ConstructL()
+    {
+    iMTPTypeString = CMTPTypeString::NewL();
+    iObjectMeta = CMTPObjectMetaData::NewL();
+    }
+
+/**
+* Check format code, prop code and objectg Handle
+*/
+TMTPResponseCode CMTPImageDpGetObjectPropValue::CheckRequestL()
+    {
+    TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+    TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);	
+
+    if(responseCode == EMTPRespCodeOK)
+        {
+        const TInt count = sizeof(KMTPImageDpSupportedProperties) / sizeof(TUint16);
+        TInt i = 0;
+        for(i = 0; i < count; i++)
+        
+            if(KMTPImageDpSupportedProperties[i] == propCode)
+                {
+                break;
+                }
+            if(i == count)
+                {
+                responseCode = EMTPRespCodeInvalidObjectPropCode;
+                }		
+        }
+    
+    if(responseCode == EMTPRespCodeOK)
+        {
+        responseCode = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, Request().Uint32(TMTPTypeRequest::ERequestParameter1), *iObjectMeta);
+        iObjectPropertyMgr.SetCurrentObjectL(*iObjectMeta, EFalse);
+        }	
+    
+    return responseCode;	
+    }
+    
+/**
+GetObjectPropValue request handler
+*/		
+void CMTPImageDpGetObjectPropValue::ServiceL()
+    {
+    TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+    switch(propCode)
+        {
+        case EMTPObjectPropCodeStorageID:
+            ServiceStorageIdL();
+            break;
+        case EMTPObjectPropCodeObjectFormat:
+            ServiceObjectFormatL();
+            break;
+        case EMTPObjectPropCodeProtectionStatus:
+            ServiceProtectionStatusL();
+            break;
+        case EMTPObjectPropCodeObjectSize:
+            ServiceObjectSizeL();
+            break;
+        case EMTPObjectPropCodeObjectFileName:
+            ServiceFileNameL();
+            break;
+        case EMTPObjectPropCodeDateCreated:
+            ServiceDateCreatedL();
+            break;
+        case EMTPObjectPropCodeDateModified:
+            ServiceDateModifiedL();
+            break;
+        case EMTPObjectPropCodeParentObject:
+            ServiceParentObjectL();
+            break;
+        case EMTPObjectPropCodePersistentUniqueObjectIdentifier:
+            ServicePuidL();
+            break;
+        case EMTPObjectPropCodeName:
+            ServiceNameL();
+            break;
+        case EMTPObjectPropCodeWidth:
+            ServiceWidthL();
+            break;
+        case EMTPObjectPropCodeHeight:
+            ServiceHeightL();
+            break;
+        case EMTPObjectPropCodeImageBitDepth:
+            ServiceImageBitDepthL();
+            break;
+        case EMTPObjectPropCodeRepresentativeSampleFormat:
+            ServiceRepresentativeSampleFormatL();
+            break;
+        case EMTPObjectPropCodeRepresentativeSampleSize:
+            ServiceRepresentativeSampleSizeL();
+            break;
+        case EMTPObjectPropCodeRepresentativeSampleHeight:
+            ServiceRepresentativeSampleHeightL();
+            break;
+        case EMTPObjectPropCodeRepresentativeSampleWidth:
+            ServiceRepresentativeSampleWidthL();
+            break; 
+        case EMTPObjectPropCodeNonConsumable:
+            ServiceNonConsumableL();
+            break;            
+        default:
+            User::Leave(KErrGeneral);
+        }	
+    }	
+
+void CMTPImageDpGetObjectPropValue::ServiceStorageIdL()
+    {
+    TUint32 storageId;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeStorageID, storageId);
+    iMTPTypeUint32.Set(storageId);
+    
+    SendDataL(iMTPTypeUint32);
+    }
+    
+void CMTPImageDpGetObjectPropValue::ServiceObjectFormatL()
+    {
+    TUint16 format(EMTPFormatCodeUndefined);
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeObjectFormat, format);
+    iMTPTypeUint16.Set(format);
+    
+    SendDataL(iMTPTypeUint16);	
+    }
+    
+void CMTPImageDpGetObjectPropValue::ServiceProtectionStatusL()
+    {
+    TUint16 protection;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeProtectionStatus, protection);
+    iMTPTypeUint16.Set(protection);
+
+    SendDataL(iMTPTypeUint16);	
+    }
+    
+void CMTPImageDpGetObjectPropValue::ServiceObjectSizeL()
+    {
+    TUint64 size;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeObjectSize, size);
+    iMTPTypeUint64.Set(size);
+
+    SendDataL(iMTPTypeUint64);
+    }
+    
+    
+void CMTPImageDpGetObjectPropValue::ServiceFileNameL()
+    {
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeObjectFileName, *iMTPTypeString);
+    SendDataL(*iMTPTypeString);
+    }
+
+void CMTPImageDpGetObjectPropValue::ServiceDateCreatedL()
+    {
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeDateCreated, *iMTPTypeString);
+    SendDataL(*iMTPTypeString);
+    }
+    
+void CMTPImageDpGetObjectPropValue::ServiceDateModifiedL()
+    {
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeDateModified, *iMTPTypeString);
+    SendDataL(*iMTPTypeString);
+    }
+    
+void CMTPImageDpGetObjectPropValue::ServiceParentObjectL()
+    {
+    TUint32 parent;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeParentObject, parent);
+    if (parent == KMTPHandleNoParent)
+        {
+        parent = 0;
+        }
+    iMTPTypeUint32.Set(parent);
+    
+    SendDataL(iMTPTypeUint32);
+    }
+    
+void CMTPImageDpGetObjectPropValue::ServicePuidL()
+    {
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodePersistentUniqueObjectIdentifier, iMTPTypeUint128);
+    SendDataL(iMTPTypeUint128);
+    }
+    
+void CMTPImageDpGetObjectPropValue::ServiceNameL()
+    {
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeName, *iMTPTypeString);
+    SendDataL(*iMTPTypeString);
+    }
+    
+void CMTPImageDpGetObjectPropValue::ServiceWidthL()
+    {
+    TUint32 width;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeWidth, width);
+    iMTPTypeUint32.Set(width);
+    
+    SendDataL(iMTPTypeUint32);
+    }
+
+void CMTPImageDpGetObjectPropValue::ServiceHeightL()
+    {
+    TUint32 height;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeHeight, height);
+    iMTPTypeUint32.Set(height);
+    
+    SendDataL(iMTPTypeUint32);
+    }
+
+void CMTPImageDpGetObjectPropValue::ServiceImageBitDepthL()
+    {
+    TUint32 imageBitDepth;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeImageBitDepth, imageBitDepth);
+    iMTPTypeUint32.Set(imageBitDepth);
+    
+    SendDataL(iMTPTypeUint32);
+    }
+
+
+void CMTPImageDpGetObjectPropValue::ServiceRepresentativeSampleFormatL()
+    {
+    TUint16 representativeSampleFormat;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleFormat, representativeSampleFormat);
+    iMTPTypeUint16.Set(representativeSampleFormat);
+    
+    SendDataL(iMTPTypeUint16);
+    }
+
+void CMTPImageDpGetObjectPropValue::ServiceRepresentativeSampleSizeL()
+    {
+    TUint32 representativeSampleSize;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleSize, representativeSampleSize);
+    iMTPTypeUint32.Set(representativeSampleSize);
+    
+    SendDataL(iMTPTypeUint32);
+    }
+
+void CMTPImageDpGetObjectPropValue::ServiceRepresentativeSampleHeightL()
+    {
+    TUint32 representativeSampleHeight;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleHeight, representativeSampleHeight);
+    iMTPTypeUint32.Set(representativeSampleHeight);
+    
+    SendDataL(iMTPTypeUint32);
+    }
+
+void CMTPImageDpGetObjectPropValue::ServiceRepresentativeSampleWidthL()
+    {
+    TUint32 representativeSampleWidth;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleWidth, representativeSampleWidth);
+    iMTPTypeUint32.Set(representativeSampleWidth);
+    
+    SendDataL(iMTPTypeUint32);
+    }
+
+void CMTPImageDpGetObjectPropValue::ServiceNonConsumableL()
+    {
+    TUint8 nonConsumable;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeNonConsumable, nonConsumable);
+    iMTPTypeUint8.Set(nonConsumable);
+    SendDataL(iMTPTypeUint8);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectreferences.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,104 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtptypearray.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpreferencemgr.h>
+
+#include "cmtpimagedpgetobjectreferences.h"
+#include "mtpimagedputilits.h"
+#include "cmtpimagedp.h"
+
+__FLOG_STMT(_LIT8(KComponent,"GetObjectReferences");)
+
+/**
+Two-phase construction method
+@param aPlugin The data provider plugin
+@param aFramework The data provider framework
+@param aConnection The connection from which the request comes
+@return a pointer to the created request processor object
+*/    
+MMTPRequestProcessor* CMTPImageDpGetObjectReferences::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& /*aDataProvider*/)
+    {
+    CMTPImageDpGetObjectReferences* self = new (ELeave) CMTPImageDpGetObjectReferences(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);    
+    return self;
+    }
+
+/**
+Destructor
+*/    
+CMTPImageDpGetObjectReferences::~CMTPImageDpGetObjectReferences()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectReferences::~CMTPImageDpGetObjectReferences"));
+    delete iReferences;
+    __FLOG(_L8("<< CMTPImageDpGetObjectReferences::~CMTPImageDpGetObjectReferences"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Standard c++ constructor
+*/    
+CMTPImageDpGetObjectReferences::CMTPImageDpGetObjectReferences(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    :CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+    {
+    }
+
+/**
+Second phase constructor
+*/
+void CMTPImageDpGetObjectReferences::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8(">> CMTPImageDpGetObjectReferences::ConstructL"));
+    __FLOG(_L8("<< CMTPImageDpGetObjectReferences::ConstructL"));
+    }
+
+TMTPResponseCode CMTPImageDpGetObjectReferences::CheckRequestL()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetObjectReferences::CheckRequestL"));
+    
+    TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    CMTPObjectMetaData* objectInfo = CMTPObjectMetaData::NewLC();    
+    TMTPResponseCode responseCode = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, objectHandle, *objectInfo);      
+    CleanupStack::PopAndDestroy(objectInfo);
+    
+    __FLOG_VA((_L8("CheckRequestL - Exit with responseCode = 0x%04X"), responseCode));
+    __FLOG(_L8("<< CMTPImageDpGetObjectReferences::CheckRequestL"));
+    return responseCode;
+    }
+
+/**
+GetReferences request handler
+*/    
+void CMTPImageDpGetObjectReferences::ServiceL()
+    {
+    __FLOG(_L8(">> CMTPImageDpCopyObject::ServiceL"));
+    
+    TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    MMTPReferenceMgr& referenceMgr = iFramework.ReferenceMgr();
+    delete iReferences;
+    iReferences = NULL;
+    iReferences = referenceMgr.ReferencesLC(TMTPTypeUint32(objectHandle));
+    CleanupStack::Pop(iReferences);
+    SendDataL(*iReferences);
+    __FLOG(_L8("<< CMTPImageDpCopyObject::ServiceL"));
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetpartialobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,158 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <f32file.h>
+
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypefile.h>
+
+#include "cmtpimagedpgetpartialobject.h"
+#include "mtpimagedppanic.h"
+#include "mtpimagedpconst.h"
+#include "cmtpimagedp.h"
+#include "mtpimagedputilits.h"
+#include "cmtpimagedpobjectpropertymgr.h"
+
+__FLOG_STMT(_LIT8(KComponent,"ImageDpGetPartialObject");)
+/**
+Verification data for the GetPartialObject request
+*/
+
+/**
+Two-phase construction method
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+MMTPRequestProcessor* CMTPImageDpGetPartialObject::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider)
+    {
+    CMTPImageDpGetPartialObject* self = new (ELeave) CMTPImageDpGetPartialObject(aFramework, aConnection, aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+    
+/**
+Destructor
+*/	
+CMTPImageDpGetPartialObject::~CMTPImageDpGetPartialObject()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetPartialObject::~CMTPImageDpGetPartialObject"));
+    delete iFileObject;
+    delete iObjectMeta;
+    __FLOG(_L8("<< CMTPImageDpGetPartialObject::~CMTPImageDpGetPartialObject"));
+    __FLOG_CLOSE;
+    }
+    
+/**
+Standard c++ constructor
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+*/	
+CMTPImageDpGetPartialObject::CMTPImageDpGetPartialObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& /*aDataProvider*/)
+    :CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
+    iFs(iFramework.Fs())
+    {
+    }
+
+/**
+Second-phase construction
+*/  
+void CMTPImageDpGetPartialObject::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8(">> CMTPImageDpGetPartialObject::ConstructL"));
+    iObjectMeta = CMTPObjectMetaData::NewL();
+    __FLOG(_L8("<< CMTPImageDpGetPartialObject::ConstructL"));
+    }
+    
+/**
+Check the GetPartialObject reqeust
+@return EMTPRespCodeOK if the request is good, otherwise, one of the error response codes
+*/	
+TMTPResponseCode CMTPImageDpGetPartialObject::CheckRequestL()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetPartialObject::CheckRequestL"));
+    TMTPResponseCode result = CMTPRequestProcessor::CheckRequestL();
+    if(result == EMTPRespCodeOK)
+        {
+        result = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, Request().Uint32(TMTPTypeRequest::ERequestParameter1), *iObjectMeta);
+        }
+    if(result == EMTPRespCodeOK && !VerifyParametersL())
+        {
+        result = EMTPRespCodeInvalidParameter;
+        }
+    __FLOG_VA((_L8("<< CMTPImageDpGetPartialObject::CheckRequestL 0x%x"), result));
+    __FLOG(_L8("<< CMTPImageDpGetPartialObject::CheckRequestL"));
+    return result;	
+    }
+    
+/**
+Verify if the parameter of the request (i.e. offset) is good.
+@return ETrue if the parameter is good, otherwise, EFalse
+*/		
+TBool CMTPImageDpGetPartialObject::VerifyParametersL()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetPartialObject::VerifyParametersL"));
+    TBool result = EFalse;
+    iOffset = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+    iMaxLength = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
+
+    TEntry fileEntry;
+    User::LeaveIfError(iFs.Entry(iObjectMeta->DesC(CMTPObjectMetaData::ESuid), fileEntry));
+    if((iOffset < fileEntry.iSize)) 
+        {
+        result = ETrue;
+        }
+    __FLOG_VA((_L8("<< CMTPImageDpGetPartialObject::VerifyParametersL %d"), result));
+    return result;	
+    }
+/**
+GetPartialObject request handler
+Send the partial object data to the initiator
+*/	
+void CMTPImageDpGetPartialObject::ServiceL()
+    {
+    // Get file information
+    __FLOG(_L8(">> CMTPImageDpGetPartialObject::ServiceL"));
+        // Pass the complete file back to the host
+    iFileObject = CMTPTypeFile::NewL(iFramework.Fs(), iObjectMeta->DesC(CMTPObjectMetaData::ESuid), (TFileMode)(EFileRead | EFileShareReadersOnly), iMaxLength, iOffset);
+    SendDataL(*iFileObject);	
+    __FLOG(_L8("<< CMTPImageDpGetPartialObject::ServiceL"));
+    }
+    
+    
+/**
+Signal to the initiator how much data has been sent
+@return EFalse
+*/
+TBool CMTPImageDpGetPartialObject::DoHandleResponsePhaseL()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetPartialObject::DoHandleResponsePhaseL"));
+    TUint32 dataLength = iFileObject->GetByteSent();
+    SendResponseL(EMTPRespCodeOK, 1, &dataLength);
+    __FLOG(_L8("<< CMTPImageDpGetPartialObject::DoHandleResponsePhaseL"));
+    return EFalse;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetthumb.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,126 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <bautils.h>  // FileExists
+
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/cmtptypeopaquedata.h>
+#include <thumbnailmanager.h>
+
+#include "cmtpimagedpgetthumb.h"
+#include "mtpimagedppanic.h"
+#include "mtpimagedputilits.h"
+#include "cmtpimagedpthumbnailcreator.h"
+#include "cmtpimagedpobjectpropertymgr.h"
+#include "cmtpimagedp.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"ImageDpGetThumb");)
+
+
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/     
+MMTPRequestProcessor* CMTPImageDpGetThumb::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider)
+    {
+    CMTPImageDpGetThumb* self = new (ELeave) CMTPImageDpGetThumb(aFramework, aConnection,aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/	
+CMTPImageDpGetThumb::~CMTPImageDpGetThumb()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetThumb::~CMTPImageDpGetThumb"));
+    delete iThumb;
+    delete iObjectMeta;
+    __FLOG(_L8("<< CMTPImageDpGetThumb::~CMTPImageDpGetThumb"));
+    __FLOG_CLOSE;
+    }
+    
+/**
+Standard c++ constructor
+*/	
+CMTPImageDpGetThumb::CMTPImageDpGetThumb(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider) : 
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL),imgDp(aDataProvider)
+    {
+    
+    }
+
+/**
+Second-phase constructor.
+*/        
+void CMTPImageDpGetThumb::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("CMTPImageDpGetThumb::ConstructL"));
+    iThumb = CMTPTypeOpaqueData::NewL();
+    iObjectMeta = CMTPObjectMetaData::NewL();
+    __FLOG(_L8("CMTPImageDpGetThumb::ConstructL"));
+    }
+
+
+TMTPResponseCode CMTPImageDpGetThumb::CheckRequestL()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetThumb::CheckRequestL"));
+    TMTPResponseCode result = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, Request().Uint32(TMTPTypeRequest::ERequestParameter1), *iObjectMeta);
+    __FLOG(_L8("<< CMTPImageDpGetThumb::CheckRequestL"));
+    return result;	
+    }
+    
+
+/**
+GetObject request handler
+*/
+void CMTPImageDpGetThumb::ServiceL()
+    {
+    __FLOG(_L8(">> CMTPImageDpGetThumb::ServiceL"));
+    TInt err = KErrNone;
+    TEntry fileEntry;
+    
+    User::LeaveIfError(iFramework.Fs().Entry(iObjectMeta->DesC(CMTPObjectMetaData::ESuid), fileEntry));
+    imgDp.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags);
+    if(fileEntry.iSize > KFileSizeMax)
+        {
+        __FLOG(_L8(">> CMTPImageDpGetThumb::ServiceL, fileEntry.iSize > KFileSizeMax"));
+        imgDp.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDoNotCreate);
+        }
+    imgDp.ThumbnailManager().GetThumbnailL(iObjectMeta->DesC(CMTPObjectMetaData::ESuid), *iThumb, err);
+    User::LeaveIfError(err);
+    SendDataL(*iThumb);
+    __FLOG(_L8("<< CMTPImageDpGetThumb::ServiceL"));
+    }
+
+TBool CMTPImageDpGetThumb::DoHandleCompletingPhaseL()
+    {
+    return CMTPRequestProcessor::DoHandleCompletingPhaseL();
+    }
+
+
+// End Of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpmdeobserver.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,218 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#include <mdesession.h> 
+#include <mdeconstants.h>
+#include <mdequery.h>
+
+#include <centralrepository.h>
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/tmtptypeevent.h>
+
+#include "mtpdebug.h"
+#include "mtpimagedpconst.h"
+#include "cmtpimagedpmdeobserver.h"
+#include "cmtpimagedp.h"
+#include "cmtpimagedpobjectpropertymgr.h"
+#include "mtpimagedputilits.h"
+
+__FLOG_STMT(_LIT8(KComponent, "CMTPImageDpMdeObserver");)
+
+CMTPImageDpMdeObserver* CMTPImageDpMdeObserver::NewL(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider)
+    {
+    CMTPImageDpMdeObserver* self = new (ELeave) CMTPImageDpMdeObserver(aFramework, aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+// --------------------------------------------------------------------------
+// Constructor
+// --------------------------------------------------------------------------
+//
+CMTPImageDpMdeObserver::CMTPImageDpMdeObserver(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider) :
+    iFramework(aFramework),
+    iDataProvider(aDataProvider),
+    iSubscribed(EFalse)
+    {
+    }
+
+void CMTPImageDpMdeObserver::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("CMTPImageDpMdeObserver::ConstructL - Entry"));
+    __FLOG(_L8("CMTPImageDpMdeObserver::ConstructL - Exit"));
+    }
+
+CMTPImageDpMdeObserver::~CMTPImageDpMdeObserver()
+    {
+    __FLOG(_L8("CMTPImageDpMdeObserver::~CMTPImageDpMdeObserver - Entry"));   
+    __FLOG(_L8("CMTPImageDpMdeObserver::~CMTPImageDpMdeObserver - Exit"));   
+    __FLOG_CLOSE;
+    }
+
+void CMTPImageDpMdeObserver::CreateMetadataL(const CMdEObject& aMdeObject, CMTPObjectMetaData& aMetaData)
+    {
+    const TDesC& uri = aMdeObject.Uri();
+    TParsePtrC parse(uri);  
+    TMTPFormatCode format = iDataProvider.FindFormatL(parse.Ext().Mid(1));
+    TInt32 storageId = MTPImageDpUtilits::FindStorage(iFramework, uri);
+    TUint32 parentHandle = MTPImageDpUtilits::FindParentHandleL(iFramework, iDataProvider, uri);
+    
+    aMetaData.SetUint(CMTPObjectMetaData::EDataProviderId, iFramework.DataProviderId());
+    aMetaData.SetUint(CMTPObjectMetaData::EFormatCode, format);
+    aMetaData.SetUint(CMTPObjectMetaData::EStorageId, storageId);
+    aMetaData.SetDesCL(CMTPObjectMetaData::ESuid, uri);    
+    aMetaData.SetUint(CMTPObjectMetaData::EParentHandle, parentHandle);
+    aMetaData.SetDesCL(CMTPObjectMetaData::EName, parse.Name());
+    
+    //Increate the new pictures variable
+    ++iNewPics;
+    }
+
+void CMTPImageDpMdeObserver::ProcessMdeNotificationL(const RArray<TItemId>& aObjectIdArray, TObserverNotificationType /*aType*/)
+    {    
+    __FLOG_VA((_L8("CMTPImageDpMdeObserver::ProcessMdeNotificationL Start")));       
+    
+    //Because image dp only subscribe add notification from MdS, only the add notifictions can reach here
+    //we ignore checking ENotifyAdd notification type to reduce complexity.    
+    CMdESession& mdeSession = iDataProvider.PropertyMgr().MdeSession();
+    CMdENamespaceDef& defaultNamespaceDef = mdeSession.GetDefaultNamespaceDefL();
+    CMdEObjectDef& imageObjDef = defaultNamespaceDef.GetObjectDefL(MdeConstants::Image::KImageObject);    
+                   
+    TInt objectCount = aObjectIdArray.Count();
+    for (TInt i(0); i < objectCount; ++i)
+        {
+        CMdEObject* mdeObject = mdeSession.GetObjectL(aObjectIdArray[i], imageObjDef);
+        if (mdeObject == NULL)
+            {
+            continue;
+            }
+        CleanupStack::PushL(mdeObject);
+        
+        TUint32 handle = iFramework.ObjectMgr().HandleL(mdeObject->Uri());
+        if (handle == KMTPHandleNone)
+            {
+            CMTPObjectMetaData* object = CMTPObjectMetaData::NewLC();
+            CreateMetadataL(*mdeObject, *object);
+            iFramework.ObjectMgr().InsertObjectL(*object);                
+            __FLOG_VA((_L16("Addition - Handle:%u, ObjectId:%u, URI:%S"), object->Uint(CMTPObjectMetaData::EHandle), aObjectIdArray[i], &mdeObject->Uri()));
+            
+            TMTPTypeEvent event;
+            event.SetUint16(TMTPTypeEvent::EEventCode, EMTPEventCodeObjectAdded);
+            event.SetUint32(TMTPTypeEvent::EEventSessionID, KMTPSessionAll);
+            event.SetUint32(TMTPTypeEvent::EEventTransactionID, KMTPTransactionIdNone);
+          
+            TUint32 handle = object->Uint(CMTPObjectMetaData::EHandle);            
+            event.SetUint32(TMTPTypeEvent::EEventParameter1, handle);                    
+            iFramework.SendEventL(event);
+            __FLOG_VA((_L8("ProcessMdeNotificationL - EMTPEventCodeObjectAdd, object handle:%u"), handle));
+            
+            CleanupStack::PopAndDestroy(object);//object 
+            }
+        
+        CleanupStack::PopAndDestroy(mdeObject);//mdeObject             
+        }    
+    
+    __FLOG_VA((_L8("CMTPImageDpMdeObserver::ProcessMdeNotificationL - Exit")));
+    }
+
+/*
+ * After receiving object change notification, check if there is any dp subscribed right now.
+ * if none, store change into database
+ * if yes, check the type of file with subscribed providers, if there is any match, just forward
+ * the change to that dp, if none, store change into database.
+ */
+void CMTPImageDpMdeObserver::HandleObjectNotification(CMdESession& aSession,
+                                            TObserverNotificationType aType,
+                                            const RArray<TItemId>& aObjectIdArray)
+    {
+    TRAP_IGNORE(HandleObjectNotificationL(aSession, aType, aObjectIdArray));
+    }
+
+/*
+ * L Function
+ */
+void CMTPImageDpMdeObserver::HandleObjectNotificationL(CMdESession& /*aSession*/,
+                                                    TObserverNotificationType aType,
+                                                    const RArray<TItemId>& aObjectIdArray)
+    {   
+    __FLOG_VA((_L8("CMTPImageDpMdeObserver::HandleObjectNotificationL - changeType = %d"), aType));   
+   
+    ProcessMdeNotificationL(aObjectIdArray, aType);
+
+    //Update RProperty to notify the subscribers.
+    if (iNewPics > 0)
+        {
+        __FLOG_1(_L16("CMTPImageDpMdeObserver::CMTPImageDpMdeObserver - New Pics: %u"), iNewPics);
+        MTPImageDpUtilits::UpdateNewPicturesValue(iDataProvider, iNewPics, ETrue);
+        iNewPics = 0;
+        }
+    
+    __FLOG(_L8("CMTPImageDpMdeObserver::CMTPImageDpMdeObserver - Exit"));
+    }
+
+/*
+ * Subscribe MdS notifications
+ */
+void CMTPImageDpMdeObserver::SubscribeForChangeNotificationL()
+    {    
+    __FLOG_VA((_L8("CMTPImageDpMdeObserver::SubscribeForChangeNotificationL"))); 
+
+    if (!iSubscribed)
+        {
+        CMdESession& mdeSession = iDataProvider.PropertyMgr().MdeSession();    
+        
+        CMdENamespaceDef& def = mdeSession.GetDefaultNamespaceDefL();
+        CMdEObjectDef& imageObjDef = def.GetObjectDefL(MdeConstants::Image::KImageObject);
+        
+        //Only subscribe add observer        
+        CMdELogicCondition* addCondition = CMdELogicCondition::NewLC(ELogicConditionOperatorAnd);          
+        CMdEPropertyDef& itemTypePropDef = imageObjDef.GetPropertyDefL(MdeConstants::Object::KItemTypeProperty);       
+        addCondition->AddPropertyConditionL(itemTypePropDef, ETextPropertyConditionCompareEndsWith, _L("jpeg"));                       
+        mdeSession.AddObjectObserverL(*this, addCondition, ENotifyAdd);
+        CleanupStack::Pop(addCondition);
+        
+        iSubscribed = ETrue;
+        }
+    
+    __FLOG(_L8("CMTPImageDpMdeObserver::SubscribeForChangeNotificationL - Exit")); 
+    }
+
+/*
+ * Unsubscribe MdS notifications
+ */
+void CMTPImageDpMdeObserver::UnsubscribeForChangeNotificationL()
+    {
+    __FLOG_VA((_L8("CMTPImageDpMdeObserver::UnsubscribeForChangeNotificationL"))); 
+    
+    if (iSubscribed)
+        {
+        CMdESession& mdeSession = iDataProvider.PropertyMgr().MdeSession();  
+        
+        mdeSession.RemoveObjectObserverL(*this);//add observer
+        iSubscribed = EFalse;
+        }
+    
+    __FLOG(_L8("CMTPImageDpMdeObserver::UnsubscribeForChangeNotificationL - Exit")); 
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpmoveobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,305 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#include <f32file.h>
+#include <bautils.h>
+#include <pathinfo.h> // PathInfo
+#include <sysutil.h>
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/cmtptypestring.h>
+
+#include "cmtpimagedpmoveobject.h"
+#include "mtpimagedppanic.h"
+#include "cmtpimagedpobjectpropertymgr.h"
+#include "mtpimagedputilits.h"
+#include "cmtpimagedpthumbnailcreator.h"
+#include "cmtpimagedp.h"
+
+__FLOG_STMT(_LIT8(KComponent,"MoveObject");)
+
+/**
+Verification data for the MoveObject request
+*/    
+const TMTPRequestElementInfo KMTPMoveObjectPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter2, EMTPElementTypeStorageId, EMTPElementAttrWrite, 0, 0, 0},
+        {TMTPTypeRequest::ERequestParameter3, EMTPElementTypeObjectHandle, EMTPElementAttrDir | EMTPElementAttrWrite, 1, 0, 0}
+    };
+
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/     
+MMTPRequestProcessor* CMTPImageDpMoveObject::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider)
+    {
+    CMTPImageDpMoveObject* self = new (ELeave) CMTPImageDpMoveObject(aFramework, aConnection,aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/	
+CMTPImageDpMoveObject::~CMTPImageDpMoveObject()
+    {
+    __FLOG(_L8(">> CMTPImageDpMoveObject::~CMTPImageDpMoveObject")); 
+    delete iDest;
+    delete iFileMan;
+    delete iObjectInfo;
+    __FLOG(_L8("<< CMTPImageDpMoveObject::~CMTPImageDpMoveObject"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Standard c++ constructor
+*/	
+CMTPImageDpMoveObject::CMTPImageDpMoveObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider) :
+    CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPMoveObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPMoveObjectPolicy),
+    iDataProvider(aDataProvider)
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    }
+	
+/**
+ Second phase constructor
+*/
+void CMTPImageDpMoveObject::ConstructL()
+    {
+    __FLOG(_L8(">> CMTPImageDpMoveObject::ConstructL")); 
+    iFileMan = CFileMan::NewL(iFramework.Fs());
+    iObjectInfo = CMTPObjectMetaData::NewL();
+    __FLOG(_L8("<< CMTPImageDpMoveObject::ConstructL")); 
+    }
+
+TMTPResponseCode CMTPImageDpMoveObject::CheckRequestL()
+    {
+    __FLOG(_L8(">> CMTPImageDpCopyObject::CheckRequestL"));
+    TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+    if (EMTPRespCodeOK == responseCode)
+        {
+        TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+        // Check whether object handle is valid
+        responseCode = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, objectHandle, *iObjectInfo);
+        }
+    else if(EMTPRespCodeInvalidObjectHandle == responseCode) //we only check the parent handle
+        {
+        responseCode = EMTPRespCodeInvalidParentObject;
+        }
+    
+    __FLOG_VA((_L8("CheckRequestL - Exit with responseCode = 0x%04X"), responseCode));
+    __FLOG(_L8("<< CMTPImageDpCopyObject::CheckRequestL"));
+    return responseCode;
+    }
+
+/**
+MoveObject request handler
+*/		
+void CMTPImageDpMoveObject::ServiceL()
+    {
+    __FLOG(_L8(">> CMTPImageDpMoveObject::ServiceL"));
+    
+    TMTPResponseCode ret = MoveObjectL();
+    SendResponseL(ret);
+    
+    __FLOG(_L8("<< CMTPImageDpMoveObject::ServiceL")); 
+    }
+
+/**
+A helper function of MoveObjectL.
+@param aNewFileName the new file name after the object is moved.
+*/
+TMTPResponseCode CMTPImageDpMoveObject::MoveFileL(const TDesC& aOldFileName, const TDesC& aNewFileName)	
+    {
+    __FLOG(_L8(">> CMTPImageDpMoveObject::MoveFileL"));
+    
+    TMTPResponseCode responseCode = EMTPRespCodeOK;    
+    /**
+     * File system process the move operation has two different ways:
+     * 1. move object between the same storage.
+     *    under this situation, move operatoin will triggers the EFsRename event by file system.
+     *    then harvester of MdS will directly update the uri of mde object.      
+     *    
+     * 2. move object tetween the different storage.
+     *    uder this situation, move operation will triggers four events by file system:
+     *    a. EFsFileReplace event for old uri object.
+     *    b. EFsFileReplace event for new uri object.
+     *    c. EFsFileSetModified event for DateModified property of object.
+     *    d. EFsDelete event for old uri object.
+     *    
+     *    then harvester of MdS will generate four actions for the above events:
+     *    a. EMdsFileReplaced action for old uri object, this action is a null operation, because no object associates with old uri.
+     *    b. EMdsFileReplaced action for new uri object, this action will add a new mde object into database and 
+     *       put this action into queue of image plugin to wait for execution.
+     *    c. EmdsFileModified action for new object, this action will update the DateModified property of mde object and
+     *       put this action into queue of image plugin to wait for execution.
+     *    d. EmdsFileDeleted action for old object, this action will directly delete old mde object from database.
+     */
+    
+    /**
+     * image dp should update object properties in database to avoid race condition with MdS,
+     * if move faile, it should rollback.
+     */
+    
+    TUint oldStoradId = iObjectInfo->Uint(CMTPObjectMetaData::EStorageId);
+    TUint oldParentHandle = iObjectInfo->Uint(CMTPObjectMetaData::EParentHandle);    
+    iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, aNewFileName);
+    iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
+    iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle);
+    iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo);
+    __FLOG_VA((_L16("CMTPImageDpMoveObject::MoveFileL - Update object info:%S"), &aNewFileName));
+    
+    TInt ret = MoveImageFile(aOldFileName, *iDest);
+    if (ret != KErrNone)
+        {
+        //rollback
+        __FLOG_VA((_L16("CMTPImageDpMoveObject::MoveFileL - Rollback")));
+        iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, aOldFileName);
+        iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, oldStoradId);
+        iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, oldParentHandle);
+        iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo);       
+        responseCode = EMTPRespCodeGeneralError;        
+        }
+    __FLOG_VA((_L8("CMTPImageDpMoveObject::MoveFileL - MoveImageFile:%d"), ret));
+    
+    __FLOG(_L8("<< CMTPImageDpMoveObject::MoveFileL")); 	
+    return responseCode;
+    }
+/**
+move object operations
+@return A valid MTP response code.
+*/
+TMTPResponseCode CMTPImageDpMoveObject::MoveObjectL()
+    {
+    __FLOG(_L8(">> CMTPImageDpMoveObject::MoveObjectL"));
+    TMTPResponseCode responseCode = EMTPRespCodeOK;
+    GetParametersL();
+    RBuf newObjectName;
+    newObjectName.CreateL(KMaxFileName);
+    newObjectName.CleanupClosePushL();
+    newObjectName = *iDest;
+    TFileName oldFileName = iObjectInfo->DesC(CMTPObjectMetaData::ESuid);
+    TParsePtrC fileNameParser(oldFileName);
+    if((newObjectName.Length() + fileNameParser.NameAndExt().Length()) <= newObjectName.MaxLength())
+        {
+        newObjectName.Append(fileNameParser.NameAndExt());
+        responseCode = CanMoveObjectL(oldFileName, newObjectName);
+        }
+    else
+        {
+        responseCode = EMTPRespCodeGeneralError;
+        }
+        
+    if(responseCode == EMTPRespCodeOK)
+        {
+        responseCode = MoveFileL(oldFileName, newObjectName);
+        }
+    CleanupStack::PopAndDestroy(); // newObjectName.
+    __FLOG(_L8("<< CMTPImageDpMoveObject::MoveObjectL")); 	
+    return responseCode;
+    }
+
+/**
+Retrieve the parameters of the request
+*/	
+void CMTPImageDpMoveObject::GetParametersL()
+    {
+    __FLOG(_L8(">> CMTPImageDpMoveObject::GetParametersL"));
+    __ASSERT_DEBUG(iRequestChecker, Panic(EMTPImageDpRequestCheckNull));
+    
+    TUint32 objectHandle  = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+    iNewParentHandle  = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
+    
+    if(iNewParentHandle == 0)
+        {
+        SetDefaultParentObjectL();
+        }
+    else	
+        {
+        CMTPObjectMetaData* parentObjectInfo = iRequestChecker->GetObjectInfo(iNewParentHandle);
+        __ASSERT_DEBUG(parentObjectInfo, Panic(EMTPImageDpObjectNull));
+        delete iDest;
+        iDest = NULL;
+        iDest = parentObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocL();
+        }
+    __FLOG(_L8("<< CMTPImageDpMoveObject::GetParametersL"));
+    }
+    
+/**
+Get a default parent object, ff the request does not specify a parent object, 
+*/
+void CMTPImageDpMoveObject::SetDefaultParentObjectL()
+    {
+    __FLOG(_L8(">> CMTPImageDpMoveObject::SetDefaultParentObjectL"));  
+    const CMTPStorageMetaData& storage = iFramework.StorageMgr().StorageL(iStorageId);
+    delete iDest;
+    iDest = NULL;
+    iDest = storage.DesC(CMTPStorageMetaData::EStorageSuid).AllocL();
+    iNewParentHandle = KMTPHandleNoParent;
+    __FLOG(_L8("<< CMTPImageDpMoveObject::SetDefaultParentObjectL"));  
+    }
+
+/**
+Check if we can move the file to the new location
+*/
+TMTPResponseCode CMTPImageDpMoveObject::CanMoveObjectL(const TDesC& aOldName, const TDesC& aNewName) const
+    {
+    __FLOG(_L8(">> CMTPImageDpMoveObject::CanMoveObjectL"));     
+    TMTPResponseCode result = EMTPRespCodeOK;
+
+    TEntry fileEntry;
+    User::LeaveIfError(iFramework.Fs().Entry(aOldName, fileEntry));
+    TDriveNumber drive(static_cast<TDriveNumber>(iFramework.StorageMgr().DriveNumber(iStorageId)));
+    User::LeaveIfError(drive);
+    TVolumeInfo volumeInfo;
+    User::LeaveIfError(iFramework.Fs().Volume(volumeInfo, drive));
+    
+    if(volumeInfo.iFree < fileEntry.iSize)
+        {
+        result = EMTPRespCodeStoreFull;
+        }
+    else if (BaflUtils::FileExists(iFramework.Fs(), aNewName))			
+        {
+        result = EMTPRespCodeInvalidParentObject;
+        }
+    __FLOG_VA((_L8("CanMoveObjectL - Exit with response code 0x%04X"), result));
+    __FLOG(_L8("<< CMTPImageDpMoveObject::CanMoveObjectL"));     
+    return result;	
+    }
+
+TInt CMTPImageDpMoveObject::MoveImageFile(const TDesC& aOldImageName, const TDesC& aNewImageName)
+    {
+    __FLOG(_L8(">> CMTPImageDpMoveObject::MoveImageFile"));
+    __FLOG_VA((_L8("move image src: %S dest: %S"), &aOldImageName, &aNewImageName));        
+    __FLOG(_L8("<< CMTPImageDpMoveObject::MoveImageFile"));
+    return iFileMan->Move(aOldImageName, aNewImageName);
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,935 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#include <bautils.h>
+#include <f32file.h>
+#include <bautils.h>
+#include <s32file.h>
+#include <e32const.h>
+#include <e32cmn.h>
+#include <imageconversion.h> 
+#include <mdeconstants.h>
+
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/tmtptypeuint32.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mtpprotocolconstants.h>
+
+#include "cmtpimagedpobjectpropertymgr.h"
+#include "mtpimagedppanic.h"
+#include "mtpimagedputilits.h"
+#include "mtpimagedpconst.h"
+#include "mtpdebug.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"MTPImageDpPropertyMgr");)
+
+/**
+The properties cache table content.
+*/
+const CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::TElementMetaData CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::KElements[CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::ENumProperties] = 
+    {
+        {0, CMTPImagePropertiesCache::EUint}, // EImagePixWidth
+        {1, CMTPImagePropertiesCache::EUint}, // EImagePixHeight
+        {2, CMTPImagePropertiesCache::EUint}, // EImageBitDepth
+        {0, CMTPImagePropertiesCache::EDesC}, // EDateCreated
+    };
+
+CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache* CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::NewL()
+    {
+    CMTPImagePropertiesCache* self = new(ELeave) CMTPImagePropertiesCache(KElements, ENumProperties);
+    self->ConstructL();
+    return self;
+    }
+
+/**
+Destructor.
+*/
+CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::~CMTPImagePropertiesCache()
+    {
+    iElementsDesC.ResetAndDestroy();
+    iElementsUint.Reset();
+    } 
+
+/**
+Constructor.
+*/
+CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::CMTPImagePropertiesCache(const TElementMetaData* aElements, TUint aCount) :
+    iElements(sizeof(TElementMetaData), const_cast<TElementMetaData*>(aElements), aCount)
+    {
+    
+    }
+
+void CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::ConstructL()
+    {
+    const TUint KCount(iElements.Count());
+    for (TUint i(0); (i < KCount); i++)
+        {
+        const TElementMetaData& KElement(iElements[i]);
+        switch (KElement.iType)
+            {
+        case EDesC:
+            __ASSERT_DEBUG((iElementsDesC.Count() == KElement.iOffset), Panic(EMTPImageDpBadLayout));
+            iElementsDesC.AppendL(KNullDesC().AllocLC());
+            CleanupStack::Pop();
+            break;
+
+        case EUint:
+            __ASSERT_DEBUG((iElementsUint.Count() == KElement.iOffset), Panic(EMTPImageDpBadLayout));
+            iElementsUint.AppendL(0);
+            break;
+
+        default:
+            //nothing to do
+            __DEBUG_ONLY(User::Invariant());
+            break;
+            }         
+        }
+    
+    iObjectHandle = KMTPHandleNone;   
+    }
+
+void CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::ResetL()
+    {
+    SetUint(EImagePixWidth, 0);
+    SetUint(EImagePixHeight, 0);
+    SetUint(EImageBitDepth, 0);
+    SetDesCL(EDateCreated, KNullDesC);
+    }
+
+const TDesC& CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::DesC(TUint aId) const
+    {
+    __ASSERT_DEBUG((iElements[aId].iType == EDesC), Panic(EMTPImageDpTypeMismatch));
+    return *iElementsDesC[iElements[aId].iOffset];
+    }  
+
+TUint CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::Uint(TUint aId) const
+    {
+    __ASSERT_DEBUG((iElements[aId].iType == EUint), Panic(EMTPImageDpTypeMismatch));
+    return iElementsUint[iElements[aId].iOffset];
+    }
+
+TUint CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::ObjectHandle() const
+    {
+    return iObjectHandle;
+    }
+
+void CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::SetDesCL(TUint aId, const TDesC& aValue)
+    {
+    const TElementMetaData& KElement(iElements[aId]);
+    __ASSERT_DEBUG((KElement.iType == EDesC), Panic(EMTPImageDpTypeMismatch));
+    delete iElementsDesC[KElement.iOffset];
+    iElementsDesC[KElement.iOffset] = NULL;
+    iElementsDesC[KElement.iOffset] = aValue.AllocL();  
+    }
+
+void CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::SetUint(TUint aId, TUint aValue)
+    {
+    __ASSERT_DEBUG((iElements[aId].iType == EUint), Panic(EMTPImageDpTypeMismatch));
+    iElementsUint[iElements[aId].iOffset] = aValue;
+    }
+
+void CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::SetObjectHandle(TUint aObjectHandle)
+    {
+    iObjectHandle = aObjectHandle;
+    }
+
+CMTPImageDpObjectPropertyMgr* CMTPImageDpObjectPropertyMgr::NewL(MMTPDataProviderFramework& aFramework)
+    {
+    CMTPImageDpObjectPropertyMgr* self = new (ELeave) CMTPImageDpObjectPropertyMgr(aFramework);
+    CleanupStack::PushL(self);
+    self->ConstructL(aFramework);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CMTPImageDpObjectPropertyMgr::CMTPImageDpObjectPropertyMgr(MMTPDataProviderFramework& aFramework) :
+    iFs(aFramework.Fs()),
+    iObjectMgr(aFramework.ObjectMgr())
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    }
+
+void CMTPImageDpObjectPropertyMgr::ConstructL(MMTPDataProviderFramework& /*aFramework*/)
+    {
+    __FLOG(_L8("CMTPImageDpObjectPropertyMgr::ConstructL - Entry"));
+    iPropertiesCache = CMTPImagePropertiesCache::NewL();    
+    iMetaDataSession = CMdESession::NewL(*this);
+    __FLOG(_L8("CMTPImageDpObjectPropertyMgr::ConstructL - Open Mde session"));
+    
+    iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait();
+    iActiveSchedulerWait->Start(); // wait for mdesession to start
+    if (iMdeSessionError != KErrNone) 
+        {
+        User::Leave(iMdeSessionError);
+        }
+    __FLOG(_L8("CMTPImageDpObjectPropertyMgr::ConstructL - Exit"));
+    }
+    
+CMTPImageDpObjectPropertyMgr::~CMTPImageDpObjectPropertyMgr()
+    {
+    __FLOG(_L8("CMTPImageDpObjectPropertyMgr::~CMTPImageDpObjectPropertyMgr - Entry"));
+    delete iPropertiesCache;
+    delete iObject;
+    delete iMetaDataSession;
+    delete iActiveSchedulerWait; 
+    __FLOG(_L8("CMTPImageDpObjectPropertyMgr::~CMTPImageDpObjectPropertyMgr - Exit"));
+    __FLOG_CLOSE;
+    }
+
+void CMTPImageDpObjectPropertyMgr::SetCurrentObjectL(CMTPObjectMetaData& aObjectInfo, TBool aRequireForModify, TBool aSaveToCache)
+    {
+    __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::SetCurrentObjectL"));
+    iObjectInfo = &aObjectInfo;
+
+    /**
+     * Image DP property manager will not directly modify properties which stored in the MdS
+     */
+    if(!aRequireForModify)
+        {
+        /**
+         * determine whether the cache hit is occured
+         */
+        if (iPropertiesCache->ObjectHandle() == iObjectInfo->Uint(CMTPObjectMetaData::EHandle))
+            {
+            iCacheHit = ETrue;
+            }
+        else
+            {
+            iCacheHit = EFalse;
+            
+            CMdENamespaceDef& defaultNamespace = iMetaDataSession->GetDefaultNamespaceDefL();
+            CMdEObjectDef& imageObjDef = defaultNamespace.GetObjectDefL( MdeConstants::Image::KImageObject );
+            delete iObject;
+            iObject = NULL;
+            
+            //if we can not open MdS object for getting properties, we will not get properites which stored in MdS
+            TFileName uri;
+            uri.CopyLC(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
+            TRAP_IGNORE((iObject = iMetaDataSession->GetObjectL(uri, imageObjDef)));            
+            }        
+        }    
+    else
+        {        
+        /**
+         * Set image object properties, because the cached properties are all readonly,
+         * so only sendobjectproplist/sendobjectinfo operations can use cache mechanism, 
+         * other operations will not use cache, such as setobjectvalue/setobjectproplist
+         */
+        if (aSaveToCache)
+            {
+            TUint objectHandle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);
+            if (iPropertiesCache->ObjectHandle() != objectHandle)
+                {
+                iPropertiesCache->ResetL();
+                }
+            iPropertiesCache->SetObjectHandle(objectHandle);            
+            }
+        }
+    
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::SetCurrentObjectL"));
+    }
+
+void CMTPImageDpObjectPropertyMgr::SetPropertyL(TMTPObjectPropertyCode aProperty, const TUint8 aValue)
+    {
+    __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::SetPropertyL"));
+    __ASSERT_DEBUG(iObjectInfo, Panic(EMTPImageDpObjectNull));
+    
+    if (aProperty == EMTPObjectPropCodeNonConsumable) 
+        {
+        iObjectInfo->SetUint(CMTPObjectMetaData::ENonConsumable, aValue);
+        }
+    else
+        {
+        User::Leave(EMTPRespCodeObjectPropNotSupported);
+        }
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::SetPropertyL"));
+    }
+
+void CMTPImageDpObjectPropertyMgr::SetPropertyL(TMTPObjectPropertyCode aProperty, const TUint16 aValue)
+    {
+    __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::SetPropertyL"));
+    __ASSERT_DEBUG(iObjectInfo, Panic(EMTPImageDpObjectNull));
+    
+    switch(aProperty)
+        {
+    case EMTPObjectPropCodeObjectFormat:
+        iObjectInfo->SetUint(CMTPObjectMetaData::EFormatCode, aValue);
+        break;        
+    case EMTPObjectPropCodeProtectionStatus://this property does not supported by image dp
+        //nothing to do
+        break;
+    default:
+        //nothing to do
+        break;
+        }
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::SetPropertyL"));
+    }
+
+void CMTPImageDpObjectPropertyMgr::SetPropertyL(TMTPObjectPropertyCode aProperty, const TUint32 aValue)
+    {
+    __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::SetPropertyL"));
+    __ASSERT_DEBUG(iObjectInfo, Panic(EMTPImageDpObjectNull));
+    
+    switch(aProperty)
+        {
+    case EMTPObjectPropCodeStorageID:
+        iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, aValue);
+        break;
+    case EMTPObjectPropCodeParentObject:
+        iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, aValue);
+        break;
+    case EMTPObjectPropCodeWidth:
+        iPropertiesCache->SetUint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImagePixWidth, aValue);
+        break;
+    case EMTPObjectPropCodeHeight:
+        iPropertiesCache->SetUint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImagePixHeight, aValue);
+        break; 
+    case EMTPObjectPropCodeImageBitDepth:
+        iPropertiesCache->SetUint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImageBitDepth, aValue);
+        break;          
+    default:
+        //nothing to do
+        break;
+        }
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::SetPropertyL"));
+    }
+
+void CMTPImageDpObjectPropertyMgr::SetPropertyL(TMTPObjectPropertyCode aProperty, const TDesC& aValue)
+    {
+    __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::SetPropertyL"));
+    __ASSERT_DEBUG(iObjectInfo, Panic(EMTPImageDpObjectNull));
+    
+    switch(aProperty)
+        {
+    case EMTPObjectPropCodeObjectFileName:
+        {
+        TParsePtrC oldUri = TParsePtrC(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
+        
+        //calculate new file name length
+        TInt len = oldUri.DriveAndPath().Length() + aValue.Length();
+        
+        //allocate memory for the new uri
+        RBuf  newUri;
+        newUri.CleanupClosePushL();
+        newUri.CreateL(len);
+        
+        //create the new uri
+        newUri.Append(oldUri.DriveAndPath());
+        newUri.Append(aValue);
+        newUri.Trim();
+        
+        //ask fs to rename file, leave if err returned from fs
+        User::LeaveIfError(iFs.Rename(oldUri.FullName(), newUri));
+        iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, newUri);
+        CleanupStack::PopAndDestroy(&newUri);        
+        }
+        break;
+        
+    case EMTPObjectPropCodeName:
+        iObjectInfo->SetDesCL(CMTPObjectMetaData::EName, aValue);
+        break;
+              
+    case EMTPObjectPropCodeDateModified:
+        {
+        TTime modifiedTime;
+        ConvertMTPTimeStr2TTimeL(aValue, modifiedTime);
+        iFs.SetModified(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), modifiedTime);     
+        }
+        break;
+      
+    case EMTPObjectPropCodeDateCreated://MdS property
+        iPropertiesCache->SetDesCL(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EDateCreated, aValue);
+        break;
+        
+    default:
+        //nothing to do
+        break;
+        }
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::SetPropertyL"));
+    }
+
+void CMTPImageDpObjectPropertyMgr::GetPropertyL(TMTPObjectPropertyCode aProperty, TUint8 &aValue)
+    {
+    __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetPropertyL"));
+    __ASSERT_DEBUG(iObjectInfo, Panic(EMTPImageDpObjectNull));
+    
+    if (aProperty == EMTPObjectPropCodeNonConsumable) 
+        {
+        aValue = iObjectInfo->Uint(CMTPObjectMetaData::ENonConsumable);       
+        }
+    else
+        {
+        User::Leave(EMTPRespCodeObjectPropNotSupported);
+        }     
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetPropertyL"));
+    }
+
+void CMTPImageDpObjectPropertyMgr::GetPropertyL(TMTPObjectPropertyCode aProperty, TUint16 &aValue)
+    {
+    __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetPropertyL"));
+    __ASSERT_DEBUG(iObjectInfo, Panic(EMTPImageDpObjectNull));
+    TEntry entry;
+    switch(aProperty)
+        {
+    case EMTPObjectPropCodeObjectFormat:
+        aValue = iObjectInfo->Uint(CMTPObjectMetaData::EFormatCode);
+        break;
+    case EMTPObjectPropCodeRepresentativeSampleFormat:
+        aValue = KThumbFormatCode;
+       break;        
+    case EMTPObjectPropCodeProtectionStatus:
+        iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), entry);
+        if (entry.IsReadOnly())
+            {
+            aValue = EMTPProtectionReadOnly;
+            }
+        else
+            {
+            aValue = EMTPProtectionNoProtection;
+            }
+        break;        
+    default:
+        GetPropertyFromMdsL(aProperty, &aValue);
+        break;
+        }
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetPropertyL"));
+    }
+
+void CMTPImageDpObjectPropertyMgr::GetPropertyL(TMTPObjectPropertyCode aProperty, TUint32 &aValue)
+    {
+    __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetPropertyL"));
+    __ASSERT_DEBUG(iObjectInfo, Panic(EMTPImageDpObjectNull));
+    
+    switch(aProperty)
+        {
+    case EMTPObjectPropCodeStorageID:
+        aValue = iObjectInfo->Uint(CMTPObjectMetaData::EStorageId);
+        break;
+        
+    case EMTPObjectPropCodeParentObject:
+        aValue = iObjectInfo->Uint(CMTPObjectMetaData::EParentHandle);
+        break;        
+       
+    case EMTPObjectPropCodeRepresentativeSampleSize:
+        aValue = KThumbCompressedSize;
+       break;       
+       
+    case EMTPObjectPropCodeRepresentativeSampleHeight:
+        aValue = KThumbHeigth;
+       break;
+       
+    case EMTPObjectPropCodeRepresentativeSampleWidth:
+        aValue = KThumbWidht;
+       break;
+              
+    default:
+        GetPropertyFromMdsL(aProperty, &aValue);
+        break;  
+        }
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetPropertyL"));
+    }
+    
+void CMTPImageDpObjectPropertyMgr::GetPropertyL(TMTPObjectPropertyCode aProperty, TUint64& aValue)
+    {
+    __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetPropertyL"));
+    __ASSERT_DEBUG(iObjectInfo, Panic(EMTPImageDpObjectNull));
+
+    if (aProperty == EMTPObjectPropCodeObjectSize) 
+        {
+        TEntry entry;
+        iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), entry);
+        aValue = entry.FileSize();            
+        }
+    else
+        {
+        User::Leave(EMTPRespCodeObjectPropNotSupported);
+        }    
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetPropertyL"));
+    }
+
+void CMTPImageDpObjectPropertyMgr::GetPropertyL(TMTPObjectPropertyCode aProperty, TMTPTypeUint128& aValue)
+    {
+    __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetPropertyL"));
+    __ASSERT_DEBUG(iObjectInfo, Panic(EMTPImageDpObjectNull));
+    
+    if (aProperty == EMTPObjectPropCodePersistentUniqueObjectIdentifier) 
+        {
+        TUint32 handle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);
+        aValue = iObjectMgr.PuidL(handle);
+        }
+    else
+        {
+        User::Leave(EMTPRespCodeObjectPropNotSupported);
+        }
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetPropertyL"));
+    }
+    
+void CMTPImageDpObjectPropertyMgr::GetPropertyL(TMTPObjectPropertyCode aProperty, CMTPTypeString& aValue)
+    {
+    __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetPropertyL"));
+    __ASSERT_DEBUG(iObjectInfo, Panic(EMTPImageDpObjectNull));
+
+    switch(aProperty)
+        {    
+    case EMTPObjectPropCodeObjectFileName:
+        {
+        TFileName name;
+        User::LeaveIfError(BaflUtils::MostSignificantPartOfFullName(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), name));     
+        aValue.SetL(name);
+        }
+        break;
+        
+    case EMTPObjectPropCodeName:
+        {
+        aValue.SetL(iObjectInfo->DesC(CMTPObjectMetaData::EName));
+        }
+        break;
+        
+    case EMTPObjectPropCodeDateModified:
+        {
+        TBuf<64> dateString;
+        TEntry entry;
+        iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), entry);
+        
+        _LIT(KTimeFormat, "%F%Y%M%DT%H%T%S"); 
+        entry.iModified.FormatL(dateString, KTimeFormat);        
+        aValue.SetL(dateString);
+        }
+        break;                 
+        
+    default:
+        GetPropertyFromMdsL(aProperty, &aValue);
+        break;
+        }
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetPropertyL"));
+    }
+
+void CMTPImageDpObjectPropertyMgr::GetPropertyFromMdsL(TMTPObjectPropertyCode aProperty, TAny* aValue)
+    {
+    __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetPropertyFromMdsL"));
+    
+    TInt err = KErrNone;
+    CMdENamespaceDef& defaultNamespace = iMetaDataSession->GetDefaultNamespaceDefL();
+    CMdEObjectDef& imageObjDef = defaultNamespace.GetObjectDefL( MdeConstants::Image::KImageObject );
+    CMdEProperty* mdeProperty = NULL;
+    switch (aProperty)
+        {        
+    case EMTPObjectPropCodeDateCreated:
+        {
+        if (iCacheHit)
+            {
+            (*(static_cast<CMTPTypeString*>(aValue))).SetL(iPropertiesCache->DesC(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EDateCreated));
+            }
+        else if (iObject)
+            {        
+            CMdEPropertyDef& creationDatePropDef = imageObjDef.GetPropertyDefL(MdeConstants::Object::KCreationDateProperty);
+            TInt err = iObject->Property( creationDatePropDef, mdeProperty );  
+            if (err >= KErrNone) 
+                {
+                TBuf<KMaxTimeFormatSpec*2> timeValue;
+                // locale independent YYYYMMSSThhmmss, as required by the MTP spec
+                _LIT(KTimeFormat, "%F%Y%M%DT%H%T%S");
+                mdeProperty->TimeValueL().FormatL(timeValue, KTimeFormat);
+                (*(static_cast<CMTPTypeString*>(aValue))).SetL(timeValue);
+                }
+            }
+        }
+       break;  
+       
+    case EMTPObjectPropCodeWidth:
+        {
+        if (iCacheHit)
+            {
+            *static_cast<TUint32*>(aValue) = iPropertiesCache->Uint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImagePixWidth);
+            }
+        else if (iObject)
+            {
+            CMdEPropertyDef& imageWidthPropDef = imageObjDef.GetPropertyDefL(MdeConstants::MediaObject::KWidthProperty);
+            err = iObject->Property( imageWidthPropDef, mdeProperty );  
+            if (err >= KErrNone) 
+                {
+                TUint16 width = mdeProperty->Uint16ValueL();
+                if (width > 0)
+                    {
+                    *static_cast<TUint32*>(aValue) = width;
+                    }
+                else
+                    {
+                    *static_cast<TUint32*>(aValue) = ParseImageFileL(iObject->Uri(), EMTPObjectPropCodeWidth);
+                    }
+                }
+            else
+                {
+                *static_cast<TUint32*>(aValue) = ParseImageFileL(iObject->Uri(), EMTPObjectPropCodeWidth);
+                }
+            }
+        else
+            {
+            *static_cast<TUint32*>(aValue) = 0;
+            }
+        }
+       break; 
+       
+    case EMTPObjectPropCodeHeight:
+        {
+        if (iCacheHit)
+            {
+            *static_cast<TUint32*>(aValue) = iPropertiesCache->Uint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImagePixHeight);
+            }
+        else if (iObject)
+            {
+            CMdEPropertyDef& imageHeightPropDef = imageObjDef.GetPropertyDefL(MdeConstants::MediaObject::KHeightProperty);
+            err = iObject->Property( imageHeightPropDef, mdeProperty );  
+            if (err >= KErrNone) 
+                {
+                TUint16 height = mdeProperty->Uint16ValueL();
+                if (height > 0)
+                    {
+                    *static_cast<TUint32*>(aValue) = height;
+                    }
+                else
+                    {
+                    *static_cast<TUint32*>(aValue) = ParseImageFileL(iObject->Uri(), EMTPObjectPropCodeHeight);
+                    }
+                }
+            else
+                {
+                *static_cast<TUint32*>(aValue) = ParseImageFileL(iObject->Uri(), EMTPObjectPropCodeHeight);
+                }
+            }
+        else
+            {
+            *static_cast<TUint32*>(aValue) = 0;
+            }
+        }
+       break; 
+       
+    case EMTPObjectPropCodeImageBitDepth:
+        {
+        if (iCacheHit)
+            {
+            *static_cast<TUint32*>(aValue) = iPropertiesCache->Uint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImageBitDepth);
+            }
+        else if (iObject)
+            {
+            CMdEPropertyDef& imageBitDepth = imageObjDef.GetPropertyDefL(MdeConstants::Image::KBitsPerSampleProperty);
+            err = iObject->Property( imageBitDepth, mdeProperty );  
+            if (err >= KErrNone) 
+                {
+                TUint16 bitDepth = mdeProperty->Uint16ValueL();
+                if (bitDepth > 0)
+                    {
+                    *static_cast<TUint32*>(aValue) = bitDepth;
+                    }
+                else
+                    {
+                    *static_cast<TUint32*>(aValue) = ParseImageFileL(iObject->Uri(), EMTPObjectPropCodeImageBitDepth);
+                    }                
+                }
+            else
+                {
+                *static_cast<TUint32*>(aValue) = ParseImageFileL(iObject->Uri(), EMTPObjectPropCodeImageBitDepth);
+                }  
+            }
+        else
+            {
+            *static_cast<TUint32*>(aValue) = 0;
+            }        
+        }     
+       break; 
+       
+    default:
+        //nothing to do
+        break;
+        }
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetPropertyFromMdsL"));
+    }
+
+TBool CMTPImageDpObjectPropertyMgr::GetYear(const TDesC& aDateString, TInt& aYear) const
+    {
+  __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetYear"));
+    aYear = 0;
+    TLex dateBuf(aDateString.Left(4));
+  __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetYear"));
+    return dateBuf.Val(aYear) == KErrNone;
+    }
+
+TBool CMTPImageDpObjectPropertyMgr::GetMonth(const TDesC& aDateString, TMonth& aMonth) const
+    {
+      __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetMonth"));
+    TBool result = EFalse;
+    aMonth = EJanuary;
+    TInt month = 0;
+    TLex dateBuf(aDateString.Mid(4, 2));
+    if(dateBuf.Val(month) == KErrNone && month > 0 && month < 13)
+        {
+        month--;
+        aMonth = (TMonth)month;
+        result = ETrue;
+        }
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetMonth"));
+    return result;
+    }
+
+TBool CMTPImageDpObjectPropertyMgr::GetDay(const TDesC& aDateString, TInt& aDay) const
+    {
+    __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetDay"));
+    TBool result = EFalse;
+    aDay = 0;
+    TLex dateBuf(aDateString.Mid(6, 2));
+    if(dateBuf.Val(aDay) == KErrNone && aDay > 0 && aDay < 32)
+        {
+        aDay--;
+        result = ETrue;
+        }
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetDay"));
+    return result;	
+    }
+
+TBool CMTPImageDpObjectPropertyMgr::GetHour(const TDesC& aDateString, TInt& aHour) const
+    {
+    __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetHour"));
+    aHour = 0;
+    TLex dateBuf(aDateString.Mid(9, 2));
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetHour"));
+    return (dateBuf.Val(aHour) == KErrNone && aHour >=0 && aHour < 60);
+    }
+                
+TBool CMTPImageDpObjectPropertyMgr::GetMinute(const TDesC& aDateString, TInt& aMinute) const
+    {
+    __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetMinute"));
+    aMinute = 0;
+    TLex dateBuf(aDateString.Mid(11, 2));
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetMinute"));
+    return (dateBuf.Val(aMinute) == KErrNone && aMinute >=0 && aMinute < 60);
+    }
+
+TBool CMTPImageDpObjectPropertyMgr::GetSecond(const TDesC& aDateString, TInt& aSecond) const
+    {
+    __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetSecond"));
+    aSecond = 0;
+    TLex dateBuf(aDateString.Mid(13, 2));
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetSecond"));
+    return (dateBuf.Val(aSecond) == KErrNone && aSecond >= 0 && aSecond < 60);
+    }
+
+TBool CMTPImageDpObjectPropertyMgr::GetTenthSecond(const TDesC& aDateString, TInt& aTenthSecond) const
+    {
+    __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetTenthSecond"));
+    TBool result = EFalse;
+    aTenthSecond = 0;
+    TInt dotPos = aDateString.Find(_L("."));
+    if(dotPos != KErrNotFound && dotPos < aDateString.Length() - 1)
+        {
+        TLex dateBuf(aDateString.Mid(dotPos + 1, 1));
+        result = (dateBuf.Val(aTenthSecond) == KErrNone && aTenthSecond >=0 && aTenthSecond < 10);
+        }
+    else
+        {
+        result = ETrue;
+        }
+    __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetTenthSecond"));
+    return result;	
+    }
+
+/*
+ * Convert the MTP datatime string to TTime:
+ * 
+ *  MTP datatime string format: YYYYMMDDThhmmss.s  Optional(.s)
+ *  TTime string format       : YYYYMMDD:HHMMSS.MMMMMM
+ *  
+ */
+void CMTPImageDpObjectPropertyMgr::ConvertMTPTimeStr2TTimeL(const TDesC& aTimeString, TTime& aModifiedTime) const
+    {
+    //Convert the Time String to TDateTime
+    TInt year = 0;
+    TMonth month;
+    TInt day = 0;
+    TInt hour = 0;
+    TInt minute = 0;
+    TInt second = 0;
+    TInt tenthSecond = 0;
+    
+    if(!GetYear(aTimeString,year)
+           ||!GetMonth(aTimeString,month)
+           ||!GetDay(aTimeString,day)
+           ||!GetHour(aTimeString,hour)
+           ||!GetMinute(aTimeString,minute)
+           ||!GetSecond(aTimeString,second)
+           ||!GetTenthSecond(aTimeString,tenthSecond))
+        {
+        User::Leave(KErrArgument);
+        }
+    else
+        {     
+        TDateTime dateTime(year, month, day, hour, minute, second, tenthSecond);
+        aModifiedTime = dateTime;
+        } 
+    }
+
+void CMTPImageDpObjectPropertyMgr::RemoveProperty(CMdEObject& aObject, CMdEPropertyDef& aPropDef)
+    {
+    __FLOG(_L8("CMTPImageDpObjectPropertyMgr::RemoveProperty"));
+    TInt index;
+    CMdEProperty* property;
+    index = aObject.Property(aPropDef, property);
+    if (index != KErrNotFound)
+        {
+        aObject.RemoveProperty(index);
+        }
+    }
+
+TUint32 CMTPImageDpObjectPropertyMgr::ParseImageFileL(const TDesC& aUri, TMTPObjectPropertyCode aPropCode)
+    {
+    TUint32 result = 0;
+    TInt err = KErrNone;
+    const TInt K64Kb = 65536;
+    
+    HBufC8* buffer = HBufC8::NewLC(K64Kb);
+    TPtr8 myImagePtr = buffer->Des();
+    err = iFs.ReadFileSection(aUri, 0, myImagePtr, K64Kb);
+    if (err != KErrNone)
+        {
+        CleanupStack::PopAndDestroy(buffer);
+        return result;
+        }
+    
+    CBufferedImageDecoder *decoder = CBufferedImageDecoder::NewL(iFs);
+    CleanupStack::PushL(decoder);
+        
+    decoder->OpenL(myImagePtr, CImageDecoder::TOptions( CImageDecoder::EPreferFastDecode | CImageDecoder::EOptionIgnoreExifMetaData));
+    if (decoder->ValidDecoder())
+        {
+        const TFrameInfo& info = decoder->FrameInfo();
+        
+        switch (aPropCode)
+            {
+        case EMTPObjectPropCodeWidth:
+            result = info.iOverallSizeInPixels.iWidth;
+            break;
+            
+        case EMTPObjectPropCodeHeight:
+            result = info.iOverallSizeInPixels.iHeight;
+            break;
+            
+        case EMTPObjectPropCodeImageBitDepth:
+            result = info.iBitsPerPixel;
+            break;
+            
+        default:
+            // nothing to do
+            break;
+            }
+        
+        /**
+         * Open MdE object for update image object properties after parsing
+         */
+        CMdENamespaceDef& defaultNamespace = iMetaDataSession->GetDefaultNamespaceDefL();
+        CMdEObjectDef& imageObjDef = defaultNamespace.GetObjectDefL(MdeConstants::Image::KImageObject);
+        CMdEPropertyDef& imageWidthPropDef = imageObjDef.GetPropertyDefL(MdeConstants::MediaObject::KWidthProperty);
+        CMdEPropertyDef& imageHeightPropDef = imageObjDef.GetPropertyDefL(MdeConstants::MediaObject::KHeightProperty);
+        CMdEPropertyDef& imageBitDepth = imageObjDef.GetPropertyDefL(MdeConstants::Image::KBitsPerSampleProperty);
+        
+        //update current object properties
+        TUint16 width = info.iOverallSizeInPixels.iWidth;
+        RemoveProperty(*iObject, imageWidthPropDef);
+        iObject->AddUint16PropertyL(imageWidthPropDef, width);
+        
+        TUint16 height = info.iOverallSizeInPixels.iHeight;
+        RemoveProperty(*iObject, imageHeightPropDef);
+        iObject->AddUint16PropertyL(imageHeightPropDef, height);
+        
+        TUint16 bitsPerPixel = info.iBitsPerPixel;
+        RemoveProperty(*iObject, imageBitDepth);
+        iObject->AddUint16PropertyL(imageBitDepth, bitsPerPixel);
+        
+        CMdEObject* updateObject = NULL;
+        TRAP(err, updateObject = iMetaDataSession->OpenObjectL(iObject->Id(), imageObjDef));
+        if (err == KErrNone && updateObject != NULL)
+            {
+            CleanupStack::PushL(updateObject);
+            
+            RemoveProperty(*updateObject, imageWidthPropDef);                   
+            updateObject->AddUint16PropertyL(imageWidthPropDef, width);    
+            
+            RemoveProperty(*updateObject, imageHeightPropDef);        
+            updateObject->AddUint16PropertyL(imageHeightPropDef, height);
+            
+            RemoveProperty(*updateObject, imageBitDepth);        
+            updateObject->AddUint16PropertyL(imageBitDepth, bitsPerPixel);    
+                    
+            iMetaDataSession->CommitObjectL(*updateObject);
+            CleanupStack::PopAndDestroy(updateObject);
+            }
+        }
+    
+    CleanupStack::PopAndDestroy(2);// decoder, buffer
+    
+    return result;
+    }
+
+/**
+ * Return the mdesession instance
+ */
+CMdESession& CMTPImageDpObjectPropertyMgr::MdeSession()
+    {
+    return *iMetaDataSession;
+    }
+
+/**
+ *  From MMdESessionObserver
+ */
+void CMTPImageDpObjectPropertyMgr::HandleSessionOpened(CMdESession& /*aSession*/, TInt aError)
+    {   
+    SetMdeSessionError(aError);
+    if (iActiveSchedulerWait && iActiveSchedulerWait->IsStarted())
+        {
+        iActiveSchedulerWait->AsyncStop();  
+        }
+    }
+
+/**
+ *  From MMdESessionObserver
+ */
+void CMTPImageDpObjectPropertyMgr::HandleSessionError(CMdESession& /*aSession*/, TInt aError)
+    {
+    SetMdeSessionError(aError);
+    if (iActiveSchedulerWait && iActiveSchedulerWait->IsStarted())
+        {
+        iActiveSchedulerWait->AsyncStop();  
+        }  
+    }
+
+void CMTPImageDpObjectPropertyMgr::SetMdeSessionError(TInt aError)
+    {
+    iMdeSessionError = aError;
+    }
+
+void CMTPImageDpObjectPropertyMgr::ClearCacheL()
+    {
+    iPropertiesCache->ResetL();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedprenameobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,238 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#include <f32file.h>
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/tmtptypeuint32.h>
+
+#include "cmtpimagedprenameobject.h"
+#include "cmtpimagedp.h"
+
+__FLOG_STMT(_LIT8(KComponent,"CMTPImageDpRenameObject");)
+
+const TInt KMmMtpRArrayGranularity = 4;
+const TInt KUpdateThreshold = 30;
+const TInt KMaxFileNameLength = 260;
+
+CMTPImageDpRenameObject* CMTPImageDpRenameObject::NewL(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider)
+    {
+    CMTPImageDpRenameObject* self = new ( ELeave ) CMTPImageDpRenameObject(aFramework, aDataProvider);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CMTPImageDpRenameObject::CMTPImageDpRenameObject
+// Standard C++ Constructor
+// -----------------------------------------------------------------------------
+//
+CMTPImageDpRenameObject::CMTPImageDpRenameObject(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider) :
+    CActive(EPriorityStandard),
+    iFramework(aFramework),
+    iDataProvider(aDataProvider),
+    iObjectHandles(KMmMtpRArrayGranularity)
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("CMTPImageDpRenameObject::CMTPImageDpRenameObject"));    
+    }
+
+// -----------------------------------------------------------------------------
+// CMTPImageDpRenameObject::~CMTPImageDpRenameObject
+// destructor
+// -----------------------------------------------------------------------------
+//
+CMTPImageDpRenameObject::~CMTPImageDpRenameObject()
+    {
+    __FLOG(_L8(">> ~CMTPImageDpRenameObject"));
+    Cancel();
+    iObjectHandles.Close();
+    delete iObjectInfo;
+    delete iParentObjectInfo;
+    iNewFileName.Close();
+    delete iRenameWaiter;
+    __FLOG(_L8("<< ~CMTPImageDpRenameObject"));
+    __FLOG_CLOSE;    
+    }
+
+// -----------------------------------------------------------------------------
+// CMTPImageDpRenameObject::StartL
+//
+// -----------------------------------------------------------------------------
+//
+void CMTPImageDpRenameObject::StartL(const TUint32 aParentHandle, const TDesC& /*aOldFolderName*/)
+    {
+    __FLOG_VA((_L16(">> CMTPImageDpRenameObject::StartL aParentHandle(0x%x)"), aParentHandle));
+
+    iObjectHandles.Reset();
+
+    GenerateObjectHandleListL(aParentHandle);
+    iCount = iObjectHandles.Count();
+    __FLOG_VA((_L8(">> CMTPImageDpRenameObject::StartL handle count = %u"), iCount));
+    if (iCount > 0)
+        {
+        iIndex = 0;
+
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, iStatus.Int() );
+        SetActive();
+
+        iRenameWaiter->Start();
+        iObjectHandles.Reset();
+        }
+
+    __FLOG(_L8("<< CMTPImageDpRenameObject::StartL"));
+    }
+
+// -----------------------------------------------------------------------------
+// CMTPImageDpRenameObject::DoCancel()
+// Cancel the rename object process
+// -----------------------------------------------------------------------------
+//
+void CMTPImageDpRenameObject::DoCancel()
+    {
+
+    }
+
+// -----------------------------------------------------------------------------
+// CMTPImageDpRenameObject::RunL
+//
+// -----------------------------------------------------------------------------
+//
+void CMTPImageDpRenameObject::RunL()
+    {
+    __FLOG_VA((_L8(">> CMTPImageDpRenameObject::RunL iIndex = %d"), iIndex));
+    if (iIndex < iCount)
+        {
+        TInt threshold = KUpdateThreshold;
+        for (;iIndex < iCount && threshold > 0; ++iIndex, --threshold)
+            {
+            if (iFramework.ObjectMgr().ObjectL(iObjectHandles[iIndex], *iObjectInfo))
+                {
+                //get parent object info
+                if (iFramework.ObjectMgr().ObjectL(iObjectInfo->Uint(CMTPObjectMetaData::EParentHandle), *iParentObjectInfo))
+                    {                    
+                    TParsePtrC objectUri = TParsePtrC(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
+                    TParsePtrC parentUri = TParsePtrC(iParentObjectInfo->DesC(CMTPObjectMetaData::ESuid));
+                    
+                    iNewFileName.Zero();
+                    iNewFileName.Append(parentUri.DriveAndPath());
+                    iNewFileName.Append(objectUri.NameAndExt());
+                    iNewFileName.Trim();
+                    __FLOG_VA((_L16("New file name(%S)"), &iNewFileName));
+                    
+                    // update framework metadata DB
+                    iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, iNewFileName);
+                    iObjectInfo->SetUint(CMTPObjectMetaData::EObjectMetaDataUpdate, 1);
+                    iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo);                  
+                    }                
+                }         
+            }
+              
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete(status, iStatus.Int());
+        SetActive();
+        }
+    else
+        {
+        if(iRenameWaiter->IsStarted())
+            iRenameWaiter->AsyncStop();
+        }
+
+    __FLOG(_L8("<< CMTPImageDpRenameObject::RunL"));
+    }
+
+// -----------------------------------------------------------------------------
+// CMTPImageDpRenameObject::RunError
+//
+// -----------------------------------------------------------------------------
+//
+TInt CMTPImageDpRenameObject::RunError( TInt aError )
+    {
+    if (aError != KErrNone)
+        __FLOG_VA((_L8(">> CMTPImageDpRenameObject::RunError with error %d"), aError));
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CMTPImageDpRenameObject::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CMTPImageDpRenameObject::ConstructL()
+    {
+    __FLOG(_L8(">> CMTPImageDpRenameObject::ConstructL"));
+    CActiveScheduler::Add( this );
+
+    iObjectInfo = CMTPObjectMetaData::NewL();
+    iParentObjectInfo = CMTPObjectMetaData::NewL();
+    iNewFileName.CreateL(KMaxFileNameLength);
+    iRenameWaiter = new( ELeave ) CActiveSchedulerWait;
+    __FLOG(_L8("<< CMTPImageDpRenameObject::ConstructL"));
+    }
+
+// -----------------------------------------------------------------------------
+// CMTPImageDpRenameObject::GenerateObjectHandleListL
+//
+// -----------------------------------------------------------------------------
+//
+void CMTPImageDpRenameObject::GenerateObjectHandleListL(TUint32 aParentHandle)
+    {
+    __FLOG_VA((_L8(">> CMTPImageDpRenameObject::GenerateObjectHandleListL aParentHandle(0x%x)"), aParentHandle));
+    RMTPObjectMgrQueryContext context;
+    RArray<TUint> handles;
+    CleanupClosePushL(context); // + context
+    CleanupClosePushL(handles); // + handles
+
+    TMTPObjectMgrQueryParams params(KMTPStorageAll, KMTPFormatsAll, aParentHandle);
+    do
+        {
+        iFramework.ObjectMgr().GetObjectHandlesL(params, context, handles);
+
+        TInt numberOfObjects = handles.Count();
+        for (TInt i = 0; i < numberOfObjects; i++)
+            {
+            if (iFramework.ObjectMgr().ObjectOwnerId(handles[i]) == iFramework.DataProviderId())
+                {
+                iObjectHandles.AppendL(handles[i]);
+                continue;
+                }
+
+            // Folder
+            // TODO: need to modify, should not know device dp id
+            if (iFramework.ObjectMgr().ObjectOwnerId(handles[i]) == 0) // We know that the device dp id is always 0, otherwise the whole MTP won't work.
+                {
+                GenerateObjectHandleListL(handles[i]);
+                }
+            }
+        }
+    while (!context.QueryComplete());
+
+    CleanupStack::PopAndDestroy(&handles); // - handles
+    CleanupStack::PopAndDestroy(&context); // - context
+
+    __FLOG(_L8("<< CMTPImageDpRenameObject::GenerateObjectHandleListL"));
+    }
+//end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpsendobjectinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1250 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#include <f32file.h>
+#include <bautils.h>
+
+#include <mtp/mmtpdataproviderframework.h>
+
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypefile.h>
+#include <mtp/cmtptypeobjectinfo.h>
+#include <mtp/cmtptypeobjectproplist.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpconnection.h>
+#include <mtp/tmtptyperequest.h>
+
+#include "mtpdebug.h"
+#include "cmtpimagedpobjectpropertymgr.h"
+#include "cmtpimagedpsendobjectinfo.h"
+#include "mtpimagedppanic.h"
+#include "mtpimagedpconst.h"
+#include "cmtpimagedpthumbnailcreator.h"
+#include "mtpimagedputilits.h"
+#include "cmtpimagedp.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent, "ImageDPSendObjectInfo");)
+
+const TInt RollbackFuncCnt = 3;
+
+const TMTPRequestElementInfo KMTPSendObjectPropListPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeStorageId, EMTPElementAttrWrite, 1, 0, 0}, 
+        {TMTPTypeRequest::ERequestParameter2, EMTPElementTypeObjectHandle, EMTPElementAttrDir, 2, KMTPHandleAll, KMTPHandleNone}
+    };
+/**
+Two-phase construction method
+@param aFramework  The data provider framework
+@param aConnection The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+MMTPRequestProcessor* CMTPImageDpSendObjectInfo::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider)
+    {
+    CMTPImageDpSendObjectInfo* self = new (ELeave) CMTPImageDpSendObjectInfo(aFramework, aConnection,aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+CMTPImageDpSendObjectInfo::~CMTPImageDpSendObjectInfo()
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::~CMTPImageDpSendObjectInfo - Entry"));   
+        
+    Rollback();
+    iRollbackList.Close();
+
+    delete iDateMod;
+    delete iDateCreated;
+    delete iFileReceived;
+    delete iParentSuid;    
+    delete iReceivedObject;
+    delete iObjectInfo;
+    delete iObjectPropList;
+    
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::~CMTPImageDpSendObjectInfo - Exit"));
+    __FLOG_CLOSE; 
+    }
+
+/**
+Standard c++ constructor
+@param aFramework    The data provider framework
+@param aConnection    The connection from which the request comes
+*/    
+CMTPImageDpSendObjectInfo::CMTPImageDpSendObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
+    iDataProvider(aDataProvider),
+    iObjectPropertyMgr(aDataProvider.PropertyMgr())
+    {
+
+    }
+
+#define ADD_FSM_ENTRY(currentstate, event, nextstate, failedstate, action)   \
+    iStateMachine[currentstate][event].iNextSuccessState = nextstate;        \
+    iStateMachine[currentstate][event].iNextFailedState  = failedstate;      \
+    iStateMachine[currentstate][event].iFsmAction        = action
+
+/**
+Second-phase construction
+*/        
+void CMTPImageDpSendObjectInfo::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::ConstructL - Entry"));   
+         
+    iRollbackList.ReserveL(RollbackFuncCnt);
+    iExpectedSendObjectRequest.SetUint16(TMTPTypeRequest::ERequestOperationCode, EMTPOpCodeSendObject);
+    iReceivedObject = CMTPObjectMetaData::NewL();
+    iReceivedObject->SetUint(CMTPObjectMetaData::EDataProviderId, iFramework.DataProviderId());
+    
+    // build FSM matrix    
+    // process sendobjectinfo/sendobjectproplist operation
+    ADD_FSM_ENTRY(EStateIdle, EObjectInfoEvent,     EObjectInfoCheck, EStateIdle, FsmCheckObjectInfoParamsL);
+    ADD_FSM_ENTRY(EStateIdle, EObjectPropListEvent, EObjectInfoCheck, EStateIdle, FsmCheckObjectPropListParamsL);
+    ADD_FSM_ENTRY(EStateIdle, EObjectEvent,         EStateIdle,       EStateIdle, FsmCheckObjectParams);
+    
+    ADD_FSM_ENTRY(EObjectInfoCheck, EObjectInfoEvent,     EObjectInfoServ, EStateIdle, FsmServiceSendObjectInfoL);
+    ADD_FSM_ENTRY(EObjectInfoCheck, EObjectPropListEvent, EObjectInfoServ, EStateIdle, FsmServiceSendObjectPropListL);
+    ADD_FSM_ENTRY(EObjectInfoCheck, EObjectEvent,         EStateEnd,       EStateEnd,  NULL);
+    
+    ADD_FSM_ENTRY(EObjectInfoServ, EObjectInfoEvent,     EObjectInfoSucceed, EStateIdle, FsmDoHandleSendObjectInfoCompleteL);
+    ADD_FSM_ENTRY(EObjectInfoServ, EObjectPropListEvent, EObjectInfoSucceed, EStateIdle, FsmDoHandleSendObjectPropListCompleteL);
+    ADD_FSM_ENTRY(EObjectInfoServ, EObjectEvent,         EStateEnd,          EStateEnd,  NULL);
+    
+    // process sendobject operation
+    ADD_FSM_ENTRY(EObjectInfoSucceed, EObjectInfoEvent,     EObjectInfoCheck, EStateIdle,          FsmCheckObjectInfoParamsL);
+    ADD_FSM_ENTRY(EObjectInfoSucceed, EObjectPropListEvent, EObjectInfoCheck, EStateIdle,          FsmCheckObjectPropListParamsL);
+    ADD_FSM_ENTRY(EObjectInfoSucceed, EObjectEvent,         EObjectCheck,     EObjectInfoSucceed,  FsmCheckObjectParams);
+    
+    ADD_FSM_ENTRY(EObjectCheck, EObjectInfoEvent,     EStateEnd,   EStateEnd,  NULL);
+    ADD_FSM_ENTRY(EObjectCheck, EObjectPropListEvent, EStateEnd,   EStateEnd,  NULL);
+    ADD_FSM_ENTRY(EObjectCheck, EObjectEvent,         EObjectServ, EObjectInfoSucceed, FsmServiceSendObjectL);
+    
+    ADD_FSM_ENTRY(EObjectServ, EObjectInfoEvent,     EStateEnd,   EStateEnd,  NULL);
+    ADD_FSM_ENTRY(EObjectServ, EObjectPropListEvent, EStateEnd,   EStateEnd,  NULL);
+    ADD_FSM_ENTRY(EObjectServ, EObjectEvent,         EStateIdle,  EObjectInfoSucceed, FsmDoHandleSendObjectCompleteL);
+    
+    __FLOG(_L8("CMTPImageEnumerator::ConstructL - Exit"));  
+    }
+
+TBool CMTPImageDpSendObjectInfo::FsmCheckObjectInfoParamsL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr)
+    {
+    return aObject->CheckObjectInfoParamsL(aPtr);
+    }
+
+TBool CMTPImageDpSendObjectInfo::FsmCheckObjectPropListParamsL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr)
+    {
+    return aObject->CheckObjectPropListParamsL(aPtr);
+    }
+
+TBool CMTPImageDpSendObjectInfo::FsmCheckObjectParams(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr)
+    {
+    return aObject->CheckObjectParams(aPtr);
+    }
+
+TBool CMTPImageDpSendObjectInfo::FsmServiceSendObjectInfoL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr)
+    {
+    return aObject->ServiceSendObjectInfoL(aPtr);
+    }
+
+TBool CMTPImageDpSendObjectInfo::FsmServiceSendObjectPropListL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr)
+    {
+    return aObject->ServiceSendObjectPropListL(aPtr);
+    }
+
+TBool CMTPImageDpSendObjectInfo::FsmServiceSendObjectL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr)
+    {
+    return aObject->ServiceSendObjectL(aPtr);
+    }
+
+TBool CMTPImageDpSendObjectInfo::FsmDoHandleSendObjectInfoCompleteL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr)
+    {
+    return aObject->DoHandleSendObjectInfoCompleteL(aPtr);
+    }
+
+TBool CMTPImageDpSendObjectInfo::FsmDoHandleSendObjectPropListCompleteL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr)
+    {
+    return aObject->DoHandleSendObjectPropListCompleteL(aPtr);
+    }
+
+TBool CMTPImageDpSendObjectInfo::FsmDoHandleSendObjectCompleteL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr)
+    {
+    return aObject->DoHandleSendObjectCompleteL(aPtr);
+    }
+
+/**
+Verify the request
+@return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
+*/    
+TMTPResponseCode CMTPImageDpSendObjectInfo::CheckRequestL()
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckRequestL - Entry"));
+    
+    iOperationCode = Request().Uint16(TMTPTypeRequest::ERequestOperationCode);
+    
+    switch (iOperationCode)
+        {      
+    case EMTPOpCodeSendObjectInfo:
+        iEvent = EObjectInfoEvent;
+        iElementCount = sizeof(KMTPSendObjectPropListPolicy) / sizeof(TMTPRequestElementInfo); //for the checker
+        iElements = KMTPSendObjectPropListPolicy;            
+        break;
+        
+    case EMTPOpCodeSendObjectPropList:
+        iEvent = EObjectPropListEvent;
+        iElementCount = sizeof(KMTPSendObjectPropListPolicy) / sizeof(TMTPRequestElementInfo); //for the checker
+        iElements = KMTPSendObjectPropListPolicy;
+        break;
+        
+    case EMTPOpCodeSendObject:
+    	  //In ParseRouter everytime SendObject gets resolved then will be removed from Registry
+    	  //Right away therefore we need reRegister it here again in case possible cancelRequest
+    	  //Against this SendObject being raised.
+    	  iExpectedSendObjectRequest.SetUint32(TMTPTypeRequest::ERequestSessionID, iSessionId);
+    	  iFramework.RouteRequestRegisterL(iExpectedSendObjectRequest, iConnection);
+        iEvent = EObjectEvent;
+        iElementCount = 0; //for the checker
+        iElements = NULL;
+        break;
+        
+    default:
+        // Nothing to do
+        break;
+        }
+    
+    FsmAction pCheck = iStateMachine[iCurrentState][iEvent].iFsmAction;
+    __ASSERT_ALWAYS((pCheck != NULL), Panic(EMTPImageDpNoMatchingProcessor));
+
+    //coverity[var_deref_model]
+    TMTPResponseCode result = CMTPRequestProcessor::CheckRequestL();
+    if(EMTPRespCodeOK == result)
+        {
+        TBool ret = EFalse;
+        TRAPD(err, ret = (*pCheck)(this, &result));
+        if (ret)
+            {
+            iCurrentState = iStateMachine[iCurrentState][iEvent].iNextSuccessState;
+            }
+        else
+            {
+            iCurrentState = iStateMachine[iCurrentState][iEvent].iNextFailedState;
+            }
+        User::LeaveIfError(err);
+        }
+    __FLOG_1(_L8("CheckRequestL - Result: 0x%04x"), result);
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckRequestL - Exit"));
+    
+    return result;    
+    }
+    
+TBool CMTPImageDpSendObjectInfo::HasDataphase() const
+    {
+    return ETrue;
+    }
+
+TBool CMTPImageDpSendObjectInfo::CheckObjectInfoParamsL(TAny *aPtr)
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectInfoParamsL - Entry"));
+    
+    TMTPResponseCode* ret = static_cast<TMTPResponseCode*>(aPtr);
+    *ret = EMTPRespCodeOK;
+    
+    const TUint32 storeId(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
+    const TUint32 parentHandle(Request().Uint32(TMTPTypeRequest::ERequestParameter2));
+    
+    // this checking is only valid when the second parameter is not a special value.
+    if (parentHandle != KMTPHandleAll && parentHandle != KMTPHandleNone)
+        {
+        //does not take owernship
+        CMTPObjectMetaData* parentObjInfo = CMTPObjectMetaData::NewLC();        
+        if (iFramework.ObjectMgr().ObjectL(parentHandle, *parentObjInfo))
+            {
+            TUint32 storageId = parentObjInfo->Uint(CMTPObjectMetaData::EStorageId);   
+            if (storeId != storageId)        
+                {
+                *ret = EMTPRespCodeInvalidObjectHandle;
+                }
+            }
+        else
+            {
+            *ret = EMTPRespCodeInvalidObjectHandle;            
+            }        
+        CleanupStack::PopAndDestroy(parentObjInfo);
+        }
+    
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectInfoParamsL - Exit"));
+    return (*ret == EMTPRespCodeOK) ? ETrue : EFalse;
+    }
+
+TBool CMTPImageDpSendObjectInfo::CheckObjectPropListParamsL(TAny *aPtr)
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectPropListParamsL - Entry"));
+    TMTPResponseCode* ret = static_cast<TMTPResponseCode*>(aPtr);
+    *ret = EMTPRespCodeOK;
+    
+    TMTPFormatCode formatCode = static_cast<TMTPFormatCode>(Request().Uint32(TMTPTypeRequest::ERequestParameter3));
+    if (!IsFormatValid(formatCode))
+        {
+        *ret = EMTPRespCodeInvalidObjectFormatCode;
+        }
+    else
+        {
+        iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+        TUint32 objectSizeHigh = Request().Uint32(TMTPTypeRequest::ERequestParameter4);
+        TUint32 objectSizeLow = Request().Uint32(TMTPTypeRequest::ERequestParameter5);
+        iObjectSize = MAKE_TUINT64(objectSizeHigh, objectSizeLow);
+        
+        if (iStorageId == KMTPStorageDefault)
+            {
+            iStorageId = iFramework.StorageMgr().DefaultStorageId();
+            }
+           
+        //if the object size is more,then report this error.
+        if (!CanStoreFileL(iStorageId, iObjectSize))
+            {
+            *ret = EMTPRespCodeStoreFull;
+            }        
+        }
+    
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectPropListParamsL - Exit"));
+    return (*ret == EMTPRespCodeOK) ? ETrue : EFalse;
+    }
+
+TBool CMTPImageDpSendObjectInfo::CheckObjectParams(TAny *aPtr)
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectParamsL - Entry"));
+    TMTPResponseCode* ret = static_cast<TMTPResponseCode*>(aPtr);
+    *ret = EMTPRespCodeOK;
+    
+    /**
+    * If the previous request is not the SendObjectInfo/SendObjectPropList/UpdateObjectPropList operation,
+    * the SendObject operation should failed.
+    */
+    if ( (iPreviousTransactionID + 1) != Request().Uint32(TMTPTypeRequest::ERequestTransactionID))
+        {
+        *ret = EMTPRespCodeNoValidObjectInfo;
+        }
+    
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectParamsL - Exit"));
+    return (*ret == EMTPRespCodeOK) ? ETrue : EFalse;    
+    }
+
+/**
+SendObjectInfo/SendObject request handler
+NOTE: SendObjectInfo has to be comes before SendObject requests.  To maintain the state information
+between the two requests, the two requests are combined together in one request processor.
+*/    
+void CMTPImageDpSendObjectInfo::ServiceL()
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceL - Entry"));
+
+    FsmAction pService = iStateMachine[iCurrentState][iEvent].iFsmAction;
+    __ASSERT_DEBUG(pService, Panic(EMTPImageDpNoMatchingProcessor));
+    
+    TBool ret = EFalse;
+    TRAPD(err, ret = (*pService)(this, NULL));
+    if (ret)
+        {
+        iCurrentState = iStateMachine[iCurrentState][iEvent].iNextSuccessState;
+        }
+    else
+        {
+        iCurrentState = iStateMachine[iCurrentState][iEvent].iNextFailedState;
+        }    
+    
+    if (err != KErrNone)
+        {
+        Rollback();
+        }
+    User::LeaveIfError(err);
+    
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceL - Exit"));  
+    }
+
+/**
+Override to match both the SendObjectInfo and SendObject requests
+@param aRequest    The request to match
+@param aConnection The connection from which the request comes
+@return ETrue if the processor can handle the request, otherwise EFalse
+*/        
+TBool CMTPImageDpSendObjectInfo::Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::Match - Entry"));
+    TBool result = EFalse;
+    TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
+    if ((operationCode == EMTPOpCodeSendObjectInfo || 
+        operationCode == EMTPOpCodeSendObject ||
+        operationCode == EMTPOpCodeSendObjectPropList) &&
+        &iConnection == &aConnection)
+        {
+        result = ETrue;
+        }
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::Match - Exit"));  
+    return result;    
+    }
+
+/**
+Override to handle the response phase of SendObjectInfo and SendObject requests
+@return EFalse
+*/
+TBool CMTPImageDpSendObjectInfo::DoHandleResponsePhaseL()
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleResponsePhaseL - Entry"));
+
+    //to check if the sending/receiving data is successful
+    iSuccessful = !iCancelled;
+ 
+    FsmAction pResponse = iStateMachine[iCurrentState][iEvent].iFsmAction;
+    __ASSERT_DEBUG(pResponse, Panic(EMTPImageDpNoMatchingProcessor));
+    
+    TBool ret = EFalse;
+    TRAPD(err, ret = (*pResponse)(this, &iSuccessful))
+    if (ret)
+        {
+        iCurrentState = iStateMachine[iCurrentState][iEvent].iNextSuccessState;
+        }
+    else
+        {
+        iCurrentState = iStateMachine[iCurrentState][iEvent].iNextFailedState;
+        }          
+    
+    if (err != KErrNone)
+        {
+        Rollback();
+        }
+    User::LeaveIfError(err);
+    
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleResponsePhaseL - Exit"));   
+    return EFalse;
+    }
+
+/**
+Override to handle the completing phase of SendObjectInfo and SendObject requests
+@return ETrue if succesfully received the file, otherwise EFalse
+*/    
+TBool CMTPImageDpSendObjectInfo::DoHandleCompletingPhaseL()
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleCompletingPhaseL - Entry"));
+    TBool result = ETrue;
+    CMTPRequestProcessor::DoHandleCompletingPhaseL();
+
+    if (iSuccessful)
+        {
+        if (iOperationCode == EMTPOpCodeSendObjectInfo || iOperationCode == EMTPOpCodeSendObjectPropList)
+            {
+            iPreviousTransactionID = Request().Uint32(TMTPTypeRequest::ERequestTransactionID);
+            result = EFalse;
+            }
+        }
+    else
+        {
+        if (iOperationCode == EMTPOpCodeSendObject)
+            {
+            iPreviousTransactionID++;
+            }
+        result = EFalse;
+        }
+    
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleCompletingPhaseL - Exit"));  
+    return result;    
+    }
+
+/**
+SendObjectInfo request handler
+*/
+TBool CMTPImageDpSendObjectInfo::ServiceSendObjectInfoL(TAny* /*aPtr*/)
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectInfoL - Entry"));
+    
+    delete iObjectInfo;
+    iObjectInfo = NULL;
+    iObjectInfo = CMTPTypeObjectInfo::NewL();
+    ReceiveDataL(*iObjectInfo);
+    
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectInfoL - Exit"));
+    return ETrue;
+    }
+
+/**
+SendObjectPropList request handler
+*/
+TBool CMTPImageDpSendObjectInfo::ServiceSendObjectPropListL(TAny* /*aPtr*/)
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectPropListL - Entry"));
+    
+    delete iObjectPropList;
+    iObjectPropList = NULL;
+    iObjectPropList = CMTPTypeObjectPropList::NewL();
+    iReceivedObject->SetUint(CMTPObjectMetaData::EFormatCode, iRequest->Uint32(TMTPTypeRequest::ERequestParameter3));
+    ReceiveDataL(*iObjectPropList);
+    
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectPropListL - Exit"));
+    return ETrue;
+    }
+    
+/**
+SendObject request handler
+*/    
+TBool CMTPImageDpSendObjectInfo::ServiceSendObjectL(TAny* /*aPtr*/)
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectL - Entry"));
+         
+    iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObject);
+    //prepare for rollback
+    iRollbackList.Append(RemoveObjectFromDb);    
+    
+    delete iFileReceived;
+    iFileReceived = NULL;    
+    iFileReceived = CMTPTypeFile::NewL(iFramework.Fs(), iFullPath, EFileWrite);
+    iFileReceived->SetSizeL(iObjectSize);
+    
+    //prepare for rollback
+    iRollbackList.Append(RemoveObjectFromFs);    
+    ReceiveDataL(*iFileReceived);
+    
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectL - Exit"));
+    return ETrue;
+    }
+
+/**
+Get a default parent object, if the request does not specify a parent object.
+*/
+void CMTPImageDpSendObjectInfo::GetDefaultParentObjectL()
+    {    
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::GetDefaultParentObjectL - Entry"));  
+
+    if (iStorageId == KMTPStorageDefault)
+        {
+        iStorageId = iFramework.StorageMgr().DefaultStorageId();
+        }
+    TInt drive(static_cast<TDriveNumber>(iFramework.StorageMgr().DriveNumber(iStorageId)));
+    User::LeaveIfError(drive);       
+
+    delete iParentSuid;
+    iParentSuid = NULL;
+    iParentSuid = (iFramework.StorageMgr().StorageL(iStorageId).DesC(CMTPStorageMetaData::EStorageSuid)).AllocL();
+    iReceivedObject->SetUint(CMTPObjectMetaData::EParentHandle, KMTPHandleNoParent);
+    
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::GetDefaultParentObjectL - Exit"));                 
+    }
+
+/**
+Get parent object and storage id
+@return EMTPRespCodeOK if successful, otherwise, EMTPRespCodeInvalidParentObject
+*/
+TMTPResponseCode CMTPImageDpSendObjectInfo::GetParentObjectAndStorageIdL()
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::GetParentObjectAndStorageIdL - Entry"));    
+    __ASSERT_DEBUG(iRequestChecker, Panic(EMTPImageDpRequestCheckNull));
+
+    iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    iParentHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+    //does not take ownership
+    CMTPObjectMetaData* parentObjectInfo = iRequestChecker->GetObjectInfo(iParentHandle);
+
+    if (!parentObjectInfo)
+        {
+        GetDefaultParentObjectL();    
+        }
+    else
+        {        
+        delete iParentSuid;
+        iParentSuid = NULL;
+        iParentSuid = parentObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocL();
+        iReceivedObject->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle);
+        }
+
+    __FLOG_VA((_L8("ParentSuid = %S"), iParentSuid));
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::GetParentObjectAndStorageIdL - Exit"));     
+    return EMTPRespCodeOK;
+    }
+
+/**
+Handling the completing phase of SendObjectInfo request
+@return ETrue if the specified object can be saved on the specified location, otherwise, EFalse
+*/    
+TBool CMTPImageDpSendObjectInfo::DoHandleSendObjectInfoCompleteL(TAny* /*aPtr*/)
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectInfoCompleteL - Entry"));    
+  
+    TBool result(ETrue);
+    TUint16 format(iObjectInfo->Uint16L(CMTPTypeObjectInfo::EObjectFormat));
+    
+    result = IsFormatValid(TMTPFormatCode(format));
+    
+    if (result)
+        {
+        delete iDateMod;
+        iDateMod = NULL;
+        iDateMod = iObjectInfo->StringCharsL(CMTPTypeObjectInfo::EDateModified).AllocL();
+        delete iDateCreated;
+        iDateCreated = NULL;
+        iDateCreated = iObjectInfo->StringCharsL(CMTPTypeObjectInfo::EDateCreated).AllocL();
+
+        TMTPResponseCode responseCode(GetParentObjectAndStorageIdL());
+        if (responseCode != EMTPRespCodeOK)
+            {
+            SendResponseL(responseCode);
+            result = EFalse;
+            }
+        }
+    else
+        {
+        SendResponseL(EMTPRespCodeInvalidObjectFormatCode);
+        }
+        
+    if (result)
+        {
+        iObjectSize = iObjectInfo->Uint32L(CMTPTypeObjectInfo::EObjectCompressedSize);
+        if(!CanStoreFileL(iStorageId, iObjectSize))
+            {
+            SendResponseL(EMTPRespCodeStoreFull);
+            result = EFalse;            
+            }
+        }
+
+    if (result)
+        {
+        iProtectionStatus = iObjectInfo->Uint16L(CMTPTypeObjectInfo::EProtectionStatus);
+        if (iProtectionStatus !=  EMTPProtectionNoProtection &&
+            iProtectionStatus != EMTPProtectionReadOnly)
+            {
+            SendResponseL(EMTPRespCodeParameterNotSupported);
+            result = EFalse;
+            }
+        }
+
+    if (result)
+        {
+        result = GetFullPathName(iObjectInfo->StringCharsL(CMTPTypeObjectInfo::EFilename));
+        if (!result)
+            {        
+            // File and/or parent pathname invalid.
+            SendResponseL(EMTPRespCodeInvalidDataset);
+            }
+        }
+
+    if (result)
+        {    
+        result = !Exists(iFullPath);
+        if (!result)
+            {
+            SendResponseL(EMTPRespCodeAccessDenied);
+            }
+        else
+            {
+            ReserveObjectL();            
+            imageWidth = iObjectInfo->Uint32L(CMTPTypeObjectInfo::EImagePixWidth);
+            imageHeight = iObjectInfo->Uint32L(CMTPTypeObjectInfo::EImagePixHeight);
+            imageBitDepth = iObjectInfo->Uint32L(CMTPTypeObjectInfo::EImageBitDepth);            
+            iReceivedObject->SetUint(CMTPObjectMetaData::EFormatCode, format);
+            SetPropertiesL();                            
+            ReturnResponseL();
+            }
+        }
+    
+    iSuccessful = result;    
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectInfoCompleteL - Exit"));
+    return result;    
+    }
+
+/**
+Handling the completing phase of SendObjectPropList request
+@return ETrue if the specified object can be saved on the specified location, otherwise, EFalse
+*/    
+TBool CMTPImageDpSendObjectInfo::DoHandleSendObjectPropListCompleteL(TAny* /*aPtr*/)
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectPropListCompleteL - Entry"));
+    TBool result(ETrue);
+    
+    TMTPResponseCode responseCode(GetParentObjectAndStorageIdL());
+    if (responseCode != EMTPRespCodeOK)
+        {
+        SendResponseL(responseCode);
+        result = EFalse;
+        }    
+
+    if (result)
+        {
+        // Any kind of association is treated as a folder
+        const TUint32 formatCode(Request().Uint32(TMTPTypeRequest::ERequestParameter3));
+
+        TInt invalidParameterIndex = KErrNotFound;
+        responseCode = VerifyObjectPropListL(invalidParameterIndex);
+        result = (responseCode == EMTPRespCodeOK);    
+        if (!result)
+            {
+            TUint32 parameters[4];
+            parameters[0] = 0;
+            parameters[1] = 0;
+            parameters[2] = 0;
+            parameters[3] = invalidParameterIndex;
+            SendResponseL(responseCode, 4, parameters);
+            }
+        }
+        
+    if (result) 
+        {
+        result = !Exists(iFullPath);
+        if (!result)
+            {
+            // Object with the same name already exists.
+            SendResponseL(EMTPRespCodeAccessDenied);
+            }
+        }    
+    
+    if (result)
+        {
+        //the EFormatCode property has been set in ServiceSendObjectPropListL() function
+        ReserveObjectL();
+        SetPropertiesL();
+        ReturnResponseL();      
+        }
+        
+    iSuccessful = result;
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectPropListCompleteL - Exit"));
+    return result;    
+    }
+    
+/**
+Handling the completing phase of SendObject request
+@return ETrue if the object has been successfully saved on the device, otherwise, EFalse
+*/    
+TBool CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL(TAny* /*aPtr*/)
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL - Entry"));    
+    TBool result(ETrue);
+    
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+    TInt64 objectsize = 0;
+#else
+    TInt objectsize = 0;
+#endif
+    
+    iFileReceived->File().Size(objectsize);    
+    
+    if (objectsize != iObjectSize)
+        {
+        __FLOG_VA((_L8("object sizes differ %lu != %lu"), objectsize, iObjectSize));
+        iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);         
+        Rollback();
+        
+        TMTPResponseCode responseCode = EMTPRespCodeObjectTooLarge;
+        if (objectsize < iObjectSize)
+            {
+            responseCode = EMTPRespCodeInvalidDataset;
+            }
+        SendResponseL(responseCode);
+        result = EFalse;
+        }
+        
+    // SendObject is cancelled or connection is dropped.
+    if(result && iCancelled)
+        {
+        __FLOG(_L8("It is a cancel for sendObject."));
+        iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
+        Rollback();
+        SendResponseL(EMTPRespCodeTransactionCancelled);    
+        }
+    else if (result && !iCancelled)
+	    {	    	    
+        if (iProtectionStatus ==  EMTPProtectionNoProtection ||
+            iProtectionStatus == EMTPProtectionReadOnly)
+            {
+            TUint attValue = 0;
+            User::LeaveIfError(iFileReceived->File().Att(attValue));
+            attValue &= ~(KEntryAttNormal | KEntryAttReadOnly);
+            
+            if (iProtectionStatus == EMTPProtectionNoProtection)
+                {                        
+                attValue |= KEntryAttNormal;
+                }
+            else
+                {
+                attValue |= KEntryAttReadOnly;
+                }
+            User::LeaveIfError(iFileReceived->File().SetAtt(attValue, ~attValue));
+            }
+        
+        //update datemodified property.
+        if(iDateMod != NULL && iDateMod->Length())
+           {
+           TTime modifiedTime;
+           iObjectPropertyMgr.ConvertMTPTimeStr2TTimeL(*iDateMod, modifiedTime);
+           User::LeaveIfError(iFileReceived->File().SetModified(modifiedTime));
+           }  
+                                   
+	     iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
+        
+        //The MTP spec states that it is not mandatory for SendObjectInfo/SendObjectPropList
+        //to be followed by a SendObject.  An object is reserved in the ObjectStore on 
+        //receiving a SendObjectInfo/SendObjectPropList request, but we only commit it 
+        //on receiving the corresponding SendObject request.  With Associations however 
+        //we commit the object straight away as the SendObject phase is often absent 
+        //with folder creation.
+		
+        CleanUndoList();
+        SendResponseL(EMTPRespCodeOK);
+	    }        
+    
+    delete iFileReceived;
+    iFileReceived = NULL;  
+    
+    iSuccessful = result;
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL - Exit"));
+    return result;
+    }
+
+void CMTPImageDpSendObjectInfo::UnreserveObject(CMTPImageDpSendObjectInfo* aObject)
+    {
+    aObject->UnreserveObject();
+    }
+
+void CMTPImageDpSendObjectInfo::RemoveObjectFromFs(CMTPImageDpSendObjectInfo* aObject)
+    {
+    aObject->RemoveObjectFromFs();
+    }
+
+void CMTPImageDpSendObjectInfo::RemoveObjectFromDb(CMTPImageDpSendObjectInfo* aObject)
+    {
+    aObject->RemoveObjectFromDb();
+    }
+
+void CMTPImageDpSendObjectInfo::UnreserveObject()
+    {    
+    __ASSERT_DEBUG(iReceivedObject, Panic(EMTPImageDpObjectNull));
+    TRAP_IGNORE(iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObject));
+    }
+
+void CMTPImageDpSendObjectInfo::RemoveObjectFromFs()
+    {    
+    delete iFileReceived;
+    iFileReceived = NULL;
+    TInt err = iFramework.Fs().Delete(iFullPath);
+    if (err != KErrNone)
+        {
+        //add Suid to deleteobjectlist
+        iDataProvider.AppendDeleteObjectsArrayL(iFullPath);
+        }
+    }
+
+void CMTPImageDpSendObjectInfo::RemoveObjectFromDb()
+    {    
+    /**
+     * remove all cached properties if rollback occured.
+     */
+    TRAP_IGNORE(
+            iFramework.ObjectMgr().RemoveObjectL(iReceivedObject->Uint(CMTPObjectMetaData::EHandle));
+            iObjectPropertyMgr.ClearCacheL();            
+            );
+    }
+
+void CMTPImageDpSendObjectInfo::ReturnResponseL()
+    {
+    iExpectedSendObjectRequest.SetUint32(TMTPTypeRequest::ERequestSessionID, iSessionId);
+    iFramework.RouteRequestRegisterL(iExpectedSendObjectRequest, iConnection);
+    
+    TUint32 parameters[3];
+    parameters[0] = iStorageId;
+    parameters[1] = iParentHandle;
+    parameters[2] = iReceivedObject->Uint(CMTPObjectMetaData::EHandle);
+    SendResponseL(EMTPRespCodeOK, (sizeof(parameters) / sizeof(parameters[0])), parameters);       
+    }
+
+/**
+*/
+TBool CMTPImageDpSendObjectInfo::IsFormatValid(TMTPFormatCode aFormat) const
+    {
+    __FLOG_1(_L8("CMTPImageDpSendObjectInfo::IsFormatValid - Format: 0x%04x"), aFormat);
+    TInt count(sizeof(KMTPValidCodeExtensionMappings) / sizeof(KMTPValidCodeExtensionMappings[0]));        
+    for(TInt i=0; i < count; i++)
+        {
+        if (KMTPValidCodeExtensionMappings[i].iFormatCode == aFormat)
+            {
+            return ETrue;
+            }
+        }
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::IsFormatValid - Exit"));
+    return EFalse;
+    }
+
+/**
+Get the full path name of the object to be saved
+@param aFileName, on entry, contains the file name of the object,
+on return, contains the full path name of the object to be saved
+@return ETrue if the name is valid, EFalse otherwise
+*/
+TBool CMTPImageDpSendObjectInfo::GetFullPathName(const TDesC& aFileName)
+    {
+    __FLOG_1(_L8("CMTPImageDpSendObjectInfo::GetFullPathNameL - FileName: %S"), &aFileName);
+    TBool result(EFalse);
+    if (aFileName.Length() > 0)
+        {
+        iFullPath = *iParentSuid;
+        if (iFullPath.Length() + aFileName.Length() < iFullPath.MaxLength())
+            {
+            iFullPath.Append(aFileName);
+            result = iFramework.Fs().IsValidName(iFullPath);
+            }
+        __FLOG_1(_L16("FullPath: %S"), &iFullPath);
+        }
+
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::GetFullPathNameL - Exit"));
+    return result;
+    }
+
+/**
+Check if we can store the file on the storage
+@return ETrue if yes, otherwise EFalse
+*/
+TBool CMTPImageDpSendObjectInfo::CanStoreFileL(TUint32 aStorageId, TInt64 aObjectSize) const
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::CanStoreFileL - Entry"));
+    TBool result(ETrue);
+    if (aStorageId == KMTPStorageDefault)
+        {
+        aStorageId = iFramework.StorageMgr().DefaultStorageId();
+        }
+    
+    TDriveNumber drive(static_cast<TDriveNumber>(iFramework.StorageMgr().DriveNumber(aStorageId)));
+    User::LeaveIfError(drive);
+    TVolumeInfo volumeInfo;
+    User::LeaveIfError(iFramework.Fs().Volume(volumeInfo, drive));
+    if (volumeInfo.iFree < aObjectSize)
+        {        
+        result = EFalse;
+        }
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::CanStoreFileL - Exit"));
+    return result;        
+    }
+
+/**
+Check if the file already exists on the storage.
+@return ETrue if file is exists, otherwise EFalse
+*/
+TBool CMTPImageDpSendObjectInfo::Exists(const TDesC& aName) const
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::Exists - Entry")); 
+    // This detects both files and folders
+    TBool ret(EFalse); 
+    ret = BaflUtils::FileExists(iFramework.Fs(), aName);
+    __FLOG_VA((_L16("Exists: %S (%d)"), &aName, ret));
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::IsTooLarge - Exit"));
+    return ret;
+    }
+
+/**
+Check if the property list is valid and extract properties (file name)
+@param aInvalidParameterIndex if invalid, contains the index of the property.  Undefined, if it is valid.
+@return if error, one of the error response code; otherwise EMTPRespCodeOK
+*/
+TMTPResponseCode CMTPImageDpSendObjectInfo::VerifyObjectPropListL(TInt& aInvalidParameterIndex)
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::VerifyObjectPropListL - Entry"));
+    
+    TMTPResponseCode responseCode(EMTPRespCodeOK);
+    const TUint KCount(iObjectPropList->NumberOfElements());
+    iObjectPropList->ResetCursor();
+    for (TUint i(0); (i < KCount); i++)
+        {
+        CMTPTypeObjectPropListElement& KElement=iObjectPropList->GetNextElementL();
+        const TUint32 KHandle(KElement.Uint32L(CMTPTypeObjectPropListElement::EObjectHandle));
+        aInvalidParameterIndex = i;
+        if (KHandle != KMTPHandleNone)
+            {
+            responseCode = EMTPRespCodeInvalidObjectHandle;            
+            break;
+            }
+            
+        responseCode = CheckPropCodeL(KElement);
+        if (responseCode != EMTPRespCodeOK)
+            {
+            break;
+            }
+        responseCode = ExtractPropertyL(KElement);
+        if (responseCode != EMTPRespCodeOK)
+            {
+            break;
+            }        
+        }
+    __FLOG_VA((_L8("Result = 0x%04X"), responseCode));
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::VerifyObjectPropListL - Exit"));
+    return responseCode;        
+    }
+
+/**
+Extracts the file information from the object property list element
+@param aElement an object property list element
+@param aPropertyCode MTP property code for the element
+@return MTP response code
+*/
+TMTPResponseCode CMTPImageDpSendObjectInfo::ExtractPropertyL(const CMTPTypeObjectPropListElement& aElement)
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::ExtractPropertyL - Entry"));
+    TMTPResponseCode responseCode(EMTPRespCodeOK);
+    switch (aElement.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode))
+        {       
+    case EMTPObjectPropCodeObjectFileName:
+        {
+        const TDesC& KFileName = aElement.StringL(CMTPTypeObjectPropListElement::EValue);
+        if (!GetFullPathName(KFileName))
+            {
+            responseCode = EMTPRespCodeInvalidDataset;
+            }
+        }
+        break;
+
+    case EMTPObjectPropCodeProtectionStatus:
+        {
+        iProtectionStatus = aElement.Uint16L(CMTPTypeObjectPropListElement::EValue);
+        if (iProtectionStatus !=  EMTPProtectionNoProtection &&
+            iProtectionStatus != EMTPProtectionReadOnly)
+            {
+            responseCode = EMTPRespCodeParameterNotSupported;
+            }
+        }
+        break;
+
+    case EMTPObjectPropCodeDateModified:
+        delete iDateMod;
+        iDateMod = NULL;
+        iDateMod = aElement.StringL(CMTPTypeObjectPropListElement::EValue).AllocL();
+        break;
+        
+    case EMTPObjectPropCodeDateCreated:
+        delete iDateCreated;
+        iDateCreated = NULL;
+        iDateCreated = aElement.StringL(CMTPTypeObjectPropListElement::EValue).AllocL();
+        break;
+        
+	case EMTPObjectPropCodeName:
+    	iName = aElement.StringL(CMTPTypeObjectPropListElement::EValue);
+    	break;
+        
+    case EMTPObjectPropCodeObjectFormat:
+        iFormatCode = aElement.Uint16L(CMTPTypeObjectPropListElement::EValue);
+        if (iFormatCode != EMTPFormatCodeEXIFJPEG)
+            {
+            responseCode = EMTPRespCodeInvalidObjectPropFormat;
+            }
+        break;
+        
+    case EMTPObjectPropCodeWidth:
+        imageWidth = aElement.Uint32L(CMTPTypeObjectPropListElement::EValue);
+        break;
+        
+    case EMTPObjectPropCodeHeight:
+        imageHeight = aElement.Uint32L(CMTPTypeObjectPropListElement::EValue);
+        break;
+        
+    case EMTPObjectPropCodeImageBitDepth:
+        imageBitDepth = aElement.Uint32L(CMTPTypeObjectPropListElement::EValue);
+        break;
+        
+    case EMTPObjectPropCodeNonConsumable:
+        iNonConsumable = aElement.Uint8L(CMTPTypeObjectPropListElement::EValue);       
+        break;
+        
+    default:
+        break;
+        }
+    __FLOG_VA((_L8("Result = 0x%04X"), responseCode));
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::ExtractPropertyL - Exit"));
+    return responseCode;    
+    }
+
+/**
+Validates the data type for a given property code.
+@param aElement an object property list element
+@param aPropertyCode MTP property code for the element
+@return EMTPRespCodeOK if the combination is valid, or another MTP response code if not
+*/
+TMTPResponseCode CMTPImageDpSendObjectInfo::CheckPropCodeL(const CMTPTypeObjectPropListElement& aElement) const
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckPropCode - Entry"));
+    TMTPResponseCode responseCode(EMTPRespCodeOK);
+    switch(aElement.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode))
+        {
+    case EMTPObjectPropCodeStorageID:
+        if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT32)
+            {
+            responseCode = EMTPRespCodeInvalidObjectPropFormat;
+            }
+        else if (iStorageId != aElement.Uint32L(CMTPTypeObjectPropListElement::EValue))
+            {
+            responseCode = EMTPRespCodeInvalidDataset;
+            }
+        break;
+    
+    case EMTPObjectPropCodeObjectFormat:
+        if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT16)
+            {
+            responseCode = EMTPRespCodeInvalidObjectPropFormat;
+            }
+        else if (Request().Uint32(TMTPTypeRequest::ERequestParameter3) != aElement.Uint16L(CMTPTypeObjectPropListElement::EValue))
+            {
+            responseCode = EMTPRespCodeInvalidDataset;
+            }
+        break;
+       
+    case EMTPObjectPropCodeObjectSize:
+        if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT64)
+            {
+            responseCode = EMTPRespCodeInvalidObjectPropFormat;
+            }
+        else if (iObjectSize != aElement.Uint64L(CMTPTypeObjectPropListElement::EValue))
+            {
+            responseCode = EMTPRespCodeInvalidDataset;
+            }
+        break;
+         
+    case EMTPObjectPropCodeParentObject:
+        if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT32)
+            {
+            responseCode = EMTPRespCodeInvalidObjectPropFormat;
+            }
+        else if (Request().Uint32(TMTPTypeRequest::ERequestParameter2) != aElement.Uint32L(CMTPTypeObjectPropListElement::EValue))
+            {
+            responseCode = EMTPRespCodeInvalidDataset;
+            }
+        break;
+
+    case EMTPObjectPropCodePersistentUniqueObjectIdentifier:
+        responseCode =     EMTPRespCodeAccessDenied;
+        break;
+
+    case EMTPObjectPropCodeRepresentativeSampleFormat:
+    case EMTPObjectPropCodeProtectionStatus:
+        if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT16)
+            {
+            responseCode = EMTPRespCodeInvalidObjectPropFormat;
+            }                        
+        break;
+        
+    case EMTPObjectPropCodeDateCreated:
+    case EMTPObjectPropCodeDateModified:                    
+    case EMTPObjectPropCodeObjectFileName:    
+    case EMTPObjectPropCodeName:
+        if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeString)
+            {
+            responseCode = EMTPRespCodeInvalidObjectPropFormat;
+            }
+        break;
+        
+    case EMTPObjectPropCodeWidth:
+    case EMTPObjectPropCodeHeight:
+    case EMTPObjectPropCodeImageBitDepth:
+    case EMTPObjectPropCodeRepresentativeSampleSize:
+    case EMTPObjectPropCodeRepresentativeSampleHeight:
+    case EMTPObjectPropCodeRepresentativeSampleWidth:
+        if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT32)
+            {
+            responseCode = EMTPRespCodeInvalidObjectPropFormat;
+            }
+        break;
+    case EMTPObjectPropCodeNonConsumable:
+        if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT8)
+            {
+            responseCode = EMTPRespCodeInvalidObjectPropFormat;
+            }
+        break;        
+    default:
+        responseCode = EMTPRespCodeInvalidObjectPropCode;
+        break;
+        }
+    __FLOG_VA((_L8("Result = 0x%04X"), responseCode));
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckPropCode - Exit"));
+    return responseCode;    
+    }
+
+/**
+Reserves space for and assigns an object handle to the received object, then
+sends a success response.
+*/
+void CMTPImageDpSendObjectInfo::ReserveObjectL()
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::ReserveObjectL - Entry"));
+
+    iReceivedObject->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);    
+    iFramework.ObjectMgr().ReserveObjectHandleL(*iReceivedObject, iObjectSize);    
+    
+    // prepare for rollback
+    iRollbackList.Append(UnreserveObject);    
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::ReserveObjectL - Exit"));   
+    }
+
+/**
+Sets the read only status on the current file to match the sent object.
+*/
+void CMTPImageDpSendObjectInfo::SetPropertiesL()
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::SetPropertiesL - Entry"));
+    
+    iObjectPropertyMgr.SetCurrentObjectL(*iReceivedObject, ETrue, ETrue);
+    iReceivedObject->SetDesCL(CMTPObjectMetaData::ESuid, iFullPath);
+    if (iName.Length() == 0)
+        {
+        TParsePtrC pathParser(iFullPath);
+        iName = pathParser.Name();
+        }
+    iObjectPropertyMgr.SetPropertyL(EMTPObjectPropCodeName, iName);
+    iObjectPropertyMgr.SetPropertyL(EMTPObjectPropCodeProtectionStatus, iProtectionStatus);
+    iObjectPropertyMgr.SetPropertyL(EMTPObjectPropCodeWidth, imageWidth);
+    iObjectPropertyMgr.SetPropertyL(EMTPObjectPropCodeHeight, imageHeight);
+    iObjectPropertyMgr.SetPropertyL(EMTPObjectPropCodeImageBitDepth, imageBitDepth);    
+    iObjectPropertyMgr.SetPropertyL(EMTPObjectPropCodeNonConsumable, iNonConsumable);
+  
+    if(iDateCreated != NULL && iDateCreated->Length())
+        {//currently image dp can not support this property
+        iObjectPropertyMgr.SetPropertyL(EMTPObjectPropCodeDateCreated, *iDateCreated);
+        }
+    
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::SetPropertiesL - Exit"));
+    }
+    
+void CMTPImageDpSendObjectInfo::Rollback()
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::Rollback - Entry"));  
+    
+    TInt count = iRollbackList.Count();
+    while(--count >= 0)
+        {
+        TRAP_IGNORE((*iRollbackList[count])(this));
+        }
+    iRollbackList.Reset();
+    
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::Rollback - Exit"));  
+    }
+    
+void CMTPImageDpSendObjectInfo::CleanUndoList()
+    {
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::CleanUndoList - Entry")); 
+    
+    iRollbackList.Reset();
+    
+    __FLOG(_L8("CMTPImageDpSendObjectInfo::CleanUndoList - Exit"));  
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpsetobjectproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,190 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/cmtptypeobjectproplist.h>
+
+#include "cmtpimagedpsetobjectproplist.h"
+#include "cmtpimagedpobjectpropertymgr.h"
+#include "cmtpimagedp.h"
+#include "mtpimagedputilits.h"
+
+__FLOG_STMT(_LIT8(KComponent,"CMTPImageDpSetObjectPropList");)
+
+MMTPRequestProcessor* CMTPImageDpSetObjectPropList::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider)
+    {
+    CMTPImageDpSetObjectPropList* self = new (ELeave) CMTPImageDpSetObjectPropList(aFramework, aConnection,aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+    
+CMTPImageDpSetObjectPropList::~CMTPImageDpSetObjectPropList()
+    {
+    __FLOG(_L8(">> CMTPImageDpSetObjectPropList::~CMTPImageDpSetObjectPropList"));
+    delete iPropertyList;
+    delete iObjectMeta;
+    __FLOG(_L8("<< CMTPImageDpSetObjectPropList::~CMTPImageDpSetObjectPropList"));
+    __FLOG_CLOSE;
+    }
+    
+CMTPImageDpSetObjectPropList::CMTPImageDpSetObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
+    iDataProvider(aDataProvider),
+    iPropertyMgr(aDataProvider.PropertyMgr())		
+    {
+    
+    }
+    
+void CMTPImageDpSetObjectPropList::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8(">> CMTPImageDpSetObjectPropList::ConstructL"));
+    iPropertyList = CMTPTypeObjectPropList::NewL();
+    iObjectMeta = CMTPObjectMetaData::NewL();
+    __FLOG(_L8("<< CMTPImageDpSetObjectPropList::ConstructL"));
+    }
+
+void CMTPImageDpSetObjectPropList::ServiceL()
+    {
+    __FLOG(_L8(">> CMTPImageDpSetObjectPropList::ConstructL"));
+    ReceiveDataL(*iPropertyList);
+    __FLOG(_L8(">> CMTPImageDpSetObjectPropList::ConstructL"));
+    }
+
+TBool CMTPImageDpSetObjectPropList::DoHandleResponsePhaseL()
+    {
+    __FLOG(_L8(">> CMTPImageDpSetObjectPropList::DoHandleResponsePhaseL"));
+    MMTPObjectMgr& objects(iFramework.ObjectMgr());
+    TUint32 parameter(0);
+    TMTPResponseCode responseCode(EMTPRespCodeOK);
+    const TUint count(iPropertyList->NumberOfElements());
+    iPropertyList->ResetCursor();
+    __FLOG_VA((_L8("setting %d properties"), count));
+    TUint32 preHandle = KMTPHandleNone;
+    for (TUint i(0); ((i < count) && (responseCode == EMTPRespCodeOK)); i++)
+        {
+        CMTPTypeObjectPropListElement& element=iPropertyList->GetNextElementL(); 
+        TUint32 handle = element.Uint32L(CMTPTypeObjectPropListElement::EObjectHandle);
+        TUint16 propertyCode = element.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode);
+        TUint16 dataType = element.Uint16L(CMTPTypeObjectPropListElement::EDatatype);
+        __FLOG_VA((_L8("set property, propertycode %d, datatype %d, handle %d"), propertyCode, dataType, handle));
+        
+        responseCode = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, handle, *iObjectMeta);
+        if ((EMTPRespCodeOK == responseCode) && (iObjectMeta->Uint(CMTPObjectMetaData::EDataProviderId) == iFramework.DataProviderId()))
+            {
+            // Object is owned by the FileDp
+            responseCode = CheckPropCode(propertyCode, dataType);
+            if (responseCode == EMTPRespCodeOK)
+                {
+                if(preHandle != handle)
+                    {
+                    iPropertyMgr.SetCurrentObjectL(*iObjectMeta, ETrue);
+                    }
+                
+                switch(propertyCode)
+                    {
+                    case EMTPObjectPropCodeObjectFileName:
+                    case EMTPObjectPropCodeName:
+                    case EMTPObjectPropCodeDateModified:
+                        iPropertyMgr.SetPropertyL(TMTPObjectPropertyCode(propertyCode), element.StringL(CMTPTypeObjectPropListElement::EValue));
+                        objects.ModifyObjectL(*iObjectMeta);
+                        break;
+                    case EMTPObjectPropCodeNonConsumable:
+                        iPropertyMgr.SetPropertyL(TMTPObjectPropertyCode(propertyCode), element.Uint8L(CMTPTypeObjectPropListElement::EValue));
+                        objects.ModifyObjectL(*iObjectMeta);
+                        break;                        
+                    default:
+                        responseCode = EMTPRespCodeInvalidObjectPropCode;
+                        break;
+                    }
+                
+                }
+            if (responseCode != EMTPRespCodeOK)
+                {
+                // Return the index of the failed property in the response.
+                parameter = i;
+                }
+            }
+        preHandle = handle;
+        }
+
+    SendResponseL(responseCode, 1, &parameter);
+    __FLOG(_L8("<< CMTPImageDpSetObjectPropList::DoHandleResponsePhaseL"));
+    return EFalse;
+    }
+
+TBool CMTPImageDpSetObjectPropList::HasDataphase() const
+    {
+    __FLOG(_L8(">> CMTPImageDpSetObjectPropList::HasDataphase"));
+    return ETrue;
+    }
+
+TMTPResponseCode CMTPImageDpSetObjectPropList::CheckPropCode(TUint16 aPropertyCode, TUint16 aDataType) const
+    {
+    __FLOG(_L8(">> CMTPImageDpSetObjectPropList::CheckPropCode"));
+    TMTPResponseCode responseCode = EMTPRespCodeOK;
+    switch(aPropertyCode)
+        {
+        case EMTPObjectPropCodeStorageID:
+        case EMTPObjectPropCodeObjectFormat:
+        case EMTPObjectPropCodeObjectSize:		
+        case EMTPObjectPropCodeParentObject:
+        case EMTPObjectPropCodePersistentUniqueObjectIdentifier:
+        case EMTPObjectPropCodeProtectionStatus:
+        case EMTPObjectPropCodeWidth:
+        case EMTPObjectPropCodeHeight:
+        case EMTPObjectPropCodeImageBitDepth:
+        case EMTPObjectPropCodeRepresentativeSampleFormat:
+        case EMTPObjectPropCodeRepresentativeSampleSize:
+        case EMTPObjectPropCodeRepresentativeSampleHeight:
+        case EMTPObjectPropCodeRepresentativeSampleWidth:
+        case EMTPObjectPropCodeDateCreated:
+            responseCode = 	EMTPRespCodeAccessDenied;
+            break;
+                            
+        case EMTPObjectPropCodeObjectFileName:	
+        case EMTPObjectPropCodeName:
+        case EMTPObjectPropCodeDateModified:
+            if (aDataType != EMTPTypeString)
+                {
+                responseCode = EMTPRespCodeInvalidObjectPropFormat;
+                }
+            break;
+        case EMTPObjectPropCodeNonConsumable:
+            if (aDataType != EMTPTypeUINT8)
+                {
+                responseCode = EMTPRespCodeInvalidObjectPropFormat;
+                }
+            break;            
+        default:
+            responseCode = EMTPRespCodeInvalidObjectPropCode;
+        }
+    __FLOG(_L8("<< CMTPImageDpSetObjectPropList::CheckPropCode"));
+    return responseCode;
+    }
+    
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpsetobjectpropvalue.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,265 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <f32file.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtpobjectmetadata.h>
+              
+#include "mtpimagedpconst.h"
+#include "mtpimagedppanic.h"
+#include "mtpimagedputilits.h"
+#include "cmtpimagedp.h"
+#include "cmtpimagedpobjectpropertymgr.h"
+#include "cmtpimagedpsetobjectpropvalue.h"
+
+__FLOG_STMT(_LIT8(KComponent,"CMTPImageDpSetObjectPropValue");)
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+MMTPRequestProcessor* CMTPImageDpSetObjectPropValue::NewL(
+											MMTPDataProviderFramework& aFramework,
+											MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider)
+	{
+	CMTPImageDpSetObjectPropValue* self = new (ELeave) CMTPImageDpSetObjectPropValue(aFramework, aConnection,aDataProvider);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+Destructor
+*/	
+CMTPImageDpSetObjectPropValue::~CMTPImageDpSetObjectPropValue()
+	{	
+	__FLOG(_L8(">> ~CMTPImageDpSetObjectPropValue"));
+	delete iMTPTypeString;
+	delete iObjectMeta;
+	__FLOG(_L8("<< ~CMTPImageDpSetObjectPropValue"));
+	__FLOG_CLOSE;
+	}
+
+/**
+Standard c++ constructor
+*/	
+CMTPImageDpSetObjectPropValue::CMTPImageDpSetObjectPropValue(
+									MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider)
+	:CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
+	iDataProvider(aDataProvider),
+	iObjectPropertyMgr(aDataProvider.PropertyMgr())
+	{
+	}
+
+									
+/**
+A helper function of CheckRequestL. To check whether the object property code is readonly.
+@param aObjectPropCode the object property code passed in.
+@return ETrue if the object property code is readonly. Otherwise EFalse.
+*/	
+TBool CMTPImageDpSetObjectPropValue::IsPropCodeReadonly(TUint32 aObjectPropCode)
+	{
+	__FLOG(_L8(">> CMTPImageDpSetObjectPropValue::IsPropCodeReadonly"));
+	TBool returnCode = EFalse;
+	if(aObjectPropCode == EMTPObjectPropCodeStorageID
+		|| aObjectPropCode == EMTPObjectPropCodeObjectFormat
+		|| aObjectPropCode == EMTPObjectPropCodeProtectionStatus
+		|| aObjectPropCode == EMTPObjectPropCodeObjectSize
+		|| aObjectPropCode == EMTPObjectPropCodeParentObject
+		|| aObjectPropCode == EMTPObjectPropCodeDateCreated
+		|| aObjectPropCode == EMTPObjectPropCodePersistentUniqueObjectIdentifier
+		|| aObjectPropCode == EMTPObjectPropCodeWidth
+		|| aObjectPropCode == EMTPObjectPropCodeHeight
+		|| aObjectPropCode == EMTPObjectPropCodeImageBitDepth
+		|| aObjectPropCode == EMTPObjectPropCodeRepresentativeSampleFormat
+		|| aObjectPropCode == EMTPObjectPropCodeRepresentativeSampleSize
+		|| aObjectPropCode == EMTPObjectPropCodeRepresentativeSampleHeight
+		|| aObjectPropCode == EMTPObjectPropCodeRepresentativeSampleWidth)
+		{
+		returnCode = ETrue;
+		}
+	__FLOG(_L8("<< CMTPImageDpSetObjectPropValue::IsPropCodeReadonly"));
+	return returnCode;
+	}
+
+/**
+Verify object handle, prop code
+*/
+TMTPResponseCode CMTPImageDpSetObjectPropValue::CheckRequestL()
+	{
+	__FLOG(_L8(">> CMTPImageDpSetObjectPropValue::CheckRequestL"));
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	if(responseCode == EMTPRespCodeOK)
+		{
+		responseCode = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, Request().Uint32(TMTPTypeRequest::ERequestParameter1), *iObjectMeta);
+		}
+	
+	TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+	if(responseCode == EMTPRespCodeOK)
+		{
+			const TInt count = sizeof(KMTPImageDpSupportedProperties) / sizeof(TUint16);
+			TInt i = 0;
+			for(i = 0; i < count; i++)
+				{
+				if(KMTPImageDpSupportedProperties[i] == propCode
+					&& IsPropCodeReadonly(propCode))
+					// Object property code supported, but cann't be set.
+					{
+					responseCode = EMTPRespCodeAccessDenied;
+					break;
+					}
+				else if(KMTPImageDpSupportedProperties[i] == propCode)
+					// Object property code supported and can be set.
+					{
+					break;
+					}
+				}
+			if(i == count)
+				{
+				responseCode = EMTPRespCodeInvalidObjectPropCode;
+				}
+		}
+	__FLOG(_L8("<< CMTPImageDpSetObjectPropValue::CheckRequestL"));
+	return responseCode;
+	}
+		
+/**
+SetObjectPropValue request handler
+*/	
+void CMTPImageDpSetObjectPropValue::ServiceL()
+	{
+	__FLOG(_L8(">> CMTPImageDpSetObjectPropValue::ServiceL"));
+	TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+	delete iMTPTypeString;
+	iMTPTypeString = NULL;
+	iMTPTypeString = CMTPTypeString::NewL();
+	switch(propCode)
+		{
+	    case EMTPObjectPropCodeDateModified:
+		case EMTPObjectPropCodeObjectFileName:
+		case EMTPObjectPropCodeName:
+			ReceiveDataL(*iMTPTypeString);
+			break;
+        case EMTPObjectPropCodeNonConsumable:
+            ReceiveDataL(iMTPTypeUint8);
+            break;			
+		default:
+			User::Leave(KErrGeneral);
+		}	
+	__FLOG(_L8("<< CMTPImageDpSetObjectPropValue::ServiceL"));
+	}
+
+/**
+Apply the references to the specified object
+@return EFalse
+*/	
+TBool CMTPImageDpSetObjectPropValue::DoHandleResponsePhaseL()
+	{
+	__FLOG(_L8(">> CMTPImageDpSetObjectPropValue::DoHandleResponsePhaseL"));
+	
+    iObjectPropertyMgr.SetCurrentObjectL(*iObjectMeta, ETrue);
+    /*
+    [Winlog]If file is readonly, all property of this file shoule not be changed.
+    */
+    TUint16 protection;
+    iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeProtectionStatus, protection);
+    if(EMTPProtectionReadOnly == protection)
+        {
+        SendResponseL(EMTPRespCodeAccessDenied);
+        return EFalse;  
+        }
+	TInt32 handle(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+	
+	switch(propCode)
+		{
+		case EMTPObjectPropCodeDateModified:
+			{
+			if (iMTPTypeString->NumChars() == (iMTPTypeString->StringChars().Length() + 1)) 
+				{
+				iObjectPropertyMgr.SetPropertyL(TMTPObjectPropertyCode(propCode), iMTPTypeString->StringChars());				
+				}
+			else if ( iMTPTypeString->NumChars() == 0 )
+				{
+				responseCode = EMTPRespCodeOK;
+				}			
+			}
+	        break;
+
+		case EMTPObjectPropCodeObjectFileName:
+		case EMTPObjectPropCodeName:
+			{
+			if (iMTPTypeString->NumChars() == (iMTPTypeString->StringChars().Length() + 1)) 
+				{
+				iObjectPropertyMgr.SetPropertyL(TMTPObjectPropertyCode(propCode), iMTPTypeString->StringChars());
+				iFramework.ObjectMgr().ModifyObjectL(*iObjectMeta);
+				}
+			else if ( iMTPTypeString->NumChars() == 0 )
+				{
+				responseCode = EMTPRespCodeOK;
+				}	
+			}
+            break;
+        case EMTPObjectPropCodeNonConsumable:
+            {
+            iObjectPropertyMgr.SetPropertyL(TMTPObjectPropertyCode(propCode), iMTPTypeUint8.Value());
+            iFramework.ObjectMgr().ModifyObjectL(*iObjectMeta);
+            responseCode = EMTPRespCodeOK;
+            }
+            break;            
+ 		default:
+			responseCode = EMTPRespCodeInvalidObjectPropFormat;
+			//Panic(EMTPImageDpUnsupportedProperty);
+		}
+	
+	SendResponseL(responseCode);
+	
+	__FLOG(_L8("<< CMTPImageDpSetObjectPropValue::DoHandleResponsePhaseL"));
+	return EFalse;	
+	}
+	
+TBool CMTPImageDpSetObjectPropValue::HasDataphase() const
+	{
+	return ETrue;
+	}
+	
+/**
+Second-phase construction
+*/			
+void CMTPImageDpSetObjectPropValue::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8(">> CMTPImageDpSetObjectPropList::ConstructL"));
+	
+	iObjectMeta = CMTPObjectMetaData::NewL();
+	
+	__FLOG(_L8("<< CMTPImageDpSetObjectPropList::ConstructL"));
+	}
+
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpsetobjectprotection.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,157 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtptypearray.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpreferencemgr.h>
+#include <mtp/mmtpobjectmgr.h>
+
+#include "cmtpimagedpsetobjectreferences.h"
+#include "mtpimagedputilits.h"
+#include "cmtpimagedp.h"
+#include "cmtpimagedpsetobjectprotection.h"
+
+__FLOG_STMT(_LIT8(KComponent,"SetObjectProtection");)
+
+/**
+Two-phase construction method
+@param aPlugin The data provider plugin
+@param aFramework The data provider framework
+@param aConnection The connection from which the request comes
+@return a pointer to the created request processor object
+*/    
+MMTPRequestProcessor* CMTPImageDpSetObjectProtection::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& /*aDataProvider*/)
+    {
+    CMTPImageDpSetObjectProtection* self = new (ELeave) CMTPImageDpSetObjectProtection(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+CMTPImageDpSetObjectProtection::~CMTPImageDpSetObjectProtection()
+    {
+    __FLOG(_L8(">> CMTPImageDpSetObjectProtection::~CMTPImageDpSetObjectProtection"));
+    delete iObjMeta;
+    __FLOG(_L8("<< CMTPImageDpSetObjectProtection::~CMTPImageDpSetObjectProtection"));
+    
+    __FLOG_CLOSE;
+    }
+
+/**
+Standard c++ constructor
+*/    
+CMTPImageDpSetObjectProtection::CMTPImageDpSetObjectProtection(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    :CMTPRequestProcessor(aFramework, aConnection, 0, NULL), 
+    iRfs(aFramework.Fs())
+    {
+    }
+
+/**
+Second phase constructor
+*/
+void CMTPImageDpSetObjectProtection::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    
+    __FLOG(_L8(">> CMTPImageDpSetObjectProtection::ConstructL"));
+    iObjMeta = CMTPObjectMetaData::NewL();
+    __FLOG(_L8("<< CMTPImageDpSetObjectProtection::ConstructL"));
+    
+    }
+
+TMTPResponseCode CMTPImageDpSetObjectProtection::CheckRequestL()
+    {
+    __FLOG(_L8(">> CMTPImageDpSetObjectProtection::CheckRequestL"));
+    
+    TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    TUint32 statusValue = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+   
+    //Check ObjectHanlde
+    TMTPResponseCode responseCode = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, objectHandle, *iObjMeta);
+    
+    if(EMTPRespCodeOK == responseCode)
+        {    
+        //Check parameter value
+        switch(statusValue)
+            {
+            case EMTPProtectionNoProtection:
+            case EMTPProtectionReadOnly:
+                {
+                responseCode = EMTPRespCodeOK;
+                }
+                break;
+            default:
+                responseCode = EMTPRespCodeInvalidParameter;
+                break;     
+            }
+        }
+    __FLOG_VA((_L8("CheckRequestL - Exit with responseCode = 0x%04X"), responseCode));
+    __FLOG(_L8("<< CMTPImageDpSetObjectProtection::CheckRequestL"));
+    
+    return responseCode;
+    }
+
+
+/**
+Apply the references to the specified object
+@return EFalse
+*/    
+TBool CMTPImageDpSetObjectProtection::DoHandleResponsePhaseL()
+    {
+    return EFalse; 
+    }
+
+/**
+GetReferences request handler
+*/    
+void CMTPImageDpSetObjectProtection::ServiceL()
+    {
+    __FLOG(_L8(">> CMTPImageDpCopyObject::ServiceL"));
+    TUint32 statusValue = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+    TMTPResponseCode responseCode = EMTPRespCodeOK;
+    TInt ret = KErrNone;
+    
+    switch(statusValue)
+        {
+        case EMTPProtectionNoProtection:
+            {
+            ret = iRfs.SetAtt(iObjMeta->DesC(CMTPObjectMetaData::ESuid),KEntryAttNormal,KEntryAttReadOnly);
+            }
+            break;
+        case EMTPProtectionReadOnly:
+            {
+            ret = iRfs.SetAtt(iObjMeta->DesC(CMTPObjectMetaData::ESuid),KEntryAttReadOnly,KEntryAttNormal);
+            }
+            break;
+        default:
+            responseCode = EMTPRespCodeInvalidParameter;
+            break;
+        }
+    
+    if (ret != KErrNone)
+        {
+        responseCode = EMTPRespCodeAccessDenied;
+        }
+    
+    SendResponseL(responseCode);    
+    __FLOG(_L8("<< CMTPImageDpCopyObject::ServiceL"));
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpsetobjectreferences.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,151 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtptypearray.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpreferencemgr.h>
+#include <mtp/mmtpobjectmgr.h>
+
+#include "cmtpimagedpsetobjectreferences.h"
+#include "mtpimagedputilits.h"
+#include "cmtpimagedp.h"
+
+__FLOG_STMT(_LIT8(KComponent,"SetObjectReferences");)
+
+/**
+Two-phase construction method
+@param aPlugin The data provider plugin
+@param aFramework The data provider framework
+@param aConnection The connection from which the request comes
+@return a pointer to the created request processor object
+*/    
+MMTPRequestProcessor* CMTPImageDpSetObjectReferences::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& /*aDataProvider*/)
+    {
+    CMTPImageDpSetObjectReferences* self = new (ELeave) CMTPImageDpSetObjectReferences(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);    
+    return self;
+    }
+
+/**
+Destructor
+*/    
+CMTPImageDpSetObjectReferences::~CMTPImageDpSetObjectReferences()
+    {
+    __FLOG(_L8(">> CMTPImageDpSetObjectReferences::~CMTPImageDpSetObjectReferences"));
+    delete iReferences;
+    __FLOG(_L8("<< CMTPImageDpSetObjectReferences::~CMTPImageDpSetObjectReferences"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Standard c++ constructor
+*/    
+CMTPImageDpSetObjectReferences::CMTPImageDpSetObjectReferences(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    :CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+    {
+    }
+
+/**
+Second phase constructor
+*/
+void CMTPImageDpSetObjectReferences::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8(">> CMTPImageDpSetObjectReferences::ConstructL"));
+    __FLOG(_L8("<< CMTPImageDpSetObjectReferences::ConstructL"));
+    }
+
+TMTPResponseCode CMTPImageDpSetObjectReferences::CheckRequestL()
+    {
+    __FLOG(_L8(">> CMTPImageDpSetObjectReferences::CheckRequestL"));
+    
+    TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    CMTPObjectMetaData* objectInfo = CMTPObjectMetaData::NewLC();    
+    TMTPResponseCode responseCode = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, objectHandle, *objectInfo);      
+    CleanupStack::PopAndDestroy(objectInfo);
+    __FLOG_VA((_L8("CheckRequestL - Exit with responseCode = 0x%04X"), responseCode));
+    __FLOG(_L8("<< CMTPImageDpSetObjectReferences::CheckRequestL"));
+    return responseCode;
+    }
+
+
+/**
+Apply the references to the specified object
+@return EFalse
+*/    
+TBool CMTPImageDpSetObjectReferences::DoHandleResponsePhaseL()
+    {
+    if(!VerifyReferenceHandlesL())
+        {
+        SendResponseL(EMTPRespCodeInvalidObjectReference);
+        }
+    else
+        {
+        MMTPReferenceMgr& referenceMgr = iFramework.ReferenceMgr();
+        TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+        referenceMgr.SetReferencesL(TMTPTypeUint32(objectHandle), *iReferences);
+        SendResponseL(EMTPRespCodeOK);
+        }
+    return EFalse;    
+    }
+
+/**
+GetReferences request handler
+*/    
+void CMTPImageDpSetObjectReferences::ServiceL()
+    {
+    __FLOG(_L8(">> CMTPImageDpCopyObject::ServiceL"));
+    delete iReferences;
+    iReferences = NULL;
+    iReferences = CMTPTypeArray::NewL(EMTPTypeAUINT32);
+    ReceiveDataL(*iReferences);
+    __FLOG(_L8("<< CMTPImageDpCopyObject::ServiceL"));
+    }
+
+TBool CMTPImageDpSetObjectReferences::HasDataphase() const
+    {
+    return ETrue;
+    }
+
+/**
+Verify if the references are valid handles to objects
+@return ETrue if all the references are good, otherwise, EFalse
+*/    
+TBool CMTPImageDpSetObjectReferences::VerifyReferenceHandlesL() const
+    {
+    __ASSERT_DEBUG(iReferences, User::Invariant());
+    TBool result = ETrue;
+    TInt count = iReferences->NumElements();
+    CMTPObjectMetaData* object(CMTPObjectMetaData::NewLC());
+    MMTPObjectMgr& objectMgr = iFramework.ObjectMgr();
+    TMTPTypeUint32 handle;
+    for(TInt i = 0; i < count; i++)
+        {
+        iReferences->ElementL(i, handle);
+        if(!objectMgr.ObjectL(handle, *object))
+            {
+            result = EFalse;
+            break;
+            }
+        }
+    CleanupStack::PopAndDestroy(object);
+    return result; 
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpthumbnailcreator.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,340 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#include <e32base.h>
+#include <e32property.h>
+#include <fbs.h>
+#include <caf/content.h>
+#include <icl/imagedata.h>
+#include <sysutil.h>
+#include <pathinfo.h> // PathInfo
+#include <bautils.h> // FileExists
+#include <mtp/cmtptypeopaquedata.h>
+#include "cmtpimagedpthumbnailcreator.h"
+#include "mtpimagedpconst.h"
+#include "mtpimagedputilits.h"
+
+__FLOG_STMT(_LIT8(KComponent,"CMTPImageDpThumbnailCreator");)
+// --------------------------------------------------------------------------
+// CMTPImageDpThumbnailCreator::NewL
+// 2-phased constructor.
+// --------------------------------------------------------------------------
+//
+CMTPImageDpThumbnailCreator* CMTPImageDpThumbnailCreator::NewL()
+    {
+    CMTPImageDpThumbnailCreator* self= new (ELeave) CMTPImageDpThumbnailCreator();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+ 
+// --------------------------------------------------------------------------
+// CMTPImageDpThumbnailCreator::~CMTPImageDpThumbnailCreator
+// C++ destructor.
+// --------------------------------------------------------------------------
+//    
+CMTPImageDpThumbnailCreator::~CMTPImageDpThumbnailCreator()
+    {
+    __FLOG(_L8(">> ~CMTPImageDpThumbnailCreator"));
+    Cancel();
+    if(EGetting == iState)
+        {
+        iThumbMgr->CancelRequest(iCurrentReq);
+        }
+    delete iData;
+    delete iImgEnc;
+#ifdef MTPTHUMBSCALING
+    delete iScaler;
+#endif
+    delete iBitmap;  
+    delete iObjectSource;
+    delete iThumbMgr;
+    if(iActiveSchedulerWait->IsStarted())
+        {
+        *iCreationErr = KErrNotReady;
+        iActiveSchedulerWait->AsyncStop();
+        }
+    delete iActiveSchedulerWait;
+    __FLOG(_L8("<< ~CMTPImageDpThumbnailCreator"));
+    __FLOG_CLOSE;
+    }
+ 
+// --------------------------------------------------------------------------
+// CMTPImageDpThumbnailCreator::CMTPImageDpThumbnailCreator
+// C++ constructor.
+// --------------------------------------------------------------------------
+//    
+CMTPImageDpThumbnailCreator::CMTPImageDpThumbnailCreator(): 
+CActive(EPriorityStandard)
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("CMTPImageDpThumbnailCreator::CMTPImageDpThumbnailCreator(), begin"));
+    CActiveScheduler::Add(this);  
+    __FLOG(_L8("CMTPImageDpThumbnailCreator::CMTPImageDpThumbnailCreator(), end"));
+    }
+
+// --------------------------------------------------------------------------
+// CMTPImageDpThumbnailCreator::ConstructL
+// 2nd phase constructor.
+// --------------------------------------------------------------------------
+//
+void CMTPImageDpThumbnailCreator::ConstructL()
+    {
+    __FLOG(_L8("CMTPImageDpThumbnailCreator::ConstructL(), begin"));
+    iThumbMgr = CThumbnailManager::NewL( *this ); 
+    iThumbMgr->SetThumbnailSizeL( EFullScreenThumbnailSize );
+#ifdef MTPTHUMBSCALING
+    iScaler = CBitmapScaler::NewL();
+#endif    
+    iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait();
+    __FLOG(_L8("CMTPImageDpThumbnailCreator::ConstructL(), end"));
+    }
+
+// --------------------------------------------------------------------------
+// CMTPImageDpThumbnailCreator::DoCancel
+// From CActive.
+// --------------------------------------------------------------------------
+//
+void CMTPImageDpThumbnailCreator::DoCancel()
+    {
+    __FLOG_VA((_L8(">> CMTPImageDpThumbnailCreator::DoCancel() iState %d iStatus 0x%X"), iState, iStatus.Int()));
+    switch(iState)
+        {
+#ifdef MTPTHUMBSCALING
+        case EScaling:
+            iScaler->Cancel();
+            break;
+#endif
+        case EEncoding:
+            iImgEnc->Cancel();
+            break;
+        default:
+            break;
+        }
+    if(iActiveSchedulerWait->IsStarted())
+        {
+        *iCreationErr = KErrCancel;
+        iActiveSchedulerWait->AsyncStop();
+        }
+    // we will not continue creating thumbs.
+    __FLOG_VA((_L8("<< CMTPImageDpThumbnailCreator::DoCancel() iState %d"), iState));
+    }
+
+// --------------------------------------------------------------------------
+// CMTPImageDpThumbnailCreator::RunL
+// From CActive.
+// --------------------------------------------------------------------------
+//    
+void CMTPImageDpThumbnailCreator::RunL()
+    {
+    __FLOG_VA((_L8(">> CMTPImageDpThumbnailCreator::RunL() iState %d iStatus %d"), iState, iStatus.Int()));
+    User::LeaveIfError(iStatus.Int());
+    switch (iState)
+        { 
+#ifdef MTPTHUMBSCALING
+        case EGetted:
+            {
+            ScaleBitmap();
+            iState = EScaling;
+            break;
+            }
+#endif
+        case EScaling:
+            {
+            EncodeImageL( );
+            iState=EEncoding;
+            break;
+            }
+        case EEncoding:
+            {
+            iState=EIdle;
+            if (iThumbMgr->Flags() == CThumbnailManager::EDoNotCreate)
+                {
+                __FLOG_VA((_L8("CMTPImageDpThumbnailCreator::RunL(),EDoNotCreate; iState %d"), iState));
+                delete iData;
+                iData = HBufC8::NewL(1);
+                iBuffer->Write(*iData);
+                }
+            else{
+                iBuffer->Write(*iData);
+                }
+            
+            __FLOG_VA((_L8("<< CMTPImageDpThumbnailCreator::RunL(),iBuffer->Write(*iData); iState %d"), iState));
+            if(iActiveSchedulerWait->IsStarted())
+                {
+                iActiveSchedulerWait->AsyncStop();
+                }
+            break;
+            }
+        default:
+            {
+            User::Leave(KErrGeneral);
+            break;
+            }
+        }
+    __FLOG_VA((_L8("<< CMTPImageDpThumbnailCreator::RunL() iState %d"), iState));
+    }
+
+// --------------------------------------------------------------------------
+// RunError
+// --------------------------------------------------------------------------
+//    
+TInt CMTPImageDpThumbnailCreator::RunError(TInt aErr)
+    {
+    __FLOG_VA((_L8(">> CMTPImageDpThumbnailCreator::RunError() err 0x%X"), aErr));
+    iState=EIdle;
+    if(iActiveSchedulerWait->IsStarted())
+        {
+        *iCreationErr = aErr;
+        iActiveSchedulerWait->AsyncStop();
+        }
+    // no need to cancel iScalerP since only leave is issued if scaler creation fails
+    __FLOG(_L8("<< CMTPImageDpThumbnailCreator::RunError()"));
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+void CMTPImageDpThumbnailCreator::GetThumbnailL(const TDesC& aFileName, CMTPTypeOpaqueData& aThumbName,  TInt& result)
+    {
+    __FLOG(_L8(">> CMtpImageDphumbnailCreator::GetThumbnailL()"));
+    iBuffer = &aThumbName;
+    GetThumbL(aFileName);
+    iCreationErr = &result;		//reset the err flag
+    *iCreationErr = KErrNone;
+    __FLOG(_L8("<< CMTPImageDpThumbnailCreator::CreateThumbnailL()"));
+    iActiveSchedulerWait->Start();
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+void CMTPImageDpThumbnailCreator::ClearThumbnailData()
+    {
+    delete iData;
+    iData = NULL;
+    delete iBitmap;
+    iBitmap = NULL;
+    delete iObjectSource;
+    iObjectSource = NULL;
+    delete iImgEnc;
+    iImgEnc = NULL;
+    }
+
+void CMTPImageDpThumbnailCreator::GetThumbL(const TDesC& aFileName)
+    {
+    __FLOG(_L8(">> CMtpImageDphumbnailCreator::GetThumbL()"));
+    // Create an object source representing a path to a file on local
+    // file system.
+    delete iObjectSource;
+    iObjectSource = NULL;
+    
+    iObjectSource = CThumbnailObjectSource::NewL(aFileName, KJpegMimeType);
+    iCurrentReq = iThumbMgr->GetThumbnailL( *iObjectSource );
+    iState = EGetting;
+    __FLOG(_L8("<< CMtpImageDphumbnailCreator::GetThumbL()"));
+    }
+
+#ifdef MTPTHUMBSCALING
+// --------------------------------------------------------------------------
+// CMTPImageDpThumbnailCreator::ScaleBitmapL
+// Scales the bitmap to the thumbnail size.
+// --------------------------------------------------------------------------
+//
+void CMTPImageDpThumbnailCreator::ScaleBitmap()
+    {
+    __FLOG(_L8("CMTPImageDpThumbnailCreator::ScaleBitmapL(), begin"));
+    TSize size( KThumbWidht, KThumbHeigth ); // size 160x120      
+    // Resize image to thumbnail size 
+    iScaler->Scale( &iStatus, *iBitmap, size );
+    SetActive();
+    __FLOG(_L8("CMTPImageDpThumbnailCreator::ScaleBitmapL(), end"));
+    }
+#endif
+
+// --------------------------------------------------------------------------
+// CMTPImageDpThumbnailCreator::EncodeImageL
+// Encodes bitmap as a jpeg image.
+// --------------------------------------------------------------------------
+//
+void CMTPImageDpThumbnailCreator::EncodeImageL( )
+    {
+    __FLOG(_L8(">> CMTPImageDpThumbnailCreator::EncodeImageL()"));
+
+    delete iData;
+    iData = NULL;
+    
+    delete iImgEnc;
+    iImgEnc = NULL;
+    
+    // Convert bitmap to jpg
+    iImgEnc = CImageEncoder::DataNewL( iData, KPtpMimeJPEG, CImageEncoder::EPreferFastEncode );
+    iImgEnc->Convert( &iStatus, *iBitmap );
+    SetActive();
+    __FLOG(_L8("<< CMTPImageDpThumbnailCreator::EncodeImageL()"));
+    }
+
+//
+//
+void CMTPImageDpThumbnailCreator::ThumbnailReady( TInt aError, MThumbnailData& aThumbnail, TThumbnailRequestId aId )
+    {
+    // This function must not leave.
+    __FLOG(_L8(">> CMTPImageDpThumbnailCreator::ThumbnailReady()"));
+    if(iCurrentReq != aId)
+        {
+        __FLOG(_L8("CMTPImageDpThumbnailCreator::ThumbnailReady(),iCurrentReq != aId"));
+        return;
+        }
+    if (aError == KErrNone)
+        {
+        TRAP_IGNORE(iThumbMgr->SetFlagsL(CThumbnailManager::EDefaultFlags));
+        delete iBitmap;   
+        // Claim ownership of the bitmap instance for later use
+        iBitmap = aThumbnail.DetachBitmap();
+#ifdef MTPTHUMBSCALING
+        iState = EGetted;
+#else
+        iState = EScaling;				//direct set to Scaling state jump the scaling function
+#endif
+        }
+    else if ((iThumbMgr->Flags() == CThumbnailManager::EDoNotCreate) && (aError == KErrNotFound))
+        {
+        __FLOG(_L8("CMTPImageDpThumbnailCreator::ThumbnailReady(),EDoNotCreate, KErrNotFound"));
+        iState = EEncoding;
+        iThumbMgr->CreateThumbnails(*iObjectSource);
+        aError = KErrNone;
+        }
+    iStatus=KRequestPending;
+    TRequestStatus* status=&iStatus;
+    User::RequestComplete(status, aError);
+    SetActive();
+    __FLOG(_L8("<< CMTPImageDpThumbnailCreator::ThumbnailReady()"));
+    }
+
+void CMTPImageDpThumbnailCreator::ThumbnailPreviewReady( MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ )
+    {
+    
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/mtpimagedp.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,45 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <ecom/registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = 0x2001FCA2;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x102827AD;
+			implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x2001FCAE;
+					version_no = 1;
+					display_name = "MTP Image Data Provider plug-in.";
+                			default_data = "jpeg";
+					opaque_data = "KMediaSyncServerAddition||KMediaSyncServerRemoval";
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/mtpimagedp_config.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,35 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+//     supported_modes = KMTPModeMTP | KMTPModePTP | KMTPModePictBridge;  
+
+#include <mtp/mtpdataproviderconfig.rh>
+
+RESOURCE MTP_DATA_PROVIDER dpConfig
+    {
+    type = KMTPDataProviderTypeECOM;
+    major_version = 1;
+    object_enumeration_persistent = 0;
+    supported_modes = KMTPModeMTP;
+    server_name = "";
+    server_image_name = "";
+    opaque_resource = 0;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/mtpimagedpgetformatcapabilities.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,280 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <mtp/cmtptypeinterdependentpropdesc.h>
+#include <mtp/cmtptypeobjectpropdesc.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/cmtptypestring.h>
+
+#include "cmtpimagedpgetformatcapabilities.h"
+#include "cmtpimagedp.h"
+
+__FLOG_STMT(_LIT8(KComponent,"ImageDpGetFormatCapabilities");)
+MMTPRequestProcessor* CMTPImageDpGetFormatCapabilities::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& /*aDataProvider*/)
+    {
+    CMTPImageDpGetFormatCapabilities* self = new (ELeave) CMTPImageDpGetFormatCapabilities(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+    
+CMTPImageDpGetFormatCapabilities::~CMTPImageDpGetFormatCapabilities()
+    {
+    __FLOG(_L8(">> ~CMTPPictureDpGetObject"));
+    delete iCapabilityList;
+    __FLOG(_L8("<< ~CMTPPictureDpGetObject"));
+    __FLOG_CLOSE;
+    }
+
+void CMTPImageDpGetFormatCapabilities::ServiceL()
+    {
+    __FLOG(_L8(">> CMTPPictureDpGetFormatCapabilities::ServiceL"));
+    delete iCapabilityList;
+    iCapabilityList = NULL;
+    iCapabilityList = CMTPTypeFormatCapabilityList::NewL();
+    BuildFormatExifJpegL();
+    SendDataL(*iCapabilityList); 
+    __FLOG(_L8("<< CMTPPictureDpGetFormatCapabilities::ServiceL"));   
+    }
+    
+void CMTPImageDpGetFormatCapabilities::BuildFormatExifJpegL()
+    {
+    __FLOG(_L8(">> CMTPPictureDpGetFormatCapabilities::BuildFormatExifJpegL"));
+    CMTPTypeInterdependentPropDesc*  interDesc = CMTPTypeInterdependentPropDesc::NewLC();
+    CMTPTypeFormatCapability* frmCap = CMTPTypeFormatCapability::NewLC( EMTPFormatCodeEXIFJPEG ,interDesc );
+    
+    //EMTPObjectPropCodeStorageID
+    CMTPTypeObjectPropDesc* desc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeStorageID);
+    desc->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodeStorageID)); 
+    frmCap->AppendL(desc);
+    CleanupStack::Pop(1, desc);
+    
+    //EMTPObjectPropCodeObjectFormat
+    desc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeObjectFormat);
+    desc->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodeObjectFormat));
+    frmCap->AppendL(desc);
+    CleanupStack::Pop(1, desc);
+    
+    //EMTPObjectPropCodeProtectionStatus
+    frmCap->AppendL( ServiceProtectionStatusL() );
+    
+    //EMTPObjectPropCodeObjectSize
+    desc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeObjectSize);
+    desc->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodeObjectSize));
+    frmCap->AppendL(desc);
+    CleanupStack::Pop(1, desc);
+    
+    //EMTPObjectPropCodeObjectFileName
+    _LIT(KMtpObjDescObjFileName, "[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 7}\\.[[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 2}]?");
+    CMTPTypeString* form = CMTPTypeString::NewLC( KMtpObjDescObjFileName );
+    desc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeObjectFileName, CMTPTypeObjectPropDesc::ERegularExpressionForm, form);
+    desc->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodeObjectFileName));
+    frmCap->AppendL(desc);
+    CleanupStack::Pop(1, desc); 
+    CleanupStack::PopAndDestroy(form ); 
+    
+    //EMTPObjectPropCodeDateModified
+    desc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeDateModified);
+    desc->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodeDateModified));
+    frmCap->AppendL(desc);
+    CleanupStack::Pop(1, desc);
+    
+    //EMTPObjectPropCodeParentObject
+    desc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeParentObject);
+    desc->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodeParentObject));
+    frmCap->AppendL(desc);
+    CleanupStack::Pop(1, desc);
+    
+    //EMTPObjectPropCodePersistentUniqueObjectIdentifier
+    desc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodePersistentUniqueObjectIdentifier);
+    desc->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodePersistentUniqueObjectIdentifier));
+    frmCap->AppendL(desc);
+    CleanupStack::Pop(1, desc);
+
+    //EMTPObjectPropCodeName
+    desc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeName);
+    desc->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodeName));
+    frmCap->AppendL(desc);
+    CleanupStack::Pop(1, desc);
+    
+    //EMTPObjectPropCodeNonConsumable
+    frmCap->AppendL(ServiceNonConsumableL() );
+    
+    
+    
+    CMTPTypeObjectPropDesc::TPropertyInfo info;
+    info.iDataType     = EMTPTypeString;
+    info.iFormFlag     = CMTPTypeObjectPropDesc::EDateTimeForm;
+    info.iGetSet       = CMTPTypeObjectPropDesc::EReadOnly;
+    //EMTPObjectPropCodeDateCreated
+    desc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeDateCreated, info, NULL);
+    desc->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodeDateCreated));
+    frmCap->AppendL(desc);
+    CleanupStack::Pop(1, desc);
+    
+    info.iDataType     = EMTPTypeUINT32;
+    info.iFormFlag     = CMTPTypeObjectPropDesc::ERangeForm;
+    
+    CMTPTypeObjectPropDescRangeForm* expectedForm = CMTPTypeObjectPropDescRangeForm::NewLC(EMTPTypeUINT32);
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EMinimumValue, 0x00000001);
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EMaximumValue, 0x20000000);
+    expectedForm->SetUint32L(CMTPTypeObjectPropDescRangeForm::EStepSize, 0x00000001);
+    desc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeWidth, info, expectedForm);
+    desc->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodeWidth));
+    frmCap->AppendL(desc);
+    CleanupStack::Pop(1, desc);
+    
+    desc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeHeight, info, expectedForm);
+    desc->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodeHeight));
+    frmCap->AppendL(desc);
+    CleanupStack::Pop(1, desc);
+    
+    desc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeImageBitDepth, info, expectedForm);
+    desc->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodeImageBitDepth));
+    frmCap->AppendL(desc);
+    CleanupStack::Pop(1, desc);
+    
+    desc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeRepresentativeSampleSize, info, expectedForm);
+    desc->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodeRepresentativeSampleSize));
+    frmCap->AppendL(desc);
+    CleanupStack::Pop(1, desc);
+    
+    desc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeRepresentativeSampleHeight, info, expectedForm);
+    desc->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodeRepresentativeSampleHeight));
+    frmCap->AppendL(desc);
+    CleanupStack::Pop(1, desc);
+    
+    desc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeRepresentativeSampleWidth, info, expectedForm);
+    desc->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodeRepresentativeSampleWidth));
+    frmCap->AppendL(desc);
+    CleanupStack::Pop(1, desc);
+    CleanupStack::PopAndDestroy(expectedForm);
+    
+    info.iDataType = EMTPTypeUINT16;
+    info.iFormFlag = CMTPTypeObjectPropDesc::EEnumerationForm;
+    CMTPTypeObjectPropDescEnumerationForm* expectedEnumForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT16);
+    CleanupStack::PushL(expectedEnumForm);
+    TUint16 values[] = {EMTPFormatCodeEXIFJPEG};
+    TUint   numValues((sizeof(values) / sizeof(values[0])));
+    for (TUint i = 0; i < numValues; i++)
+        {
+        TMTPTypeUint16 data(values[i]);
+        expectedEnumForm->AppendSupportedValueL(data);
+        }
+    desc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeRepresentativeSampleFormat, info, expectedEnumForm);
+    desc->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodeRepresentativeSampleFormat));
+    frmCap->AppendL(desc);
+    CleanupStack::Pop(1, desc);
+    CleanupStack::PopAndDestroy(expectedEnumForm);
+    
+    iCapabilityList->AppendL(frmCap);
+    CleanupStack::Pop(frmCap);
+    CleanupStack::Pop(interDesc);
+    __FLOG(_L8("<< CMTPPictureDpGetFormatCapabilities::BuildFormatExifJpegL"));
+    }
+
+
+CMTPTypeObjectPropDesc* CMTPImageDpGetFormatCapabilities::ServiceProtectionStatusL()
+    {
+    __FLOG(_L8(">> CMTPPictureDpGetFormatCapabilities::ServiceProtectionStatusL"));
+    CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT16);
+    CleanupStack::PushL(expectedForm);
+    //Currently, we only support EMTPProtectionNoProtection and EMTPProtectionReadOnly
+//  TUint16 values[] = {EMTPProtectionNoProtection, EMTPProtectionReadOnly, EMTPProtectionReadOnlyData, EMTPProtectionNonTransferable};
+    TUint16 values[] = {EMTPProtectionNoProtection, EMTPProtectionReadOnly};
+    TUint   numValues((sizeof(values) / sizeof(values[0])));
+    for (TUint i = 0; i < numValues; i++)
+        {
+        TMTPTypeUint16 data(values[i]);
+        expectedForm->AppendSupportedValueL(data);
+        }
+    CMTPTypeObjectPropDesc* ret = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeProtectionStatus, *expectedForm);
+    ret->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodeProtectionStatus));
+    CleanupStack::Pop(1, ret);
+    CleanupStack::PopAndDestroy(expectedForm);
+    __FLOG(_L8("<< CMTPPictureDpGetFormatCapabilities::ServiceProtectionStatusL"));
+    return ret;
+   
+    }
+
+CMTPTypeObjectPropDesc* CMTPImageDpGetFormatCapabilities::ServiceNonConsumableL()
+    {
+    __FLOG(_L8(">> CMTPPictureDpGetFormatCapabilities::ServiceNonConsumableL"));
+    CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT8);
+    CleanupStack::PushL(expectedForm);
+    TUint8 values[] = {0,1};
+    TUint   numValues((sizeof(values) / sizeof(values[0])));
+    for (TUint i = 0; i < numValues; i++)
+        {
+        TMTPTypeUint8 data(values[i]);
+        expectedForm->AppendSupportedValueL(data);
+        }   
+    CMTPTypeObjectPropDesc* ret = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeNonConsumable, *expectedForm);
+    ret->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, GetPropertyGroupNumber(EMTPObjectPropCodeNonConsumable));
+    CleanupStack::Pop(1, ret);
+    CleanupStack::PopAndDestroy(expectedForm);
+    __FLOG(_L8("<< CMTPPictureDpGetFormatCapabilities::ServiceNonConsumableL"));
+    return ret;
+    }
+
+
+TMTPResponseCode CMTPImageDpGetFormatCapabilities::CheckRequestL()
+    {
+    __FLOG(_L8(">> CMTPPictureDpGetFormatCapabilities::CheckRequestL"));
+    iFormatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    if((iFormatCode != EMTPFormatCodeEXIFJPEG) && (iFormatCode != KMTPFormatsAll))
+        {
+        return EMTPRespCodeInvalidObjectFormatCode;
+        }
+    __FLOG(_L8("<< CMTPPictureDpGetFormatCapabilities::CheckRequestL"));   
+    return EMTPRespCodeOK; 
+    }
+    
+
+CMTPImageDpGetFormatCapabilities::CMTPImageDpGetFormatCapabilities(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+    {
+    }
+    
+void CMTPImageDpGetFormatCapabilities::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8(">> CMTPPictureDpGetFormatCapabilities::ConstructL"));
+    __FLOG(_L8("<< CMTPPictureDpGetFormatCapabilities::ConstructL"));
+    }
+
+TUint16 CMTPImageDpGetFormatCapabilities::GetPropertyGroupNumber(const TUint16 aPropCode) const
+    {
+    for( TInt propCodeIndex = 0 ; propCodeIndex < KMTPImageDpGroupOneSize ; propCodeIndex++)
+        {
+            if(KMTPImageDpGroupOneProperties[propCodeIndex] == aPropCode)
+                {
+                return KMTPImageDpPropertyGroupOneNumber;
+                }
+        }
+    
+    // if not foud, the group number should be 0.
+    return 0;
+    }
+   
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/mtpimagedpimplementations.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,40 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <ecom/implementationproxy.h>
+#include "cmtpimagedp.h"
+
+
+// Define the interface UIDs
+static const TImplementationProxy ImplementationTable[] =
+    {
+        {
+        {0x2001FCAE}, (TProxyNewLPtr)(CMTPImageDataProvider::NewL)
+        }
+    };
+
+/**
+ECOM entry point
+*/
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/mtpimagedprequestprocessor.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,134 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+
+#include <mtp/tmtptyperequest.h>
+
+#include "mtpimagedpconst.h"
+#include "cmtprequestprocessor.h"
+#include "mtpimagedprequestprocessor.h"
+
+//processors
+#include "cmtpimagedpgetobjectpropdesc.h"
+#include "cmtpimagedpgetobjectproplist.h"
+#include "cmtpimagedpgetobject.h"
+#include "cmtpimagedpgetobjectinfo.h"
+#include "cmtpimagedpgetthumb.h"
+#include "cmtpimagedpgetobjectpropssupported.h"
+#include "cmtpimagedpsendobjectinfo.h"
+#include "cmtpimagedpgetpartialobject.h"
+#include "cmtpimagedpcopyobject.h"
+#include "cmtpimagedpmoveobject.h"
+#include "cmtpimagedpdeleteobject.h"
+#include "cmtpimagedpgetobjectpropvalue.h"
+#include "cmtpimagedpsetobjectpropvalue.h"
+#include "cmtpimagedpsetobjectproplist.h"
+#include "cmtpimagedpgetformatcapabilities.h"
+#include "cmtpimagedpgetobjectreferences.h"
+#include "cmtpimagedpsetobjectreferences.h"
+#include "cmtprequestunknown.h"
+#include "cmtpimagedpsetobjectprotection.h"
+
+/** 
+Defines a processor factory function pointer
+*/
+typedef MMTPRequestProcessor* (*TMTPImageDpRequestProcessorCreateFunc)(
+                                                                MMTPDataProviderFramework& aFramework, 
+                                                                MMTPConnection& aConnection,
+                                                                CMTPImageDataProvider& aDataProvider);
+
+/** 
+Defines an entry which maps from operation code to the request processor
+*/
+typedef struct 
+	{
+	TUint16                                  iOperationCode;
+	TMTPImageDpRequestProcessorCreateFunc    iCreateFunc;
+	}TMTPImageDpRequestProcessorEntry;
+
+/**
+A mapping table from the operation code to the request processor factory method
+*/
+
+// --------------------------------------------------------------------------
+// A mapping table from the operation code to the request processor factory method
+// --------------------------------------------------------------------------
+//
+static const TMTPImageDpRequestProcessorEntry KMTPImageDpRequestProcessorTable[] = 
+	{
+	{EMTPOpCodeGetObjectInfo, CMTPImageDpGetObjectInfo::NewL},
+	{EMTPOpCodeGetObject,  CMTPImageDpGetObject::NewL},
+	{EMTPOpCodeGetPartialObject,  CMTPImageDpGetPartialObject::NewL},		
+    {EMTPOpCodeGetThumb, CMTPImageDpGetThumb::NewL}, 
+	{EMTPOpCodeGetObjectPropsSupported, CMTPImageDpGetObjectPropsSupported::NewL}, 
+	{EMTPOpCodeGetObjectPropDesc, CMTPImageDpGetObjectPropDesc::NewL},
+	{EMTPOpCodeGetObjectPropValue, CMTPImageDpGetObjectPropValue::NewL},
+	{EMTPOpCodeGetObjectPropList, CMTPImageDpGetObjectPropList::NewL},
+	{EMTPOpCodeGetObjectReferences, CMTPImageDpGetObjectReferences::NewL},
+	{EMTPOpCodeSetObjectReferences, CMTPImageDpSetObjectReferences::NewL},
+	{EMTPOpCodeDeleteObject, CMTPImageDpDeleteObject::NewL},		
+	{EMTPOpCodeSendObjectInfo,  CMTPImageDpSendObjectInfo::NewL},
+	{EMTPOpCodeSendObject,  CMTPImageDpSendObjectInfo::NewL},	//force the SendObject request to be processed by the SendObjectInfo processor 
+	{EMTPOpCodeSendObjectPropList, CMTPImageDpSendObjectInfo::NewL},	//force the SendObjectPropList request to be processed by the SendObjectInfo processor 
+	{EMTPOpCodeSetObjectPropValue, CMTPImageDpSetObjectPropValue::NewL},
+	{EMTPOpCodeSetObjectPropList, CMTPImageDpSetObjectPropList::NewL},	
+	{EMTPOpCodeMoveObject, CMTPImageDpMoveObject::NewL},	
+	{EMTPOpCodeCopyObject, CMTPImageDpCopyObject::NewL},
+	{EMTPOpCodeGetFormatCapabilities,CMTPImageDpGetFormatCapabilities::NewL},
+	{EMTPOpCodeSetObjectProtection,CMTPImageDpSetObjectProtection::NewL},
+	};
+
+// --------------------------------------------------------------------------
+// Create a request processor that matches the request
+// @param aPlugin	The reference to the data provider plugin 
+// @param aFramework The reference to the data provider framework
+// @param aRequest	The request to be processed
+// @param aConnection The connection from which the request comes from
+// @return a pointer to the request processor
+// --------------------------------------------------------------------------
+//
+MMTPRequestProcessor* MTPImageDpProcessor::CreateL(
+													MMTPDataProviderFramework& aFramework,
+													const TMTPTypeRequest& aRequest, 
+													MMTPConnection& aConnection,
+													CMTPImageDataProvider& aDataProvider)
+	{
+    TMTPImageDpRequestProcessorCreateFunc createFunc = NULL; 
+	TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
+	TInt count = sizeof(KMTPImageDpRequestProcessorTable) / sizeof(TMTPRequestProcessorEntry);
+
+	for(TInt i = 0; i < count; i++)
+		{
+		if(KMTPImageDpRequestProcessorTable[i].iOperationCode == operationCode)
+			{
+			createFunc = KMTPImageDpRequestProcessorTable[i].iCreateFunc;
+			break;
+			}
+		}
+		
+	if(!createFunc)	
+		{
+		return CMTPRequestUnknown::NewL(aFramework, aConnection);
+		}
+	else
+	    {
+	    return (*createFunc)(aFramework, aConnection, aDataProvider);
+	    }
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/mtpimagedputilits.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,92 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <f32file.h>
+#include <centralrepository.h>
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/mmtpobjectmgr.h>
+
+#include "mtpimagedpconst.h"
+#include "mtpimagedputilits.h"
+#include "cmtpimagedp.h"
+
+TMTPResponseCode MTPImageDpUtilits::VerifyObjectHandleL(MMTPDataProviderFramework& aFramework, const TMTPTypeUint32& aHandle, CMTPObjectMetaData& aMetaData)
+	{
+	if (!aFramework.ObjectMgr().ObjectL(aHandle, aMetaData))
+		{
+		 return EMTPRespCodeInvalidObjectHandle;
+		}
+	return EMTPRespCodeOK;
+	}
+
+TInt32 MTPImageDpUtilits::FindStorage(MMTPDataProviderFramework& aFramework, const TDesC& aPath)
+    {
+    TParsePtrC parse(aPath);
+
+    TPtrC drive(parse.Drive());
+    TInt driveNumber;  
+    aFramework.Fs().CharToDrive(drive[0], driveNumber);
+    
+    return aFramework.StorageMgr().FrameworkStorageId(static_cast<TDriveNumber>(driveNumber));
+    }
+
+TUint32 MTPImageDpUtilits::FindParentHandleL(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider, const TDesC& aFullPath)
+    {
+    TUint32 parentHandle = KMTPHandleNoParent;
+    TParsePtrC parse(aFullPath);
+    
+    if(!parse.IsRoot())
+        {   
+        if (!aDataProvider.GetCacheParentHandle(parse.DriveAndPath(), parentHandle))
+            {
+            parentHandle = aFramework.ObjectMgr().HandleL(parse.DriveAndPath());
+            if (parentHandle == KMTPHandleNone)
+                {
+                parentHandle = KMTPHandleNoParent;
+                }        
+            else
+                {
+                aDataProvider.SetCacheParentHandle(parse.DriveAndPath(), parentHandle);
+                }
+            }
+        }
+    
+    return parentHandle;    
+    }
+
+void MTPImageDpUtilits::UpdateNewPicturesValue(CMTPImageDataProvider& aDataProvider, TInt aNewPics, TBool aSetRProperty)
+    {    
+    TInt preNewPic = 0;
+    aDataProvider.Repository().Get(ENewImagesCount, preNewPic);
+    
+    TInt newPics = aNewPics + preNewPic;
+    aDataProvider.Repository().Set(ENewImagesCount, newPics);
+    
+    TInt curValue = 0;
+    RProperty::Get(TUid::Uid(KMTPServerUID), KMTPNewPicKey, curValue);
+    
+    if (aSetRProperty && curValue != newPics)
+        {
+        RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, newPics);
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,32 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#if !defined(GCCXML)  // NO GCCXML
+
+PRJ_PLATFORMS
+
+
+PRJ_MMPFILES
+../group/rptp.mmp
+../group/mtppictbridgedp.mmp
+
+
+PRJ_EXPORTS
+../inc/rptp.h         SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(rptp.h)
+./mtppictbridgedp.iby /epoc32/rom/include/mtppictbridgedp.iby
+./rptp.iby            CORE_MW_LAYER_IBY_EXPORT_PATH(rptp.iby)
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/group/mtp_pictbridgedp.mrp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	mtp_pictbridgedp
+source \sf\mw\remoteconn\mtpdataproviders\mtppictbridgedp
+
+binary	\sf\mw\remoteconn\mtpdataproviders\mtppictbridgedp\group all
+exports	\sf\mw\remoteconn\mtpdataproviders\mtppictbridgedp\group
+
+notes_source	\component_defs\release.src
+
+ipr E 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/group/mtppictbridgedp.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,31 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef MTPPICTBRIDGEDP_IBY
+#define MTPPICTBRIDGEDP_IBY
+
+#include <mtp_framework.iby>
+#include <rptp.iby>
+
+#ifdef __USB_PICTBRIDGE 
+
+// MTP data provider
+ECOM_PLUGIN(mtppictbridgedp.dll, mtppictbridgedp.rsc)
+
+data=EPOCROOT##epoc32\data\Z\resource\mtp\2001FE3C.rsc  resource\mtp\2001FE3C.rsc   
+
+#endif
+
+#endif //MTPPICTBRIDGEDP_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/group/mtppictbridgedp.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,77 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <comms-infras/commsdebugutility.mmh> 
+
+TARGET          mtppictbridgedp.dll
+TARGETTYPE      PLUGIN
+UID             0x10009D8D 0x2001FE3B
+CAPABILITY      CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData
+VENDORID        0x101FB657
+
+MW_LAYER_SYSTEMINCLUDE
+
+// framework
+SOURCEPATH      ../src
+
+SOURCE          mtppictbridgerequestprocessor.cpp
+SOURCE          cmtppictbridgedp.cpp
+SOURCE          cmtppictbridgeenumerator.cpp
+SOURCE          mtppictbridgedpimplementations.cpp
+SOURCE          cptpserver.cpp
+SOURCE          cptpsession.cpp
+SOURCE          cptptimer.cpp
+SOURCE          cptpreceivedmsghandler.cpp
+SOURCE          cmtppictbridgeprinter.cpp
+SOURCE          cmtppictbridgeusbconnection.cpp
+SOURCE          cmtppictbridgedpgetobject.cpp
+SOURCE          cmtppictbridgedpgetobjectinfo.cpp
+SOURCE          cmtppictbridgedpsendobjectinfo.cpp
+
+
+// ECOM resource
+START RESOURCE      mtppictbridgedp.rss    
+TARGET              mtppictbridgedp.rsc
+END
+
+// Data provider configuration resource file. 
+// The target filename corresponds to the implementation UID.
+START RESOURCE      mtppictbridgedp_config.rss   
+TARGETPATH          /resource/mtp
+TARGET              2001fe3c.rsc
+END
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../mtpfws/mtpfw/dataproviders/dputility/inc
+USERINCLUDE     ../../../mtpfws/mtpfw/common/inc
+USERINCLUDE     ../../../mtpfws/mtpfw/inc
+USERINCLUDE     ../../../mtpfws/mtpfw/datatypes/inc
+USERINCLUDE     ../../../mtpfws/mtpfw/transports/transportapi/inc
+
+LIBRARY             featmgr.lib                         // For feature support management 
+LIBRARY             mtpdataproviderapi.lib
+LIBRARY             mtpdataproviderutility.lib
+LIBRARY             mtpdatatypes.lib
+LIBRARY             mtpframework.lib   //required by setobjectproplist.
+LIBRARY             euser.lib  
+LIBRARY             bafl.lib        // BaflUtils
+LIBRARY             edbms.lib       // db stuff
+LIBRARY             efsrv.lib 
+LIBRARY             estor.lib       // CFileStore
+#ifndef __TEST_IN_SYMBIAN_
+LIBRARY             platformenv.lib // PathInfo
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/group/rptp.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -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 RPTP_IBY
+#define RPTP_IBY
+
+file=ABI_DIR\BUILD_DIR\rptp.dll        system\libs\rptp.dll
+
+#endif //RPTP_IBY
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/group/rptp.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,33 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+TARGET        	rptp.dll
+TARGETTYPE      dll
+UID             0x1000008d 0x1020DF7F
+CAPABILITY      ALL -TCB
+VENDORID        0x101FB657
+
+SOURCEPATH      ../src
+SOURCE          rptp.cpp
+
+
+USERINCLUDE		  ../inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY		euser.lib  
+LIBRARY		efsrv.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgedp.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,91 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+
+#ifndef CMTPPICTBRIDGEDP_H
+#define CMTPPICTBRIDGEDP_H
+
+#include <mtp/cmtpdataproviderplugin.h>
+#include <comms-infras/commsdebugutility.h>
+
+#include "mmtppictbridgeenumeratorcallback.h"
+#include "cmtprequestprocessor.h"
+#include "mtpdebug.h"
+
+class CMTPPictBridgeEnumerator;
+class CPtpServer;
+
+/** 
+Implements the pictbridge data provider plugin.
+*/
+
+class CMTPPictBridgeDataProvider:
+    public CMTPDataProviderPlugin, 
+    public MMTPPictBridgeEnumeratorCallback
+    {
+public:
+
+    static TAny* NewL(TAny* aParams);
+    ~CMTPPictBridgeDataProvider();
+    const CPtpServer* PtpServer()const {return iServerP;}
+
+public:
+    TUint32 DeviceDiscoveryHandle() const;
+
+public: // From CMTPDataProviderPlugin
+
+    void Cancel();
+    void ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection);
+    void ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams);
+    void ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    void StartObjectEnumerationL(TUint32 aStorageId, TBool aPersistentFullEnumeration);
+    void StartStorageEnumerationL();
+    void Supported (TMTPSupportCategory aCategory, RArray<TUint>& aArray) const;
+    void SupportedL(TMTPSupportCategory aCategory, CDesCArray& aStrings)  const;
+
+private: // From MMTPEnumerationCallback
+
+    void NotifyStorageEnumerationCompleteL();
+    void NotifyEnumerationCompleteL(TUint32 aStorageId, TInt aError);
+
+private:
+    CMTPPictBridgeDataProvider(TAny* aParams);
+    void ConstructL();
+    TInt LocateRequestProcessorL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    TInt LocateRequestProcessorL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection);    
+    void SessionClosedL(const TMTPNotificationParamsSessionChange& aSession);
+    void SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession);
+
+private:
+    CMTPPictBridgeEnumerator* iPictBridgeEnumeratorP;  // owned
+    CPtpServer* iServerP;  // owned
+
+    /**
+    The active request processors table.
+    */ 
+    RPointerArray<MMTPRequestProcessor> iActiveProcessors;
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+    
+#endif // CMTPPICTBRIDGEDP_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgedpgetobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,57 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+
+#ifndef CMTPPICTBRIDGEDPGETOBJECT_H
+#define CMTPPICTBRIDGEDPGETOBJECT_H
+
+#include "cmtprequestprocessor.h"
+#include "cmtppictbridgedp.h"
+
+class CMTPTypeFile;
+
+class CMTPPictBridgeDpGetObject : public CMTPRequestProcessor
+    {
+public:
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider);    
+    ~CMTPPictBridgeDpGetObject();    
+
+private: // From CMTPRequestProcessor
+    void ServiceL();
+    TBool DoHandleResponsePhaseL();
+
+private: 
+    CMTPPictBridgeDpGetObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider);
+    void ConstructL();
+    void BuildFileObjectL(const TDesC& aFileName);
+
+private: // Owned
+    CMTPPictBridgeDataProvider& iPictBridgeDP;
+    CMTPTypeFile*    iFileObject;  // owned
+    TMTPResponseCode iError;
+    
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+    
+#endif // CMTPPICTBRIDGEDPGETOBJECT_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgedpgetobjectinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,58 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef CMTPPICTBRIDGEDPGETOBJECTINFO_H
+#define CMTPPICTBRIDGEDPGETOBJECTINFO_H
+
+#include <f32file.h>
+
+#include "cmtprequestprocessor.h"
+#include "cmtppictbridgedp.h"
+
+class CMTPTypeObjectInfo;
+
+class CMTPPictBridgeDpGetObjectInfo : public CMTPRequestProcessor
+    {
+public:
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider);   
+    ~CMTPPictBridgeDpGetObjectInfo();   
+    
+private:
+    CMTPPictBridgeDpGetObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider);   
+    void ConstructL();
+
+private: // From CMTPRequestProcessor
+    void ServiceL();
+
+private:
+    void BuildObjectInfoL();
+    void SetFileSizeDateL(const TDesC& aFileName, TBool aDiscoveryFile);    
+
+private:
+    CMTPPictBridgeDataProvider& iPictBridgeDP;
+    CMTPTypeObjectInfo* iObjectInfoToBuildP; // owned
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+
+#endif CMTPPICTBRIDGEDPGETOBJECTINFO_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgedpgetobjectpropdesc.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,65 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef MTPPICTBRIDGEGETOBJECTPROPDESC_H_
+#define MTPPICTBRIDGEGETOBJECTPROPDESC_H_
+
+#include "cmtprequestprocessor.h"
+#include "cmtppictbridgedp.h"
+
+class CMTPTypeObjectPropDesc;
+
+/** 
+Defines pictbridge data provider GetObjectPropDesc request processor
+@internalTechnology
+*/
+class CMTPPictBridgeGetObjectPropDesc : public CMTPRequestProcessor
+    {
+public:
+    static MMTPRequestProcessor* NewL( MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider );
+    ~CMTPPictBridgeGetObjectPropDesc();
+    
+private:
+    CMTPPictBridgeGetObjectPropDesc(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider);
+    void ConstructL();
+
+private:    //from CMTPRequestProcessor
+    void ServiceL();    
+
+private:
+    //helper
+    void ServiceStorageIdL();
+    void ServiceObjectFormatL();
+    void ServiceProtectionStatusL();
+    void ServiceObjectSizeL();
+    void ServiceFileNameL();
+    void ServiceDateModifiedL();
+    void ServiceParentObjectL();
+    void ServicePuidL();
+    void ServiceNameL();
+    void ServiceNonConsumableL();
+    TUint16 GetPropertyGroupNumber(const TUint16 aPropCode) const;
+    
+private:
+    CMTPTypeObjectPropDesc* iObjectProperty;
+    CMTPPictBridgeDataProvider& iPictBridgeDP;
+    };
+    
+#endif /* MTPPICTBRIDGEGETOBJECTPROPDESC_H_ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgedpgetobjectproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,76 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+
+#ifndef CMTPPICTBRIDGEDPGETOBJECTPROPLIST_H_
+#define CMTPPICTBRIDGEDPGETOBJECTPROPLIST_H_
+
+#include "cmtprequestprocessor.h"
+#include "cmtppictbridgedp.h"
+#include "rmtpdpsingletons.h"
+
+class CMTPTypeArray;
+class CMTPTypeObjectPropList;
+
+/** 
+Implements the picturebridge data provider GetObjectPropList request processor.
+*/
+class CMTPPictBridgeDpGetObjectPropList : public CMTPRequestProcessor
+    {
+public:
+    static MMTPRequestProcessor* NewL( MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider);
+    ~CMTPPictBridgeDpGetObjectPropList();
+    
+private:
+    CMTPPictBridgeDpGetObjectPropList( MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider);
+    void ConstructL();
+    
+private://from CMTPRequestProcessor
+    void ServiceL();
+    TMTPResponseCode CheckRequestL();
+    
+private:
+
+    TMTPResponseCode CheckPropCode() const;
+    TMTPResponseCode CheckDepth() const;
+    
+    void GetObjectHandlesL();
+    void GetObjectHandlesL( TUint32 aStorageId, TUint32 aFormatCode, TUint32 aParentHandle );
+    void GetRootObjectHandlesL( TUint32 aFormatCode, TUint32 aDepth );
+    
+    void ServiceAllPropertiesL(TUint32 aHandle, TBool aDiscoveryFile );
+    void ServiceGroupPropertiesL(TUint32 aHandle,TUint16 aGroupCode, TBool aDiscoveryFile );
+    void ServiceOneObjectPropertyL(TUint32 aHandle, TUint32 aPropCode, TBool aDiscoveryFile );
+    
+private: // Owned
+    CMTPPictBridgeDataProvider&   iPictBridgeDP;    
+    CMTPTypeArray*          iHandles;
+    CMTPTypeObjectPropList* iPropertyList;
+    RMTPDpSingletons		iDpSingletons; 
+	CMTPObjectMetaData*		iObjMeta;
+	TEntry 					iFileEntry;
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+
+#endif /* CMTPPICTBRIDGEDPGETOBJECTPROPLIST_H_ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgedpsendobjectinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,131 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+
+#ifndef CMTPPICTBRIDGEDPSENDOBJECTINFO_H
+#define CMTPPICTBRIDGEDPSENDOBJECTINFO_H
+
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/tmtptypenull.h>
+
+#include "cmtprequestprocessor.h"
+#include "rmtpdpsingletons.h"
+#include "cmtppictbridgedp.h"
+
+class CMTPTypeFile;
+class CMTPTypeObjectInfo;
+class CMTPTypeObjectPropList;
+class CMTPTypeObjectPropListElement;
+
+class CMTPPictBridgeDpSendObjectInfo : public CMTPRequestProcessor
+    {
+public:
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider);
+    ~CMTPPictBridgeDpSendObjectInfo();    
+    
+public:
+    void NotifyOnObjectReceived();
+
+protected:
+    TMTPResponseCode ErrorToMTPError(TInt aError) const;
+
+private: // From CMTPRequestProcessor
+
+    TBool Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const;
+    TMTPResponseCode CheckRequestL();
+    void ServiceL();
+    TBool DoHandleCompletingPhaseL();
+    TBool DoHandleResponsePhaseL();
+    TBool HasDataphase() const;
+
+private:
+    CMTPPictBridgeDpSendObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider);
+    void ConstructL();
+    TMTPResponseCode CheckSendingStateL();
+    void GetDefaultParentObjectL();
+    TMTPResponseCode GetParentObjectAndStorageIdL();
+    
+    void ServiceSendObjectInfoL();
+    void ServiceSendObjectPropListL();
+    void ServiceSendObjectL();
+    
+    TBool DoHandleSendObjectInfoCompleteL();
+    TBool DoHandleSendObjectPropListCompleteL();
+    TBool DoHandleSendObjectCompleteL();
+        
+    TBool GetFullPathNameL(const TDesC& aFileName);
+    
+    TBool CanStoreFileL(TUint32 aStorageId, TInt64 aObjectSize) const;
+    TBool IsTooLarge(TUint64 aObjectSize) const;
+    void ReserveObjectL();
+    void CreateFsObjectL();
+    void Rollback();
+    
+    TMTPResponseCode MatchStoreAndParentL() const;
+
+    TBool IsFormatValid(TMTPFormatCode aFormat) const;
+    
+    TMTPResponseCode VerifyObjectPropListL( TInt& aInvalidParameterIndex );
+    TMTPResponseCode CheckPropCodeL( const CMTPTypeObjectPropListElement& aElement ) const;
+
+    TMTPResponseCode ExtractPropertyL( const CMTPTypeObjectPropListElement& aElement );
+    
+private:
+    enum TMTPSendingObjectState
+        {
+        EObjectNone,
+        EObjectInfoInProgress,
+        EObjectInfoSucceed,
+        EObjectInfoFail,
+        ESendObjectInProgress,
+        ESendObjectSucceed,
+        ESendObjectFail
+        };
+        
+private: // Owned
+
+    CMTPPictBridgeDataProvider&   iPictBridgeDP;
+    CMTPTypeFile*           iFileReceivedP;  // owned
+    CMTPTypeObjectInfo*     iObjectInfoP;  // owned
+    CMTPTypeObjectPropList* iObjectPropList;//owned
+    TMTPSendingObjectState  iProgress;
+    TUint16                 iOperationCode;
+    TUint32                 iStorageId;
+    TUint32                 iParentHandle;
+    TUint64                 iObjectSize;
+    HBufC*                  iParentSuidP;  // owned
+    TFileName               iFullPath;
+    HBufC*                  iDateModP; // owned To carry modified date extracted from PropertyList
+    CMTPObjectMetaData*     iReceivedObjectP;  // owned
+    TMTPTypeRequest         iExpectedSendObjectRequest;
+    TMTPTypeNull            iNullObject;
+    TUint16                 iProtectionStatus;
+    TUint32                 iPreviousTransactionID;
+    RMTPDpSingletons		iDpSingletons;
+    TFileName				iName;
+    TBool					iNoRollback;
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+    
+#endif //CMTPPictBridgeDpSendObjectInfo_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgeenumerator.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,70 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+
+#ifndef CMTPPICTBRIDGEENUMERATOR_H
+#define CMTPPICTBRIDGEENUMERATOR_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <d32dbms.h>
+
+#include <comms-infras/commsdebugutility.h>
+#include "mtppictbridgedpconst.h"
+#include "mtpdebug.h"
+#include "rmtpframework.h"
+
+class MMTPDataProviderFramework;
+class MMTPObjectMgr;
+class CMTPObjectMetaData;
+class MMTPPictBridgeEnumeratorCallback;
+
+/** 
+Defines file enumerator.  Enumerates all files/directories under a specified path or storage
+
+*/
+class CMTPPictBridgeEnumerator : public CBase
+    {
+public:
+    static CMTPPictBridgeEnumerator* NewL(MMTPDataProviderFramework& aFramework, MMTPPictBridgeEnumeratorCallback& aCallback);
+    ~CMTPPictBridgeEnumerator();
+
+public:
+    void EnumerateObjectsL(TUint32 aStorageId);
+    void EnumerateStoragesL();
+    TUint32 DeviceDiscoveryHandle() const;
+    
+private:
+    CMTPPictBridgeEnumerator(MMTPDataProviderFramework& aFramework, MMTPPictBridgeEnumeratorCallback& aCallback);
+    void ConstructL();
+
+private: 
+    // Owned
+    MMTPDataProviderFramework&              iFramework;
+    MMTPPictBridgeEnumeratorCallback&       iCallback;
+    TUint32                                 iDpsDiscoveryHandle;
+    RMTPFramework       iSingletons;
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+
+#endif // CMTPPICTBRIDGEENUMERATOR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgegetformatcapabilities.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,66 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+
+#ifndef CMTPPICTBRIDGEGETFORMATCAPABILITIES_H_
+#define CMTPPICTBRIDGEGETFORMATCAPABILITIES_H_
+
+#include <mtp/cmtptypeformatcapabilitylist.h>
+#include "cmtprequestprocessor.h"
+#include "cmtppictbridgedp.h"
+#include "mtpdpconst.h"
+
+/** 
+Implements the file data provider CMTPGetFormatCapabilities request processor.
+@internalComponent
+*/
+class CMTPPictBridgeDpGetFormatCapabilities : public CMTPRequestProcessor
+    {
+public:
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider);    
+    ~CMTPPictBridgeDpGetFormatCapabilities();    
+
+private: // From CMTPRequestProcessor
+    void ServiceL();
+    TMTPResponseCode CheckRequestL();
+    
+private:
+    CMTPPictBridgeDpGetFormatCapabilities(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider);
+    void ConstructL();
+    void BuildFormatScriptL();
+    CMTPTypeObjectPropDesc* ServiceProtectionStatusL();
+    CMTPTypeObjectPropDesc* ServiceNonConsumableL();
+    TUint16 GetPropertyGroupNumber(const TUint16 aPropCode) const;
+    
+private: // Owned
+    CMTPPictBridgeDataProvider&   iPictBridgeDP;
+    TUint                         iFormatCode;
+    /* 
+     * CMTPTypeCapabilityList dataset.
+     */
+    CMTPTypeFormatCapabilityList* iCapabilityList;
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+
+#endif /* CMTPPICTBRIDGEGETFORMATCAPABILITIES_H_ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgegetobjectpropssupported.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,52 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef CMTPPICTBRIDGEGETOBJECTPROPSSUPPORTED_H_
+#define CMTPPICTBRIDGEGETOBJECTPROPSSUPPORTED_H_
+
+#include "cmtprequestprocessor.h"
+#include "cmtppictbridgedp.h"
+
+class CMTPTypeArray;
+
+/** 
+Defines pictbridge data provider GetObjectPropsSupported request processor
+
+@internalTechnology
+*/
+class CMTPPictBridgeGetObjectPropsSupported : public CMTPRequestProcessor
+    {
+public:
+    static MMTPRequestProcessor* NewL( MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider );
+    ~CMTPPictBridgeGetObjectPropsSupported();
+    
+private:
+    CMTPPictBridgeGetObjectPropsSupported( MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider );
+    void ConstructL();
+    
+private:    //from CMTPRequestProcessor
+    virtual TMTPResponseCode CheckRequestL();
+    virtual void ServiceL();
+    
+private:
+    CMTPPictBridgeDataProvider& iPictBridgeDP;
+    CMTPTypeArray*          iObjectPropsSupported;
+    };
+
+#endif /* CMTPPICTBRIDGEGETOBJECTPROPSSUPPORTED_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgeprinter.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,84 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+
+#ifndef CMTPPICTBRIDGEPRINTER_H
+#define CMTPPICTBRIDGEPRINTER_H
+#include <mtp/tmtptypeevent.h>
+#include "mtpdebug.h"
+
+class CMTPTypeObjectInfo;
+class MMTPConnection;
+class CPtpServer;
+class CPtpSession;
+class MServiceHandlerObserver;
+class CPtpReceivedMsgHandler;
+class CMTPPictBridgeUsbConnection; 
+
+class CMTPPictBridgePrinter : public CBase
+    {
+    public:
+        enum TPrinterStatus
+            {
+            ENotConnected,
+            EConnected,
+            ENotPrinter
+            };
+        static CMTPPictBridgePrinter* NewL(CPtpServer& aServer);
+        ~CMTPPictBridgePrinter();
+        void ConnectionClosed();
+        void DpsDiscovery(const TFileName& aFileName, MMTPConnection* aConnectionP);
+        void SendDpsFileL(const TDesC& aFile, TBool aTimeout, TInt aSize); 
+        void CancelSendDpsFile();
+        void DpsFileSent(TInt aError);
+        
+        void DpsObjectReceived(TUint32 aHandle);
+        void ObjectReceived(TDes& aFile);
+
+        void DeRegisterDpsPrinterNotify(CPtpSession* aSession);
+        void RegisterDpsPrinterNotify(CPtpSession* aSession);
+
+        void RegisterObserver(MServiceHandlerObserver* aObserverP);
+        void  NoDpsDiscovery();
+        TBool SendObjectPending() const;
+        MMTPConnection* ConnectionP() const;
+        TPrinterStatus Status() const;
+        CPtpReceivedMsgHandler* MsgHandlerP() const;
+        inline const CMTPPictBridgeUsbConnection* UsbConnectionP() const { return iUsbConnectionP; }
+    private:
+        void ConstructL();
+        CMTPPictBridgePrinter(CPtpServer& aServer);
+        void CreateRequestObjectTransfer(TUint32 aHandle, TMTPTypeEvent& aEvent);
+    private:
+        CPtpServer& iServer;
+        MMTPConnection* iPrinterConnectionP;  // not owned
+        TPrinterStatus iPrinterStatus;
+        CPtpSession* iDpsPrinterNotifyCbP; // not owned
+        CPtpReceivedMsgHandler* iMsgHandlerP; // owned
+        MServiceHandlerObserver* iObserverP; // not owned
+        TUint32 iOutgoingObjectHandle;
+        CMTPPictBridgeUsbConnection* iUsbConnectionP; // owned
+        TMTPTypeEvent iEvent;
+        /**
+        FLOGGER debug trace member variable.
+        */
+        __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+#endif // CMTPPICTBRIDGEPRINTER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/cmtppictbridgeusbconnection.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,90 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+
+#ifndef CMTPPICTBRIDGEUSBCONNECTION_H
+#define CMTPPICTBRIDGEUSBCONNECTION_H
+
+#include <e32base.h>
+#include <e32property.h>
+#include "mtpdebug.h"
+
+
+// FORWARD DECLARATION
+class CMTPPictBridgePrinter;
+
+/**
+ * @since 
+*/
+class CMTPPictBridgeUsbConnection : public CActive
+    {
+    public:
+        
+        /**
+        * @since 
+        */
+        static CMTPPictBridgeUsbConnection* NewL(CMTPPictBridgePrinter& aPrinter);
+        
+        /**
+        * @since 
+        */
+        ~CMTPPictBridgeUsbConnection();    
+        
+        /**
+        * @since 
+        */        
+        void Listen();
+
+        /**
+        * @return ETrue if the connection was closed, EFalse otherwise
+        */        
+        TBool ConnectionClosed();
+    private:
+        /**
+        * @since 
+        */
+        CMTPPictBridgeUsbConnection(CMTPPictBridgePrinter& aPrinter);
+        
+        /**
+        * @since 
+        */
+        void ConstructL();
+        
+        /**
+        * @since 
+        */
+        void RunL();
+        
+        void DoCancel();
+        
+        TInt RunError(TInt aErr);
+        
+    private:
+        CMTPPictBridgePrinter& iPrinter;
+        RProperty              iProperty;
+        TInt                   iPreviousPersonality;
+        /**
+        FLOGGER debug trace member variable.
+        */
+        __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+    
+#endif
+    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/cptpreceivedmsghandler.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,107 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+
+#ifndef CPTPRECEIVEDMSGHANDLER_H
+#define CPTPRECEIVEDMSGHANDLER_H
+
+#include <e32debug.h>
+#include "ptpdef.h"
+#include "rptp.h"
+
+class CPtpServer;
+
+    /**
+    * Ptp Message Handler class
+    * Handles PTP Operations and Responses,
+    **/
+NONSHARABLE_CLASS(CPtpReceivedMsgHandler) : public CBase
+    {          
+public: 
+
+    /**
+    * 2-phased constructor.
+    * @param
+    * @return None. 
+    */
+    static CPtpReceivedMsgHandler* NewL(CPtpServer* aServerP); 
+    
+
+    
+    /**
+    * C++ destructor.
+    * @return None.
+    **/
+    ~CPtpReceivedMsgHandler();
+    
+    /**
+    * Performs Initialization
+    * @return None. 
+    **/
+    void Initialize();
+                                                 
+   
+    /**
+    * Register for Receive Object Notification
+    * @param aExtension, File Extension 
+    * @return None. 
+    **/
+    void RegisterReceiveObjectNotify(const TDesC& aExtention);
+        
+    /**
+    * RegisterSendObjectNotify
+    * @return None. 
+    **/
+    void DeRegisterReceiveObjectNotify();        
+    
+    /**
+    * Handles Object received
+    * @return None. 
+    **/ 
+    TBool ObjectReceived(TUint32 aHandle);    
+
+private: 
+    /**
+    * C++ constructor.
+    * @return None.  
+    **/
+    CPtpReceivedMsgHandler(CPtpServer* aServerP);
+    void ConstructL();
+private: 
+
+     CPtpServer* iServerP; // not owned
+
+     // the handle of the rceived object
+     TUint32 iReceiveHandle;
+     
+     TBuf<KFileExtLength> iExtension;  
+               
+     // transaction IDs
+     TUint32 iTransactionID;
+
+     RArray<TUint32> iReceiveQ;
+     /**
+     FLOGGER debug trace member variable.
+     */
+     __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+#endif //  CPTPRECEIVEDMSGHANDLER_H
+
+    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/cptpserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,106 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+
+#ifndef PTPSERVER_H
+#define PTPSERVER_H
+
+
+#include "s60dependency.h"
+
+#include <e32svr.h>   
+#include <mtp/cmtptypeobjectinfo.h>
+
+#include "ptpdef.h"
+#include "rptp.h"
+#include "cptpsession.h"
+#include "cmtppictbridgedp.h"
+
+//FORWARD DECLARATION
+
+class MMTPDataProviderFramework;
+class TMTPTypeEvent;
+class CMTPPictBridgePrinter;
+class CMTPObjectMetaData;
+class CFileMan;
+
+static const TInt KMTPMaxPtpFolderPathLength = 256;
+
+/**
+*  A server class to initialize server. 
+*
+*  @since S60 5.2
+*/
+NONSHARABLE_CLASS(CPtpServer) : public CServer2
+    {
+     
+public:
+    static CPtpServer* NewL(MMTPDataProviderFramework& aFramework, CMTPPictBridgeDataProvider& aDataProvider);
+    ~CPtpServer();
+
+public:// from CServer2, creates a new session.
+    CSession2* NewSessionL( const TVersion& aVersion, const RMessage2& aMessage ) const;
+    
+public:
+    const TDesC& PtpFolder();
+      
+    void GetObjectHandleByNameL(const TDesC& aNameAndPath, TUint32& aHandle);
+    void GetObjectNameByHandleL(TDes& aNameAndPath, const TUint32 aHandle);
+
+    void SendEventL(TMTPTypeEvent& ptpEvent);
+    void AddTemporaryObjectL(const TDesC& aPathAndFileName, TUint32& aHandle);
+    void RemoveTemporaryObjects();
+    void RemoveObjectL(const TDesC& aSuid);
+    void NotifyOnMtpSessionOpen(CPtpSession* aSession);
+
+    inline CMTPPictBridgePrinter* Printer() const{ return iPrinterP; }
+    inline TInt NumSession() const { return iNumSession; }
+    inline void IncrementSessionCount(){ iNumSession++; }
+    inline void DecrementSessionCount(){ iNumSession--; }
+    inline TUint32 DeviceDiscoveryHandle() const{ return iDataProvider.DeviceDiscoveryHandle(); }
+    inline TBool MtpSessionOpen() const{ return iMtpSessionOpen; }
+
+    MMTPDataProviderFramework& Framework() const;
+
+    void MtpSessionOpened();
+    void MtpSessionClosed();
+    void CancelNotifyOnMtpSessionOpen(CPtpSession* aSession);
+
+private:    
+    CPtpServer(MMTPDataProviderFramework& aFramework, CMTPPictBridgeDataProvider& aDataProvider);
+    void ConstructL();
+
+private:   
+    TBuf<KMTPMaxPtpFolderPathLength> iPtpFolder;
+    CMTPPictBridgePrinter* iPrinterP;  // owned
+    TInt iNumSession;
+    MMTPDataProviderFramework& iFramework;
+    CMTPPictBridgeDataProvider& iDataProvider;
+    RPointerArray<CMTPObjectMetaData> iTemporaryObjects;
+    TBool iMtpSessionOpen;
+    CPtpSession* iSessionOpenNotifyClientP;
+    CFileMan*          iFileMan;
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+#endif // PTPSERVER_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/cptpsession.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,220 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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 PTPSESSION_H
+#define PTPSESSION_H
+
+#include <e32svr.h>   
+#include "ptpdef.h"
+#include "rptp.h"
+
+class CPtpServer;
+class CPtpTimer;
+
+/**
+* MServiceHandlerObserver M Class for callbacks
+*  @since S60 3.2
+*/
+class MServiceHandlerObserver
+    {
+    public: 
+        
+        /**
+        * Called to notify send Object complete with status
+        * @since S60 3.2
+        * @param aState, Object send status
+        */
+       virtual void SendObjectCompleted(TInt aStatus) = 0;
+        
+        /**
+        * Called to notify object received with name and path
+        * @since S60 3.2
+        * @param aNameAndPath
+        */
+       virtual void ReceivedObjectCompleted(TDes& aNameAndPath) = 0;
+        
+        /**
+        * Called to notify DPS Discovery status
+        * @param aState, Printer state
+        */
+       virtual void IsDpsPrinterCompleted(TDpsPrinterState aState) = 0;
+        /**
+        * Cancel Outstanding request
+        * @since S60 3.2
+        */
+
+       virtual void CancelOutstandingRequest() = 0;
+    };
+
+/**
+*  A session class which creates an instance of PTP Stack when starting, 
+*  and releases used memory when closing.
+*
+*  @since S60 3.2
+*/
+NONSHARABLE_CLASS(CPtpSession) : public CSession2, MServiceHandlerObserver
+	{
+public:
+    /**
+    * 2-phased constructor.
+    * @since S60 3.2
+    */
+	static CPtpSession* NewL(CPtpServer* aServer);
+
+	/**
+	* C++ destructor.
+	* @since S60 3.2
+	*/
+	~CPtpSession(); 
+	
+	/**
+    * From CSession2, passes the request forward to DispatchMessageL.
+   	* @since S60 3.2
+    */
+	void ServiceL( const RMessage2& aMessage );
+	
+	/**
+    * Handles the request from client.
+  	* @since S60 3.2
+    */
+	void DispatchMessageL( const RMessage2& aMessage );
+    
+    CPtpServer* ServerP() const;
+    
+
+public: 	// from MServiceHandlerObserver
+    
+    /**
+    *  @since S60 3.2
+    */   
+       void SendObjectCompleted(TInt aStatus);
+    
+    /**
+    *  @since S60 3.2
+    */
+       void ReceivedObjectCompleted(TDes& aNameAndPath);
+    
+    /**
+    @since S60 3.2
+    */
+       void IsDpsPrinterCompleted(TDpsPrinterState aState); 
+
+       void MTPSessionOpened();
+private:
+    
+	/**
+	* C++ constructor.
+	* @since S60 3.2
+	*/
+	CPtpSession(CPtpServer* aServer);
+    void ConstructL();
+    
+    /**
+    * To create PTP stack and load Transport Plugin
+    * @since S60 3.2
+    */
+    void CreateStackL(const RMessage2& aMessage);
+	
+    /**
+    * Destroys PTP stack and Unloads Transport Plugin
+    * @since S60 3.2
+    */
+    void DestroyStackL();
+	
+    /**
+    * Asynch. request if DPS (PictBridge) Printer connected
+    * @since S60 3.2
+    */
+	TInt IsDpsPrinter(const RMessage2& aMessage, TBool& aComplete);
+    
+    /**
+	* To get object handle By Name
+	* @since S60 3.2
+	*/
+    void GetObjectHandleByNameL(const RMessage2& aMessage);
+    
+    /**
+	* To Get Object name by handle
+	* @since S60 3.2
+	*/
+    void GetNameByObjectHandleL(const RMessage2& aMessage);
+    
+    /**
+	* Request to send Object
+	* @since S60 3.2
+	*/
+    TInt SendObject(const RMessage2& aMessage, TBool& aComplete);
+    
+    /**
+	* Register for Object received notifications
+	* @since S60 3.2
+	*/
+    TInt ObjectReceivedNotify(const RMessage2& aMessage, TBool& aComplete);
+    
+    /**
+	* Cancel previously issued Asynch. request IsDpsPrinter()
+	* @since S60 3.2
+	*/
+    void CancelIsDpsPrinter();
+    
+    /**
+	* Cancel previously issued asynch. request send Object
+	* @since S60 3.2
+	*/
+    void CancelSendObject();
+    
+    /**
+	* DeRegister for Object received notification
+	* @since S60 3.2
+	*/
+    void CancelObjectReceivedNotify();
+    
+    /**
+	* Get PTP Folder name and path
+	* @since S60 3.2
+	*/
+    TInt PtpFolder(const RMessage2& aMessage);
+    
+    /**
+	* Request Cancel current PTP Transaction
+	* @since S60 3.2
+	*/
+    void CancelOutstandingRequest();
+
+    void CleanupL();
+
+private: 	// Data
+	CPtpServer*  iServerP;  // not owned
+	RMessage2    iSendObjectMsg;
+	RMessage2    iObjectReceivedNotifyMsg;
+	RMessage2    iDpsPrinterMsg;
+	RMessage2    iCancelMsg;
+    TFileName    iReceivedFile;
+    CPtpTimer*   iTimerP;  // owned
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // PTPSESSION_H
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/cptptimer.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,55 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+
+#ifndef PTPTIMER_H
+#define PTPTIMER_H
+
+#include <e32base.h>
+#include "ptpdef.h"
+
+// FORWARD DECLARATION
+class CPtpSession;
+
+
+class CPtpTimer : public CTimer
+    {
+    public:
+        
+ 
+        static CPtpTimer* NewL(CPtpSession& aSession);
+        ~CPtpTimer();    
+        
+    private:
+        CPtpTimer(CPtpSession& aSession);
+        void ConstructL();
+        void RunL();      
+        TInt RunError(TInt aErr);
+        
+    private:
+        CPtpSession& iSession;
+		/**
+        FLOGGER debug trace member variable.
+        */
+        __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+    
+#endif
+    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/mmtppictbridgeenumeratorcallback.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,48 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+
+#ifndef MMTPPICTBRIDGEENUMERATORCALLBACK_H
+#define MMTPPICTBRIDGEENUMERATORCALLBACK_H
+
+#include <e32std.h>
+
+/** 
+Defines the PictBridgeDP enumeration complete notification interface.
+@internalComponent
+*/
+class MMTPPictBridgeEnumeratorCallback
+	{
+public:
+	/**
+	Notifies that storage enumeration is completed.
+	*/
+	virtual void NotifyStorageEnumerationCompleteL() = 0;
+
+	/**
+	Notifies that enumeration of the specified storage is completed.
+    @param aStorageId The MTP StorageID of the enumerated storage.
+	@param aError The enumeration completion error status.
+	*/
+	virtual void NotifyEnumerationCompleteL(TUint32 aStorageId, TInt aError) = 0;
+
+	};
+	
+#endif // MMTPPICTBRIDGEENUMERATORCALLBACK_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/mtppictbridgedpconst.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,103 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef MTPPICTBRIDGEDPCONST_H
+#define MTPPICTBRIDGEDPCONST_H
+
+#include <mtp/mtpprotocolconstants.h>
+#include <comms-infras/commsdebugutility.h>
+#include "mtpdpconst.h"
+
+
+_LIT(KDeviceDiscovery, "DDISCVRY.DPS"); 
+_LIT(KHostDiscovery, "HDISCVRY.DPS");
+_LIT(KHostRequest, "HREQUEST.DPS");
+_LIT(KHostResponse, "HRSPONSE.DPS");
+
+
+static const TUint KDiscoveryTime = 15 * 1000 * 1000; //15s 
+static const TUint KSendTimeout = 15* 1000 * 1000; // 15s
+
+
+/**
+define all the operations that are supported by the pictbridge data provider
+*/
+static const TUint16 KMTPPictBridgeDpSupportedOperations[] = 
+    {
+    EMTPOpCodeGetObjectInfo,
+//    EMTPOpCodeGetObjectPropList,
+    EMTPOpCodeGetObject,
+//    EMTPOpCodeSetObjectPropList,
+    EMTPOpCodeSendObjectInfo,
+//    EMTPOpCodeSendObjectPropList,
+    EMTPOpCodeSendObject
+//    EMTPOpCodeGetObjectPropsSupported,
+//    EMTPOpCodeGetObjectPropDesc,
+//    EMTPOpCodeGetFormatCapabilities,
+//    EMTPOpCodeDeleteObject
+    };  
+
+/**
+define all the object properties that are supported by the pictbridge data provider
+*/
+static const TUint16 KMTPPictBridgeDpSupportedProperties[] = 
+    {
+    EMTPObjectPropCodeStorageID,
+    EMTPObjectPropCodeObjectFormat,
+    EMTPObjectPropCodeProtectionStatus,
+    EMTPObjectPropCodeObjectSize,
+    EMTPObjectPropCodeObjectFileName,
+    EMTPObjectPropCodeDateModified,
+    EMTPObjectPropCodeParentObject,
+    EMTPObjectPropCodePersistentUniqueObjectIdentifier,
+    EMTPObjectPropCodeName,
+    EMTPObjectPropCodeNonConsumable
+    };
+
+static const TUint32 KPtpNoValue = 0x00;
+static const TInt KMTPProcessLimit = 1000; // how many entries processed before completing the ao
+static const TInt KExtensionBufferSize=5; //related to the size of strings in SMTPValidCodeExtensionMapping
+
+// extensions of image files that are shared via MTP PictBridge Data Provider
+
+struct SMTPValidCodeExtensionMapping
+    {
+    public:
+    TMTPFormatCode iFormatCode;
+    const TText*   iExtension;
+    };
+
+// Note when adding extensions: 
+// same value for iExtension can be in the file only once, 
+// values for iFormatCode code can be multiple times
+
+#if defined(_UNICODE)
+#define CASTING(a) ((const TText*)L ## a)
+#else
+#define CASTING(a) ((const TText*)(a))
+#endif
+
+static const SMTPValidCodeExtensionMapping KMTPValidCodeExtensionMappings[] =
+    {
+        {EMTPFormatCodeScript, CASTING("dps")} // dps script
+    };
+
+#endif // MTPPICTBRIDGEDPCONST_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/mtppictbridgedppanic.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,52 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+
+#ifndef MTPPICTBRIDGEDPPANIC_H
+#define MTPPICTBRIDGEDPPANIC_H
+
+#include <e32std.h>
+
+/**
+define the file data provider panic code
+@internalTechnology
+
+*/
+enum TMTPPictBridgeDpPanic
+    {
+    EMTPPictBridgeDpNoMatchingProcessor = 0,
+    EMTPPictBridgeDpObjectNull = 1,
+    EMTPPictBridgeDpFormatNotSupported = 2,
+    EMTPPictBridgeDpSendObjectStateInvalid = 3,
+    EMTPPictBridgeDpRequestCheckNull = 4,
+    EMTPPictBridgeDpHandlesNull = 5,
+    EMTPPictBridgeDpUnsupportedProperty = 6,
+    EMTPPictBridgeDpObjectPropertyNull = 7,
+    EMTPPictBridgeDpCannotRenameDir = 8,
+    };
+
+_LIT(KMTPPictBridgeDpPanic, "MTP PictBridge Data Provider");
+
+inline void Panic(TMTPPictBridgeDpPanic aCode)
+    {
+    User::Panic(KMTPPictBridgeDpPanic, aCode);
+    };
+#endif // MTPPICTBRIDGEPANIC_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/mtppictbridgedpprocessor.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,48 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+
+#ifndef MTPPICTBRIDGEDPPROCESSOR_H_
+#define MTPPICTBRIDGEDPPROCESSOR_H_
+
+class MMTPConnection;
+class TMTPTypeRequest;
+class CMTPDataProviderPlugin;
+class MMTPDataProviderFramework;
+class MMTPRequestProcessor;
+class CMTPPictBridgeDataProvider;
+//class CPtpServer;
+
+/** 
+Defines PictBridge data provider request processor factory
+
+@internalTechnology
+*/
+class MTPPictBridgeDpProcessor
+	{
+public:
+	static MMTPRequestProcessor* CreateL(
+	                                    MMTPDataProviderFramework& aFramework,
+	                                    const TMTPTypeRequest& aRequest, 
+	                                    MMTPConnection& aConnection,
+	                                    CMTPPictBridgeDataProvider& aDataProvider);    
+	};
+
+#endif /*MTPPICTBRIDGEDPPROCESSOR_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/ptpdef.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,62 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+
+#ifndef PTPDEF_H
+#define PTPDEF_H
+
+#include <e32std.h>
+#include <comms-infras/commsdebugutility.h> // for __FLOG debugging
+
+_LIT( KPTPServer, "PtpServer" );
+_LIT( KPTPClientPanicCategory, "PTPServ-Client");
+
+__FLOG_STMT(_LIT8(KComponent,    "PictBridgeDp");)
+__FLOG_STMT(_LIT8(KPtpServerLog, "PTPServer");)
+
+const TInt KPtpServerVersionMinor = 1;
+const TInt KPtpServerVersionMajor = 1;
+const TInt KFileNameAndPathLength = 32;
+
+enum TPtpPanicsClient
+    {
+    ECannotStartServer,
+    EBadRequest,
+    ERequestPending
+    };
+
+enum TPtpClientMessage 
+    {
+    EPtpCreateStack,
+    EPtpDestroyStack,
+    EPtpRegister,
+    ECancelIsDpsPrinter,
+    EIsDpsPrinter,
+    EGetObjectHandleByName,
+    EGetNameByObjectHandle,
+    ESendObject,
+    ECancelSendObject,
+    EObjectReceivedNotify,
+    ECancelObjectReceivedNotify,
+    EPtpFolder
+    };
+
+#endif // PTPDEF_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/rptp.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,160 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cmtpdeltadatamgr.h
+// 
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef  __INC_RPTP_H
+#define  __INC_RPTP_H
+
+#include <e32base.h>
+
+const TInt KFileExtLength = 8;
+
+enum TDpsPrinterState
+    {
+    EPrinterNotAvailable,
+    EPrinterAvailable
+    };       
+
+/**
+*  RPtp class is used to create a PTP Server session and a connection to the
+*  selected transport medium.
+*/
+NONSHARABLE_CLASS(RPtp) : public RSessionBase
+    {
+    
+public:
+    IMPORT_C RPtp();
+    
+    /**
+    * Creates new session to PTP Server. This also register the observer
+    * to the ptp server. This should be only used by the client
+    */  
+    IMPORT_C TInt Connect();
+    
+    /**
+    * Creates connection to the server and initializes the ptp stack based on
+    * specified transport medium.
+    * @return KErrNone if success or system error if failed.
+    */
+    IMPORT_C TInt CreatePtpStack( const TUid aTransport );
+    
+    /**
+    * Performs DPS discovery.
+    * @param aStatus the result of the Dps discovery, either EAvailable or
+    *   NotAvailable from TDpsPrinterState enum
+    */
+    IMPORT_C void IsDpsPrinter(TRequestStatus& aStatus);
+    
+    /**
+    * Cancels previously issued Asynch request IsDpsPrinter
+    */
+    IMPORT_C void CancelIsDpsPrinter();
+        
+    /**
+    * Client sends object and get informed when the object is received by
+    * the host. This method is intended for sending DPS files only.
+    * @param aNameAndPath, the name and full path of the file.
+    * @param aStatus, Asynchronous completion word for the operation.
+    * @param aTimeout whether the client needs the reply for this request. If
+    *   it needs the timeout will be true, which means if timout happened, 
+    *   the reply is KErrTimedout. 
+    * @param aSize  size of the object to be sent. Not used. @deprecated 5.2
+    * @param aAdd  Not used. @deprecated 5.2
+    */
+    IMPORT_C void SendObject(const TDesC& aNameAndPath, 
+                             TRequestStatus& aStatus, TBool aTimeout,
+                             TInt aSize=0, TBool aAdd = EFalse);
+    
+    /**
+    * Cancel object sending request.
+    */
+    IMPORT_C void CancelSendObject();
+        
+    /**
+    * Registers the certain DPS files arrival (from the host) notification. 
+    * Note that the received file is deleted when next call on this API is made.
+    * @param aFileExtension.  file extension
+    * @param aNameAndPath  name and path of the file.
+    * @param aDelete @deprecated. The recveived file is always deleted when next
+    *    call to any method on this API is made.
+    * @param aStatus, Asynchronous completion word for the operation.
+    * @return None.
+    */
+    IMPORT_C void ObjectReceivedNotify(const TDesC& aFileExtension,
+                                       TDes& aNameAndPath, 
+                                       TRequestStatus& aStatus,
+                                       TBool aDelete = EFalse);
+    
+    /**
+    * Gets the object handle (whether the object exists).
+    * The client may use this function to delete certain file 
+    * (mainly for dps now)  
+    * @param aNameAndPath, A name and full path of the file.
+    * @param aHandle , 32bit handle of the object
+    * @param aAdd if ETrue, this object is added to the list if not found.
+    * @return KErrNone if object is found or KErrNotFound if not.
+    */
+    IMPORT_C TInt GetObjectHandleByName(const TDesC& aNameAndPath, 
+                                        TUint32& aHandle, 
+                                        TBool aAdd = EFalse);
+    
+    /**
+    * Gets the file name.
+    * @param aNameAndPath, A name and full path of the file.
+    * @param aHandle , 32bit handle of the objcet
+    * @return KErrNone if successfull or system error if failed
+    */
+    IMPORT_C TInt GetNameByObjectHandle(TDes& aNameAndPath, 
+                                        const TUint32 aHandle );
+    
+    
+    /**
+    * Cancel Object received notification 
+    */
+    IMPORT_C void CancelObjectReceivedNotify();
+    
+    /**
+    * Closes the connection to PTP server.
+    */
+    IMPORT_C void DestroyPtpStatck();
+    
+    /**
+    * Returns name and path of folder. Note: while this still returns a valid folder name,
+    * that folder is no more used for anything.
+    * @return Folder Name and Path
+    */
+    IMPORT_C const TDesC& PtpFolder();
+
+    /**
+    */
+    IMPORT_C void Close();    
+private:
+    TInt DoConnect();        
+    
+private:
+    TBuf<KFileExtLength> iExt;
+    TFileName iFile;
+    TBool iConnected;
+    };
+    
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/inc/s60dependency.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,33 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+
+#ifndef EX_S60DEPENDENCY_H
+#define EX_S60DEPENDENCY_H
+
+#include <e32base.h>
+
+#include <platform/mw/usbwatcherinternalpskeys.h>
+#include <platform/mw/usbpersonalityids.h>
+#include <pathinfo.h> 
+#include <featmgr/featmgr.h>
+
+#endif // EX_S60DEPENDENCY_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedp.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,377 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/tmtptyperequest.h>
+#include <mtp/cmtpstoragemetadata.h>
+#include <mtp/mmtpconnection.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpdataproviderapitypes.h>
+#include <mtp/mtpprotocolconstants.h>
+#include "cmtppictbridgedp.h"
+#include "cptpserver.h"
+#include "mtppictbridgedpconst.h"
+#include "mtppictbridgedppanic.h"
+#include "mtppictbridgedpprocessor.h"
+#include "cmtppictbridgeenumerator.h"
+#include "ptpdef.h"
+
+LOCAL_D const TInt KArrayGranularity = 3;
+
+// --------------------------------------------------------------------------
+// PictBridge data provider factory method.
+// @return A pointer to a pictbridge data provider object. Ownership is transfered.
+// @leave One of the system wide error codes, if a processing failure occurs.
+// --------------------------------------------------------------------------
+//
+TAny* CMTPPictBridgeDataProvider::NewL(TAny* aParams)
+    {
+    CMTPPictBridgeDataProvider* self = new (ELeave) CMTPPictBridgeDataProvider(aParams);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+// --------------------------------------------------------------------------
+// Constructor
+// --------------------------------------------------------------------------
+//
+CMTPPictBridgeDataProvider::CMTPPictBridgeDataProvider(TAny* aParams):
+    CMTPDataProviderPlugin(aParams),
+    iActiveProcessors(KArrayGranularity)
+    {
+    }
+
+// --------------------------------------------------------------------------
+// second phase constructor
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgeDataProvider::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8(">> CMTPPictBridgeDataProvider::ConstructL"));   
+    iPictBridgeEnumeratorP = CMTPPictBridgeEnumerator::NewL(Framework(), *this);
+    iServerP = CPtpServer::NewL(Framework(), *this);
+    __FLOG(_L8("<< CMTPPictBridgeDataProvider::ConstructL"));
+    }
+// --------------------------------------------------------------------------
+// Destructor
+// --------------------------------------------------------------------------
+//
+CMTPPictBridgeDataProvider::~CMTPPictBridgeDataProvider()
+    {
+    __FLOG(_L8(">> ~CMTPPictBridgeDataProvider"));
+
+    TUint count(iActiveProcessors.Count());
+    while (count--)
+        {
+        iActiveProcessors[count]->Release();
+        }
+    iActiveProcessors.Close();
+
+    delete iPictBridgeEnumeratorP;
+    delete iServerP;
+
+    __FLOG(_L8("<< ~CMTPPictBridgeDataProvider"));
+    __FLOG_CLOSE;
+    }
+
+// --------------------------------------------------------------------------
+// Cancel
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgeDataProvider::Cancel()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDataProvider::Cancel"));
+    // nothing to cancel
+    __FLOG(_L8("<< CMTPPictBridgeDataProvider::Cancel"));
+    }
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgeDataProvider::ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection)
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDataProvider::ProcessEventL"));    
+
+    TInt idx = LocateRequestProcessorL(aEvent, aConnection);
+
+    if (idx != KErrNotFound)
+        {
+        iActiveProcessors[idx]->HandleEventL(aEvent);
+        }
+
+    __FLOG(_L8("<< CMTPPictBridgeDataProvider::ProcessEventL"));    
+    }
+// --------------------------------------------------------------------------
+// Process notifications from the initiator
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgeDataProvider::ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams)
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDataProvider::ProcessNotificationL"));    
+    
+    switch (aNotification)
+        {
+    case EMTPSessionClosed:
+        SessionClosedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams));
+        break;
+        
+    case EMTPSessionOpened:
+        SessionOpenedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams));
+        break;
+        
+    default:
+        // Ignore all other notifications.
+        break;
+        }
+
+    __FLOG(_L8("<< CMTPPictBridgeDataProvider::ProcessNotificationL"));    
+    }
+// --------------------------------------------------------------------------
+// Process requests from the initiator
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgeDataProvider::ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {    
+    __FLOG(_L8(">> CMTPPictBridgeDataProvider::ProcessRequestPhaseL"));    
+
+    TInt idx = LocateRequestProcessorL(aRequest, aConnection);
+    __ASSERT_DEBUG((idx != KErrNotFound), Panic(EMTPPictBridgeDpNoMatchingProcessor));
+    MMTPRequestProcessor* processorP(iActiveProcessors[idx]);
+    TBool result(processorP->HandleRequestL(aRequest, aPhase));
+    if (result)    //destroy the processor
+        {
+        processorP->Release();
+        iActiveProcessors.Remove(idx);
+        }
+
+    __FLOG_VA((_L8("<< CMTPPictBridgeDataProvider::ProcessRequestPhaseL result=%d"), result));    
+    }
+
+// --------------------------------------------------------------------------
+// Starts the object enumeration
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgeDataProvider::StartObjectEnumerationL(TUint32 aStorageId, TBool /*aPersistentFullEnumeration*/)
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDataProvider::StartObjectEnumerationL"));
+    
+    iPictBridgeEnumeratorP->EnumerateObjectsL(aStorageId);
+
+    __FLOG(_L8("<< CMTPPictBridgeDataProvider::StartObjectEnumerationL"));
+    }
+
+// --------------------------------------------------------------------------
+// Storage enumeration is not needed, just declared complete
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgeDataProvider::StartStorageEnumerationL()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDataProvider::StartStorageEnumerationL"));        
+    iPictBridgeEnumeratorP->EnumerateStoragesL();
+    __FLOG(_L8("<< CMTPPictBridgeDataProvider::StartStorageEnumerationL"));
+    }
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgeDataProvider::Supported(TMTPSupportCategory aCategory, RArray<TUint>& aArray) const
+    {   
+    __FLOG_VA((_L8(">> CMTPPictBridgeDataProvider::Supported %d"), aCategory));
+    switch (aCategory) 
+        {        
+    case EEvents:
+        aArray.Append(EMTPEventCodeRequestObjectTransfer);
+        break;
+    case EObjectPlaybackFormats:
+    case EObjectCaptureFormats:
+         break;
+    case EObjectProperties:
+        {
+        TInt count(sizeof(KMTPPictBridgeDpSupportedProperties) / sizeof(KMTPPictBridgeDpSupportedProperties[0]));
+        for (TInt i = 0; i < count; i++ )
+            {
+            aArray.Append( KMTPPictBridgeDpSupportedProperties[i] );
+            }
+        }
+        break; 
+
+    case EOperations:
+        {
+        TInt count(sizeof(KMTPPictBridgeDpSupportedOperations) / sizeof(KMTPPictBridgeDpSupportedOperations[0]));
+        for (TInt i = 0; (i < count); i++)
+            {
+            aArray.Append(KMTPPictBridgeDpSupportedOperations[i]);
+            }
+        }
+        break;  
+
+    case EStorageSystemTypes:
+        aArray.Append(CMTPStorageMetaData::ESystemTypeDefaultFileSystem);
+        break; 
+
+    default:
+        // Unrecognised category, leave aArray unmodified.
+        break;
+        }
+    __FLOG(_L8("<< CMTPPictBridgeDataProvider::Supported"));
+    }
+
+void CMTPPictBridgeDataProvider::SupportedL(TMTPSupportCategory aCategory, CDesCArray& /*aStrings*/) const
+    {
+    switch (aCategory) 
+        {
+        case EFolderExclusionSets:
+            break;
+        case EFormatExtensionSets:
+            break;
+        default:
+            break;
+        }
+    }
+
+
+// --------------------------------------------------------------------------
+// CMTPPictBridgeDataProvider::NotifyStorageEnumerationCompleteL()
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgeDataProvider::NotifyStorageEnumerationCompleteL()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDataProvider::NotifyStorageEnumerationCompleteL"));    
+    Framework().StorageEnumerationCompleteL();
+    __FLOG(_L8("<< CMTPPictBridgeDataProvider::NotifyStorageEnumerationCompleteL"));    
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+#ifdef __FLOG_ACTIVE
+void CMTPPictBridgeDataProvider::NotifyEnumerationCompleteL(TUint32 aStorageId, TInt aErr )
+#else
+void CMTPPictBridgeDataProvider::NotifyEnumerationCompleteL(TUint32 aStorageId, TInt /* aErr*/ )
+#endif
+    {
+    __FLOG_VA((_L8(">> CMTPPictBridgeDataProvider::NotifyEnumerationCompletedL storage 0x%08X status %d"), aStorageId, aErr ));
+    Framework().ObjectEnumerationCompleteL(aStorageId);
+    __FLOG(_L8("<< CMTPPictBridgeDataProvider::NotifyEnumerationCompletedL"));
+    }
+
+
+// --------------------------------------------------------------------------
+// Find or create a request processor that can process the specified request.
+// @param aRequest    The request to be processed
+// @param aConnection The connection from which the request comes
+// @return the idx of the found/created request processor
+// --------------------------------------------------------------------------
+//
+TInt CMTPPictBridgeDataProvider::LocateRequestProcessorL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDataProvider::LocateRequestProcessorL"));        
+    
+    TInt idx(KErrNotFound);
+    TInt count(iActiveProcessors.Count());
+    for (TInt i = 0; (i < count); i++)
+        {
+        if (iActiveProcessors[i]->Match(aRequest, aConnection))
+            {
+            idx = i;
+            break;
+            }
+        }
+        
+    if (idx == KErrNotFound)
+        {
+        MMTPRequestProcessor* processorP = MTPPictBridgeDpProcessor::CreateL(Framework(), aRequest, aConnection, *this);
+        CleanupReleasePushL(*processorP);
+        iActiveProcessors.AppendL(processorP);
+        CleanupStack::Pop();
+        idx = count;
+        }
+        
+    __FLOG(_L8("<< CMTPPictBridgeDataProvider::LocateRequestProcessorL")); 
+    return idx;
+    }
+
+// --------------------------------------------------------------------------
+// Find or create a request processor that can process the specified event.
+// @param aEvent    The event to be processed
+// @param aConnection The connection from which the request comes
+// @return the idx of the found request processor, KErrNotFound if not found
+// --------------------------------------------------------------------------
+//
+TInt CMTPPictBridgeDataProvider::LocateRequestProcessorL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection)
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDataProvider::LocateRequestProcessorL (event)"));
+        
+    TInt idx(KErrNotFound);
+    TInt count(iActiveProcessors.Count());
+    for (TInt i = 0; (i < count); i++)
+        {
+        if (iActiveProcessors[i]->Match(aEvent, aConnection))
+            {
+            idx = i;
+            break;
+            }
+        }    
+    __FLOG(_L8("<< CMTPPictBridgeDataProvider::LocateRequestProcessorL (event)"));
+    return idx;
+    }
+
+// --------------------------------------------------------------------------
+// Cleans up outstanding request processors when a session is closed.
+// @param aSession notification parameter block
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgeDataProvider::SessionClosedL(const TMTPNotificationParamsSessionChange& aSession)
+    {
+    __FLOG_VA((_L8(">> CMTPPictBridgeDataProvider::SessionClosedL SessionID = %d"), aSession.iMTPId));
+    
+    TInt count = iActiveProcessors.Count();
+    while(count--)
+        {
+        MMTPRequestProcessor* processorP = iActiveProcessors[count];
+        TUint32 sessionId = processorP->SessionId();
+        if((sessionId == aSession.iMTPId) && (processorP->Connection().ConnectionId() == aSession.iConnection.ConnectionId()))
+            {
+            processorP->Release();
+            iActiveProcessors.Remove(count);
+            }
+        }
+
+    iServerP->MtpSessionClosed();
+    __FLOG(_L8("<< CMTPPictBridgeDataProvider::SessionClosedL"));
+    }
+
+// --------------------------------------------------------------------------
+// Prepares for a newly-opened session.
+// @param aSession notification parameter block
+// --------------------------------------------------------------------------
+//
+#ifdef __FLOG_ACTIVE
+void CMTPPictBridgeDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession )
+#else
+void CMTPPictBridgeDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& /*aSession*/ )
+#endif
+    {
+    __FLOG_VA((_L8(" CMTPPictBridgeDataProvider::SessionOpenedL SessionID = %d"), aSession.iMTPId));
+    iServerP->MtpSessionOpened();
+    }
+
+TUint32 CMTPPictBridgeDataProvider::DeviceDiscoveryHandle() const
+    {    
+    return iPictBridgeEnumeratorP->DeviceDiscoveryHandle();
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpgetformatcapabilities.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,233 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <mtp/cmtptypeinterdependentpropdesc.h>
+#include <mtp/cmtptypeobjectpropdesc.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include "cmtprequestprocessor.h"
+#include "cmtppictbridgegetformatcapabilities.h"
+#include "ptpdef.h"
+
+/**
+Two-phase construction method
+@param aFramework   The data provider framework
+@param aConnection  The connection object
+@param aDataProvider  The pictbridge Dp
+*/ 
+MMTPRequestProcessor* CMTPPictBridgeDpGetFormatCapabilities::NewL(
+    MMTPDataProviderFramework& aFramework,
+    MMTPConnection& aConnection,
+    CMTPPictBridgeDataProvider& aDataProvider)
+    {
+    CMTPPictBridgeDpGetFormatCapabilities* self = new (ELeave) CMTPPictBridgeDpGetFormatCapabilities(aFramework, aConnection, aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/
+CMTPPictBridgeDpGetFormatCapabilities::~CMTPPictBridgeDpGetFormatCapabilities()
+    {
+    delete iCapabilityList;
+    __FLOG_CLOSE;
+    }
+
+/**
+ServiceL
+*/
+void CMTPPictBridgeDpGetFormatCapabilities::ServiceL()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpGetFormatCapabilities::ServiceL"));
+    delete iCapabilityList;
+    iCapabilityList = CMTPTypeFormatCapabilityList::NewL();
+    iFormatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    BuildFormatScriptL();
+ 
+    SendDataL(*iCapabilityList); 
+    __FLOG(_L8("<< CMTPPictBridgeDpGetFormatCapabilities::ServiceL"));   
+    }
+    
+/**
+BuildFormatScriptL
+*/
+void CMTPPictBridgeDpGetFormatCapabilities::BuildFormatScriptL() 
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpGetFormatCapabilities::BuildFormatScriptL"));
+    CMTPTypeInterdependentPropDesc*  interDesc = CMTPTypeInterdependentPropDesc::NewLC();
+    CMTPTypeFormatCapability* frmCap = CMTPTypeFormatCapability::NewLC( EMTPFormatCodeScript ,interDesc );
+     
+    //for group code
+    //EMTPObjectPropCodeStorageID
+    CMTPTypeObjectPropDesc* objectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeStorageID);
+    objectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeStorageID));
+    frmCap->AppendL( objectProperty );
+    
+    //EMTPObjectPropCodeObjectFormat
+    objectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectFormat);
+    objectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeObjectFormat));
+    frmCap->AppendL( objectProperty );
+    
+    //EMTPObjectPropCodeProtectionStatus
+    frmCap->AppendL( ServiceProtectionStatusL() );
+    
+    //EMTPObjectPropCodeObjectSize
+    objectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectSize);
+    objectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeObjectSize));
+    frmCap->AppendL( objectProperty );
+    
+    //EMTPObjectPropCodeObjectFileName
+    objectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectFileName);
+    objectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeObjectFileName));
+    frmCap->AppendL( objectProperty );
+    
+    //EMTPObjectPropCodeDateModified
+    objectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeDateModified);
+    objectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeDateModified));
+    frmCap->AppendL(  objectProperty );
+    
+    //EMTPObjectPropCodeParentObject
+    objectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeParentObject);
+    objectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeParentObject));
+    frmCap->AppendL( objectProperty );
+    
+    //EMTPObjectPropCodePersistentUniqueObjectIdentifier
+    objectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodePersistentUniqueObjectIdentifier);
+    objectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodePersistentUniqueObjectIdentifier));
+    frmCap->AppendL( objectProperty );
+    
+    //EMTPObjectPropCodeName
+    objectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeName);
+    objectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeName));
+    frmCap->AppendL( objectProperty); 
+    
+    //EMTPObjectPropCodeNonConsumable
+    frmCap->AppendL(ServiceNonConsumableL() );
+ 
+    iCapabilityList->AppendL(frmCap);
+    CleanupStack::Pop(frmCap);
+    CleanupStack::Pop(interDesc);
+    __FLOG(_L8("<< CMTPPictBridgeDpGetFormatCapabilities::BuildFormatScriptL"));
+    }
+
+/**
+ServiceProtectionStatusL
+*/
+CMTPTypeObjectPropDesc* CMTPPictBridgeDpGetFormatCapabilities::ServiceProtectionStatusL()
+    {
+    CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT16);
+    CleanupStack::PushL(expectedForm);
+    //Currently, we only support EMTPProtectionNoProtection and EMTPProtectionReadOnly
+    TUint16 values[] = {EMTPProtectionNoProtection, EMTPProtectionReadOnly};
+    TUint   numValues((sizeof(values) / sizeof(values[0])));
+    for (TUint i = 0; i < numValues; i++)
+        {
+        TMTPTypeUint16 data(values[i]);
+        expectedForm->AppendSupportedValueL(data);
+        }  
+    CMTPTypeObjectPropDesc* ret = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeProtectionStatus, *expectedForm);
+    ret->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeProtectionStatus));
+    CleanupStack::PopAndDestroy(expectedForm);
+    return ret;
+    }
+
+/**
+ServiceNonConsumableL
+*/
+CMTPTypeObjectPropDesc* CMTPPictBridgeDpGetFormatCapabilities::ServiceNonConsumableL()
+    {
+    CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT8);
+    CleanupStack::PushL(expectedForm);
+    TUint8 values[] = {0,1};
+    TUint   numValues((sizeof(values) / sizeof(values[0])));
+    for (TUint i = 0; i < numValues; i++)
+        {
+        TMTPTypeUint8 data(values[i]);
+        expectedForm->AppendSupportedValueL(data);
+        }   
+    CMTPTypeObjectPropDesc* ret = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeNonConsumable, *expectedForm);
+    ret->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeNonConsumable));
+    CleanupStack::PopAndDestroy(expectedForm);
+    
+    return ret;
+    }
+
+/**
+CheckRequestL
+*/
+TMTPResponseCode CMTPPictBridgeDpGetFormatCapabilities::CheckRequestL()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpGetFormatCapabilities::CheckRequestL"));   
+    TMTPResponseCode response = CMTPRequestProcessor::CheckRequestL(); 
+    if(EMTPRespCodeOK != response)
+        return response;
+    
+    TUint32 formatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    
+    if((formatCode != EMTPFormatCodeScript)&& (iFormatCode != KMTPFormatsAll))
+        {
+        return EMTPRespCodeInvalidObjectFormatCode;
+        }
+
+    __FLOG(_L8("<< CMTPPictBridgeDpGetFormatCapabilities::CheckRequestL"));   
+    return EMTPRespCodeOK; 
+    }
+    
+/**
+Standard c++ constructor
+*/  
+CMTPPictBridgeDpGetFormatCapabilities::CMTPPictBridgeDpGetFormatCapabilities(
+    MMTPDataProviderFramework& aFramework,
+    MMTPConnection& aConnection,
+    CMTPPictBridgeDataProvider& aDataProvider):
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
+    iPictBridgeDP(aDataProvider)
+    {
+    }
+    
+/**
+ConstructL
+*/      
+void CMTPPictBridgeDpGetFormatCapabilities::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("CMTPPictBridgeDpGetFormatCapabilities::ConstructL")); 
+    }
+
+/**
+GetPropertyGroupNumber
+*/  
+TUint16  CMTPPictBridgeDpGetFormatCapabilities::GetPropertyGroupNumber(const TUint16 aPropCode) const
+    {
+    
+    // begin from group 1, since group 0 is not used
+    for(int group = 1; group <= KMTPDpPropertyGroupNumber; group++)
+        {
+        for( int propCodeIndex = 0 ; propCodeIndex < KMTPDpPropertyNumber ; propCodeIndex++)
+            {
+                if(KMTPDpPropertyGroups[group][propCodeIndex] == aPropCode)
+                    {
+                    return group;
+                    }
+            }
+        }
+    
+    // if not foud, the group number should be 0.
+    return 0;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpgetobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,138 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <f32file.h>
+
+#include <mtp/cmtptypefile.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptyperequest.h>
+#include "cmtppictbridgedpgetobject.h"
+#include "cmtppictbridgeprinter.h"
+#include "mtppictbridgedppanic.h"
+#include "cmtprequestchecker.h"
+#include "cptpserver.h"
+
+/**
+Verification data for the GetNumObjects request
+*/
+const TMTPRequestElementInfo KMTPGetObjectPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrFile, 0, 0, 0}
+    };
+
+//=============================================================================
+//
+//=============================================================================
+MMTPRequestProcessor* CMTPPictBridgeDpGetObject::NewL(
+	MMTPDataProviderFramework& aFramework,
+	MMTPConnection& aConnection,
+	CMTPPictBridgeDataProvider& aDataProvider)
+    {       
+    CMTPPictBridgeDpGetObject* self = new (ELeave) CMTPPictBridgeDpGetObject(aFramework, aConnection, aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);         
+    return self;
+    }
+
+/**
+Destructor
+*/  
+CMTPPictBridgeDpGetObject::~CMTPPictBridgeDpGetObject()
+    {   
+    __FLOG(_L8("~CMTPPictBridgeDpGetObject"));          
+    delete iFileObject;
+    __FLOG_CLOSE;
+    }
+    
+/**
+Standard c++ constructor
+*/  
+CMTPPictBridgeDpGetObject::CMTPPictBridgeDpGetObject(
+	MMTPDataProviderFramework& aFramework,
+	MMTPConnection& aConnection,
+	CMTPPictBridgeDataProvider& aDataProvider): 
+    CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetObjectPolicy),
+    iPictBridgeDP(aDataProvider),
+    iError(EMTPRespCodeOK)
+    {    
+    }
+
+/**
+Second-phase constructor.
+*/        
+void CMTPPictBridgeDpGetObject::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    }
+
+/**
+GetObject request handler
+*/      
+void CMTPPictBridgeDpGetObject::ServiceL()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpGetObject::ServiceL"));        
+    __ASSERT_DEBUG(iRequestChecker, Panic(EMTPPictBridgeDpRequestCheckNull));
+    TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    //does not take ownership
+    CMTPObjectMetaData* objectInfo = iRequestChecker->GetObjectInfo(objectHandle);
+    if (!objectInfo)
+        {
+        __FLOG_VA((_L8(">> CMTPPictBridgeDpGetObject::ServiceL no object info for objectHandle %d"), objectHandle));
+        // The object handle has already been checked, so an invalid handle can
+        // only occur if it was invalidated during a context switch between
+        // the validation time and now.
+        iError = EMTPRespCodeInvalidObjectHandle;
+        iPictBridgeDP.PtpServer()->Printer()->DpsFileSent(KErrBadHandle);
+        }
+    else
+        {
+        BuildFileObjectL(objectInfo->DesC(CMTPObjectMetaData::ESuid));
+        SendDataL(*iFileObject);
+        iPictBridgeDP.PtpServer()->Printer()->DpsFileSent(KErrNone);
+        }
+    __FLOG(_L8("<< CMTPPictBridgeDpGetObject::ServiceL"));
+    }
+
+//=============================================================================
+//
+//=============================================================================
+void CMTPPictBridgeDpGetObject::BuildFileObjectL(const TDesC& aFileName)
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpGetObject::BuildFileObjectL"));            
+    delete iFileObject;
+    iFileObject = NULL;
+    iFileObject = CMTPTypeFile::NewL(iFramework.Fs(), aFileName, EFileRead);
+    __FLOG(_L8("<< CMTPPictBridgeDpGetObject::BuildFileObjectL"));            
+    }
+    
+
+//=============================================================================
+//
+//=============================================================================
+TBool CMTPPictBridgeDpGetObject::DoHandleResponsePhaseL()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpGetObject::DoHandleResponsePhaseL"));            
+    TMTPResponseCode responseCode = (iCancelled ? EMTPRespCodeIncompleteTransfer : iError);
+    SendResponseL(responseCode);
+    __FLOG(_L8("<< CMTPPictBridgeDpGetObject::DoHandleResponsePhaseL"));
+    return EFalse;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpgetobjectinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,223 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <f32file.h>
+#include <imageconversion.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtptypeobjectinfo.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpstoragemgr.h>
+#include "cmtppictbridgedpgetobjectinfo.h"
+#include "mtppictbridgedpconst.h"
+#include "mtppictbridgedppanic.h"
+#include "cmtprequestchecker.h"
+#include "cptpserver.h"
+
+/**
+Two-phase construction method
+*/ 
+MMTPRequestProcessor* CMTPPictBridgeDpGetObjectInfo::NewL(
+    MMTPDataProviderFramework& aFramework,              
+    MMTPConnection& aConnection,
+    CMTPPictBridgeDataProvider& aDataProvider)
+    {
+    CMTPPictBridgeDpGetObjectInfo* self = new (ELeave) CMTPPictBridgeDpGetObjectInfo(aFramework, aConnection, aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/  
+CMTPPictBridgeDpGetObjectInfo::~CMTPPictBridgeDpGetObjectInfo()
+    {   
+    __FLOG(_L8("CMTPPictBridgeDpGetObjectInfo::~CMTPPictBridgeDpGetObjectInfo"));
+    delete iObjectInfoToBuildP;
+    __FLOG_CLOSE;
+    }
+
+/**
+Standard c++ constructor
+*/  
+CMTPPictBridgeDpGetObjectInfo::CMTPPictBridgeDpGetObjectInfo(
+    MMTPDataProviderFramework& aFramework,
+    MMTPConnection& aConnection,
+    CMTPPictBridgeDataProvider& aDataProvider)
+    :CMTPRequestProcessor(aFramework, aConnection, 0, NULL ),
+    iPictBridgeDP(aDataProvider)
+    {
+    }
+
+/**
+GetObjectInfo request handler
+*/
+void CMTPPictBridgeDpGetObjectInfo::ServiceL()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpGetObjectInfo::ServiceL"));
+    BuildObjectInfoL();
+    SendDataL(*iObjectInfoToBuildP);    
+    __FLOG(_L8("<< CMTPPictBridgeDpGetObjectInfo::ServiceL"));
+    }
+
+/**
+Second-phase construction
+*/      
+void CMTPPictBridgeDpGetObjectInfo::ConstructL()
+    {
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+    iObjectInfoToBuildP = CMTPTypeObjectInfo::NewL();
+    }
+
+/**
+Populate the object info dataset
+*/      
+void CMTPPictBridgeDpGetObjectInfo::BuildObjectInfoL()  
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpGetObjectInfo::BuildObjectInfoL"));
+    __ASSERT_DEBUG(iRequestChecker, Panic(EMTPPictBridgeDpRequestCheckNull));
+
+    TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+
+    __FLOG_VA((_L8(" object handle 0x%x"), objectHandle));    
+
+    //1. storage id
+    TUint32 storageId(iFramework.StorageMgr().DefaultStorageId()); // we always use default storage for DPS
+
+    iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::EStorageID, storageId); 
+
+    //2. object format
+    TUint16 format(EMTPFormatCodeScript); // we only handle DPS script
+    iObjectInfoToBuildP->SetUint16L(CMTPTypeObjectInfo::EObjectFormat, format);
+    __FLOG_VA((_L8(" format ok 0x%x"), format));   
+
+    //3. protection status,
+    TUint16 protection(EMTPProtectionNoProtection); // we do not care about protection
+
+    iObjectInfoToBuildP->SetUint16L(CMTPTypeObjectInfo::EProtectionStatus, protection);
+    __FLOG_VA((_L8(" protection(%d) ok"), protection));   
+
+    //4. object compressed size
+    // see SetFileSizeDateL
+
+    //5. thumb format      
+    iObjectInfoToBuildP->SetUint16L(CMTPTypeObjectInfo::EThumbFormat, 0);
+    //6. thumb compressed size
+    iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::EThumbCompressedSize, 0);
+    //7. thumb pix width
+    iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::EThumbPixWidth, 0);
+    //8, thumb pix height
+    iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::EThumbPixHeight, 0);
+    //9. image pix width
+    iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::EImagePixWidth, 0);
+    //10. image pix height
+    iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::EImagePixHeight, 0);
+    //11. image bit depth
+    iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::EImageBitDepth, 0);
+   
+    CMTPObjectMetaData* objectP = CMTPObjectMetaData::NewL();
+    CleanupStack::PushL(objectP);
+
+    iFramework.ObjectMgr().ObjectL(objectHandle, *objectP);
+
+    //12. Parent object
+    TUint32 parent(objectP->Uint(CMTPObjectMetaData::EParentHandle)); 
+    iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::EParentObject, parent);
+        
+    //13 and 14. Association type and description
+    TUint16 associationType(EMTPAssociationTypeUndefined);
+    iObjectInfoToBuildP->SetUint16L(CMTPTypeObjectInfo::EAssociationType, associationType); 
+    iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::EAssociationDescription, 0);
+        
+    //15. sequence number
+    iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::ESequenceNumber, 0);
+    
+    //16. file name
+    //use the name without full path specification
+    TParse parse;
+    User::LeaveIfError( parse.Set(objectP->DesC(CMTPObjectMetaData::ESuid), NULL, NULL) );    
+    iObjectInfoToBuildP->SetStringL(CMTPTypeObjectInfo::EFilename, parse.NameAndExt());
+    
+    //4, compressed size, 17 Date created, and 18 Date modified
+    SetFileSizeDateL(objectP->DesC(CMTPObjectMetaData::ESuid), (objectHandle==iPictBridgeDP.PtpServer()->DeviceDiscoveryHandle())); 
+    
+    //18. keyword
+    //empty keyword
+    iObjectInfoToBuildP->SetStringL(CMTPTypeObjectInfo::EKeywords, KNullDesC);
+    CleanupStack::PopAndDestroy(objectP);
+    __FLOG(_L8("<< CMTPPictBridgeDpGetObjectInfo::BuildObjectInfoL"));
+    }
+
+
+/**
+Set file properties
+*/ 
+void CMTPPictBridgeDpGetObjectInfo::SetFileSizeDateL(const TDesC& aFileName, TBool aDiscoveryFile)
+    {
+    __FLOG_VA((_L16(">> CMTPPictBridgeDpGetObjectInfo::SetFileSizeDateL aDiscoveryFile %d %S"), aDiscoveryFile, &aFileName));
+
+    // open the file for retrieving information
+    RFile file;
+    TInt size(0);
+    TTime modifiedTime=0;
+    
+    if (!aDiscoveryFile)
+        {
+        User::LeaveIfError(file.Open(iFramework.Fs(), aFileName, EFileShareReadersOnly));
+        CleanupClosePushL(file);
+        
+        //file size
+        User::LeaveIfError(file.Size(size));
+        
+        //file modified time
+        User::LeaveIfError(file.Modified(modifiedTime));
+        }
+    else
+        {
+        //file modified time
+        modifiedTime.HomeTime();
+        }
+
+    //file size
+    TUint32 fileSize=size;
+    iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::EObjectCompressedSize, fileSize);
+    __FLOG_VA((_L8(" file size %d"), fileSize));   
+
+    //file modified time
+    const TInt KTimeStringLen=0x0f;// YYYYMMDDThhmmss(.s), we exclude tenths of seconds and use length 15, (MTP 1.0 spec, section 3.2.5)
+    TBuf<KTimeStringLen> modifiedTimeBuffer;
+    _LIT(KTimeFormat,"%Y%M%DT%H%M%T%S");
+    modifiedTime.FormatL(modifiedTimeBuffer, KTimeFormat);
+
+    CMTPTypeString* dateString = CMTPTypeString::NewLC(modifiedTimeBuffer);
+    iObjectInfoToBuildP->SetStringL(CMTPTypeObjectInfo::EDateModified, dateString->StringChars());
+    //file creation time, set it as the same as modified time, as Symbian does not support this field
+    iObjectInfoToBuildP->SetStringL(CMTPTypeObjectInfo::EDateCreated, dateString->StringChars());   
+    CleanupStack::PopAndDestroy(dateString);
+    
+    if (!aDiscoveryFile)
+        {
+        CleanupStack::PopAndDestroy(&file);
+        }
+    
+    __FLOG_VA((_L16("<< CMTPPictBridgeDpGetObjectInfo::SetFileSizeDateL %S"),&modifiedTimeBuffer));
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpgetobjectpropdesc.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,229 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <f32file.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtptypeobjectpropdesc.h>
+
+#include <mtp/cmtptypestring.h>
+#include "cmtppictbridgedpgetobjectpropdesc.h"
+#include "mtppictbridgedpconst.h"
+#include "mtppictbridgedppanic.h"
+
+ 
+_LIT(KMtpObjDescObjFileName, "[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 7}\\.[[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 2}]?");
+
+/**
+Two-phase construction method
+@param aPlugin  The data provider plugin
+@param aFramework   The data provider framework
+@param aConnection  The connection from which the request comes
+@param aDataProvider  The pictBridge dataprovider
+@return a pointer to the created request processor object
+*/ 
+MMTPRequestProcessor* CMTPPictBridgeGetObjectPropDesc::NewL(
+    MMTPDataProviderFramework& aFramework, 
+    MMTPConnection& aConnection,
+    CMTPPictBridgeDataProvider& aDataProvider )
+    {
+    CMTPPictBridgeGetObjectPropDesc* self = new (ELeave) CMTPPictBridgeGetObjectPropDesc(aFramework, aConnection, aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/      
+CMTPPictBridgeGetObjectPropDesc::~CMTPPictBridgeGetObjectPropDesc()
+    {   
+    delete iObjectProperty;
+    }
+
+/**
+Standard c++ constructor
+*/  
+CMTPPictBridgeGetObjectPropDesc::CMTPPictBridgeGetObjectPropDesc(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider)
+    :CMTPRequestProcessor(aFramework, aConnection, 0, NULL), iPictBridgeDP(aDataProvider)
+    {
+    }
+    
+/**
+GetObjectPropDesc request handler
+*/  
+void CMTPPictBridgeGetObjectPropDesc::ServiceL()
+    {
+    delete iObjectProperty;
+    iObjectProperty = NULL; 
+    
+    TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    switch(propCode)
+        {
+        case EMTPObjectPropCodeStorageID:
+            ServiceStorageIdL();
+            break;
+        case EMTPObjectPropCodeObjectFormat:
+            ServiceObjectFormatL();
+            break;
+        case EMTPObjectPropCodeProtectionStatus:
+            ServiceProtectionStatusL();
+            break;
+        case EMTPObjectPropCodeObjectSize:
+            ServiceObjectSizeL();
+            break;
+        case EMTPObjectPropCodeObjectFileName:
+            ServiceFileNameL();
+            break;
+        case EMTPObjectPropCodeDateModified:
+            ServiceDateModifiedL();
+            break;
+        case EMTPObjectPropCodeParentObject:
+            ServiceParentObjectL();
+            break;
+        case EMTPObjectPropCodePersistentUniqueObjectIdentifier:
+            ServicePuidL();
+            break;
+        case EMTPObjectPropCodeName:
+            ServiceNameL();
+            break;
+        case EMTPObjectPropCodeNonConsumable:
+            ServiceNonConsumableL();
+            break;
+        default:
+            Panic(EMTPPictBridgeDpUnsupportedProperty);
+        }
+    __ASSERT_DEBUG(iObjectProperty, Panic(EMTPPictBridgeDpObjectPropertyNull));
+    iObjectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(propCode));
+    SendDataL(*iObjectProperty);    
+    }
+
+
+/**
+Second-phase construction
+*/          
+void CMTPPictBridgeGetObjectPropDesc::ConstructL()
+    {
+    }
+        
+
+void CMTPPictBridgeGetObjectPropDesc::ServiceStorageIdL()
+    {
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeStorageID);    
+    }
+    
+void CMTPPictBridgeGetObjectPropDesc::ServiceObjectFormatL()
+    {   
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectFormat); 
+    }
+    
+void CMTPPictBridgeGetObjectPropDesc::ServiceProtectionStatusL()
+    {
+    CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT16);
+    CleanupStack::PushL(expectedForm);
+    //Currently, we only support EMTPProtectionNoProtection and EMTPProtectionReadOnly
+    TUint16 values[] = {EMTPProtectionNoProtection, EMTPProtectionReadOnly};
+    TUint   numValues((sizeof(values) / sizeof(values[0])));
+    for (TUint i = 0; i < numValues; i++)
+        {
+        TMTPTypeUint16 data(values[i]);
+        expectedForm->AppendSupportedValueL(data);
+        }  
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeProtectionStatus, *expectedForm);          
+    CleanupStack::PopAndDestroy(expectedForm);
+    }
+    
+void CMTPPictBridgeGetObjectPropDesc::ServiceObjectSizeL()
+    {
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectSize);   
+    }
+    
+    
+void CMTPPictBridgeGetObjectPropDesc::ServiceFileNameL()
+    {
+        CMTPTypeString* form = CMTPTypeString::NewLC( KMtpObjDescObjFileName ); // + form
+        // Althrough iObjectProperty is released in ServiceL(),
+        // release it here maybe a more safer way 
+        if ( iObjectProperty != NULL )
+        {
+        delete iObjectProperty;
+        iObjectProperty = NULL;
+        }
+
+        iObjectProperty = CMTPTypeObjectPropDesc::NewL( EMTPObjectPropCodeObjectFileName,
+            CMTPTypeObjectPropDesc::ERegularExpressionForm,
+            form );
+
+        CleanupStack::PopAndDestroy( form ); // - form
+    }
+    
+void CMTPPictBridgeGetObjectPropDesc::ServiceDateModifiedL()
+    {
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeDateModified);
+    }
+    
+void CMTPPictBridgeGetObjectPropDesc::ServiceParentObjectL()
+    {
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeParentObject);
+    }
+    
+void CMTPPictBridgeGetObjectPropDesc::ServicePuidL()
+    {
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodePersistentUniqueObjectIdentifier);
+    }
+    
+void CMTPPictBridgeGetObjectPropDesc::ServiceNameL()
+    {
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeName); 
+    }
+    
+void CMTPPictBridgeGetObjectPropDesc::ServiceNonConsumableL()
+    {
+    CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT8);
+    CleanupStack::PushL(expectedForm);
+    TUint8 values[] = {0,1};
+    TUint   numValues((sizeof(values) / sizeof(values[0])));
+    for (TUint i = 0; i < numValues; i++)
+        {
+        TMTPTypeUint8 data(values[i]);
+        expectedForm->AppendSupportedValueL(data);
+        }   
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeNonConsumable, *expectedForm);     
+    CleanupStack::PopAndDestroy(expectedForm);
+    }
+
+
+    
+TUint16  CMTPPictBridgeGetObjectPropDesc::GetPropertyGroupNumber(const TUint16 aPropCode) const
+    {
+    // begin from group 1, since group 0 is not used
+    for(int group = 1; group <= KMTPDpPropertyGroupNumber; group++)
+        {
+        for( int propCodeIndex = 0 ; propCodeIndex < KMTPDpPropertyNumber ; propCodeIndex++)
+            {
+                if(KMTPDpPropertyGroups[group][propCodeIndex] == aPropCode)
+                    {
+                    return group;
+                    }
+            }
+        }
+    
+    // if not foud, the group number should be 0.
+    return 0;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpgetobjectproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,471 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtptypeobjectproplist.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include "cmtppictbridgedpgetobjectproplist.h"
+#include "mtppictbridgedppanic.h"
+#include "mtppictbridgedpconst.h"
+#include "cptpserver.h"
+
+/**
+Two-phase construction method
+@param aFramework   The data provider framework
+@param aConnection  The connection object
+@param aDataProvider  The pictbridge Dp
+*/
+MMTPRequestProcessor* CMTPPictBridgeDpGetObjectPropList::NewL(
+    MMTPDataProviderFramework& aFramework,
+    MMTPConnection& aConnection,
+    CMTPPictBridgeDataProvider& aDataProvider )
+    {  
+    CMTPPictBridgeDpGetObjectPropList* self = new (ELeave) CMTPPictBridgeDpGetObjectPropList(aFramework, aConnection, aDataProvider);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+/**
+Destructor
+*/
+CMTPPictBridgeDpGetObjectPropList::~CMTPPictBridgeDpGetObjectPropList()
+    {
+    __FLOG(_L8("+~CMTPPictBridgeDpGetObjectPropList()"));
+    
+    delete iHandles;
+    delete iPropertyList;
+    iDpSingletons.Close();
+    delete iObjMeta;
+    
+    __FLOG(_L8("-~CMTPPictBridgeDpGetObjectPropList()"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Standard c++ constructor
+*/  
+CMTPPictBridgeDpGetObjectPropList::CMTPPictBridgeDpGetObjectPropList(
+    MMTPDataProviderFramework& aFramework,
+    MMTPConnection& aConnection,
+    CMTPPictBridgeDataProvider& aDataProvider ) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL ),
+    iPictBridgeDP(aDataProvider)
+    {
+    }
+
+/**
+ConstructL
+*/      
+void CMTPPictBridgeDpGetObjectPropList::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("+CMTPPictBridgeDpGetObjectPropList::ConstructL()"));
+    
+	iDpSingletons.OpenL(iFramework);
+    iPropertyList = CMTPTypeObjectPropList::NewL();
+	iObjMeta = CMTPObjectMetaData::NewL();
+	
+	__FLOG(_L8("-CMTPPictBridgeDpGetObjectPropList::ConstructL()"));
+    }
+
+/**
+ServiceL
+*/  
+void CMTPPictBridgeDpGetObjectPropList::ServiceL()
+    {
+    __FLOG(_L8("+CMTPPictBridgeDpGetObjectPropList::ServiceL()"));
+    
+    GetObjectHandlesL();
+    TInt numObjects(iHandles->NumElements());
+    TUint32 propCode( Request().Uint32( TMTPTypeRequest::ERequestParameter3 ));
+    // get group code
+	TUint32 groupCode(Request().Uint32(TMTPTypeRequest::ERequestParameter4));
+	TBool isDiscoveryFile( EFalse );
+	
+    for ( TInt i(0); i < numObjects; i++ )
+        {
+        TUint32 handle( iHandles->ElementUint(i) );
+        iFramework.ObjectMgr().ObjectL(handle, *iObjMeta);
+        TFileName file(iObjMeta->DesC(CMTPObjectMetaData::ESuid));
+        TInt ret = iFramework.Fs().Entry(iObjMeta->DesC(CMTPObjectMetaData::ESuid), iFileEntry);
+        if (( ret != KErrNone )&& ( handle == iPictBridgeDP.PtpServer()->DeviceDiscoveryHandle() ))
+            {
+            isDiscoveryFile = ETrue;
+            }
+        else
+            {
+            User::Leave( ret );
+            }
+        
+        if ( KMaxTUint == propCode )
+            {
+            ServiceAllPropertiesL( handle, isDiscoveryFile );
+            }
+        else if ( 0 == propCode )
+            {
+            ServiceGroupPropertiesL( handle, groupCode, isDiscoveryFile );
+            }
+        else 
+            {
+            ServiceOneObjectPropertyL( handle, propCode, isDiscoveryFile );
+            } 
+        isDiscoveryFile = EFalse;
+        }
+    SendDataL( *iPropertyList );
+    
+    __FLOG(_L8("-CMTPPictBridgeDpGetObjectPropList::ServiceL()"));
+    }
+
+/**
+CheckRequestL
+*/
+TMTPResponseCode CMTPPictBridgeDpGetObjectPropList::CheckRequestL()
+    {
+    __FLOG(_L8("+CMTPPictBridgeDpGetObjectPropList::CheckRequestL()"));
+    
+    TMTPResponseCode result = CMTPRequestProcessor::CheckRequestL();
+
+    if ( result == EMTPRespCodeOK )
+        {
+        result = CheckPropCode();
+        }
+    if ( result == EMTPRespCodeOK )
+        {
+        result = CheckDepth();
+        }
+    
+    __FLOG(_L8("-CMTPPictBridgeDpGetObjectPropList::CheckRequestL()"));
+    return result;
+    }
+
+/**
+CheckPropCode
+*/
+TMTPResponseCode CMTPPictBridgeDpGetObjectPropList::CheckPropCode() const
+    {
+    __FLOG(_L8("+CMTPPictBridgeDpGetObjectPropList::CheckPropCode()"));
+    
+    TMTPResponseCode response = EMTPRespCodeOK;
+    TUint32 formatCode = Request().Uint32( TMTPTypeRequest::ERequestParameter2 );
+    TUint32 propCode = Request().Uint32( TMTPTypeRequest::ERequestParameter3 );
+
+    if(( propCode != KMaxTUint ) && ( propCode != 0 ))
+        {
+         const TInt count = sizeof(KMTPPictBridgeDpSupportedProperties) / sizeof(KMTPPictBridgeDpSupportedProperties[0]);
+         TInt i(0);
+         for( i = 0; i < count; i++ )
+           {
+           if( KMTPPictBridgeDpSupportedProperties[i] == propCode )
+             {
+             break;
+             }
+           }
+         if( i == count )
+           {
+           response = EMTPRespCodeInvalidObjectPropCode;
+           }
+        }
+    
+    __FLOG(_L8("-CMTPPictBridgeDpGetObjectPropList::CheckPropCode()"));
+    return response;
+    }
+
+/**
+CheckDepth
+*/
+TMTPResponseCode CMTPPictBridgeDpGetObjectPropList::CheckDepth() const
+    {
+    __FLOG(_L8("+CMTPPictBridgeDpGetObjectPropList::CheckDepth()"));
+    TMTPResponseCode response = EMTPRespCodeSpecificationByDepthUnsupported;
+
+    // We either support no depth at all, or 1 depth or (0xFFFFFFFF) with objecthandle as 0x00000000
+    TUint32 handle( Request().Uint32(TMTPTypeRequest::ERequestParameter1 ));
+    TUint32 depth( Request().Uint32(TMTPTypeRequest::ERequestParameter5 ));
+
+    if ((0 == depth ) || ( 1 == depth ) ||
+            ( KMaxTUint == depth && KMTPHandleNone == handle )) 
+        {
+        response = EMTPRespCodeOK;
+        }
+    
+    __FLOG(_L8("-CMTPPictBridgeDpGetObjectPropList::CheckDepth()"));
+    return response; 
+    }
+
+/**
+GetObjectHandlesL
+*/
+void CMTPPictBridgeDpGetObjectPropList::GetObjectHandlesL()
+    {
+    __FLOG(_L8("+CMTPPictBridgeDpGetObjectPropList::GetObjectHandlesL()"));
+    
+    TUint32 handle(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
+    TUint32 formatCode(Request().Uint32(TMTPTypeRequest::ERequestParameter2));
+    TUint32 depth(Request().Uint32(TMTPTypeRequest::ERequestParameter5));
+
+    delete iHandles;
+    iHandles = NULL;
+
+    if (KMTPHandleAll == handle)
+        {
+        GetObjectHandlesL(KMTPStorageAll, formatCode, KMTPHandleNone);
+        }
+    else if (KMTPHandleNone == handle)
+        {
+        GetRootObjectHandlesL(formatCode, depth);
+        }
+    else 
+        {
+        iHandles = CMTPTypeArray::NewL(EMTPTypeAUINT32);
+        iHandles->AppendUintL(handle);
+        }
+    
+    __FLOG(_L8("-CMTPPictBridgeDpGetObjectPropList::GetObjectHandlesL()"));
+    }
+
+/**
+GetObjectHandlesL
+*/
+void CMTPPictBridgeDpGetObjectPropList::GetObjectHandlesL( TUint32 aStorageId, TUint32 aFormatCode, TUint32 aParentHandle )
+    {
+    __FLOG(_L8("+CMTPPictBridgeDpGetObjectPropList::GetObjectHandlesL()"));
+    
+    RMTPObjectMgrQueryContext   context;
+    RArray<TUint>               handles;
+    TMTPObjectMgrQueryParams    params( aStorageId, aFormatCode, aParentHandle );
+    CleanupClosePushL( context );
+    CleanupClosePushL( handles );
+
+    delete iHandles;
+    iHandles = CMTPTypeArray::NewL( EMTPTypeAUINT32 );
+
+    do
+        {
+        iFramework.ObjectMgr().GetObjectHandlesL( params, context, handles );
+        iHandles->AppendL( handles );
+        }
+    while( !context.QueryComplete() );
+
+    CleanupStack::PopAndDestroy( &handles );
+    CleanupStack::PopAndDestroy( &context );
+    
+    __FLOG(_L8("-CMTPPictBridgeDpGetObjectPropList::GetObjectHandlesL()"));
+    }
+
+/**
+GetRootObjectHandlesL
+*/
+void CMTPPictBridgeDpGetObjectPropList::GetRootObjectHandlesL( TUint32 aFormatCode, TUint32 aDepth )
+    {
+    __FLOG(_L8("+CMTPPictBridgeDpGetObjectPropList::GetRootObjectHandlesL()"));
+    
+    if ( KMaxTUint == aDepth )
+        {
+        GetObjectHandlesL( KMTPStorageAll, aFormatCode, KMTPHandleNone );
+        }
+    else if ( 0 == aDepth )
+        {
+        delete iHandles;
+        iHandles = CMTPTypeArray::NewL( EMTPTypeAUINT32 );    //empty array
+        }
+    else
+        {
+        GetObjectHandlesL( KMTPStorageAll, aFormatCode, KMTPHandleNoParent );
+        }
+    
+    __FLOG(_L8("-CMTPPictBridgeDpGetObjectPropList::GetRootObjectHandlesL()"));
+    }
+
+/**
+ServiceAllPropertiesL
+*/
+void CMTPPictBridgeDpGetObjectPropList::ServiceAllPropertiesL( TUint32 aHandle, TBool aDiscoveryFile )
+    {
+    __FLOG(_L8("+CMTPPictBridgeDpGetObjectPropList::ServiceAllPropertiesL()"));
+    
+    if ( iFramework.ObjectMgr().ObjectOwnerId( aHandle ) == iFramework.DataProviderId() )
+        {
+        for ( TUint i(0); i < (sizeof(KMTPPictBridgeDpSupportedProperties) / sizeof(KMTPPictBridgeDpSupportedProperties[0])); i++ )
+            {
+            ServiceOneObjectPropertyL( aHandle, KMTPPictBridgeDpSupportedProperties[i], aDiscoveryFile );
+            }
+        }
+    
+    __FLOG(_L8("-CMTPPictBridgeDpGetObjectPropList::ServiceAllPropertiesL()"));
+    }
+
+/**
+ServiceGroupPropertiesL
+*/
+void CMTPPictBridgeDpGetObjectPropList::ServiceGroupPropertiesL(TUint32 aHandle,TUint16 aGroupCode, TBool aDiscoveryFile )
+	{
+	__FLOG(_L8("+CMTPPictBridgeDpGetObjectPropList::ServiceGroupPropertiesL()"));
+	TBool supportGroupCode = ( aGroupCode >0 )&&( aGroupCode < KMTPDpPropertyGroupNumber+1 );
+	if ( supportGroupCode && ( iFramework.ObjectMgr().ObjectOwnerId(aHandle) == iFramework.DataProviderId() ))
+        {
+        for (TUint propCodeIndex(0); propCodeIndex < KMTPDpPropertyNumber; propCodeIndex++)
+            {
+            TUint16 propCode = KMTPDpPropertyGroups[aGroupCode][propCodeIndex];  
+            if(propCode != 0)
+            	{
+            	ServiceOneObjectPropertyL(aHandle, propCode, aDiscoveryFile );
+            	}
+            }
+        }
+	
+	__FLOG(_L8("-CMTPPictBridgeDpGetObjectPropList::ServiceGroupPropertiesL()"));
+	}
+
+/**
+ServiceOneObjectPropertyL
+*/
+void CMTPPictBridgeDpGetObjectPropList::ServiceOneObjectPropertyL( TUint32 aHandle, TUint32 aPropCode, TBool aDiscoveryFile )
+    {
+    __FLOG(_L8("+CMTPPictBridgeDpGetObjectPropList::ServiceOneObjectPropertyL()"));
+    
+    if ( iFramework.ObjectMgr().ObjectOwnerId( aHandle ) == iFramework.DataProviderId() )
+        {
+        switch(aPropCode)
+            {
+        case EMTPObjectPropCodeNonConsumable:
+            {
+            
+            TUint8 value = iObjMeta->Uint(CMTPObjectMetaData::ENonConsumable);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetUint8L(CMTPTypeObjectPropListElement::EValue, value);
+            iPropertyList->CommitPropElemL(propElem);
+            }        
+            break;
+            
+        case EMTPObjectPropCodeObjectFormat:
+        	{
+            TUint16 value = iObjMeta->Uint(CMTPObjectMetaData::EFormatCode);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetUint16L(CMTPTypeObjectPropListElement::EValue, value);
+            iPropertyList->CommitPropElemL(propElem);
+        	}
+        	break;
+            case EMTPObjectPropCodeProtectionStatus:
+            {
+            TUint16 value( 1 );
+            if( !aDiscoveryFile ) 
+                {
+                value = iFileEntry.IsReadOnly();
+                }
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetUint16L(CMTPTypeObjectPropListElement::EValue, value);
+            iPropertyList->CommitPropElemL(propElem);
+            }
+            break;
+            case EMTPObjectPropCodeStorageID:
+        	{
+            TUint32 value = iObjMeta->Uint(CMTPObjectMetaData::EStorageId);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetUint32L(CMTPTypeObjectPropListElement::EValue, value);
+            iPropertyList->CommitPropElemL(propElem);
+        	}
+        	break;
+            case EMTPObjectPropCodeParentObject:
+            {
+            TUint32 value = iObjMeta->Uint(CMTPObjectMetaData::EParentHandle);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetUint32L(CMTPTypeObjectPropListElement::EValue, value);
+            iPropertyList->CommitPropElemL(propElem);
+            }
+            break;
+            case EMTPObjectPropCodeObjectSize:
+            {
+            TUint64 value( 0 );
+            if( !aDiscoveryFile ) 
+                {
+                value = iFileEntry.FileSize();
+                }
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetUint64L(CMTPTypeObjectPropListElement::EValue, value);
+            iPropertyList->CommitPropElemL(propElem);
+            }
+            break;
+            case EMTPObjectPropCodePersistentUniqueObjectIdentifier:
+            {
+            TMTPTypeUint128 value = iFramework.ObjectMgr().PuidL(aHandle);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetUint128L(CMTPTypeObjectPropListElement::EValue, value.UpperValue(), value.LowerValue());
+            iPropertyList->CommitPropElemL(propElem); 
+            }        
+            break;
+            case EMTPObjectPropCodeDateModified:
+        	{
+            TBuf<64> dateString;
+            if ( !aDiscoveryFile )
+                {
+                iDpSingletons.MTPUtility().TTime2MTPTimeStr(iFileEntry.iModified, dateString);
+                }
+            else{
+                TTime modifiedTime( 0 );
+                modifiedTime.HomeTime();
+                iDpSingletons.MTPUtility().TTime2MTPTimeStr( modifiedTime, dateString );
+                }
+                    	
+            CMTPTypeString* value = CMTPTypeString::NewLC(dateString);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetStringL(CMTPTypeObjectPropListElement::EValue, value->StringChars());
+            iPropertyList->CommitPropElemL(propElem);
+            CleanupStack::PopAndDestroy(value);
+        	}
+        	break;
+            case EMTPObjectPropCodeObjectFileName:
+        	{
+        	CMTPTypeString* value( NULL );
+        	if ( !aDiscoveryFile )
+        	    {
+        	    value = CMTPTypeString::NewLC(iFileEntry.iName);
+        	    }
+        	else
+        	    {
+        	    TParse parse;
+        	    parse.Set( iObjMeta->DesC(CMTPObjectMetaData::ESuid), NULL, NULL );
+        	    value = CMTPTypeString::NewLC( parse.NameAndExt() );
+        	    }
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetStringL(CMTPTypeObjectPropListElement::EValue, value->StringChars());
+            iPropertyList->CommitPropElemL(propElem);
+            CleanupStack::PopAndDestroy(value);
+        	}
+        	break;
+            case EMTPObjectPropCodeName:
+            {
+            CMTPTypeString* value = CMTPTypeString::NewLC(iObjMeta->DesC(CMTPObjectMetaData::EName));
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetStringL(CMTPTypeObjectPropListElement::EValue, value->StringChars());
+            iPropertyList->CommitPropElemL(propElem);
+            CleanupStack::PopAndDestroy(value);
+            }
+            break;
+            default:
+                {
+                Panic( EMTPPictBridgeDpUnsupportedProperty );
+                }
+                break;
+            }
+        }
+    __FLOG(_L8("-CMTPPictBridgeDpGetObjectPropList::ServiceOneObjectPropertyL()"));
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpsendobjectinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,984 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <f32file.h>
+#include <bautils.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypefile.h>
+#include <mtp/cmtptypeobjectinfo.h>
+#include <mtp/cmtptypeobjectproplist.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpconnection.h>
+#include <mtp/tmtptyperequest.h>
+#include "ptpdef.h"
+#include "cmtppictbridgedpsendobjectinfo.h"
+#include "mtppictbridgedppanic.h"
+#include "mtppictbridgedpconst.h"
+#include "cmtppictbridgeprinter.h"
+#include "cptpserver.h"
+#include "cmtpconnection.h"
+#include "cmtpconnectionmgr.h"
+
+/**
+Verification data for the SendObjectInfo request
+*/
+const TMTPRequestElementInfo KMTPSendObjectInfoPolicy[] = 
+    {
+    {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeStorageId, EMTPElementAttrWrite, 1, 0, 0},                
+    {TMTPTypeRequest::ERequestParameter2, EMTPElementTypeObjectHandle, EMTPElementAttrWrite, 2, KMTPHandleAll, KMTPHandleNone}
+    };
+
+
+/**
+Two-phase construction method
+@param aFramework  The data provider framework
+@param aConnection The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+MMTPRequestProcessor* CMTPPictBridgeDpSendObjectInfo::NewL(
+    MMTPDataProviderFramework& aFramework,
+    MMTPConnection& aConnection,
+    CMTPPictBridgeDataProvider& aDataProvider)
+    {
+    CMTPPictBridgeDpSendObjectInfo* self = new (ELeave) CMTPPictBridgeDpSendObjectInfo(aFramework, aConnection, aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+CMTPPictBridgeDpSendObjectInfo::~CMTPPictBridgeDpSendObjectInfo()
+    {
+    __FLOG_VA((_L8(">> CMTPPictBridgeDpSendObjectInfo::~CMTPPictBridgeDpSendObjectInfo iProgress=%d iNoRollback=%d "), iProgress, iNoRollback));
+
+    if ((iProgress == EObjectInfoSucceed || 
+        iProgress == EObjectInfoFail || 
+        iProgress == EObjectInfoInProgress) && !iNoRollback)
+        {
+        // Not finished SendObjectInfo/PropList SendObject pair detected.
+        Rollback();
+        }
+ 
+    iDpSingletons.Close();
+    delete iDateModP;
+    delete iFileReceivedP;
+    delete iParentSuidP;    
+    delete iReceivedObjectP;
+    delete iObjectInfoP;
+    delete iObjectPropList;
+
+    __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::~CMTPPictBridgeDpSendObjectInfo"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Standard c++ constructor
+@param aFramework    The data provider framework
+@param aConnection    The connection from which the request comes
+*/    
+CMTPPictBridgeDpSendObjectInfo::CMTPPictBridgeDpSendObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider):
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
+    iPictBridgeDP(aDataProvider)
+    {
+    }
+
+/**
+Verify the request
+@return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
+*/    
+TMTPResponseCode CMTPPictBridgeDpSendObjectInfo::CheckRequestL()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::CheckRequestL"));    
+    TMTPResponseCode result = CheckSendingStateL();
+    
+    if (result != EMTPRespCodeOK) 
+        {
+        return result;
+        }
+    
+    if (iProgress == EObjectNone)    //this is the SendObjectInfo phase
+        {
+        iElementCount = sizeof(KMTPSendObjectInfoPolicy) / sizeof(TMTPRequestElementInfo);
+        iElements = KMTPSendObjectInfoPolicy;            
+        }
+    else if (iProgress == EObjectInfoSucceed)
+        {
+        iElementCount = 0;
+        iElements     = NULL;
+        }
+
+    if (iElements)
+        {
+        result = CMTPRequestProcessor::CheckRequestL();    
+        }
+
+    if ( EMTPRespCodeOK == result )
+        {
+        result = MatchStoreAndParentL();
+        }
+
+    if (( EMTPRespCodeOK == result ) && ( EMTPOpCodeSendObjectPropList == iOperationCode ))
+        {
+        iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+        TUint32 objectSizeHigh = Request().Uint32(TMTPTypeRequest::ERequestParameter4);
+        TUint32 objectSizeLow = Request().Uint32(TMTPTypeRequest::ERequestParameter5);
+        iObjectSize = MAKE_TUINT64(objectSizeHigh, objectSizeLow);
+        if (IsTooLarge(iObjectSize))
+            {
+             result = EMTPRespCodeObjectTooLarge;            
+            }
+        if(result && !CanStoreFileL(iStorageId, iObjectSize))
+           {
+           result = EMTPRespCodeStoreFull;            
+           }        
+        }
+    // If the previous request is not SendObjectInfo, SendObject fails
+    if (result == EMTPRespCodeOK && iOperationCode == EMTPOpCodeSendObject)
+        {
+        if (iPreviousTransactionID + 1 != Request().Uint32(TMTPTypeRequest::ERequestTransactionID))
+            {
+            result = EMTPRespCodeNoValidObjectInfo;
+            }
+        }
+        
+    __FLOG_VA((_L8("<< CMTPPictBridgeDpSendObjectInfo::CheckRequestL 0x%04x"), result));    
+
+    return result;    
+    }
+    
+TBool CMTPPictBridgeDpSendObjectInfo::HasDataphase() const
+    {
+    return ETrue;
+    }
+
+/**
+SendObjectInfo/SendObject request handler
+NOTE: SendObjectInfo has to be comes before SendObject requests.  To maintain the state information
+between the two requests, the two requests are combined together in one request processor.
+*/    
+void CMTPPictBridgeDpSendObjectInfo::ServiceL()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::ServiceL"));
+    if (iProgress == EObjectNone)
+        {
+        if ( EMTPOpCodeSendObjectInfo == iOperationCode )
+            {
+            ServiceSendObjectInfoL();
+            }
+        else
+            {
+            ServiceSendObjectPropListL();
+            }
+        }
+    else
+        {
+        ServiceSendObjectL();
+        }    
+    __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::ServiceL"));    
+    }
+
+/**
+Second-phase construction
+*/        
+void CMTPPictBridgeDpSendObjectInfo::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::ConstructL"));      
+    iExpectedSendObjectRequest.SetUint16(TMTPTypeRequest::ERequestOperationCode, EMTPOpCodeSendObject);
+    iReceivedObjectP = CMTPObjectMetaData::NewL();
+    iReceivedObjectP->SetUint(CMTPObjectMetaData::EDataProviderId, iFramework.DataProviderId());
+    iDpSingletons.OpenL(iFramework);
+    iNoRollback = EFalse;
+    __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::ConstructL"));    
+    }
+
+/**
+Override to match both the SendObjectInfo and SendObject requests
+@param aRequest    The request to match
+@param aConnection The connection from which the request comes
+@return ETrue if the processor can handle the request, otherwise EFalse
+*/        
+TBool CMTPPictBridgeDpSendObjectInfo::Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::Match"));    
+    TBool result = EFalse;
+    TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
+    if ((operationCode == EMTPOpCodeSendObjectInfo || 
+        operationCode == EMTPOpCodeSendObject ||
+        operationCode == EMTPOpCodeSendObjectPropList) &&
+        &iConnection == &aConnection)
+        {
+        result = ETrue;
+        }
+    __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::Match"));    
+    return result;    
+    }
+
+/**
+Override to handle the response phase of SendObjectInfo and SendObject requests
+@return EFalse
+*/
+TBool CMTPPictBridgeDpSendObjectInfo::DoHandleResponsePhaseL()
+    {
+    __FLOG_VA((_L8(">> CMTPPictBridgeDpSendObjectInfo::DoHandleResponsePhaseL iProgress==%d opCode==0x%x"),iProgress, iOperationCode));
+    //to check if the sending/receiving data is successful
+    TBool successful = !iCancelled;
+    if (iProgress == EObjectInfoInProgress)
+        {
+        if (iOperationCode == EMTPOpCodeSendObjectInfo)
+            {            
+            successful = DoHandleSendObjectInfoCompleteL();
+            }
+        else
+            {
+            successful = DoHandleSendObjectPropListCompleteL();
+            }
+        iProgress = (successful ? EObjectInfoSucceed : EObjectInfoFail);
+        }
+    else if (iProgress == ESendObjectInProgress)
+        {
+        successful = DoHandleSendObjectCompleteL();
+        iProgress = (successful ? ESendObjectSucceed : ESendObjectFail);
+        }        
+    __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::DoHandleResponsePhaseL"));    
+    return EFalse;
+    }
+
+/**
+Override to handle the completing phase of SendObjectInfo and SendObject requests
+@return ETrue if succesfully received the file, otherwise EFalse
+*/    
+TBool CMTPPictBridgeDpSendObjectInfo::DoHandleCompletingPhaseL()
+    {
+    __FLOG_VA((_L8(">> CMTPPictBridgeDpSendObjectInfo::DoHandleCompletingPhaseL iProgress==%d opCode==0x%x"),iProgress, iOperationCode));
+    TBool result = ETrue;
+    CMTPRequestProcessor::DoHandleCompletingPhaseL();
+    if (iProgress == EObjectInfoSucceed)
+        {
+        if (( iOperationCode == EMTPOpCodeSendObjectInfo ) || ( iOperationCode == EMTPOpCodeSendObjectPropList ))
+            {
+            iPreviousTransactionID = Request().Uint32(TMTPTypeRequest::ERequestTransactionID);
+            }
+        result = EFalse;
+        }
+    else if (iProgress == ESendObjectSucceed)
+        {
+        iPictBridgeDP.PtpServer()->Printer()->DpsObjectReceived(iReceivedObjectP->Uint(CMTPObjectMetaData::EHandle));
+        }
+    else if (iProgress == ESendObjectFail)
+        {
+        if (iOperationCode == EMTPOpCodeSendObject)
+            {
+            iPreviousTransactionID++;
+            }
+        iProgress = EObjectInfoSucceed;
+        result = EFalse;
+        }
+    
+    __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::DoHandleCompletingPhaseL"));    
+    return result;    
+    }
+
+/**
+Verify if the SendObject request comes after SendObjectInfo request
+@return EMTPRespCodeOK if SendObject request comes after a valid SendObjectInfo request, otherwise
+EMTPRespCodeNoValidObjectInfo
+*/
+TMTPResponseCode CMTPPictBridgeDpSendObjectInfo::CheckSendingStateL()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::CheckSendingStateL"));    
+    TMTPResponseCode result = EMTPRespCodeOK;
+    iOperationCode = Request().Uint16(TMTPTypeRequest::ERequestOperationCode);
+
+    if (iOperationCode == EMTPOpCodeSendObject)
+        {
+        //In ParseRouter everytime SendObject gets resolved then will be removed from Registry
+        //Right away therefore we need reRegister it here again in case possible cancelRequest
+        //Against this SendObject being raised.
+        iExpectedSendObjectRequest.SetUint32(TMTPTypeRequest::ERequestSessionID, iSessionId);
+        iFramework.RouteRequestRegisterL(iExpectedSendObjectRequest, iConnection);
+        }
+   
+    if (iProgress == EObjectNone)
+        {
+        if (iOperationCode == EMTPOpCodeSendObject)
+            {
+            result = EMTPRespCodeNoValidObjectInfo;
+            }        
+        }
+    else if (iProgress == EObjectInfoSucceed) 
+        {
+        if (iOperationCode == EMTPOpCodeSendObjectInfo || iOperationCode == EMTPOpCodeSendObjectPropList)
+            {
+            // Not finished SendObjectInfo/SendObject pair detected, need to remove the object reservation that was created, unless the object already existed
+            if (!iNoRollback )
+                {
+                __FLOG(_L8("  CMTPPictBridgeDpSendObjectInfo::CheckSendingStateL ... Rolling back!"));
+                Rollback();
+                }
+
+            delete iObjectInfoP;
+            iObjectInfoP = NULL;
+            delete iObjectPropList;
+            iObjectPropList = NULL;
+            iProgress = EObjectNone;
+            }
+        }
+    else 
+        {
+        Panic(EMTPPictBridgeDpSendObjectStateInvalid);
+        }
+    __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::CheckSendingStateL"));    
+    return result;    
+    }
+
+/**
+SendObjectInfo request handler
+*/
+void CMTPPictBridgeDpSendObjectInfo::ServiceSendObjectInfoL()
+    {
+    delete iObjectInfoP;
+    iObjectInfoP = NULL;
+    iObjectInfoP = CMTPTypeObjectInfo::NewL();
+    ReceiveDataL(*iObjectInfoP);
+    iProgress = EObjectInfoInProgress;
+    }
+
+/**
+ServiceSendObjectPropListL request handler
+*/ 
+void CMTPPictBridgeDpSendObjectInfo::ServiceSendObjectPropListL()
+    {
+    delete iObjectPropList;
+    iObjectPropList = NULL;
+    iObjectPropList = CMTPTypeObjectPropList::NewL();
+    ReceiveDataL( *iObjectPropList );
+    iProgress = EObjectInfoInProgress;
+    }
+
+/**
+SendObject request handler
+*/    
+void CMTPPictBridgeDpSendObjectInfo::ServiceSendObjectL()
+    {    
+    ReceiveDataL(*iFileReceivedP);    
+    iProgress = ESendObjectInProgress;
+    }
+
+/**
+Get a default parent object, if the request does not specify a parent object.
+*/
+void CMTPPictBridgeDpSendObjectInfo::GetDefaultParentObjectL()
+    {    
+    __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::GetDefaultParentObjectL"));    
+
+    if (iStorageId == KMTPStorageDefault)
+        {
+        iStorageId = iFramework.StorageMgr().DefaultStorageId();
+        }
+    TInt drive(static_cast<TDriveNumber>(iFramework.StorageMgr().DriveNumber(iStorageId)));
+    User::LeaveIfError(drive);
+
+    // Obtain the root of the drive.  Logical storages can sometimes have a filesystem root
+    // other than <drive>:\ .  For example an MP3 DP might have a root of c:\media\music\
+
+    delete iParentSuidP;
+    iParentSuidP = NULL;
+    iParentSuidP=(iFramework.StorageMgr().StorageL(iStorageId).DesC(CMTPStorageMetaData::EStorageSuid)).AllocL();
+    iReceivedObjectP->SetUint(CMTPObjectMetaData::EParentHandle, KMTPHandleNoParent);
+    __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::GetDefaultParentObjectL"));            
+    }
+
+/**
+Get parent object and storage id
+@return EMTPRespCodeOK if successful, otherwise, EMTPRespCodeInvalidParentObject
+*/
+TMTPResponseCode CMTPPictBridgeDpSendObjectInfo::GetParentObjectAndStorageIdL()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::GetParentObjectAndStorageIdL"));    
+    __ASSERT_DEBUG(iRequestChecker, Panic(EMTPPictBridgeDpRequestCheckNull));
+
+    iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    iParentHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+    //does not take ownership
+    CMTPObjectMetaData* parentObjectInfo = iRequestChecker->GetObjectInfo(iParentHandle);
+
+    if (!parentObjectInfo)
+        {
+        GetDefaultParentObjectL();    
+        }
+    else
+        {        
+        delete iParentSuidP;
+        iParentSuidP = NULL;
+        iParentSuidP = parentObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocL();
+        iReceivedObjectP->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle);
+        }
+
+    __FLOG_VA((_L16("<< CMTPPictBridgeDpSendObjectInfo::GetParentObjectAndStorageIdL %S"), iParentSuidP));    
+    return EMTPRespCodeOK;
+    }
+
+/**
+Handling the completing phase of SendObjectInfo request
+@return ETrue if the specified object can be saved on the specified location, otherwise, EFalse
+*/    
+TBool CMTPPictBridgeDpSendObjectInfo::DoHandleSendObjectInfoCompleteL()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::DoHandleSendObjectInfoCompleteL"));    
+    TBool result(ETrue);
+    TUint16 format(iObjectInfoP->Uint16L(CMTPTypeObjectInfo::EObjectFormat));
+    
+    result = IsFormatValid(TMTPFormatCode(format));
+    
+    if (result)
+        {
+        delete iDateModP;
+        iDateModP = NULL;
+        iDateModP = iObjectInfoP->StringCharsL(CMTPTypeObjectInfo::EDateModified).AllocL();
+    
+        TMTPResponseCode responseCode(GetParentObjectAndStorageIdL());
+        if (responseCode != EMTPRespCodeOK)
+            {
+            SendResponseL(responseCode);
+            result = EFalse;
+            }
+        }
+    else
+        {
+        SendResponseL(EMTPRespCodeInvalidObjectFormatCode);
+        }
+
+    if (result)
+        {
+        iObjectSize = iObjectInfoP->Uint32L(CMTPTypeObjectInfo::EObjectCompressedSize);
+        if (IsTooLarge(iObjectSize))
+            {
+            SendResponseL(EMTPRespCodeObjectTooLarge);
+            result = EFalse;            
+            }
+        if(result && !CanStoreFileL(iStorageId, iObjectSize))
+            {
+            SendResponseL(EMTPRespCodeStoreFull);
+            result = EFalse;            
+            }
+        }
+
+    if (result)
+        {
+        iProtectionStatus = iObjectInfoP->Uint16L(CMTPTypeObjectInfo::EProtectionStatus);
+        if (iProtectionStatus !=  EMTPProtectionNoProtection &&
+            iProtectionStatus != EMTPProtectionReadOnly)
+            {
+            SendResponseL(EMTPRespCodeParameterNotSupported);
+            result = EFalse;
+            }
+        }
+
+    if (result)
+        {
+        result = GetFullPathNameL(iObjectInfoP->StringCharsL(CMTPTypeObjectInfo::EFilename));
+        if (!result)
+            {        
+            // File and/or parent pathname invalid.
+            SendResponseL(EMTPRespCodeInvalidDataset);
+            }
+        }
+
+    // pictbridge objects should be overwritten
+/*
+    if (result)
+        {    
+        result &= !Exists(iFullPath);
+        if (!result)
+            {        
+            // Object with the same name already exists.
+            __FLOG(_L8("   no rollback"));
+			iNoRollback = ETrue;
+            SendResponseL(EMTPRespCodeAccessDenied);
+            }
+        }
+  */
+    
+    if (result)
+        {
+        iReceivedObjectP->SetUint(CMTPObjectMetaData::EFormatCode, format);
+        iPictBridgeDP.PtpServer()->Printer()->DpsDiscovery(iFullPath, &iConnection);
+        TRAPD(err, CreateFsObjectL()); 
+        
+        if (err != KErrNone)
+            {
+            SendResponseL(ErrorToMTPError(err));
+            }
+        else
+            {
+            ReserveObjectL();
+            }
+        }
+    __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::DoHandleSendObjectInfoCompleteL"));    
+    return result;    
+    }
+
+
+TBool CMTPPictBridgeDpSendObjectInfo::DoHandleSendObjectPropListCompleteL()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::DoHandleSendObjectPropListCompleteL"));
+    TBool result(ETrue);
+    TMTPResponseCode responseCode( GetParentObjectAndStorageIdL() );
+    if ( responseCode != EMTPRespCodeOK )
+        {
+        SendResponseL( responseCode );
+        result = EFalse;
+        }
+    
+    if ( result )
+        {
+        TInt invalidParameterIndex = KErrNotFound;
+        responseCode = VerifyObjectPropListL( invalidParameterIndex );
+        result = ( responseCode == EMTPRespCodeOK );
+        if ( !result )
+            {
+            TUint32 parameters[4];
+            parameters[0] = 0;
+            parameters[1] = 0;
+            parameters[2] = 0;
+            parameters[3] = invalidParameterIndex;
+            SendResponseL( responseCode, 4, parameters );
+            }
+        }
+
+    if ( result )
+        {
+        iReceivedObjectP->SetUint(CMTPObjectMetaData::EFormatCode, iRequest->Uint32( TMTPTypeRequest::ERequestParameter3 ));
+        iPictBridgeDP.PtpServer()->Printer()->DpsDiscovery(iFullPath, &iConnection);
+        TRAPD(err, CreateFsObjectL());
+        if ( err != KErrNone )
+            {
+            SendResponseL(ErrorToMTPError(err));
+            }
+        else
+            {
+            ReserveObjectL();
+            }
+        }
+
+    __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::DoHandleSendObjectPropListCompleteL"));
+    return result;
+    }
+
+/**
+*/
+TBool CMTPPictBridgeDpSendObjectInfo::IsFormatValid(TMTPFormatCode aFormat) const
+    {
+    __FLOG_VA((_L8(">> CMTPPictGetObjectPropDesc::IsFormatValid %d"),aFormat));
+    TInt count(sizeof(KMTPValidCodeExtensionMappings) / sizeof(KMTPValidCodeExtensionMappings[0]));        
+    for(TInt i = 0; i < count; i++)
+        {
+        if (KMTPValidCodeExtensionMappings[i].iFormatCode == aFormat)
+            {
+            __FLOG(_L8("<< CMTPPictGetObjectPropDesc::IsFormatValid ETrue"));
+            return ETrue;
+            }
+        }
+    __FLOG(_L8("<< CMTPPictGetObjectPropDesc::IsFormatValid EFalse"));
+    return EFalse;
+    }
+    
+/**
+Handling the completing phase of SendObject request
+@return ETrue if the object has been successfully saved on the device, otherwise, EFalse
+*/    
+TBool CMTPPictBridgeDpSendObjectInfo::DoHandleSendObjectCompleteL()
+    {
+    __FLOG_VA((_L8(">> CMTPPictGetObjectPropDesc::DoHandleSendObjectCompleteL size=%d cancelled=%d"), iObjectSize, iCancelled));
+    TBool result(ETrue);
+                
+    delete iFileReceivedP;
+    iFileReceivedP = NULL;
+        
+    TEntry fileEntry;
+    User::LeaveIfError(iFramework.Fs().Entry(iFullPath, fileEntry));
+
+    if (fileEntry.FileSize() != iObjectSize)
+        {
+        __FLOG_VA((_L8("   sizes differ %d!=%d"),fileEntry.iSize, iObjectSize));
+        iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
+         
+        iFramework.Fs().Delete(iFullPath);
+        iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObjectP);
+        TMTPResponseCode responseCode = EMTPRespCodeObjectTooLarge;
+        if (fileEntry.FileSize() < iObjectSize)
+            {
+            responseCode = EMTPRespCodeInvalidDataset;
+            }
+        SendResponseL(responseCode);
+        result = EFalse;
+        }
+
+    
+    // Get the result of the SendObject operation. 
+    RMTPFramework frameworkSingletons;   
+    frameworkSingletons.OpenL();
+    TUint connectionId = iConnection.ConnectionId();
+    CMTPConnectionMgr& connectionMgr = frameworkSingletons.ConnectionMgr();
+    CMTPConnection& connection = connectionMgr.ConnectionL(connectionId);
+    TInt ret = connection.GetDataReceiveResult(); 
+    frameworkSingletons.Close();
+     // SendObject is cancelled or connection is dropped.
+    if(result && (iCancelled || (ret == KErrAbort)))
+        {
+        iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
+        Rollback();
+        SendResponseL(EMTPRespCodeTransactionCancelled);        
+        }
+    else if (result && !iCancelled)
+        {
+         iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
+        
+        //The MTP spec states that it is not mandatory for SendObjectInfo
+        //to be followed by a SendObject.  An object is reserved in the ObjectStore on 
+        //receiving a SendObjectInfo request, but we only commit it 
+        //on receiving the corresponding SendObject request.  With Associations however 
+        //we commit the object straight away as the SendObject phase is often absent 
+        //with folder creation.
+
+
+        iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObjectP);
+        SendResponseL(EMTPRespCodeOK);
+        }
+    __FLOG(_L8("<< CMTPPictGetObjectPropDesc::DoHandleSendObjectCompleteL"));
+    return result;
+    }
+
+/**
+Get the full path name of the object to be saved
+@param aFileName, on entry, contains the file name of the object,
+on return, contains the full path name of the object to be saved
+@return ETrue if the name is valid, EFalse otherwise
+*/
+TBool CMTPPictBridgeDpSendObjectInfo::GetFullPathNameL(const TDesC& aFileName)
+    {
+    __FLOG_VA((_L16(">> CMTPPictBridgeDpSendObjectInfo::GetFullPathNameL file %S"), &aFileName));
+    TBool result(EFalse);
+    if (aFileName.Length() > 0)
+        {
+        iFullPath = *iParentSuidP;
+        if (iFullPath.Length() + aFileName.Length() < iFullPath.MaxLength())
+            {
+            iFullPath.Append(aFileName);
+            result = iFramework.Fs().IsValidName(iFullPath);
+            }
+        }
+
+    __FLOG_VA((_L16("<< CMTPPictBridgeDpSendObjectInfo::GetFullPathNameL full path %S"), &iFullPath));
+    return result;
+    }
+
+/**
+Check if we can store the file on the storage
+@return ETrue if yes, otherwise EFalse
+*/
+TBool CMTPPictBridgeDpSendObjectInfo::CanStoreFileL(TUint32 aStorageId, TInt64 aObjectSize) const
+    {
+    TBool result(ETrue);
+    if (aStorageId == KMTPStorageDefault)
+        {
+        aStorageId = iFramework.StorageMgr().DefaultStorageId();
+        }
+    TInt drive(iFramework.StorageMgr().DriveNumber(aStorageId));
+    User::LeaveIfError(drive);
+    TVolumeInfo volumeInfo;
+    User::LeaveIfError(iFramework.Fs().Volume(volumeInfo, drive));
+    if (volumeInfo.iFree < aObjectSize)
+        {        
+        result = EFalse;
+        }
+    return result;        
+    }
+
+/**
+Check if the object is too large
+@return ETrue if yes, otherwise EFalse
+*/
+TBool CMTPPictBridgeDpSendObjectInfo::IsTooLarge(TUint64 aObjectSize) const
+    {
+    TBool ret(aObjectSize > KMaxTInt64);
+    return ret;
+    }
+    
+TMTPResponseCode CMTPPictBridgeDpSendObjectInfo::VerifyObjectPropListL( TInt& aInvalidParameterIndex )
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::VerifyObjectPropListL"));
+    TMTPResponseCode responseCode( EMTPRespCodeOK );
+    const TUint KCount( iObjectPropList->NumberOfElements() );
+    iObjectPropList->ResetCursor();
+    for ( TUint i(0); (i < KCount); i++ )
+        {
+        CMTPTypeObjectPropListElement& KElement=iObjectPropList->GetNextElementL();
+        const TUint32 KHandle( KElement.Uint32L(CMTPTypeObjectPropListElement::EObjectHandle) );
+        aInvalidParameterIndex = i;
+        if ( KHandle != KMTPHandleNone )
+            {
+            responseCode = EMTPRespCodeInvalidObjectHandle;  
+            break;
+            }
+        responseCode = CheckPropCodeL( KElement );
+        if ( responseCode != EMTPRespCodeOK )
+            {
+            break;
+            }
+        responseCode = ExtractPropertyL(KElement);
+        if ( responseCode != EMTPRespCodeOK )
+            {
+            break;
+            }  
+        }
+
+    __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::VerifyObjectPropListL"));
+    return responseCode;
+    }
+
+TMTPResponseCode CMTPPictBridgeDpSendObjectInfo::ExtractPropertyL( const CMTPTypeObjectPropListElement& aElement )
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::ExtractPropertyL"));
+    TMTPResponseCode responseCode(EMTPRespCodeOK);
+    switch ( aElement.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode) )
+        {
+    case EMTPObjectPropCodeObjectFileName:
+        {
+        const TDesC& KFileName = aElement.StringL(CMTPTypeObjectPropListElement::EValue);
+        if (!GetFullPathNameL(KFileName))
+            {
+            responseCode = EMTPRespCodeInvalidDataset;
+            }
+        }
+        break;
+
+    case EMTPObjectPropCodeProtectionStatus:
+        {
+        iProtectionStatus = aElement.Uint16L(CMTPTypeObjectPropListElement::EValue);
+        if (iProtectionStatus !=  EMTPProtectionNoProtection &&
+            iProtectionStatus != EMTPProtectionReadOnly)
+            {
+            responseCode = EMTPRespCodeParameterNotSupported;
+            }
+        }
+        break;
+
+    case EMTPObjectPropCodeDateModified:
+        delete iDateModP;
+        iDateModP = NULL;
+        iDateModP = aElement.StringL(CMTPTypeObjectPropListElement::EValue).AllocL();
+        break;
+    case EMTPObjectPropCodeName:
+    	iName = aElement.StringL(CMTPTypeObjectPropListElement::EValue);
+    	break;
+    default:
+        break;
+        }
+
+    __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::ExtractPropertyL"));
+    return responseCode;
+    }
+    
+TMTPResponseCode CMTPPictBridgeDpSendObjectInfo::CheckPropCodeL( const CMTPTypeObjectPropListElement& aElement ) const
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::CheckPropCodeL"));
+    TMTPResponseCode responseCode( EMTPRespCodeOK );
+    switch( aElement.Uint16L( CMTPTypeObjectPropListElement::EPropertyCode ))
+        {
+        case EMTPObjectPropCodeStorageID:
+            {
+            if ( aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT32 )
+                {
+                responseCode = EMTPRespCodeInvalidObjectPropFormat;
+                }
+            else if ( iStorageId != aElement.Uint32L(CMTPTypeObjectPropListElement::EValue) )
+                {
+                responseCode = EMTPRespCodeInvalidDataset;
+                }
+            }
+            break;
+        case EMTPObjectPropCodeObjectFormat:
+            {
+            if ( aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT16 )
+                {
+                responseCode = EMTPRespCodeInvalidObjectPropFormat;
+                }
+        else if (Request().Uint32(TMTPTypeRequest::ERequestParameter3) != aElement.Uint16L(CMTPTypeObjectPropListElement::EValue))
+                {
+                responseCode = EMTPRespCodeInvalidDataset;
+                }
+            }
+            break;
+        case EMTPObjectPropCodeObjectSize:
+            {
+            if ( aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT64 )
+                {
+                responseCode = EMTPRespCodeInvalidObjectPropFormat;
+                }
+        else if (iObjectSize != aElement.Uint64L(CMTPTypeObjectPropListElement::EValue))
+                {
+                responseCode = EMTPRespCodeInvalidDataset;
+                }
+            }
+            break;
+        case EMTPObjectPropCodeParentObject:
+            {
+            if ( aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT32 )
+                {
+                responseCode = EMTPRespCodeInvalidObjectPropFormat;
+                }
+            else if( Request().Uint32(TMTPTypeRequest::ERequestParameter2) != aElement.Uint32L(CMTPTypeObjectPropListElement::EValue) )
+                {
+                responseCode = EMTPRespCodeInvalidDataset;
+                }
+            }
+            break;
+        case EMTPObjectPropCodePersistentUniqueObjectIdentifier:
+            {
+            responseCode = EMTPRespCodeAccessDenied;
+            }
+            break;
+        case EMTPObjectPropCodeProtectionStatus:
+            {
+            if ( aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT16 )
+                {
+                responseCode = EMTPRespCodeInvalidObjectPropFormat;
+                }
+            }
+            break;
+        case EMTPObjectPropCodeDateModified:
+        case EMTPObjectPropCodeObjectFileName:
+        case EMTPObjectPropCodeName:
+            {
+            if ( aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeString )
+                {
+                responseCode = EMTPRespCodeInvalidObjectPropFormat;
+                }
+            }
+            break;
+        case EMTPObjectPropCodeNonConsumable:
+            {
+            if ( aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT8 )
+                {
+                responseCode = EMTPRespCodeInvalidObjectPropFormat;
+                }
+            }
+            break;
+        default:
+            {
+            responseCode = EMTPRespCodeInvalidObjectPropCode;
+            }
+            break;
+        }
+    __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::CheckPropCodeL"));
+    return responseCode; 
+    }
+
+TMTPResponseCode CMTPPictBridgeDpSendObjectInfo::MatchStoreAndParentL() const
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::MatchStoreAndParentL"));
+    TMTPResponseCode ret = EMTPRespCodeOK;
+    const TUint32 storeId(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
+    const TUint32 parentHandle(Request().Uint32(TMTPTypeRequest::ERequestParameter2));
+    if (parentHandle != KMTPHandleAll && parentHandle != KMTPHandleNone)
+        {
+        CMTPObjectMetaData* parentObjInfo = iRequestChecker->GetObjectInfo(parentHandle);
+        __ASSERT_DEBUG(parentObjInfo, Panic(EMTPPictBridgeDpObjectNull));
+
+        if (parentObjInfo->Uint(CMTPObjectMetaData::EStorageId) != storeId)   
+            {
+            ret = EMTPRespCodeInvalidObjectHandle;
+            }
+        }
+    __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::MatchStoreAndParentL"));
+    return ret;
+    }
+
+/**
+Reserves space for and assigns an object handle to the received object, then
+sends a success response.
+*/
+void CMTPPictBridgeDpSendObjectInfo::ReserveObjectL()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::ReserveObjectL"));    
+    iReceivedObjectP->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
+    iReceivedObjectP->SetDesCL(CMTPObjectMetaData::ESuid, iFullPath);
+    
+    iFramework.ObjectMgr().ReserveObjectHandleL(*iReceivedObjectP, iObjectSize);    
+    
+    iExpectedSendObjectRequest.SetUint32(TMTPTypeRequest::ERequestSessionID, iSessionId);
+    iFramework.RouteRequestRegisterL(iExpectedSendObjectRequest, iConnection);
+    TUint32 parameters[3];
+    parameters[0] = iStorageId;
+    parameters[1] = iParentHandle;
+    parameters[2] = iReceivedObjectP->Uint(CMTPObjectMetaData::EHandle);
+    SendResponseL(EMTPRespCodeOK, (sizeof(parameters) / sizeof(parameters[0])), parameters);
+    __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::ReserveObjectL"));    
+    }
+    
+void CMTPPictBridgeDpSendObjectInfo::CreateFsObjectL()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::CreateFsObjectL"));    
+    delete iFileReceivedP;
+    iFileReceivedP = NULL;
+    iFileReceivedP = CMTPTypeFile::NewL(iFramework.Fs(), iFullPath, EFileWrite);
+    iFileReceivedP->SetSizeL(iObjectSize);
+    __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::CreateFsObjectL"));    
+    }
+    
+void CMTPPictBridgeDpSendObjectInfo::Rollback()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::Rollback"));
+    // Delete this object from file system.
+    delete iFileReceivedP;
+    iFileReceivedP=NULL;
+    TInt err=iFramework.Fs().Delete(iFullPath);
+    __FLOG_VA((_L16(">> CMTPPictBridgeDpSendObjectInfo::Rollback deleted %S with return code %d"), &iFullPath, err));
+    TRAP_IGNORE(iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObjectP));
+    __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::Rollback"));    
+    }
+    
+TMTPResponseCode CMTPPictBridgeDpSendObjectInfo::ErrorToMTPError(TInt aError) const
+    {
+    TMTPResponseCode resp = EMTPRespCodeGeneralError;
+    
+    switch (aError)
+        {
+    case KErrAccessDenied:
+        resp = EMTPRespCodeAccessDenied;
+        break;
+        
+    case KErrDiskFull:
+        resp = EMTPRespCodeStoreFull;
+        break;
+
+    default:
+        resp = EMTPRespCodeGeneralError;
+        break;
+        }
+        
+    return resp;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgeenumerator.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,152 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <f32file.h>
+#include <bautils.h>
+#include <s32file.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptypeevent.h>
+#include "cmtppictbridgeenumerator.h"
+#include "mmtppictbridgeenumeratorcallback.h"
+#include "ptpdef.h"
+#include "cmtpdataprovidercontroller.h"
+#include <mtp/cmtptypefile.h>
+#include <pathinfo.h>
+
+//==================================================================
+// 
+//==================================================================  
+CMTPPictBridgeEnumerator* CMTPPictBridgeEnumerator::NewL(MMTPDataProviderFramework& aFramework, MMTPPictBridgeEnumeratorCallback& aCallback)
+    {
+    CMTPPictBridgeEnumerator* self = new (ELeave) CMTPPictBridgeEnumerator(aFramework, aCallback);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+//==================================================================
+// 
+//==================================================================  
+CMTPPictBridgeEnumerator::CMTPPictBridgeEnumerator(MMTPDataProviderFramework& aFramework, MMTPPictBridgeEnumeratorCallback& aCallback)
+    :iFramework(aFramework), iCallback(aCallback)
+    {
+    }
+
+//==================================================================
+// 
+//==================================================================  
+void CMTPPictBridgeEnumerator::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8(">> CMTPPictBridgeEnumerator::ConstructL"));
+    iSingletons.OpenL();
+    __FLOG(_L8("<< CMTPPictBridgeEnumerator::ConstructL"));
+    }
+
+/**
+destructor
+*/    
+CMTPPictBridgeEnumerator::~CMTPPictBridgeEnumerator()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeEnumerator::~CMTPPictBridgeEnumerator"));
+    // we keep the persistent handle
+    iSingletons.Close();
+    __FLOG(_L8("<< CMTPPictBridgeEnumerator::~CMTPPictBridgeEnumerator"));
+	__FLOG_CLOSE;
+    }
+
+// --------------------------------------------------------------------------
+//
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgeEnumerator::EnumerateStoragesL()
+    {
+    iCallback.NotifyStorageEnumerationCompleteL();
+    }
+
+// --------------------------------------------------------------------------
+// "handle of the file DDISCVRY.DPS"
+// --------------------------------------------------------------------------
+TUint32 CMTPPictBridgeEnumerator::DeviceDiscoveryHandle() const
+    {
+    return iDpsDiscoveryHandle;
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+void CMTPPictBridgeEnumerator::EnumerateObjectsL(TUint32 aStorageId)
+    {
+    __FLOG(_L8(">> CMTPPictBridgeEnumerator::EnumerateObjectsL"));
+    const TUint storageId(iFramework.StorageMgr().DefaultStorageId());
+
+    if ((aStorageId==KMTPStorageAll) || (aStorageId==storageId))
+        {
+        MMTPObjectMgr& objectMgr=iFramework.ObjectMgr();
+
+        //delete the files which maybe impact printing
+        TFileName        fullPath;        
+		fullPath = PathInfo::PhoneMemoryRootPath();
+		fullPath.Append(KHostDiscovery);
+		__FLOG_VA((_L16("full path is %S "), &fullPath));
+		iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly);
+		iFramework.Fs().Delete(fullPath);
+		
+		fullPath = PathInfo::PhoneMemoryRootPath();
+		fullPath.Append(KHostRequest);
+		__FLOG_VA((_L16("full path is %S "), &fullPath));
+		iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly);
+		iFramework.Fs().Delete(fullPath);
+		
+		fullPath = PathInfo::PhoneMemoryRootPath();
+		fullPath.Append(KHostResponse);
+		__FLOG_VA((_L16("full path is %S "), &fullPath));
+		iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly);
+		iFramework.Fs().Delete(fullPath);
+		
+        // enumerate device discovery file (create if not exist)
+        CMTPTypeFile*    discoveryFile;
+        fullPath = PathInfo::PhoneMemoryRootPath();
+        fullPath.Append(KDeviceDiscovery);
+        __FLOG_VA((_L16("full path is %S "), &fullPath));
+        iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly);
+        iFramework.Fs().Delete(fullPath);
+        
+        discoveryFile = NULL;
+        discoveryFile = CMTPTypeFile::NewLC(iFramework.Fs(), fullPath, EFileWrite);
+        discoveryFile->SetSizeL(0);
+        CleanupStack::PopAndDestroy(discoveryFile);
+        
+        CMTPObjectMetaData* objectP = CMTPObjectMetaData::NewLC(iSingletons.DpController().FileDpId(), EMTPFormatCodeScript, storageId, fullPath);
+
+        objectP->SetUint(CMTPObjectMetaData::EParentHandle, KMTPHandleNoParent);
+	    objectMgr.InsertObjectL(*objectP);
+	    iDpsDiscoveryHandle = objectP->Uint( CMTPObjectMetaData::EHandle );
+	    __FLOG_VA((_L8("added discovery file iDpsDiscoveryHandle is 0x%08X"), iDpsDiscoveryHandle));
+
+        CleanupStack::PopAndDestroy(objectP);
+        }
+		iCallback.NotifyEnumerationCompleteL(aStorageId, KErrNone);
+
+    __FLOG(_L8("<< CMTPPictBridgeEnumerator::EnumerateObjectsL"));
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgegetobjectpropssupported.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,91 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+#include <mtp/cmtptypearray.h>
+#include "cmtppictbridgegetobjectpropssupported.h"
+#include "mtppictbridgedpconst.h"
+
+/**
+Verification data for the GetObjectPropSupported request
+*/
+const TMTPRequestElementInfo KMTPGetObjectPropSupportedPolicy[] = 
+    {
+            {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeFormatCode, EMTPElementAttrNone, 1, EMTPFormatCodeUndefined, 0},
+    };
+
+MMTPRequestProcessor* CMTPPictBridgeGetObjectPropsSupported::NewL( MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider )
+    {
+    CMTPPictBridgeGetObjectPropsSupported* self = new (ELeave) CMTPPictBridgeGetObjectPropsSupported( aFramework, aConnection, aDataProvider );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/  
+CMTPPictBridgeGetObjectPropsSupported::~CMTPPictBridgeGetObjectPropsSupported()
+    {
+    delete iObjectPropsSupported;
+    }
+
+/**
+Standard c++ constructor
+*/
+CMTPPictBridgeGetObjectPropsSupported::CMTPPictBridgeGetObjectPropsSupported( MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPPictBridgeDataProvider& aDataProvider )
+:CMTPRequestProcessor( aFramework, aConnection, sizeof(KMTPGetObjectPropSupportedPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetObjectPropSupportedPolicy ),
+iPictBridgeDP( aDataProvider )
+    {
+    
+    }
+
+/**
+check format code
+*/
+TMTPResponseCode CMTPPictBridgeGetObjectPropsSupported::CheckRequestL()
+    {
+    TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+    if ( EMTPRespCodeOK == responseCode )
+        {
+        TUint32 formatCode = Request().Uint32( TMTPTypeRequest::ERequestParameter1 );
+        if( formatCode != EMTPFormatCodeScript )
+            {
+            responseCode = EMTPRespCodeInvalidObjectFormatCode;
+            }
+        }
+    
+    return responseCode;
+    }
+
+/**
+CMTPPictBridgeGetObjectPropsSupported request handler
+*/
+void CMTPPictBridgeGetObjectPropsSupported::ServiceL()
+    {
+    TInt count = sizeof(KMTPPictBridgeDpSupportedProperties) / sizeof(TUint16);
+    for( TInt i = 0; i < count; i++ )
+        {
+        iObjectPropsSupported->AppendUintL(KMTPPictBridgeDpSupportedProperties[i]);
+        }
+    SendDataL(*iObjectPropsSupported);
+    }
+
+/**
+Second-phase construction
+*/
+void CMTPPictBridgeGetObjectPropsSupported::ConstructL()
+    {
+    iObjectPropsSupported = CMTPTypeArray::NewL(EMTPTypeAUINT16);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgeprinter.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,279 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtptypeobjectinfo.h>
+#include <mtp/mmtpconnection.h>
+#include <mtp/mtpprotocolconstants.h>
+
+#include "cptpserver.h"
+#include "cptpsession.h"
+#include "cptpreceivedmsghandler.h"
+#include "cmtppictbridgeprinter.h"
+#include "mtppictbridgedpconst.h"
+#include "cmtppictbridgeusbconnection.h"
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+CMTPPictBridgePrinter* CMTPPictBridgePrinter::NewL(CPtpServer& aServer)
+    {
+    CMTPPictBridgePrinter* selfP = new (ELeave) CMTPPictBridgePrinter(aServer);
+    CleanupStack::PushL(selfP);
+    selfP->ConstructL();
+    CleanupStack::Pop(selfP);
+    return selfP;    
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgePrinter::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KPtpServerLog);
+    iMsgHandlerP = CPtpReceivedMsgHandler::NewL(&iServer);
+    iUsbConnectionP = CMTPPictBridgeUsbConnection::NewL(*this);
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+CMTPPictBridgePrinter::CMTPPictBridgePrinter(CPtpServer& aServer):iServer(aServer), iPrinterStatus(ENotConnected)
+    {
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+CMTPPictBridgePrinter::~CMTPPictBridgePrinter()
+    {
+    delete iMsgHandlerP;
+    delete iUsbConnectionP;
+    __FLOG_CLOSE;
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgePrinter::ConnectionClosed()
+    {
+    iPrinterConnectionP=NULL; 
+    iPrinterStatus=ENotConnected;
+    iMsgHandlerP->Initialize();
+    iServer.RemoveTemporaryObjects();
+    CancelSendDpsFile(); // we rely on the client to get notification on 
+                         // disconnectrion from elsewhere. If not the timer 
+                         // will expire and handle completing the message
+    }
+
+// --------------------------------------------------------------------------
+//
+// --------------------------------------------------------------------------
+//
+CMTPPictBridgePrinter::TPrinterStatus CMTPPictBridgePrinter::Status() const
+    {
+    return iPrinterStatus;
+    }
+
+// --------------------------------------------------------------------------
+//
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgePrinter::NoDpsDiscovery()
+    {
+    if (iPrinterStatus != EConnected)
+        {
+        iPrinterStatus=ENotPrinter;
+        }
+    else
+        {
+        __FLOG(_L8("WARNING! CMTPPictBridgePrinter::NoDpsDiscovery trying to say no printer even though already discovered"));
+        }
+    }
+
+// --------------------------------------------------------------------------
+//
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgePrinter::DpsObjectReceived(TUint32 aHandle)
+    {
+    __FLOG(_L8("CMTPPictBridgePrinter::DpsObjectReceived"));                    
+    if(iPrinterStatus==EConnected) // we only handle the object when we are connected to the printer
+        {
+        iMsgHandlerP->ObjectReceived(aHandle);
+        }
+    else
+        {
+        __FLOG(_L8("!!!!WARNING: CMTPPictBridgePrinter::DpsObjectReceived Rx dps file when printer not connected!"));
+        }
+    }        
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgePrinter::DpsDiscovery(const TFileName& aFileName, MMTPConnection* aConnectionP)
+    {
+    __FLOG_VA(_L8(">> CMTPPictBridgePrinter::DpsDiscovery"));
+    if ( iPrinterStatus != EConnected )
+        {
+        if (KErrNotFound!=aFileName.Find(KHostDiscovery))
+            {
+            __FLOG(_L8("***Dps printer Discovered."));
+            iPrinterConnectionP=aConnectionP;
+            iPrinterStatus=EConnected;
+            iUsbConnectionP->Listen();
+            if(iDpsPrinterNotifyCbP)
+                {
+                iDpsPrinterNotifyCbP->IsDpsPrinterCompleted(EPrinterAvailable);    
+                }
+            }
+        }    
+    __FLOG_VA((_L16("<< CMTPPictBridgePrinter::DpsDiscovery received file %S"), &aFileName)); 
+    }
+// --------------------------------------------------------------------------
+//
+// --------------------------------------------------------------------------
+//    
+void CMTPPictBridgePrinter::DeRegisterDpsPrinterNotify(CPtpSession* /*aSessionP*/ )
+    {
+    __FLOG(_L8(">>>CMTPPictBridgePrinter::DeRegisterDpsPrinterNotify"));
+    iDpsPrinterNotifyCbP=NULL;
+    __FLOG(_L8("<<<CMTPPictBridgePrinter::DeRegisterDpsPrinterNotify"));
+    }
+    
+// --------------------------------------------------------------------------
+//
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgePrinter::RegisterDpsPrinterNotify(CPtpSession* aSessionP)
+    {
+    __FLOG_VA((_L8(">>>CMTPPictBridgePrinter::RegisterDpsPrinterNotify 0x%x (old) 0x%x (new)"), iDpsPrinterNotifyCbP, aSessionP));
+    __ASSERT_DEBUG(iDpsPrinterNotifyCbP==NULL, User::Invariant());
+    iDpsPrinterNotifyCbP=aSessionP;
+    __FLOG(_L8("<<<CMTPPictBridgePrinter::RegisterDpsPrinterNotify"));    
+    }
+
+    
+// --------------------------------------------------------------------------
+// CPtpEventSender::SendL()
+// Adds Object To List PTP Stack Object List,Sends RequestObjectTransfer Event
+// and registers observer for object sent notification 
+// --------------------------------------------------------------------------
+//    
+void CMTPPictBridgePrinter::SendDpsFileL(const TDesC& aFile, TBool /*aTimeout*/, TInt /*aSize*/)
+    {
+    __FLOG_VA((_L16(">> CMTPPictBridgePrinter::SendDpsFileL %S"), &aFile));            
+    
+    TUint32 handle(0);  
+    TRAPD(err, iServer.GetObjectHandleByNameL(aFile, handle));
+    if(err!=KErrNone || handle==0)
+        {
+        __FLOG_VA((_L8("   Object does not exist, adding it, errorcode = %d"), err));
+        iServer.AddTemporaryObjectL(aFile, handle);    
+        }
+
+    CreateRequestObjectTransfer(handle, iEvent);
+    iServer.SendEventL(iEvent);
+    iOutgoingObjectHandle=handle;
+    __FLOG_VA((_L8("<< CMTPPictBridgePrinter::SendDpsFileL handle 0x%x"),iOutgoingObjectHandle));
+    }
+
+// --------------------------------------------------------------------------
+// CPtpServer::CancelSendDpsFile()
+// Cancels Object sedn and call for deregister object sent notification
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgePrinter::CancelSendDpsFile()
+    {
+    __FLOG(_L8(">>>CMTPPictBridgePrinter::CancelSendObject"));    
+    iOutgoingObjectHandle=0;
+    __FLOG(_L8("<<<CMTPPictBridgePrinter::CancelSendObject"));    
+    }
+
+// --------------------------------------------------------------------------
+// --------------------------------------------------------------------------
+//
+TBool CMTPPictBridgePrinter::SendObjectPending() const
+    {
+    return (iOutgoingObjectHandle!=0);
+    }
+
+// --------------------------------------------------------------------------
+// CPtpEventSender::CreateRequestObjectTransfer
+// Creates PTP event RequestObjectTransfer
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgePrinter::CreateRequestObjectTransfer(TUint32 aHandle, 
+                                                 TMTPTypeEvent& aEvent )
+    {
+    __FLOG_VA((_L8("CMTPPictBridgePrinter::CreateRequestEventTransfer for 0x%x"), aHandle)); 
+
+    aEvent.Reset();
+
+    aEvent.SetUint16(TMTPTypeEvent::EEventCode, EMTPEventCodeRequestObjectTransfer);
+    aEvent.SetUint32(TMTPTypeEvent::EEventSessionID, KMTPSessionAll); 
+    aEvent.SetUint32(TMTPTypeEvent::EEventTransactionID, KMTPNotSpecified32);
+    
+    aEvent.SetUint32(TMTPTypeEvent::EEventParameter1, aHandle);
+    aEvent.SetUint32(TMTPTypeEvent::EEventParameter2, KPtpNoValue);
+    aEvent.SetUint32(TMTPTypeEvent::EEventParameter3, KPtpNoValue);
+    }
+
+// --------------------------------------------------------------------------
+// CPtpServer::ObjectReceived
+// Notifies of object received
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgePrinter::ObjectReceived(TDes& aFile)
+    {
+    __FLOG(_L8("CMTPPictBridgePrinter::ObjectReceived"));                    
+    iObserverP->ReceivedObjectCompleted(aFile);
+    }    
+
+// --------------------------------------------------------------------------
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgePrinter::DpsFileSent(TInt aError)
+    {
+    __FLOG_VA((_L8("CMTPPictBridgePrinter::DpsFileSent error %d handle 0x%x"), aError, iOutgoingObjectHandle));
+    if( SendObjectPending() )
+        {
+        iObserverP->SendObjectCompleted(aError); 
+        iOutgoingObjectHandle=0;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// --------------------------------------------------------------------------
+//    
+void CMTPPictBridgePrinter::RegisterObserver(MServiceHandlerObserver* aObserverP)
+    {
+    iObserverP = aObserverP;
+    }
+
+MMTPConnection* CMTPPictBridgePrinter::ConnectionP() const
+    {
+    return iPrinterConnectionP;    
+    }
+    
+CPtpReceivedMsgHandler* CMTPPictBridgePrinter::MsgHandlerP() const
+    {
+    return iMsgHandlerP;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgeusbconnection.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,163 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include "s60dependency.h"
+#include "cmtppictbridgeusbconnection.h"
+#include "cmtppictbridgeprinter.h"
+#include "ptpdef.h"
+
+const TInt KNotAssigned=0;
+// --------------------------------------------------------------------------
+// 
+// 
+// --------------------------------------------------------------------------
+//
+CMTPPictBridgeUsbConnection* CMTPPictBridgeUsbConnection::NewL(CMTPPictBridgePrinter& aPrinter)
+    {
+    CMTPPictBridgeUsbConnection* self = new(ELeave) CMTPPictBridgeUsbConnection(aPrinter);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// 
+// 
+// --------------------------------------------------------------------------
+//    
+CMTPPictBridgeUsbConnection::CMTPPictBridgeUsbConnection(CMTPPictBridgePrinter& aPrinter) : CActive(EPriorityStandard),
+    iPrinter(aPrinter)
+    {
+    CActiveScheduler::Add(this);    
+    }
+    
+
+
+// --------------------------------------------------------------------------
+// 
+// 
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgeUsbConnection::ConstructL()    
+    {
+    __FLOG_OPEN(KMTPSubsystem, KPtpServerLog);
+    __FLOG(_L8("CMTPPictBridgeUsbConnection::ConstructL"));        
+    User::LeaveIfError(iProperty.Attach(KPSUidUsbWatcher, KUsbWatcherSelectedPersonality));
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+CMTPPictBridgeUsbConnection::~CMTPPictBridgeUsbConnection()
+    {
+    __FLOG(_L8(">> CMTPPictBridgeUsbConnection::~"));
+    Cancel();
+    iProperty.Close();
+    __FLOG(_L8("<< CMTPPictBridgeUsbConnection::~"));
+    __FLOG_CLOSE;
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgeUsbConnection::Listen()
+    {
+    iProperty.Subscribe(iStatus);
+    SetActive();
+    if(ConnectionClosed()) // we listen to the disconnection only if connected to the printer
+        {
+        iPrinter.ConnectionClosed();
+        Cancel();    
+        }
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//    
+TBool CMTPPictBridgeUsbConnection::ConnectionClosed()
+    {
+    TInt personality=KNotAssigned;
+    TInt ret = RProperty::Get(KPSUidUsbWatcher, KUsbWatcherSelectedPersonality, personality);
+
+    __FLOG_VA((_L8("CMTPPictBridgeUsbConnection::ConnectionClosed() current personality = %d, previous personality = %d"), personality, iPreviousPersonality));  
+    if ((ret == KErrNone && 
+        (personality == KUsbPersonalityIdMS || personality == KUsbPersonalityIdPTP))
+       || (iPreviousPersonality != KNotAssigned && personality != iPreviousPersonality))
+        { 
+        __FLOG_VA((_L8("****WARNING!!! PTP server detects the USB connection closed!")));  
+        return ETrue;
+        }
+
+    iPreviousPersonality = personality;
+    return EFalse;
+    }
+
+
+    
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+void CMTPPictBridgeUsbConnection::DoCancel()
+    {
+    __FLOG(_L8("CMTPPictBridgeUsbConnection::DoCancel()"));
+    iProperty.Cancel();
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//    
+void CMTPPictBridgeUsbConnection::RunL()
+    {
+    __FLOG_VA((_L8(">>>CMTPPictBridgeUsbConnection::RunL %d"),iStatus.Int()));
+
+    TBool closed = EFalse;    
+    if( iStatus == KErrNone )
+        {
+        closed=ConnectionClosed();
+        if(closed)
+            {
+            iPrinter.ConnectionClosed();                
+            }
+        }
+
+    if(iStatus != KErrCancel && !closed) // if connection not closed, keep on listening
+        {
+        Listen();
+        }
+
+    __FLOG(_L8("<<<CMTPPictBridgeUsbConnection::RunL"));	
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//    
+#ifdef __FLOG_ACTIVE
+TInt CMTPPictBridgeUsbConnection::RunError(TInt aErr)
+#else
+TInt CMTPPictBridgeUsbConnection::RunError(TInt /*aErr*/)
+#endif
+    {
+    __FLOG_VA((_L8(">>>CMTPPictBridgeUsbConnection::RunError %d"), aErr));
+    return KErrNone;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/cptpreceivedmsghandler.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,171 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <f32file.h>
+#include <e32base.h>
+#include <mtp/mtpprotocolconstants.h>
+
+#include "mtppictbridgedpconst.h"
+#include "cptpreceivedmsghandler.h"
+#include "cmtppictbridgeprinter.h"
+#include "cptpserver.h"
+#include "ptpdef.h"
+
+// --------------------------------------------------------------------------
+// CPtpReceivedMsgHandler::NewL()
+// 
+// --------------------------------------------------------------------------
+//
+CPtpReceivedMsgHandler* CPtpReceivedMsgHandler::NewL(CPtpServer* aServerP)
+    {
+    CPtpReceivedMsgHandler* self = new (ELeave) CPtpReceivedMsgHandler(aServerP);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self); 
+    return self;
+    }
+    
+
+// --------------------------------------------------------------------------
+// CPtpReceivedMsgHandler::CPtpReceivedMsgHandler()
+// 
+// --------------------------------------------------------------------------
+//
+CPtpReceivedMsgHandler::CPtpReceivedMsgHandler(CPtpServer* aServerP) : iServerP(aServerP)
+    {
+    Initialize();
+    }
+    
+// --------------------------------------------------------------------------
+// CPtpReceivedMsgHandler::ConstructL()
+// 
+// --------------------------------------------------------------------------
+//    
+void CPtpReceivedMsgHandler::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KPtpServerLog);
+    }
+    
+// --------------------------------------------------------------------------
+// CPtpReceivedMsgHandler::~CPtpReceivedMsgHandler()
+// C++ destructor.
+// --------------------------------------------------------------------------
+//
+CPtpReceivedMsgHandler::~CPtpReceivedMsgHandler()
+    {
+    __FLOG(_L8("CPtpReceivedMsgHandler::~"));
+    iReceiveQ.Close();
+    __FLOG_CLOSE;
+    }
+    
+// --------------------------------------------------------------------------
+// CPtpReceivedMsgHandler::Initialize()
+// 
+// --------------------------------------------------------------------------
+//    
+void CPtpReceivedMsgHandler::Initialize()
+    {
+    iReceiveHandle = 0;
+    iExtension.Zero();
+    iTransactionID = 0;
+    iReceiveQ.Reset();
+    }
+    
+ 
+// --------------------------------------------------------------------------
+// CPtpReceivedMsgHandler::RegisterReceiveObjectNotify()
+// 
+// --------------------------------------------------------------------------
+//
+void CPtpReceivedMsgHandler::RegisterReceiveObjectNotify(const TDesC& aExtension)
+    {
+    __FLOG(_L8(">>>PtpMsgHandler::RegisterReceiveObjectNotify"));
+    iExtension.Copy(aExtension);
+    __FLOG_VA((_L8("***the Receiving Que msg count: %d"), iReceiveQ.Count()));
+    for ( TUint index = 0; index < iReceiveQ.Count(); ++index )
+        {
+        if ( ObjectReceived( iReceiveQ[index] ) )
+            {
+            iReceiveQ.Remove(index);
+            break;
+            }
+        }
+    __FLOG_VA((_L8("***the Receiving Que msg count:%d"), iReceiveQ.Count()));
+    __FLOG(_L8("<<<PtpMsgHandler::RegisterReceiveObjectNotify"));    
+    }
+       
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+TBool CPtpReceivedMsgHandler::ObjectReceived(TUint32 aHandle)
+    {
+    __FLOG_VA((_L8(">>>CPtpReceivedMsgHandler::ObjectReceived 0x%x"), aHandle));    
+    TBuf<KFileNameAndPathLength> file;
+    TInt err=KErrNone;
+    TRAP( err, iServerP->GetObjectNameByHandleL(file, aHandle));
+    __FLOG_VA((_L16("---after GetObjectNameByHandleL err(%d) file is %S"), err, &file));    
+    if (err == KErrNone)
+        {
+        TFileName fileName; 
+        TBuf<KFileExtLength> extension;
+        TParse p;
+        err = p.Set(file,NULL,NULL);
+        __FLOG_VA((_L8("---after Set err(%d)"), err));            
+        if (err == KErrNone)
+            {
+            fileName = p.FullName();
+        
+            extension = p.Ext();
+            __FLOG_VA((_L16("---after parse file is %S ext is %S comparing it to %S"), &fileName, &extension, &iExtension));
+            if (!iExtension.CompareF(extension))
+                {
+                iServerP->Printer()->ObjectReceived(fileName);
+                // deregister notification
+                DeRegisterReceiveObjectNotify();
+                return ETrue; 
+                }
+            else
+                {
+                // we keep the coming file in a "queue" so that later 
+                // registry for this file will be informed
+
+                if(KErrNotFound == iReceiveQ.Find(aHandle))
+                    {
+                    iReceiveQ.Append(aHandle);
+                    }
+
+                __FLOG_VA((_L8("*** Que length is %d err is %d"), iReceiveQ.Count(), err));
+                }
+            }   
+        }
+        
+    __FLOG_VA((_L8("<<<CPtpReceivedMsgHandler::ObjectReceived %d"), err));
+    return EFalse;
+    }
+
+    
+// --------------------------------------------------------------------------
+// CPtpReceivedMsgHandler::DeRegisterReceiveObjectNotify()
+// Deregisters observer for Object receive notification
+// --------------------------------------------------------------------------
+//    
+void CPtpReceivedMsgHandler::DeRegisterReceiveObjectNotify()       
+    {
+    __FLOG(_L8("CPtpReceivedMsgHandler::DeRegisterReceivObjectNotify"));        
+    iExtension.Zero();
+    iReceiveHandle = 0;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/cptpserver.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,302 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <mtp/tmtptypeevent.h>
+#include <mtp/tmtptypeuint32.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpconnection.h>
+
+#include "ptpdef.h"
+#include "cptpserver.h"
+#include "mtppictbridgedpconst.h"
+#include "cmtppictbridgeprinter.h"
+
+_LIT(KPtpFolder, "_Ptp\\");
+
+// --------------------------------------------------------------------------
+// 
+// 2-phased constructor.
+// --------------------------------------------------------------------------
+//
+CPtpServer* CPtpServer::NewL(MMTPDataProviderFramework& aFramework, CMTPPictBridgeDataProvider& aDataProvider)
+    {
+    CPtpServer* self = new (ELeave) CPtpServer(aFramework, aDataProvider);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    self->StartL( KPTPServer );
+    CleanupStack::Pop(self);  
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// 
+// C++ constructor.
+// --------------------------------------------------------------------------
+//
+CPtpServer::CPtpServer(MMTPDataProviderFramework& aFramework, CMTPPictBridgeDataProvider& aDataProvider) : CServer2(EPriorityStandard), 
+                                                                iFramework(aFramework), 
+                                                                iDataProvider(aDataProvider)
+    {
+    }
+
+// --------------------------------------------------------------------------
+// 
+// 2nd phase constructor.
+// --------------------------------------------------------------------------
+//
+void CPtpServer::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KPtpServerLog);
+    __FLOG(_L8(">>>CPtpServer::ConstructL"));
+    iFileMan = CFileMan::NewL(iFramework.Fs());
+    iPtpFolder = PathInfo::PhoneMemoryRootPath();
+    iPtpFolder.Append( PathInfo::ImagesPath());   
+    iPtpFolder.Append(KPtpFolder);
+    iFileMan->RmDir(iPtpFolder);
+    Framework().Fs().MkDirAll(iPtpFolder);
+
+    iPrinterP = CMTPPictBridgePrinter::NewL(*this);
+    __FLOG(_L8("<<<CPtpServer::ConstructL"));
+    }
+    
+
+// --------------------------------------------------------------------------
+// 
+// C++ destructor.
+// --------------------------------------------------------------------------
+//
+CPtpServer::~CPtpServer()
+    {
+    __FLOG(_L8(">>>CPtpServer::~"));
+    delete iPrinterP;
+    iPrinterP = NULL;
+    delete iFileMan;
+    iFileMan = NULL;    
+    __FLOG(_L8("<<<CPtpServer::~"));
+	__FLOG_CLOSE;
+    }
+        
+
+// ----------------------------------------------------------------------------
+// 
+// from CServer2, creates a new session.
+// ----------------------------------------------------------------------------
+//
+CSession2* CPtpServer::NewSessionL(const TVersion& aVersion, 
+                                   const RMessage2& /*aMessage*/) const
+    {
+    __FLOG(_L8(">>>CPtpServer::NewSessionL"));
+    TVersion v(KPtpServerVersionMajor, KPtpServerVersionMinor, 0);
+    if (!User::QueryVersionSupported(v,aVersion))
+        {
+        __FLOG(_L8("!!!!Error: CPtpServer::NewSessionL version not support!"));
+        User::Leave(KErrNotSupported);
+        }
+    if (iNumSession>0)
+        {
+        __FLOG(_L8("!!!!Error: CPtpServer::NewSessionL session is in use!"));
+        User::Leave(KErrInUse);            
+        }
+    CPtpSession* session = CPtpSession::NewL(const_cast<CPtpServer*>(this)); 
+    __FLOG(_L8("<<<CPtpServer::NewSessionL"));
+    return session; 
+    }
+
+// --------------------------------------------------------------------------
+// CPtpServer::GetObjectHandleByNameL()
+// Returns object handle
+// --------------------------------------------------------------------------
+//
+void CPtpServer::GetObjectHandleByNameL(const TDesC& aNameAndPath, TUint32& aHandle)
+    {
+    __FLOG_VA((_L16(">> CPtpServer::GetObjectHandleByNameL %S"), &aNameAndPath));
+    aHandle=Framework().ObjectMgr().HandleL(aNameAndPath);
+    __FLOG_VA((_L16("<< CPtpServer::GetObjectHandleByNameL %S == 0x%x"), &aNameAndPath, aHandle));
+    }
+
+// --------------------------------------------------------------------------
+// CPtpServer::GetObjectNameByHandleL()
+// Returns object name and path
+// --------------------------------------------------------------------------
+//
+void CPtpServer::GetObjectNameByHandleL(TDes& aNameAndPath, 
+                                       const TUint32 aHandle)
+    {
+    __FLOG(_L8(">> CPtpServer::GetObjectNameByHandleL"));
+    TMTPTypeUint32 handle(aHandle);
+    CMTPObjectMetaData* objectP=CMTPObjectMetaData::NewL();
+    CleanupStack::PushL(objectP);
+    TBool err = Framework().ObjectMgr().ObjectL(handle, *objectP);
+    if(EFalse == err)
+        {
+        __FLOG(_L8("!!!!Error: CPtpServer::GetObjectNameByHandleL ObjectL failed!"));
+        User::Leave(KErrBadHandle);
+        }
+    
+    aNameAndPath=objectP->DesC(CMTPObjectMetaData::ESuid);    
+    CleanupStack::PopAndDestroy(objectP);
+    __FLOG(_L8("<< CPtpServer::GetObjectNameByHandleL"));
+    }
+
+
+// --------------------------------------------------------------------------
+// CPtpServer::SendEvent
+// Requests Object send
+// --------------------------------------------------------------------------
+//
+void CPtpServer::SendEventL(TMTPTypeEvent& ptpEvent)
+    {
+    __FLOG(_L8(">> CPtpServer::SendEventL"));    
+
+    if(iPrinterP->Status()!=CMTPPictBridgePrinter::EConnected)
+        {
+        __FLOG(_L8("   CPtpServer::SendEventL, no printer connection"));
+        User::Leave(KErrNotReady);
+        }
+    Framework().SendEventL(ptpEvent, *(iPrinterP->ConnectionP()));
+
+    __FLOG(_L8("<< CPtpServer::SendEventL"));    
+    }
+
+    
+// --------------------------------------------------------------------------
+// 
+// 
+// --------------------------------------------------------------------------
+//  
+MMTPDataProviderFramework& CPtpServer::Framework() const
+    {
+    return iFramework;
+    }
+    
+
+// --------------------------------------------------------------------------
+// --------------------------------------------------------------------------
+// 
+const TDesC& CPtpServer::PtpFolder()
+    {
+    return iPtpFolder; 
+    }
+
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+void CPtpServer::AddTemporaryObjectL(const TDesC& aPathAndFileName, TUint32& aHandle)
+    {
+    __FLOG_VA((_L8(">> CPtpServer::AddTemporaryObjectL")));
+
+    // always using the default storage for this
+
+    CMTPObjectMetaData* objectP(CMTPObjectMetaData::NewLC(Framework().DataProviderId(), 
+                                     EMTPFormatCodeScript, // we only support sending DPS scripts
+                                     Framework().StorageMgr().DefaultStorageId(), 
+                                     aPathAndFileName));
+
+    // since this object is temporary, we will not add any other details for it
+
+    Framework().ObjectMgr().InsertObjectL(*objectP);
+    aHandle=objectP->Uint(CMTPObjectMetaData::EHandle);
+    CleanupStack::Pop(objectP);
+    TInt err=iTemporaryObjects.Append(objectP); 
+    if(err)
+        {
+        Framework().Fs().Delete(objectP->DesC(CMTPObjectMetaData::ESuid)); // not checking the return value since there is not much we can do with it
+        RemoveObjectL(objectP->DesC(CMTPObjectMetaData::ESuid));
+        delete objectP;
+        __FLOG_VA((_L8("  CPtpServer::AddTemporaryObjectL, leaving %d"), err));
+        User::Leave(err);
+        }
+    
+    
+    __FLOG_VA((_L8("<< CPtpServer::AddTemporaryObjectL")));
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+void CPtpServer::RemoveTemporaryObjects()
+    {
+    __FLOG_VA((_L8(">> CPtpServer::RemoveTemporaryObjects %d"), iTemporaryObjects.Count()));
+
+    for (TInt i=0; i<iTemporaryObjects.Count();i++)
+        {
+        TInt err(KErrNone);
+        TRAP(err,RemoveObjectL(iTemporaryObjects[i]->DesC(CMTPObjectMetaData::ESuid)));
+        __FLOG_VA((_L16("removed object from db %S err=%d"), &(iTemporaryObjects[i]->DesC(CMTPObjectMetaData::ESuid)), err));
+        err=Framework().Fs().Delete(iTemporaryObjects[i]->DesC(CMTPObjectMetaData::ESuid));
+        __FLOG_VA((_L16("removed object from fs  %S err=%d"), &(iTemporaryObjects[i]->DesC(CMTPObjectMetaData::ESuid)), err));
+        
+        }
+    iTemporaryObjects.ResetAndDestroy();
+    __FLOG_VA((_L8("<< CPtpServer::RemoveTemporaryObjects %d"), iTemporaryObjects.Count()));
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+void CPtpServer::RemoveObjectL(const TDesC& aSuid)
+    {    
+    __FLOG_VA((_L16(">> CPtpServer::RemoveObjectL %S"), &aSuid));
+    Framework().ObjectMgr().RemoveObjectL(aSuid);
+    __FLOG_VA((_L8("<< CPtpServer::RemoveObjectL")));
+    }
+
+// --------------------------------------------------------------------------
+// --------------------------------------------------------------------------
+//     
+void CPtpServer::MtpSessionClosed()
+    {
+    iMtpSessionOpen = EFalse;
+    RemoveTemporaryObjects();
+    iTemporaryObjects.Close();
+    }
+
+// --------------------------------------------------------------------------
+// --------------------------------------------------------------------------
+//     
+void CPtpServer::MtpSessionOpened()
+    {
+    iMtpSessionOpen=ETrue;
+    if(iSessionOpenNotifyClientP)
+        {
+        iSessionOpenNotifyClientP->MTPSessionOpened();
+        iSessionOpenNotifyClientP=NULL;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// --------------------------------------------------------------------------
+//     
+void CPtpServer::CancelNotifyOnMtpSessionOpen(CPtpSession* /*aSessionP*/)
+    {
+    iSessionOpenNotifyClientP=NULL;    
+    }
+
+// --------------------------------------------------------------------------
+// --------------------------------------------------------------------------
+//     
+void CPtpServer::NotifyOnMtpSessionOpen(CPtpSession* aSession)
+    {
+    iSessionOpenNotifyClientP=aSession; 
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/cptpsession.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,530 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <f32file.h>
+#include "cptpsession.h"
+#include "cptpserver.h"
+#include "cptpreceivedmsghandler.h"
+#include "cmtppictbridgeprinter.h"
+#include "cptptimer.h"
+#include "mtppictbridgedpconst.h"
+#include "ptpdef.h" 
+
+// --------------------------------------------------------------------------
+// 
+// 2-phased constructor.
+// --------------------------------------------------------------------------
+//
+CPtpSession* CPtpSession::NewL(CPtpServer* aServer)
+    {
+    CPtpSession* self= new (ELeave) CPtpSession(aServer);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// 
+// C++ constructor.
+// --------------------------------------------------------------------------
+//
+CPtpSession::CPtpSession(CPtpServer* aServer) : iServerP(aServer) 
+    {
+    iServerP->Printer()->RegisterObserver(this); // since PTP register service 
+                  // is deprecated we register the observer at session creation
+    iServerP->IncrementSessionCount();                  
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+void CPtpSession::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KPtpServerLog);
+    iTimerP=CPtpTimer::NewL(*this);
+    }
+// --------------------------------------------------------------------------
+// 
+// C++ destructor.
+// --------------------------------------------------------------------------
+//
+CPtpSession::~CPtpSession()
+    {
+    __FLOG(_L8(">>>CPtpSession::~"));
+    delete iTimerP;
+    CancelOutstandingRequest();
+    TRAP_IGNORE(CleanupL()); // there is not much we can do at this phase if the removal fails, so just ignore
+    if(iServerP->NumSession())
+        {
+        iServerP->DecrementSessionCount();
+        }
+    __FLOG(_L8("<<<CPtpSession::~"));
+    __FLOG_CLOSE;
+    }
+
+// --------------------------------------------------------------------------
+// 
+// From CSession2, passes the request forward to DispatchMessageL.
+// --------------------------------------------------------------------------
+//
+void CPtpSession::ServiceL( const RMessage2& aMessage )
+    {
+    __FLOG(_L8(">>>CPtpSession::ServiceL"));
+    DispatchMessageL(aMessage);
+    __FLOG(_L8("<<<CPtpSession::ServiceL"));
+    }
+
+// --------------------------------------------------------------------------
+//  Cleans up the previously received DPS file, since the files are used only 
+//  for communication
+// --------------------------------------------------------------------------
+//
+void CPtpSession::CleanupL()
+    {
+    __FLOG(_L8(">>>CPtpSession::Cleanup"));
+    if(iReceivedFile.Size())
+        {
+        __FLOG_VA((_L16("   deleting file %S"), &iReceivedFile));
+        User::LeaveIfError(iServerP->Framework().Fs().Delete(iReceivedFile));
+        __FLOG(_L8("   removing from DB"));
+        iServerP->RemoveObjectL(iReceivedFile);
+        iReceivedFile.Zero();
+        }
+    __FLOG(_L8("<<<CPtpSession::Cleanup"));
+    }
+
+// --------------------------------------------------------------------------
+// Handles the request from client.
+// --------------------------------------------------------------------------
+//
+void CPtpSession::DispatchMessageL( const RMessage2& aMessage )
+    {
+    __FLOG_VA((_L8(">>>CPtpSession::DispatchMessageL %d"), aMessage.Function()));
+    TInt ret = KErrNone;
+    TBool complete = ETrue;        
+    CleanupL(); // calling this here assumes that the client never makes a new call 
+                // before it has handled the received DPS message
+    switch( aMessage.Function() )
+        {        
+        case EIsDpsPrinter:
+            ret = IsDpsPrinter(aMessage, complete);
+            break;
+
+        case ECancelIsDpsPrinter:
+            CancelIsDpsPrinter();
+            break;
+
+        case EGetObjectHandleByName:  
+            GetObjectHandleByNameL(aMessage);
+            break;
+
+        case EGetNameByObjectHandle:
+            GetNameByObjectHandleL(aMessage);
+            break;
+
+        case ESendObject:
+            ret = SendObject(aMessage, complete);
+            break;
+
+        case ECancelSendObject:
+            CancelSendObject();
+            break;
+
+        case EObjectReceivedNotify:
+            ret = ObjectReceivedNotify(aMessage, complete);
+            break;
+
+        case ECancelObjectReceivedNotify:
+            CancelObjectReceivedNotify();
+            break;
+
+        case EPtpFolder:
+            ret = PtpFolder(aMessage);
+            break;
+
+        default:
+            __FLOG(_L8("!!!Error: ---Wrong param from client!!!"));
+            aMessage.Panic(KPTPClientPanicCategory, EBadRequest);
+            break;
+        }
+        
+    if (complete)
+        {
+        aMessage.Complete(ret);
+        }
+    __FLOG_VA((_L8("<<<PtpSession::DispatchMessageL ret=%d"), ret));
+    }
+
+// --------------------------------------------------------------------------
+// CPtpSession::CancelIsDpsPrinter()
+// Cancels Asynchronous request IsDpsPrinter
+// --------------------------------------------------------------------------
+//
+void CPtpSession::CancelIsDpsPrinter()
+    {
+    __FLOG(_L8(">>>CPtpSession::CancelIsDpsPrinter"));
+    if (iDpsPrinterMsg.Handle())
+        {
+        iDpsPrinterMsg.Complete(KErrCancel);
+        iServerP->Printer()->DeRegisterDpsPrinterNotify(this);
+        iTimerP->Cancel();
+        iServerP->CancelNotifyOnMtpSessionOpen(this);
+        } 
+    __FLOG(_L8("<<<CPtpSession::CancelIsDpsPrinter"));
+    }
+    
+// --------------------------------------------------------------------------
+// CPtpSession::CancelSendObject()
+// Cancel Asynchronous request send Object
+// --------------------------------------------------------------------------
+//
+void CPtpSession::CancelSendObject()
+    {
+    __FLOG(_L8(">>>CancelSendObject"));
+    if (iSendObjectMsg.Handle())
+        {
+        iServerP->Printer()->CancelSendDpsFile();
+        iSendObjectMsg.Complete(KErrCancel);
+        iTimerP->Cancel();
+        }
+    __FLOG(_L8("<<<CancelSendObject"));    
+    }
+    
+// --------------------------------------------------------------------------
+// CPtpSession::CancelObjectReceivedNotify()
+// Deregisters for Object received notification
+// --------------------------------------------------------------------------
+//
+void CPtpSession::CancelObjectReceivedNotify()
+    {
+    __FLOG(_L8(">>>CancelObjectReceivedNotify"));       
+    if (iObjectReceivedNotifyMsg.Handle())
+        {
+        __FLOG_VA((_L8("the handle is 0x%x"), iObjectReceivedNotifyMsg.Handle()));
+        iServerP->Printer()->MsgHandlerP()->DeRegisterReceiveObjectNotify();
+        iObjectReceivedNotifyMsg.Complete(KErrCancel);                    
+        }
+    __FLOG(_L8("<<<CancelObjectReceivedNotifiy"));
+    }
+    
+// --------------------------------------------------------------------------
+// CPtpSession::IsDpsPrinter()
+// --------------------------------------------------------------------------
+//    
+TInt CPtpSession::IsDpsPrinter(const RMessage2& aMessage, TBool& aComplete)
+    {
+    __FLOG(_L8(">>>IsDpsPrinter"));
+    TInt ret=EPrinterNotAvailable;
+    if (!iDpsPrinterMsg.Handle()) // not already pending
+        {
+        switch (iServerP->Printer()->Status())
+            {   
+            case CMTPPictBridgePrinter::ENotConnected:
+                iDpsPrinterMsg = aMessage;    
+                iServerP->Printer()->RegisterDpsPrinterNotify(this);
+                aComplete = EFalse;
+                if(iServerP->MtpSessionOpen())
+                    {
+                    if (!iTimerP->IsActive()) 
+                        {
+                        iTimerP->After(KDiscoveryTime);
+                        }
+                    }
+                else
+                    {
+                    iServerP->NotifyOnMtpSessionOpen(this);
+                    }                    
+                // we do not set ret since the  value does not really matter, we will be waiting for the discovery to complete
+                __FLOG(_L8(" waiting"));
+                break;
+                
+            case CMTPPictBridgePrinter::EConnected:
+                ret=EPrinterAvailable;
+                aComplete = ETrue;
+                __FLOG(_L8(" connected"));
+                break;
+
+            case CMTPPictBridgePrinter::ENotPrinter:
+                ret=EPrinterNotAvailable;
+                aComplete = ETrue;
+                __FLOG(_L8(" not connected"));
+                break;
+
+            default:
+                break;                
+            }
+        }
+    else
+        {
+        __FLOG(_L8("!!!Error: client message error, duplicated IsDpsPrinter"));                        
+        aMessage.Panic(KPTPClientPanicCategory, ERequestPending);
+        aComplete = EFalse;
+        }
+    __FLOG(_L8("<<<IsDpsPrinter"));
+    return ret;
+    }
+
+// --------------------------------------------------------------------------
+// start the timer for printer detection, since we have now session open and 
+// we are ready to communicate wioth the host
+// --------------------------------------------------------------------------
+void CPtpSession::MTPSessionOpened()
+    {
+    __FLOG(_L8(">>>CPtpSession::MTPSessionOpened"));
+    if (!iTimerP->IsActive() && iDpsPrinterMsg.Handle()) 
+        {
+        __FLOG(_L8("   CPtpSession::MTPSessionOpened timer started"));
+        iTimerP->After(KDiscoveryTime);
+        }        
+    __FLOG(_L8("<<<CPtpSession::MTPSessionOpened"));
+    }
+    
+// --------------------------------------------------------------------------
+// CPtpSession::GetObjectHandleByNameL()
+// 
+// --------------------------------------------------------------------------
+//
+void CPtpSession::GetObjectHandleByNameL(const RMessage2& aMessage)
+    {
+    __FLOG(_L8(">>>CPtpSession::GetObjectHandleByNameL"));
+    TFileName file;
+    User::LeaveIfError(aMessage.Read(0, file));
+    __FLOG_VA((_L16("--the file is %S"), &file));
+    TUint32 handle=0;
+    TRAP_IGNORE(iServerP->GetObjectHandleByNameL(file, handle));
+    TPckgBuf<TUint32> handlePckg(handle);
+    aMessage.WriteL(1, handlePckg);     
+    __FLOG_VA((_L16("<<<CPtpSession::GetObjectHandleByNameL handle=%d"), handle));
+    }
+    
+// --------------------------------------------------------------------------
+// CPtpSession::GetNameByObjectHandle()
+
+// --------------------------------------------------------------------------
+//
+void CPtpSession::GetNameByObjectHandleL(const RMessage2& aMessage)
+    {
+    __FLOG(_L8(">>>CPtpSession::GetNameByObjectHandle"));               
+    TUint32 handle = 0;
+    TPckgBuf<TUint32> pckgHandle(handle);
+    User::LeaveIfError(aMessage.Read(1, pckgHandle));
+    TFileName file; 
+    handle = pckgHandle();
+    __FLOG_VA((_L8("---handle is %x"), handle));
+    TRAP_IGNORE(iServerP->GetObjectNameByHandleL(file, handle));
+    __FLOG_VA((_L16("the file is %S"), &file));
+    aMessage.WriteL(0, file);
+    
+    __FLOG(_L8("<<<CPtpSession::GetNameByObjectHandle"));               
+    }
+              
+// --------------------------------------------------------------------------
+// CPtpSession::SendObject()
+// Asynch. request send Object
+// --------------------------------------------------------------------------
+//
+TInt CPtpSession::SendObject(const RMessage2& aMessage, TBool& aComplete)
+    {
+    __FLOG(_L8(">>>CPtpSession::SendObject"));                      
+    TInt err(KErrNone);
+    
+    if (iSendObjectMsg.Handle())
+        {
+        __FLOG(_L8("!!!!Error: client message error, duplicated SendObject"));
+        aMessage.Panic(KPTPClientPanicCategory, ERequestPending);
+        aComplete = EFalse;
+        return KErrNone;
+        }
+    else
+        {
+        // Parameter add is depracated. We do not send Object added and we do not keep ther DPS object permanently in
+        // our system.
+        //
+        // Sending ObjectAdded Event is not mandatory ( See Appendix B page 78. DPS Usage of USB and PTP in CIPA DC-001-2003)
+
+        TBool timeout = aMessage.Int2();    
+        __FLOG_VA((_L8("---timeout is %d"), timeout));    
+        TFileName file; 
+        err = aMessage.Read(0, file);
+        if (err == KErrNone)
+            {
+            __FLOG_VA((_L16("---the file is %S"), &file));
+            TInt size = aMessage.Int3();
+            __FLOG_VA((_L8("---the file size is %d"), size)); // size is deprecated and not used anymore
+            TRAP(err, iServerP->Printer()->SendDpsFileL(file, timeout, size));
+            if (err == KErrNone)
+                {
+                iSendObjectMsg = aMessage;
+                aComplete = EFalse;    
+                }
+            }
+        if ((EFalse != timeout) && !iTimerP->IsActive())
+            {
+            iTimerP->After(KSendTimeout);
+            }
+        __FLOG_VA((_L8("<<<CPtpSession::SendObject err=%d"), err));
+        return err;    
+        }    
+    }             
+
+// --------------------------------------------------------------------------
+// CPtpSession::ObjectReceivedNotify()
+// 
+// --------------------------------------------------------------------------
+//   
+TInt CPtpSession::ObjectReceivedNotify(const RMessage2& aMessage, 
+                                       TBool& aComplete)
+    {
+    __FLOG(_L8(">>>CPtpSession::ObjectReceivedNotify"));                        
+    if (iObjectReceivedNotifyMsg.Handle())
+        {
+        __FLOG(_L8("!!!!Error: client message error, duplicated ObjectReceivedNotify"));
+        aMessage.Panic(KPTPClientPanicCategory, ERequestPending);
+        aComplete = EFalse;
+        return KErrNone;
+        }
+    else
+        {
+        //TBool del = aMessage.Int2();
+        //__FLOG_VA((_L8("---the del is %d"), del));    
+
+        TBuf<KFileExtLength> ext; 
+        TInt err = aMessage.Read(0, ext);
+        if (err == KErrNone)
+            {
+            __FLOG_VA((_L16("the extension is %S"), &ext));
+            
+            iObjectReceivedNotifyMsg = aMessage; 
+            aComplete = EFalse;
+            iServerP->Printer()->MsgHandlerP()->RegisterReceiveObjectNotify(ext);
+            }
+        __FLOG(_L8("<<<CPtpSession::ObjectReceivedNotify"));                            
+        return err;
+        }
+    }
+    
+// --------------------------------------------------------------------------
+// CPtpSession::PtpFolder()
+// Returns PtpFolder Name and Path
+// --------------------------------------------------------------------------
+//    
+TInt CPtpSession::PtpFolder(const RMessage2& aMessage)
+    {
+    __FLOG(_L8(">>>CPtpSession::PtpFolder"));
+    TInt err(KErrNotReady);
+    TFileName folder = iServerP->PtpFolder();
+    err = aMessage.Write(0,folder);
+    __FLOG_VA((_L16("<<<CPtpSession::PtpFolder %S err(%d)"), &folder, err));
+    return err;
+    }
+    
+// --------------------------------------------------------------------------
+// CPtpSession::SendObjectCompleted()
+// 
+// --------------------------------------------------------------------------
+//    
+void CPtpSession::SendObjectCompleted(TInt aStatus)
+    {
+    __FLOG_VA((_L16(">>>CPtpSession::SendObjectCompleted status(%d)"), aStatus));
+    if (iSendObjectMsg.Handle())
+        {
+        iSendObjectMsg.Complete(aStatus);    
+        iTimerP->Cancel();
+        }
+    else
+        {
+        __FLOG(_L8("!!!Warning: CPtpSession::SendObjectCompleted: UNEXPECTED CALL"));
+        }
+    __FLOG(_L8("<<<CPtpSession::SendObjectCompleted")); 
+    }
+
+// --------------------------------------------------------------------------
+// CPtpSession::IsDpsPrinterCompleted()
+// 
+// --------------------------------------------------------------------------
+//
+void CPtpSession::IsDpsPrinterCompleted(TDpsPrinterState aState)
+    {
+    __FLOG(_L8(">>>CPtpSession::IsDpsPrinterCompleted"));    
+    if (iDpsPrinterMsg.Handle())
+        {
+        iDpsPrinterMsg.Complete(aState);
+        iTimerP->Cancel();
+        iServerP->Printer()->DeRegisterDpsPrinterNotify(this);
+        }
+    else
+        {
+        __FLOG(_L8("!!!Warning: CPtpSession::IsDpsPrinterCompleted: UNEXPECTED CALL"));
+        }
+    __FLOG(_L8("<<<CPtpSession::IsDpsPrinterCompleted"));    
+    }
+
+// --------------------------------------------------------------------------
+// CPtpSession::ReceivedObjectCompleted()
+// 
+// --------------------------------------------------------------------------
+//
+void CPtpSession::ReceivedObjectCompleted(TDes& aFile)
+    {
+    __FLOG(_L8(">>>CPtpSession::ReceivedObjectCompleted"));
+    if (iObjectReceivedNotifyMsg.Handle())
+        {
+        TInt err = iObjectReceivedNotifyMsg.Write(1, aFile);
+        iReceivedFile.Copy(aFile);
+        __FLOG_VA((_L8("***CPtpSession::ReceivedObjectCompleted err=%d"), err));
+        iObjectReceivedNotifyMsg.Complete(err);
+        }
+    else
+        {
+        __FLOG(_L8("!!!Warning: Strange Happened!!!"));    
+        }
+    __FLOG(_L8("<<<CPtpSession::ReceivedObjectCompleted"));
+    }
+
+// --------------------------------------------------------------------------
+// 
+// Cancels outstanding request
+// --------------------------------------------------------------------------
+//
+void CPtpSession::CancelOutstandingRequest()
+    {
+    __FLOG(_L8(">>>CPtpSession::CancelOutstandingRequest"));
+    if (iSendObjectMsg.Handle())
+        {
+        iSendObjectMsg.Complete(KErrCancel);
+        }
+    if (iObjectReceivedNotifyMsg.Handle())
+        {
+        iObjectReceivedNotifyMsg.Complete(KErrCancel);
+        }
+    if (iDpsPrinterMsg.Handle())
+        {
+        iDpsPrinterMsg.Complete(KErrCancel);
+        }
+    __FLOG(_L8("<<<CPtpSession::CancelOutstandingRequest"));    
+    }
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+CPtpServer* CPtpSession::ServerP() const
+    {
+    return iServerP;    
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/cptptimer.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,122 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include "cptptimer.h"
+#include "cmtppictbridgeprinter.h"
+#include "cptpsession.h"
+#include "cptpserver.h"
+#include "ptpdef.h"
+#include "mtppictbridgedpconst.h"
+
+// --------------------------------------------------------------------------
+// 
+// 
+// --------------------------------------------------------------------------
+//
+CPtpTimer* CPtpTimer::NewL(CPtpSession& aSession)
+    {
+    CPtpTimer* self = new(ELeave) CPtpTimer(aSession);
+    CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// 
+// 
+// --------------------------------------------------------------------------
+//    
+CPtpTimer::CPtpTimer(CPtpSession& aSession) : CTimer(EPriorityStandard),
+    iSession(aSession)
+    {
+    CActiveScheduler::Add(this);    
+    }
+    
+// --------------------------------------------------------------------------
+// 
+// 
+// --------------------------------------------------------------------------
+//
+void CPtpTimer::ConstructL()    
+    {
+    __FLOG_OPEN(KMTPSubsystem, KPtpServerLog);
+    __FLOG(_L8("CPtpTimer::ConstructL"));        
+    CTimer::ConstructL();
+    }
+
+// --------------------------------------------------------------------------
+// 
+// 
+// --------------------------------------------------------------------------
+//
+CPtpTimer::~CPtpTimer()
+    {
+    __FLOG(_L8("CPtpTimer::~"));        
+    Cancel();
+    __FLOG_CLOSE;
+    }
+    
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//    
+void CPtpTimer::RunL()
+    {
+    __FLOG(_L8(">>>CPtpTimer::RunL"));
+    if (iStatus.Int() == KErrNone)
+        {
+        __FLOG(_L8("--- timer expired, because of:"));
+
+        if (iSession.ServerP()->Printer()->Status() == CMTPPictBridgePrinter::ENotConnected) // must be DPS discovery, since no other service is supported
+            {
+            __FLOG(_L8("--- Dps printer not available"));            
+            iSession.ServerP()->Printer()->NoDpsDiscovery();
+            iSession.IsDpsPrinterCompleted(EPrinterNotAvailable);
+            }
+        else if (iSession.ServerP()->Printer()->SendObjectPending())
+            {
+            __FLOG(_L8("---SendObject timeout"));
+            iSession.ServerP()->Printer()->DpsFileSent(KErrTimedOut);
+            }
+        else 
+            {
+            __FLOG(_L8("---something else, do not care"));
+            }    
+        }
+    else if (iStatus.Int() == KErrCancel)
+        {
+        __FLOG(_L8("--- RunL Cancelled."));
+        }
+    else 
+        {
+        __FLOG_VA((_L8("!!!Error: Err %d returned."), iStatus.Int()));
+        }
+    __FLOG(_L8("<<<CPtpTimer::RunL"));	
+    }
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+#ifdef __FLOG_ACTIVE
+TInt CPtpTimer::RunError(TInt aErr)
+#else
+TInt CPtpTimer::RunError(TInt /*aErr*/)
+#endif
+    {
+    __FLOG_VA((_L8(">>>CPtpTimer::RunError %d"), aErr));
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/mtppictbridgedp.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,42 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+#include <ecom/registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = 0x2001FE3B;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x102827AD;
+			implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x2001FE3C; 
+					version_no = 1;
+					display_name = "MTP PictBridge Data Provider plug-in.";
+					default_data = "";
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/mtppictbridgedp_config.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#include <mtp/mtpdataproviderconfig.rh>
+
+RESOURCE MTP_DATA_PROVIDER dpConfig
+    {
+    type = KMTPDataProviderTypeECOM;
+    major_version = 1;
+    object_enumeration_persistent = 0;
+    supported_modes = KMTPModeMTP;
+    server_name = "";
+    server_image_name = "";
+    opaque_resource = 0;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/mtppictbridgedpimplementations.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,36 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <ecom/implementationproxy.h>
+#include "cmtppictbridgedp.h"
+#include "ptpdef.h" // debug
+
+// Define the interface UIDs
+static const TImplementationProxy ImplementationTable[] =
+    {
+        {
+        {0x2001FE3C}, (TProxyNewLPtr)(CMTPPictBridgeDataProvider::NewL)
+        }
+    };
+
+/**
+ECOM entry point
+*/
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/mtppictbridgerequestprocessor.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,110 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+ */
+
+#include <mtp/tmtptyperequest.h>
+#include "mtppictbridgedpconst.h"
+#include "mtppictbridgedpprocessor.h"
+#include "cmtppictbridgedpgetobject.h"
+#include "cmtppictbridgedpgetobjectinfo.h"
+#include "cmtppictbridgedpsendobjectinfo.h"
+#include "cmtprequestunknown.h"
+#include "cmtpcommonrequestprocessor.h"
+
+/** 
+Defines a processor factory function pointer
+
+@internalTechnology
+*/
+typedef MMTPRequestProcessor* (*TMTPPictBridgeRequestProcessorCreateFunc)(
+                                                                MMTPDataProviderFramework& aFramework, 
+                                                                MMTPConnection& aConnection,
+                                                                CMTPPictBridgeDataProvider& aDataProvider);
+
+
+/** 
+Defines an entry which maps from operation code to the request processor
+
+@internalTechnology
+*/
+typedef struct 
+    {
+    TUint16                                  iOperationCode;
+    TMTPPictBridgeRequestProcessorCreateFunc iCreateFunc;
+    }TMTPPictBridgeRequestProcessorEntry;
+
+template<TMTPResponseCode RESPCODE, TBool HASITORDATA>
+static MMTPRequestProcessor* CommonProcessorCreator(MMTPDataProviderFramework& aFramework, 
+                                                    MMTPConnection& aConnection,
+                                                    CMTPPictBridgeDataProvider& )
+    {
+    return CMTPCommonRequestProcessor::NewL<RESPCODE, HASITORDATA>(aFramework, aConnection);
+    }
+    
+
+// --------------------------------------------------------------------------
+// A mapping table from the operation code to the request processor factory method
+// --------------------------------------------------------------------------
+//
+static const TMTPPictBridgeRequestProcessorEntry KMTPPictBridgeDpRequestProcessorTable[]=
+    {
+    {EMTPOpCodeGetObjectInfo,           CMTPPictBridgeDpGetObjectInfo::NewL},
+    {EMTPOpCodeGetObject,               CMTPPictBridgeDpGetObject::NewL},
+    {EMTPOpCodeSendObjectInfo,          CMTPPictBridgeDpSendObjectInfo::NewL},
+    {EMTPOpCodeSendObject,              CMTPPictBridgeDpSendObjectInfo::NewL}  
+    };
+
+// --------------------------------------------------------------------------
+// Create a request processor that matches the request
+// @param aPlugin   The reference to the data provider plugin 
+// @param aFramework The reference to the data provider framework
+// @param aRequest  The request to be processed
+// @param aConnection The connection from which the request comes from
+// @return a pointer to the request processor
+// --------------------------------------------------------------------------
+//
+MMTPRequestProcessor* MTPPictBridgeDpProcessor::CreateL(
+                                                    MMTPDataProviderFramework& aFramework,
+                                                    const TMTPTypeRequest& aRequest, 
+                                                    MMTPConnection& aConnection,
+                                                    CMTPPictBridgeDataProvider& aDataProvider)
+    {
+    
+
+    TMTPPictBridgeRequestProcessorCreateFunc createFunc = NULL; 
+    TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
+    TInt count = sizeof(KMTPPictBridgeDpRequestProcessorTable) / sizeof(TMTPRequestProcessorEntry);
+
+    for(TInt i = 0; i < count; i++)
+        {
+        if(KMTPPictBridgeDpRequestProcessorTable[i].iOperationCode == operationCode)
+            {
+            createFunc = KMTPPictBridgeDpRequestProcessorTable[i].iCreateFunc;
+            break;
+            }
+        }
+
+    if(!createFunc) 
+        {
+        return CMTPRequestUnknown::NewL(aFramework, aConnection);
+        }
+
+    return (*createFunc)(aFramework, aConnection, aDataProvider);
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/src/rptp.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,286 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <f32file.h>
+#include "rptp.h"
+#include "ptpdef.h"
+
+
+//-----------------------------------------------------------------------------
+// RPtp::RPtp()
+// C++ Constructor
+//-----------------------------------------------------------------------------
+//
+EXPORT_C RPtp::RPtp()
+    {
+    iConnected=EFalse;
+    }
+
+//-----------------------------------------------------------------------------
+// RPtp::Connect()
+// Creates session with PtpServer
+//-----------------------------------------------------------------------------
+//
+EXPORT_C TInt RPtp::Connect()
+    {
+    // We do not attempt to start the server since it is started up only when 
+    // MTP is loaded (at USB cable connection). To be compatible with previous 
+    // version of PTP server we keep track of the connection and try to create it
+    // if it does not yet exist.
+    if(DoConnect() != KErrNone) // we claim that the connection succeeded.
+    	{
+    	//Do nothing.Still return KErrNone to lanuch ImagePrint to prompt users to plug-in USB cable.
+    	}
+    
+    return KErrNone;
+    }
+
+//-----------------------------------------------------------------------------
+// RPtp::DoConnect()
+//-----------------------------------------------------------------------------
+//
+TInt RPtp::DoConnect()
+    {
+    TInt ret=KErrNone;
+    if(EFalse==iConnected)
+        {
+        TVersion version(KPtpServerVersionMajor, KPtpServerVersionMinor, 0);
+        ret=KErrNotReady;
+        ret = CreateSession( KPTPServer, version );
+        if (KErrNone==ret)
+            {
+            iConnected=ETrue;
+            }
+        }
+    return ret; 
+    }
+
+//-----------------------------------------------------------------------------
+// RPtp::CreatePtpStack()
+// Creates session with PTP Server, creates PTP stack and loads transposrt plugin
+// Called by PTP Class controller
+//-----------------------------------------------------------------------------
+//
+EXPORT_C TInt RPtp::CreatePtpStack(const TUid /* aTransport */)
+    {
+    Connect();
+    return KErrNone;
+    }
+    
+
+//-----------------------------------------------------------------------------
+// RPtp::IsDpsPrinter()
+// Asynchronously request request DPS printer status
+//-----------------------------------------------------------------------------
+//
+EXPORT_C void RPtp::IsDpsPrinter(TRequestStatus& aStatus)
+    {
+    if(DoConnect()==KErrNone)
+        {
+        SendReceive(EIsDpsPrinter, aStatus);
+        }
+    else
+        {
+        TRequestStatus* statusP=&aStatus;
+        User::RequestComplete(statusP, EPrinterNotAvailable);
+        }
+    }
+
+//-----------------------------------------------------------------------------
+// RPtp::CancelIsDpsPrinter()
+// Cancel DPS printer status request
+//-----------------------------------------------------------------------------
+//
+EXPORT_C void RPtp::CancelIsDpsPrinter()
+    {
+    if(DoConnect()==KErrNone)
+        {
+        if(SendReceive(ECancelIsDpsPrinter)==KErrServerTerminated)
+            {
+            iConnected=EFalse;
+            }
+        }
+    }
+    
+//-----------------------------------------------------------------------------
+// RPtp::SendObject()
+// Request send object to Pictbridge Printer host 
+//-----------------------------------------------------------------------------
+//
+EXPORT_C void RPtp::SendObject(const TDesC& aNameAndPath, 
+                               TRequestStatus& aStatus, TBool aTimeout, 
+                               TInt aSize, TBool aAdd)
+    {   
+    if(DoConnect()==KErrNone)
+        {
+        iFile.Copy(aNameAndPath);
+        const TIpcArgs args(&iFile, aAdd, aTimeout, aSize); 
+        SendReceive(ESendObject, args, aStatus);
+        }
+    else
+        {
+        TRequestStatus* statusP=&aStatus;
+        User::RequestComplete(statusP, KErrNotReady);
+        }
+    }
+
+//-----------------------------------------------------------------------------
+// RPtp::CancelSendObject()
+// Cancel send object request 
+//-----------------------------------------------------------------------------
+//
+EXPORT_C void RPtp::CancelSendObject()
+    {
+    if(DoConnect()==KErrNone)
+        {
+        if(SendReceive(ECancelSendObject)==KErrServerTerminated)
+            {
+            iConnected=EFalse;    
+            }
+        }
+    }
+
+//-----------------------------------------------------------------------------
+// RPtp::GetObjectHandleByName()
+// Get Object handle by name
+//-----------------------------------------------------------------------------
+//
+EXPORT_C TInt RPtp::GetObjectHandleByName(const TDesC& aNameAndPath, 
+                                          TUint32& aHandle, 
+                                          TBool /*aAdd*/)
+    {
+    TInt ret=KErrNone;
+    if((ret=DoConnect())==KErrNone)
+        {
+        TPckgBuf<TUint32> pckgHandle(aHandle);
+        const TIpcArgs args(&aNameAndPath, &pckgHandle, EFalse/*aAdd*/);
+        ret = SendReceive(EGetObjectHandleByName, args);
+        if (ret == KErrNone)
+            {
+            aHandle = (TUint32)pckgHandle();
+            if(0 == aHandle)
+                {
+                ret = KErrNotFound;
+                }
+            }
+        else if (ret == KErrServerTerminated)
+            {
+            iConnected=EFalse;    
+            }
+        }
+    return ret;     
+    }
+
+//-----------------------------------------------------------------------------
+// GetNameByObjectHandle()
+// Get object name and path by object handle 
+//-----------------------------------------------------------------------------
+//
+EXPORT_C TInt RPtp::GetNameByObjectHandle(TDes& aNameAndPath, 
+                                          const TUint32 aHandle)
+    {
+    TInt ret=KErrNone;
+    if((ret=DoConnect())==KErrNone)
+        {   
+        TPckgBuf<TUint32> pckgHandle(aHandle);
+        const TIpcArgs args(&aNameAndPath, &pckgHandle);
+        ret = SendReceive(EGetNameByObjectHandle, args);
+        if (ret==KErrServerTerminated)
+            {
+            iConnected=EFalse;    
+            }
+        }
+    return ret;
+    }
+
+//-----------------------------------------------------------------------------
+// RPtp::ObjectReceivedNotify()
+// Register for object received notification
+//-----------------------------------------------------------------------------
+//
+EXPORT_C void RPtp::ObjectReceivedNotify( const TDesC& aExt,
+                                          TDes& aNameAndPath,
+                                          TRequestStatus& aStatus,
+                                          TBool aDelete )
+    {
+    if(DoConnect()==KErrNone)
+        {
+        iExt.Copy(aExt);
+        const TIpcArgs args(&iExt, &aNameAndPath, aDelete);
+        SendReceive(EObjectReceivedNotify, args, aStatus);
+        }
+    else
+        {
+        TRequestStatus* statusP=&aStatus;
+        User::RequestComplete(statusP, KErrNotReady);
+        }
+    }
+
+//-----------------------------------------------------------------------------
+// RPtp::CancelObjectReceivedNotify()
+// Cancel for object received notification
+//-----------------------------------------------------------------------------
+//
+EXPORT_C void RPtp::CancelObjectReceivedNotify()
+    {
+    if(DoConnect()==KErrNone)
+        {
+        if(SendReceive(ECancelObjectReceivedNotify)==KErrServerTerminated)
+            {
+            iConnected=EFalse;    
+            }
+        }
+    }
+
+//-----------------------------------------------------------------------------
+// RPtp::DestroyPtpStatck()
+// Destroy PTP stack @deprecated, only calls close, use Close() instead
+//-----------------------------------------------------------------------------
+//
+EXPORT_C void RPtp::DestroyPtpStatck()
+    {
+    Close();
+    }
+ 
+//-----------------------------------------------------------------------------
+// RPtp::Close()
+// Override RSessionBase::Close();
+//-----------------------------------------------------------------------------
+//
+EXPORT_C void RPtp::Close()
+    {
+    RSessionBase::Close();
+    iConnected=EFalse;
+    }
+
+//-----------------------------------------------------------------------------
+// RPtp::PtpFolder()
+// returns name and Path of PtpFolder
+//-----------------------------------------------------------------------------
+//      
+EXPORT_C const TDesC& RPtp::PtpFolder()
+    {
+    if(DoConnect()==KErrNone)
+        {
+        const TIpcArgs args(&iFile); 
+        if(SendReceive(EPtpFolder, args)==KErrServerTerminated)
+            {
+            iConnected=EFalse;    
+            }
+        }
+    return iFile;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/common/inc/cmtprequestlogger.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,79 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPREQUESTLOGGER_H
+#define CMTPREQUESTLOGGER_H
+
+#include <e32base.h>
+
+//#include "rmtpframework.h"
+#include "mtpdebug.h"
+
+#include <gmxmlcomposer.h>
+#include <mtp/mtpdataproviderapitypes.h>
+
+class TMTPTypeRequest;
+class TMTPTypeResponse;
+class CMTPXmlLogger;
+	
+/** 
+@internalComponent
+*/
+class CMTPRequestLogger : public CBase, public MMDXMLComposerObserver 
+    {
+public:
+
+	IMPORT_C ~CMTPRequestLogger();
+	IMPORT_C static CMTPRequestLogger* NewL();
+	IMPORT_C void LogRequestL(const TMTPTypeRequest& aRequest);
+	IMPORT_C void LogResponseL(const TMTPTypeResponse& aResponse);
+	IMPORT_C void WriteDataPhaseL(const MMTPType& aData, TMTPTransactionPhase aDataPhase);
+	IMPORT_C TInt CreateOutputDir(TDes& aTestCaseFn);
+    IMPORT_C void WriteTestCaseL(TDesC& aTestCaseFn, const TMTPTypeResponse& aResponse);
+    
+    public: // from MMDXMLComposerObserver
+	IMPORT_C void ComposeFileCompleteL();
+    
+private:    
+    CMTPRequestLogger();
+    void ConstructL();
+    
+private:
+    // We store all of the test case data upto the response phase as the XML parser requires an
+    // 2nd level active scheduler to be constructed to work in this context.
+    TMTPTypeRequest iCurrentRequest;
+    TBuf<KMaxFileName> iCurrentRToIDataPhaseFN;
+    TBuf<KMaxFileName> iCurrentIToRDataPhaseFN;
+    
+    TInt iCurrentTestCaseId;
+    TBuf<KMaxFileName> iCurrentXMLTestCase;
+    TBuf<KMaxFileName> iCurrentTestOutputDir;
+    RFs iFs;
+    RFile iCurrentTestOutput;
+    CActiveScheduler* s;
+    CMTPXmlLogger* iXMLLogger;
+    //CActiveSchedulerWait iWait;
+    CActiveScheduler* iScheduler;
+    CActiveScheduler* iCurrent;
+    TInt iCurrentSessionID;
+    __FLOG_DECLARATION_MEMBER;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/common/inc/mtpbuildoptions.hrh	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,36 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Build options for MTP
+// Special build flag, capture request, data phase and responses to disk.
+// 
+//
+
+/**
+ @file
+ @internalComponent
+*/
+//#define MTP_CAPTURE_TEST_DATA 1
+
+/**
+Special build flag, enable this macro will make only "c:\mtptest" and 
+"z:\mtptest" visible to the file dp.
+*/
+#define MTP_PROXY_TEST_TRANSPORT 1
+
+
+/**
+Build flag to enable/disable Flogger __FLOG_HEXDUMP within the USB transport, UDEB builds only
+Note: When enabled this flag may cause lockups when transferring large (1024KB+ files) over USB.
+*/
+//#define MTP_DEBUG_FLOG_HEX_DUMP 1
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/common/inc/mtpdatacapture.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,39 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPDATACAPTURE_H
+#define CMTPDATACAPTURE_H
+
+// MTP data caputre defines
+
+#if defined(__WINS__)
+_LIT(KRequestCaptureRootDir, "c:\\test\\data\\");
+#elif defined(__SERIES60_) 
+_LIT(KRequestCaptureRootDir, "f:\\test\\data\\");
+#else
+_LIT(KRequestCaptureRootDir, "e:\\test\\data\\");
+#endif
+
+_LIT(KRequestCaptureDirPrefix, "testcase");
+_LIT(KIToRDataPhaseOutputFile, "i_to_r_dataphase.dat");
+_LIT(KRToIDataPhaseOutputFile, "r_to_i_dataphase.dat");
+_LIT(KTestCaseFilename, "testcase.xml");
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/common/inc/mtpdebug.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,42 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef MTPDEBUG_H
+#define MTPDEBUG_H
+
+#include <comms-infras/commsdebugutility.h>
+
+__FLOG_STMT(_LIT8(KMTPSubsystem, "MTP");)
+
+#ifdef __FLOG_ACTIVE
+#define __MTP_HEAP_FLOG \
+    { \
+    TInt allocated; \
+    TInt largest; \
+    TInt available(User::Heap().Available(largest)); \
+    TInt size(User::Heap().Size()); \
+    User::Heap().AllocSize(allocated); \
+    __FLOG_STATIC_VA((KMTPSubsystem, KComponent, _L8("Heap: Size = %d, Allocated = %d, Available = %d, Largest block = %d"), size, allocated, available, largest)); \
+    }
+#else
+#define __MTP_HEAP_FLOG 
+#endif // __FLOG_ACTIVE
+
+#endif // MTPDEBUG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/daemon/client/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,30 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// MTP Client API
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../interface/rmtpclient.h   SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/rmtpclient.h)
+
+PRJ_MMPFILES 
+mtpclient.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/daemon/client/group/mtpclient.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,34 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+TARGET              mtpclient.dll
+TARGETTYPE          DLL
+UID         	    0x1000008D 0x102827A0
+VENDORID 			0x70000001
+
+CAPABILITY          All -Tcb
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+USERINCLUDE			../../common/inc/ 
+USERINCLUDE			../../../common/inc 
+
+SOURCEPATH          ../src 
+SOURCE              rmtpclient.cpp
+
+LIBRARY             euser.lib
+LIBRARY				efsrv.lib
+LIBRARY				hal.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/daemon/client/interface/rmtpclient.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,117 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef RMTPCLIENT_H
+#define RMTPCLIENT_H
+
+#include <e32std.h>
+
+/**
+Implements the MTP client API. This API provides a control interface to start 
+and stop MTP services. 
+@publishedPartner
+@released
+*/
+class RMTPClient : public RSessionBase
+    {
+public:
+
+    IMPORT_C RMTPClient();
+    IMPORT_C void Close();
+    IMPORT_C TInt Connect();
+    IMPORT_C TInt StartTransport(TUid aTransport);
+    IMPORT_C TInt StartTransport(TUid aTransport, const TDesC8& aParameter);
+    IMPORT_C TInt StopTransport(TUid aTransport);
+    IMPORT_C const TVersion& Version() const;
+	IMPORT_C TInt  IsAvailable(TUid aTransport);
+	IMPORT_C TInt  IsProcessRunning();
+private: // Owned
+
+    /**
+    The minimum MTP daemon version with which the MTP client API is compatible.
+    */
+    TVersion iVersion;
+    };
+
+/**
+Implements the MTP operational mode Publish & Subscribe key.
+@publishedPartner
+@released
+*/
+static const TInt32 KUidMTPModeKeyValue(0x1028304B);
+
+/**
+Implements the MTP Connection State Publish & Subscribe Category.
+@publishedPartner
+@released
+*/
+const TUid KMTPPublishConnStateCat={0x102827A2};
+
+/**
+Implements the MTP Connection StatePublish & Subscribe key.
+@publishedPartner
+@released
+*/
+enum TMTPConnTypeKey
+{
+	EMTPConnStateKey,
+	EMTPVersionInfo,	
+};
+
+/**
+  These are the different connection states,This events are used for publishing
+  @publishedPartner
+  @released 
+  */
+enum TMTPConnStateType
+{
+	EConnectedToHost = 0,
+	ESendingDataToHost,
+	EReceiveDataFromHost,
+	EDisconnectedFromHost
+};
+
+/**
+  The struct is used for MTP over Bluetooth.
+  @publishedPartner
+  @released
+  */
+struct TMTPBTRemoteDevice
+    {
+    TInt64   iDeviceAddr;
+    TUint16  iDeviceServicePort;
+    };
+
+/**
+  The struct is used for MTP over Bluetooth.
+  @publishedPartner
+  @released
+  */
+typedef TPckgBuf<TMTPBTRemoteDevice> TMTPBTRemoteDeviceBuf;
+
+/**
+  Used for MTP over Bluetooth Parameter Verification.
+  @publishedPartner
+  @released
+  */
+const TUint8 KMTPBTRemoteDeviceBufLength( 0x0a );
+
+#endif // RMTPCLIENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/daemon/client/src/rmtpclient.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,240 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+//The minumum free RAM for mtp server startup, in Bytes.
+//If current free RAM is lower than this threhold value, mtp server
+//will not get started.
+#define SYMBIAN_MTP_RAM_THRESHOLD                4*1024*1024 //4MB
+
+//The minimum free space in phone memory for mtp server startup, in Bytes.
+//If current free space in phone memory is lower than this threhold value,
+//mtp server will not get started.
+#define SYMBIAN_MTP_PHONE_MEMORY_THRESHOLD       512*1024 //512KB
+
+//The drive used as phone memory in target device
+#define SYMBIAN_PHONE_MEMORY_DRIVE_NAME          EDriveC
+
+#include <e32cmn.h>
+#include <e32uid.h>
+#include <hal.h>  //for HAL to get free RAM
+#include <f32file.h>  //for RFs to get free disk space in phone memory
+#include <mtp/rmtpclient.h>
+#include "mtpclientserver.h"
+
+/**
+Get the free RAM.
+@param on return, 'aFree' contains the free memory in bytes.
+@return ErrNone on success, other system-wide error on failure.
+ */
+static TInt GetFreeRAM(TInt &aFree)
+    {
+    TInt err = HAL::Get(HAL::EMemoryRAMFree,aFree);
+    __ASSERT_DEBUG(err != KErrArgument,User::Invariant());
+    return err;
+    }
+
+/**
+Get the free disk space in phone memory.
+@param on return,'aFree' contains the free space in bytes.
+@return ErrNone on success, other system-wide error on failure.
+ */
+static TInt GetFreeSpaceInPhoneMemory(TInt64 &aFree)
+    {
+    TVolumeInfo info;
+    RFs rfs;
+    TInt err = rfs.Connect();
+    if (err != KErrNone)
+        {
+        return err;
+        }
+
+    err = rfs.Volume(info,SYMBIAN_PHONE_MEMORY_DRIVE_NAME);
+    aFree = info.iFree;
+    rfs.Close();
+    return err;
+    }
+
+/**
+Starts the MTP daemon server process.
+@return KErrNone if the MTP daemon server process is started successfully, 
+otherwise one of the system wide error codes.
+*/
+
+LOCAL_D TInt StartServer()
+	{
+	const TUidType serverUid(KNullUid, KNullUid, KMTPServerUid3);
+	
+	//Firstly, check the free ram
+	TInt freeRam = 0;
+	TInt err = GetFreeRAM(freeRam);
+	
+	//Ignore the error code and move ahead
+	if (err == KErrNone && freeRam < SYMBIAN_MTP_RAM_THRESHOLD)
+	    {
+	    return KErrNoMemory;
+	    }
+	    
+	//Secondly,check the free disk space in phone memory
+	TInt64 freeDisk = 0;
+	err = GetFreeSpaceInPhoneMemory(freeDisk);
+    
+	//Ignore the error code and move ahead
+	if (err == KErrNone && freeDisk < SYMBIAN_MTP_PHONE_MEMORY_THRESHOLD)
+	    {
+	    return KErrDiskFull;
+	    }
+	
+	// Create the server process.
+	RProcess server;
+	TInt ret(server.Create(KMTPServerName, KNullDesC, serverUid));
+	if (ret == KErrNone)
+	    {	
+    	TRequestStatus status;
+    	server.Rendezvous(status);
+    	
+    	if (status != KRequestPending)
+    	    {
+    		// Abort the server process.
+    	    server.Kill(status.Int());
+    	    }
+    	else
+    	    {
+    	    // Run the server process.
+    	    server.Resume();
+    	    }
+		// Wait for the server start up to complete.
+    	User::WaitForRequest(status);
+    	ret = (server.ExitType() == EExitPanic) ? KErrGeneral : status.Int();
+    	server.Close();
+	    }
+	    
+	return ret;
+	}
+
+
+
+/**
+Constructor.
+*/
+EXPORT_C RMTPClient::RMTPClient() :
+    iVersion(KMTPVersionMajor, KMTPVersionMinor, KMTPVersionBuild)
+    {
+
+    }
+   
+/**
+Closes a connection to the MTP daemon server.
+*/ 
+EXPORT_C void RMTPClient::Close()
+    {
+    RSessionBase::Close();
+    }
+	
+/**
+Opens a connection to the MTP daemon server.
+@return KErrNone if the connection is made, otherwise one of the system wide 
+error codes.
+*/
+EXPORT_C TInt RMTPClient::Connect()
+	{	
+	TInt ret(KErrNone);
+	const TSecurityPolicy policy(static_cast<TSecureId>(KMTPServerUid3));
+    const static TInt KMaxRetries(3);
+	for (TInt retry(KMaxRetries); ((retry > 0) && ((ret == KErrNone) || (ret == KErrAlreadyExists))); retry--)
+		{
+		ret = CreateSession(KMTPServerName, iVersion, KMTPASyncMessageSlots, EIpcSession_Unsharable, &policy);
+		
+        if ((ret == KErrNotFound) || (ret == KErrServerTerminated))
+		    {
+		    ret = StartServer();
+		    }
+		else 
+			{ 
+			// Return if there's any err other than KErrNotFound or KErrServerTerminated.
+			retry = 0;
+			}
+		}
+	return ret;
+	} 
+
+/**
+Starts up the specified MTP transport protocol.
+@param aTransport The implementation UID of the transport protocol implemetation.
+@return KErrNone if the transport is started successfully, otherwise one of the 
+system wide error codes.
+*/
+EXPORT_C TInt RMTPClient::StartTransport(TUid aTransport)
+    {
+    TIpcArgs args( static_cast< TInt >( aTransport.iUid ), &KNullDesC8 );
+    return SendReceive( EMTPClientStartTransport, args );
+    }
+
+/**
+Starts up the specified MTP BLUETOOTH transport protocol.
+@param aTransport The implementation UID of the transport protocol implemetation.
+@return KErrNone if the transport is started successfully, otherwise one of the 
+system wide error codes.
+*/
+EXPORT_C TInt RMTPClient::StartTransport(TUid aTransport, const TDesC8& aParameter)
+    {
+    TIpcArgs args(static_cast<TInt>(aTransport.iUid), &aParameter);
+    return SendReceive(EMTPClientStartTransport,args);
+    }
+ 
+/**
+Shuts down the specified MTP transport protocol.
+@param aTransport The implementation UID of the transport protocol implemetation.
+@return KErrNone if the transport is started successfully, otherwise one of the 
+system wide error codes.
+*/
+EXPORT_C TInt RMTPClient::StopTransport(TUid aTransport)
+    {
+    return SendReceive(EMTPClientStopTransport, TIpcArgs(static_cast<TInt>(aTransport.iUid)));
+    }
+
+/**
+Provides the minimum MTP daemon version with which the MTP client API is 
+compatible.
+@return The minimum MTP daemon version.
+*/    
+EXPORT_C const TVersion& RMTPClient::Version() const
+	{
+    return iVersion;
+	}
+
+/**
+Checks whether MTP Framework shall allow the StartTransport Command or not.
+@param aTransport The implementation UID of the transport protocol implementation.
+@return KErrNone if the MTP FW is available for the given Transport,KErrAlreadyExists- If the same transport is running.
+KErrServerBusy- If the Transport can not be started.
+*/    
+EXPORT_C TInt RMTPClient::IsAvailable(TUid aTransport)
+    {
+	return  SendReceive(EMTPClientIsAvailable, TIpcArgs(static_cast<TInt>(aTransport.iUid)));
+    }
+
+/**
+Checks  whether the mtpserver.exe process is running or not.
+@returns KErrNone if mtpserver.exe is runnig, KErrNotFound if the process is not running.
+*/        
+EXPORT_C TInt RMTPClient::IsProcessRunning()
+    {
+		TFindServer findProc;
+		findProc.Find(KMTPServerName);
+		TFullName procName;
+		return findProc.Next(procName);		
+    
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/daemon/common/inc/mtpclientserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,82 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef MTPCLIENTSERVER_H
+#define MTPCLIENTSERVER_H
+
+#include <e32std.h>
+
+/**
+The MTP daemon server process name.
+*/
+_LIT(KMTPServerName,"mtpserver");
+
+/**
+The current major version number of the MTP daemon.
+*/
+const TUint KMTPVersionMajor(1);
+
+/**
+The current minor version number of the MTP daemon.
+*/
+const TUint KMTPVersionMinor(0);
+
+/**
+The current build number of the MTP daemon.
+*/
+const TUint KMTPVersionBuild(0);
+
+/**
+The MTP daemon server process UID3.
+*/
+const TUid KMTPServerUid3 = {0x102827A2};
+
+/**
+The number of message slots available to an MTP client session.
+*/
+const TInt KMTPASyncMessageSlots(1);
+
+/**
+The MTP client/server IPC function codes.
+*/
+enum TMTPClientIpcCodes
+	{
+	/**
+	RMTPClient::StartTransport
+	*/
+	EMTPClientStartTransport    = 0,
+	
+	/**
+	RMTPClient::StopTransport
+	*/
+	EMTPClientStopTransport     = 1,
+	
+	/**
+	RMTPClient::StopTransport
+	*/
+	EMTPClientClose             = 2,
+
+/**
+	RMTPClient::IsAvailable
+	*/
+	EMTPClientIsAvailable       = 3,
+
+	/**
+	The invalid function code placeholder.
+	*/
+	EMTPClientNotSupported
+	};
+
+#endif // MTPCLIENTSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/daemon/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,28 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// MTP daemon components
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include            "../../datatypes/group/bld.inf"
+#include            "../../transports/transportapi/group/bld.inf"
+#include            "../../dataproviders/dataproviderapi/group/bld.inf"
+#include            "../client/group/bld.inf"
+#include            "../server/group/bld.inf"
+#include            "../../dataproviders/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/daemon/server/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,29 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Media Transfer Protocol Framework 
+// 
+//
+
+/**
+ @file
+*/
+
+PRJ_PLATFORMS
+
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES 
+mtpserver.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/daemon/server/group/mtpserver.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,54 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <comms-infras/commsdebugutility.mmh>
+
+TARGET              mtpserver.exe
+TARGETTYPE          EXE
+UID         	    0 0x102827A2
+VENDORID 			0x70000001
+
+CAPABILITY			CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData
+
+#ifdef WINSCW
+//EPOCHEAPSIZE        0x1400000   0x1400000   // 20MB
+EPOCHEAPSIZE        0x80000   0x400000   // 4MB
+#else
+EPOCHEAPSIZE        0x80000   0x400000   // 4MB
+#endif
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+USERINCLUDE         ../inc/ 
+USERINCLUDE         ../../common/inc/
+USERINCLUDE         ../../../common/inc
+USERINCLUDE         ../../../inc 
+USERINCLUDE         ../../../transports/transportapi/inc
+
+SOURCEPATH          ../src/ 
+SOURCE              cmtpserver.cpp
+SOURCE              cmtpserversession.cpp
+SOURCE 				cmtpshutdown.cpp
+
+// EPOC libraries.
+LIBRARY				ecom.lib
+LIBRARY				efsrv.lib
+LIBRARY 			euser.lib
+
+// MTP libraries.
+LIBRARY				mtpframework.lib
+
+SMPSAFE
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/daemon/server/inc/cmtpserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,95 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPSERVER_H
+#define CMTPSERVER_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+
+#include "mtpdebug.h"
+#include "rmtpframework.h"
+
+class CMTPShutdown;
+
+/**
+Implements the MTP daemon server, which houses the MTP framework components, 
+and implements the server side portion of the MTP Client API as a standard 
+Symbian OS client/server interface. 
+@internalTechnology
+*/
+class CMTPServer : public CPolicyServer
+	{
+public:
+
+	~CMTPServer();
+
+    static void RunServerL();
+	void AddSession();
+	void DropSession();
+	
+private: // From CPolicyServer
+	
+	CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
+
+private:
+
+	static CMTPServer* NewLC();
+	CMTPServer();
+	void ConstructL();
+	
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    /**
+    The MTP framework singletons.
+    */
+    RMTPFramework   iFrameworkSingletons;
+	
+	/**
+	The active MTP client API session count.
+	*/
+	TInt            iSessionCount;
+	
+	/**
+	The daemon server process shutdown timer
+	*/
+	CMTPShutdown*   iShutdown;
+	};
+
+/** 
+MTP server panic codes.
+*/
+enum TMTPPanic
+	{
+	EPanicBadDescriptor         = -1,
+	EPanicIllegalFunction       = -2,
+	EPanicAlreadyReceiving      = -3,
+	EPanicErrArgument           = -4
+	};
+
+void PanicClient(const RMessagePtr2& aMessage, TMTPPanic aPanic);
+	
+#endif // CMTPSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/daemon/server/inc/cmtpserversession.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,64 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <e32base.h>
+
+#include "cmtpserver.h"
+#include "mtpclientserver.h"
+#include "mtpdebug.h"
+#include "rmtpframework.h"
+
+/**
+Implements a single server side instance of an MTP Client API session. This 
+API is implemented as a standard Symbian OS client/server interface. 
+@internalTechnology
+*/
+class CMTPServerSession : public CSession2
+    {
+public:
+
+    CMTPServerSession();
+    ~CMTPServerSession();
+    
+public: // From CSession2
+
+    void CreateL();  
+    void ServiceL(const RMessage2& aMessage);
+
+private:
+    
+    void DoStartTransportL(const RMessage2& aMessage);
+    void DoStopTransport(const RMessage2& aMessage);
+    void DoIsAvailableL(const RMessage2& aMessage);
+    TBool CheckIsAvailableL(TUid aNewUID,TUid aCurUID);
+    TBool CheckIsBlueToothTransport(TUid aNewUid);
+    
+private:
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    /**
+    The MTP framework singletons.
+    */
+    RMTPFramework iSingletons;
+    };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/daemon/server/inc/cmtpshutdown.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,55 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPSHUTDOWN_H
+#define CMTPSHUTDOWN_H
+
+#include <e32base.h>
+
+#include "rmtpframework.h"
+
+/**
+Implements the MTP server process shutdown timer. 
+@internalComponent
+*/
+class CMTPShutdown : public CTimer
+    {
+public:
+
+    static CMTPShutdown* NewL(); 
+    virtual ~CMTPShutdown();
+      
+    void Start();
+    
+private: // From CTimer
+
+    void RunL();
+    
+private:
+
+    CMTPShutdown();
+    void ConstructL();    
+
+private:
+    
+    RMTPFramework iSingletons;
+    };
+
+#endif // CMTPSHUTDOWN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/daemon/server/src/cmtpserver.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,249 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <ecom/ecom.h>
+
+#include "cmtpconnectionmgr.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpserver.h"
+#include "cmtpserversession.h"
+#include "cmtpshutdown.h"
+#include "mtpclientserver.h"
+#include "mtpdebug.h"
+#include "rmtpframework.h"
+
+#define UNUSED_VAR(a) (a) = (a)
+
+__FLOG_STMT(_LIT8(KComponent,"Server");)
+
+/**
+PlatSec policy.
+*/ 
+const TUint8 KMTPPolicyElementNetworkAndLocal = 0;
+
+const TInt KMTPFunctionCodeRanges[] = 
+    {    
+    EMTPClientStartTransport, 
+    EMTPClientNotSupported,
+    };
+
+const TUint KMTPFunctionCodeRangeCount(sizeof(KMTPFunctionCodeRanges) / sizeof(KMTPFunctionCodeRanges[0]));
+
+const TUint8 KMtpElementsIndex[KMTPFunctionCodeRangeCount] =
+    {
+    KMTPPolicyElementNetworkAndLocal,
+    CPolicyServer::ENotSupported,
+    };
+
+const CPolicyServer::TPolicyElement KMtpPolicyElements[] = 
+    { 
+    {_INIT_SECURITY_POLICY_C2(ECapabilityNetworkServices, ECapabilityLocalServices), CPolicyServer::EFailClient},
+    };
+
+const static CPolicyServer::TPolicy KMTPServerPolicy =
+    {
+    CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass
+    KMTPFunctionCodeRangeCount,
+    KMTPFunctionCodeRanges,
+    KMtpElementsIndex,     // what each range is compared to 
+    KMtpPolicyElements     // what policies range is compared to
+    };
+    
+/**
+Destructor.
+*/
+CMTPServer::~CMTPServer()
+    {
+    __FLOG(_L8("~CMTPServer - Entry"));
+    delete iShutdown;
+    iFrameworkSingletons.ConnectionMgr().StopTransports();
+    iFrameworkSingletons.DpController().UnloadDataProviders();
+    iFrameworkSingletons.Close();
+    REComSession::FinalClose();
+    __FLOG(_L8("~CMTPServer - Exit"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Creates and executes a new CMTPServer instance.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPServer::RunServerL()
+    {
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("RunServerL - Entry"));
+    
+    // Naming the server thread after the server helps to debug panics
+    User::LeaveIfError(User::RenameProcess(KMTPServerName));
+    
+    // Create and install the active scheduler.
+    CActiveScheduler* scheduler(new(ELeave) CActiveScheduler);
+    CleanupStack::PushL(scheduler);
+    CActiveScheduler::Install(scheduler);
+    
+    // Create the server and leave it on the cleanup stack.
+    CMTPServer* server(CMTPServer::NewLC());
+    
+    // Initialisation complete, signal the client
+    RProcess::Rendezvous(KErrNone);
+    
+    // Execute the server.
+    CActiveScheduler::Start();
+
+	// Server shutting down. 
+	CleanupStack::PopAndDestroy(server);
+        
+    CleanupStack::PopAndDestroy(1); // scheduler
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("RunServerL - Exit"));
+    } 
+
+/**
+Adds a new CMTPServer session.
+*/
+void CMTPServer::AddSession()
+    {  
+    __FLOG(_L8("AddSession - Entry"));
+    if(iShutdown && iShutdown->IsActive())
+        {  
+        iShutdown->Cancel();
+        }
+    ++iSessionCount;
+    __FLOG(_L8("AddSession - Exit"));
+    }
+
+/**
+Removes a CMTPServer session. If there are no active MTP client API sessions 
+remaining and no active MTP connections, then a shutdown timer is started to 
+terminate the server thread.
+*/
+void CMTPServer::DropSession()
+    {
+    __FLOG(_L8("DropSession - Entry"));
+         
+    if (--iSessionCount==0 && iFrameworkSingletons.ConnectionMgr().TransportCount() == 0)
+        {
+        // No active MTP client API sessions remain, start the shutdown timer.
+        if (!iShutdown)
+            {
+            TRAPD(error, iShutdown = CMTPShutdown::NewL());
+            __FLOG(_L8("CMTPShutdown Loaded- Entry"));
+            UNUSED_VAR(error);    
+            }
+        if (iShutdown)
+            {
+            __FLOG(_L8("Shutdown Started - Entry"));
+            iShutdown->Start();
+            }
+        }
+    __FLOG(_L8("DropSession - Exit"));
+    }
+    
+CSession2* CMTPServer::NewSessionL(const TVersion&,const RMessage2&) const
+    {
+    __FLOG(_L8("NewSessionL - Entry"));
+    __FLOG(_L8("NewSessionL - Exit"));
+    return new(ELeave) CMTPServerSession();
+    }
+       
+/**
+CMTPServer factory method. A pointer to the constructed CMTPServer instance is
+placed on the cleanup stack.
+@return A pointer to a new CMTPServer instance. Ownership IS transfered.
+@leave One of the system wide error codes if a processing failure occurs.
+*/
+CMTPServer* CMTPServer::NewLC()
+    {
+    CMTPServer* self=new(ELeave) CMTPServer;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+/**
+Constructor.
+*/    
+CMTPServer::CMTPServer() : 
+    CPolicyServer(CActive::EPriorityStandard, KMTPServerPolicy)
+    {
+
+    }
+    
+/**
+second-phase constructor.
+*/
+void CMTPServer::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry"));
+    StartL(KMTPServerName);
+    iFrameworkSingletons.OpenL();
+    __FLOG(_L8("ConstructL - Exit"));
+    }
+        
+/*
+RMessage::Panic() also completes the message. This is:
+(a) important for efficient cleanup within the kernel
+(b) a problem if the message is completed a second time
+@param aMessage Message to be paniced.
+@param aPanic Panic code.
+*/
+void PanicClient(const RMessagePtr2& aMessage,TMTPPanic aPanic)
+    {
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("PanicClient - Entry"));
+    __FLOG_STATIC_VA((KMTPSubsystem, KComponent, _L8("Panic = %d"), aPanic));
+    _LIT(KPanic,"MTPServer");
+    aMessage.Panic(KPanic, aPanic);
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("PanicClient - Exit"));
+    }
+
+/**
+Process entry point
+*/
+TInt E32Main()
+    {
+    __UHEAP_MARK;
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("E32Main - Entry"));
+    __MTP_HEAP_FLOG
+    
+    CTrapCleanup* cleanup=CTrapCleanup::New();
+    TInt ret = KErrNoMemory;
+    if (cleanup)
+        {
+#ifdef __OOM_TESTING__
+        TInt i = 0;
+        while (ret == KErrNoMemory || ret == KErrNone)
+             {
+             __UHEAP_SETFAIL(RHeap::EDeterministic,i++);
+             __UHEAP_MARK;
+
+             TRAP(nRet, RunServerL());
+
+             __UHEAP_MARKEND;
+             __UHEAP_RESET;
+             }
+#else
+        TRAP(ret, CMTPServer::RunServerL());
+      
+#endif        
+        delete cleanup;
+        }
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("E32Main - Exit"));
+    __UHEAP_MARKEND;
+    return ret;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/daemon/server/src/cmtpserversession.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,219 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include "cmtpconnectionmgr.h"
+#include "cmtpserversession.h"
+#include "rmtpframework.h"
+#include "cmtpframeworkconfig.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpparserrouter.h"
+#include "e32def.h"
+__FLOG_STMT(_LIT8(KComponent,"ServerSession");)
+
+
+/**
+Constructor.
+*/
+CMTPServerSession::CMTPServerSession()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("CMTPServerSession - Entry"));
+    __FLOG(_L8("CMTPServerSession - Exit"));
+    }
+    
+/**
+Destructor.
+*/
+CMTPServerSession::~CMTPServerSession()
+    {
+    __FLOG(_L8("~CMTPServerSession - Entry"));
+    static_cast<CMTPServer*>(const_cast<CServer2*>(CSession2::Server()))->DropSession();
+    iSingletons.Close();
+    __FLOG(_L8("~CMTPServerSession - Exit"));
+    __FLOG_CLOSE;
+    }
+    
+void CMTPServerSession::CreateL()
+    {
+    __FLOG(_L8("CreateL - Entry"));
+    iSingletons.OpenL();
+    static_cast<CMTPServer*>(const_cast<CServer2*>(CSession2::Server()))->AddSession();
+    __FLOG(_L8("CreateL - Exit"));
+    }
+
+void CMTPServerSession::ServiceL(const RMessage2& aMessage)
+    {
+    __FLOG(_L8("ServiceL - Entry"));
+    switch (aMessage.Function())
+        {
+    case EMTPClientStartTransport:
+        __FLOG(_L8("StartTransport message received"));        
+        DoStartTransportL(aMessage);
+        break;
+    case EMTPClientStopTransport:
+        __FLOG(_L8("StopTransport message received"));
+        DoStopTransport(aMessage);
+        break;
+     case EMTPClientIsAvailable :
+        __FLOG(_L8("IsAvailable message received"));
+        DoIsAvailableL(aMessage);
+     
+        break;
+    default:
+        __FLOG(_L8("Unrecognised message received"));
+        break;        
+        }
+    __FLOG(_L8("ServiceL - Exit"));
+    }
+TBool CMTPServerSession::CheckIsAvailableL(TUid aNewUID,TUid aCurUID)
+{
+
+	    TInt SwitchEnabled;
+	    iSingletons.FrameworkConfig().GetValueL(CMTPFrameworkConfig::ETransportSwitchEnabled, SwitchEnabled);	    
+	    if(!SwitchEnabled )
+		    {		    
+		    return EFalse;
+		    }
+       TBuf<30> value;
+       iSingletons.FrameworkConfig().GetValueL(CMTPFrameworkConfig::ETransportHighPriorityUID,value);	    	    
+	   TUint HighUID;	    
+	   TLex lex(value);	    
+	   TInt conErr = lex.Val(HighUID,EHex);
+	   if(aCurUID.iUid == HighUID)
+		    {
+		    return EFalse;	
+
+		    }
+	   else if(aNewUID.iUid ==HighUID)
+		    {
+	    	return ETrue;
+		    }
+	   return EFalse;	
+}
+/**
+Starts up the specified MTP transport protocol.
+@param aTransport The implementation UID of the transport protocol implemetation.
+@leave One of the system wide error codes, if a processing error occurs.
+*/
+void CMTPServerSession::DoStartTransportL(const RMessage2& aMessage)
+    {
+    __FLOG(_L8("DoStartTransportL - Entry"));
+    TUid newUID = TUid::Uid(aMessage.Int0()); 
+    TUid curUID = iSingletons.ConnectionMgr().TransportUid();
+    if(curUID !=(KNullUid))  // Another Transport is already running
+		{
+    	if(!CheckIsAvailableL(newUID,curUID))
+    		{
+    		aMessage.Complete(KErrServerBusy);
+    		iSingletons.ConnectionMgr().QueueTransportL( newUID, NULL );
+    		return;
+    		}
+	    iSingletons.ConnectionMgr().StopTransport(curUID);
+    	}
+    
+    TUid secureid=aMessage.SecureId();    
+    iSingletons.ConnectionMgr().SetClientSId(secureid);
+    
+    TInt length = aMessage.GetDesLength( 1 );
+    
+    if((!CheckIsBlueToothTransport(newUID) || (length!=0)) && (iSingletons.DpController().Count()==0))
+    	{
+    	iSingletons.DpController().LoadDataProvidersL();
+    	iSingletons.Router().ConfigureL();
+    	}
+   
+    if (length > 0)
+    	{
+    	HBufC8* paramHbuf = HBufC8::NewLC(length);
+    	TPtr8 bufptr = paramHbuf->Des();
+    	aMessage.ReadL( 1, bufptr, 0);
+    	TRAPD(err, iSingletons.ConnectionMgr().StartTransportL( newUID, static_cast<TAny*>(paramHbuf) ));
+    	if ( KErrArgument == err )
+    		{
+    		PanicClient( aMessage, EPanicErrArgument );
+    		}
+    	else if ( KErrNone == err )
+    		{
+    		aMessage.Complete(KErrNone);
+    		}
+    	else 
+    		{
+    		User::LeaveIfError( err );
+    		}
+    	CleanupStack::PopAndDestroy(paramHbuf);
+    	}
+    else
+    	{
+    	iSingletons.ConnectionMgr().StartTransportL(newUID, NULL);
+    	aMessage.Complete(KErrNone);
+    	}
+    
+    
+    __FLOG(_L8("DoStartTransportL - Exit"));
+    }  
+
+
+/**
+Shuts down the specified MTP transport protocol.
+@param aTransport The implementation UID of the transport protocol implemetation.
+*/  
+void CMTPServerSession::DoStopTransport(const RMessage2& aMessage)
+    {
+    __FLOG(_L8("DoStopTransport - Entry"));
+   iSingletons.ConnectionMgr().StopTransport( TUid::Uid( aMessage.Int0() ), ETrue );
+    aMessage.Complete(KErrNone);
+    __FLOG(_L8("DoStopTransport - Exit"));
+    }
+
+/**
+Checks whether MTP Framework shall allow the StartTransport Command for given transport.
+@param aTransport The implementation UID of the transport protocol implementation.
+@leave One of the system wide error codes, if a processing error occurs.
+*/  
+void CMTPServerSession::DoIsAvailableL(const RMessage2& aMessage)
+    {
+    __FLOG(_L8("DoStopTransport - Entry"));
+   
+   TUid newUID = TUid::Uid(aMessage.Int0()); 
+   TUid curUID = iSingletons.ConnectionMgr().TransportUid();
+   
+   if(curUID !=(KNullUid))  // Another Transport is already running
+		{
+		if(curUID== newUID)
+			{
+    		aMessage.Complete(KErrAlreadyExists); 	
+    		return;				
+			}
+    	else if(!CheckIsAvailableL(newUID,curUID))
+    		{
+    		aMessage.Complete(KErrServerBusy); 	
+    		return;
+    		}	    
+    	}
+
+    aMessage.Complete(KErrNone);
+    __FLOG(_L8("DoStopTransport - Exit"));
+    }
+
+TBool CMTPServerSession::CheckIsBlueToothTransport(TUid aNewUid)
+	{
+	TInt32 bluetoothUid = 0x10286FCB;
+	return aNewUid.iUid == bluetoothUid;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/daemon/server/src/cmtpshutdown.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,84 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <e32std.h>
+
+#include "cmtpshutdown.h"
+#include "cmtpdataprovidercontroller.h"
+
+
+/**
+CMTPShutdown factory method. 
+@return A pointer to a new CMTPShutdown instance. Ownership IS transfered.
+@leave One of the system wide error codes if a processing failure occurs.
+*/
+CMTPShutdown* CMTPShutdown::NewL()
+    {
+    CMTPShutdown* self = new (ELeave) CMTPShutdown;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+    
+/**
+Destructor.
+*/
+CMTPShutdown::~CMTPShutdown()
+    {
+    Cancel();
+    iSingletons.Close();
+    }
+    
+/**
+Starts the shutdown timer.
+*/   
+void CMTPShutdown::Start()
+    {
+    // Shutdown delay, in microseconds.
+    const TUint KMTPShutdownDelay = (1000000 * 5);
+    After(KMTPShutdownDelay);
+    }
+    
+void CMTPShutdown::RunL()
+    {
+    if ( iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumerated )
+        {
+        Start();
+        }
+    else
+        {
+        CActiveScheduler::Stop();
+        }
+    }
+    
+/** 
+Constructor
+*/
+CMTPShutdown::CMTPShutdown() : 
+    CTimer(EPriorityNormal)
+    {
+    
+    }    
+
+/**
+Second phase constructor.
+*/    
+void CMTPShutdown::ConstructL()
+    {
+    CTimer::ConstructL();
+    iSingletons.OpenL();
+    CActiveScheduler::Add(this);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,47 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// MTP data provider API
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+../interface/cmtpdataproviderplugin.h       SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtpdataproviderplugin.h)
+../interface/cmtpmetadata.h                 SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtpmetadata.h)
+../interface/cmtpobjectmetadata.h           SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtpobjectmetadata.h)
+../interface/cmtpstoragemetadata.h          SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtpstoragemetadata.h)
+../interface/mmtpconnection.h               SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mmtpconnection.h)
+../interface/mmtpdataprovider.h             SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mmtpdataprovider.h)
+../interface/mmtpdataproviderconfig.h       SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mmtpdataproviderconfig.h)
+../interface/mmtpdataproviderframework.h    SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mmtpdataproviderframework.h)
+../interface/mmtpframeworkconfig.h          SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mmtpframeworkconfig.h)
+../interface/mmtpobjectmgr.h                SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mmtpobjectmgr.h)
+../interface/mmtpstoragemgr.h               SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mmtpstoragemgr.h)
+../interface/mmtpreferencemgr.h             SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mmtpreferencemgr.h)
+../interface/mmtpsession.h                  SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mmtpsession.h)
+../interface/mtpdataproviderapitypes.h      SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mtpdataproviderapitypes.h)
+../interface/mtpdataproviderconfig.hrh      /epoc32/include/mtp/mtpdataproviderconfig.hrh
+../interface/mtpdataproviderconfig.rh       SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mtpdataproviderconfig.rh)
+../interface/mtpobjectmgrquerytypes.h       SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mtpobjectmgrquerytypes.h)
+../interface/mtpstoragemgrquerytypes.h      SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mtpstoragemgrquerytypes.h)
+../interface/mmtpdatacodegenerator.h		SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mmtpdatacodegenerator.h)
+
+PRJ_MMPFILES 
+mtpdataproviderapi.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/group/mtpdataproviderapi.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,45 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mtpdataproviderapi.dll MTP data provider API.
+// 
+//
+
+/**
+ @file
+*/
+
+TARGET              mtpdataproviderapi.dll
+TARGETTYPE          DLL
+UID         	    0x1000008D 0x102827A3
+VENDORID 			0x70000001
+
+CAPABILITY          All -Tcb
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+SOURCEPATH          ../src 
+SOURCE              cmtpdataproviderplugin.cpp
+SOURCE              cmtpmetadata.cpp
+SOURCE              cmtpobjectmetadata.cpp
+SOURCE              cmtpstoragemetadata.cpp
+SOURCE              mmtpdataprovider.cpp
+SOURCE              mtpobjectmgrquerytypes.cpp
+SOURCE              mtpstoragemgrquerytypes.cpp
+
+LIBRARY             bafl.lib
+LIBRARY             ecom.lib 
+LIBRARY             edbms.lib 
+LIBRARY             euser.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/cmtpdataproviderplugin.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,69 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef CMTPDATAPROVIDERPLUGIN_H
+#define CMTPDATAPROVIDERPLUGIN_H
+
+#include <e32base.h>
+#include <mtp/mmtpdataprovider.h>
+#include <mtp/mtpdataproviderapitypes.h>
+
+class MMTPDataProviderFramework;
+
+/** 
+CMTPDataProviderPlugin interface UID.
+*/
+const TUid KMTPDataProviderPluginInterfaceUid = {0x102827AD};
+
+/** 
+Defines the MTP data provider ECOM plug-in service provider 
+interface.
+@publishedPartner
+@released
+*/
+class CMTPDataProviderPlugin : 
+    public CBase, 
+    public MMTPDataProvider
+    {
+    
+public:
+
+    IMPORT_C static CMTPDataProviderPlugin* NewL(TUid aImplementationUid, TAny* aParams);
+    IMPORT_C virtual ~CMTPDataProviderPlugin();
+
+protected: // From MMTPDataProvider
+
+    IMPORT_C MMTPDataProviderFramework& Framework() const;
+    
+protected:
+
+    IMPORT_C CMTPDataProviderPlugin(TAny* aParams);
+
+private: // Owned
+
+    TUid                        iDtorIdKey;
+    
+private: // Not owned
+    
+    MMTPDataProviderFramework*  iFramework;
+    };
+    
+#endif // CMTPDATAPROVIDERPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/cmtpmetadata.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,223 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef CMTPMETADATA_H
+#define CMTPMETADATA_H
+
+#include <badesca.h>
+#include <e32base.h>
+
+/** 
+Defines the MTP meta-data base class.
+@publishedPartner
+@released
+*/
+class CMTPMetaData : public CBase
+    {        
+public:
+    /* 
+     * Store the hash code for the folder
+     */
+    struct TPathHash
+    	{
+    	TUint32 iHash;
+    	TUint   iIndex;
+    	};
+
+public:
+    
+    IMPORT_C virtual ~CMTPMetaData();
+    
+    IMPORT_C const TDesC& DesC(TUint aId) const;
+    IMPORT_C const CDesCArray& DesCArray(TUint aId);
+    IMPORT_C TInt Int(TUint aId) const;
+    IMPORT_C const RArray<TInt>& IntArray(TUint aId) const;
+    IMPORT_C TUint Uint(TUint aId) const;
+    IMPORT_C const RArray<TUint>& UintArray(TUint aId) const;
+    
+    IMPORT_C void GetIntArrayL(TUint aId, RArray<TInt>& aValue);
+    IMPORT_C void GetUintArrayL(TUint aId, RArray<TUint>& aValue);
+    
+    IMPORT_C void SetDesCL(TUint aId, const TDesC& aValue);
+    IMPORT_C void SetDesCArrayL(TUint aId, const CDesCArrayFlat& aValue);
+    IMPORT_C void SetDesCArrayL(TUint aId, const CDesCArraySeg& aValue);
+    IMPORT_C void SetInt(TUint aId, TInt aValue);
+    IMPORT_C void SetIntArrayL(TUint aId, const RArray<TInt>& aValue);
+    IMPORT_C void SetUint(TUint aId, TUint aValue);
+    IMPORT_C void SetUintArrayL(TUint aId, const RArray<TUint>& aValue);
+    IMPORT_C void SetHashPath(const TDesC16& aExclusionPath, TUint aIndex);
+    IMPORT_C const RArray<TPathHash>& GetHashPathArray();
+    
+    IMPORT_C TAny* GetExtendedInterface(TUid aInterfaceUid);
+    IMPORT_C static TInt CompareTPathHash(const TPathHash&, const TPathHash&);
+    
+protected:
+
+    /**
+    The meta-data element data type identifiers.
+    */
+    enum TType
+        {
+        /**
+        Unknown (null).
+        */
+        EUndefined  = 0,
+        
+        /**
+        @see TDesC.
+        */
+        EDesC       = 1,
+        
+        /**
+        @see CDesCArray.
+        */
+        EDesCArray  = 2,
+        
+        /**
+        @see TInt.
+        */
+        EInt        = 3,
+        
+        /**
+        @see Rarray<TInt>.
+        */
+        EIntArray   = 4,
+        
+        /**
+        @see TUint.
+        */
+        EUint       = 5,
+        
+        /**
+        @see Rarray<TUint>.
+        */
+        EUintArray  = 6,
+        };
+
+    /**
+    Describes the meta-data element.
+    */
+    struct TElementMetaData
+        {
+        /**
+        The element buffer offset.
+        */
+        TUint   iOffset;
+        
+        /**
+        The element data type identifier.
+        */
+        TType   iType;
+        };
+    
+protected:
+
+    CMTPMetaData(const TElementMetaData* aElements, TUint aCount);  
+    void ConstructL();
+    void ConstructL(const CMTPMetaData& aFrom);
+
+private:
+    
+    CMTPMetaData();
+    
+    void CopyL(const CDesCArray& aFrom, CDesCArray& aTo);
+    void CopyL(const RArray<TInt>& aFrom, RArray<TInt>& aTo);
+    void CopyL(const RArray<TUint>& aFrom, RArray<TUint>& aTo);
+    
+    void DeleteIntArray(TUint aIdx);
+    void DeleteUintArray(TUint aIdx);
+
+private:  // Owned
+
+    /**
+    The default array granularity
+    */
+    static const TUint              KGranularity = 8;
+    
+    /**
+    The element meta-data.
+    */
+    const RArray<TElementMetaData>  iElements;
+    
+    /**
+    The DesC element data.
+    */
+    RPointerArray<HBufC>            iElementsDesC;
+    
+    /**
+    The DesCArray element data.
+    */
+    RPointerArray<CDesCArray>       iElementsDesCArray;
+
+    /**
+    The Int element data.
+    */
+    RArray<TInt>                    iElementsInt;
+    
+    /**
+    The IntArray element data.
+    */
+    RPointerArray<TAny>             iElementsIntArray;
+
+    /**
+    The Uint element data.
+    */
+    RArray<TUint>                   iElementsUint;
+    
+    /**
+    The UintArray element data.
+    */
+    RPointerArray<TAny>             iElementsUintArray;
+    
+    /**
+    The extended data object pointer.
+    */
+    TAny*                           iExtensionData;
+    
+    /**
+    The extended interface object pointer.
+    */
+    TAny*                           iExtensionInterfaces;
+
+    /**
+    The TDesCArrayType type element data.
+    */
+    RArray<TInt>  iElementsDesCArrayType;
+    RArray<TPathHash>               iPathHash;
+
+	/**
+    The CDesCArray element data type identifiers.
+    */
+    enum TDesCArrayType 
+    	{
+    	/**
+        @see CDesCArrayFlat.
+        */
+    	 EDesCArrayFlat = 0,
+    		
+    	/**
+        @see CDesCArraySeg.
+        */
+    	 EDesCArraySeg = 1,
+    	};
+    };
+    
+#endif // CMTPMETADATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/cmtpobjectmetadata.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,174 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef CMTPOBJECTMETADATA_H
+#define CMTPOBJECTMETADATA_H
+
+#include <mtp/cmtpmetadata.h>
+
+/** 
+Defines the MTP object meta-data.
+@publishedPartner
+@released
+*/
+class CMTPObjectMetaData : public CMTPMetaData
+{
+public:
+
+    /**
+    MTP object meta-data element identifiers.
+    */      
+    enum TElementId
+        {        
+        /**
+        The ID of the data provider responsible for the data object. This 
+        element is of type @see TUint.
+        */
+        EDataProviderId     = 0,
+        
+        /**
+        The object format code. This element is of type @see TUint.
+        */
+        EFormatCode         = 1,
+        
+        /**
+        The object format sub-code. Currently this field is ignored unless the 
+        @see EFormatCode contains a value of @see EMTPFormatCodeAssociation, in 
+        which case this field should the specify the MTP association type code.
+        This element is of type @see TUint.
+        */
+        EFormatSubCode      = 2,
+        
+        /**
+        The object handle. This element is of type @see TUint.
+        */
+        EHandle             = 3,
+        
+        /**
+        The set of MTP operational modes in which the object is visible and 
+        will be enumerated to a connected MTP Initiator. The MTP operational
+        modes are represented as a set of @see TMTPOperationalMode bit flags.
+        This element is of type @see TUint 
+        */
+        EModes              = 4,
+        
+        /**
+        The parent object handle. This element is of type @see TUint.
+        */
+        EParentHandle       = 5,
+        
+        /**
+        The MTP storage ID of the storage on which the data object resides. 
+        This element is of type @see TUint.
+        */
+        EStorageId          = 6,
+        
+        /**
+        The MTP storage ID of the storage on which the data object resides. 
+        This element is of type @see TUint.
+        */
+        EStorageVolumeId    = 7,
+        
+        /**
+        The data object's System Unique IDentifier (SUID). This element is of 
+        type @see TDesC&.
+        */
+        ESuid               = 8,
+
+		/**
+		The data object's user rating
+		This element is of type @see TUint.
+		@deprecated
+		*/
+		EUserRating = 9,
+
+		/** 
+		The data object's BuyNow flag
+		This element is of type @see TUint.
+		@deprecated
+		*/
+		EBuyNow = 10,
+
+		/** The data object's Played flag
+		This element is of type @see TUint.
+		@deprecated
+		*/
+		EPlayCount = 11,
+		
+		/**
+		The data Objects Identifier as in HandleStore table
+		This element is of type @see TUint.
+		*/
+		EIdentifier = 12,
+		
+		/**
+		The id related to ParentHandle
+		This element is of type @see TUint.
+		*/
+		//EParentId = 13,
+		
+		/**
+		The flag, used in object modification, indicates if the modified object
+		should be reported to initiator
+		This element is of type @see TUint.
+		*/
+		ENonConsumable = 13,
+		
+		EObjectMetaDataUpdate = 14,	
+
+		EName = 15,
+        /**
+        The number of elements.        
+        */
+        ENumElements,
+        };
+
+public:
+    
+    IMPORT_C static CMTPObjectMetaData* NewL();
+    IMPORT_C static CMTPObjectMetaData* NewLC();
+    IMPORT_C static CMTPObjectMetaData* NewL(TUint aDataProviderId, TUint aFormatCode, TUint aStorageId, const TDesC& aSuid);
+    IMPORT_C static CMTPObjectMetaData* NewLC(TUint aDataProviderId, TUint aFormatCode, TUint aStorageId, const TDesC& aSuid);
+    IMPORT_C ~CMTPObjectMetaData();
+    
+private:
+    
+    CMTPObjectMetaData();
+    void ConstructL();
+    void ConstructL(TUint aDataProviderId, TUint aFormatCode, TUint aStorageId, const TDesC& aSuid);
+    /* @deprecated */
+    void ConstructL( const TDesC& aSuid, TUint aUserRating, TUint aBuyNow, TUint aPlayCount);
+
+public:
+	/* @deprecated */
+    IMPORT_C static CMTPObjectMetaData* NewL(const TDesC& aSuid, TUint aUserRating, TUint aBuyNow, TUint aPlayCount );
+    /* @deprecated */
+    IMPORT_C static CMTPObjectMetaData* NewLC(const TDesC& aSuid, TUint aUserRating, TUint aBuyNow, TUint aPlayCount );
+    
+private:  // Owned
+    
+    /**
+    The element meta-data.
+    */
+    static const TElementMetaData   KElements[];
+};
+
+#endif // CMTPOBJECTMETADATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/cmtpstoragemetadata.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,205 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef CMTPSTORAGEMETADATA_H
+#define CMTPSTORAGEMETADATA_H
+
+#include <mtp/cmtpmetadata.h>
+
+/** 
+Defines the MTP storage meta-data.
+@publishedPartner
+@released
+*/
+class CMTPStorageMetaData : public CMTPMetaData
+    {
+public:
+
+    /**
+    Defines the MTP storage meta-data element identifiers.
+    */      
+    enum TElementId
+        {         
+        /**
+        The storage attribute flags (@see TStorageAttribute). This element is of type 
+        @see TUint.
+        */
+        EAttributes         = 0,
+             
+        /**
+        The list of areas on the storage which contain data objects which must
+        not be exposed by the MTP protocol and which must be excluded during
+        data provider object enumeration. If @see EStorageSystemType is 
+        specified as @see ESystemTypeGenericHierachal then entries in this list
+        are interpreted and validated as Symbian OS folder pathnames (e.g. 
+        "C:\Private", or "Z:\System"). This element is of type @see CDesCArray.
+        */
+        EExcludedAreas      = 1,
+             
+        /**
+        The MTP StorageID. This element is of type @see TUint.
+        */
+        EStorageId          = 2,
+             
+        /**
+        The MTP set of logical MTP StorageIDs associated with this storage. 
+        This set will always be empty if @see EStorageID is a logical MTP 
+        StorageID. This element is of type @see RArray<TUint>.
+        */
+        EStorageLogicalIds  = 3,
+        
+        /**
+        The storage System Unique IDentifier (SUID). If @see EStorageSystemType 
+        is specified as @see ESystemTypeGenericHierachal then this value is 
+        interpreted and validated as a Symbian OS folder pathname (e.g. 
+        C:\Media", or "E:\") representing the root point of the MTP storage. 
+        This element is of type @see TDesC.
+        */
+        EStorageSuid        = 4,
+          
+        /**
+        The storage system (@see TStorageSystemType). This element is of type 
+        @see TUint.
+        */
+        EStorageSystemType  = 5,
+        
+        /**
+        The number of elements.        
+        */
+        ENumElements,
+        };
+
+    /**
+    Defines the MTP storage attribute bit flags. These are encoded as 
+    @see TUint. Flags in the least significant 16-bit range are reserved,
+    those in the most significant 16-bit range are available for use as 
+    extension values by storage owners.
+    */
+    enum TStorageAttribute
+        {        
+        /**
+        The null attribute.
+        */
+        EAttrNone           = 0x00000000,
+        
+        /**
+        The extension attribute flags mask.
+        */
+        EAttrMaskExtensions = 0xFFFF0000,
+        
+        /**
+        The reserved attribute flags mask.
+        */
+        EAttrMaskReserved   = 0x0000FFFF,
+        };
+        
+    /**
+    Defines the storage system type identifier code space. This 16-bit code 
+    space is partitioned and encoded identically to the MTP "Filesystem Type", 
+    as described in the "Media Transfer Protocol Enhanced" specification. 
+    */
+    enum TStorageSystemType
+        {      
+        /**
+        The undefined storage system type identifier code.
+        */
+        ESystemTypeUndefined            = 0x00000000,
+        
+        /**
+        The generic flat storage system type identifier code.
+        */
+        ESystemTypeGenericFlat          = 0x00000001,
+        
+        /**
+        The generic hierachal storage system type identifier code.
+        */
+        
+        ESystemTypeGenericHierachal     = 0x00000002,
+        
+        /**
+        The DRM Content Format (DCF) storage system type identifier code.
+        */
+        ESystemTypeDCF                  = 0x00000003,
+        
+        /**
+        The start of the reserved storage system type identifier code space.
+        */
+        ESystemTypeMaskReservedStart    = 0x00000004,
+        
+        /**
+        The end of the reserved storage system type identifier code space.
+        */
+        ESystemTypeMaskReservedEnd      = 0x00007FFF,
+        
+        /**
+        The MTP vendor extension storage system type identifier code flags.
+        */
+        ESystemTypeMTPVendorExtension   = 0x00008000,
+        
+        /**
+        The MTP defined storage system type identifier code flags.
+        */
+        ESystemTypeMTPDefined           = 0x0000C000,
+        
+        /**
+        The 16-bit storage system type identifier code mask.
+        */
+        ESystemTypeMask                 = 0x0000FFFF,
+        
+        /**
+        The default hierachal file system (@see RFs) based storage type 
+        identifier. If this storage type is specified then:
+        
+            1.  The storage is assumed to reside on the file system.
+            2.  The @see EStorageSuid is interpreted and validated as a Symbian 
+                OS folder pathname (e.g. C:\Media", or "E:\") representing the 
+                root point of the MTP storage.
+            3.  Entries in the @see EExcludedAreas are interpreted and 
+                validated as Symbian OS folder pathnames (e.g. "C:\Private", or
+                "Z:\System").
+        */
+        ESystemTypeDefaultFileSystem    = ESystemTypeGenericHierachal,
+        };
+        
+public:
+    
+    IMPORT_C static CMTPStorageMetaData* NewL();
+    IMPORT_C static CMTPStorageMetaData* NewLC();
+    IMPORT_C static CMTPStorageMetaData* NewL(TUint aStorageSystemType, const TDesC& aStorageSuid);
+    IMPORT_C static CMTPStorageMetaData* NewLC(TUint aStorageSystemType, const TDesC& aStorageSuid);
+    IMPORT_C static CMTPStorageMetaData* NewL(const CMTPStorageMetaData& aStorage);
+    IMPORT_C static CMTPStorageMetaData* NewLC(const CMTPStorageMetaData& aStorage);
+    IMPORT_C ~CMTPStorageMetaData();
+    
+private:
+    
+    CMTPStorageMetaData();
+    void ConstructL(TUint aStorageSystemType, const TDesC& aStorageSuid);
+
+private:  // Owned
+    
+    /**
+    The element meta-data.
+    */
+    static const TElementMetaData   KElements[];
+    };
+    
+#endif // CMTPSTORAGEMETADATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpconnection.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,100 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef MMTPCONNECTION_H
+#define MMTPCONNECTION_H
+
+#include <e32cmn.h>
+#include <e32def.h>
+#include <mtp/mtpdataproviderapitypes.h>
+
+class MMTPSession;
+
+/** 
+Defines the MTP data provider framework MTP connection interface.
+
+@publishedPartner
+@released
+*/
+class MMTPConnection
+    {
+public:
+
+    /**
+    Provides the unique MTP data provider framework assigned identifier of the
+    connection.
+    @return The MTP data provider framework assigned connection identifier.
+    */
+    virtual TUint ConnectionId() const = 0;
+
+    /**
+    Provides a count of the number of sessions currently active on the 
+    connection.
+    @return The number of sessions currently active on the connection.
+    */
+    virtual TUint SessionCount() const = 0;
+
+    /**
+    Indicates if a session with the specified MTP connection assigned
+    identifier is currently active on the connection.
+    @param aMTPId The MTP connection assigned identifier of the session.
+    @return ETrue, if a session with the specified session identifier is 
+    currently active on the connection, otherwise EFalse.
+    */
+    virtual TBool SessionWithMTPIdExists(TUint32 aMTPId) const = 0;
+    
+    /**
+    Provides a reference to the session with the specified MTP connection 
+    assigned identifier. 
+    @param aMTPId The MTP connection assigned identifier of the 
+    requested session.
+    @return The reference of the session with the specified MTP connection 
+    assigned identifier.
+    @leave KErrNotFound, if the specified session identifier is not currently
+    active on the connection.
+    @see SessionWithMTPIdExists
+    */
+    virtual MMTPSession& SessionWithMTPIdL(TUint32 aMTPId) const = 0;
+
+    /**
+    Indicates if a session with the specified MTP connection assigned
+    identifier is currently active on the connection.
+    @param aUniqueId The MTP connection assigned identifier of the session.
+    @return ETrue, if a session with the specified session identifier is 
+    currently active on the connection, otherwise EFalse.
+    */
+    virtual TBool SessionWithUniqueIdExists(TUint32 aUniqueId) const = 0;
+    
+    /**
+    Provides a reference to the session with the specified MTP connection 
+    assigned identifier. 
+    @param aUniqueId The MTP connection assigned identifier of the 
+    requested session.
+    @return The reference of the session with the specified MTP connection 
+    assigned identifier.
+    @leave KErrNotFound, if the specified session identifier is not currently
+    active on the connection.
+    @see SessionWithMTPIdExists
+    */
+    virtual MMTPSession& SessionWithUniqueIdL(TUint32 aUniqueId) const = 0;
+    };
+    
+#endif // MMTPCONNECTION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpdatacodegenerator.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,78 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#ifndef MMTPDATACODEGENERATOR_H_
+#define MMTPDATACODEGENERATOR_H_
+
+#include <e32def.h>
+#include <mtp/tmtptypeguid.h>
+
+class TMTPTypeGuid;
+
+/** 
+Defines the MTP data provider framework datacode generator 
+interface.
+*/
+class MMTPDataCodeGenerator
+    {
+public:
+
+    /**
+    Generate one ServiceID .
+    @param aPGUID The GUID of Service.
+    @param aServiceType service type (normal or abstract).
+    @param aServiceID the service id that is allocated.
+    @return System wide error code. KErrNone, if successful.
+    */
+   virtual TInt AllocateServiceID( const TMTPTypeGuid& aPGUID, const TUint aServiceType, TUint& aServiceID ) = 0;
+   
+   /**
+    Generate one service property code .
+    @param aServicePGUID The service GUID .
+    @param aPKNamespace The GUID of PKey Namespace
+    @param aPKID The PKey ID of service property
+    @param aServicePropertyCode The service property code that is allocated.
+    @return System wide error code. KErrNone if successful.
+    */
+   virtual TInt AllocateServicePropertyCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, TUint16& aServicePropertyCode ) = 0;
+   
+   /**
+    Generate one service format code.
+    @param aServicePGUID The service GUID .
+    @param aGUID The GUID of service format
+    @param aServiceFormatCode The service format code that is allocated.
+    @return System wide error code. KErrNone if successful.
+    */
+   virtual TInt AllocateServiceFormatCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, TUint16& aServiceFormatCode ) = 0;
+   
+   /**
+    Generate one service method code .
+    @param aServicePGUID The service GUID .
+    @param aGUID The GUID of method
+    @param aMethodFormatCode The method format code that is allocated.
+    @return System wide error code. KErrNone if successful.
+    */
+   virtual TInt AllocateServiceMethodFormatCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, TUint16& aMethodFormatCode ) = 0;
+   
+   };
+
+
+
+#endif /* MMTPDATACODEGENERATOR_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpdataprovider.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,189 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef MMTPDATAPROVIDER_H
+#define MMTPDATAPROVIDER_H
+
+#include <badesca.h>
+#include <e32base.h>
+#include <mtp/mtpdataproviderapitypes.h>
+
+class MMTPConnection;
+class MMTPDataProviderFramework;
+class TMTPTypeEvent;
+class TMTPTypeRequest;
+
+/** 
+Defines the MTP data provider Service Provider Interface (SPI).
+@publishedPartner
+@released
+*/
+class MMTPDataProvider
+    {
+public:
+
+    /**
+    Cancels the most recent outstanding request made to the MTP data provider 
+    service provider interface. If there is no such request outstanding, then 
+    no action is taken.
+    */
+    virtual void Cancel() = 0;
+    
+    /**
+    Notifies the data provider that an asynchronous event dataset has been 
+    received on the specified MTP connection.
+    @param aEvent The MTP event dataset.
+    @param aConnection The MTP connection on which the event was received.
+    @leave One of the system wide error code, if a processing failure occurs
+    in the data provider.
+    */
+    virtual void ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) = 0;
+
+    /**
+    Notifies the data provider of a significant event which has been detected. 
+    Additional details regarding the event may optionally be provided in the 
+    accompanying notification parameter block.
+    @param aNotification The notification type identifier.
+    @param aParams The notification type specific parameter block
+    @leave One of the system wide error code if a processing failure occurs
+    in the data provider.
+    */
+    virtual void ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams) = 0;
+    
+    /**
+    Initiates an MTP transaction phase processing sequence in the data 
+    provider. The data provider must respond by issuing a signal to the MTP 
+    data provider framework layer interface that is appropriate for the request
+    type and current phase (as specified by aPhase) of the MTP transaction 
+    being processed, as follows:
+    
+    MTP Transaction Phase	Valid MMTPDataProviderFramework Signal
+    ---------------------   --------------------------------------
+	ERequestPhase			ReceiveDataL, SendDataL, SendResponseL
+	EResponsePhase			SendResponseL
+	ECompletingPhase		TransactionCompleteL
+     
+    @param aPhase The MTP transaction phase to be processed.
+    @param aRequest The MTP request dataset of the active MTP transaction.
+    @param aConnection The MTP connection on which the transaction is being 
+    processed.
+    @see MMTPDataProviderFramework::ReceiveDataL
+    @see MMTPDataProviderFramework::SendDataL
+    @see MMTPDataProviderFramework::SendResponseL
+    @see MMTPDataProviderFramework::TransactionCompleteL
+    @leave One of the system wide error code if a processing failure occurs
+    in the data provider.
+    */
+    virtual void ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) = 0;
+    
+    /**
+    @Deprecated.
+    Initiates an object store enumeration sequence to enumerate all MTP data 
+    objects which reside on the specified storage and for which the data 
+    provider is responsible. The data provider is expected to invoke the 
+    appropriate @see MMTPObjectMgr methods to enumerate all MTP data objects 
+    for which it is responsible and which it wishes to have presented to a 
+    connected MTP initiator. The data provider must complete the sequence by 
+    signalling @see ObjectEnumerationCompleteL to the data provider framework 
+    layer interface.
+    @param aStorageId The MTP StorageID of the storage to be enumerated. A 
+    value of KMTPStorageAll indicates that all storages should be enumerated.
+    @leave One of the system wide error code if a processing failure occurs
+    in the data provider.
+    @see MMTPDataProviderFramework::ObjectEnumerationCompleteL
+    */	
+    IMPORT_C virtual void StartObjectEnumerationL(TUint32 aStorageId);
+    
+    /**
+    Initiates a storage enumeration sequence. The data provider is expected to 
+    invoke the appropriate @see MMTPStorageMgr methods to enumerate all MTP 
+    storages for which it is responsible and which it wishes to have presented 
+    to a connected MTP initiator. The data provider must complete the sequence 
+    by signalling @see StorageEnumerationCompleteL to the data provider 
+    framework layer interface.
+    @leave One of the system wide error code if a processing failure occurs
+    in the data provider.
+    @see MMTPDataProviderFramework::StorageEnumerationCompleteL
+    */	
+    virtual void StartStorageEnumerationL() = 0;
+    
+    /**
+    Provides the set of MTP datacodes of the specified category that are 
+    supported by the data provider.
+    @param aCategory The requested MTP datacode category.
+    @param aArray On successful completion, the set of MTP datacodes that are 
+    supported by the data provider.
+    */  
+    virtual void Supported(TMTPSupportCategory aCategory, RArray<TUint>& aCodes) const = 0;
+    
+    /**
+    Provides the MTP string values of the specified category that is supported 
+    by the data provider. 
+    @param aCategory The requested MTP datacode category.
+    @param aStrings On successful completion, the set of string data that are 
+    supported by the data provider.
+    @leave One of the system wide error code if a processing failure occurs
+    in the data provider.
+    */  
+    IMPORT_C virtual void SupportedL(TMTPSupportCategory aCategory, CDesCArray& aStrings) const;
+    
+    /**
+    Provides an MTP data provider extension interface implementation 
+    for the specified interface Uid. 
+    @param aInterfaceUid The unique identifier for the extension interface being 
+    requested.
+    @return Pointer to an interface instance or 0 if the interface is not 
+    supported. Ownership is NOT transfered.
+    */
+    IMPORT_C virtual TAny* GetExtendedInterface(TUid aInterfaceUid);
+    
+protected:
+
+    /**
+    Provides a handle to the MTP data provider framework layer interface.
+    @return Handle of the MTP data provider framework layer interface. 
+    Ownership is NOT transfered.
+    */
+    virtual MMTPDataProviderFramework& Framework() const = 0;
+    
+public:
+    /**
+    Initiates an object store enumeration sequence to enumerate all MTP data 
+    objects which reside on the specified storage and for which the data 
+    provider is responsible. The data provider is expected to invoke the 
+    appropriate @see MMTPObjectMgr methods to enumerate all MTP data objects 
+    for which it is responsible and which it wishes to have presented to a 
+    connected MTP initiator. The data provider must complete the sequence by 
+    signalling @see ObjectEnumerationCompleteL to the data provider framework 
+    layer interface.
+    @param aStorageId The MTP StorageID of the storage to be enumerated. A 
+    value of KMTPStorageAll indicates that all storages should be enumerated.
+    @param aPersistentFullEnumeration It is used by only persistent data providers,
+    it indicates whether the persistent data providers should do the object full-enumreation or not. 
+    @leave One of the system wide error code if a processing failure occurs
+    in the data provider.
+    @see MMTPDataProviderFramework::ObjectEnumerationCompleteL
+    */	
+	IMPORT_C virtual void StartObjectEnumerationL(TUint32 aStorageId, TBool aPersistentFullEnumeration);
+    
+    };
+
+#endif // MMTPDATAPROVIDER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpdataproviderconfig.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,168 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef MMTPDATAPROVIDERCONFIG_H
+#define MMTPDATAPROVIDERCONFIG_H
+
+#include <e32std.h>
+
+/**
+Defines the data provider configurability parameter interface.
+@publishedPartner
+@released
+*/
+class MMTPDataProviderConfig
+	{
+public:
+
+    /**
+    Defines the data provider configurability parameters.
+    */
+    enum TParameter
+        {
+	    /**
+	    This parameter specifies the type of the data provider which in turn 
+	    determines how it will be loaded. The set of valid parameter values is 
+	    defined by the @see TMTPDataProviderType enumeration.
+	    
+	    This parameter value can be accessed using the @see UintValue API.
+	    */
+        EDataProviderType,
+
+	    /**
+	    This parameter specifies the highest major MTP protocol revision 
+	    supported by the data provider. MTP protocol revision identifiers take 
+	    the form N.N, of which the major protocol revision comprises the most 
+	    significant digit(s) to the left of the period (.), e.g. a major 
+	    protocol version value of 1 would represent all MTP protocol revisions 
+	    from 1.0 up to (but not including) 2.0. 
+	    
+	    This parameter value can be accessed using the @see UintValue API.
+	    */
+        EMajorProtocolRevision,						
+        
+	    /**
+	    This parameter indicates whether the object enumerations which the data 
+	    provider registers with the MTP object manager should persist when the 
+	    data provider is unloaded from the MTP framework. If the persistent 
+	    option is selected, then on each subsequent activation after its 
+	    initial object store enumeration is complete the data provider will be 
+	    required to re-enumerate only that portion of its object store which 
+	    has changed (objects added, removed, or modified) since it was last 
+	    loaded. If the persistent option is not selected, then the data 
+	    provider will be required to re-enumerate its entire object store each 
+	    time it is loaded. 
+	    
+	    This parameter value can be accessed using the @see BoolValue API
+	    */
+        EObjectEnumerationPersistent,
+        	
+	    /**
+	    This parameter specifies the modes of operation which the data provider
+	    supports. It is specified as an integer which encodes a set of bit 
+	    flags. The set of valid bit flag values is defined by the @see TMTPMode
+	    enumeration. 
+	    
+	    The set of parameter values can be accessed using the 
+	    @see GetArrayValue API.
+	    */
+        ESupportedModes,				
+
+	    /**
+	    This parameter is reserved for future use.
+	    */
+        EServerName,			
+        
+	    /**
+	    This parameter is reserved for future use.
+	    */
+        EServerImageName,			
+        
+        /**
+        This parameter specifies an optional configuration data resource whose
+        form and function is specific to the data provider. 
+        
+        The parameter value is specified as an LLINK resource and can be 
+        accessed using the @see DesC8Value API.
+        */
+        EOpaqueResource,
+        
+        /**
+        This parameter specifies the resource filename in which the set of data 
+        provider configurability parameter values are specified.
+	    
+	    The set of parameter values can be accessed using the 
+	    @see DesCValue API.
+        */
+        EResourceFileName,
+
+	    /**
+	    This parameter specifies the enumeration phase of the data provider	    
+	    
+	    This parameter value can be accessed using the @see UintValue API.
+	    */	    
+        EEnumerationPhase
+        };
+
+public:
+
+    /**
+    Provides the specified @see TBool parameter value.
+    @param aParam The parameter value to retrieve.
+    @return Returns The parameter value
+    @panic USER 0, if the parameter data type is not @see TBool.
+    */
+    virtual TBool BoolValue(TParameter aParam) const = 0;
+
+    /**
+    Provides the specified @see TDesC parameter value.
+    @param aParam The parameter value to retrieve.
+    @return Returns The parameter value
+    @panic USER 0, if the parameter data type is not @see TDesC.
+    */
+	virtual const TDesC& DesCValue(TParameter aParam) const = 0;
+
+    /**
+    Provides the specified @see TDesC8 parameter value.
+    @param aParam The parameter value to retrieve.
+    @return Returns The parameter value
+    @panic USER 0, if the parameter data type is not @see TDesC8.
+    */
+	virtual const TDesC8& DesC8Value(TParameter aParam) const = 0;
+
+    /**
+    Provides the specified @see TUint parameter value.
+    @param aParam The parameter value to retrieve.
+    @return Returns The parameter value
+    @panic USER 0, if the parameter data type is not @see TUint.
+    */
+	virtual TUint UintValue(TParameter aParam) const = 0;
+	
+    /**
+    Retrieves the specified @see RArray<TUint> parameter value.
+    @param aParam The parameter value to retrieve.
+    @return Returns The parameter value
+    @panic USER 0, if the parameter data type is not @see RArray<TUint>.
+    */
+    virtual void GetArrayValue(TParameter aParam, RArray<TUint>& aArray) const = 0;
+	};
+
+#endif // MMTPDATAPROVIDERCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpdataproviderframework.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,302 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef MMTPDATAPROVIDERFRAMEWORK_H
+#define MMTPDATAPROVIDERFRAMEWORK_H
+
+#include <e32cmn.h>
+#include <e32def.h>
+#include <mtp/mtpdataproviderconfig.hrh>
+#include <mtp/mtpdataproviderapitypes.h>
+
+class MMTPConnection;
+class MMTPDataProviderConfig;
+class MMTPFrameworkConfig;
+class MMTPObjectMgr;
+class MMTPReferenceMgr;
+class MMTPStorageMgr;
+class MMTPType;
+class TMTPTypeEvent;
+class TMTPTypeResponse;
+class TMTPTypeRequest;
+class RFs;
+class MMTPDataCodeGenerator;
+
+/**
+Defines the MTP data provider framework layer application programming
+interface.
+@publishedPartner
+@released
+*/
+class MMTPDataProviderFramework
+    {
+public:
+
+    /**
+    Provides the unique identifier of the calling data provider.
+    @return The data provider identifier.
+    */
+    virtual TUint DataProviderId() const = 0;
+
+    /**
+    Provides the current MTP operational mode.
+    @return The current MTP operational mode.
+    */
+    virtual TMTPOperationalMode Mode() const = 0;
+
+    /**
+    Initiates a data object receive sequence in the MTP data provider framework
+    layer. This method should only be invoked when processing the ERequestPhase
+    of an MTP transaction (@see CMTPDataProviderPlugin::ProcessRequestPhaseL),
+    and causes the MTP session transaction state to transition to the
+    @see EDataIToRPhase. The data object receive sequence is completed when the 
+    MTP data provider framework layer initiates the @see EResponsePhase of the 
+    MTP transaction (@see CMTPDataProviderPlugin::ProcessRequestPhaseL).
+    @param aData The MTP data object sink buffer.
+    @param aRequest The MTP request dataset of the active MTP transaction.
+    @param aConnection The handle of the MTP connection on which the transaction
+    is being processed.
+    @see CMTPDataProviderPlugin::ProcessRequestPhaseL
+    @leave KErrNotReady, if invoked when the current MTP transaction phase is
+    not ERequestPhase.
+    */
+    virtual void ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) = 0;
+
+    /**
+    Initiates a data object send sequence in the MTP data provider framework
+    layer. This method should only be invoked when processing the ERequestPhase
+    of an MTP transaction (@see CMTPDataProviderPlugin::ProcessRequestPhaseL),
+    and causes the MTP session transaction state to transition to the
+    @see EDataRToIPhase. The data object send sequence is completed when the 
+    MTP data provider framework layer initiates the @see EResponsePhase of the 
+    MTP transaction (@see CMTPDataProviderPlugin::ProcessRequestPhaseL).
+    @param aData The MTP data object source buffer.
+    @param aRequest The MTP request dataset of the active MTP transaction.
+    @param aConnection The handle of the MTP connection on which the transaction
+    is being processed.
+    @see CMTPDataProviderPlugin::ProcessRequestPhaseL
+    @leave KErrNotReady, if invoked when the current MTP transaction phase is
+    not ERequestPhase.
+    */
+    virtual void SendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) = 0;
+
+    /**
+    Signals the MTP data provider framework layer to send an asynchronous event
+    dataset on the specified MTP connection.
+    @param aEvent The MTP event dataset source buffer.
+    @param aConnection The handle of the MTP connection on which the event is
+    to be sent.
+    @leave KErrArgument, if the event data is not valid.
+    */
+    virtual void SendEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) = 0;
+
+    /**
+    Signals the MTP data provider framework layer to send an asynchronous event
+    dataset on all active MTP connections.
+    @param aEvent The MTP event dataset source, this should always target all
+    open sessions, i.e. SessionID should be set to KMTPAllSessions.
+    @leave KErrArgument, if the event data is invalid.
+    */
+    virtual void SendEventL(const TMTPTypeEvent& aEvent) = 0;
+
+    /**
+    Initiates an MTP response dataset send sequence in the MTP data provider
+    framework layer. This method should only be invoked when processing either
+    the @see ERequestPhase or @see EResponsePhase of an MTP transaction, (@see
+    CMTPDataProviderPlugin::ProcessRequestPhaseL) and causes the MTP session
+    transaction state to transition to the @see ECompletingPhase. The MTP 
+    response dataset send sequence is completed when the MTP data provider 
+    framework layer initiates the @see ECompletingPhase of the MTP transaction 
+    (@see CMTPDataProviderPlugin::ProcessRequestPhaseL).
+    @param aResponse The MTP aResponse dataset source buffer.
+    @param aConnection The handle of the MTP connection on which the transaction
+    is being processed.
+    @see CMTPDataProviderPlugin::ProcessRequestPhaseL
+    @leave KErrNotReady, if invoked when the current MTP transaction phase is
+    not ERequestPhase or EResponsePhase.
+    */
+    virtual void SendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) = 0;
+
+    /**
+    Signals to the MTP data provider framework layer that all processing
+    related to the current transaction has been completed. This method should
+    only be invoked when processing the @see ECompletingPhase of the MTP 
+    transaction (@see CMTPDataProviderPlugin::ProcessRequestPhaseL), and causes 
+    the MTP session transaction state to transition to the @see EIdle state.
+    @param aRequest The MTP request dataset that initiated the transaction.
+    @param aRequest The MTP request dataset of the active MTP transaction.
+    @param aConnection The handle of the MTP connection on which the transaction
+    is being processed.
+    @see CMTPDataProviderPlugin::ProcessRequestPhaseL
+    @leave KErrNotReady If invoked when the current MTP transaction phase is
+    invalid.
+    */
+    virtual void TransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) = 0;
+
+    /**
+    Registers the calling data provider to receive one or more occurrences of 
+    the specified request dataset that are received on the specified 
+    connection. This method should be used to register the calling data 
+    provider to receive the following request types:
+    
+        1.  Follow-on requests of an MTP operation that can span multiple 
+            transaction cycles. The following request types are recognised
+            by the framework as follow-on requests:
+            
+            i)  SendObject (preceded by SendObjectInfo or SendObjectPropList). 
+            ii) TerminateOpenCapture (preceded by InitiateOpenCapture).
+            
+        2.  MTP vendor extension requests.
+        
+    Note that:
+
+        1.  The request dataset being registered must minimally specify the
+            Operation Code of the expected operation and the SessionID on which 
+            the operation request is expected to be received. 
+            
+            Follow-on request registrations MUST specify a specific SessionID. 
+            Registrations of non follow-on requests may optionally specify a 
+            SessionID of @see KMTPSessionAll to receive matching requests from
+            any active MTP session.
+           
+        2.  With the exception of the TransactionID element, registered request
+            datasets must exactly match all data elements of the expected request 
+            dataset in order to be successfully routed.
+           
+        3.  Duplicate RouteRequestRegisterL registrations are not permitted. A request 
+            dataset that matches that of a previous registration by this or 
+            any other data provider on the same MTP session will result in the 
+            previous registration being superceded.
+           
+        4.  Pending RouteRequestRegisterL registrations can be withdrawn at any time
+            using the @see RouteRequestUnregisterL method. 
+           
+        5.  RouteRequestRegisterL registrations of MTP request types which ARE 
+            recognised by the framework as MTP follow-on requests (SendObject, 
+            TerminateOpenCapture) will result in at most one matching request 
+            occurence being routed to the data provider. To receive another 
+            request dataset of the same type, a new @see RouteRequestRegisterL 
+            registration must be made.
+            
+        6   RouteRequestRegisterL registrations of MTP request types which ARE
+            NOT recognised by the framework as MTP follow-on requests will 
+            result in all matching requests which are subsequently received 
+            being routed to the data provider. This will continue until such 
+            time as the RouteRequestRegisterL registration is withdrawn using 
+            the @see RouteRequestUnregisterL method.
+            
+        7.  RouteRequestRegisterL registrations request datasets which specify 
+            an SessionID value of @see KMTPSessionAll, will result in matching 
+            requests which are subsequently received on any active MTP session
+            being routed to the data provider.
+
+    @param aRequest The operation request dataset being registered.
+    @param aConnection The handle of the MTP connection on which the operation
+    request is expected to be received.
+    @leave KErrArgument, if the request dataset does meet the minimal
+    registration requirements specified above.
+    @leave One of the system wide error codes, if a general processing error
+    occurs.
+    @see RouteRequestUnregisterL
+    */
+    virtual void RouteRequestRegisterL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) = 0;
+
+    /**
+    Cancels a pending RouteRequestRegisterL registration.
+    @param aRequest The registered operation request dataset.
+    @param aConnection The handle of the MTP connection for which the operation
+    request was registered.
+    @leave One of the system wide error codes, if a general processing error
+    occurs.
+    @see RouteRequestRegisterL
+    */
+    virtual void RouteRequestUnregisterL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) = 0;
+
+    /**
+    Signals the completion of the data provider's object store enumeration
+    sequence that was previously initiated by a StartObjectEnumerationL signal
+    made to the MTP data provider interface.
+    @param aStorageId The MTP StorageID of the enumerated storage. This should 
+    match the value specified in the preceding StartObjectEnumerationL.
+    @see MMTPDataProvider::StartObjectEnumerationL
+    */
+    virtual void ObjectEnumerationCompleteL(TUint32 aStorageId) = 0;
+
+    /**
+    Signals the completion of the data provider's storage enumeration sequence
+    that was previously initiated by a StartStorageEnumerationL signal
+    made to the MTP data provider interface.
+    @see MMTPDataProvider::StartStorageEnumerationL
+    */
+    virtual void StorageEnumerationCompleteL() = 0;
+
+    /**
+    Provides a handle to the configurability data specified in the data 
+    provider's configuration file. 
+    @return Handle to the data provider's configurability data.
+    */
+    virtual const MMTPDataProviderConfig& DataProviderConfig() const = 0;
+
+    /**
+    Provides a handle to the data provider framework configurability parameter 
+    data. 
+    @return Handle to the data provider framework configurability data.
+    */
+    virtual const MMTPFrameworkConfig& FrameworkConfig() const = 0;
+
+    /**
+    Provides a handle to the MTP object manager, which manages the assignment
+    of MTP object handles and their mapping to actual data objects on behalf
+    of the data provider.
+    @return Handle to the MTP data provider framework object manager.
+    */
+    virtual MMTPObjectMgr& ObjectMgr() const = 0;
+
+    /**
+    Provides a handle to the MTP object reference manager, to which data
+    providers can delegate the handling of the MTP persistent, abstract
+    object referencing mechanism.
+    @return Handle to the MTP data provider framework object reference manager.
+    */
+    virtual MMTPReferenceMgr& ReferenceMgr() const = 0;
+
+    /**
+    Provides a handle to the MTP storage manager, which manages the assignment 
+    of MTP storage identifiers on behalf of the data provider.
+    @return Handle to the MTP data provider framework storage manager.
+    */
+    virtual MMTPStorageMgr& StorageMgr() const = 0;
+    
+    /**
+    Provides a handle to the MTP data provider framework RFs session.
+    @return Handle to the MTP data provider framework RFs session.
+    */
+    virtual RFs& Fs() const = 0;
+    
+    /**
+    Provides a handle to the MTP datacode generator, which generate the datacode of service properties , formats and methods etc.
+    @return Handle to the MTP datacode generator.
+    */
+    virtual MMTPDataCodeGenerator& DataCodeGenerator() const = 0;
+   
+    };
+
+#endif // MMTPDATAPROVIDERFRAMEWORK_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpframeworkconfig.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,234 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef MMTPFRAMEWORKCONFIG_H
+#define MMTPFRAMEWORKCONFIG_H
+
+#include <e32base.h>
+
+/**
+Defines the framework configurability parameter interface. 
+
+The MTP framework implements a number of configurability parameters using a 
+central repository. The initial set of configurability parameters are loaded 
+from a compiled (binary) initialisation file. Read only access to the 
+framework configurability data is available for reference purposes using this 
+interface. Write access to these parameters is only available to the MTP 
+framework. 
+@publishedPartner
+@released
+*/
+class MMTPFrameworkConfig
+    {
+public:
+
+    /**
+    Defines the framework configurability parameters.
+    */
+    enum TParameter
+        {
+	    /**
+	    This parameter defines the Device Friendly Name MTP device property 
+	    value. It is implemented as a string and has a maximum length of 254 
+	    characters. The parameter value specified in the initialisation file 
+	    may be overwritten in the course of MTP operational processing, if an 
+	    MTP SetDevicePropValue specifying the Device Friendly Name device 
+	    property is received.
+	    
+	    This parameter value can be retrieved as either @see TDes or @see HBufC
+	    values.
+	    */        
+        EDeviceFriendlyName                 = 0x00000000,
+        
+	    /**
+	    This parameter defines the Synchronization Partner MTP device property 
+	    value. It is implemented as a string and has a maximum length of 254 
+	    characters. The parameter value specified in the initialisation file 
+	    may be overwritten in the course of MTP operational processing, if an 
+	    MTP SetDevicePropValue specifying the Synchronization Partner device 
+	    property is received.
+	    
+	    This parameter value can be retrieved as either @see TDes or @see HBufC
+	    values.
+	    */        
+        ESynchronizationPartnerName         = 0x00000001,
+
+	    /**
+	    This parameter is reserved for future use.
+	    */        
+        ERamDriveMetadataStorageEnable      = 0x00000002,
+
+	    /**
+	    This parameter indicates if the framework will allocate MTP logical 
+	    storage IDs. If set to ETrue, then the framework will allocates a
+	    single logical storage ID on each of the available Symbian OS file 
+	    system drives as they become available. If set to EFalse then the 
+	    framework will not allocate any MTP logical storage IDs, in which
+	    case the active data providers are responsible for doing so using 
+	    the @see MMTPStorageMgr interface.
+	    
+	    This parameter value can be retrieved as an @see TBool value.
+	    */        
+        ELogicalStorageIdsAllocationEnable  = 0x00000003,
+
+	    /**
+	    This parameter specifies the Symbian OS file system drive which acts as
+	    the default MTP storage ID (0x00000000). It is implemented as an 
+	    integer value which represents the default drive using a zero based 
+	    numbering scheme (i.e. 0 represents the A drive, 25 represents the Z 
+	    drive etc.) or a MTP storage ID(assigned by the MTP framework).
+	    
+	    This parameter value can be retrieved as an @see TUint value.
+	    */        
+        EDefaultStorageDrive                = 0x00000004,
+
+	    /**
+	    This parameter specifies the device's default MTP Object Format Code.
+	    This format is used when processing MTP operation which specify a 
+	    default (0x00000000) ObjectFormatCode parameter (e.g. InitiateCapture, 
+	    InitiateOpenCapture).
+	    
+	    This parameter value can be retrieved as an @see TUint value.
+	    */        
+        EDefaultObjectFormatCode            = 0x00000005,
+        
+        /**
+        UID of the Stub SIS File
+        This is used by the framework while loading the dataprovider.
+        This parameter value can be retrieved as an @see TUint value.
+        */         
+        EPackageStubUID                     = 0x00000006,
+		/**
+		Implimentation UID of transport PlugIn with high priority.
+		This is used when ETransportSwitchEnabled is enabled.when 
+		MTP client try to start a transport protocol while another 
+		one already exist, if the new one is equal to this parameter 
+		value, the previous protocol plugin will be stopped and the 
+		new transport protocol plugin will be started.
+		 
+		This value can be retrieved as an @TDes value.
+	    */                
+        ETransportHighPriorityUID           = 0x00000007,
+
+        /**
+        Transport protocol implementation switch enable flag.
+        If set to ETrue, the switch is allowed;if set to EFalse,
+        the switch is not allowed. 
+		Refer to ETransportHighPriorityUID for more details.
+		
+		This value can be retrieved as an @see TBool value.
+        */
+        ETransportSwitchEnabled             = 0x00000008,
+        
+        /*
+         * Reserved by MTP framework.
+         * This parameter specifies the device default FunctionalID(128 bits, GUID),
+         */
+        EDeviceDefaultFuncationalID                 = 0x00000010,
+        
+        /*
+         * Reserved by MTP framework.
+         * This parameter specifies the device current FunctionalID(128 bits, GUID),
+         */
+        EDeviceCurrentFuncationalID                 = 0x00000011,
+        
+        /*
+         * Reserved by MTP framework.
+         * This parameter specifies the device default ModelID(128 bits, GUID),
+         */
+        EDeviceDefaultModelID                       = 0x00000012,
+        
+        /*
+         * Reserved by MTP framework.
+         * This parameter specifies the device current ModelID(128 bits, GUID),
+         */
+        EDeviceCurrentModelID                       = 0x00000013,
+   
+        /*
+         * Reserved by MTP framework. 
+         * Indicate whether the MTP server has crashed or been abnormally down or not.
+         * This parameter value can be retrieved as an @see TBool value.
+         */
+        EAbnormalDown								= 0x00000014,
+        
+	    /**
+	    This parameter specifies the Symbian OS file system drives which are 
+	    excluded from the set of MTP storages which are managed by the MTP 
+	    framework. Any drive which is identified in this set will not be 
+	    assigned a corresponding MTP storage ID value by the MTP framework. 
+	    This parameter is implemented as an array of integer values each of 
+	    which represent an excluded drive using a zero based numbering scheme 
+	    (i.e. 0 represents the A drive, 25 represents the Z drive etc.)
+	    
+	    This parameter value can be retrieved as an @see RArray<TUint> value.
+	    */        
+        EExcludedStorageDrives             = 0x00010000
+        };
+		
+public:
+
+    /**
+    Provides the value of a descriptor configurability parameter. This should
+    be used when the length of the parameter value is known not to exceed the 
+    capacity of the parameter value buffer. If the maximum parameter length is 
+    not known then the @see ValueL method should be used.
+    @param aParam The identifier of the parameter value to be retrieved
+    @param aValue The parameter value buffer to be filled. 
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void GetValueL(TParameter aParam, TDes& aValue) const = 0;
+    
+    /**
+    Provides the value of a descriptor configurability parameter. This should 
+    be used when the maximum length of the parameter value is not known.
+    @param aParam The identifier of the parameter value to be retrieved.
+    @return A pointer to a heap descriptor containing the parameter value. 
+    Ownership IS transferred.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual HBufC* ValueL(TParameter aParam) const = 0;
+
+    /**
+    Provides the value of an unsigned integer configurability parameter.
+    @param aParam The identifier of the parameter value to be retrieved
+    @param aValue The parameter value buffer to be filled. 
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void GetValueL(TParameter aParam, TUint& aValue) const = 0;
+
+    /**
+    Provides the value of a boolean configurability parameter.
+    @param aParam The identifier of the parameter value to be retrieved
+    @param aValue The parameter value buffer to be filled. 
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void GetValueL(TParameter aParam, TBool& aValue) const = 0;
+
+    /**
+    Provides the value of an unsigned integer array configurabilitt parameter.
+    @param aParam The identifier of the parameter value to be retrieved
+    @param aValue The parameter value buffer to be filled. 
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void GetValueL(TParameter aParam, RArray<TUint>& aArray) const = 0;
+    };
+    
+#endif // MMTPFRAMEWORKCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpobjectmgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,286 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef MMTPOBJECTMGR_H
+#define MMTPOBJECTMGR_H
+
+#include <badesca.h>
+#include <e32cmn.h>
+#include <e32def.h>
+#include <mtp/mtpobjectmgrquerytypes.h>
+#include <mtp/tmtptypeuint128.h>
+
+class CMTPObjectMetaData;
+class CMTPTypeArray;
+class TMTPTypeUint32;
+
+/** 
+Defines the MTP data provider framework object store enumeration manager 
+interface.
+@publishedPartner
+@released
+*/
+class MMTPObjectMgr
+    {
+public:
+    
+    /**
+    Provides a count of the number of object meta data records present 
+    in the MTP data object enumeration store. This query can be targeted 
+    at specific storage media and/or object data formats, or can be used 
+    to query all MTP data objects on the device.
+    @param aParams The query parameters.
+    @return A count of the number of object meta data records.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual TUint CountL(const TMTPObjectMgrQueryParams& aParams) const = 0;
+	
+	/**
+	Commits into MTP data object enumeration store the object handle and 
+	storage space previously reserved for the specified object. This is 
+	typically used when either an MTP SendObjectInfo/SendObject, or 
+	SendObjectPropList/SendObject operation sequence has completed 
+	successfully.
+    @param aObject The MTP data object information record to be commited.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    @see ReserveObjectHandleL
+	*/
+	virtual void CommitReservedObjectHandleL(CMTPObjectMetaData& aObject) = 0;
+    
+    /**
+    Provides an array of object handles present in the MTP data object 
+    enumeration store. This query can be targeted at specific storage media 
+    and/or object data formats, or can be used to query all MTP data objects 
+    on the device. 
+    
+    Depending on the query parameter specified, this query may incur significant 
+    RAM consumption, and so is intended to be called repeatedly in order to 
+    retrieve all matching SUID data. On completion, @see aContext can be used
+    to determine if there is more data to be retrieved.
+    
+    If there are no object handles which match the specified parameters then a 
+    zero length SUID array is provided. 
+    
+    @param aParams The query parameters.
+    @param aContext The query context data. On completion this data indicates 
+    if there are additional object handle data to retrieve.
+    @param aHandles The MTP object handles array buffer to be populated.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void GetObjectHandlesL(const TMTPObjectMgrQueryParams& aParams, RMTPObjectMgrQueryContext& aContext, RArray<TUint>& aHandles) const = 0;
+    
+    /**
+    Provides an array of object SUIDs present in the MTP data object 
+    enumeration store. This query can be targeted at specific storage media 
+    and/or object data formats, or can be used to query all MTP data objects 
+    on the device. 
+    
+    Depending on the query parameter specified, this query may incur significant 
+    RAM consumption, and so is intended to be called repeatedly in order to 
+    retrieve all matching object SUID data. On completion, @see aContext can be used
+    to determine if there is more data to be retrieved.
+    
+    If there are no object handles which match the specified parameters then a 
+    zero length SUID array is provided. 
+    
+    @param aParams The query parameters.
+    @param aContext The query context data. On completion this data indicates 
+    if there are additional SUID data to retrieve.
+    @param aSuids The object SUIDs array buffer to be populated.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void GetObjectSuidsL(const TMTPObjectMgrQueryParams& aParams, RMTPObjectMgrQueryContext& aContext, CDesCArray& aSuids) const = 0;
+	
+
+	
+	/**
+	Provides the MTP object handle of the object with the specified specified 
+	System Unique Identifier (SUID).
+    @param aSuid The object SUID.
+    @return The MTP object handle.
+    @leave One of the system wide error codes, if a processing failure occurs.
+	*/
+	virtual TUint32 HandleL(const TDesC& aSuid) const = 0;
+
+    /**
+    Inserts a single object information record into the MTP data object 
+    enumeration store. A unique MTP object handle is assigned to the 
+    data object.
+    @param aObject The MTP data object information record to be inserted.
+    @leave KErrAlreadyExists, if an object with the specified MTP object SUID
+    already exists in the MTP data object enumeration store.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void InsertObjectL(CMTPObjectMetaData& aObject) = 0;
+
+    /**
+    Inserts multiple object meta data records in the MTP data object 
+    enumeration store. A unique MTP object handle is assigned to each of the 
+    data objects. 
+    @param aObjects The MTP data object meta data records to be inserted.
+    @leave KErrAlreadyExists, if an object with the one of the specified MTP 
+    object SUIDs already exists in the MTP data object enumeration store.
+    already exists in the MTP data object enumeration store.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void InsertObjectsL(RPointerArray<CMTPObjectMetaData>& aObjects) = 0;
+	
+    /**
+    Modifies the specified MTP data object's object information record. 
+    @param aObject The modified MTP data object information record values.
+    */
+    virtual void ModifyObjectL(const CMTPObjectMetaData& aObject) = 0;
+    
+    /**
+    Provides either the object information record associated with the 
+    associated MTP object handle, or provides an indication that the specified
+    object handle does not exist. 
+    @param aHandle The MTP object handle associated with the object information 
+    record to be provided.
+    @param aObject On exit, the object information record of the requested object. 
+    @return ETrue if the specified object handle exists, otherwise EFalse.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual TBool ObjectL(const TMTPTypeUint32& aHandle, CMTPObjectMetaData& aObject) const = 0;
+
+    /**
+    Provides the object information record associated with the associated MTP
+    object SUID, or provides an indication that the specified object handle 
+    does not exist. 
+    @param aSuid The MTP object SUID associated with the object information 
+    record to be provided.
+    @param aObject On exit, the object information record of the requested object. 
+    @return ETrue if the specified object handle exists, otherwise EFalse.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual TBool ObjectL(const TDesC& aSuid, CMTPObjectMetaData& aObject) const = 0;
+
+
+    /**
+    Provides the ID of the data provider responsible for the specified MTP 
+    data object.
+    @param aHandle The MTP object handle.
+    @return The responsible data provider ID.
+    */
+    virtual TUint ObjectOwnerId(const TMTPTypeUint32& aHandle) const = 0;
+	
+
+	
+	/**
+	Provides the Persistent Unique Identifier (PUID) of the object with the 
+	specified MTP object handle.
+    @param aHandle The MTP object handle.
+    @return The object PUID.
+    @leave One of the system wide error codes, if a processing failure occurs.
+	*/
+	virtual TMTPTypeUint128 PuidL(TUint32 aHandle) const = 0;
+	
+	/**
+	Provides the Persistent Unique Identifier (PUID) of the object with the 
+	specified internal object unique ID.
+    @param aObjectUid The internal object unique ID.
+    @return The object PUID.
+    @leave One of the system wide error codes, if a processing failure occurs.
+	*/
+	virtual TMTPTypeUint128 PuidL(TInt64 aObjectUid) const = 0;
+	
+	/**
+	Provides the Persistent Unique Identifier (PUID) of the object with the 
+	specified System Unique Identifier (SUID).
+    @param aSuid The object SUID.
+    @return The object PUID.
+    @leave One of the system wide error codes, if a processing failure occurs.
+	*/
+	virtual TMTPTypeUint128 PuidL(const TDesC& aSuid) const = 0;
+    
+    /**
+    Removes the object information record associated with the specified MTP 
+    object handle from the MTP data object enumeration store.
+    @param aHandle The MTP object handle associated with the object information 
+    record to be removed.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void RemoveObjectL(const TMTPTypeUint32& aHandle) = 0;
+    
+    /**
+    Removes the object information record associated with the specified object
+    SUID from the MTP data object enumeration store.
+    @param aSuid The object SUID associated with the object information 
+    record to be removed.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void RemoveObjectL(const TDesC& aSuid) = 0;
+
+    /**
+    Removes multiple object meta data records from the MTP data object 
+    enumeration store.
+    @param aSuids The array of object SUIDs associated with the object 
+    meta data records to be removed.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void RemoveObjectsL(const CDesCArray& aSuids) = 0;
+
+    /**
+    Removes from the MTP data object enumeration store all object meta data 
+    records owned by the specified data provider.
+    @param aDataProviderId The ID of the data provider owning the object 
+    meta data records to be deleted.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void RemoveObjectsL(TUint aDataProviderId) = 0;
+	
+	/**
+	Reserves space for and assigns an object handle to the object described
+	by the specified object information record. This is typically used when
+	processing MTP SendObjectInfo or SendObjectPropList operations.
+	@param aObject The object information record of the object. On 
+	successful completion this is updated with the assigned object handle.
+	@param aSpaceRequired The storage space to be reserved for the object.
+	@leave KErrTooBig, if aSpaceRequired exceeds the available capacity of the 
+	storage. 
+	@leave KErrOverflow, if an object handle cannot be assigned.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    @see CommitReservedObjectL
+    @see UnReserveObjectHandleL
+	*/
+	virtual void ReserveObjectHandleL(CMTPObjectMetaData& aObject, TUint64 aSpaceRequired) = 0;
+	
+	/**
+	Releases the object handle and storage space previously reserved for the 
+	specified object. This is typically used when either an MTP 
+	SendObjectInfo/SendObject, or SendObjectPropList/SendObject operation 
+	sequence has not completed successfully.
+	@param aObject The MTP data object information record of the object.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    @see ReserveObjectHandleL
+	*/
+	virtual void UnreserveObjectHandleL(const CMTPObjectMetaData& aObject) = 0;
+	/**
+	Get MtpDeltaDataMgr
+	*/
+	virtual TAny* MtpDeltaDataMgr()
+	   	{
+	   	return NULL;
+	   	};
+    };
+    
+#endif // MMTPOBJECTMGR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpreferencemgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,104 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+
+#ifndef MMTPREFERENCEMGR_H
+#define MMTPREFERENCEMGR_H
+
+#include <badesca.h>
+#include <e32cmn.h>
+#include <e32def.h>
+
+class CMTPTypeArray;
+class TMTPTypeUint32;
+
+/** 
+Defines the MTP data provider framework object reference manager interface.
+
+@publishedPartner
+@released
+*/
+class MMTPReferenceMgr
+    {
+public:
+    
+    /**
+    Provides an MTP array of the target object handles which are referenced 
+    by the specified source object handle. A pointer to the MTP array is 
+    placed on the cleanup stack.
+    @param aFromHandle The MTP object handle of the source object from which 
+    the references originate.
+    @return The MTP reference target object handle array. Ownership IS transferred.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual CMTPTypeArray* ReferencesLC(const TMTPTypeUint32& aFromHandle) const = 0;
+    
+    /**
+    Provides an SUID array of the target object SUIDs which are referenced by 
+    the specified source object SUID. A pointer to the SUID array is 
+    placed on the cleanup stack.
+    @param aFromSuid The SUID of the source object from which the references 
+    originate.
+    @return The reference target object SUID array. Ownership IS transferred.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual CDesCArray* ReferencesLC(const TDesC& aParentSuid) const = 0;
+    
+    /**
+    Removes all object reference links in which the specified SUID represents 
+    either the source or target reference object.
+    @param aSuid The object SUID.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void RemoveReferencesL(const TDesC& aSuid) = 0;
+
+    /**
+    Creates an abstract reference linkage between the specified source and 
+    target object SUIDs.
+    @param aFromSuid The SUID of the source object from which the reference 
+    originates.
+    @param aToSuid The SUID of the target object to which the reference is 
+    made.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void SetReferenceL(const TDesC& aFromSuid, const TDesC& aToSuid) = 0;
+    
+    /**
+    Replaces the abstract reference links originating from the specified 
+    source object SUID with the specified set of target object SUIDs.
+    @param aFromSuid The SUID of the source object from which the references 
+    originate.
+    @param aToSuids The reference target object SUID array.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void SetReferencesL(const TDesC& aFromSuid, const CDesCArray& aToSuids) = 0;
+    
+    /**
+    Replaces the abstract reference links originating from the specified 
+    source object handle with the specified set of target object handles.
+    @param aFromHandle The MTP object handle of the source object from which 
+    the references originate.
+    @param aToHandles The reference target MTP object handle array.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void SetReferencesL(const TMTPTypeUint32& aFromHandle, const CMTPTypeArray& aToHandles) = 0;
+    };
+#endif // MMTPREFERENCEMGR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpsession.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,65 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef MMTPSESSION_H
+#define MMTPSESSION_H
+
+#include <e32cmn.h>
+#include <e32def.h>
+#include <mtp/mtpdataproviderapitypes.h>
+
+class TMTPTypeRequest;
+
+/** 
+Defines the MTP data provider framework MTP session interface.
+@publishedPartner
+@released
+*/
+class MMTPSession
+    {
+public:
+
+    /**
+    Provides a handle to the MTP request dataset of the session's active MTP 
+    transaction. This method should only be invoked if the current MTP 
+    transaction phase is other than EIdle (@see TransactionPhase).
+    @return The active MTP transaction request dataset.
+    @leave KErrNotReady, if the MTP transaction phase is EIdle.
+    @see TransactionPhase.
+    */
+    virtual const TMTPTypeRequest& ActiveRequestL() const = 0;
+    
+    /**
+    Provides the session identifier assigned by the MTP connection on which
+    the session resides. This identifier is unique only to the connection,
+    and may also be in use on any other active connection.
+    @return The MTP connection's session identifier.
+    */
+    virtual TUint32 SessionMTPId() const = 0;
+
+    /**
+    Provides the unique session identifier assigned by the MTP data provider
+    framework. This identifier is unique across all active connections.
+    @return The unique session identifier.
+    */
+    virtual TUint SessionUniqueId() const = 0;
+    };
+#endif // MMTPSESSION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpstoragemgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,306 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef MMTPSTORAGEMGR_H
+#define MMTPSTORAGEMGR_H
+
+#include <f32file.h>
+
+#include <mtp/cmtpstoragemetadata.h>
+#include <mtp/mtpstoragemgrquerytypes.h>
+
+class CMTPTypeString;
+
+/** 
+Defines the MTP data provider framework storage manager interface. The storage 
+manager controls the allocation of physical and logical MTP StorageIDs, and 
+their mapping to storage media, such as Symbian OS file system drives.
+
+MTP StorageIDs are represented as unsigned 32-bit integers and are subdivided 
+into two 16-bit fields. The most significant 16-bits represents the physical 
+StorageID and the least significant 16-bits represents the StorageID of a 
+logical partition of that physical storage. 
+@publishedPartner
+@released
+*/
+class MMTPStorageMgr
+    {
+public:
+    
+    /**
+    Creates a new logical MTP StorageID partition on the specified Symbian OS 
+    file system drive, to be owned and managed by the specified data provider.
+    @param aDataProviderId The identifier of the data provider which will be 
+    responsible for the logical MTP StorageID.
+    @param aDriveNumber The Symbian OS file system drive on which the logical 
+    MTP StorageID partition is to be created.
+    @return The fully formed MTP StorageID of the new logical storage 
+    partition.
+    @param aStorage The storage meta-data. This must minimally specify the 
+    @see EStorageSystemType and @see EStorageSuid elements. The 
+    @see EStorageSystemType must match that of the corresponding physical 
+    MTP StorageID. If @see EStorageSystemType is specified as 
+    @see ESystemTypeDefaultFileSystem then @see EStorageSuid is validated as a 
+    fully formed file system folder path (e.g. "C:\Media") which must 
+    correspond to the specified file system drive.
+    @leave KErrAlreadyExists, if the storage SUID is already defined.
+    @leave KErrArgument if @see EStorageSystemType is not 
+    @see ESystemTypeDefaultFileSystem, or if @see EStorageSuid is not a valid
+    file system folder path, or does not match the specified drive.
+    @leave KErrNotFound if the specified drive does not exist.
+    @leave KErrPathNotFound, if @see EStorageSystemType is 
+    @see ESystemTypeDefaultFileSystem and the path specified by 
+    @see EStorageSuid does not exist on the Symbian OS filesystem. 
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual TUint32 AllocateLogicalStorageIdL(TUint aDataProviderId, TDriveNumber aDriveNumber, const CMTPStorageMetaData& aStorage) = 0;
+    
+    /**
+    Creates a new logical MTP StorageID partition on the specified physical MTP
+    StorageID, to be owned and managed by the specified data provider.
+    @param aDataProviderId The identifier of the data provider which will be 
+    responsible for the logical MTP StorageID.
+    @param aPhysicalStorageId The physical MTP StorageID on which the logical 
+    MTP StorageID partition is to be created.
+    @param aStorage The storage meta-data. This must minimally specify the 
+    @see EStorageSystemType and @see EStorageSuid elements. The 
+    @see EStorageSystemType must match that of the corresponding physical 
+    MTP StorageID. If @see EStorageSystemType is specified as 
+    @see ESystemTypeDefaultFileSystem then @see EStorageSuid is validated as a 
+    fully formed file system folder path (e.g. "C:\Media") which must 
+    correspond to the specified file system drive.
+    @return The fully formed MTP StorageID of the new logical storage 
+    partition.
+    @leave KErrAlreadyExists, if the storage SUID is already defined.
+    @leave KErrArgument if @see EStorageSystemType is not 
+    @see ESystemTypeDefaultFileSystem, or if @see EStorageSuid is not a valid
+    file system folder path, or does not match the specified drive.
+    @leave KErrNotFound if the specified physical StorageID does not exist.
+    @leave KErrPathNotFound, if @see EStorageSystemType is 
+    @see ESystemTypeDefaultFileSystem and the path specified by 
+    @see EStorageSuid does not exist on the Symbian OS filesystem. 
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual TUint32 AllocateLogicalStorageIdL(TUint aDataProviderId, TUint32 aPhysicalStorageId, const CMTPStorageMetaData& aStorage) = 0;
+    
+    /**
+    Creates a new physical MTP StorageID to be owned and managed by the 
+    specified data provider.
+    @param aDataProviderId The identifier of the data provider which will be 
+    responsible for the physical MTP StorageID.
+    @param aStorage The storage meta-data. 
+    @return The physical MTP StorageID.
+    @leave KErrAlreadyExists, if the storage SUID is already defined.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual TUint32 AllocatePhysicalStorageIdL(TUint aDataProviderId, const CMTPStorageMetaData& aStorage) = 0;
+    
+    /**
+    Releases the specified fully formed logical MTP StorageID. 
+    @param aDataProviderId The identifier of the data provider which is 
+    responsible for the logical MTP StorageID.
+    @param aLogicalStorageId The fully formed logical MTP StorageID to be 
+    deallocated.
+    @return KErrNone, if successful.
+    @return KErrNotFound, if the specified logical MTP StorageID is not 
+    defined.
+    @return KErrAccessDenied, if the specified data provider is not the owner of
+    the specified logical MTP StorageID.
+    @return one of the system wide error codes, if a processing failure occurs.
+    */
+    virtual TInt DeallocateLogicalStorageId(TUint aDataProviderId, TUint32 aLogicalStorageId) = 0;
+    
+    /**
+    Releases all logical MTP StorageIDs which represent partitions of the 
+    specified physical MTP StorageID and which are owned by the specified data 
+    provider.
+    @param aDataProviderId The identifier of the data provider which is 
+    responsible for the logical MTP StorageIDs.
+    @param aPhysicalStorageId The physical MTP StorageID.
+    */
+    virtual void DeallocateLogicalStorageIds(TUint aDataProviderId, TUint32 aPhysicalStorageId) = 0;
+    
+    /**
+    Releases the specified physical MTP StorageID, along with all associated
+    logical storage partititions. 
+    @param aDataProviderId The identifier of the data provider which is 
+    responsible for the physical MTP StorageID.
+    @param aPhysicalStorageId The physical MTP StorageID to be released.
+    @return KErrNone if successful.
+    @return KErrNotFound, if the specified sical MTP StorageID is not 
+    defined.
+    @return KErrAccessDenied if the specified data provider is not the owner of
+    the specified physical MTP StorageID.
+    @return one of the system wide error codes, if a processing failure occurs.
+    */
+    virtual TInt DeallocatePhysicalStorageId(TUint aDataProviderId, TUint32 aPhysicalStorageId) = 0;
+
+    /**
+    Provides the default MTP StorageID, as determined by the value of the 
+    @see MTPFrameworkConfig::EDefaultStorageDrive framework configurability 
+    parameter. This may either be a physical or fully formed logical MTP 
+    StorageID, depending on the value of the 
+    @see MTPFrameworkConfig::ELogicalStorageIdsAllocationEnable framework 
+    configurability parameter.
+    @return The default MTP StorageID.
+    */
+    virtual TUint32 DefaultStorageId() const = 0;
+
+    /**
+    Provides the Symbian OS drive number associated with the specified MTP 
+    StorageID. 
+    @param aStorageId The physical or fully formed logical MTP StorageID.
+    @return The Symbian OS drive number associated with the specified MTP 
+    StorageID.
+    @return KErrNotFound, if the MTP StorageID does not exist, or is not 
+    associated with a Symbian OS drive number.
+    */
+    virtual TInt DriveNumber(TUint32 aStorageId) const = 0;
+
+    /**
+    Provides the fully formed MTP StorageID created by the MTP data provider 
+    framework on the specified Symbian OS drive. If the 
+    @see MTPFrameworkConfig::ELogicalStorageIdsAllocationEnable framework 
+    configurability parameter is set, then an MTP StorageID is created on each 
+    of the available Symbian OS file system drives as they become available. If
+    not set then the creation of all logical MTP StorageIDs is deferred to the 
+    active data providers.
+    @param aDriveNumber The drive number for which the corresponding logical
+    MTP StorageID is required.
+    @return The fully formed MTP StorageID of the logical storage which 
+    corresponds to the specified Symbian OS drive number.
+    @return KErrNotFound, if the Symbian OS drive number does not correspond 
+    to an MTP data provider framework created default logical MTP StorageID.
+    */
+    virtual TInt32 FrameworkStorageId(TDriveNumber aDriveNumber) const = 0;
+    
+    /**
+    Provides an ordered list of the Symbian OS file system drives which are
+    available for use as MTP storages. This comprises the sub-set of available
+    Symbian OS file system drives which are left exposed by the the @see
+    MTPFrameworkConfig::EExcludedStorageDrives framework configurability 
+    parameter.
+    @param aDrives On succesful completion, the list of available Symbian OS 
+    file system drives.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void GetAvailableDrivesL(RArray<TDriveNumber>& aDrives) const = 0;
+    
+    /**
+    Provides an ordered list of the storage meta-data for all available logical
+    MTP StorageIDs which match the specified query criteria. 
+    @param aParams The query parameters.
+    @param aStorages On succesful completion, the list of matching storage 
+    meta-data. 
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void GetLogicalStoragesL(const TMTPStorageMgrQueryParams& aParams, RPointerArray<const CMTPStorageMetaData>& aStorages) const = 0;
+    
+    /**
+    Provides an ordered list of the storage meta-data for all available 
+    physical MTP StorageIDs which match the specified query criteria. 
+    @param aParams The query parameters.
+    @param aStorages On succesful completion, the list of matching storage 
+    meta-data. 
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void GetPhysicalStoragesL(const TMTPStorageMgrQueryParams& aParams, RPointerArray<const CMTPStorageMetaData>& aStorages) const = 0;
+    
+    /**
+    Provides the logical StorageID component (i.e. the least significant 
+    16-bits) of the specified 32-bit MTP StorageID.
+    @param aStorageId The MTP StorageID.
+    @return The logical MTP StorageID, if successful.
+    */
+    virtual TUint32 LogicalStorageId(TUint32 aStorageId) const = 0;
+    
+    /**
+    Provides the the fully formed 32-bit logical StorageID associated with the
+    specified storage System Unique IDentifier (SUID).
+    @param aStorageId The MTP StorageID.
+    @return If successful, the fully formed MTP StorageID of the logical 
+    storage which corresponds to the specified storage UID.
+    KErrNotFound, if the specified storage UID is not defined.
+    */
+    virtual TInt32 LogicalStorageId(const TDesC& aStorageSuid) const = 0;
+
+    /**
+    Provides the physical MTP StorageID associated with the specified 
+    Symbian OS drive number.
+    @param aDriveNumber The Symbian OS drive number.
+    @return If successful, the physical MTP StorageID associated with the 
+    specified Symbian OS drive number.
+    KErrNotFound, if the Symbian OS drive number is not associated with an MTP
+    StorageID.
+    */
+    virtual TInt32 PhysicalStorageId(TDriveNumber aDriveNumber) const = 0;
+   
+    /**
+    Provides the physical StorageID component (i.e. the most significant 
+    16-bits) of the specified 32-bit MTP StorageID.
+    @param aStorageId The MTP StorageID.
+    @return The physical MTP StorageID.
+    */
+    virtual TUint32 PhysicalStorageId(TUint32 aStorageId) const = 0;
+    
+    /**
+    Provides the storage meta-data for the specified logical MTP StorageID.
+    @param aStorageId The physical or fully formed logical MTP StorageID.
+    @leave KErrNotFound if the specified StorageID does not exist.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual const CMTPStorageMetaData& StorageL(TUint32 aStorageId) const = 0;
+   
+    /**
+    Constructs a fully formed 32-bit MTP StorageID from the specified physical 
+    and logical MTP StorageIDs.
+    @param aPhysicalStorageId The physical MTP StorageID. The least significant
+    16-bits are ignored.
+    @param aLogicalStorageId The logical MTP StorageID. The most significant 
+    16-bits are ignored.
+    @return The fully formed 32-bit MTP StorageID.
+    */
+    virtual TUint32 StorageId(TUint32 aPhysicalStorageId, TUint32 aLogicalStorageId) const = 0;
+    
+    /**
+    Indicates if the specified StorageID is defined.
+    @param aStorageId The physical or fully formed logical MTP StorageID.
+    @return ETrue if the StorageID exists, otherwise EFalse.
+    */
+    virtual TBool ValidStorageId(TUint32 aStorageId) const = 0;
+
+    /**
+    Generates an MTP volume identifier string of which the leading 128 
+    characters are guaranteed to be unique amongst all storages presented to a 
+    conected MTP initiator.
+    @param aDataProviderId The identifier of the data provider.
+    @param aStorageId The MTP StorageID associated with the volume identifier.
+    @param aVolumeIdSuffix The data provider supplied volume identifier string.
+    @return The MTP volume identifier string. Ownership IS transferred.
+    @leave KErrAccessDenied if the specified data provider is not the owner of
+    the specified StorageID.
+    @leave KErrNotFound if the specified MTP StorageID does not exist.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual CMTPTypeString* VolumeIdL(TUint aDataProviderId, TUint32 aStorageId, const TDesC& aVolumeIdSuffix) const = 0;
+    };
+    
+#endif // MMTPSTORAGEMGR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mtpdataproviderapitypes.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,316 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef MTPDATAPROVIDERAPITYPES_H
+#define MTPDATAPROVIDERAPITYPES_H
+
+#include <mtp/mtpdataproviderconfig.hrh>
+
+class MMTPConnection;
+
+/** 
+Defines the various data provider type categories.
+@publishedPartner
+@released
+*/
+enum TMTPDataProviderTypes
+    {
+    /**
+    ECOM plug-in.
+    */
+    EEcom   = KMTPDataProviderTypeECOM
+    };
+
+/** 
+Defines the MTP framework operational modes.
+@publishedPartner
+@released
+*/
+enum TMTPOperationalMode
+    {
+    /**
+    Undefined mode.
+    */
+    EModeUnknown    = KMTPModeUnknown,
+    
+    /**
+    MTP Mode.
+    */
+    EModeMTP        = KMTPModeMTP,
+    
+    /**
+    PTP Mode.
+    */
+    EModePTP        = KMTPModePTP,
+    
+    /**
+    PictBridge Mode.
+    */
+    EModePictBridge = KMTPModePictBridge,
+    
+	};
+
+/** 
+Defines the MTP framework event notification types.
+@publishedPartner
+@released
+*/
+enum TMTPNotification
+    {
+    /**
+    This notification indicates that the operational mode of the MTP data 
+    provider framework has changed. Details of the mode change are provided in
+    the accompanying @see TMTPNotificationParamsSessionChange notification 
+    parameter block.
+    */
+    EMTPModeChanged,
+    
+    /**
+    This notification indicates that an active MTP session has become inactive. 
+    Details of the session are provided in the accompanying 
+    @see TMTPNotificationParamsSessionChange notification parameter block.
+    */
+    EMTPSessionClosed,
+
+    /**
+    This notification indicates that a new MTP session has become active. 
+    Details of the session are provided in the accompanying 
+    @see TMTPNotificationParamsSessionChange notification parameter block.
+    */
+    EMTPSessionOpened,
+
+    /**
+    This notification indicates that a new MTP storage has become available as
+    a result of the insertion of removable storage media. 
+    Details of the storage are provided in the accompanying 
+    @see TMTPNotificationParamsStorageChange notification parameter block.
+    */
+    EMTPStorageAdded,
+
+    /**
+    This notification indicates that an MTP storage has become unavailable as
+    a result of the removal of removable storage media. 
+    Details of the storage are provided in the accompanying 
+    @see TMTPNotificationParamsStorageChange notification parameter block.
+    */
+    EMTPStorageRemoved,
+	
+	/**
+    This notification indicates that an MTP storage has become unavailable as
+    a result of the usb cable removed. 
+    Details of the storage are provided in the accompanying     
+    */
+	EMTPDisconnected,
+	
+	/**
+	This notification indicates that an MTP Object has been Renamed.
+	*/
+	EMTPRenameObject,
+	
+	EMTPObjectAdded
+    };
+
+/**
+Defines the notification parameter block which accompanies @see EMTPModeChanged 
+notifications.
+*/
+class TMTPNotificationParamsModeChange
+    {
+public:
+
+    /**
+    The new MTP operational mode TO which the MTP framework is 
+    transitioning.
+    */
+    TMTPOperationalMode    iNewMode;
+    
+    /**
+    The previous MTP operational mode FROM which the MTP framework is 
+    transitioning.
+    */
+    TMTPOperationalMode    iPreviousMode;
+    };
+
+/**
+Defines the notification parameter block which accompanies @see ESessionOpened 
+and @see ESessionClosed notifications.
+*/
+class TMTPNotificationParamsSessionChange
+    {
+public:
+
+    /**
+    The MTP connection assigned identifier of the session.
+    */
+    TUint           iMTPId;
+
+    /**
+    The MTP connection on which the exists.
+    */
+    MMTPConnection& iConnection;
+    };
+
+/**
+Defines the notification parameter block which accompanies @see EStorageAdded 
+and @see EStorageRemoved notifications.
+*/
+class TMTPNotificationParamsStorageChange
+    {
+public:
+
+    /**
+    The MTP StorageID assigned to the storage.
+    */
+    TUint32 iStorageId;
+    };
+    
+/** 
+Defines the various data provider MTP feature support categories.
+@publishedPartner
+@released
+*/
+enum TMTPSupportCategory
+    {
+    /**
+    MTP association type datacodes.
+    */
+    EAssociationTypes       = 0,
+    
+    /**
+    MTP device property identifier datacodes.
+    */
+    EDeviceProperties       = 1,
+    
+    /**
+    MTP event identifier datacodes.
+    */
+    EEvents                 = 2,
+
+    /**
+    Produced MTP object format identifier datacodes.
+    */
+    EObjectCaptureFormats   = 3,
+
+    /**
+    Consumed MTP object format identifier datacodes.
+    */
+    EObjectPlaybackFormats  = 4,
+    
+    /**
+    MTP object property identifier datacodes.
+    */
+    EObjectProperties       = 5,
+
+    /**
+    MTP operation identifier datacodes.
+    */
+    EOperations             = 6,  
+    
+    /**
+    Supported storage systems (@see CMTPStorageMetaData::TStorageSystemType).
+    */
+    EStorageSystemTypes     = 7,
+    
+    /**
+    MTP extension set identifier strings.
+    */
+    EVendorExtensionSets    = 8,
+    
+    /**
+    Folder exclusion list strings
+     */
+    EFolderExclusionSets    = 9,
+    
+    /**
+    Format code and file extension mapping strings
+     */
+    EFormatExtensionSets    = 10,
+    
+    /**
+    MTP Device Service Extension service identifier strings.
+    */
+    EServiceIDs    = 11,
+
+    /**
+    The number of supported categories.
+    */
+    ENumCategories
+    };
+
+/** 
+Defines the MTP operation transaction processing phases.
+@publishedPartner
+@released
+*/
+enum TMTPTransactionPhase
+{
+    /**
+    Transaction phase unspecified.
+    */
+    EUndefined          = 0x00000000,
+	
+    /**
+    No MTP transaction is in-progress.
+    */
+	EIdlePhase          = 0x00000001,
+	
+    /**
+    MTP request phase.
+    */
+    ERequestPhase       = 0x00000002,
+	
+    /**
+    MTP data phase (data flow direction is MTP initiator to MTP responder).
+    */
+    EDataIToRPhase      = 0x00000004,
+	
+    /**
+    MTP data phase (data flow direction is MTP responder to MTP initiator).
+    */
+    EDataRToIPhase      = 0x00000008,
+	
+    /**
+    MTP response phase.
+    */
+    EResponsePhase      = 0x00000010,
+	
+    /**
+    Transaction conmpleting phase.
+    */
+    ECompletingPhase    = 0x00000020
+};
+
+class TMTPNotificationParamsHandle
+{
+public:
+
+/**
+The MTP framework assigned Object Handle in the session.
+*/
+TUint32           iHandleId;   
+/**
+The MTP framework assigned Object FileName in the session.
+*/
+TFileName         iFileName;
+
+};
+
+#endif // MTPDATAPROVIDERAPITYPES_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mtpdataproviderconfig.hrh	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,62 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#if !defined(MTPDATAPROVIDERCONFIG_HRH)
+#define MTPDATAPROVIDERCONFIG_HRH
+
+/**
+The ECOM data provider type identifier.
+@publishedPartner
+@released
+*/
+#define KMTPDataProviderTypeECOM    0x0001
+    
+/**
+The undefined operational mode bit flag.
+@publishedPartner
+@released
+*/
+#define KMTPModeUnknown             0x0000
+    
+/**
+The MTP operational mode bit flag.
+@publishedPartner
+@released
+*/
+#define KMTPModeMTP                 0x0001
+    
+/**
+The PTP operational mode bit flag.
+@publishedPartner
+@released
+*/
+#define KMTPModePTP                 0x0002 
+    
+/**
+The PictBridge operational mode bit flag.
+@publishedPartner
+@released
+*/ 
+#define KMTPModePictBridge          0x0004
+
+
+#endif // MTPDATAPROVIDERCONFIG_HRH
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mtpdataproviderconfig.rh	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,37 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Defines the resource type to be used for data provider registration
+// 
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#include <mtp/mtpdataproviderconfig.hrh>
+
+STRUCT MTP_DATA_PROVIDER
+    {
+    WORD type = KMTPDataProviderTypeECOM;
+    BYTE major_version = 1;
+    BYTE object_enumeration_persistent = 0; // 0 EFalse, 1 ETrue
+    WORD supported_modes = KMTPModeMTP;     // OR'd combination of KMTPModeMTP, KMTPModePTP and KMTPModePictBridge   
+    LTEXT server_name = "";
+    LTEXT server_image_name = "";
+    LLINK opaque_resource = 0;
+    BYTE enumeration_phase = 0;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mtpobjectmgrquerytypes.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,97 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef MTPOBJECTMGRQUERYTYPES_H
+#define MTPOBJECTMGRQUERYTYPES_H
+
+#include <e32def.h>
+#include <mtp/mtpprotocolconstants.h> 
+
+class RDbView;
+
+/**
+Defines the MTP data provider framework object store enumeration manager object
+query parameters.
+*/
+class TMTPObjectMgrQueryParams
+    {
+public:
+
+    IMPORT_C TMTPObjectMgrQueryParams(TUint32 aStorageId, TUint32 aFormatCode, TUint32 aParentHandle, TUint32 aDpId = KMTPDataProviderAll);
+
+public:
+
+    /**
+    The identifier of the storage on which the objects being queried 
+    reside. A value of @see KMTPStorageAll requests indicates that an 
+    aggregated set of objects residing on all storages is required.
+    */
+    TUint32 iStorageId;
+    
+    /**
+    The MTP object format code of the objects being queried. A value of 
+    @see KMTPFormatsAll indicates that an aggregated set of all object 
+    formats is required.
+    */
+    TUint32 iFormatCode;
+    
+    /**
+    The MTP object handle of the parent of the objects being queried. A 
+    value of @see KMTPHandleNoParent indicates that the set of objects 
+    residing in the root folder of their storage is required. 
+    */
+    TUint32 iParentHandle;
+	
+    /**
+    The data provider which owns the MTP objects @see KMTPDataProviderAll 
+    indicates objects owned by any data providres
+    */
+	TUint32  iDpId;
+    };
+  
+/**
+Defines the MTP data provider framework object store enumeration manager 
+object query context data. This data indicates if there is additional 
+object data to be retrieved which matches the query.
+*/
+class RMTPObjectMgrQueryContext
+    {
+public:
+
+    IMPORT_C RMTPObjectMgrQueryContext();
+    
+    IMPORT_C void Close();
+    
+    IMPORT_C TBool QueryComplete() const;
+    
+private:
+
+    friend class CMTPObjectStore;
+    IMPORT_C RDbView& DbView();
+    IMPORT_C void OpenL();
+    IMPORT_C TBool IsOpen() const;
+    
+private:
+
+    TAny* iContext;
+    };
+    
+#endif // MTPOBJECTMGRQUERYTYPES_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mtpstoragemgrquerytypes.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,57 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef MTPSTORAGEMGRQUERYTYPES_H
+#define MTPSTORAGEMGRQUERYTYPES_H
+
+#include <e32cmn.h>
+
+/**
+Defines the MTP data provider framework object store enumeration manager object
+query parameters.
+*/
+class TMTPStorageMgrQueryParams
+    {
+public:
+
+    IMPORT_C TMTPStorageMgrQueryParams();
+    IMPORT_C TMTPStorageMgrQueryParams(const TDesC& aStorageSuid, TUint32 aStorageSystemType);
+    
+    IMPORT_C void SetStorageSuid(const TDesC& aStorageSuid);
+    IMPORT_C void SetStorageSystemType(TUint32 aStorageSystemType);
+    
+    IMPORT_C const TDesC& StorageSuid() const;
+    IMPORT_C TUint32 StorageSystemType() const;
+
+private:
+    
+    /**
+    The storage System Unique IDentifier (SUID). 
+    */
+    TPtrC   iStorageSuid;
+
+    /**
+    The storage system type.
+    */
+    TUint32 iStorageSystemType;
+    };
+    
+#endif // MTPSTORAGEMGRQUERYTYPES_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/src/cmtpdataproviderplugin.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,63 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <ecom/ecom.h>
+#include <mtp/cmtpdataproviderplugin.h>
+#include <mtp/mmtpdataproviderframework.h>
+
+/**
+MTP data provider plug-in factory method.
+@param aImplementationUid A UID specifying the required data provider 
+interface implementation.
+@param aParams An MTP framework specific parameter block pointer. This pointer
+should simply be passed through to this class's constructor by the derived 
+class.
+@return Pointer to the plug-in instance. Ownership IS transfered.
+@leave KErrNoMemory If the plug-in instance could not be allocated.
+@leave KErrArgument If an invalid aImplementationUid was specified.
+*/
+EXPORT_C CMTPDataProviderPlugin* CMTPDataProviderPlugin::NewL(TUid aImplementationUid, TAny* aParams)
+    {
+    CMTPDataProviderPlugin* self = reinterpret_cast<CMTPDataProviderPlugin*>(
+        REComSession::CreateImplementationL(
+            aImplementationUid,
+            _FOFF(CMTPDataProviderPlugin, iDtorIdKey), 
+            aParams));
+    return self;
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPDataProviderPlugin::~CMTPDataProviderPlugin()
+    {
+	REComSession::DestroyedImplementation(iDtorIdKey);
+    }
+
+/**
+Constructor.
+@param aParams Parameter block pointer.
+@panic USER 0 If the parameter block pointer is 0.
+*/
+EXPORT_C CMTPDataProviderPlugin::CMTPDataProviderPlugin(TAny* aParams) :
+    iFramework(reinterpret_cast<MMTPDataProviderFramework*> (aParams))
+    {
+    __ASSERT_ALWAYS(iFramework, User::Invariant());
+    }
+
+EXPORT_C MMTPDataProviderFramework& CMTPDataProviderPlugin::Framework() const
+    {
+    return *iFramework;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/src/cmtpmetadata.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,556 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtpmetadata.h>
+#include <e32hashtab.h>
+#include <e32debug.h>
+
+#ifdef _DEBUG
+/**
+CMTPMetaData panic category.
+*/
+_LIT(KMTPPanicCategory, "CMTPMetaData");
+
+/**
+CMTPMetaData panic reasons.
+*/
+enum TMTPPanicReasons
+    {
+    EPanicBadLayout     = 0,
+    EPanicTypeMismatch  = 1,
+    EPanicTypeUnknown   = 2,
+    };
+
+/**
+Creates a CMTPMetaData category panic condition.
+@param The panic condition reason code.
+@panic CMTPMetaData aReason Always.
+*/
+LOCAL_C void Panic(TInt aReason)
+    {
+    User::Panic(KMTPPanicCategory, aReason);
+    }
+#endif // _DEBUG
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPMetaData::~CMTPMetaData()
+    {
+    iElementsDesC.ResetAndDestroy();
+    iElementsDesCArray.ResetAndDestroy();
+    iElementsDesCArrayType.Close();	
+    iElementsDesCArrayType.Reset();
+    iElementsInt.Reset();
+    TInt count(iElementsIntArray.Count());
+    while (count)
+        {
+        DeleteIntArray(--count);
+        }
+    iElementsIntArray.Reset();
+    
+    iElementsUint.Reset();
+    count = (iElementsUintArray.Count());
+    while (count)
+        {
+        DeleteUintArray(--count);
+        }
+    iElementsUintArray.Reset();	
+	iPathHash.Close();
+    } 
+    
+/**
+Provides the value of the specified element.
+@param aId The element identifier.
+@return The element value.
+@panic CMTPMetaData 0 In debug builds, if the specified element is not of
+the requested type.
+*/
+EXPORT_C const TDesC& CMTPMetaData::DesC(TUint aId) const
+    {
+    __ASSERT_DEBUG((iElements[aId].iType == EDesC), Panic(EPanicTypeMismatch));
+    return *iElementsDesC[iElements[aId].iOffset];
+    }    
+    
+/**
+Provides the value of the specified element.
+@param aId The element identifier.
+@return The element value.
+@panic CMTPMetaData 0 In debug builds, if the specified element is not of
+the requested type.
+*/
+EXPORT_C const CDesCArray& CMTPMetaData::DesCArray(TUint aId)
+    {
+    __ASSERT_DEBUG((iElements[aId].iType == EDesCArray), Panic(EPanicTypeMismatch));
+    return *iElementsDesCArray[iElements[aId].iOffset];
+    }
+    
+/**
+Provides the value of the specified element.
+@param aId The element identifier.
+@return The element value.
+@panic CMTPMetaData 0 In debug builds, if the specified element is not of
+the requested type.
+*/
+EXPORT_C TInt CMTPMetaData::Int(TUint aId) const
+    {
+    __ASSERT_DEBUG((iElements[aId].iType == EInt), Panic(EPanicTypeMismatch));
+    return iElementsInt[iElements[aId].iOffset];
+    }
+    
+/**
+Provides the value of the specified element.
+@param aId The element identifier.
+@return The element value.
+@panic CMTPMetaData 0 In debug builds, if the specified element is not of
+the requested type.
+*/
+EXPORT_C const RArray<TInt>& CMTPMetaData::IntArray(TUint aId) const
+    {
+    __ASSERT_DEBUG((iElements[aId].iType == EIntArray), Panic(EPanicTypeMismatch));
+    return *(reinterpret_cast<const RArray<TInt>*> (iElementsIntArray[iElements[aId].iOffset]));
+    }
+    
+/**
+Provides the value of the specified element.
+@param aId The element identifier.
+@return The element value.
+@panic CMTPMetaData 0 In debug builds, if the specified element is not of
+the requested type.
+*/
+EXPORT_C TUint CMTPMetaData::Uint(TUint aId) const
+    {
+    __ASSERT_DEBUG((iElements[aId].iType == EUint), Panic(EPanicTypeMismatch));
+    return iElementsUint[iElements[aId].iOffset];
+    }
+    
+/**
+Provides the value of the specified element.
+@param aId The element identifier.
+@return The element value.
+@panic CMTPMetaData 0 In debug builds, if the specified element is not of
+the requested type.
+*/
+EXPORT_C const RArray<TUint>& CMTPMetaData::UintArray(TUint aId) const
+    {
+    __ASSERT_DEBUG((iElements[aId].iType == EUintArray), Panic(EPanicTypeMismatch));
+    return *(reinterpret_cast<const RArray<TUint>*> (iElementsUintArray[iElements[aId].iOffset]));
+    }
+
+/**
+Provides a copy of the specified element.
+@param aId The element identifier.
+@param aValue On successful completion, a copy of the element value.
+@panic CMTPMetaData 0 In debug builds, if the specified element is not of
+the requested type.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C void CMTPMetaData::GetIntArrayL(TUint aId, RArray<TInt>& aValue)
+    {
+    __ASSERT_DEBUG((iElements[aId].iType == EUintArray), Panic(EPanicTypeMismatch));
+    CopyL(IntArray(aId), aValue);
+    }
+
+/**
+Provides a copy of the specified element.
+@param aId The element identifier.
+@param aValue On successful completion, a copy of the element value.
+@panic CMTPMetaData 0 In debug builds, if the specified element is not of
+the requested type.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C void CMTPMetaData::GetUintArrayL(TUint aId, RArray<TUint>& aValue)
+    {
+    __ASSERT_DEBUG((iElements[aId].iType == EUintArray), Panic(EPanicTypeMismatch));
+    CopyL(UintArray(aId), aValue);
+    }
+    
+/**
+Sets the value of the specified element.
+@param aId The element identifier.
+@param aValue The element value.
+@panic CMTPMetaData 0 In debug builds, if the specified element is not of
+the requested type.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C void CMTPMetaData::SetDesCL(TUint aId, const TDesC& aValue)
+    {
+    const TElementMetaData& KElement(iElements[aId]);
+    __ASSERT_DEBUG((KElement.iType == EDesC), Panic(EPanicTypeMismatch));
+    delete iElementsDesC[KElement.iOffset];
+    iElementsDesC[KElement.iOffset] = NULL;
+	iElementsDesC[KElement.iOffset] = aValue.AllocL();	
+    }
+    
+/**
+Sets the value of the specified element.
+@param aId The element identifier.
+@param aValue The element value.
+@panic CMTPMetaData 0 In debug builds, if the specified element is not of
+the requested type.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C void CMTPMetaData::SetDesCArrayL(TUint aId, const CDesCArrayFlat& aValue)
+    {
+    __ASSERT_DEBUG((iElements[aId].iType == EDesCArray), Panic(EPanicTypeMismatch));
+    TUint idx(iElements[aId].iOffset);
+    delete iElementsDesCArray[idx];
+    iElementsDesCArray[idx] = NULL;
+    iElementsDesCArray[idx] = new(ELeave) CDesCArrayFlat(KGranularity);
+	iElementsDesCArrayType[idx]=EDesCArrayFlat;
+    CopyL(aValue, *iElementsDesCArray[idx]);
+    }
+    
+/**
+Sets the value of the specified element.
+@param aId The element identifier.
+@param aValue The element value.
+@panic CMTPMetaData 0 In debug builds, if the specified element is not of
+the requested type.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C void CMTPMetaData::SetDesCArrayL(TUint aId, const CDesCArraySeg& aValue)
+    {
+    __ASSERT_DEBUG((iElements[aId].iType == EDesCArray), Panic(EPanicTypeMismatch));
+    TUint idx(iElements[aId].iOffset);
+    delete iElementsDesCArray[idx];
+    iElementsDesCArray[idx] = NULL;
+    iElementsDesCArray[idx] = new(ELeave) CDesCArraySeg(KGranularity);
+	iElementsDesCArrayType[idx]=EDesCArraySeg;
+    CopyL(aValue, *iElementsDesCArray[idx]);
+    }
+    
+/**
+Sets the value of the specified element.
+@param aId The element identifier.
+@param aValue The element value.
+@panic CMTPMetaData 0 In debug builds, if the specified element is not of
+the requested type.
+*/
+EXPORT_C void CMTPMetaData::SetInt(TUint aId, TInt aValue)
+    {
+    __ASSERT_DEBUG((iElements[aId].iType == EInt), Panic(EPanicTypeMismatch));
+    iElementsInt[iElements[aId].iOffset] = aValue;
+    }
+    
+/**
+Sets the value of the specified element.
+@param aId The element identifier.
+@param aValue The element value.
+@panic CMTPMetaData 0 In debug builds, if the specified element is not of
+the requested type.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C void CMTPMetaData::SetIntArrayL(TUint aId, const RArray<TInt>& aValue)
+    {
+    __ASSERT_DEBUG((iElements[aId].iType == EIntArray), Panic(EPanicTypeMismatch));
+    TUint idx(iElements[aId].iOffset);
+    DeleteIntArray(idx);
+    iElementsIntArray[idx] = new(ELeave) RArray<TInt>;
+    CopyL(aValue, *(reinterpret_cast<RArray<TInt>*>(iElementsIntArray[iElements[aId].iOffset])));
+    }
+    
+/**
+Sets the value of the specified element.
+@param aId The element identifier.
+@param aValue The element value.
+@panic CMTPMetaData 0 In debug builds, if the specified element is not of
+the requested type.
+*/
+EXPORT_C void CMTPMetaData::SetUint(TUint aId, TUint aValue)
+    {
+    __ASSERT_DEBUG((iElements[aId].iType == EUint), Panic(EPanicTypeMismatch));
+    iElementsUint[iElements[aId].iOffset] = aValue;
+    }
+    
+/**
+Sets the value of the specified element.
+@param aId The element identifier.
+@param aValue The element value.
+@panic CMTPMetaData 0 In debug builds, if the specified element is not of
+the requested type.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C void CMTPMetaData::SetUintArrayL(TUint aId, const RArray<TUint>& aValue)
+    {
+    __ASSERT_DEBUG((iElements[aId].iType == EUintArray), Panic(EPanicTypeMismatch));
+    TUint idx(iElements[aId].iOffset);
+    DeleteUintArray(idx);
+    iElementsUintArray[idx] = new(ELeave) RArray<TUint>;
+    CopyL(aValue, *(reinterpret_cast<RArray<TUint>*>(iElementsUintArray[iElements[aId].iOffset])));
+    }
+
+/**
+Provides an MTP object manager's object meta data record extension 
+interface implementation for the specified interface Uid. 
+@param aInterfaceUid Unique identifier for the extension interface being 
+requested.
+@return Pointer to an interface instance or 0 if the interface is not 
+supported. Ownership is NOT transfered.
+*/
+EXPORT_C TAny* CMTPMetaData::GetExtendedInterface(TUid /*aInterfaceUid*/)
+    {
+    return iExtensionInterfaces;
+    }
+
+/**
+Constructor.
+*/
+CMTPMetaData::CMTPMetaData(const TElementMetaData* aElements, TUint aCount) :
+    iElements(sizeof(*aElements), const_cast<TElementMetaData*>(aElements), aCount),
+    iElementsDesC(KGranularity)
+    {
+
+    }
+    
+/**
+Second phase constructor.
+@leave One of the system wide error code, if a processing failure occurs.
+*/
+void CMTPMetaData::ConstructL()
+    {
+    const TUint KCount(iElements.Count());
+    for (TUint i(0); (i < KCount); i++)
+        {
+        const TElementMetaData& KElement(iElements[i]);
+        switch (KElement.iType)
+            {
+        case EDesC:
+            __ASSERT_DEBUG((iElementsDesC.Count() == KElement.iOffset), Panic(EPanicBadLayout));
+            iElementsDesC.AppendL(KNullDesC().AllocLC());
+            CleanupStack::Pop();
+            break;
+            
+        case EDesCArray:
+        	{
+            __ASSERT_DEBUG((iElementsDesCArray.Count() == KElement.iOffset), Panic(EPanicBadLayout));
+            CDesCArrayFlat* desarray = new(ELeave) CDesCArrayFlat(KGranularity);
+            CleanupStack::PushL(desarray);
+            iElementsDesCArray.AppendL(desarray);
+            CleanupStack::Pop(desarray);
+			iElementsDesCArrayType.AppendL(EDesCArrayFlat);
+            break;
+        	}
+            
+        case EInt:
+            __ASSERT_DEBUG((iElementsInt.Count() == KElement.iOffset), Panic(EPanicBadLayout));
+            iElementsInt.AppendL(0);
+            break;
+            
+        case EIntArray:
+        	{
+            __ASSERT_DEBUG((iElementsIntArray.Count() == KElement.iOffset), Panic(EPanicBadLayout));
+            RArray<TInt>* intarray = new(ELeave) RArray<TInt>;
+            CleanupStack::PushL(intarray);
+            iElementsIntArray.AppendL(intarray);
+            CleanupStack::Pop(intarray);
+            break;
+        	}
+            
+        case EUint:
+            __ASSERT_DEBUG((iElementsUint.Count() == KElement.iOffset), Panic(EPanicBadLayout));
+            iElementsUint.AppendL(0);
+            break;
+            
+        case EUintArray:
+        	{
+            __ASSERT_DEBUG((iElementsUintArray.Count() == KElement.iOffset), Panic(EPanicBadLayout));
+            RArray<TUint>* uintarray = new(ELeave) RArray<TUint>;
+            CleanupStack::PushL(uintarray);
+            iElementsUintArray.AppendL(uintarray);
+            CleanupStack::Pop(uintarray);
+            break;
+        	}
+            
+        default:
+            __DEBUG_ONLY(Panic(EPanicTypeUnknown));
+            break;
+            }
+        }
+    }      
+    
+/**
+Second phase copy constructor.
+@param aFrom The source meta-data.
+@leave One of the system wide error code, if a processing failure occurs.
+*/
+void CMTPMetaData::ConstructL(const CMTPMetaData& aFrom)
+    {
+    // iElementsDesC
+    TUint count(aFrom.iElementsDesC.Count());
+    for (TUint i(0); (i < count); i++)
+        {
+        iElementsDesC.AppendL(aFrom.iElementsDesC[i]->AllocLC());
+        CleanupStack::Pop();
+        }
+    
+    // iElementsDesCArray 
+    count = aFrom.iElementsDesCArray.Count();
+    for (TUint i(0); (i < count); i++)
+        {
+        if ((aFrom.iElementsDesCArrayType[i])==EDesCArrayFlat)
+            {
+            CDesCArrayFlat* flatarray = new(ELeave) CDesCArrayFlat(KGranularity);
+        	CleanupStack::PushL(flatarray);
+            iElementsDesCArray.AppendL(flatarray);
+            CleanupStack::Pop(flatarray);
+            }
+        else
+            {
+            CDesCArraySeg* segarray = new(ELeave) CDesCArraySeg(KGranularity);
+        	CleanupStack::PushL(segarray);
+            iElementsDesCArray.AppendL(segarray);
+            CleanupStack::Pop(segarray);
+            }
+        CopyL(*aFrom.iElementsDesCArray[i], *iElementsDesCArray[i]);
+        }
+    
+    // iElementsInt    
+    CopyL(aFrom.iElementsInt, iElementsInt);
+    
+    // iElementsIntArray
+    count = aFrom.iElementsIntArray.Count();
+    for (TUint i(0); (i < count); i++)
+        {        
+        RArray<TInt>* intarray = new(ELeave) RArray<TInt>;
+    	CleanupStack::PushL(intarray);
+        iElementsIntArray.AppendL(intarray);
+        CleanupStack::Pop(intarray);
+        const RArray<TInt>& from(*reinterpret_cast<RArray<TInt>*>(aFrom.iElementsIntArray[i]));
+        RArray<TInt>& to(*reinterpret_cast<RArray<TInt>*>(iElementsIntArray[i]));
+        CopyL(from, to);
+        }
+        
+    // iElementsUint
+    CopyL(aFrom.iElementsUint, iElementsUint);
+    
+    // iElementsIntArray
+    count = aFrom.iElementsUintArray.Count();
+    for (TUint i(0); (i < count); i++)
+        {
+        RArray<TUint>* array = new(ELeave) RArray<TUint>;
+    	CleanupStack::PushL(array);
+        iElementsUintArray.AppendL(array);
+        CleanupStack::Pop(array);
+        const RArray<TUint>& from(*reinterpret_cast<RArray<TUint>*>(aFrom.iElementsUintArray[i]));
+        RArray<TUint>& to(*reinterpret_cast<RArray<TUint>*>(iElementsUintArray[i]));
+        CopyL(from, to);
+        }
+    // iPathHash
+    for(TInt i=0; i<aFrom.iPathHash.Count(); ++i)
+    	{
+    	this->iPathHash.Append(aFrom.iPathHash[i]);
+    	}
+    }
+
+/**
+Default constructor.
+*/
+CMTPMetaData::CMTPMetaData() :
+    iElementsDesC(KGranularity)
+    {
+    
+    }  
+    
+/**
+Copies the specified array contents.
+@param aFrom The source array.
+@param aTo The target array.
+@leave One of the system wide error code, if a processing failure occurs.
+*/
+void CMTPMetaData::CopyL(const CDesCArray& aFrom, CDesCArray& aTo)
+    {
+    const TUint KCount(aFrom.Count());
+    for (TUint i(0); (i < KCount); i++)
+        {
+        aTo.AppendL(aFrom[i]);
+        }
+    }
+    
+/**
+Copies the specified array contents.
+@param aFrom The source array.
+@param aTo The target array.
+@leave One of the system wide error code, if a processing failure occurs.
+*/
+void CMTPMetaData::CopyL(const RArray<TInt>& aFrom, RArray<TInt>& aTo)
+    {
+    aTo.Reset();
+    const TUint KCount(aFrom.Count());
+    for (TUint i(0); (i < KCount); i++)
+        {
+        aTo.AppendL(aFrom[i]);
+        }
+    }
+    
+/**
+Copies the specified array contents.
+@param aFrom The source array.
+@param aTo The target array.
+@leave One of the system wide error code, if a processing failure occurs.
+*/
+void CMTPMetaData::CopyL(const RArray<TUint>& aFrom, RArray<TUint>& aTo)
+    {
+    aTo.Reset();
+    const TUint KCount(aFrom.Count());
+    for (TUint i(0); (i < KCount); i++)
+        {
+        aTo.AppendL(aFrom[i]);
+        }
+    }
+    
+/**
+Deletes the specified IntArray.
+@param aIdx The iElementsIntArray index.
+*/
+void CMTPMetaData::DeleteIntArray(TUint aIdx)
+    {
+    RArray<TInt>* array(reinterpret_cast<RArray<TInt>*>(iElementsIntArray[aIdx]));
+    array->Reset();
+    delete array;
+    }
+    
+/**
+Deletes the specified IntArray.
+@param aIdx The iElementsIntArray index.
+*/
+void CMTPMetaData::DeleteUintArray(TUint aIdx)
+    {
+    RArray<TUint>* array(reinterpret_cast<RArray<TUint>*>(iElementsUintArray[aIdx]));
+    array->Reset();
+    delete array;
+    }
+EXPORT_C void CMTPMetaData::SetHashPath(const TDesC16& aExclusionPath, TUint aIndex)
+	{
+	TFileName ex(aExclusionPath);
+	ex.LowerCase();
+	TUint32 HashCode=DefaultHash::Des16(ex);
+	TPathHash entry;
+    entry.iHash=HashCode;
+    entry.iIndex=aIndex;
+	
+	TLinearOrder<TPathHash> order(CMTPMetaData::CompareTPathHash);
+	iPathHash.InsertInOrderAllowRepeats(entry, order);
+	}
+
+EXPORT_C TInt CMTPMetaData::CompareTPathHash(const TPathHash& aVal1, const TPathHash& aVal2)
+	{
+	return (aVal1.iHash>aVal2.iHash)?1:((aVal1.iHash==aVal2.iHash)?0:-1);
+	}
+
+EXPORT_C const RArray<CMTPMetaData::TPathHash>& CMTPMetaData::GetHashPathArray()
+	{
+	return iPathHash;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/src/cmtpobjectmetadata.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,221 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mtpprotocolconstants.h>
+    
+/**
+The element meta-data table content.
+*/
+const CMTPMetaData::TElementMetaData CMTPObjectMetaData::KElements[CMTPObjectMetaData::ENumElements] = 
+    {
+        {0, CMTPObjectMetaData::EUint}, // EDataProviderId
+        {1, CMTPObjectMetaData::EUint}, // EFormatCode
+        {2, CMTPObjectMetaData::EUint}, // EFormatSubCode
+        {3, CMTPObjectMetaData::EUint}, // EHandle
+        {4, CMTPObjectMetaData::EUint}, // EModes
+        {5, CMTPObjectMetaData::EUint}, // EParentHandle
+        {6, CMTPObjectMetaData::EUint}, // EStorageId
+        {7, CMTPObjectMetaData::EUint}, // EStorageVolumeId
+        {0, CMTPObjectMetaData::EDesC}, // ESuid
+        {8, CMTPObjectMetaData::EUint}, // EUserRating @deprecated 
+        {9, CMTPObjectMetaData::EUint}, // EBuyNow @deprecated 
+        {10, CMTPObjectMetaData::EUint}, // EPlayed @deprecated  
+        {11, CMTPObjectMetaData::EUint},// EIdentifier
+        //{0, CMTPObjectMetaData::EInt},// EParentId
+        {12, CMTPObjectMetaData::EUint},// ENonConsumable
+        {13, CMTPObjectMetaData::EUint},// EObjectMetaDataUpdate
+        {1, CMTPObjectMetaData::EDesC},// EName
+    };
+    
+/**
+MTP object manager meta-data factory method. This method creates an 
+empty object meta-data record.
+@return A pointer to a new CMTPObjectMetaData instance, ownership IS transferred.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C CMTPObjectMetaData* CMTPObjectMetaData::NewL()
+    {
+    CMTPObjectMetaData* self = CMTPObjectMetaData::NewLC();
+    CleanupStack::Pop(self); // self
+    return self;
+    }
+
+/**
+MTP object manager meta-data factory method. This method creates an 
+empty object meta-data record. A pointer to the meta-data is
+placed on the cleanup stack.
+@return A pointer to a new CMTPObjectMetaData instance, ownership IS transferred.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C CMTPObjectMetaData* CMTPObjectMetaData::NewLC()
+    {
+    CMTPObjectMetaData* self = new(ELeave) CMTPObjectMetaData();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+    
+/**
+MTP object manager meta-data factory method. 
+@param aDataProviderId The identifier of the data provider which owns the data 
+object.
+@param aFormatCode The MTP object format code of the data object.
+@param aStorageId The MTP storage ID of the storage media on which the data 
+object resides.
+@param aSuid A buffer containing the SUID of the data object.
+@return A pointer to a new CMTPObjectMetaData instance, ownership IS transferred.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C CMTPObjectMetaData* CMTPObjectMetaData::NewL(TUint aDataProviderId, TUint aFormatCode, TUint aStorageId, const TDesC& aSuid)
+    {
+    CMTPObjectMetaData* self = CMTPObjectMetaData::NewLC(aDataProviderId, aFormatCode, aStorageId, aSuid);
+    CleanupStack::Pop(self);
+    return self;
+    }
+    
+/**
+MTP object manager meta-data factory method. A pointer to the meta-data is 
+placed on the cleanup stack.
+@param aDataProviderId The identifier of the data provider which owns the data 
+object.
+@param aFormatCode The MTP object format code of the data object.
+@param aStorageId The MTP storage ID of the storage media on which the data 
+object resides.
+@param aSuid A buffer containing the SUID of the data object.
+@return A pointer to a new CMTPObjectMetaData instance, ownership IS transferred.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C CMTPObjectMetaData* CMTPObjectMetaData::NewLC(TUint aDataProviderId, TUint aFormatCode, TUint aStorageId, const TDesC& aSuid)
+    {
+    CMTPObjectMetaData* self = new(ELeave) CMTPObjectMetaData();
+    CleanupStack::PushL(self);
+    self->ConstructL(aDataProviderId, aFormatCode, aStorageId, aSuid);
+    return self;
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPObjectMetaData::~CMTPObjectMetaData()
+    {
+
+    } 
+
+/**
+Constructor.
+*/
+CMTPObjectMetaData::CMTPObjectMetaData() :
+    CMTPMetaData(KElements, ENumElements)
+    {
+    
+    }
+    
+/**
+Second phase constructor.
+@leave One of the system wide error code, if a processing failure occurs.
+*/
+void CMTPObjectMetaData::ConstructL()
+    {
+    CMTPMetaData::ConstructL();
+    SetUint(EParentHandle, KMTPHandleNoParent);
+    //SetInt(EParentId, KErrNotFound);
+    }
+    
+/**
+Second phase constructor.
+@param aDataProviderId The identifier of the data provider which owns the data 
+object.
+@param aFormatCode The MTP object format code of the data object.
+@param aStorageId The MTP storage ID of the storage media on which the data 
+object resides.
+@param aSuid A buffer containing the SUID of the data object.
+@leave One of the system wide error code, if a processing failure occurs.
+*/
+void CMTPObjectMetaData::ConstructL(TUint aDataProviderId, TUint aFormatCode, TUint aStorageId, const TDesC& aSuid)
+    {
+    ConstructL();
+    SetUint(EDataProviderId, aDataProviderId);
+    SetUint(EFormatCode, aFormatCode);
+    SetUint(EStorageId, aStorageId);
+    SetDesCL(ESuid, aSuid);
+    }
+    
+/**
+@deprecated
+Second phase constructor.
+@param aSuid A buffer containing the SUID of the data object.
+@param aUserRating  user rating of the data object.
+@param aBuyNow The MTP object BuyNow code of the data object.
+@param aPlayCount The MTP object aPlayCount code of the data object.
+@leave One of the system wide error code, if a processing failure occurs.
+*/
+void CMTPObjectMetaData::ConstructL(const TDesC& aSuid, TUint aUserRating, TUint aBuyNow, TUint aPlayCount)
+    {
+     ConstructL();
+
+     SetUint(EUserRating, aUserRating);
+     SetUint(EBuyNow, aBuyNow);
+     SetUint(EPlayCount, aPlayCount);
+     SetDesCL(ESuid, aSuid);
+    }
+
+/**
+@deprecated
+MTP object manager meta-data factory method.
+@param aSuid A buffer containing the SUID of the data object.
+@param aUserRating  user rating of the data object.
+@param aBuyNow The MTP object BuyNow code of the data object.
+@param aPlayCount The MTP object aPlayCount code of the data object.
+@return A pointer to a new CMTPObjectMetaData instance, ownership IS transferred.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C CMTPObjectMetaData* CMTPObjectMetaData::NewL(const TDesC& aSuid, TUint aUserRating, TUint aBuyNow, TUint aPlayCount)
+    {
+    CMTPObjectMetaData* self = CMTPObjectMetaData::NewLC(aSuid, aUserRating, aBuyNow, aPlayCount);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+@deprecated
+MTP object manager meta-data factory method. A pointer to the meta-data is 
+placed on the cleanup stack.
+@param aSuid A buffer containing the SUID of the data object.
+@param aUserRating  user rating of the data object.
+@param aBuyNow The MTP object BuyNow code of the data object.
+@param aPlayCount The MTP object aPlayCount code of the data object.
+@return A pointer to a new CMTPObjectMetaData instance, ownership IS transferred.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C CMTPObjectMetaData* CMTPObjectMetaData::NewLC(const TDesC& aSuid, TUint aUserRating, TUint aBuyNow, TUint aPlayCount)
+    {
+    CMTPObjectMetaData* self = new(ELeave) CMTPObjectMetaData();
+    CleanupStack::PushL(self);
+    self->ConstructL(aSuid, aUserRating, aBuyNow, aPlayCount);
+    return self;
+    }
+
+
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/src/cmtpstoragemetadata.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,144 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtpstoragemetadata.h>
+    
+/**
+The element meta-data table content.
+*/
+const CMTPMetaData::TElementMetaData CMTPStorageMetaData::KElements[CMTPStorageMetaData::ENumElements] = 
+    {
+        {0, CMTPStorageMetaData::EUint},        // EAttributes
+        {0, CMTPStorageMetaData::EDesCArray},   // EExcludedAreas
+        {1, CMTPStorageMetaData::EUint},        // EStorageId
+        {0, CMTPStorageMetaData::EUintArray},   // ELogicalIds
+        {0, CMTPStorageMetaData::EDesC},        // EStorageSuid
+        {2, CMTPStorageMetaData::EUint},        // EStorageSystemType
+    };
+    
+/**
+MTP storage meta-data factory method. This method creates an 
+empty storage meta-data record.
+@return A pointer to a new CMTPStorageMetaData instance, ownership IS transferred.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C CMTPStorageMetaData* CMTPStorageMetaData::NewL()
+    {
+    CMTPStorageMetaData* self = CMTPStorageMetaData::NewLC();
+    CleanupStack::Pop(self); // self
+    return self;
+    }
+
+/**
+MTP storage meta-data factory method. This method creates an 
+empty storage meta-data record. A pointer to the meta-data is placed on the 
+cleanup stack.
+@return A pointer to a new CMTPStorageMetaData instance, ownership IS transferred.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C CMTPStorageMetaData* CMTPStorageMetaData::NewLC()
+    {
+    CMTPStorageMetaData* self = new(ELeave) CMTPStorageMetaData();
+    CleanupStack::PushL(self);
+    self->CMTPMetaData::ConstructL();
+    return self;
+    }
+    
+/**
+MTP storage meta-data factory method. 
+@param aStorageSystemType The storage system type.
+@param aStorageSuid The storage System Unique IDentifier (SUID).
+@return A pointer to a new CMTPStorageMetaData instance, ownership IS transferred.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C CMTPStorageMetaData* CMTPStorageMetaData::NewL(TUint aStorageSystemType, const TDesC& aStorageSuid)
+    {
+    CMTPStorageMetaData* self = CMTPStorageMetaData::NewLC(aStorageSystemType, aStorageSuid);
+    CleanupStack::Pop(self);
+    return self;
+    }
+    
+/**
+MTP storage meta-data factory method. A pointer to the meta-data is 
+placed on the cleanup stack.
+@param aStorageSystemType The storage system type.
+@param aStorageSuid The storage System Unique IDentifier (SUID).
+@return A pointer to a new CMTPStorageMetaData instance, ownership IS transferred.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C CMTPStorageMetaData* CMTPStorageMetaData::NewLC(TUint aStorageSystemType, const TDesC& aStorageSuid)
+    {
+    CMTPStorageMetaData* self = new(ELeave) CMTPStorageMetaData();
+    CleanupStack::PushL(self);
+    self->ConstructL(aStorageSystemType, aStorageSuid);
+    return self;
+    }
+    
+/**
+MTP storage meta-data copy factory method. 
+@return A pointer to a new CMTPStorageMetaData instance, ownership IS transferred.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C CMTPStorageMetaData* CMTPStorageMetaData::NewL(const CMTPStorageMetaData& aStorage)
+    {
+    CMTPStorageMetaData* self = CMTPStorageMetaData::NewLC(aStorage);
+    CleanupStack::Pop(self);
+    return self;
+    }
+    
+/**
+MTP storage meta-data copy factory method. A pointer to the meta-data
+is placed on the cleanup stack.
+@param aStorage .
+@return A pointer to a new CMTPStorageMetaData instance, ownership IS transferred.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C CMTPStorageMetaData* CMTPStorageMetaData::NewLC(const CMTPStorageMetaData& aStorage)
+    {
+    CMTPStorageMetaData* self = new(ELeave) CMTPStorageMetaData();
+    CleanupStack::PushL(self);
+    self->CMTPMetaData::ConstructL(aStorage);
+    return self;
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPStorageMetaData::~CMTPStorageMetaData()
+    {
+
+    } 
+
+/**
+Constructor.
+*/
+CMTPStorageMetaData::CMTPStorageMetaData() :
+    CMTPMetaData(KElements, ENumElements)
+    {
+    
+    }
+    
+/**
+Second phase constructor.
+@param aStorageSystemType The storage system type.
+@param aStorageSuid The storage System Unique IDentifier (SUID).
+@leave One of the system wide error code, if a processing failure occurs.
+*/
+void CMTPStorageMetaData::ConstructL(TUint aStorageSystemType, const TDesC& aStorageSuid)
+    {
+    CMTPMetaData::ConstructL();
+    SetUint(EStorageSystemType, aStorageSystemType);
+    SetDesCL(EStorageSuid, aStorageSuid);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/src/mmtpdataprovider.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,43 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mmtpdataprovider.h>
+
+
+EXPORT_C void MMTPDataProvider::SupportedL(TMTPSupportCategory /*aCategory*/, CDesCArray& /*aStrings*/) const
+    {
+    
+    }
+
+EXPORT_C TAny* MMTPDataProvider::GetExtendedInterface(TUid /*aInterfaceUid*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C void MMTPDataProvider::StartObjectEnumerationL(TUint32 /*aStorageId*/)
+	{
+	_LIT(KMTPPanicCategory, "MMTPDataProvider");
+	User::Panic(KMTPPanicCategory, KErrNotSupported);
+	}
+
+EXPORT_C void MMTPDataProvider::StartObjectEnumerationL(TUint32 aStorageId, TBool /*aPersistentFullEnumeration*/)
+	{
+	StartObjectEnumerationL(aStorageId);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/src/mtpobjectmgrquerytypes.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,69 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <d32dbms.h>
+#include <mtp/mtpobjectmgrquerytypes.h>
+
+EXPORT_C TMTPObjectMgrQueryParams::TMTPObjectMgrQueryParams(TUint32 aStorageId, TUint32 aFormatCode, TUint32 aParentHandle, TUint32 aDpId) :
+    iStorageId(aStorageId),
+    iFormatCode(aFormatCode),
+    iParentHandle(aParentHandle),
+    iDpId(aDpId)
+    {
+    
+    }
+
+EXPORT_C RMTPObjectMgrQueryContext::RMTPObjectMgrQueryContext() :
+    iContext(NULL)
+    {
+    
+    }
+    
+EXPORT_C void RMTPObjectMgrQueryContext::Close()
+    {
+    if (iContext)
+        {
+        RDbView* view(reinterpret_cast<RDbView*>(iContext));
+        view->Close();
+        delete view;
+        iContext = NULL;
+        }
+    }
+    
+EXPORT_C TBool RMTPObjectMgrQueryContext::QueryComplete() const
+    {
+    return (!IsOpen());
+    }
+    
+EXPORT_C RDbView& RMTPObjectMgrQueryContext::DbView()
+    {
+    __ASSERT_DEBUG(iContext, User::Invariant());
+    return (*reinterpret_cast<RDbView*>(iContext));
+    }
+    
+EXPORT_C void RMTPObjectMgrQueryContext::OpenL()
+    {
+    iContext = reinterpret_cast<TAny*>(new(ELeave) RDbView);
+    }
+    
+EXPORT_C TBool RMTPObjectMgrQueryContext::IsOpen() const
+    {
+    return (iContext != NULL);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/src/mtpstoragemgrquerytypes.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,86 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/cmtpstoragemetadata.h>
+#include <mtp/mtpstoragemgrquerytypes.h>
+
+/**
+Default constructor.
+*/
+EXPORT_C TMTPStorageMgrQueryParams::TMTPStorageMgrQueryParams() :
+    iStorageSuid(KNullDesC),
+    iStorageSystemType(CMTPStorageMetaData::ESystemTypeUndefined)
+    {
+    
+    }
+
+/**
+Constructor.
+@param aStorageSuid The storage System Unique IDentifier (SUID). A value of 
+@see KNullDesC indicates that the query is targetting all storages.
+@param aStorageSystemType The storage system type. A value of 
+@see CMTPStorageMetaData::ESystemTypeUndefined indicates that the query is 
+targeting all storage systems
+*/
+EXPORT_C TMTPStorageMgrQueryParams::TMTPStorageMgrQueryParams(const TDesC& aStorageSuid, TUint32 aStorageSystemType) :
+    iStorageSuid(aStorageSuid),
+    iStorageSystemType(aStorageSystemType)
+    {
+    
+    }
+  
+/**
+Sets the storage System Unique IDentifier (SUID).
+@param aStorageSuid The storage System Unique IDentifier (SUID). A value of 
+@see KNullDesC indicates that the query is targetting all storages.
+*/
+EXPORT_C void TMTPStorageMgrQueryParams::SetStorageSuid(const TDesC& aStorageSuid)
+    {
+    iStorageSuid.Set(aStorageSuid);
+    }
+
+/**
+Sets the storage system type.
+@param aStorageSystemType The storage system type. A value of 
+@see CMTPStorageMetaData::ESystemTypeUndefined indicates that the query is 
+targeting all storage systems
+*/
+EXPORT_C void TMTPStorageMgrQueryParams::SetStorageSystemType(TUint32 aStorageSystemType)
+    {
+    iStorageSystemType = aStorageSystemType;
+    }
+  
+/**
+Provides the storage System Unique IDentifier (SUID).
+@param The storage SUID.
+*/
+EXPORT_C const TDesC& TMTPStorageMgrQueryParams::StorageSuid() const
+    {
+    return iStorageSuid;
+    }
+
+/**
+Provides the storage system type.
+@param The storage system type.
+*/
+EXPORT_C TUint32 TMTPStorageMgrQueryParams::StorageSystemType() const
+    {
+    return iStorageSystemType;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/devdpextn/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,29 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Media Transfer Protocol device data provider extension plugin
+// 
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+
+
+PRJ_EXPORTS
+
+
+PRJ_MMPFILES
+devdpextn.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/devdpextn/group/devdpextn.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,46 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @file
+// @SYMPurpose devdpextn.dll MTP device dp extension data provider plugin.
+// 
+//
+
+
+
+TARGET		  devdpextn.dll
+TARGETTYPE	  PLUGIN
+UID			  0x10009D8D 0x20010AD9 
+VENDORID 	  0x70000001
+
+CAPABILITY          CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData
+					
+USERINCLUDE	    ../inc
+USERINCLUDE	    ../../inc
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+SOURCEPATH	    ../src
+
+
+SOURCE		   implproxy.cpp cmtpextndevdpplugin.cpp
+
+
+
+LIBRARY		 euser.lib ecom.lib mtpdatatypes.lib mtpdevdpextnapi.lib //for cmtptypestring
+
+
+SOURCEPATH ../src
+START RESOURCE devdpextn.rss
+END
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/devdpextn/inc/cmtpextndevdpplugin.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,56 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+#ifndef CMTPEXTNDEVDPPLUGIN_H_
+#define CMTPEXTNDEVDPPLUGIN_H_
+
+#include <mtp/cmtpextndevdp.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/cmtptypedevicepropdesc.h>
+
+/*enum TMTPDeviceDpExtnSupportedProperties1 
+	{
+	0x5008,
+	
+	};*/
+
+
+class CDevDpReferncePlugin : public CMtpExtnDevicePropPlugin
+{
+public:
+	static CDevDpReferncePlugin* NewL();
+	void  ConstructL();
+	CDevDpReferncePlugin();
+	~CDevDpReferncePlugin();
+	TInt  GetDevPropertyL(const TMTPDevicePropertyCode aPropCode, MMTPType**) ;
+	TInt GetDevPropertyDescL (const TMTPDevicePropertyCode aPropCode, MMTPType**) ;
+	TInt GetDevicePropertyContainerL(TMTPDevicePropertyCode aPropCode, MMTPType**) ;
+	TMTPResponseCode SetDevicePropertyL();
+	TInt ResetDevPropertyL(const TMTPDevicePropertyCode aPropCode);
+	void Supported (TMTPSupportCategory aCategory, RArray <TUint>& aArray, TMTPOperationalMode aMode);
+
+
+private:
+	TMTPTypeUint32* iData;
+	CMTPTypeDevicePropDesc* iPropDesc;	
+	TMTPDevicePropertyCode iPropCode;
+};
+
+
+#endif /*CMTPEXTNDEVDPPLUGIN_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/devdpextn/src/cmtpextndevdpplugin.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,167 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+
+#include "cmtpextndevdpplugin.h"
+
+static const TInt KDefaultValue = 55;
+
+CDevDpReferncePlugin* CDevDpReferncePlugin::NewL()
+    {
+    CDevDpReferncePlugin* self = new(ELeave) CDevDpReferncePlugin;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+	void  CDevDpReferncePlugin::ConstructL()
+	{
+	iData = new(ELeave) TMTPTypeUint32();
+	}
+
+
+void CDevDpReferncePlugin::Supported(TMTPSupportCategory /*aCategory*/ ,RArray <TUint>& aArray, TMTPOperationalMode aMode)
+    {
+    if(KMTPModeMTP == aMode)
+        {
+        aArray.Append(EMTPDevicePropCodePlaybackObject );  // 0xD411,
+        }
+    }
+
+
+CDevDpReferncePlugin::CDevDpReferncePlugin()
+    {
+    }
+
+CDevDpReferncePlugin::~CDevDpReferncePlugin()
+     {
+     delete iData;
+     delete iPropDesc;
+     }
+
+/**
+ returns the default value
+*/
+TInt  CDevDpReferncePlugin::GetDevPropertyL (const TMTPDevicePropertyCode aPropCode, MMTPType** aMMTPType)
+    {
+    TInt errorCode = KErrNone;
+    switch(aPropCode)
+        {
+        case EMTPDevicePropCodePlaybackObject:
+			iData->Set(KDefaultValue);
+			*aMMTPType = iData;
+        break;
+        default:
+            errorCode = KErrNotFound;
+        break;
+        }
+    return errorCode;
+    }
+
+TInt  CDevDpReferncePlugin::GetDevPropertyDescL (const TMTPDevicePropertyCode aPropCode, MMTPType**  aMMTPType)
+    {
+    TInt errorCode = KErrNone;
+
+    switch (aPropCode)
+        {
+        case EMTPDevicePropCodePlaybackObject:
+        	delete iPropDesc;
+			iPropDesc = NULL;
+			iPropDesc = CMTPTypeDevicePropDesc::NewL(EMTPDevicePropCodePlaybackObject, 1, 0, NULL);
+			iPropDesc->SetUint32L(CMTPTypeDevicePropDesc::EFactoryDefaultValue, 0);
+	    	iPropDesc->SetUint32L(CMTPTypeDevicePropDesc::ECurrentValue, 1);
+			*aMMTPType = iPropDesc;
+        break;
+        default:
+            errorCode = KErrNotFound;
+        break;
+        }
+    return errorCode;
+    }
+/**
+called from ServiceL allocates the container for receiving data.
+*/
+TInt  CDevDpReferncePlugin::GetDevicePropertyContainerL(TMTPDevicePropertyCode aPropCode, MMTPType** aMmtpType)
+    {
+    TInt errorCode = KErrNone;
+    iPropCode = aPropCode;
+    switch (aPropCode)
+        {
+        case EMTPDevicePropCodePlaybackObject:
+            {
+            *aMmtpType = iData;
+            }
+        break;
+
+        default:
+            errorCode = KErrNotFound;
+        break;
+        }
+    return errorCode;
+    }
+
+
+TMTPResponseCode CDevDpReferncePlugin::SetDevicePropertyL()
+    {
+    TInt errorCode = KErrNone;
+    switch (iPropCode)
+        {
+        case EMTPDevicePropCodePlaybackObject:
+            {
+             //if  extension plugin supports more than one property. then add member a variable to 
+   			 //store the incoming value in it.
+             TUint int1 = (iData->Value());
+            }
+        break;
+
+        default:
+        errorCode = KErrNotFound;
+        break;
+        }
+
+	  if(errorCode == KErrNone)
+	 	 {
+	     return EMTPRespCodeOK;
+	  	}
+	  else
+	 	{
+	    return EMTPRespCodeOperationNotSupported;
+	  	}
+    }
+
+
+TInt CDevDpReferncePlugin::ResetDevPropertyL(TMTPDevicePropertyCode aPropCode)
+    {
+    TInt errorCode = KErrNone;
+    switch (aPropCode)
+        {
+        case EMTPDevicePropCodePlaybackObject:
+            {
+            	iData->Set(KDefaultValue);// setting to default value
+            }
+            break;
+           default:
+            errorCode = KErrNotFound;
+            break;
+        }
+    return errorCode;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/devdpextn/src/devdpextn.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,40 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mtpdevicedp.rss
+// 
+//
+
+#include <ecom/registryinfo.rh>
+RESOURCE REGISTRY_INFO theinfo
+{
+	dll_uid = 0x20010AD9;
+	interfaces =
+		{
+			INTERFACE_INFO
+			{
+			interface_uid = 0x20010ADA;//uid for interface
+			implementations=
+					{
+						IMPLEMENTATION_INFO
+						{
+							implementation_uid = 0x20010ADB;// uid for plugin 1
+							version_no = 1;
+							display_name = "plugin1";
+							default_data = "plug1";
+							opaque_data ="";
+						}
+				};
+			}
+		};
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/devdpextn/src/implproxy.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,34 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <ecom/implementationproxy.h>
+#include "cmtpextndevdpplugin.h"
+
+static const TImplementationProxy ImplementationTable[] =
+	{
+		{
+	       {0x20010ADB}, (TProxyNewLPtr)(CDevDpReferncePlugin::NewL)
+		          
+		}
+	};
+	
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+	{
+	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+	return ImplementationTable;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/devdpextnapi/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,32 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// bld.inf for mtpdevdpextnapi
+// Media Transfer Protocol device data provider extension plugin api
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+
+
+PRJ_EXPORTS
+../interface/mmtpdevdpextn.h              SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mmtpdevdpextn.h)  
+../interface/cmtpextndevdp.h              SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtpextndevdp.h)
+
+
+PRJ_MMPFILES 
+mtpdevdpextnapi.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/devdpextnapi/group/mtpdevdpextnapi.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,45 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mtpdevdpextnapi.dll MTP device dp extension data provider API.
+// 
+//
+
+/**
+ @file
+*/
+
+TARGET              mtpdevdpextnapi.dll
+TARGETTYPE          DLL
+UID                 0x1000008D 0x20010ADE
+VENDORID 	        0x70000001
+
+CAPABILITY          CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData
+
+//CAPABILITY ALL - TCB
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+USERINCLUDE         ../interface
+USERINCLUDE         ../../inc
+
+SOURCEPATH          ../src 
+SOURCE              cmtpdevdpextn.cpp
+
+
+
+LIBRARY             ecom.lib
+LIBRARY             euser.lib
+
+
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/devdpextnapi/interface/cmtpextndevdp.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,87 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Defines the MTP Device dp extension data provider ECOM plug-in service provider 
+// interface.
+// 
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef CMTPDEVDPEXTN_H
+#define CMTPDEVDPEXTN_H
+
+#include <e32debug.h>
+#include <mtp/mtpdataproviderapitypes.h>
+#include <mtp/mmtpdevdpextn.h>
+#include <mtp/mmtpdataproviderframework.h>
+
+class MExtnDevPluginCallback;
+	
+/** 
+Those who are implementing "MExtnDevicePropDp" interface as ecom plugin,
+should use 0x20010ADA as the interface UID in ECOM resource file.
+*/
+const TUid KMTPExtnDevDpPluginInterfaceUid = {0x20010ADA};
+
+
+class CMtpExtnDevicePropPlugin : public CBase, public MExtnDevicePropDp
+{
+
+public:
+/**
+loads the plugin having implementation uid as aUid 
+*/
+	IMPORT_C static CMtpExtnDevicePropPlugin* NewL(TUid aUid );
+
+	IMPORT_C ~CMtpExtnDevicePropPlugin();
+
+	IMPORT_C TInt  GetDevPropertyL (const TMTPDevicePropertyCode /*aPropCode*/, MMTPType**);
+
+	IMPORT_C TInt GetDevPropertyDescL (const TMTPDevicePropertyCode /*aPropCode*/, MMTPType**);
+
+	IMPORT_C TInt GetDevicePropertyContainerL(TMTPDevicePropertyCode /*aPropCode*/, MMTPType**);
+
+	IMPORT_C TMTPResponseCode SetDevicePropertyL();
+
+	IMPORT_C void Supported (TMTPSupportCategory /*aCategory*/, RArray <TUint>& /*aArray*/ ,TMTPOperationalMode /*aMode*/);
+
+	IMPORT_C TInt ResetDevPropertyL(const TMTPDevicePropertyCode aPropCode);
+
+
+	IMPORT_C void SetCallback(MExtnDevPluginCallback& aExtnDevPluginCallback);
+
+	IMPORT_C void NotifyOnDevicePropertyChanged (TMTPDevicePropertyCode& aPropCode);
+
+	/**
+	* This method return mtpframework
+	*/
+	IMPORT_C MMTPDataProviderFramework& Framework( ) const;
+ 
+private:
+	MExtnDevPluginCallback* iExtnDevPluginCallback;
+
+	TUid                        iDtorIdKey;
+};
+
+#endif //
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/devdpextnapi/interface/mmtpdevdpextn.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,83 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+#ifndef MMTPDEVDPEXTN_H_
+#define MMTPDEVDPEXTN_H_
+
+#include <e32base.h>
+#include <e32cons.h>
+#include <e32cmn.h>
+#include <ecom/ecom.h>
+#include <mtp/mtpdataproviderapitypes.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mtpprotocolconstants.h>
+
+
+class MExtnDevicePropDp
+{
+public:
+/**
+This interface method is designed to implement GetDevicePropValue (Operation Code EMTPOpCodeGetDevicePropValue).
+This operation returns the current value of the particular device property.
+@param aPropCode : device property code eg: PlaybackObject(D411)
+@param aMMTPtype : out param memory need to be allocated by the implementation.
+				   Owner ship of this param should be with allocator.
+*/
+virtual TInt GetDevPropertyL(const TMTPDevicePropertyCode aPropCode, MMTPType** aMMTPtype) = 0;
+
+
+/**
+This interface method is designed to implement GetDevicePropDesc (Operation Code EMTPOpCodeGetDevicePropDesc).
+This operation returns the current property desc of the particular device property.
+@param aPropCode : device property code eg: PlaybackObject(D411)
+@param aMMTPtype : out param memory need to be allocated by the implementation.
+				   Owner ship of this param should be with allocator.
+*/
+virtual TInt GetDevPropertyDescL(const TMTPDevicePropertyCode aPropCode, MMTPType** aMMTPtype) = 0;
+
+/**
+@param aMMTPtype : out param memory need to be allocated by the implementation.
+				   Owner ship of this param should be with allocator.
+SetDevicePropertyL function uses the allocated memory to set the device property when 
+a EMTPOpCodeSetDevicePropValue operation code comes.				   
+
+*/
+virtual TInt GetDevicePropertyContainerL(TMTPDevicePropertyCode aPropCode, MMTPType** aMMTPtype) = 0;
+
+/**
+This method sets the device property implemented by extension plugin.
+*/
+virtual TMTPResponseCode SetDevicePropertyL() = 0;
+
+/**
+This method returns the supported properties by extension plugin.
+*/
+virtual void Supported (TMTPSupportCategory aCategory, RArray <TUint>& aArray, TMTPOperationalMode aMode) = 0;
+
+/**
+This interface method is designed to implement RessetDevicePropValue. 
+@param aPropCode : device property code .
+*/
+virtual TInt ResetDevPropertyL(const TMTPDevicePropertyCode aPropCode) = 0;
+
+};
+
+
+#endif /*MMTPDEVDPEXTN_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/devdpextnapi/src/cmtpdevdpextn.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,79 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "cmtpextndevdp.h"
+#include "mextndevplugincallback.h"
+
+EXPORT_C TInt  CMtpExtnDevicePropPlugin::GetDevPropertyL (const TMTPDevicePropertyCode /*aPropCode*/, MMTPType**)
+	{
+	return KErrNotSupported;
+	}
+
+EXPORT_C TInt CMtpExtnDevicePropPlugin::GetDevPropertyDescL (const TMTPDevicePropertyCode /*aPropCode*/, MMTPType**)
+	{
+	return KErrNotSupported;
+	}
+ 
+EXPORT_C TInt CMtpExtnDevicePropPlugin::GetDevicePropertyContainerL(TMTPDevicePropertyCode /*aPropCode*/, MMTPType**)
+	 {
+	 return KErrNotSupported;	
+	 }
+
+EXPORT_C TMTPResponseCode CMtpExtnDevicePropPlugin::SetDevicePropertyL()
+	{
+	return EMTPRespCodeDevicePropNotSupported;
+	}
+ 
+EXPORT_C void CMtpExtnDevicePropPlugin::Supported (TMTPSupportCategory /*aCategory*/, RArray <TUint>& /*aArray*/ ,TMTPOperationalMode /*aMode*/)
+	{
+	return;
+	}
+ 
+EXPORT_C TInt CMtpExtnDevicePropPlugin::ResetDevPropertyL(const TMTPDevicePropertyCode /*aPropCode*/)
+	{
+	return KErrNotSupported;
+	}
+
+EXPORT_C CMtpExtnDevicePropPlugin* CMtpExtnDevicePropPlugin::NewL(TUid aUid )
+	{
+	CMtpExtnDevicePropPlugin* self = reinterpret_cast<CMtpExtnDevicePropPlugin*>(
+	REComSession::CreateImplementationL(aUid, _FOFF(CMtpExtnDevicePropPlugin, iDtorIdKey))); 
+	return self; 
+	}
+
+EXPORT_C  CMtpExtnDevicePropPlugin::~CMtpExtnDevicePropPlugin()
+	{
+	REComSession::DestroyedImplementation (iDtorIdKey);
+	}
+	
+EXPORT_C void CMtpExtnDevicePropPlugin::SetCallback(MExtnDevPluginCallback& aExtnDevPluginCallback)
+	{
+	iExtnDevPluginCallback = &aExtnDevPluginCallback;
+	}
+	
+EXPORT_C void CMtpExtnDevicePropPlugin::NotifyOnDevicePropertyChanged (TMTPDevicePropertyCode& aPropCode)
+	{
+	TRAP_IGNORE(iExtnDevPluginCallback->OnDevicePropertyChangedL (aPropCode));	
+	}
+
+	/**
+	* This method return mtpframework
+	*/
+EXPORT_C MMTPDataProviderFramework& CMtpExtnDevicePropPlugin::Framework ( ) const
+	{
+        	//RDebug::Printf(" data provider id is %d", );
+	return iExtnDevPluginCallback->DataProviderFramework();
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,39 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// bld.inf for mtpdevicedp
+// Media Transfer Protocol device data provider
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+#ifdef SYMBIAN_OLD_EXPORT_LOCATION
+../inc/mextndevplugincallback.h
+#endif
+
+mtpdevice.ico /epoc32/data/z/private/102827a2/mtpdevice.ico
+mtpdevice.ico /epoc32/winscw/c/private/102827a2/mtpdevice.ico
+../inc/mtpdevicedp_config.rh SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mtpdevicedp_config.rh)
+
+mtp_devicedp.iby   /epoc32/rom/include/mtp_devicedp.iby
+
+PRJ_MMPFILES 
+mtpdevicedp.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/group/mtp_devicedp.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -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 MTP_DEVICEDP_IBY
+#define MTP_DEVICEDP_IBY
+
+#if !defined(SYMBIAN_EXCLUDE_MTP)
+
+
+// MTP Device Data Provider
+ECOM_PLUGIN(mtpdevicedp.dll, mtpdevicedp.rsc)
+
+// MTP plugin registration resource file
+data=EPOCROOT##epoc32\data\Z\resource\mtp\102827AF.rsc  resource\mtp\102827AF.rsc 
+
+
+
+
+
+#endif //SYMBIAN_EXCLUDE_MTP
+
+#endif  //MTP_DEVICEDP_IBY
Binary file mtpfws/mtpfw/dataproviders/devdp/group/mtpdevice.ico has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/group/mtpdevicedp.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,91 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <comms-infras/commsdebugutility.mmh>
+
+TARGET              mtpdevicedp.dll
+TARGETTYPE          PLUGIN
+UID                 0x10009D8D 0x102827A4
+VENDORID            0x70000001
+
+CAPABILITY          CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+USERINCLUDE         ../inc
+USERINCLUDE         ../../dputility/inc
+USERINCLUDE         ../../../common/inc 
+USERINCLUDE         ../../../inc
+USERINCLUDE         ../../../transports/transportapi/inc
+USERINCLUDE         ../devdpextnapi/interface
+
+SOURCEPATH          ../src 
+SOURCE              cmtpclosesession.cpp
+SOURCE				cmtpdevdpexclusionmgr.cpp
+SOURCE              cmtpdevicedatastore.cpp
+SOURCE              cmtpdevicedp.cpp
+SOURCE              cmtpdevicedpconfigmgr.cpp
+SOURCE 				cmtpdevrequestunknown.cpp
+SOURCE 				cmtpgetdeviceinfo.cpp
+SOURCE 				cmtpgetdevicepropdesc.cpp
+SOURCE 				cmtpgetdevicepropvalue.cpp
+SOURCE 				cmtpgetnumobjects.cpp
+SOURCE 				cmtpgetobjecthandles.cpp
+SOURCE 				cmtpgetstorageids.cpp
+SOURCE 				cmtpgetstorageinfo.cpp
+SOURCE 				cmtpopensession.cpp
+SOURCE 				cmtpresetdevice.cpp
+SOURCE 				cmtpsetdevicepropvalue.cpp
+SOURCE              cmtpstoragewatcher.cpp
+SOURCE          	cmtptypedeviceinfo.cpp
+SOURCE              mtpdevicedpimplementations.cpp
+SOURCE              mtpdevicedpprocessor.cpp
+SOURCE              rmtpdevicedpsingletons.cpp 
+SOURCE              cmtpdevdpextnmap.cpp
+SOURCE              cmtpresetdevicepropvalue.cpp 
+SOURCE				cmtpgetserviceinfo.cpp 
+SOURCE				cmtpgetserviceids.cpp 
+
+
+
+SOURCEPATH          ../src 
+START RESOURCE      mtpdevicedp.rss    
+TARGET              mtpdevicedp.rsc
+END
+
+// Data provider configuration resource file. 
+// The target filename corresponds to the implementation UID.
+START RESOURCE      mtpdevicedp_config.rss
+HEADER   
+TARGETPATH          /resource/mtp
+TARGET              102827af.rsc
+END
+
+LIBRARY             bafl.lib
+LIBRARY             efsrv.lib
+LIBRARY             etel3rdparty.lib 
+LIBRARY             estor.lib 
+LIBRARY             euser.lib
+LIBRARY             hal.lib 
+LIBRARY             edbms.lib
+LIBRARY      		centralrepository.lib
+
+LIBRARY             mtpdatatypes.lib
+LIBRARY             mtpdataproviderapi.lib
+LIBRARY             mtpframework.lib
+LIBRARY		        tzclient.lib 
+LIBRARY             mtpdataproviderutility.lib 
+LIBRARY             ecom.lib 
+LIBRARY             mtpdevdpextnapi.lib
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpclosesession.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,56 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPCLOSESESSION_H
+#define CMTPCLOSESESSION_H
+
+#include "cmtprequestprocessor.h"
+#include "rmtpframework.h"
+
+/** 
+Implements the device data provider CloseSession request processor
+@internalComponent
+*/
+class CMTPCloseSession : public CMTPRequestProcessor
+	{
+public:
+
+	static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);	
+	~CMTPCloseSession();
+
+private: // From CMTPRequestProcessor
+
+	TMTPResponseCode CheckRequestL();
+	void ServiceL();	
+	
+private:	
+
+	CMTPCloseSession(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+	void ConstructL();
+
+	void RemoveSessionL(TUint32 aSessionId);
+	
+private:
+
+    RMTPFramework iSingletons;
+	};
+	
+#endif // CMTPCLOSESESSION_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevdpexclusionmgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,47 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPDEVDPEXCLUSIONMGR_H
+#define CMTPDEVDPEXCLUSIONMGR_H
+
+#include <e32base.h>
+#include "cmtpfsexclusionmgr.h"
+
+/** 
+@internalTechnology
+*/
+class CMTPDevDpExclusionMgr :
+	public CMTPFSExclusionMgr
+	{
+public:
+	static CMTPDevDpExclusionMgr* NewL(MMTPDataProviderFramework& aFramework);
+	~CMTPDevDpExclusionMgr();
+	
+	// CMTPFSExclusionMgr
+	TBool IsFileAcceptedL(const TDesC& aFileName, TUint32 aStorageID) const;
+	TBool IsFormatValid(TMTPFormatCode aFormat) const;
+	TBool IsExtensionValid(const TDesC& aExtension) const;
+    
+protected:
+	CMTPDevDpExclusionMgr(MMTPDataProviderFramework& aFramework);
+
+	};
+	
+#endif // CMTPDEVDPEXCLUSIONMGR_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevdpextnmap.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,41 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+#include "cmtpextndevdp.h"
+
+#ifndef CMTPDEVDPEXTNMAP_H
+#define CMTPDEVDPEXTNMAP_H
+
+
+  class  CDevDpExtnPluginMap : public CBase
+  {
+  public:
+  static	CDevDpExtnPluginMap* NewL(MExtnDevPluginCallback& aDevdp, TUid aUid);
+  	void ConstructL(MExtnDevPluginCallback& aDevdp, TUid aUid);
+  	virtual ~CDevDpExtnPluginMap();
+  	void SetExtPlugin(CMtpExtnDevicePropPlugin* aPlugin);
+  	CMtpExtnDevicePropPlugin* ExtPlugin();
+  	RArray<TUint>* SupportedOpCodes();
+  private:	
+  	RArray<TUint> iSupportedOpCodes;
+  	CMtpExtnDevicePropPlugin* iPlugin;// MExtnDevicePropDp
+  	
+  };
+  
+  #endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevicedatastore.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,172 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPDEVICEDATASTORE_H
+#define CMTPDEVICEDATASTORE_H
+
+#include <e32base.h>
+#include <etel3rdparty.h>
+#include <mtp/tmtptypeuint32.h>
+#include <mtp/cmtptypearray.h>
+
+#include "mtpdebug.h"
+#include "rmtpframework.h"
+#include "mmtpdevdpextn.h"
+#include"cmtpextndevdp.h"
+
+class CMTPTypeString;
+class MMTPEnumerationCallback;
+class RFs;
+class RReadStream;
+class RWriteStream;
+
+/** 
+Implements the MTP device data provider's device information data store.
+@internalComponent
+*/
+class CMTPDeviceDataStore : public CActive
+   {    
+
+public:
+
+    static CMTPDeviceDataStore* NewL();
+    ~CMTPDeviceDataStore();
+    
+    TBool RequestPending() const; 
+	void BatteryLevelL(TRequestStatus& aStatus, TUint& aBatteryLevel);
+    const TDesC& DeviceFriendlyName() const;
+    const TDesC& DeviceFriendlyNameDefault() const;
+    const TDesC& DeviceVersion() const;
+    const TDesC& Manufacturer() const;
+    const TDesC& Model() const;
+    const TDesC& MTPExtensions() const;
+    const TDesC& SerialNumber() const;
+    const TDesC& SynchronisationPartner() const;
+    const TDesC& SynchronisationPartnerDefault() const;
+    
+    void SetDeviceFriendlyNameL(const TDesC& aName);
+    void SetSynchronisationPartnerL(const TDesC& aName);
+    
+    void StartEnumerationL(TUint32 aStorageId, MMTPEnumerationCallback& aCallback);
+    const TDesC& SessionInitiatorVersionInfo() const;
+    const TDesC& SessionInitiatorVersionInfoDefault() const;
+    void SetSessionInitiatorVersionInfoL(const TDesC& aName);
+    TUint32 PerceivedDeviceTypeDefault() const;
+    TUint32 PerceivedDeviceType() const;
+    const TDesC& DateTimeL();
+    TInt SetDateTimeL(const TDesC& aDateTime );    
+    void DateTimeToStringL(TDes& aDateTime);
+    void StringToDateTime(TDes& aDateTime );
+    void LoadDeviceIconL();
+    const CMTPTypeArray& DeviceIcon();
+    TInt ValidateString(const TDesC& aDateTimeStr, TDes& aDateTime, TInt &aOffsetVal);
+
+	
+
+	/*utility methods */
+	void SetSupportedDevicePropertiesL(RArray<TUint> &aSupportedDevProps);
+	const CMTPTypeArray & GetSupportedDeviceProperties();	
+	void SetExtnDevicePropDp(MExtnDevicePropDp* aExtnDevicePropDp);
+	MExtnDevicePropDp* ExtnDevicePropDp();
+
+private: // Form CActive
+
+    void DoCancel();
+    TInt RunError(TInt aError);
+    void RunL();
+    void CheckDeviceIconProperties( RArray<TUint> &aSupportedDeviceProperties);
+    
+private:
+
+    CMTPDeviceDataStore();
+    void ConstructL();
+
+    TBool Enumerated() const;
+    void ExternalizeL(RWriteStream& aWriteStream) const;
+    void InternalizeL(RReadStream& aReadStream);
+    const TDesC& PropertyStoreName();
+    void AppendMTPExtensionSetsL(TBool& aCompleted);
+    void RestoreL();
+    void Schedule(TInt32 aState);
+    void SetRequestComplete(TRequestStatus& aRequest, TUint aErr);
+    void SetRequestPending(TRequestStatus& aRequest);
+    void SetState(TInt32 aState);
+    TInt32 State() const;
+    void StoreL();
+    void StoreFormattedSerialNumber(const TDesC& aSerialNo);
+    
+private: // Owned
+
+    enum TState    
+        {
+        EUndefined                      = 0x00000000,
+        EEnumeratingDevicePropertyStore = 0x00000001,
+        EEnumeratingDeviceVersion       = 0x00000002,
+        EEnumeratingPhoneId             = 0x00000003,
+        EEnumeratingBatteryLevel        = 0x00000004,
+        EEnumeratingVendorExtensions	= 0x00000005,
+        EEnumerated                     = 0x80000000,
+        EEnumeratedBatteryLevel         = 0x80000004,
+        };
+    
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+    CTelephony::TBatteryInfoV1 		iBatteryInfoV1;
+    CTelephony::TBatteryInfoV1Pckg  iBatteryInfoV1Pckg;  
+    CMTPTypeString*                 iDeviceFriendlyName;
+    RBuf                            iDeviceVersion;
+    RMTPFramework                   iSingletons;
+    RBuf                			iMTPExtensions; 
+    CTelephony::TPhoneIdV1          iPhoneIdV1;
+    CTelephony::TPhoneIdV1Pckg      iPhoneIdV1Pckg; 
+    TFileName                       iPropertyStoreName;  
+    RBuf                            iSerialNumber;
+    TInt32                          iState;
+    TUint32                         iStorageId;
+    CMTPTypeString*                 iSynchronisationPartner; 
+    CTelephony*                     iTelephony;
+    HBufC*							iDeviceFriendlyNameDefault;
+    HBufC*							iSyncPartnerNameDefault;
+    TInt							iCurrentDpIndex;
+    //HBufC*						iSessionInitiatorVersionInfoDefault;
+    CMTPTypeString*  				iSessionInitiatorVersionInfo;
+    TMTPTypeUint32  				iPerceivedDeviceType;
+    CMTPTypeString*  				iDateTime;
+    CMTPTypeArray*  				iDeviceIcon; 
+
+    // this array is to store all supported device properties.
+    CMTPTypeArray*                                   iSupportedDevProArray;
+    TUint8			iFormatOreder; 
+    
+private: // Not owned.
+
+    MMTPEnumerationCallback* 	    iCallback;
+    TRequestStatus*                 iPendingStatus;
+    TUint*                          iPendingBatteryLevel;
+    
+    MExtnDevicePropDp*              iExtnDevicePropDp;
+    };
+   
+#endif // CMTPDEVICEDATASTORE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevicedp.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,168 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPDEVICEDP_H
+#define CMTPDEVICEDP_H
+
+#include <mtp/cmtpdataproviderplugin.h>
+#include "mtpdebug.h"
+#include "mmtpenumerationcallback.h"
+#include "rmtpdevicedpsingletons.h"
+#include "rmtpdpsingletons.h"
+#include "mextndevplugincallback.h"
+#include "mmtpdevdpextn.h"
+
+#include "cmtpgetdevicepropdesc.h"
+#include "cmtpdevicedatastore.h"
+#include "cmtpdevdpextnmap.h"
+#include <mtp/tmtptypeevent.h>
+
+class CMTPDevDpExclusionMgr;
+class CMTPFSEnumerator;
+class CMTPStorageWatcher;
+class MMTPRequestProcessor;
+class CMtpExtnDevicePropPlugin;
+class CMTPDeviceDataStore;
+
+/** 
+Implements the MTP device data provider plug-in.
+@internalComponent
+*/
+class CMTPDeviceDataProvider : 
+	public CMTPDataProviderPlugin,
+	public MMTPEnumerationCallback , public MExtnDevPluginCallback
+    {
+private:
+	enum TEnumerationState
+		{
+		EUndefined,
+		EEnumeratingDeviceDataStore,
+		EEnumeratingFolders,
+		EEnumerationComplete,
+		};
+    
+public:
+
+    static TAny* NewL(TAny* aParams);
+    ~CMTPDeviceDataProvider();
+    
+private: // From CMTPDataProviderPlugin
+
+    void Cancel();
+    void ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection);
+    void ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams);
+    void ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    void StartObjectEnumerationL(TUint32 aStorageId, TBool aPersistentFullEnumeration);
+    void StartStorageEnumerationL();
+    void Supported(TMTPSupportCategory aCategory, RArray<TUint>& aArray) const;
+
+private: // MMTPEnumerationCallback
+
+	void NotifyEnumerationCompleteL(TUint32 aStorageId, TInt aError);
+
+private:
+    
+    CMTPDeviceDataProvider(TAny* aParams);
+    void ConstructL();
+    
+    TInt LocateRequestProcessorL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    TInt LocateRequestProcessorL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection);    
+    void SessionClosedL(const TMTPNotificationParamsSessionChange& aSession);
+    void SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession);
+    TInt FindExtnPlugin(TUint aOpcode);
+    void LoadExtnPluginsL();
+   
+   public:
+    //from MExtnDevPluginCallback
+    void OnDevicePropertyChangedL (TMTPDevicePropertyCode& aPropCode);
+	
+    /**
+      * This method return reference MMTPDataProviderFramework
+      */
+    MMTPDataProviderFramework& DataProviderFramework ();
+    
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+    /**
+    The active request processors table. Multiple request processors may be 
+    active in a multi-session MTP environment.
+    */
+    RPointerArray<MMTPRequestProcessor> iActiveProcessors;
+    
+    /**
+    The device DP singletons.
+    */
+    RMTPDeviceDpSingletons              iDevDpSingletons;
+    
+    /**
+    The dp utilities singleton.
+    */
+    RMTPDpSingletons					iDpSingletons;
+    
+    /**
+    The device dp object enumeration state.
+    */
+    TEnumerationState					iEnumeratingState;
+    
+    /**
+    The device dp folder enumerator.
+    */
+    CMTPFSEnumerator*					iEnumerator;
+    
+    /**
+    The device dp exlusion manager. 
+    */
+    CMTPDevDpExclusionMgr*				iExclusionMgr;
+    
+    /**
+    The list of storages to be enumerated.
+    */	
+    RArray<TUint32>                     iPendingEnumerations;
+    
+    /**
+    The system storages watcher.
+    */
+    CMTPStorageWatcher*                 iStorageWatcher;
+    
+    /**
+    The device Dp extension plugin map array.
+    */   
+    RPointerArray<CDevDpExtnPluginMap> iExtnPluginMapArray;//2113
+  
+    /**
+    The event dataset.
+    */     
+    TMTPTypeEvent                   iEvent;
+    
+    //not owned by this class
+    CMTPDeviceDataStore *iPtrDataStore;
+    
+    TInt								iActiveProcessor;
+    TBool								iActiveProcessorRemoved;
+
+   
+    };
+    
+#endif // CMTPDEVICEDP_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevicedpconfigmgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,135 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPDEVICEDPCONFIGMGR_H
+#define CMTPDEVICEDPCONFIGMGR_H
+
+#include <e32base.h>
+#include <badesca.h>
+
+#include "mtpdebug.h"
+#include "mtpdevicedpconst.h"
+
+class MMTPDataProviderFramework;
+
+class CMTPDeviceDpConfigMgr : 
+	public CBase
+	{
+public:
+	enum TParameter
+	    {
+    	/**
+	    The set of folders containing data objects which are not exposed by the 
+   		MTP protocol and which are excluded from the file data provider's 
+    	object enumeration process. Each folder should be specified using format 
+    	acceptable to the TDesC Match function. To exclude entries on a specific drive
+    	use a format prefixed by the drive letter (e.g by specifiying C:\dir\*).
+
+    	Excluded folder specifications do not need to include a trailing backslash 
+    	("\"). Any trailing backslash which is present will be ignored.
+
+    	The exclusion list does not prohibit the root folder of a drive from being 
+    	specified (e.g. by specifying "K:\\*"). If specified this has the effect of
+    	excluding all folders and data objects on the specified drive. To prevent 
+    	objects being added to the device and then not being visible to the MTP 
+    	initiator that created them, any attempt by an MTP initiator to write 
+    	data (SendObject) to an excluded root folder will be rejected with an 
+    	"Access Denied" MTP response code.
+    	*/
+    	EFolderExclusionList,
+ 
+    	/**
+    	The maximum number of data objects that are enumerated on each 
+    	iteration of the file data provider's object enumerator.
+    	
+    	Setting this to an appropriate number will reduce the running time of the
+    	enumerator ActiveObject RunL as to allow other ActiveObjects to run. 
+    	The downside is that the enumerator will take longer to iterate over 
+    	directory entries due less objects being added in each RunL call.
+    	
+    	Setting this to a larger number will increase the running time of the
+    	enumerator ActiveObject RunL decreasing total enumerator running time but
+    	potentially starving out other ActiveObjects.
+    	*/
+    	EEnumerationIterationLength,
+    	};
+	
+public:
+	static CMTPDeviceDpConfigMgr* NewL(MMTPDataProviderFramework& aFramework);
+	~CMTPDeviceDpConfigMgr();
+	
+	TUint UintValueL(TParameter aParam) const;
+	CDesCArray* GetArrayValueL(TParameter aParam) const;
+	
+	/**
+	  *This method is to get friendly name for a particular drive/volume.
+	  *
+	  *@param aDriveNo : drive in which friendly name is needed.
+	  *@param aVolumeName : out param for friendly name, it is read
+	  * from mtpdevicedp_config.rss file
+	  */
+	void GetFriendlyVolumeNameL(TInt aDriveNo, TDes& aVolumeName);
+
+	/**
+	  *This method is to get root dir path for a particular drive/volume.
+	  *
+	  *@param aDriveNo : drive in which root dir path is needed.
+	  *@param aRootDirPath : out param for root dir path, it is read
+	  * from mtpdevicedp_config.rss file
+	  */
+	void GetRootDirPathL(TInt aDriveNo, TDes& aRootDirPath);
+	
+	/**
+	  *This method is to get the ordered format from the rss file
+	  *
+	  *@param aOrderInfoArray : is an array for storing ordered formats(out param).
+	  * 
+	  */
+    void GetRssConfigInfoArrayL(RArray<TUint>& aOrderInfoArray, TDevDPConfigRSSParams aParam);
+
+private:
+	CMTPDeviceDpConfigMgr(MMTPDataProviderFramework& aFramework);
+	void ConstructL();
+	
+	CDesCArray* ReadExclusionListL() const;
+	
+	/**
+	  *This method is to get drive info for a particular drive/volume.
+	  *
+	  *@param aDriveNo : drive in which drive info is needed.
+	  *@param aVolumeName : out param for friendly name, it is read
+	  * from mtpdevicedp_config.rss file
+	  *@param aRootDirPath : out param for root dir path, it is read
+	  * from mtpdevicedp_config.rss file
+	  */
+	void  GetDriveInfoL(TInt aDriveNo, TDes& aVolumeName, TDes& aRootDirPath);
+
+private:
+	/**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+	MMTPDataProviderFramework& iFramework;
+	TUint iResourceId;
+	TUint iEnumItrLength;	
+	};
+
+#endif // CMTPDEVICEDPCONFIGMGR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevrequestunknown.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,58 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPDEVREQUESTUNKNOWN_H
+#define CMTPDEVREQUESTUNKNOWN_H
+
+#include <mtp/cmtptypeinterdependentpropdesc.h>
+#include "cmtprequestunknown.h"
+#include "rmtpframework.h"
+
+/** 
+Implements the device data provider default request processor. MTP requests 
+which cannot be dispatched to a suitable data provider are routed to the 
+device data provider.
+@internalComponent
+*/
+class CMTPDevRequestUnknown : public CMTPRequestUnknown
+    {
+public:
+    
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPDevRequestUnknown();
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+    void ServiceInterdependentPropDescL();
+
+private:    
+    
+    CMTPDevRequestUnknown(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+	
+private:
+	
+	CMTPTypeInterdependentPropDesc* iDataSet;
+    RMTPFramework iSingletons;
+    };
+    
+#endif // CMTPDEVREQUESTUNKNOWN_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetdeviceinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,93 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPGETDEVICEINFO_H
+#define CMTPGETDEVICEINFO_H
+
+#include "cmtprequestprocessor.h"
+#include "mtpdebug.h"
+#include "rmtpdevicedpsingletons.h"
+#include "rmtpframework.h"
+
+class CMTPTypeDeviceInfo;
+class CMTPTypeArray;
+class CMTPDataProviderController;   
+
+/** 
+Implements the device data provider GetDeviceInfo request processor.
+@internalComponent
+*/
+class CMTPGetDeviceInfo : public CMTPRequestProcessor
+    {
+
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPGetDeviceInfo();
+        
+private:    
+
+    CMTPGetDeviceInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+
+private: // From CMTPRequestProcessor
+    
+    void ServiceL();
+        
+private:
+
+    void BuildDeviceInfoL();
+
+    void SetSupportedOperationsL(CMTPDataProviderController& aDpController);
+    void SetSupportedEventsL(CMTPDataProviderController& aDpController);
+    void SetSupportedDevicePropertiesL();
+    void SetSupportedCaptureFormatsL(CMTPDataProviderController& aDpController);
+    void SetSupportedPlaybackFormatsL(CMTPDataProviderController& aDpController);
+   
+    void AddToArrayL(RArray<TUint>& aDestArray, const RArray<TUint>& aSrcArray) const;
+    void AddToArrayWithFilterL(RArray<TUint>& aDestArray, const RArray<TUint>& aSrcArray) const;
+
+    void RemoveServiceFormat(RArray<TUint>& aSupportedCaptureFormats);
+
+private: // Owned.
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    /**
+    The DeviceInfo dataset buffer.
+    */
+    CMTPTypeDeviceInfo*     iDeviceInfo;
+    
+    /**
+    The MTP framework singletons.
+    */
+    RMTPFramework           iSingletons;
+    
+    /**
+    The device DP singletons handle.
+    */
+    RMTPDeviceDpSingletons  iDpSingletons;
+    };
+    
+#endif // CMTPGETDEVICEINFO_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetdevicepropdesc.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,120 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPGETDEVICEPROPDESC_H
+#define CMTPGETDEVICEPROPDESC_H
+
+#include "cmtprequestprocessor.h"
+#include "mtpdebug.h"
+#include "rmtpdevicedpsingletons.h"
+
+#include "mmtpdevdpextn.h"
+
+//#define  value for Unordered format 0 for unordered and 1 for ordered
+#define FORMAT_UNORDERED 0x00
+#define FORMAT_ORDERED 0x01
+
+//define here for supporting metadata service, not support now
+const TUint64 KUseDeviceStageH = 0;
+const TUint64 KUseDeviceStageL = 0;
+
+class CMTPTypeDevicePropDesc;
+class CRepository;
+/** 
+Implements the device data provider GetDevicePropDesc request processor.
+@internalComponent
+*/
+class CMTPGetDevicePropDesc : public CMTPRequestProcessor
+    {
+
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPGetDevicePropDesc();    
+  //  void SetExtnDevicePropDp(MExtnDevicePropDp* aExtnDevicePropDp);
+   // MExtnDevicePropDp* ExtnDevicePropDp();
+
+    
+protected:    
+
+    CMTPGetDevicePropDesc(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+    
+    // From CMTPRequestProcessor
+    virtual TMTPResponseCode CheckRequestL();
+public:
+    TMTPTypeGuid* GetGUIDL( const TUint aKey);
+    void SaveGUID( const TUint aKey, TMTPTypeGuid& aValue );
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+    
+	void DoCancel();
+	void RunL();
+
+private:
+
+    virtual void ServiceBatteryLevelL();
+    virtual void ServiceDeviceFriendlyNameL();
+    virtual void ServiceSynchronisationPartnerL();
+    virtual void ServiceSessionInitiatorVersionInfoL();
+    virtual void ServicePerceivedDeviceTypeL();
+    virtual void ServiceDateTimeL();
+    virtual void ServiceDeviceIconL();
+    virtual void ServiceSupportedFormatsOrderedL();
+    virtual void ServiceFunctionalIDL();
+    virtual void ServiceModelIDL();
+    virtual void ServiceUseDeviceStageL();
+    virtual void HandleExtnServiceL(TInt aPropCode, MExtnDevicePropDp* aExtnDevplugin );
+
+protected:	
+	virtual TUint8 GetFormatOrdered();
+protected: // Owned
+
+ //	 MExtnDevicePropDp* iExtnDevicePropDp;
+  
+    /**
+    The current battery level.
+    */
+    TUint                   iBatteryLevelValue;
+    
+    /**
+    The device DP singletons handle.
+    */
+    RMTPDeviceDpSingletons  iDpSingletons;   
+    
+  
+    
+private: // Owned.
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    CMTPTypeDevicePropDesc* iPropDesc;
+    TMTPTypeGuid*           iData;
+    TUint32                 iPropCode;
+    CRepository*            iRepository;
+   //	MMTPType* mtptype;
+     };
+    
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetdevicepropvalue.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,81 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPGETDEVICEPROPVALUE_H
+#define CMTPGETDEVICEPROPVALUE_H
+
+#include "cmtpgetdevicepropdesc.h"
+
+class CMTPTypeString;
+class TMTPTypeUint8;
+
+/** 
+Implements the device data provider GetDevicePropValue request processor.
+@internalComponent
+*/
+class CMTPGetDevicePropValue : public CMTPGetDevicePropDesc
+    {
+    
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPGetDevicePropValue();    
+    
+private:    
+
+    CMTPGetDevicePropValue(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+    
+private: // From CMTPGetDevicePropDesc
+
+    void ServiceBatteryLevelL();
+    void ServiceDeviceFriendlyNameL();
+    void ServiceSynchronisationPartnerL();   
+    void ServiceSessionInitiatorVersionInfoL();
+    void ServicePerceivedDeviceTypeL();	
+    void ServiceDateTimeL();
+    void ServiceDeviceIconL();
+    void ServiceSupportedFormatsOrderedL();
+    void ServiceFunctionalIDL();
+    void ServiceModelIDL();
+    void ServiceUseDeviceStageL();
+   void HandleExtnServiceL(TInt aPropCode, MExtnDevicePropDp* aExtnDevplugin);  //2113
+
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+    TMTPTypeUint8   iBatteryLevel;
+    TMTPTypeUint32 iUint32;	
+    CMTPTypeString* iString;
+    TMTPTypeUint8   iUint8;	
+    TMTPTypeGuid*   iData;
+    /*
+    ownership of this pointer is belongs to devicedatastore so should not 
+    delete this pointer.
+    */
+    const CMTPTypeArray* iMtpArray; 	
+    };
+    
+#endif // CMTPGETDEVICEPROPVALUE_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetnumobjects.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,61 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+
+#ifndef CMTPGETNUMOBJECTS_H
+#define CMTPGETNUMOBJECTS_H
+
+#include "cmtprequestprocessor.h"
+#include "rmtpframework.h"
+
+class MMTPObjectMgr;
+
+/** 
+Implements device data provider GetNumObjects request processor
+@internalComponent
+*/
+class CMTPGetNumObjects : public CMTPRequestProcessor
+	{
+public:
+
+	static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);	
+	~CMTPGetNumObjects();
+
+private: // From CMTPRequestProcessor
+
+	TMTPResponseCode CheckRequestL();
+	void ServiceL();
+
+protected:
+	
+	CMTPGetNumObjects(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+	void ConstructL();
+
+private:
+
+	TBool IsSupportedFormatL(TUint32 aFormatCode);
+			
+private:
+
+	RMTPFramework iSingletons;
+	};
+	
+#endif // CMTPGETNUMOBJECTS_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetobjecthandles.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,54 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPGETOBJECTHANLES_H
+#define CMTPGETOBJECTHANLES_H
+
+#include "cmtpgetnumobjects.h"
+
+class CMTPTypeArray;
+
+/** 
+Implements device data provider GetObjectHandles request processor.
+@internalComponent
+*/
+class CMTPGetObjectHandles : public CMTPGetNumObjects
+    {
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPGetObjectHandles();    
+    
+private:    
+
+    CMTPGetObjectHandles(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+        
+private:
+
+    CMTPTypeArray* iHandles;
+    };
+    
+#endif // CMTPGETOBJECTHANLES_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetserviceids.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,62 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// 
+
+/**
+@file
+@internalComponent
+*/
+
+
+#ifndef CMTPGETSERVICEIDS_H_
+#define CMTPGETSERVICEIDS_H_
+
+
+#include "cmtprequestprocessor.h"
+#include "f32file.h"
+#include "rmtpframework.h"
+
+class CMTPTypeArray;
+
+/** 
+Implements the device data provider's GetServiceIds request processor
+@internalComponent
+*/
+class CMTPGetServiceIds : public CMTPRequestProcessor
+    {
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPGetServiceIds();    
+    
+private:    
+
+	CMTPGetServiceIds(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+
+private:
+
+    void BuildServiceIdsL();
+    
+private: // Owned
+
+    RMTPFramework   iFrameworkSingletons;
+    CMTPTypeArray*  iServiceIds;
+    };
+
+#endif /*CMTPGETSERVICEIDS_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetserviceinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,87 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+
+#ifndef CMTPGETSERVICEINFO_H_
+#define CMTPGETSERVICEINFO_H_
+
+#include "cmtprequestprocessor.h"
+#include "mtpdebug.h"
+#include "rmtpdevicedpsingletons.h"
+#include "rmtpframework.h"
+#include "cmtpserviceinfo.h"
+
+
+class CMTPTypeServiceInfo;
+
+
+/** 
+Implements the device data provider GetDeviceInfo request processor.
+@internalComponent
+*/
+class CMTPGetServiceInfo : public CMTPRequestProcessor
+    {
+
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPGetServiceInfo();
+        
+private:    
+
+	CMTPGetServiceInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+
+private: // From CMTPRequestProcessor
+    
+    void ServiceL();
+        
+private:
+
+    void BuildServiceInfoL();
+    void BuildServiceInfoHeadL(CMTPServiceInfo& aServiceInfo);
+    void BuildUsedServiceGUIDL(CMTPServiceInfo& aServiceInfo);
+    void BuildServicePropertyL(CMTPServiceInfo& aServiceInfo);
+    void BuildServiceFormatL(CMTPServiceInfo& aServiceInfo);
+    void BuildServiceMethodL(CMTPServiceInfo& aServiceInfo);
+    void BuildDataBlockL(CMTPServiceInfo& aServiceInfo);
+    
+    void AddToArrayL(RArray<TUint>& aDestArray, const RArray<TUint>& aSrcArray) const;
+    
+private: // Owned.
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    /**
+    The DeviceInfo dataset buffer.
+    */
+    CMTPTypeServiceInfo*     iServiceInfo;
+    
+    /**
+    The MTP framework singletons.
+    */
+    RMTPFramework           iSingletons;
+    
+    };
+
+#endif /*CMTPGETSERVICEINFO_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetstorageids.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,61 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPGETSTORAGEIDS_H
+#define CMTPGETSTORAGEIDS_H
+
+#include "cmtprequestprocessor.h"
+#include "f32file.h"
+#include "rmtpframework.h"
+
+class CMTPTypeArray;
+
+/** 
+Implements the device data provider's GetStorageIds request processor
+@internalComponent
+*/
+class CMTPGetStorageIds : public CMTPRequestProcessor
+    {
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPGetStorageIds();    
+    
+private:    
+
+    CMTPGetStorageIds(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+
+private:
+
+    void BuildStorageIdsL();
+    
+private: // Owned
+
+    RMTPFramework   iFrameworkSingletons;
+    CMTPTypeArray*  iStorageIds;
+    };
+    
+#endif // CMTPGETSTORAGEIDS_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetstorageinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,82 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __CMTPGETSTORAGEINFO_H__
+#define __CMTPGETSTORAGEINFO_H__
+
+#include <f32file.h>
+
+#include "cmtprequestprocessor.h"
+#include "rmtpframework.h"
+#include "mtpdebug.h"
+
+//forward declaration
+class CMTPTypeStorageInfo;
+
+/** 
+Defines device data provider GetStorageInfo request processor
+
+@internalTechnology
+*/
+class CMTPGetStorageInfo : public CMTPRequestProcessor
+	{
+public:
+	static MMTPRequestProcessor* NewL(
+									MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection);	
+	~CMTPGetStorageInfo();	
+	
+private:	
+	CMTPGetStorageInfo(
+					MMTPDataProviderFramework& aFramework,
+					MMTPConnection& aConnection);
+					
+	void ConstructL();
+
+private:	//from CMTPRequestProcessor
+	virtual void ServiceL();
+
+private:
+	//helper
+	void BuildStorageInfoL();
+	void SetStorageTypeL();
+	void SetFileSystemTypeL();
+	void SetAccessCapabilityL();
+	void SetMaxCapacityL();
+	void SetFreeSpaceInBytesL();
+	void SetFreeSpaceInObjectsL();
+	void SetStorageDescriptionL();
+	void SetVolumeIdentifierL();
+	void SetupDriveVolumeInfoL();	
+		
+private:
+	/**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+	CMTPTypeStorageInfo*		iStorageInfo;
+	TDriveInfo					iDriveInfo;
+	TVolumeInfo 				iVolumeInfo;
+	RMTPFramework               iSingletons;
+	};
+	
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpopensession.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,55 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPOPENSESSION_H
+#define CMTPOPENSESSION_H
+
+#include "cmtprequestprocessor.h"
+#include "rmtpframework.h"
+
+/** 
+Implements the device data provider OpenSession request processor
+@internalComponent
+*/
+class CMTPOpenSession : public CMTPRequestProcessor
+    {
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPOpenSession();
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+        
+private:
+    
+    CMTPOpenSession(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+
+    void OpenSessionL();
+    
+private:
+
+    RMTPFramework iSingletons;
+    };
+    
+#endif // CMTPOPENSESSION_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpresetdevice.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,53 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPRESETDEVICE_H
+#define CMTPRESETDEVICE_H
+
+#include "cmtprequestprocessor.h"
+#include "rmtpframework.h"
+
+/** 
+Implements the device data provider ResetDevice request processor
+@internalComponent
+*/
+class CMTPResetDevice : public CMTPRequestProcessor
+    {
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPResetDevice();
+
+private: // From CMTPRequestProcessor
+	TMTPResponseCode CheckRequestL();
+    void ServiceL();
+        
+private:
+    
+    CMTPResetDevice(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+    
+private:
+
+    RMTPFramework iSingletons;
+    };
+    
+#endif // CMTPRESETDEVICE_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpresetdevicepropvalue.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,84 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPRESETDEVICEPROPVALUE_H
+#define CMTPRESETDEVICEPROPVALUE_H
+
+#include "cmtpgetdevicepropdesc.h"
+#include "mtpdebug.h"
+
+class CMTPTypeString;
+/** 
+Implements the device data provider SetDevicePropValue request processor.
+@internalComponent
+*/
+class CMTPResetDevicePropValue : public CMTPRequestProcessor
+    {
+    
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPResetDevicePropValue();    
+
+     
+private:    
+
+    CMTPResetDevicePropValue(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+  
+
+
+private: // From CMTPRequestProcessor
+    
+    TMTPResponseCode CheckRequestL();
+
+    void ServiceL();
+    void HandleExtnServiceL(TInt aPropCode, MExtnDevicePropDp* aExtnDevplugin);
+//	void DoCancel();
+//	void RunL();    
+	void ServiceSessionInitiatorVersionInfoL();
+	void ServicePerceivedDeviceTypeL();
+	void ServiceDateTimeL();
+	void ServiceDeviceIconL();
+	void ServiceSupportedFormatsOrderedL();
+	void ServiceFunctionalIDL();
+	void ServiceModelIDL();
+	void ServiceUseDeviceStageL();
+	
+private:
+    TMTPTypeGuid* GetGUIDL( const TUint aKey);
+    void SaveGUID( const TUint aKey, TMTPTypeGuid& aValue );
+
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+//    CMTPTypeString* iString;
+    TUint32                 iPropCode;
+    TMTPTypeGuid*           iData;
+    RMTPDeviceDpSingletons  iDpSingletons;  
+    CRepository*            iRepository;
+    };
+    
+#endif // CMTPResetDevicePropValue_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpsetdevicepropvalue.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,96 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPSETDEVICEPROPVALUE_H
+#define CMTPSETDEVICEPROPVALUE_H
+
+#include "cmtpgetdevicepropdesc.h"
+#include "mtpdebug.h"
+
+class CMTPTypeString;
+
+/** 
+Implements the device data provider SetDevicePropValue request processor.
+@internalComponent
+*/
+class CMTPSetDevicePropValue : public CMTPGetDevicePropDesc
+    {
+    
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPSetDevicePropValue();    
+    
+private:    
+
+    CMTPSetDevicePropValue(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+  
+    void CompleteServiceDeviceFriendlyNameL();   
+    void CompleteServiceSynchronisationPartnerL(); 
+
+private: // From CMTPRequestProcessor
+    
+    TBool DoHandleResponsePhaseL();
+    TBool HasDataphase() const;
+    TMTPResponseCode CheckRequestL();
+    
+private: // From CMTPGetDevicePropDesc
+
+    void ServiceBatteryLevelL();
+    void ServiceDeviceFriendlyNameL();
+    void ServiceSynchronisationPartnerL();
+    void CompleteServiceSessionInitiatorVersionInfoL();
+    void ServiceSessionInitiatorVersionInfoL();
+    void CompletePerceivedDeviceTypeL();
+    void ServicePerceivedDeviceTypeL();
+    void CompleteServiceDateTimeL();
+    void ServiceDateTimeL();
+    void CompleteDeviceIconL();	
+    void ServiceDeviceIconL();	
+    void CompleteServiceSupportedFormatsOrderedL();
+    void ServiceSupportedFormatsOrderedL();
+    void ServiceUseDeviceStageL();
+    void CompleteServiceUseDeviceStageL();
+    void ServiceModelIDL();
+    void CompleteServiceModelIDL();
+    void ServiceFunctionalIDL();
+    void CompleteServiceFunctionalIDL();
+    void HandleExtnServiceL(TInt aPropCode, MExtnDevicePropDp* aExtnDevplugin);
+
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+    CMTPTypeString* iString;
+    TMTPTypeUint32 iUint32;	
+    TMTPTypeUint8 iUint8;	
+    CMTPTypeArray* iMtparray; 
+    TMTPTypeGuid* iData;
+
+    //
+	
+    };
+    
+#endif // CMTPSETDEVICEPROPVALUE_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpstoragewatcher.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,127 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPSTORAGEWATCHER_H
+#define CMTPSTORAGEWATCHER_H
+
+#include <e32base.h>
+#include <mtp/tmtptypeevent.h>
+
+#include "mtpdebug.h"
+#include "rmtpframework.h"
+#include "rmtpdpsingletons.h"
+
+class MMTPDataProviderFramework;
+
+/** 
+Implements the MTP device data provider system storage watcher.
+@internalComponent
+*/
+class CMTPStorageWatcher : public CActive
+   {    
+
+public:
+
+    static CMTPStorageWatcher* NewL(MMTPDataProviderFramework& aFramework);
+    ~CMTPStorageWatcher();
+    
+    void EnumerateStoragesL();
+    void Start();
+    
+private: // Form CActive
+
+    void DoCancel();
+    TInt RunError(TInt aError);
+    void RunL();
+    
+private:
+
+    CMTPStorageWatcher(MMTPDataProviderFramework& aFramework);
+    void ConstructL();
+    
+    TUint32 DriveConfigurationL(TBool aAllDrives) const;
+    TBool Excluded(TDriveNumber aDriveNumber) const;
+    void RequestNotification();
+    void SendEventL(TUint16 aEvent, TUint32 aStorageId);
+    void StorageAvailableL(TDriveNumber aDriveNumber);
+    void StorageUnavailableL(TDriveNumber aDriveNumber);    
+    void AppendFolderExclusionListL();
+    
+private: // Owned
+
+    enum TState    
+        {
+        EUndefined  = 0x00000000,
+        EStarted    = 0x00000001
+        };
+    
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    /**
+    The available drives configuration.
+    */
+	TUint32                         iDrivesConfig;
+    
+    /**
+    The drive exclusion list.
+    */
+    RArray<TUint>                   iDrivesExcluded;
+    
+    /**
+    The MTP event dataset buffer.
+    */
+    TMTPTypeEvent                   iEvent;
+    
+    /**
+    The MTP framework singletons.
+    */
+    RMTPFramework                   iFrameworkSingletons;
+    
+    /**
+    The logical storages allocation enable flag.
+    */
+    TBool                           iAllocateLogicalStorages;
+    
+    /**
+    The state variable.
+    */
+    TUint32                         iState;
+    
+    /**
+    The folder exclusion list.
+    */
+    CDesCArray*						iFolderExclusionList;
+    
+    /**
+    The DP Singleton.
+    */
+    RMTPDpSingletons				iDpSingletons;
+    
+private: // Not owned.
+
+    MMTPDataProviderFramework&      iFramework;
+    };
+   
+#endif // CMTPSTORAGEWATCHER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtptypedeviceinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,254 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPTYPEDEVICEINFO_H
+#define CMTPTYPEDEVICEINFO_H
+
+#include <e32std.h>
+#include <mtp/cmtptypecompoundbase.h>
+
+class CMTPTypeArray;
+class CMTPTypeString;
+
+//
+
+/** 
+Defines the MTP DeviceInfo dataset. The DeviceInfo dataset provides a 
+description of the MTP device and is generated in response to a GetDeviceInfo
+operation request.
+@internalComponent
+*/ 
+class CMTPTypeDeviceInfo : public CMTPTypeCompoundBase
+    {
+public:
+
+    /**
+    MTP DeviceInfo dataset element identifiers.
+    */
+    enum TMTPDeviceInfoElement
+        {
+        /**
+        Standard Version.
+        */
+        EStandardVersion,
+        
+        /**
+        MTP Vendor Extension ID.
+        */
+        EMTPVendorExtensionID,
+        
+        /**
+        MTP Version.
+        */
+        EMTPVersion,
+        
+        /**
+        MTP Extensions.
+        */
+        EMTPExtensions, 
+        
+        /**
+        Functional Mode.
+        */
+        EFunctionalMode,
+        
+        /**
+        Operations Supported.
+        */
+        EOperationsSupported,
+        
+        /**
+        Events Supported.
+        */
+        EEventsSupported,
+        
+        /**
+        Device Properties Supported.
+        */
+        EDevicePropertiesSupported,
+        
+        /**
+        Capture Formats.
+        */
+        ECaptureFormats,
+        
+        /**
+        Playback Formats.
+        */
+        EPlaybackFormats,
+        
+        /**
+        Manufacturer.
+        */
+        EManufacturer,
+        
+        /**
+        Model.
+        */
+        EModel,  
+        
+        /**
+        Device Version.
+        */
+        EDeviceVersion,
+        
+        /**
+        Serial Number.
+        */
+        ESerialNumber,
+        
+        /**
+        The number of dataset elements.
+        */
+        ENumElements,
+        };
+
+public:
+    
+    static CMTPTypeDeviceInfo* NewL();
+    static CMTPTypeDeviceInfo* NewLC();
+    
+    virtual ~CMTPTypeDeviceInfo();   
+     
+public: // From MMTPType
+
+    TUint Type() const;
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+
+private:
+
+    CMTPTypeDeviceInfo();
+    void ConstructL();
+
+    MMTPType* NewArrayChunkL(const TElementInfo& aElementInfo);
+    MMTPType* NewFlatChunkL(const TElementInfo& aElementInfo);
+    MMTPType* NewStringChunkL(const TElementInfo& aElementInfo);
+    MMTPType* NewUInt16Chunk(const TElementInfo& aElementInfo);
+
+private:
+        
+    /**
+    Data chunk identifiers.
+    */
+    enum TChunkIds
+        {
+        /**
+        The flat data chunk ID.
+        */
+        EIdFlatChunk,
+        
+        /**
+        The EMTPExtensions element data chunk ID.
+        */
+        EIdMTPExtensionsChunk,
+        
+        /**
+        The EFunctionalMode element data chunk ID.
+        */
+        EIdFunctionalModeChunk,
+        
+        /**
+        The EOperationsSupported element data chunk ID.
+        */
+        EIdOperationsSupportedChunk,
+        
+        /**
+        The EEventsSupported element data chunk ID.
+        */
+        EIdEventsSupportedChunk,
+        
+        /**
+        The EDevicePropertiesSupported element data chunk ID.
+        */
+        EIdDevicePropertiesSupportedChunk,
+        
+        /**
+        The ECaptureFormats element data chunk ID.
+        */
+        EIdCaptureFormatsChunk,
+        
+        /**
+        The EPlaybackFormats element data chunk ID.
+        */
+        EIdPlaybackFormatsChunk,
+        
+        /**
+        The EPlaybackFormats element data chunk ID.
+        */
+        EIdManufacturerChunk,
+        
+        /**
+        The EModel element data chunk ID.
+        */
+        EIdModelChunk,
+        
+        /**
+        The EDeviceVersion element data chunk ID.
+        */
+        EIdDeviceVersionChunk,
+        
+        /**
+        The ESerialNumber element data chunk ID.
+        */
+        EIdSerialNumberChunk,
+        
+        /**
+        The number of data chunks.
+        */
+        EIdNumChunks
+        };
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The flat data chunk comprising elements EStandardVersion to EMTPVersion.
+    */
+    RMTPTypeCompoundFlatChunk                       iChunkFlat;
+    
+    /**
+    The EFunctionalMode data chunk.
+    */
+    TMTPTypeUint16                                  iChunkFunctionalMode;
+    
+    /**
+    The MTP array type data chunks (EOperationsSupported, EEventsSupported, 
+    EDevicePropertiesSupported, ECaptureFormats, and EPlaybackFormats). 
+    */
+    RPointerArray<CMTPTypeArray>                    iArrayChunks;
+    
+    /**
+    The MTP string type data chunks (EManufacturer, EModel, EDeviceVersion, and 
+    ESerialNumber).
+    */
+    RPointerArray<CMTPTypeString>                   iStringChunks;
+    };
+    
+#endif // CMTPTYPEDEVICEINFO_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/mextndevplugincallback.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,40 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef MEXTNDEVPLUGINCALLBACK_H_
+#define MEXTNDEVPLUGINCALLBACK_H_
+
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpdataproviderframework.h>
+
+class MExtnDevPluginCallback
+{
+public:
+	virtual void OnDevicePropertyChangedL (TMTPDevicePropertyCode& aPropCode) = 0;
+
+	/** 
+	  * This method return reference to the MMTPDataProviderFramework
+	  *
+	  * @return : reference to MMTPDataProviderFramework
+	  */
+	virtual MMTPDataProviderFramework& DataProviderFramework () = 0;
+};
+
+#endif /*MEXTNDEVPLUGINCALLBACK_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/mtpdevdppanic.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,48 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef MTPDEVDPPANIC_H
+#define MTPDEVDPPANIC_H
+
+#include <e32std.h>
+
+enum TMTPDevDpPanic
+    {
+    EMTPDevDpReserved                   = 0,
+    EMTPDevDpInvalidState               = 1,
+    EMTPDevDpDeviceInfoPhaseInvalid     = 2,
+    EMTPDevDpNoMatchingProcessor        = 3,
+    EMTPDevDpConnectionNotFound         = 4,
+    EMTPDevDpStorageNoMedia             = 5,
+    EMTPDevDpResponseParameterTooMany   = 6,
+    EMTPDevDpInvalidRequest             = 7,
+    EMTPDevDpUnknownDeviceProperty      = 8,
+    EMTPDevDpUnknownServiceID           = 9,
+
+    };
+
+_LIT(KMTPDevDpPanic, "MTPDeviceDp");
+inline void Panic(TMTPDevDpPanic aCode)
+    {
+    User::Panic(KMTPDevDpPanic, aCode);
+    };
+
+#endif // MTPDEVDPPANIC_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/mtpdevicedp_config.rh	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,56 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Defines the resource type for device dp specific configuration data
+// 
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+STRUCT MTP_DEVICEDP_CONFIG
+	{
+	WORD enumeration_iteration_length = 64; // Iterate through max 64 directory entries each RunL
+	LTEXT folder_exclusion_list[]; // What to exclude
+	}
+
+STRUCT DRIVE
+	{
+	WORD driveNo;
+	LTEXT driveName;
+	LTEXT rootDirPath;
+	}
+
+STRUCT SIGNATURE
+	{
+	LONG version;
+	SRLINK self;
+	}
+
+STRUCT DRIVEARRAY
+	{
+	STRUCT	elements[];
+	}
+
+STRUCT FORMATSARRAY
+	{
+	LTEXT objFormats[];
+	}
+
+STRUCT PLUGINUIDARRAY
+ {
+	LTEXT uid_list[];
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/mtpdevicedpconst.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,159 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef MTPDEVICEDPCONST_H
+#define MTPDEVICEDPCONST_H
+
+#include <mtp/mtpprotocolconstants.h>
+
+/**
+define all the operations that are supported by the device data provider
+*/
+static const TUint16 KMTPDeviceDpSupportedOperations[] = 
+	{
+	EMTPOpCodeGetDeviceInfo,
+	EMTPOpCodeOpenSession,
+	EMTPOpCodeCloseSession,
+	EMTPOpCodeGetStorageIDs,
+	EMTPOpCodeGetStorageInfo,
+	EMTPOpCodeGetNumObjects,
+	EMTPOpCodeGetObjectHandles,
+	EMTPOpCodeResetDevice,
+	EMTPOpCodeGetDevicePropDesc,
+	EMTPOpCodeGetDevicePropValue,
+	EMTPOpCodeSetDevicePropValue,
+	EMTPOpCodeCopyObject,
+	EMTPOpCodeMoveObject,
+	EMTPOpCodeDeleteObject,
+	EMTPOpCodeGetObject,
+	EMTPOpCodeGetObjectInfo,
+	EMTPOpCodeGetObjectPropDesc,
+	EMTPOpCodeGetObjectPropList,
+	EMTPOpCodeGetObjectPropsSupported,
+	EMTPOpCodeGetObjectPropValue,
+	EMTPOpCodeGetObjectReferences,
+	EMTPOpCodeGetInterdependentPropDesc,
+	EMTPOpCodeSendObject,
+	EMTPOpCodeSendObjectInfo,
+	EMTPOpCodeSendObjectPropList,
+	EMTPOpCodeSetObjectPropList,
+	EMTPOpCodeSetObjectPropValue,
+	EMTPOpCodeSetObjectReferences,
+	EMTPOpCodeGetServiceIDs,
+	EMTPOpCodeGetFormatCapabilities
+	};
+
+/**
+define all the device properties supported by the device data provider
+*/
+static const TUint16 KMTPDeviceDpSupportedProperties[] = 
+	{
+	//PTP
+	EMTPDevicePropCodeBatteryLevel,
+	
+	//MTP specific
+	EMTPDevicePropCodeSynchronizationPartner,
+	EMTPDevicePropCodeDeviceFriendlyName,
+	EMTPDevicePropCodeSupportedFormatsOrdered,
+	EMTPDevicePropCodeSessionInitiatorVersionInfo,
+	EMTPDevicePropCodePerceivedDeviceType,	
+	EMTPDevicePropCodeDateTime,
+	EMTPDevicePropCodeDeviceIcon,
+	
+	//MTP Device Service Extension
+	EMTPDevicePropCodeFunctionalID,
+	EMTPDevicePropCodeModelID,
+	EMTPDevicePropCodeUseDeviceStage
+	
+	};
+
+static const TUint16 KMTPDeviceDpSupportedServiceExtnProperties[] = 
+	{
+	//MTP Device Service Extension
+	EMTPDevicePropCodeFunctionalID,
+	EMTPDevicePropCodeModelID,
+	EMTPDevicePropCodeUseDeviceStage
+	};
+
+/**
+define all the object properties supported by the device data provider
+*/
+
+static const TUint16 KMTPDeviceDpSupportedObjectProperties[] = 
+	{
+	//Folder properties
+	EMTPObjectPropCodeStorageID,
+	EMTPObjectPropCodeObjectFormat,
+	EMTPObjectPropCodeProtectionStatus,
+	EMTPObjectPropCodeAssociationType,
+	EMTPObjectPropCodeAssociationDesc,
+	EMTPObjectPropCodeObjectSize,
+	EMTPObjectPropCodeObjectFileName,
+	EMTPObjectPropCodeDateModified,
+	EMTPObjectPropCodeParentObject,
+	EMTPObjectPropCodePersistentUniqueObjectIdentifier,
+	EMTPObjectPropCodeName,
+	EMTPObjectPropCodeNonConsumable	
+	};	
+
+static const TUint16 KMTPDeviceDpSupportedEvents[] = 
+	{
+	//PTP
+	EMTPEventCodeStoreAdded,
+	EMTPEventCodeStoreRemoved,
+	EMTPEventCodeDevicePropChanged,
+	EMTPEventCodeDeviceInfoChanged,
+	EMTPEventCodeStoreFull,
+	EMTPEventCodeDeviceReset,
+	EMTPEventCodeStorageInfoChanged,
+	};
+
+const TInt32    KMTPDevicePropertyStoreVersion(0x00000100);
+const TUint     KMTPDriveLetterPrefixLength(3);
+const TUint     KMTPMaxDevicePropertyLength(255);
+const TUint     KMTPSerialNumberLength(32);
+
+/**
+ Device property value defaults.
+*/
+const TInt KMTPDefaultBatteryLevel(0);
+
+/** 
+DeviceInfo dataset field defaults.
+*/
+_LIT(KMTPDefaultSerialNumber, "350149101482769");
+_LIT(KMTPDefaultManufacturer, "Symbian");
+_LIT(KMTPDefaultModel, "1234567890");
+_LIT(KMTPDefaultDeviceVersion, "1.0");
+
+/**
+ *This enumerator to identify resource file prameters.
+ * EDevDpFormats is to identify FORMATS
+ * EDevDpExtnUids is to identify UIDs for extn plugin.
+ */
+enum TDevDPConfigRSSParams
+{
+	EDevDpFormats  = 0,
+	EDevDpExtnUids = 1,
+		
+};
+	
+#endif // MTPDEVICEDPCONST_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/mtpdevicedpprocessor.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,47 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __MTPDEVICEDPPROCESSOR_H__
+#define __MTPDEVICEDPPROCESSOR_H__
+
+//forward declaration
+class MMTPConnection;
+class TMTPTypeRequest;
+class CMTPDataProviderPlugin;
+class MMTPDataProviderFramework;
+class MMTPRequestProcessor;
+
+
+/** 
+Defines device data provider request processor
+
+@internalTechnology
+*/
+class MTPDeviceDpProcessor
+	{
+public:
+	static MMTPRequestProcessor* CreateL(
+										MMTPDataProviderFramework& aFramework,
+										const TMTPTypeRequest& aRequest, 
+										MMTPConnection& aConnection);	
+	};
+	
+#endif // __MTPDEVICEDPPROCESSOR_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/rmtpdevicedpsingletons.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,97 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef RMTPDEVICEDPSINGLETONS_H
+#define RMTPDEVICEDPSINGLETONS_H
+
+#include <e32def.h>
+
+#include "mtpdebug.h"
+
+class CMTPDeviceDataStore;
+class CMTPDeviceDpConfigMgr;
+
+/** 
+Implements the MTP device data processor singletons reference manager.
+@internalComponent
+*/
+class RMTPDeviceDpSingletons
+    {
+    
+public:  
+
+    RMTPDeviceDpSingletons();  
+
+    void OpenL(MMTPDataProviderFramework& aFramework);
+    void Close();
+    
+    CMTPDeviceDataStore& DeviceDataStore();
+    CMTPDeviceDpConfigMgr& ConfigMgr();
+    
+private:
+    
+    /**
+    Implements the singletons reference block.
+    */
+    class CSingletons : public CObject
+        {
+    public: 
+
+        static CSingletons& OpenL(MMTPDataProviderFramework& aFramework);
+        void Close();
+
+    private:
+
+        static CSingletons* NewL(MMTPDataProviderFramework& aFramework);
+        virtual ~CSingletons();
+        void ConstructL(MMTPDataProviderFramework& aFramework);
+
+    public: // Owned
+
+        /**
+        FLOGGER debug trace member variable.
+        */
+        __FLOG_DECLARATION_MEMBER_MUTABLE;
+            
+        /**
+        The device information data manager.
+        */
+        CMTPDeviceDataStore*    iDeviceDataStore;
+        
+        /**
+        The device dp config manager.
+        */
+        CMTPDeviceDpConfigMgr*	iConfigMgr;
+    };
+    
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+    /**
+    The singletons reference block.
+    */
+    CSingletons*    iSingletons;
+};
+
+#endif // RMTPDEVICEDPSINGLETONS_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpclosesession.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,118 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpclosesession.h"
+#include "cmtpconnection.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpdataprovider.h"
+#include "cmtpconnectionmgr.h"
+#include "mtpdevdppanic.h"
+#include "rmtpframework.h"
+    
+/**
+Two-phase construction method
+@param aPlugin    The data provider plugin
+@param aFramework    The data provider framework
+@param aConnection    The connection from which the request comes
+@return a pointer to the created request processor object
+*/
+MMTPRequestProcessor* CMTPCloseSession::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPCloseSession* self = new (ELeave) CMTPCloseSession(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+CMTPCloseSession::~CMTPCloseSession()
+    {
+    iSingletons.Close();
+    }
+    
+/**
+Standard c++ constructor
+*/    
+CMTPCloseSession::CMTPCloseSession(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+    {
+    
+    }
+    
+/**
+Second phase constructor.
+*/
+void CMTPCloseSession::ConstructL()
+    {
+    iSingletons.OpenL();
+    }
+
+/**
+Request checker
+*/
+TMTPResponseCode CMTPCloseSession::CheckRequestL()
+    {
+    TMTPResponseCode response = CMTPRequestProcessor::CheckRequestL();
+    if (response == EMTPRespCodeOK)
+        {
+        TUint32 sessionId = iRequest->Uint32(TMTPTypeRequest::ERequestParameter1);
+        //default session (with id 0) should never be closed
+        if (!iConnection.SessionWithMTPIdExists(sessionId) || sessionId == 0)
+            {
+            response = EMTPRespCodeSessionNotOpen;
+            }
+        }
+    return response;    
+    }
+    
+/**
+CloseSession request handler
+*/    
+void CMTPCloseSession::ServiceL()
+    {    
+    // Send response first before close the session
+    SendResponseL(EMTPRespCodeOK);
+    
+    // The sessionId for closesession is always 0, the actual session ID to close is
+    // stored in payload parameter 1.
+    RemoveSessionL(iRequest->Uint32(TMTPTypeRequest::ERequestParameter1));    
+    }
+
+
+/**
+Remove the session from the connection
+@param aSessionId the sessionId to be removed
+*/
+void CMTPCloseSession::RemoveSessionL(TUint32 aSessionId)
+    {
+    TUint connectionId = iConnection.ConnectionId();
+    CMTPConnectionMgr& connectionMgr = iSingletons.ConnectionMgr();
+    CMTPConnection& connection = connectionMgr.ConnectionL(connectionId);
+    connection.SessionClosedL(aSessionId);    
+    }
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevdpexclusionmgr.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,50 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "cmtpdevdpexclusionmgr.h"
+
+CMTPDevDpExclusionMgr* CMTPDevDpExclusionMgr::NewL(MMTPDataProviderFramework& aFramework)
+	{
+	CMTPDevDpExclusionMgr* self = new (ELeave) CMTPDevDpExclusionMgr(aFramework);
+	return self;
+	}
+	
+CMTPDevDpExclusionMgr::CMTPDevDpExclusionMgr(MMTPDataProviderFramework& aFramework) :
+	CMTPFSExclusionMgr(aFramework)
+	{
+	}
+
+CMTPDevDpExclusionMgr::~CMTPDevDpExclusionMgr()
+	{
+	}
+	
+//  Methods from CMTPFSExclusionMgr
+TBool CMTPDevDpExclusionMgr::IsFileAcceptedL(const TDesC& /*aFileName*/, TUint32 /*aStorageID*/) const
+	{
+	return EFalse;
+	}
+	
+TBool CMTPDevDpExclusionMgr::IsFormatValid(TMTPFormatCode aFormat) const
+	{
+	return (aFormat == EMTPFormatCodeAssociation);
+	}
+	
+TBool CMTPDevDpExclusionMgr::IsExtensionValid(const TDesC& /*aExtension*/) const
+	{
+	// No extensions allowed - folders don't have them.
+	return EFalse;
+	}
+    
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevdpextnmap.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,65 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "cmtpdevdpextnmap.h"
+
+CDevDpExtnPluginMap* CDevDpExtnPluginMap::NewL(MExtnDevPluginCallback& aDevdp, TUid aUid)
+	{
+	CDevDpExtnPluginMap* self = new (ELeave) CDevDpExtnPluginMap();
+	CleanupStack::PushL(self);
+	self->ConstructL(aDevdp, aUid);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+void CDevDpExtnPluginMap::ConstructL(MExtnDevPluginCallback& aDevdp, TUid aUid)
+	{
+	CMtpExtnDevicePropPlugin* extnPlugin = CMtpExtnDevicePropPlugin::NewL(aUid);
+	extnPlugin->SetCallback(aDevdp);
+	SetExtPlugin(extnPlugin);
+	}
+
+void CDevDpExtnPluginMap::SetExtPlugin(CMtpExtnDevicePropPlugin* aPlugin)
+	{
+	iPlugin = aPlugin;
+	}
+
+
+CMtpExtnDevicePropPlugin* CDevDpExtnPluginMap::ExtPlugin()
+	{
+	return iPlugin;
+	}
+ 	
+CDevDpExtnPluginMap::~CDevDpExtnPluginMap()
+	{
+	iSupportedOpCodes.Close();
+
+	if(NULL != iPlugin)
+		{
+		delete iPlugin;
+		iPlugin = NULL;
+		}
+	} 	
+ 	
+RArray<TUint>* CDevDpExtnPluginMap::SupportedOpCodes()
+	{
+	return &iSupportedOpCodes;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedatastore.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1214 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <badesca.h>
+#include <bautils.h>
+#include <hal.h>
+#include <s32file.h>
+#include  <f32file.h>
+#include <tz.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/cmtpdataproviderplugin.h>
+#include <mtp/cmtptypefile.h>
+
+#include "cmtpdataprovider.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpdevicedatastore.h"
+#include "cmtpframeworkconfig.h"
+#include "mmtpenumerationcallback.h"
+#include "mtpdevdppanic.h"
+#include "mtpdevicedpconst.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"DeviceDataStore");)
+
+#ifdef __WINS__
+_LIT( KFileName, "c:\\private\\102827a2\\mtpdevice.ico");
+#else
+_LIT( KFileName, "z:\\private\\102827a2\\mtpdevice.ico");
+#endif
+
+
+// Device property datastore constants.
+_LIT(KMTPNoBackupFolder, "nobackup\\");
+_LIT(KMTPDevicePropertyStoreFileName, "mtpdevicepropertystore.dat");
+_LIT(KMTPDevicePropertyStoreDrive, "c:");
+_LIT(KMTPVendorExtensionSetDelimiter, "; ");
+
+//Default Session Initiator Version Information
+_LIT(KDefaultSessionInitiatorVersionInfo,"None");
+//Default Perceived DeviceType information
+static const TUint32 DefaultPerceivedDeviceType = 0;
+
+/*In order to ensure a reasonable RunL() duration, 8 dps at maximum are
+  queried in one RunL() invocation.
+*/
+static const TUint KExtensionSetIterationRunLength = 8;
+
+// The maximum number of extensions each dp support.
+static const TUint KExtensionSetGranularity = 4;
+
+//#define for PERCIVED_DEVICETYPE
+static const TUint KPercivedDeviceType = 3;
+//maximum length for date time string
+static const TUint KMaxDateTimeLength = 28;
+//minimum length for date time string
+static const TUint KMinDateTimeLength = 15;
+//position of date and time seperator 'T'
+static const TUint KPosDelemT = 8;
+//buffer size for reading iconfile
+static const TUint KBufferSize = 1024;
+
+//enum for time zone
+enum TDevDPTypeTimeOffset
+	{
+	EDEVDPTypeZero = 0,
+	EDEVDPTypeMinus ,
+	EDEVDPTypePlus,
+	EDEVDPTypeNotDefined,
+	};
+
+
+/**
+MTP device information data store factory method.
+@return A pointer to an MTP device information data store. Ownership IS
+transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+CMTPDeviceDataStore* CMTPDeviceDataStore::NewL()
+    {
+    CMTPDeviceDataStore* self = new (ELeave) CMTPDeviceDataStore();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor.
+*/
+CMTPDeviceDataStore::~CMTPDeviceDataStore()
+    {
+    __FLOG(_L8("~CMTPDeviceDataStore - Entry"));
+    Cancel();
+    delete iDeviceFriendlyNameDefault;
+    delete iSyncPartnerNameDefault;
+    delete iDeviceFriendlyName;
+    delete iSynchronisationPartner;
+    delete iTelephony;
+    delete iSessionInitiatorVersionInfo;
+    delete iDeviceIcon;
+    delete iSupportedDevProArray;
+    delete iDateTime;
+    iDeviceVersion.Close();
+    iSerialNumber.Close();
+    iSingletons.Close();
+    iMTPExtensions.Close();
+    __FLOG(_L8("~CMTPDeviceDataStore - Exit"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Check to see if a request such as BatteryLevel is currently
+pending for processing. If so it's not advisable to make another
+request.
+
+@return ETrue if a request is pending EFalse otherwise.
+*/
+
+TBool CMTPDeviceDataStore::RequestPending() const
+	{
+	return IsActive();
+	}
+
+void CMTPDeviceDataStore::BatteryLevelL(TRequestStatus& aStatus, TUint& aBatteryLevel)
+    {
+    __FLOG(_L8("BatteryLevel - Entry"));
+
+	if (RequestPending())
+		{
+		// We are already reading battery level
+		// leave so we don't set ourselves active twice
+		User::Leave(KErrInUse);
+		}
+
+    iPendingStatus = &aStatus;
+	SetRequestPending(*iPendingStatus);
+
+    if (iTelephony)
+        {
+        iPendingBatteryLevel    = &aBatteryLevel;
+    	iTelephony->GetBatteryInfo(iStatus, iBatteryInfoV1Pckg);
+    	SetState(EEnumeratingBatteryLevel);
+    	SetActive();
+        }
+    else
+        {
+        aBatteryLevel = KMTPDefaultBatteryLevel;
+    	SetRequestComplete(*iPendingStatus, KErrNone);
+        }
+    __FLOG(_L8("BatteryLevel - Exit"));
+    }
+
+/**
+Provides the MTP device friendly name.
+@return The MTP device friendly name.
+*/
+const TDesC& CMTPDeviceDataStore::DeviceFriendlyName() const
+    {
+    __FLOG(_L8("DeviceFriendlyName - Entry"));
+    __FLOG(_L8("DeviceFriendlyName - Exit"));
+    return iDeviceFriendlyName->StringChars();
+    }
+
+/**
+Provides the default MTP device friendly name.
+@return The default MTP device friendly name.
+*/
+const TDesC& CMTPDeviceDataStore::DeviceFriendlyNameDefault() const
+    {
+    __FLOG(_L8("DeviceFriendlyNameDefault - Entry"));
+    __FLOG(_L8("DeviceFriendlyNameDefault - Exit"));
+    return *iDeviceFriendlyNameDefault;
+    }
+
+/**
+Provides the device firmware version identifier
+@return The device firmware version identifier .
+*/
+const TDesC& CMTPDeviceDataStore::DeviceVersion() const
+    {
+    __FLOG(_L8("DeviceVersion - Entry"));
+    __FLOG(_L8("DeviceVersion - Exit"));
+    return iDeviceVersion;
+    }
+
+/**
+Provides the device manufacturer name.
+@return The device manufacturer name.
+*/
+const TDesC& CMTPDeviceDataStore::Manufacturer() const
+    {
+    __FLOG(_L8("Manufacturer - Entry"));
+    __ASSERT_DEBUG(Enumerated(), Panic(EMTPDevDpInvalidState));
+    __FLOG(_L8("Manufacturer - Exit"));
+    return iPhoneIdV1.iManufacturer;
+    }
+
+/**
+Provides the device model identifier.
+@return The device model identifier.
+*/
+const TDesC& CMTPDeviceDataStore::Model() const
+    {
+    __FLOG(_L8("Model - Entry"));
+    __ASSERT_DEBUG(Enumerated(), Panic(EMTPDevDpInvalidState));
+    __FLOG(_L8("Model - Exit"));
+    return iPhoneIdV1.iModel;
+    }
+
+/**
+Provides the MTP Vendor Extension string.
+@return The MTP Vendor Extension string.
+*/
+const TDesC& CMTPDeviceDataStore::MTPExtensions() const
+    {
+    __FLOG(_L8("MTPExtensions - Entry"));
+    __FLOG(_L8("MTPExtensions - Exit"));
+    return iMTPExtensions;
+    }
+
+/**
+Provides the device serial number.
+@return The device serial number.
+*/
+const TDesC& CMTPDeviceDataStore::SerialNumber() const
+    {
+    __FLOG(_L8("SerialNumber - Entry"));
+    __ASSERT_DEBUG(Enumerated(), Panic(EMTPDevDpInvalidState));
+    __FLOG(_L8("SerialNumber - Exit"));
+    return iPhoneIdV1.iSerialNumber;
+    }
+
+/**
+Provides the MTP synchronisation partner name.
+@return The MTP synchronisation partner name.
+*/
+const TDesC& CMTPDeviceDataStore::SynchronisationPartner() const
+    {
+    __FLOG(_L8("SynchronisationPartner - Entry"));
+    __FLOG(_L8("SynchronisationPartner - Exit"));
+    return iSynchronisationPartner->StringChars();
+    }
+
+/**
+Provides the default MTP synchronisation partner name.
+@return The default MTP synchronisation partner name.
+*/
+const TDesC& CMTPDeviceDataStore::SynchronisationPartnerDefault() const
+    {
+    __FLOG(_L8("SynchronisationPartnerDefault - Entry"));
+    __FLOG(_L8("SynchronisationPartnerDefault - Exit"));
+    return *iSyncPartnerNameDefault;
+    }
+
+/**
+Sets the MTP device friendly name.
+@param aName The new MTP device friendly name.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPDeviceDataStore::SetDeviceFriendlyNameL(const TDesC& aName)
+    {
+    __FLOG(_L8("SetDeviceFriendlyNameL - Entry"));
+    iDeviceFriendlyName->SetL(aName);
+    StoreL();
+    __FLOG(_L8("SetDeviceFriendlyNameL - Exit"));
+    }
+
+/**
+Sets the synchronisation partner name.
+@param aName The new MTP synchronisation partner name.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPDeviceDataStore::SetSynchronisationPartnerL(const TDesC& aName)
+    {
+    __FLOG(_L8("SetSynchronisationPartnerL - Entry"));
+    iSynchronisationPartner->SetL(aName);
+    StoreL();
+    __FLOG(_L8("SetSynchronisationPartnerL - Exit"));
+    }
+
+/**
+Initiates the MTP device data provider's device information data store
+enumeration sequence. The sequence is concluded when ObjectEnumerationCompleteL
+is signalled to the MTP data provider framework layer.
+@param aStorageId The MTP StorageId to be enumerated.
+@param aCallback Callback to be called when enumeration completes.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPDeviceDataStore::StartEnumerationL(TUint32 aStorageId, MMTPEnumerationCallback& aCallback)
+    {
+    __FLOG(_L8("StartEnumerationL - Entry"));
+    if (State() != EUndefined)
+        {
+        aCallback.NotifyEnumerationCompleteL(aStorageId, KErrNone);
+        }
+    else
+        {
+        iStorageId = aStorageId;
+        iCallback = &aCallback;
+        Schedule(EEnumeratingDevicePropertyStore);
+        }
+    __FLOG(_L8("StartEnumerationL - Exit"));
+    }
+
+void CMTPDeviceDataStore::DoCancel()
+    {
+    __FLOG(_L8("DoCancel - Entry"));
+    if (iTelephony)
+        {
+        switch (State())
+            {
+        case EEnumeratingPhoneId:
+            iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel);
+            break;
+
+        case EEnumeratingBatteryLevel:
+            iTelephony->CancelAsync(CTelephony::EGetBatteryInfoCancel);
+            break;
+
+        default:
+            // Nothing to do.
+            break;
+            }
+        }
+    __FLOG(_L8("DoCancel - Exit"));
+    }
+
+/**
+Handles leaves occurring in RunL.
+@param aError leave error code
+@return KErrNone
+*/
+TInt CMTPDeviceDataStore::RunError(TInt aError)
+    {
+    __FLOG(_L8("RunError - Entry"));
+    __FLOG_VA((_L8("Error = %d, State = %d"), aError, State()));
+	aError = aError;	// suppress compiler warning
+
+    switch (State())
+        {
+    case EEnumeratingDevicePropertyStore:
+        // Error restoring device properties; use defaults.
+        Schedule(EEnumeratingDeviceVersion);
+        break;
+
+    case EEnumeratingDeviceVersion:
+        // Error enumerating software build information; use default.
+        Schedule(EEnumeratingPhoneId);
+        break;
+
+    case EEnumeratingPhoneId:
+        // Error enumerating telephony device ID information; use defaults.
+        Schedule(EEnumeratingVendorExtensions);
+        break;
+
+    case EEnumeratingVendorExtensions:
+        Schedule(EEnumerated);
+    	break;
+
+    case EEnumeratingBatteryLevel:
+    	// This case will never occur
+    case EUndefined:
+    default:
+        __DEBUG_ONLY(Panic(EMTPDevDpInvalidState));
+        break;
+        }
+
+    __FLOG(_L8("RunError - Exit"));
+    return KErrNone;
+    }
+
+void CMTPDeviceDataStore::RunL()
+    {
+    __FLOG(_L8("RunL - Entry"));
+    switch (State())
+        {
+    case EEnumeratingDevicePropertyStore:
+        RestoreL();
+        Schedule(EEnumeratingDeviceVersion);
+        break;
+
+    case EEnumeratingDeviceVersion:
+        {
+        TInt buildNo(0);
+        User::LeaveIfError(HAL::Get(HALData::EManufacturerSoftwareBuild, buildNo));
+        __FLOG_VA((_L8("EManufacturerSoftwareBuild = %d "), buildNo));
+        iDeviceVersion.Format(_L("%d"), buildNo);
+        Schedule(EEnumeratingPhoneId);
+        }
+        break;
+
+    case EEnumeratingPhoneId:
+        if (!iTelephony)
+            {
+            iTelephony  = CTelephony::NewL();
+            iTelephony->GetPhoneId(iStatus, iPhoneIdV1Pckg);
+            SetActive();
+            }
+        else
+            {
+            StoreFormattedSerialNumber(iPhoneIdV1.iSerialNumber);
+            Schedule(EEnumeratingVendorExtensions);
+            }
+        break;
+
+    case EEnumeratingVendorExtensions:
+    	{
+    	TBool isCompleted = EFalse;
+    	AppendMTPExtensionSetsL(isCompleted);
+    	if (isCompleted)
+    		{
+    		Schedule(EEnumerated);
+    		}
+    	else
+    		{
+	        Schedule(EEnumeratingVendorExtensions);
+    		}
+    	}
+    	break;
+
+    case EEnumeratingBatteryLevel:
+        *iPendingBatteryLevel   = iBatteryInfoV1.iChargeLevel;
+    	SetRequestComplete(*iPendingStatus, KErrNone);
+        SetState(EEnumerated);
+        break;
+
+    case EEnumerated:
+        if (iCallback)
+            {
+            iCallback->NotifyEnumerationCompleteL(iStorageId, KErrNone);
+            iCallback = NULL;
+            iStorageId = KMTPNotSpecified32;
+            }
+        break;
+
+case EEnumeratedBatteryLevel :
+	*iPendingBatteryLevel	= iBatteryInfoV1.iChargeLevel;
+	SetRequestComplete(*iPendingStatus, KErrNone);
+	SetState(EEnumerated);
+	break;
+	
+    case EUndefined:
+    default:
+        __DEBUG_ONLY(Panic(EMTPDevDpInvalidState));
+        break;
+        }
+    __FLOG(_L8("RunL - Exit"));
+    }
+
+/**
+Constructor.
+@param aConnectionMgr The MTP connection manager interface.
+*/
+CMTPDeviceDataStore::CMTPDeviceDataStore() :
+    CActive(EPriorityStandard),
+	iBatteryInfoV1Pckg(iBatteryInfoV1),
+	iPhoneIdV1Pckg(iPhoneIdV1)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+/**
+Second phase constructor.
+*/
+void CMTPDeviceDataStore::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry"));
+    iSingletons.OpenL();
+
+    /*
+    Set the default values.
+
+        1.  Device friendly name.
+    */
+    iDeviceFriendlyNameDefault = iSingletons.FrameworkConfig().ValueL(CMTPFrameworkConfig::EDeviceFriendlyName);
+    iDeviceFriendlyName = CMTPTypeString::NewL(*iDeviceFriendlyNameDefault);
+
+    //  2.  Synchronization partner name.
+    iSyncPartnerNameDefault = iSingletons.FrameworkConfig().ValueL(CMTPFrameworkConfig::ESynchronizationPartnerName);
+    iSynchronisationPartner = CMTPTypeString::NewL(*iSyncPartnerNameDefault);
+
+    //  3.  Device Version.
+    iDeviceVersion.CreateL(KMTPDefaultDeviceVersion);
+
+    //  4.  Manufacturer.
+    iPhoneIdV1.iManufacturer    = KMTPDefaultManufacturer;
+
+    //  5.  Model.
+    iPhoneIdV1.iModel           = KMTPDefaultModel;
+
+    //  6.  Serial Number.
+    StoreFormattedSerialNumber(KMTPDefaultSerialNumber);
+
+    //  7.  Vendor Extensions
+    iMTPExtensions.CreateL(KMTPMaxStringCharactersLength);
+
+   // 8. Session Initiator version Info
+    iSessionInitiatorVersionInfo = CMTPTypeString::NewL(KDefaultSessionInitiatorVersionInfo);
+
+   //9. Percived device type property.
+   //value for mobile handset is 0x00000003
+   iPerceivedDeviceType.Set(KPercivedDeviceType);
+
+   //10 date time property. no need to creat the string right now, create the
+   //date time string whe it is requested.
+   TBuf<30> dateTimeString;
+   iDateTime = CMTPTypeString::NewL(dateTimeString);
+
+   //11 Device Icon property, Load the icon into Auint Atrray
+   LoadDeviceIconL();
+
+    __FLOG(_L8("ConstructL - Exit"));
+    }
+
+/**
+Indicates if the device information data store is in the EEnumerated state.
+@return ETrue if the device data store state is enumerated, otherwiese EFalse.
+*/
+TBool CMTPDeviceDataStore::Enumerated() const
+    {
+    __FLOG(_L8("Enumerated - Entry"));
+    TInt32 state(State());
+    __FLOG(_L8("Enumerated - Exit"));
+    return (state & EEnumerated);
+    }
+
+/**
+Externalizes device properties to the device property store.
+@param aWriteStream the stream to externalize the device properties
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPDeviceDataStore::ExternalizeL(RWriteStream& aWriteStream) const
+    {
+    __FLOG(_L8("ExternalizeL - Entry"));
+    aWriteStream.WriteInt32L(KMTPDevicePropertyStoreVersion);
+    aWriteStream << DeviceFriendlyName();
+    aWriteStream << SynchronisationPartner();
+    __FLOG(_L8("ExternalizeL - Exit"));
+    }
+
+/**
+Internalises device properties from the device property store.
+@param aReadStream The device property store input data stream.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPDeviceDataStore::InternalizeL(RReadStream& aReadStream)
+    {
+    __FLOG(_L8("InternalizeL - Entry"));
+    RBuf buf;
+    buf.CleanupClosePushL();
+
+    /*
+    Read the device property store version. This is present for future
+    expansion but is currently ignored.
+    */
+    TInt32 version(aReadStream.ReadInt32L());
+
+    // Read the device friendly name.
+    buf.CreateL(aReadStream, KMTPMaxStringCharactersLength);
+    iDeviceFriendlyName->SetL(buf);
+    buf.Close();
+
+    // Read the synchronisation partner name.
+    buf.CreateL(aReadStream, KMTPMaxStringCharactersLength);
+    iSynchronisationPartner->SetL(buf);
+    buf.Close();
+
+    CleanupStack::Pop();  //buf
+    __FLOG(_L8("InternalizeL - Exit"));
+    }
+
+/**
+Provides the full pathname of the device property store.
+@return The full pathname of the device property store.
+*/
+const TDesC& CMTPDeviceDataStore::PropertyStoreName()
+    {
+    __FLOG(_L8("PropertyStoreName - Entry"));
+    if (iPropertyStoreName.Length() == 0)
+        {
+        iSingletons.Fs().PrivatePath(iPropertyStoreName);
+        iPropertyStoreName.Insert(0, KMTPDevicePropertyStoreDrive);
+        iPropertyStoreName.Append(KMTPNoBackupFolder);
+        iPropertyStoreName.Append(KMTPDevicePropertyStoreFileName);
+        }
+
+    __FLOG(_L8("PropertyStoreName - Exit"));
+    return iPropertyStoreName;
+    }
+
+/**
+Query all dps for the MTP Vendor extensions set.
+@return ETrue if finished querying all the dps, otherwise EFalse.
+*/
+void CMTPDeviceDataStore::AppendMTPExtensionSetsL(TBool& aCompleted)
+    {
+    __FLOG(_L8("AppendMTPExtensionSetsL - Entry"));
+	CMTPDataProviderController& dps(iSingletons.DpController());
+	const TInt count = Min<TInt>(iCurrentDpIndex + KExtensionSetIterationRunLength, dps.Count());
+	aCompleted = EFalse;
+	CDesCArraySeg* extensions = new (ELeave) CDesCArraySeg(KExtensionSetGranularity);
+	CleanupStack::PushL(extensions);
+	while (!aCompleted && (iCurrentDpIndex < count))
+		{
+		CMTPDataProvider& dp(dps.DataProviderByIndexL(iCurrentDpIndex));
+		dp.Plugin().SupportedL(EVendorExtensionSets, *extensions);
+		//append the mtp extension string.
+		TInt n = extensions->Count();
+		TInt len = iMTPExtensions.Length();
+		for (TInt i = 0; i < n; i++)
+			{
+			len += (*extensions)[i].Length() + KMTPVendorExtensionSetDelimiter().Length();
+			if (len > KMTPMaxStringCharactersLength)
+				{
+				__FLOG(_L8("MTP Extensions set exceeded the maximum MTP String length"));
+				// End querying dps when the extension set exceeds the maximum mtp string length.
+				aCompleted = ETrue;
+				break;
+				}
+			else
+				{
+				if ( KErrNotFound == iMTPExtensions.Find((*extensions)[i]) )
+					{
+					iMTPExtensions.Append((*extensions)[i]);
+					iMTPExtensions.Append(KMTPVendorExtensionSetDelimiter);
+					}
+				}
+			}
+		extensions->Reset();
+		iCurrentDpIndex++;
+		}
+	CleanupStack::PopAndDestroy(extensions);
+
+	if(!aCompleted && iCurrentDpIndex >= dps.Count())
+		{
+		aCompleted = ETrue;
+		}
+
+	__FLOG(_L8("AppendMTPExtensionSetsL - Exit"));
+    }
+
+/**
+Loads device properties from the device property store.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPDeviceDataStore::RestoreL()
+    {
+    __FLOG(_L8("RestoreL - Entry"));
+    RFs& fs(iSingletons.Fs());
+    if(BaflUtils::FileExists(fs, PropertyStoreName()))
+        {
+        CFileStore* store(CDirectFileStore::OpenLC(fs, PropertyStoreName(), EFileRead));
+        RStoreReadStream instream;
+        instream.OpenLC(*store, store->Root());
+        InternalizeL(instream);
+        CleanupStack::PopAndDestroy(2, store); // instream, store
+        }
+    __FLOG(_L8("RestoreL - Exit"));
+    }
+
+/**
+Schedules the device information data store to transition to the specified state.
+@param aState The new data stream state.
+*/
+void CMTPDeviceDataStore::Schedule(TInt32 aState)
+    {
+    __FLOG(_L8("Schedule - Entry"));
+    SetState(aState);
+    SetRequestPending(iStatus);
+    SetActive();
+    SetRequestComplete(iStatus,KErrNone);
+    __FLOG(_L8("Schedule - Exit"));
+    }
+
+/**
+Completes the supplied asynchronous request completion status.
+*/
+void CMTPDeviceDataStore::SetRequestComplete(TRequestStatus& aRequest, TUint aErr)
+    {
+    __FLOG(_L8("CompleteRequest - Entry"));
+    TRequestStatus* status(&aRequest);
+    User::RequestComplete(status, aErr);
+    __FLOG(_L8("CompleteRequest - Exit"));
+    }
+
+
+/**
+Initialises the supplied asynchronous request completion status.
+*/
+void CMTPDeviceDataStore::SetRequestPending(TRequestStatus& aRequest)
+    {
+    __FLOG(_L8("SetRequestPending - Entry"));
+    aRequest = KRequestPending;
+    __FLOG(_L8("SetRequestPending - Exit"));
+    }
+
+/**
+Sets the device information data store state variable.
+@param aState The new data stream state.
+*/
+void CMTPDeviceDataStore::SetState(TInt32 aState)
+    {
+    __FLOG(_L8("SetState - Entry"));
+    iState = ((EEnumerated & iState) | aState);
+    __FLOG_VA((_L8("State set to 0x%08X"), iState));
+    __FLOG(_L8("SetState - Exit"));
+    }
+
+/**
+Provides the device information data store state variable value.
+@return The device information data store state variable value.
+*/
+TInt32 CMTPDeviceDataStore::State() const
+    {
+    __FLOG(_L8("State - Entry"));
+    __FLOG_VA((_L8("State = 0x%08X"), iState));
+    __FLOG(_L8("State - Exit"));
+    return iState;
+    }
+
+/**
+Stores device properties in the device property store.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPDeviceDataStore::StoreL()
+    {
+    __FLOG(_L8("StoreL - Entry"));
+    CFileStore* store(CDirectFileStore::ReplaceLC(iSingletons.Fs(), PropertyStoreName(), EFileWrite));
+    store->SetTypeL(KDirectFileStoreLayoutUid);
+    RStoreWriteStream outstream;
+    TStreamId id = outstream.CreateLC(*store);
+    ExternalizeL(outstream);
+    outstream.CommitL();
+    CleanupStack::PopAndDestroy(&outstream);
+    store->SetRootL(id);
+    store->CommitL();
+    CleanupStack::PopAndDestroy(store);
+    __FLOG(_L8("StoreL - Exit"));
+    }
+
+/**
+Formats the specified serial number as a valid MTP Serial Number string. The
+MTP specification recommends that the serial number always be represented as
+exactly 32 characters, with leading zeros as required.
+*/
+void CMTPDeviceDataStore::StoreFormattedSerialNumber(const TDesC& aSerialNo)
+    {
+    __FLOG(_L8("FormatSerialNumber - Entry"));
+    TBuf<KMTPSerialNumberLength> formatted;
+    if (aSerialNo.Length() < KMTPSerialNumberLength)
+        {
+        formatted = aSerialNo;
+        }
+    else
+        {
+        /*
+        Supplied serial number data is greater than or equal to the required
+        32 characters. Extract the least significant 32 characters.
+        */
+        formatted = aSerialNo.Right(KMTPSerialNumberLength);
+        }
+
+    // Store the formatted serial number.
+    iPhoneIdV1.iSerialNumber = formatted;
+
+    __FLOG(_L8("FormatSerialNumber - Exit"));
+    }
+
+/**
+* Get method for Session initiator version info(0xD406).
+*
+* @return TDesC& : session initiator version info
+*/
+const TDesC& CMTPDeviceDataStore::SessionInitiatorVersionInfo() const
+	{
+	__FLOG(_L8("SessionInitiatorVersionInfo - Entry:Exit"));
+	return iSessionInitiatorVersionInfo->StringChars();
+	}
+
+/**
+* Get method for Session initiator version info Default value.
+*
+* @return TDesC& : session initiator version info default.
+*/
+const TDesC& CMTPDeviceDataStore::SessionInitiatorVersionInfoDefault() const
+	{
+	__FLOG(_L8("SessionInitiatorVersionInfoDefault - Entry:Exit"));
+	return KDefaultSessionInitiatorVersionInfo;
+	}
+
+/**
+* Set method for Session initiator version info(0xD406).
+*
+* @Param TDesC& : session initiator version info from the initiator
+*/
+void CMTPDeviceDataStore::SetSessionInitiatorVersionInfoL(const TDesC& aVerInfo)
+	{
+	 __FLOG(_L8("SetDeviceFriendlyNameL - Entry"));
+	 iSessionInitiatorVersionInfo->SetL(aVerInfo);
+	 StoreL();
+	 __FLOG(_L8("SetDeviceFriendlyNameL - Exit"));
+	}
+
+/**
+* Get method for PerceivedDeviceTypeDefault(0x00000000	Generic).
+*
+* @return TUint32: return value for PerceivedDeviceTypeDefault
+*/
+TUint32 CMTPDeviceDataStore::PerceivedDeviceTypeDefault() const
+	{
+	__FLOG(_L8("SessionInitiatorVersionInfoDefault - Entry:Exit"));
+	return DefaultPerceivedDeviceType;
+	}
+
+/**
+* Get method for PerceivedDeviceType(0x00000003 Mobile Handset).
+* possible values for PerceivedDeviceType are
+* 0x00000000	Generic.
+* 0x00000001	Still Image/Video Camera.
+* 0x00000002	Media (Audio/Video) Player.
+* 0x00000003	Mobile Handset.
+* 0x00000004	Digital Video Camera.
+* 0x00000005	Personal Information Manager/Personal Digital Assistant.
+* 0x00000006	Audio Recorder.
+* @return TUint32: return value for PerceivedDeviceType.
+*/
+TUint32 CMTPDeviceDataStore::PerceivedDeviceType() const
+	{
+	__FLOG(_L8("SessionInitiatorVersionInfo - Entry:Exit"));
+	return iPerceivedDeviceType.Value();
+	}
+
+/**
+* Get method for Date time.
+* @return TDesC: const date time string YYYYMMDDThhmmss.s
+**/
+const TDesC& CMTPDeviceDataStore::DateTimeL()
+	{
+	__FLOG(_L8("DateTime - Entry:Exit"));
+	TBuf<30> dateTimeString;
+	DateTimeToStringL(dateTimeString);
+	iDateTime->SetL(dateTimeString);
+	__FLOG(_L8("DateTime -Exit"));
+	return iDateTime->StringChars();
+	}
+
+/**
+* This method to set the date time on MTP device
+* incoming date time string will be having a format YYYYMMDDThhmmss.s
+* it need to modify accordingly to set the time.
+*
+*@Param aDateTime : Date time string.
+* Some modification need to be done on this method(minor change).
+**/
+TInt CMTPDeviceDataStore::SetDateTimeL(const TDesC& aDateTime )
+    {
+    __FLOG(_L8("SetDateTime - Entry"));
+    TBuf<30> dateTime;
+    TInt offset = User::UTCOffset().Int();
+	//get actul time to set, offset  + ,- or UTC and offset from UTC in seconds.
+    TInt errorCode = ValidateString(aDateTime, dateTime, offset);
+    if(KErrNone == errorCode)
+	{
+	    StringToDateTime(dateTime);
+	    iDateTime->SetL(dateTime);
+	    StoreL();
+	    //now set the system time by calling user SetUTCTime
+	    TTime tt;
+	    errorCode = tt.Set(dateTime);
+            // tt is currently in an unknown time zone -- now adjust to UTC.
+	    if(KErrNone == errorCode)
+	   	{
+                  //if date time is YYYYMMDDTHHMMSS.S or append with 'Z' then
+		  TTimeIntervalSeconds utcOffset(offset);
+        	  // Subtract seconds ahead, to get to UTC timezone
+         	  tt -= utcOffset;
+        	  __FLOG(_L8("Setting UTC time"));
+        	  errorCode = User::SetUTCTime(tt);
+                  __FLOG_STMT(TBuf<30> readable;)
+        	  __FLOG_STMT(tt.FormatL(readable, _L("%F%Y%M%DT%H%T%SZ"));)
+        	  __FLOG_1(_L("Time now: %S"), &readable);
+                }
+        }
+        __FLOG_1(_L8("SetDateTime - Exit %d"), errorCode);
+
+	return errorCode;
+    }
+
+
+/**
+*This method will create a string that is compatible for MTP datet time .
+* Format("YYYYMMDDThhmmss.s") microsecond part is not implemented
+* yet but that can be done easly. one more function can be implemented
+* for appending 0s
+**/
+void CMTPDeviceDataStore::DateTimeToStringL(TDes& aDateTime)
+    {
+    __FLOG(_L8("DateTimeToString - Entry"));
+    //get home time and convert it to string
+    TTime tt;
+    tt.UniversalTime();    
+    _LIT(KFormat,"%F%Y%M%DT%H%T%SZ");
+    tt.FormatL(aDateTime, KFormat);
+    __FLOG(_L8("DateTimeToString - Exit"));
+	}
+
+/**
+*This method will convert MTP date time format ("YYYYMMDDThhmmss.s")to
+*TTime time format YYYYMMDD:hhmmss.ssssss. Right now microsecond part is
+* not implemented.
+**/
+void CMTPDeviceDataStore::StringToDateTime(TDes& aDateTime )
+	{
+    __FLOG(_L8("StringToDateTime - Entry"));
+	TBuf<30> newTime;
+	_LIT(KDlemMTP,"T");
+	_LIT(KDlemTTime,":");
+	TInt pos = aDateTime.Find(KDlemMTP)	;
+	if((KErrNotFound != pos) && (KPosDelemT == pos))
+		{
+		const TInt KYearDigits = 4;
+                const TInt KMonthDigits = 2;
+                const TInt KDayDigits = 2;
+
+                TInt month = 0;
+                TLex monthLex(aDateTime.Mid(KYearDigits, KMonthDigits));
+                //coverity[unchecked_value]
+                monthLex.Val(month);
+                
+                TInt day = 0;
+                TLex dayLex(aDateTime.Mid(KYearDigits+KMonthDigits, KDayDigits));
+                //coverity[unchecked_value]
+                dayLex.Val(day);
+
+                _LIT(KDateFormat, "%S%02d%02d");
+                TPtrC year(aDateTime.Left(KYearDigits));
+                newTime.AppendFormat(KDateFormat, &year, month - 1, day - 1);
+
+	        newTime.Append(KDlemTTime);
+		newTime.Append(aDateTime.Mid(pos + 1));
+		aDateTime.Copy(newTime);
+		}
+	else
+		{
+		_LIT(KPanic, "date time ");
+		User::Panic(KPanic, 3);
+		}
+        __FLOG_1(_L("Processed DateTime: %S"), &aDateTime);	
+	__FLOG(_L8("StringToDateTime - Exit"));
+	}
+
+/**
+*This method to validate the incoming date time string
+*Any incoming string from intiator supposed to be either  YYYYMMDDThhmmss.s
+* or YYYYMMDDT(Z/+/-)hhmmss.s form
+*1.validation is done based on minimum length of the string
+*2.based on the carector and its position.
+*char allowded are 'Z', 'T', '.','+' and '-'
+*/
+TInt CMTPDeviceDataStore::ValidateString(const TDesC& aDateTimeStr, TDes& aDateTime, TInt &aOffsetVal)
+	{
+        __FLOG(_L8("ValidateString - Entry"));
+        __FLOG_1(_L("Supplied date: %S"), &aDateTimeStr);
+	_LIT(KDlemMTP,"T");
+	TInt errCode = KErrNone;
+	TInt pos = aDateTimeStr.Find(KDlemMTP);
+        TInt nullCharPos = aDateTimeStr.Locate('\0');
+	if ( KErrNotFound != nullCharPos )
+		{		
+		aDateTime.Copy( aDateTimeStr.Left(nullCharPos));
+		}
+	else
+		{
+		aDateTime.Copy(aDateTimeStr);
+		}
+
+	//1.validation is done based on minimum length of the string and pos
+	if((KErrNotFound ==  pos )	|| (aDateTimeStr.Length() > KMaxDateTimeLength) ||
+	    (aDateTimeStr.Length() < KMinDateTimeLength) || pos != KPosDelemT)
+		{
+                __FLOG_2(_L8("Invalid. pos: %d, len: %d"), pos, aDateTimeStr.Length());
+		errCode = KErrGeneral;
+		}
+	else
+		{
+		//validation based on the carector and its position.
+		for(TInt i =0 ; i< aDateTimeStr.Length(); i ++)
+		{
+		//any other string other than 'Z', 'T', '.','+' and '-' or positon is wrong return
+		if(('0' > aDateTimeStr[i]) || ('9' < aDateTimeStr[i]))
+			{
+			switch(aDateTimeStr[i])
+				{
+				case 'T':
+				case 't':
+				if(i != pos)
+					{
+                                        __FLOG_1(_L8("Invalid. 'T' encountered at offset %d"), i);
+					//error char at rong position
+					errCode = KErrGeneral;
+					}//else fine
+				break;
+				case 'Z':
+				case 'z':
+					aOffsetVal = 0;
+                                        aDateTime.Copy(aDateTimeStr.Mid(0, i));
+					//error char at wrong position
+					if(i <KMinDateTimeLength)
+						{
+                                                __FLOG_1(_L8("Invalid. 'Z' encountered at offset %d"), i);
+						//error char at wrong position
+						errCode = KErrGeneral;
+						}//else fine
+					break;
+				case '+':
+				case '-':
+					if(i < KMinDateTimeLength)
+						{
+						//error char at wrong position
+						errCode = KErrGeneral;
+                                                __FLOG_1(_L8("Invalid. '+/-' encountered at offset %d"), i);
+						break;
+						}
+					else
+						{
+						const TInt KHoursDigits = 2;
+                                                const TInt KMinutesDigits = 2;
+                                                const TInt KSecondsPerMinute = 60;
+                                                const TInt KSecondsPerHour = KSecondsPerMinute * 60;
+						aDateTime.Copy(aDateTimeStr.Mid(0, i));
+
+                                                TUint hourOffset = 0;
+                                                TLex hourOffsetLex(aDateTimeStr.Mid(i+1, KHoursDigits));
+                                                hourOffsetLex.Val(hourOffset);
+
+                                                TUint minuteOffset = 0;
+                                                TLex minuteOffsetLex(aDateTimeStr.Mid(i+KHoursDigits+1, KMinutesDigits));
+                                                minuteOffsetLex.Val(minuteOffset);
+						if ((hourOffset > 23) || (minuteOffset > 59))
+                                                     {
+                                                     errCode = KErrGeneral;
+                                                     __FLOG_2(_L8("Invalid. Hour(%d) or Minute(%d) offset out of range."), hourOffset, minuteOffset);
+                                                     break;
+                                                     }
+
+                                                     
+                                                aOffsetVal = (hourOffset * KSecondsPerHour) + (minuteOffset * KSecondsPerMinute);
+                                                if ('-' == aDateTimeStr[i])
+							{
+					                aOffsetVal = -aOffsetVal;
+							}
+                                                __FLOG_1(_L8("Info: Timezone offset %d seconds"), aOffsetVal);	
+						}
+
+					break;
+				case '.':
+				case '\0':
+				if(i < KMinDateTimeLength)
+					{
+					//error char at wrong position
+					errCode = KErrGeneral;
+                                        __FLOG_1(_L8("Invalid. '.' or NULL at offset %d"), i);
+					}
+				break;
+				default :
+				//wrong char
+				errCode = KErrGeneral;
+                                __FLOG_2(_L8("Invalid. Character %04x at offset %d"), aDateTimeStr[i], i);
+				break;
+				}
+		}
+		if(KErrNone != errCode)
+			{
+		        __FLOG_2(_L("Processed date: %S, TimeZone: %ds ahead"), &aDateTimeStr, aOffsetVal);
+                        __FLOG_1(_L8("ValidateString - Exit %d"), errCode);
+			return errCode;
+			}
+		}
+	}
+	__FLOG_2(_L("Processed date: %S, TimeZone: %ds ahead"), &aDateTimeStr, aOffsetVal);
+        __FLOG_1(_L8("ValidateString - Exit %d"), errCode);
+	return errCode;
+	}
+
+/**
+*This method is to load/Store the deviceIcon to the  CMTPTypeArray iDeviceIcon
+*  some improvment is possible here.
+*/
+void CMTPDeviceDataStore::LoadDeviceIconL()
+	{
+	RFile rFile;
+	RFs  rFs;
+	//device icon should be stored in an array of type uint8
+	iDeviceIcon = CMTPTypeArray::NewL(EMTPTypeAUINT8);
+	TInt error = rFs.Connect();
+	if(error == KErrNone )
+		{
+		error = rFile.Open(rFs, KFileName, EFileRead);
+		//for buffer size we could have used VolumeIOParam()
+		//metho to get optimal cluseter size, it could be(1, 2, 4 kb)
+		//but it is not make much difference in performance if we use 1kb buffer
+		TBuf8<KBufferSize> buffer;
+		if(error == KErrNone )
+			{
+			TUint length =0;
+			while(ETrue)
+				{
+				error = rFile.Read(buffer, KBufferSize);
+				length = buffer.Length();
+				if((0 != length) && ( KErrNone == error))
+					{
+					for(TUint index = 0; index < length; index++ )
+						{
+							iDeviceIcon->AppendUintL(buffer[index]);
+						}
+					}
+				else
+					{
+					break;
+					}
+				}
+			}
+		rFile.Close();
+		}
+		rFs.Close();
+	}
+
+/**
+*Get method fro DeviceIcon, return value is a type unint array.
+*
+*@return iDeviceIcon: array of uint
+*/
+const CMTPTypeArray& CMTPDeviceDataStore::DeviceIcon()
+    {
+     return *iDeviceIcon;
+    }
+
+/**
+*This method is to store the supported device properties
+*/
+void CMTPDeviceDataStore::SetSupportedDevicePropertiesL(RArray<TUint>& aSupportedDevProps)
+    {
+    CheckDeviceIconProperties(aSupportedDevProps);
+    delete iSupportedDevProArray;
+    iSupportedDevProArray = NULL;
+    iSupportedDevProArray =  CMTPTypeArray::NewL(EMTPTypeAUINT16, aSupportedDevProps);
+    }
+/**
+*This method is to store the devicedp reference
+*/
+void CMTPDeviceDataStore::SetExtnDevicePropDp(MExtnDevicePropDp* aExtnDevicePropDp)
+    {
+    iExtnDevicePropDp = aExtnDevicePropDp;
+    };
+
+/**
+*This method returns the devicedp reference
+*/
+MExtnDevicePropDp* CMTPDeviceDataStore::ExtnDevicePropDp()
+{
+	return iExtnDevicePropDp;
+};
+
+
+/**
+*This method to get supported device properties
+**/
+const CMTPTypeArray& CMTPDeviceDataStore::GetSupportedDeviceProperties()
+    {
+    return *iSupportedDevProArray;
+    }
+
+/**
+This method will remove the property that is not supported
+As of now, will check the device icon property support
+*/
+void CMTPDeviceDataStore::CheckDeviceIconProperties( RArray<TUint> &aSupportedDeviceProperties)
+	{
+	//store the index value if device property.
+	TUint index = aSupportedDeviceProperties.Find(EMTPDevicePropCodeDeviceIcon);
+	if(KErrNotFound != (TInt)index)
+	{
+	RFs rFs;
+	RFile rFile;
+	TInt error = rFs.Connect();
+	if(KErrNone == error)
+		{
+		error = rFile.Open(rFs, KFileName, EFileRead);
+		}//else do nothing.
+	if(KErrNone != error)
+		{
+		//control reach here only when there is no file exists or any other error situation
+		//so remove the property from the list
+		aSupportedDeviceProperties.Remove(index);
+		}//else do nothing
+	rFile.Close();
+	rFs.Close();
+	}//else nothing to do.
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedp.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,526 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtpstoragemetadata.h>
+#include <mtp/mmtpconnection.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpdataproviderapitypes.h>
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpdevdpexclusionmgr.h"
+#include "cmtpdevicedatastore.h"
+#include "cmtpdevicedp.h"
+#include "cmtpdevicedpconfigmgr.h"
+#include "cmtpfsenumerator.h"
+#include "cmtprequestprocessor.h"
+#include "cmtpstoragewatcher.h"
+#include "mtpdevicedpconst.h"
+#include "mtpdevicedpprocessor.h"
+#include "mtpdevdppanic.h"
+
+#include "cmtpextndevdp.h"
+#include <mtp/cmtptypestring.h>
+
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"DeviceDataProvider");)
+static const TInt KMTPDeviceDpSessionGranularity(3);
+static const TInt KMTPDeviceDpActiveEnumeration(0);
+
+/**
+MTP device data provider plug-in factory method.
+@return A pointer to an MTP device data provider plug-in. Ownership IS
+transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+TAny* CMTPDeviceDataProvider::NewL(TAny* aParams)
+    {
+    CMTPDeviceDataProvider* self = new (ELeave) CMTPDeviceDataProvider(aParams);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/
+CMTPDeviceDataProvider::~CMTPDeviceDataProvider()
+    {
+    __FLOG(_L8("~CMTPDeviceDataProvider - Entry"));
+    iPendingEnumerations.Close();
+    TInt count = iActiveProcessors.Count();
+    while(count--)
+        {
+        iActiveProcessors[count]->Release();
+        }
+    iActiveProcessors.Close();
+    delete iStorageWatcher;
+    iDevDpSingletons.Close();
+    iDpSingletons.Close();
+    delete iEnumerator;
+    delete iExclusionMgr;
+
+    iExtnPluginMapArray.ResetAndDestroy();
+    iExtnPluginMapArray.Close();
+	iEvent.Reset();
+
+    __FLOG(_L8("~CMTPDeviceDataProvider - Exit"));
+    __FLOG_CLOSE;
+    }
+
+void CMTPDeviceDataProvider::Cancel()
+    {
+
+    }
+
+void CMTPDeviceDataProvider::ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection)
+    {
+    __FLOG(_L8("ProcessEventL - Entry"));
+    TInt index = LocateRequestProcessorL(aEvent, aConnection);
+    if(index != KErrNotFound)
+        {
+        iActiveProcessors[index]->HandleEventL(aEvent);
+        }
+    __FLOG(_L8("ProcessEventL - Exit"));
+    }
+
+void CMTPDeviceDataProvider::ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams)
+    {
+    __FLOG(_L8("ProcessNotificationL - Entry"));
+    switch (aNotification)
+        {
+    case EMTPSessionClosed:
+        SessionClosedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams));
+        break;
+
+    case EMTPSessionOpened:
+        SessionOpenedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams));
+        break;
+
+    default:
+        // Ignore all other notifications.
+        break;
+        }
+    __FLOG(_L8("ProcessNotificationL - Exit"));
+    }
+
+void CMTPDeviceDataProvider::ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {
+    __FLOG(_L8("ProcessRequestPhaseL - Entry"));
+    TInt index = LocateRequestProcessorL(aRequest, aConnection);
+    __ASSERT_DEBUG(index != KErrNotFound, Panic(EMTPDevDpNoMatchingProcessor));
+    MMTPRequestProcessor* processor = iActiveProcessors[index];
+    iActiveProcessor = index;
+    iActiveProcessorRemoved = EFalse;
+    TBool result = processor->HandleRequestL(aRequest, aPhase);
+    if (iActiveProcessorRemoved)
+	    {
+	    processor->Release(); // destroy the processor
+	    }
+    else if (result)
+	    {
+	    processor->Release();    	
+	    iActiveProcessors.Remove(index);
+	    }
+    iActiveProcessor = -1;
+    __FLOG(_L8("ProcessRequestPhaseL - Exit"));
+    }
+
+void CMTPDeviceDataProvider::StartObjectEnumerationL(TUint32 aStorageId, TBool /*aPersistentFullEnumeration*/)
+    {
+    __FLOG(_L8("StartObjectEnumerationL - Entry"));
+    iPendingEnumerations.AppendL(aStorageId);
+    if (iEnumeratingState == EUndefined)
+        {
+        iDevDpSingletons.DeviceDataStore().StartEnumerationL(aStorageId, *this);
+        iEnumeratingState = EEnumeratingDeviceDataStore;
+        iStorageWatcher->Start();
+        }
+    else if (iPendingEnumerations.Count() == 1)
+        {
+    	iEnumeratingState = EEnumeratingFolders;
+    	iEnumerator->StartL(iPendingEnumerations[KMTPDeviceDpActiveEnumeration]);
+        }
+    __FLOG(_L8("StartObjectEnumerationL - Exit"));
+    }
+
+void CMTPDeviceDataProvider::StartStorageEnumerationL()
+    {
+    __FLOG(_L8("StartStorageEnumerationL - Entry"));
+    iStorageWatcher->EnumerateStoragesL();
+    Framework().StorageEnumerationCompleteL();
+    __FLOG(_L8("StartStorageEnumerationL - Exit"));
+    }
+
+void CMTPDeviceDataProvider::Supported(TMTPSupportCategory aCategory, RArray<TUint>& aArray) const
+    {
+    __FLOG(_L8("Supported - Entry"));
+    TInt mode = Framework().Mode();
+    switch (aCategory)
+        {
+    case EAssociationTypes:
+        aArray.Append(EMTPAssociationTypeGenericFolder);        
+        break;
+
+    case EDeviceProperties:
+        {
+        TInt count = sizeof(KMTPDeviceDpSupportedProperties) / sizeof(TUint16);
+        for(TInt i = 0; i < count; i++)
+            {
+            if(( (EModePTP == mode) ||(EModePictBridge == mode) )
+				&& ( 0x4000 == (KMTPDeviceDpSupportedProperties[i] & 0xE000)))
+            	{
+            	//in ptp mode support only ptp properties
+            	aArray.Append(KMTPDeviceDpSupportedProperties[i]);
+            	}
+            else
+            	{
+            	aArray.Append(KMTPDeviceDpSupportedProperties[i]);
+            	}
+            }
+           
+        TInt noOfEtxnPlugins = iExtnPluginMapArray.Count();
+        for(TInt i=0; i < noOfEtxnPlugins; i++)
+	        {
+	        iExtnPluginMapArray[i]->ExtPlugin()->Supported(aCategory, *iExtnPluginMapArray[i]->SupportedOpCodes(), (TMTPOperationalMode)mode );// or pass the incoming array
+	        TInt count =iExtnPluginMapArray[i]->SupportedOpCodes()->Count();
+       												  														//bcoz it needs to b updated
+	        for (TInt r=0; r <count; r++ )
+	        	{
+	        	aArray.Append((*iExtnPluginMapArray[i]->SupportedOpCodes())[r]);
+	        	}
+	       }
+
+       TRAP_IGNORE(iPtrDataStore->SetSupportedDevicePropertiesL(aArray));
+       }
+        break;
+
+    case EEvents:
+        {
+        TInt count = sizeof(KMTPDeviceDpSupportedEvents) / sizeof(TUint16);
+        for(TInt i = 0; i < count; i++)
+            {
+            TUint16 event = KMTPDeviceDpSupportedEvents[i];
+            switch(mode)
+                {
+            case EModePTP:
+            case EModePictBridge:
+                // In the initial implementation all device DP events pass this test, but this
+                // catches any others added in the future that fall outside this range.
+                if(event <= EMTPEventCodePTPEnd)
+                    {
+                    aArray.Append(event);
+                    }
+                break;
+
+            case EModeMTP:
+                // In the initial implementation all device DP events pass this test, but this
+                // catches any others added in the future that fall outside this range.
+                if(event <= EMTPEventCodeMTPEnd)
+                    {
+                    aArray.Append(event);
+                    }
+                break;
+
+            default:
+            	// No other valid modes are defined
+                break;
+                }
+            }
+        }
+        break;
+
+    case EObjectCaptureFormats:
+    case EObjectPlaybackFormats:
+  		// Only supports association objects
+        aArray.Append(EMTPFormatCodeAssociation);
+        break;
+
+
+    case EOperations:
+        {
+        TInt count = sizeof(KMTPDeviceDpSupportedOperations) / sizeof(TUint16);
+        for(TInt i = 0; i < count; i++)
+            {
+            aArray.Append(KMTPDeviceDpSupportedOperations[i]);
+            }
+        }
+        break;
+
+    case EStorageSystemTypes:
+        aArray.Append(CMTPStorageMetaData::ESystemTypeDefaultFileSystem);
+        break;
+
+    case EObjectProperties:
+        {
+        TInt count(sizeof(KMTPDeviceDpSupportedObjectProperties) / sizeof(KMTPDeviceDpSupportedObjectProperties[0]));
+        for (TInt i(0); (i < count); i++)
+            {
+            aArray.Append(KMTPDeviceDpSupportedObjectProperties[i]);
+            }
+        }
+        break;
+
+    default:
+        // Unrecognised category, leave aArray unmodified.
+        break;
+        }
+    __FLOG(_L8("Supported - Exit"));
+    }
+
+#ifdef __FLOG_ACTIVE
+void CMTPDeviceDataProvider::NotifyEnumerationCompleteL(TUint32 aStorageId, TInt aError)
+#else
+void CMTPDeviceDataProvider::NotifyEnumerationCompleteL(TUint32 aStorageId, TInt /*aError*/)
+#endif // __FLOG_ACTIVE
+	{
+    __FLOG(_L8("NotifyEnumerationCompleteL - Entry"));
+    __ASSERT_DEBUG((aStorageId == iPendingEnumerations[KMTPDeviceDpActiveEnumeration]), User::Invariant());
+	switch(iEnumeratingState)
+		{
+	case EEnumeratingDeviceDataStore:
+		iEnumeratingState = EEnumeratingFolders;
+		iEnumerator->StartL(iPendingEnumerations[KMTPDeviceDpActiveEnumeration]);
+		break;
+
+	case EEnumeratingFolders:
+        __FLOG_VA((_L8("Enumeration of storage 0x%08X completed with error status %d"), aStorageId, aError));
+        iPendingEnumerations.Remove(KMTPDeviceDpActiveEnumeration);
+        Framework().ObjectEnumerationCompleteL(aStorageId);
+        if (iPendingEnumerations.Count() > 0)
+            {
+        	iEnumerator->StartL(iPendingEnumerations[KMTPDeviceDpActiveEnumeration]);
+            }
+        else
+            {
+    		iEnumeratingState = EEnumerationComplete;
+            }
+		break;
+
+	case EEnumerationComplete:
+	default:
+		__DEBUG_ONLY(User::Invariant());
+		break;
+		}
+    __FLOG(_L8("NotifyEnumerationCompleteL - Exit"));
+	}
+
+/**
+Constructor.
+*/
+CMTPDeviceDataProvider::CMTPDeviceDataProvider(TAny* aParams) :
+    CMTPDataProviderPlugin(aParams),
+    iActiveProcessors(KMTPDeviceDpSessionGranularity),
+    iActiveProcessor(-1)
+    {
+
+    }
+
+/**
+Load devdp extension plugins if present
+*/
+void CMTPDeviceDataProvider::LoadExtnPluginsL()
+	{
+
+	RArray<TUint> extnUidArray;
+	CleanupClosePushL(extnUidArray);
+	iDevDpSingletons.ConfigMgr().GetRssConfigInfoArrayL( extnUidArray, EDevDpExtnUids);
+
+	TInt count = extnUidArray.Count();
+	for (TInt i = 0; i < count; i++)
+		{
+
+		CDevDpExtnPluginMap* extnpluginMap = NULL;
+		extnpluginMap = CDevDpExtnPluginMap::NewL(*this, TUid::Uid(extnUidArray[i]));
+
+		if(extnpluginMap )
+			{
+			iExtnPluginMapArray.Append(extnpluginMap);
+			}
+
+		}
+	CleanupStack::PopAndDestroy(&extnUidArray);
+	}
+
+/**
+Second phase constructor.
+*/
+void CMTPDeviceDataProvider::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry"));
+    iDevDpSingletons.OpenL(Framework());
+    iPtrDataStore = &(iDevDpSingletons.DeviceDataStore());
+    iDpSingletons.OpenL(Framework());
+
+    iExclusionMgr = CMTPDevDpExclusionMgr::NewL(Framework());
+    iDpSingletons.SetExclusionMgrL(*iExclusionMgr);
+
+    iStorageWatcher = CMTPStorageWatcher::NewL(Framework());
+
+    const TUint KProcessLimit = iDevDpSingletons.ConfigMgr().UintValueL(CMTPDeviceDpConfigMgr::EEnumerationIterationLength);
+
+ 	TRAPD(err, LoadExtnPluginsL());
+ //	__ASSERT_DEBUG((err == KErrNone), Panic(_L("Invalid resource file ")));
+ 	if(KErrNone != err)
+		{
+	    __FLOG(_L8("\nTere is an issue in loading the plugin !!!!!\n"));
+		}
+
+    iEnumerator = CMTPFSEnumerator::NewL(Framework(), iDpSingletons.ExclusionMgrL(), *this, KProcessLimit);
+    __FLOG(_L8("ConstructL - Exit"));
+
+    }
+
+void CMTPDeviceDataProvider::OnDevicePropertyChangedL (TMTPDevicePropertyCode& aPropCode)
+	{
+	iEvent.Reset();
+	iEvent.SetUint16(TMTPTypeEvent::EEventCode, EMTPEventCodeDevicePropChanged );
+	iEvent.SetUint32(TMTPTypeEvent::EEventSessionID, KMTPSessionAll);
+	iEvent.SetUint32(TMTPTypeEvent::EEventTransactionID, KMTPTransactionIdNone);
+	iEvent.SetUint32(TMTPTypeEvent::EEventParameter1, aPropCode);
+	Framework().SendEventL(iEvent);
+	}
+
+/**
+ *This method will return the reference to MMTPDataProviderFramework from CMTPDataProviderPlugin
+ */
+MMTPDataProviderFramework& CMTPDeviceDataProvider::DataProviderFramework ()
+	{
+	return Framework();
+	}
+
+TInt CMTPDeviceDataProvider::FindExtnPlugin(TUint aOpcode)
+	{
+	TInt noOfEtxnPlugins = iExtnPluginMapArray.Count();
+	for(TInt i=0; i < noOfEtxnPlugins; i++)
+		{
+		if(iExtnPluginMapArray[i]->SupportedOpCodes()->Find(aOpcode)!= KErrNotFound)
+			{
+			return i;
+			}
+		}
+	return KErrNotFound;
+	}
+/**
+Find or create a request processor that can process the request
+@param aRequest    The request to be processed
+@param aConnection The connection from which the request comes
+@return the index of the found/created request processor
+*/
+TInt CMTPDeviceDataProvider::LocateRequestProcessorL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {
+    __FLOG(_L8("LocateRequestProcessorL - Entry"));
+    TInt index = KErrNotFound;
+    TInt count = iActiveProcessors.Count();
+    for(TInt i = 0; i < count; i++)
+        {
+        if(iActiveProcessors[i]->Match(aRequest, aConnection))
+            {
+            index = i;
+            break;
+            }
+        }
+    if(index == KErrNotFound)
+        {
+        MMTPRequestProcessor* processor = MTPDeviceDpProcessor::CreateL(Framework(), aRequest, aConnection);
+        __ASSERT_DEBUG(processor, Panic(EMTPDevDpNoMatchingProcessor));
+        CleanupReleasePushL(*processor);
+        iActiveProcessors.AppendL(processor);
+        TUint16 operationCode(aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode));
+
+       if (operationCode >= EMTPOpCodeGetDevicePropDesc && operationCode <=EMTPOpCodeResetDevicePropValue)
+		{
+		TUint propCode = aRequest.Uint32(TMTPTypeRequest::ERequestParameter1);
+		TInt foundplugin = FindExtnPlugin (propCode);
+		if(foundplugin!= KErrNotFound)
+			{
+			iDevDpSingletons.DeviceDataStore().SetExtnDevicePropDp(iExtnPluginMapArray[foundplugin]->ExtPlugin());
+			}
+		}
+	        CleanupStack::Pop();
+	        index = count;
+        }
+    __FLOG(_L8("LocateRequestProcessorL - Exit"));
+    return index;
+    }
+
+/**
+Finds a request processor that can process the event
+@param aEvent    The event to be processed
+@param aConnection The connection from which the request comes
+@return the index of the found request processor, KErrNotFound if not found
+*/
+TInt CMTPDeviceDataProvider::LocateRequestProcessorL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection)
+    {
+    __FLOG(_L8("LocateRequestProcessorL - Entry"));
+    TInt index = KErrNotFound;
+    TInt count = iActiveProcessors.Count();
+    for(TInt i = 0; i < count; i++)
+	{
+	if(iActiveProcessors[i]->Match(aEvent, aConnection))
+		{
+		index = i;
+		break;
+		}
+	}
+    __FLOG(_L8("LocateRequestProcessorL - Exit"));
+    return index;
+    }
+
+/**
+Cleans up outstanding request processors when a session is closed.
+@param aSession notification parameter block
+*/
+void CMTPDeviceDataProvider::SessionClosedL(const TMTPNotificationParamsSessionChange& aSession)
+    {
+    __FLOG(_L8("SessionClosedL - Entry"));
+    TInt count = iActiveProcessors.Count();
+    while(count--)
+        {
+	MMTPRequestProcessor* processor = iActiveProcessors[count];
+	TUint32 sessionId = processor->SessionId();
+	if((sessionId == aSession.iMTPId) && (processor->Connection().ConnectionId() == aSession.iConnection.ConnectionId()))
+		{
+		iActiveProcessors.Remove(count);
+		if (count == iActiveProcessor)
+    		{
+    			iActiveProcessorRemoved = ETrue;
+    		}
+    	else
+    		{        		
+    			processor->Release();
+    		} 
+		}
+        }
+    __FLOG(_L8("SessionClosedL - Exit"));
+    }
+
+/**
+Prepares for a newly-opened session.
+@param aSession notification parameter block
+*/
+#ifdef __FLOG_ACTIVE
+void CMTPDeviceDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession)
+#else
+void CMTPDeviceDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& /*aSession*/)
+#endif
+    {
+    __FLOG(_L8("SessionOpenedL - Entry"));
+    __FLOG_VA((_L8("SessionID = %d"), aSession.iMTPId));
+    __FLOG(_L8("SessionOpenedL - Exit"));
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedpconfigmgr.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,277 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <barsc.h>
+#include <barsread.h>
+
+#include <mtp/mmtpdataproviderconfig.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <102827af.rsg>
+#include "cmtpdevicedpconfigmgr.h"
+
+enum PanicReason
+{
+CMTPDeviceDpConfigMgrPanic = -1,
+};
+#ifdef _DEBUG
+_LIT(KPanicInvalidInt, "Panic is due to invalid Integer");
+_LIT(KPanicinvalidRssConfigParam, "Panic is due to invalid RSS Config Param");
+#endif 
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"DeviceDpConfigMgr");)
+
+CMTPDeviceDpConfigMgr* CMTPDeviceDpConfigMgr::NewL(MMTPDataProviderFramework& aFramework)
+	{
+	CMTPDeviceDpConfigMgr* self = new (ELeave) CMTPDeviceDpConfigMgr(aFramework);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+CMTPDeviceDpConfigMgr::CMTPDeviceDpConfigMgr(MMTPDataProviderFramework& aFramework) :
+	iFramework(aFramework)
+	{
+	}
+	
+void CMTPDeviceDpConfigMgr::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry"));
+    
+	iResourceId = iFramework.DataProviderConfig().UintValue(MMTPDataProviderConfig::EOpaqueResource);
+	
+	RResourceFile resFile;
+	CleanupClosePushL(resFile);
+	
+	resFile.OpenL(iFramework.Fs(), iFramework.DataProviderConfig().DesCValue(MMTPDataProviderConfig::EResourceFileName));
+	HBufC8* res = resFile.AllocReadLC(iResourceId);
+	
+	TResourceReader reader;
+	reader.SetBuffer(res);
+	
+	// WORD - enumeration_iteration_length
+	iEnumItrLength = reader.ReadInt16();
+	
+	// Do not read exclusion_list to conserve memory
+	// - instead read it in dynamically when requested	
+	CleanupStack::PopAndDestroy(res);
+	CleanupStack::PopAndDestroy(&resFile);
+	
+	__FLOG(_L8("ConstructL - Exit"));
+	}
+	
+CMTPDeviceDpConfigMgr::~CMTPDeviceDpConfigMgr()
+	{
+	__FLOG_CLOSE;
+	}
+	
+#ifdef _DEBUG
+TUint CMTPDeviceDpConfigMgr::UintValueL(TParameter aParam) const
+#else
+TUint CMTPDeviceDpConfigMgr::UintValueL(TParameter /*aParam*/) const
+#endif // _DEBUG
+	{
+	__ASSERT_DEBUG(aParam == CMTPDeviceDpConfigMgr::EEnumerationIterationLength, User::Invariant());
+	return iEnumItrLength;
+	}
+	
+	
+#ifdef _DEBUG
+CDesCArray* CMTPDeviceDpConfigMgr::GetArrayValueL(TParameter aParam) const
+#else
+CDesCArray* CMTPDeviceDpConfigMgr::GetArrayValueL(TParameter /*aParam*/) const
+#endif // _DEBUG
+	{
+	__ASSERT_DEBUG(aParam == CMTPDeviceDpConfigMgr::EFolderExclusionList, User::Invariant());
+	return ReadExclusionListL();
+	}
+
+CDesCArray* CMTPDeviceDpConfigMgr::ReadExclusionListL() const
+	{
+	RResourceFile resFile;
+	CleanupClosePushL(resFile);
+	
+	resFile.OpenL(iFramework.Fs(), iFramework.DataProviderConfig().DesCValue(MMTPDataProviderConfig::EResourceFileName));
+	HBufC8* res = resFile.AllocReadLC(iResourceId);
+	
+	TResourceReader reader;
+	reader.SetBuffer(res);
+	
+	// WORD - enumeration_iteration_length, skip it
+	reader.ReadInt16();
+	
+	// ARRAY - exclusion_list
+	CDesCArrayFlat* exclusionList = reader.ReadDesCArrayL();
+	
+	CleanupStack::PopAndDestroy(res);
+	CleanupStack::PopAndDestroy(&resFile);
+	return exclusionList;
+	}
+
+void CMTPDeviceDpConfigMgr::GetDriveInfoL(TInt aDriveNo, TDes& aVolumeName, TDes& aRootDirPath)
+	{
+	__FLOG(_L8("GetDriveInfoL - Entry"));
+	RResourceFile resFile;
+	resFile.OpenL(iFramework.Fs(), iFramework.DataProviderConfig().DesCValue(MMTPDataProviderConfig::EResourceFileName));
+	CleanupClosePushL(resFile);
+	HBufC8* dataBuffer=resFile.AllocReadLC(DRIVES);
+	
+	TResourceReader reader;
+	reader.SetBuffer(dataBuffer);
+	TInt maxDrives = reader.ReadInt16();
+	__FLOG_VA((_L8("aDriveNo = %d"), aDriveNo));
+	TBool found = EFalse;
+	for(TInt driveIndex = 0; driveIndex < maxDrives; driveIndex++)
+		{
+		TInt driveNumber = reader.ReadInt16();
+		TPtrC volumeName = reader.ReadTPtrC();
+		TPtrC rootDirName = reader.ReadTPtrC();
+
+		if(driveNumber ==  aDriveNo)
+			{
+			found = ETrue;
+			__FLOG_VA((_L8("Found the drive! Drive Number = %d"), driveNumber));
+			if ((KMaxFileName > volumeName.Length()) && 
+			    (KMaxFileName > rootDirName.Length())
+			    )
+				{
+				aVolumeName = volumeName;
+				aRootDirPath = rootDirName;
+				}
+			else
+				{
+				__FLOG(_L8("VolumeName or RootDirName length is more than KMaxFileName"));
+				// volumeName and/or rootDirName specified in resource file is too lengthy.
+				User::Leave(KErrArgument);
+				}			
+			break;
+			}
+		}
+	
+	if (!found)
+		{
+		__FLOG_VA((_L8("No match in resource file for Drive Number = %d"), aDriveNo));
+		// Matching drive number was not found in resource file.
+		User::Leave(KErrNotFound);
+		}
+		
+	CleanupStack::PopAndDestroy(dataBuffer);
+	CleanupStack::PopAndDestroy(&resFile);
+	__FLOG(_L8("GetDriveInfoL - Exit"));
+	}
+
+void CMTPDeviceDpConfigMgr::GetFriendlyVolumeNameL(TInt aDriveNo, TDes& aVolumeName)
+	{
+	__FLOG(_L8("GetFriendlyVolumeNameL - Entry"));
+	RBuf rootDirPath;
+	rootDirPath.CreateL(KMaxFileName);
+	rootDirPath.CleanupClosePushL();
+	GetDriveInfoL(aDriveNo, aVolumeName, rootDirPath);
+	CleanupStack::PopAndDestroy();
+	__FLOG(_L8("GetFriendlyVolumeNameL - Exit"));
+	}
+
+void CMTPDeviceDpConfigMgr::GetRootDirPathL(TInt aDriveNo, TDes& aRootDirPath)
+	{
+	__FLOG(_L8("GetRootDirPathL - Entry"));
+	RBuf volumeName;
+	volumeName.CreateL(KMaxFileName);
+	volumeName.CleanupClosePushL();
+	GetDriveInfoL(aDriveNo, volumeName, aRootDirPath);
+	CleanupStack::PopAndDestroy();
+	__FLOG(_L8("GetRootDirPathL - Exit"));
+	}
+
+/**
+  *This method is to get the ordered format from the rss file
+  *
+  *@param aOrderInfoArray : is an array for storing ordered formats(out param).
+  * 
+  */
+ void CMTPDeviceDpConfigMgr::GetRssConfigInfoArrayL(RArray<TUint>& aOrderInfoArray, TDevDPConfigRSSParams aParam)
+	{
+	__FLOG(_L8("GetOrderedFormatInfo - Entry"));
+	RResourceFile resFile;
+	resFile.OpenL(iFramework.Fs(), iFramework.DataProviderConfig().DesCValue(MMTPDataProviderConfig::EResourceFileName));
+	CleanupClosePushL(resFile);
+	HBufC8* dataBuffer = NULL;
+	
+	switch(aParam)
+		{
+		case EDevDpFormats:
+			dataBuffer = resFile.AllocReadLC(FORMATS);
+		break;
+		
+		case EDevDpExtnUids:
+			dataBuffer = resFile.AllocReadLC(EXTNPLUGINUIDS);
+		break;
+
+		default:			
+			//should not come here raise panic	
+			__ASSERT_DEBUG( 0, User::Panic(KPanicinvalidRssConfigParam, CMTPDeviceDpConfigMgrPanic));				
+		break;	
+		}
+
+	TResourceReader reader;
+	reader.SetBuffer(dataBuffer);
+	TInt noOfElem = reader.ReadInt16();
+	//rewind to the begening else desc array can not read value.
+	reader.Rewind(sizeof(TInt16));
+	if(0 != noOfElem)	
+	{
+	CDesCArrayFlat* formatArray = reader.ReadDesCArrayL();
+	CleanupStack::PushL(formatArray);
+	TInt numFormats = formatArray->Count();
+	TUint formatInt;	
+	TPtrC orderedFormat;
+	TInt errorCode = KErrNotFound;	
+	for(TInt formtIndex = 0; formtIndex < numFormats; formtIndex++)
+		{
+		orderedFormat.Set(formatArray->MdcaPoint(formtIndex));
+		TLex lex(orderedFormat);
+		errorCode = lex.Val(formatInt, EHex);		
+		//panic in debug mode invalid string is provaided
+		__ASSERT_DEBUG((errorCode == KErrNone), User::Panic(KPanicInvalidInt, CMTPDeviceDpConfigMgrPanic));
+
+		if(errorCode )
+			{
+			 __FLOG(_L8("ERROR !!!Invalid entry in the config.rss file "));
+			}
+		else
+			{
+			//Ignore the duplicate value.
+			if( aOrderInfoArray.Find(formatInt) == KErrNotFound )
+				{
+				aOrderInfoArray.Append(formatInt);
+				}
+			}
+		}
+	CleanupStack::PopAndDestroy(formatArray);
+	CleanupStack::PopAndDestroy(dataBuffer);
+	CleanupStack::PopAndDestroy(&resFile);
+
+	}
+	else
+	{
+	CleanupStack::PopAndDestroy(dataBuffer);
+	CleanupStack::PopAndDestroy(&resFile);	
+	User::Leave(KErrArgument);	
+	}
+
+	__FLOG(_L8("GetOrderedFormatInfo -  Exit"));
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevrequestunknown.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,174 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpdevrequestunknown.h"
+#include "cmtpobjectmgr.h"
+#include "cmtpparserrouter.h"
+
+/**
+Factory method.
+@param aFramework The data provider framework
+@param aConnection The connection on which the request was received.
+@return A pointer to the created request processor object.
+@leave One of the system wide error codes, if a processing error occurs.
+*/ 
+MMTPRequestProcessor* CMTPDevRequestUnknown::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPDevRequestUnknown* self = new (ELeave) CMTPDevRequestUnknown(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor.
+*/    
+CMTPDevRequestUnknown::~CMTPDevRequestUnknown()
+    {
+    iSingletons.Close(); 
+    delete iDataSet;
+    iDataSet = NULL;
+    }
+
+/**
+Implements the default MTP request handler.
+@leave One of the system wide error codes, if a processing error occurs.
+*/    
+void CMTPDevRequestUnknown::ServiceL()    
+    {
+    const TUint KOpCode(iRequest->Uint16(TMTPTypeRequest::ERequestOperationCode));
+    TBool NoDataPhase(ETrue);
+    TMTPResponseCode rsp(EMTPRespCodeOperationNotSupported);
+    if (iSingletons.Router().OperationSupportedL(KOpCode))
+    	{
+    	switch (KOpCode)
+    	    {
+	    case EMTPOpCodeGetInterdependentPropDesc:
+	        {
+            const TUint32 KFormatcode = iRequest->Uint32(TMTPTypeRequest::ERequestParameter1);
+            
+            if ((KFormatcode == KMTPFormatsAll) || (KFormatcode == KMTPNotSpecified32))
+                {
+                rsp = EMTPRespCodeInvalidCodeFormat;
+                }
+            else
+                {
+            ServiceInterdependentPropDescL();
+            NoDataPhase = EFalse;
+                }
+            }
+            break;
+
+	        
+	    case EMTPOpCodeTerminateOpenCapture:
+	        {
+	        if (iSingletons.Router().RouteRequestRegisteredL(*iRequest, iConnection))
+	            {
+    	        rsp = EMTPRespCodeInvalidTransactionID;
+	            }
+            else
+                {
+    	        rsp = EMTPRespCodeCaptureAlreadyTerminated;
+                }
+	        }
+	        break;
+	        
+	    case EMTPOpCodeGetPartialObject:
+	    case EMTPOpCodeGetObjectReferences:
+	    case EMTPOpCodeSetObjectReferences:
+            {
+            CMTPObjectMetaData* object(CMTPObjectMetaData::NewLC());
+            if (!iSingletons.ObjectMgr().ObjectL(iRequest->Uint32(TMTPTypeRequest::ERequestParameter1), *object))
+                {
+    	        rsp = EMTPRespCodeInvalidObjectHandle;
+                }
+            else if ((KOpCode == EMTPOpCodeSetObjectReferences) &&
+                        (object->Uint(CMTPObjectMetaData::EFormatCode) == EMTPFormatCodeAssociation) &&
+                        (object->Uint(CMTPObjectMetaData::EFormatSubCode) == EMTPAssociationTypeGenericFolder))
+                {
+    	        rsp = EMTPRespCodeAccessDenied;
+                }
+            else
+                {
+    	        rsp = EMTPRespCodeOperationNotSupported;
+                }
+            CleanupStack::PopAndDestroy(object);
+            }
+	        break;
+	        
+        case EMTPOpCodeGetServiceCapabilities:
+	    case EMTPOpCodeGetServicePropDesc:
+        case EMTPOpCodeGetServicePropList:
+        case EMTPOpCodeSetServicePropList:    
+	    case EMTPOpCodeDeleteServicePropList:
+	        {
+	         rsp = EMTPRespCodeInvalidServiceID;
+	        }
+	        break;
+	    case EMTPOpCodeDeleteObjectPropList:
+	    case EMTPOpCodeUpdateObjectPropList:
+	        {
+	        rsp = EMTPRespCodeInvalidObjectHandle;
+	        }
+	        break;
+	        
+	    default:
+	        rsp = EMTPRespCodeGeneralError;
+	        break;
+    	    }
+        }
+    if ( NoDataPhase )
+       {
+       SendResponseL(rsp);
+       }
+
+    }  
+
+
+/**
++Send empty interdependentpropdesc data when the request is route to device dp
++*/
+void CMTPDevRequestUnknown::ServiceInterdependentPropDescL()
+    {
+    delete iDataSet;
+    iDataSet = NULL;
+
+    iDataSet = CMTPTypeInterdependentPropDesc::NewL();
+    SendDataL(*iDataSet);
+    }
+
+    
+/**
+Constructor.
+@param aFramework The data provider framework
+@param aConnection The connection on which the request was received.
+*/    
+CMTPDevRequestUnknown::CMTPDevRequestUnknown(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestUnknown(aFramework, aConnection)
+    {
+    
+    }
+    
+/**
+Second phase constructor.
+*/
+void CMTPDevRequestUnknown::ConstructL()
+    {
+    iSingletons.OpenL();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetdeviceinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,412 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+#include <f32file.h> 
+#include <mtp/cmtpdataproviderplugin.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mtpdataproviderapitypes.h>
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpdataprovider.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpdevicedatastore.h"
+#include "cmtpgetdeviceinfo.h"
+#include "cmtptypedeviceinfo.h"
+#include "rmtpframework.h"
+#include "mtpdevdppanic.h"
+#include "mtpdevicedpconst.h"
+#include "rmtpdevicedpsingletons.h"
+#include "cmtpdevicedpconfigmgr.h"
+#include "cmtpservicemgr.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"GetDeviceInfo");)
+
+/**
+This identifies, in hundredths, the PTP version this device can support
+*/
+static const TUint16 KMTPStandardVersion = 100;
+
+/**
+This identifies the PTP vendor-extension version that are in use by this device
+*/
+static const TUint32 KMTPVendorExtensionId = 0x00000006;
+
+/**
+This identifies, in hundredths, the version of the MTP standard that this device supports
+*/
+static const TUint16 KMTPVersion = 100;    // Currently 100
+
+static const TInt KMTPArrayGranularity = 15;
+
+/**
+Two-phase construction method
+@param aPlugin    The data provider plugin
+@param aFramework    The data provider framework
+@param aConnection    The connection from which the request comes
+@return a pointer to the created request processor object
+*/    
+MMTPRequestProcessor* CMTPGetDeviceInfo::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPGetDeviceInfo* self = new (ELeave) CMTPGetDeviceInfo(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor.
+*/    
+CMTPGetDeviceInfo::~CMTPGetDeviceInfo()
+    {    
+    __FLOG(_L8("~CMTPGetDeviceInfo - Entry"));
+    delete iDeviceInfo;
+    iDpSingletons.Close();
+    iSingletons.Close();
+    __FLOG(_L8("~CMTPGetDeviceInfo - Exit"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Constructor.
+*/    
+CMTPGetDeviceInfo::CMTPGetDeviceInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+    {
+    
+    }
+    
+/**
+GetDeviceInfo request handler. Build and send device info data set.
+*/    
+void CMTPGetDeviceInfo::ServiceL()
+    {
+    __FLOG(_L8("ServiceL - Entry"));
+    BuildDeviceInfoL();
+    SendDataL(*iDeviceInfo);
+    __FLOG(_L8("ServiceL - Exit"));
+    }
+
+/**
+Second-phase constructor.
+*/        
+void CMTPGetDeviceInfo::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry")); 
+    iSingletons.OpenL();
+    iDpSingletons.OpenL(iFramework);
+    iDeviceInfo = CMTPTypeDeviceInfo::NewL();
+    __FLOG(_L8("ConstructL - Exit")); 
+    }
+
+/**
+Populates device info data set
+*/
+void CMTPGetDeviceInfo::BuildDeviceInfoL()
+    {
+    __FLOG(_L8("BuildDeviceInfoL - Entry")); 
+    CMTPDeviceDataStore& device(iDpSingletons.DeviceDataStore());
+    iDeviceInfo->SetUint16L(CMTPTypeDeviceInfo::EStandardVersion, KMTPStandardVersion);
+    iDeviceInfo->SetUint32L(CMTPTypeDeviceInfo::EMTPVendorExtensionID, KMTPVendorExtensionId);
+    iDeviceInfo->SetUint16L(CMTPTypeDeviceInfo::EMTPVersion, KMTPVersion);
+    iDeviceInfo->SetStringL(CMTPTypeDeviceInfo::EMTPExtensions, iDpSingletons.DeviceDataStore().MTPExtensions());    
+    iDeviceInfo->SetUint16L(CMTPTypeDeviceInfo::EFunctionalMode, EMTPFunctionalModeStandard);    
+    iDeviceInfo->SetStringL(CMTPTypeDeviceInfo::EManufacturer, device.Manufacturer());
+    iDeviceInfo->SetStringL(CMTPTypeDeviceInfo::EModel, device.Model());
+    iDeviceInfo->SetStringL(CMTPTypeDeviceInfo::EDeviceVersion, device.DeviceVersion());
+    iDeviceInfo->SetStringL(CMTPTypeDeviceInfo::ESerialNumber, device.SerialNumber());
+    
+    CMTPDataProviderController& dps(iSingletons.DpController());
+    SetSupportedOperationsL(dps);
+    SetSupportedEventsL(dps);
+    SetSupportedDevicePropertiesL();
+    SetSupportedCaptureFormatsL(dps);
+    SetSupportedPlaybackFormatsL(dps);
+    
+    __FLOG(_L8("BuildDeviceInfoL - Exit")); 
+    }
+
+/**
+Populates the supported operations field in the device info data set
+It enumerates the installed data provider plugins and retrieves the supported operations
+@param aDpController    A reference to the data provider controller
+*/    
+void CMTPGetDeviceInfo::SetSupportedOperationsL(CMTPDataProviderController& aDpController)
+    {
+    __FLOG(_L8("SetSupportedOperationsL - Entry")); 
+    
+    TInt count = aDpController.Count();    
+    RArray<TUint> supportedOperations(KMTPArrayGranularity);
+    CleanupClosePushL(supportedOperations);
+    const TInt32 KMTPImplementationUidDeviceDp(0x102827AF);
+    const TInt32 KMTPImplementationUidFileDp(0x102827B0);
+    const TInt32 KMTPImplementationUidProxyDp(0x102827B1);
+    const TInt32 KMTPFrameworkDpCount(3);
+    TBool bOnlyInternalDpLoad = count > KMTPFrameworkDpCount ? EFalse : ETrue;
+    while(count--)
+        {
+        TInt32 uid = aDpController.DataProviderByIndexL(count).ImplementationUid().iUid;
+        // The filter is added for licencee's request which will filtrate the symbian's internal
+        // dp's supported enhance mode operations to make licencee's dp work.
+        // Every new internal dp need add it's implementation id here to filtrate and increase
+        // the KMTPFrameworkDpCount number.
+        if ((uid == KMTPImplementationUidDeviceDp ||
+            uid == KMTPImplementationUidFileDp ||
+            uid == KMTPImplementationUidProxyDp) && !bOnlyInternalDpLoad)
+            {
+            AddToArrayWithFilterL(supportedOperations, aDpController.DataProviderByIndexL(count).SupportedCodes(EOperations));
+            }
+        else
+            {
+            AddToArrayL(supportedOperations, aDpController.DataProviderByIndexL(count).SupportedCodes(EOperations));
+            }
+        }
+
+    CMTPTypeArray* mtpOperationsArray = CMTPTypeArray::NewL(EMTPTypeAUINT16, supportedOperations);
+    CleanupStack::PopAndDestroy(&supportedOperations);
+    CleanupStack::PushL(mtpOperationsArray); //unnecessary if Set operation below does not leave,         
+    iDeviceInfo->SetL(CMTPTypeDeviceInfo::EOperationsSupported, *mtpOperationsArray);
+    CleanupStack::PopAndDestroy(mtpOperationsArray);  
+    __FLOG(_L8("SetSupportedOperationsL - Exit"));      
+    }
+
+/**
+Populates the supported events field in the device info data set
+It enumerates the installed data provider plugins and retrieves the supported events
+@param aDpController    A reference to the data provider controller
+*/    
+void CMTPGetDeviceInfo::SetSupportedEventsL(CMTPDataProviderController& aDpController)
+    {
+    __FLOG(_L8("SetSupportedEventsL - Entry"));
+    TInt count = aDpController.Count();    
+    RArray<TUint> supportedEvents(KMTPArrayGranularity);
+    CleanupClosePushL(supportedEvents);
+    while(count--)
+        {
+        AddToArrayL(supportedEvents, aDpController.DataProviderByIndexL(count).SupportedCodes(EEvents));
+        }
+    
+    CMTPTypeArray* mtpEventArray = CMTPTypeArray::NewL(EMTPTypeAUINT16, supportedEvents);
+    CleanupStack::PopAndDestroy(&supportedEvents);
+    CleanupStack::PushL(mtpEventArray); //unnecessary if Set operation below does not leave,         
+    iDeviceInfo->SetL(CMTPTypeDeviceInfo::EEventsSupported, *mtpEventArray);
+    CleanupStack::PopAndDestroy(mtpEventArray);  
+    __FLOG(_L8("SetSupportedEventsL - Exit"));  
+    }
+
+/**
+Populates the supported device properties field in the device info data set
+*/       
+void CMTPGetDeviceInfo::SetSupportedDevicePropertiesL()
+	{ 
+	__FLOG(_L8("SetSupportedDevicePropertiesL - Entry"));  
+	iDeviceInfo->SetL(CMTPTypeDeviceInfo::EDevicePropertiesSupported, 
+	iDpSingletons.DeviceDataStore().GetSupportedDeviceProperties());
+	__FLOG(_L8("SetSupportedDevicePropertiesL - Exit"));  
+	}
+
+/**
+Populates the supported capture formats field in the device info data set
+It enumerates the installed data provider plugins and retrieves the supported capture formats
+@param aDpController    A reference to the data provider controller
+*/    
+void CMTPGetDeviceInfo::SetSupportedCaptureFormatsL(CMTPDataProviderController& aDpController)
+    {
+    __FLOG(_L8("SetSupportedCaptureFormatsL - Entry"));
+    TInt count = aDpController.Count();    
+    RArray<TUint> supportedCaptureFormats(KMTPArrayGranularity);
+    CleanupClosePushL(supportedCaptureFormats);
+//get the formt supported information from the devdp rss file
+  //and store it into the CArrayFix by passing the reference of the array.
+  RArray<TUint> orderedFormats(KMTPArrayGranularity);
+  CleanupClosePushL(orderedFormats);
+  //get the count form the formt supported struct.
+  TRAPD(errorCode,iDpSingletons.ConfigMgr().GetRssConfigInfoArrayL(orderedFormats, EDevDpFormats));
+  if(KErrNone != errorCode)
+	  {
+	  __FLOG(_L8("There is an issue in reading format info from rss file "));
+	  }
+	
+    while(count--)
+        {
+        AddToArrayL(supportedCaptureFormats, aDpController.DataProviderByIndexL(count).SupportedCodes(EObjectCaptureFormats));
+        }
+	TInt insertIndex = 0;
+	//Remove the existing formats from the supportedPlaybackFormats and insert the 
+	//elements from orderedFormats at the begining.	
+	for(TInt orderedElements = 0; orderedElements <orderedFormats.Count(); orderedElements++ )
+		{
+	TInt index = supportedCaptureFormats.Find(orderedFormats[orderedElements]);	  
+	if(KErrNotFound != index)
+		{
+		supportedCaptureFormats.Remove(index);
+		//insert at insertindex position to make sure that value inserted at begening.
+		supportedCaptureFormats.Insert(orderedFormats[orderedElements], insertIndex);
+		insertIndex++;
+		}//else nothing 	  	
+		}
+	
+	//The formats which are defined in Device Service Extension should not be reported by GetDeviceInfo
+	RemoveServiceFormat(supportedCaptureFormats);
+	
+#ifdef _DEBUG
+	for(TInt i =0 ; i < supportedCaptureFormats.Count(); i++)
+	{
+	__FLOG_VA((_L8("Playback formats = %d"), supportedCaptureFormats[i]));
+	}
+#endif 
+	//before deleting make sure all the elements are added to supportedPlaybackFormats
+	CleanupStack::PopAndDestroy(&orderedFormats);
+
+    CMTPTypeArray* mtpCaptureFormatArray = CMTPTypeArray::NewL(EMTPTypeAUINT16, supportedCaptureFormats);
+    CleanupStack::PopAndDestroy(&supportedCaptureFormats);
+    CleanupStack::PushL(mtpCaptureFormatArray); //unnecessary if Set operation below does not leave,         
+    iDeviceInfo->SetL(CMTPTypeDeviceInfo::ECaptureFormats, *mtpCaptureFormatArray);
+    CleanupStack::PopAndDestroy(mtpCaptureFormatArray); 
+    __FLOG(_L8("SetSupportedCaptureFormatsL - Exit"));   
+    }
+
+/**
+Populates the supported playback formats field in the device info data set
+It enumerates the installed data provider plugins and retrieves the supported playback formats
+@param aDpController    A reference to the data provider controller
+*/    
+void CMTPGetDeviceInfo::SetSupportedPlaybackFormatsL(CMTPDataProviderController& aDpController)
+    {
+    __FLOG(_L8("SetSupportedPlaybackFormatsL - Entry"));
+    TInt count = aDpController.Count();    
+    RArray<TUint> supportedPlaybackFormats(KMTPArrayGranularity);	
+    CleanupClosePushL(supportedPlaybackFormats);
+	
+    //get the formt supported information from the devdp rss file
+    //and store it into the CArrayFix by passing the reference of the array.
+    RArray<TUint> orderedFormats(KMTPArrayGranularity);
+    CleanupClosePushL(orderedFormats);
+    //get the count form the formt supported struct.
+    TRAPD(errorCode,iDpSingletons.ConfigMgr().GetRssConfigInfoArrayL(orderedFormats, EDevDpFormats));
+	if(KErrNone != errorCode)
+		{
+		__FLOG(_L8("There is an issue in reading format info from rss file "));
+		}
+
+    while(count--)
+        {
+        AddToArrayL(supportedPlaybackFormats, aDpController.DataProviderByIndexL(count).SupportedCodes(EObjectPlaybackFormats));       
+        }
+
+	TInt insertIndex = 0;
+	//Remove the existing formats from the supportedPlaybackFormats and insert the 
+	//elements from orderedFormats at the begining.	
+ 	for(TInt orderedElements = 0; orderedElements <orderedFormats.Count(); orderedElements++ )
+ 		{
+		TInt index = supportedPlaybackFormats.Find(orderedFormats[orderedElements]);	  
+		if(KErrNotFound != index)
+			{
+			supportedPlaybackFormats.Remove(index);
+			//insert at insertindex position to make sure that value inserted at begening.
+			supportedPlaybackFormats.Insert(orderedFormats[orderedElements], insertIndex);
+			insertIndex++;
+			}//else nothing 	  	
+ 		}
+ 	
+ 	//The formats which are defined in Device Service Extension should not be reported by GetDeviceInfo
+ 	RemoveServiceFormat(supportedPlaybackFormats);
+ 	
+#ifdef _DEBUG
+	for(TInt i =0 ; i < supportedPlaybackFormats.Count(); i++)
+	{
+	__FLOG_VA((_L8("Playback formats = %d"), supportedPlaybackFormats[i]));
+	}
+#endif 
+    //before deleting make sure all the elements are added to supportedPlaybackFormats
+    CleanupStack::PopAndDestroy(&orderedFormats);
+	
+    CMTPTypeArray* mtpPlaybackFormatArray = CMTPTypeArray::NewL(EMTPTypeAUINT16, supportedPlaybackFormats);    
+    CleanupStack::PopAndDestroy(&supportedPlaybackFormats);
+    CleanupStack::PushL(mtpPlaybackFormatArray); //unnecessary if Set operation below does not leave,         
+    iDeviceInfo->SetL(CMTPTypeDeviceInfo::EPlaybackFormats, *mtpPlaybackFormatArray);
+    CleanupStack::PopAndDestroy(mtpPlaybackFormatArray);  
+    __FLOG(_L8("SetSupportedPlaybackFormatsL - Exit"));  
+    }
+
+/**
+Add elements from source array to the destination array without duplication
+@param aDestArray    The destination array
+@param aSrcArray    The source array
+*/
+void CMTPGetDeviceInfo::AddToArrayL(RArray<TUint>& aDestArray, const RArray<TUint>& aSrcArray) const
+    {
+    TInt count(aSrcArray.Count());
+    for (TInt i(0); (i < count); i++)
+        {
+        TInt err(aDestArray.InsertInOrder(aSrcArray[i]));
+        if ((err != KErrNone) && (err != KErrAlreadyExists))
+            {
+            User::Leave(err);
+            }
+        }
+    }
+
+/**
+Add elements from source array to the destination array without duplication
+User filter to help licensee's data provider's supported operation.
+@param aDestArray    The destination array
+@param aSrcArray    The source array
+*/
+void CMTPGetDeviceInfo::AddToArrayWithFilterL(RArray<TUint>& aDestArray, const RArray<TUint>& aSrcArray) const
+    {
+    TInt count(aSrcArray.Count());
+    for (TInt i(0); (i < count); i++)
+        {
+        // Apply filter
+        if(aSrcArray[i] == EMTPOpCodeGetObjectPropList ||
+           aSrcArray[i] == EMTPOpCodeSetObjectPropList||
+           aSrcArray[i] == EMTPOpCodeSendObjectPropList ||
+			aSrcArray[i] == EMTPOpCodeGetFormatCapabilities )
+            {
+            __FLOG_VA((_L8("Filter ignored operation: %d"), aSrcArray[i]));
+            continue;
+            }
+
+        TInt err(aDestArray.InsertInOrder(aSrcArray[i]));
+        if ((err != KErrNone) && (err != KErrAlreadyExists))
+            {
+            User::Leave(err);
+            }
+        }
+    }
+
+
+void CMTPGetDeviceInfo::RemoveServiceFormat(RArray<TUint>& aSupportedCaptureFormats)
+	{
+	__FLOG(_L8("RemovetServiceFormat - Entry"));
+	
+	TInt count = aSupportedCaptureFormats.Count();
+	count--;
+	while(count>=0)
+		{
+        if(iSingletons.ServiceMgr().IsServiceFormatCode( aSupportedCaptureFormats[count] ))
+            aSupportedCaptureFormats.Remove(count);
+        count--;
+		}
+	__FLOG(_L8("RemovetServiceFormat - Exit")); 
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetdevicepropdesc.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,491 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <mtp/cmtptypedevicepropdesc.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpframeworkconfig.h>
+#include <centralrepository.h>
+
+#include "cmtpdevicedatastore.h"
+#include "cmtpgetdevicepropdesc.h"
+#include "mtpdevicedpconst.h"
+#include "mtpdevdppanic.h"
+#include "cmtpdevicedpconfigmgr.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"GetDevicePropDesc");)
+
+/**
+Two-phase constructor.
+@param aPlugin The data provider plugin
+@param aFramework The data provider framework
+@param aConnection The connection from which the request comes
+@return a pointer to the created request processor object
+*/  
+MMTPRequestProcessor* CMTPGetDevicePropDesc::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPGetDevicePropDesc* self = new (ELeave) CMTPGetDevicePropDesc(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor.
+*/    
+CMTPGetDevicePropDesc::~CMTPGetDevicePropDesc()
+    {    
+    __FLOG(_L8("~CMTPGetDevicePropDesc - Entry"));
+    delete iData;
+    delete iPropDesc;
+    delete iRepository;
+    iDpSingletons.Close();
+    __FLOG(_L8("~CMTPGetDevicePropDesc - Exit"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Constructor.
+*/    
+CMTPGetDevicePropDesc::CMTPGetDevicePropDesc(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+    {    
+    }
+    
+/**
+GetDevicePropDesc request validator.
+@return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
+*/
+TMTPResponseCode CMTPGetDevicePropDesc::CheckRequestL()
+    {
+    __FLOG(_L8("CheckRequestL - Entry"));
+    TMTPResponseCode respCode(EMTPRespCodeDevicePropNotSupported);
+    iPropCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    const TInt count = sizeof(KMTPDeviceDpSupportedProperties) / sizeof(KMTPDeviceDpSupportedProperties[0]);
+    for (TUint i(0); ((respCode != EMTPRespCodeOK) && (i < count)); i++)
+        {
+        if (iPropCode == KMTPDeviceDpSupportedProperties[i])
+            {
+            respCode = EMTPRespCodeOK;
+            }
+        }
+    if((respCode != EMTPRespCodeOK) && iDpSingletons.DeviceDataStore().ExtnDevicePropDp())//2113 
+        {
+        respCode = EMTPRespCodeOK;
+        }
+    __FLOG(_L8("CheckRequestL - Exit"));
+    return respCode;
+    }
+
+/**
+GetDevicePropDesc request handler.
+*/    
+void CMTPGetDevicePropDesc::ServiceL()
+    {
+    __FLOG(_L8("ServiceL - Entry"));    
+    iPropCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    //before performing any operation will check the properties are supported or 
+    //not if not then return EMTPRespCodeDevicePropNotSupported
+    const CMTPTypeArray *mtpArray = &(iDpSingletons.DeviceDataStore().GetSupportedDeviceProperties());
+    RArray <TUint> supportedArray;	    
+    mtpArray->Array(supportedArray);
+    __FLOG_VA((_L8("No of elements in supported property array = %d "), supportedArray.Count()));	
+    if(KErrNotFound == supportedArray.Find(iPropCode))
+        {
+        SendResponseL(EMTPRespCodeDevicePropNotSupported);       
+        __FLOG(_L8("CMTPGetDevicePropDesc::EMTPRespCodeDevicePropNotSupported "));	  
+        }
+    else
+        {
+        switch (iPropCode)
+            {
+            case EMTPDevicePropCodeBatteryLevel:
+            if (iDpSingletons.DeviceDataStore().RequestPending())
+                {
+                // BatteryLevel already pending - return busy code
+                SendResponseL(EMTPRespCodeDeviceBusy);
+                }
+            else
+                {
+                iDpSingletons.DeviceDataStore().BatteryLevelL(iStatus, iBatteryLevelValue);
+                SetActive();	
+                }
+            break;
+            
+            case EMTPDevicePropCodeSynchronizationPartner:
+                ServiceSynchronisationPartnerL();
+            break;
+            
+            case EMTPDevicePropCodeDeviceFriendlyName:
+                ServiceDeviceFriendlyNameL();
+            break;
+            
+            case EMTPDevicePropCodeSessionInitiatorVersionInfo:
+                ServiceSessionInitiatorVersionInfoL();
+            break;
+            
+            case EMTPDevicePropCodePerceivedDeviceType:
+                ServicePerceivedDeviceTypeL();
+            break;
+            
+            case EMTPDevicePropCodeDateTime:
+                ServiceDateTimeL();
+            break;
+            
+            case EMTPDevicePropCodeDeviceIcon:
+                ServiceDeviceIconL();
+            break;
+
+            case EMTPDevicePropCodeSupportedFormatsOrdered:
+            ServiceSupportedFormatsOrderedL();
+            break;
+            
+            case EMTPDevicePropCodeFunctionalID:
+            	ServiceFunctionalIDL();
+            break;
+            case EMTPDevicePropCodeModelID:
+            	ServiceModelIDL();
+            break;
+            case EMTPDevicePropCodeUseDeviceStage:
+            	ServiceUseDeviceStageL();
+            break;
+ 
+            default:
+            if(iDpSingletons.DeviceDataStore().ExtnDevicePropDp())
+                {
+                HandleExtnServiceL(iPropCode, iDpSingletons.DeviceDataStore().ExtnDevicePropDp());
+                }
+            else 
+                SendResponseL(EMTPRespCodeDevicePropNotSupported); 
+            break;
+            }
+        }
+    supportedArray.Close();
+    __FLOG(_L8("ServiceL - Exit"));
+    }
+    
+    
+void  CMTPGetDevicePropDesc::HandleExtnServiceL(TInt aPropCode, MExtnDevicePropDp* aExtnDevplugin )
+	{
+	//call	 plugin ->desc
+	MMTPType* mtptype;
+	if(KErrNone == aExtnDevplugin->GetDevPropertyDescL((TMTPDevicePropertyCode)aPropCode, &mtptype))
+	{
+	SendDataL(*mtptype);	
+	}
+	else
+	{
+	SendResponseL(EMTPRespCodeDevicePropNotSupported); 	
+	}
+
+	
+	}
+void CMTPGetDevicePropDesc::DoCancel()
+    {
+    __FLOG(_L8("DoCancel - Entry"));
+    if (iPropCode == EMTPDevicePropCodeBatteryLevel)
+        {
+        iDpSingletons.DeviceDataStore().Cancel();
+        }
+    __FLOG(_L8("DoCancel - Exit"));
+    }
+    
+void CMTPGetDevicePropDesc::RunL()
+    {
+    __FLOG(_L8("RunL - Entry"));
+    if (iPropCode == EMTPDevicePropCodeBatteryLevel)
+        {
+        ServiceBatteryLevelL();
+        }
+    else
+        {
+        __DEBUG_ONLY(Panic(EMTPDevDpUnknownDeviceProperty));
+        }
+    __FLOG(_L8("RunL - Exit"));
+    }
+
+/**
+Second-phase constructor.
+*/        
+void CMTPGetDevicePropDesc::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("CMTPGetDevicePropDesc: ConstructL - Entry")); 
+    iDpSingletons.OpenL(iFramework);
+	const TUint32 KUidMTPRepositoryValue(0x10282FCC);
+    const TUid KUidMTPRepository = {KUidMTPRepositoryValue};
+    iRepository = CRepository::NewL(KUidMTPRepository);
+    __FLOG(_L8("CMTPGetDevicePropDesc: ConstructL - Exit")); 
+    }
+
+/**
+Services the battery level property.
+*/        
+void CMTPGetDevicePropDesc::ServiceBatteryLevelL()
+    {
+    __FLOG(_L8("ServiceBatteryLevelL - Entry")); 
+    CMTPTypeDevicePropDescRangeForm* form = CMTPTypeDevicePropDescRangeForm::NewLC(EMTPTypeUINT8);
+    form->SetUint8L(CMTPTypeDevicePropDescRangeForm::EMinimumValue, 0);
+    form->SetUint8L(CMTPTypeDevicePropDescRangeForm::EMaximumValue, 100);
+    form->SetUint8L(CMTPTypeDevicePropDescRangeForm::EStepSize, 10);
+    
+    delete iPropDesc;
+    iPropDesc = NULL;
+    iPropDesc = CMTPTypeDevicePropDesc::NewL(EMTPDevicePropCodeBatteryLevel, *form);
+    iPropDesc->SetUint8L(CMTPTypeDevicePropDesc::EFactoryDefaultValue, 0);    
+    iPropDesc->SetUint8L(CMTPTypeDevicePropDesc::ECurrentValue, iBatteryLevelValue);
+    CleanupStack::PopAndDestroy(form);
+
+    SendDataL(*iPropDesc);
+    __FLOG(_L8("ServiceBatteryLevelL - Exit")); 
+    }
+
+/**
+Services the device friendly name property.
+*/    
+void CMTPGetDevicePropDesc::ServiceDeviceFriendlyNameL()
+    {
+    __FLOG(_L8("ServiceDeviceFriendlyNameL - Entry"));
+    delete iPropDesc;
+    iPropDesc = NULL;
+    iPropDesc = CMTPTypeDevicePropDesc::NewL(EMTPDevicePropCodeDeviceFriendlyName);
+    
+    CMTPDeviceDataStore& device(iDpSingletons.DeviceDataStore());
+    iPropDesc->SetStringL(CMTPTypeDevicePropDesc::EFactoryDefaultValue, device.DeviceFriendlyNameDefault());
+    iPropDesc->SetStringL(CMTPTypeDevicePropDesc::ECurrentValue, device.DeviceFriendlyName());
+    
+    SendDataL(*iPropDesc);    
+    __FLOG(_L8("ServiceDeviceFriendlyNameL - Exit")); 
+    }
+        
+/**
+Services the synchronisation partner property.
+*/    
+void CMTPGetDevicePropDesc::ServiceSynchronisationPartnerL()
+    {
+    __FLOG(_L8("ServiceSynchronisationPartnerL - Entry")); 
+    delete iPropDesc;
+    iPropDesc = NULL;
+    iPropDesc = CMTPTypeDevicePropDesc::NewL(EMTPDevicePropCodeSynchronizationPartner);
+    
+    CMTPDeviceDataStore& device(iDpSingletons.DeviceDataStore());
+    iPropDesc->SetStringL(CMTPTypeDevicePropDesc::EFactoryDefaultValue, device.SynchronisationPartnerDefault());
+    iPropDesc->SetStringL(CMTPTypeDevicePropDesc::ECurrentValue, device.SynchronisationPartner());
+    
+    SendDataL(*iPropDesc); 
+    __FLOG(_L8("ServiceSynchronisationPartnerL - Exit")); 
+    }
+
+/**
+*Services the synchronisation partner property. 
+*/    
+void CMTPGetDevicePropDesc::ServiceSessionInitiatorVersionInfoL()
+    {
+    __FLOG(_L8("ServiceSessionInitiatorVersionInfoL - Entry")); 
+    delete iPropDesc;
+    iPropDesc = NULL;
+    // this property is of type set or get 
+    iPropDesc = CMTPTypeDevicePropDesc::NewL(EMTPDevicePropCodeSessionInitiatorVersionInfo, 0x01/*set/get*/, 0x00, NULL);   
+    CMTPDeviceDataStore& device(iDpSingletons.DeviceDataStore());   
+    iPropDesc->SetStringL(CMTPTypeDevicePropDesc::EFactoryDefaultValue, device.SessionInitiatorVersionInfoDefault());
+    iPropDesc->SetStringL(CMTPTypeDevicePropDesc::ECurrentValue, device.SessionInitiatorVersionInfo());
+    SendDataL(*iPropDesc); 
+    __FLOG(_L8("ServiceSessionInitiatorVersionInfoL - Exit")); 
+    }
+
+/**
+*Services the Service Perceived Device Type. 
+*/    
+void CMTPGetDevicePropDesc::ServicePerceivedDeviceTypeL()
+    {
+    __FLOG(_L8("ServicePerceivedDeviceType - Entry")); 
+    delete iPropDesc;
+    iPropDesc = NULL;
+    iPropDesc = CMTPTypeDevicePropDesc::NewL(EMTPDevicePropCodePerceivedDeviceType, 0x00/*get only*/, 0x00, NULL);
+    CMTPDeviceDataStore& device(iDpSingletons.DeviceDataStore());    
+    iPropDesc->SetUint32L(CMTPTypeDevicePropDesc::EFactoryDefaultValue, device.PerceivedDeviceTypeDefault());
+    iPropDesc->SetUint32L(CMTPTypeDevicePropDesc::ECurrentValue, device.PerceivedDeviceType());
+    SendDataL(*iPropDesc); 
+    __FLOG(_L8("ServicePerceivedDeviceType - Exit")); 
+    }
+
+/**
+Services the Date Time property. 
+*/    
+void CMTPGetDevicePropDesc::ServiceDateTimeL()
+    {
+    __FLOG(_L8("ServicePerceivedDeviceType - Entry")); 
+    delete iPropDesc;
+    iPropDesc = NULL;
+    iPropDesc = CMTPTypeDevicePropDesc::NewL(EMTPDevicePropCodeDateTime, 0x01/*get/set*/, 0x00, NULL);
+    CMTPDeviceDataStore& device(iDpSingletons.DeviceDataStore());    
+    iPropDesc->SetStringL(CMTPTypeDevicePropDesc::EFactoryDefaultValue, device.DateTimeL());
+    iPropDesc->SetStringL(CMTPTypeDevicePropDesc::ECurrentValue, device.DateTimeL());
+    SendDataL(*iPropDesc); 
+    __FLOG(_L8("ServicePerceivedDeviceType - Exit")); 
+    }
+
+/**
+Services the Date Time property. 
+*/	  
+void CMTPGetDevicePropDesc::ServiceDeviceIconL()
+    {
+    __FLOG(_L8("ServiceDeviceIcon - Entry")); 
+    delete iPropDesc;
+    iPropDesc = NULL;
+    iPropDesc = CMTPTypeDevicePropDesc::NewL(EMTPDevicePropCodeDeviceIcon, 0x00, 0x00, NULL);
+    CMTPDeviceDataStore& device(iDpSingletons.DeviceDataStore());	 
+    //need to think of which one to be used for default.
+    iPropDesc->SetL(CMTPTypeDevicePropDesc::EFactoryDefaultValue, device.DeviceIcon());
+    iPropDesc->SetL(CMTPTypeDevicePropDesc::ECurrentValue, device.DeviceIcon());
+    SendDataL(*iPropDesc); 
+    __FLOG(_L8("ServiceDeviceIcon- Exit"));   
+    }
+
+/*
+*Service Supported format ordered.
+*/
+void CMTPGetDevicePropDesc::ServiceSupportedFormatsOrderedL()
+    {
+    __FLOG(_L8("ServiceSupportedFormatsOrdered - Entry")); 
+    delete iPropDesc;
+    iPropDesc = NULL;
+    iPropDesc = CMTPTypeDevicePropDesc::NewL(EMTPDevicePropCodeSupportedFormatsOrdered, 0x00, 0x00, NULL);    
+    iPropDesc->SetUint8L(CMTPTypeDevicePropDesc::EFactoryDefaultValue, (TUint8)FORMAT_UNORDERED);
+    iPropDesc->SetUint8L(CMTPTypeDevicePropDesc::ECurrentValue, GetFormatOrdered());
+    SendDataL(*iPropDesc); 
+    __FLOG(_L8("ServiceSupportedFormatsOrdered - Exit")); 
+    }
+
+/*
+*Service Supported FuntionalID.
+*/
+void CMTPGetDevicePropDesc::ServiceFunctionalIDL()
+    {
+    __FLOG(_L8("ServiceFuntionalIDL - Entry")); 
+    delete iPropDesc;
+    iPropDesc = NULL;
+    iPropDesc = CMTPTypeDevicePropDesc::NewL(EMTPDevicePropCodeFunctionalID, 1, 0, NULL); 
+    
+    delete iData;
+	iData = GetGUIDL( MMTPFrameworkConfig::EDeviceDefaultFuncationalID ); 
+	iPropDesc->SetL(CMTPTypeDevicePropDesc::EFactoryDefaultValue, *iData);
+	delete iData;
+	iData = GetGUIDL(MMTPFrameworkConfig::EDeviceCurrentFuncationalID); 
+	iPropDesc->SetL(CMTPTypeDevicePropDesc::ECurrentValue, *iData);
+	
+    SendDataL(*iPropDesc); 
+    __FLOG(_L8("ServiceFuntionalIDL - Exit")); 
+    }
+
+/*
+*Service Supported ModelID.
+*/
+void CMTPGetDevicePropDesc::ServiceModelIDL()
+    {
+    __FLOG(_L8("ServiceModelIDL - Entry")); 
+    delete iPropDesc;
+    iPropDesc = NULL;
+    iPropDesc = CMTPTypeDevicePropDesc::NewL(EMTPDevicePropCodeModelID, 0, 0, NULL);   
+    
+    delete iData;
+    iData = GetGUIDL(MMTPFrameworkConfig::EDeviceDefaultModelID);  
+    iPropDesc->SetL(CMTPTypeDevicePropDesc::EFactoryDefaultValue, *iData);
+    
+    delete iData;
+    iData = GetGUIDL(MMTPFrameworkConfig::EDeviceCurrentModelID); 
+	iPropDesc->SetL(CMTPTypeDevicePropDesc::ECurrentValue, *iData);
+	
+    SendDataL(*iPropDesc); 
+    __FLOG(_L8("ServiceModelIDL - Exit")); 
+    }
+
+/*
+*Service Supported UseDeviceStage.
+*/
+void CMTPGetDevicePropDesc::ServiceUseDeviceStageL()
+    {
+    __FLOG(_L8("ServiceUseDeviceStageL - Entry")); 
+    delete iPropDesc;
+    iPropDesc = NULL;
+    iPropDesc = CMTPTypeDevicePropDesc::NewL(EMTPDevicePropCodeUseDeviceStage, 0, 0, NULL); 
+    
+    TMTPTypeUint8 *data = new (ELeave)TMTPTypeUint8(1);
+    iPropDesc->SetL(CMTPTypeDevicePropDesc::EFactoryDefaultValue, *data);
+    iPropDesc->SetL(CMTPTypeDevicePropDesc::ECurrentValue, *data);
+    
+    delete data;
+
+    SendDataL(*iPropDesc); 
+    __FLOG(_L8("ServiceUseDeviceStageL - Exit")); 
+    }
+
+/*
+*This method to set the supported format order.
+*this value will be set by getdevice info based on the formats present in the
+*mtpdevicedp_config.rss file.
+*/
+TUint8 CMTPGetDevicePropDesc::GetFormatOrdered()
+    {
+    TUint8 formatOrdered;
+    RArray<TUint> orderedFormats(8);
+    CleanupClosePushL(orderedFormats);  
+    TRAPD(error,iDpSingletons.ConfigMgr().GetRssConfigInfoArrayL(orderedFormats, EDevDpFormats));
+	if(error!=KErrNone)
+		{
+		__FLOG_VA((_L8("GetRssConfigArray returned with %d"), error));
+		}
+    if(orderedFormats.Count() > 0)
+        {
+        formatOrdered = (TUint8)FORMAT_ORDERED;
+        }
+    else
+        {
+        formatOrdered = (TUint8)FORMAT_UNORDERED; 
+        }
+    CleanupStack::PopAndDestroy(&orderedFormats);   
+    return formatOrdered;
+    }
+
+TMTPTypeGuid* CMTPGetDevicePropDesc::GetGUIDL(const TUint aKey)
+    {
+    
+    TBuf8<KMTPTypeUINT128Size> ptr;
+    
+    iRepository->Get(aKey,ptr);
+    
+    TMTPTypeGuid* ret = new (ELeave) TMTPTypeGuid( ptr );
+    
+    return ret;
+    }
+
+void CMTPGetDevicePropDesc::SaveGUID( const TUint aKey,  TMTPTypeGuid& aValue )
+    {
+    TPtrC8 ptr;
+    if ( KMTPChunkSequenceCompletion == aValue.FirstReadChunk(ptr) )
+    	{
+    	iRepository->Set(aKey,ptr);
+    	}
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetdevicepropvalue.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,253 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/tmtptypeuint8.h>
+#include <mtp/mmtpframeworkconfig.h>
+#include "cmtpdevicedatastore.h"
+#include "cmtpgetdevicepropvalue.h"
+#include "mtpdevicedpconst.h"
+#include "mtpdevdppanic.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"GetDevicePropValue");)
+
+/**
+Two-phase constructor.
+@param aPlugin  The data provider plugin
+@param aFramework The data provider framework
+@param aConnection The connection from which the request comes
+@return a pointer to the created request processor object.
+*/  
+MMTPRequestProcessor* CMTPGetDevicePropValue::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPGetDevicePropValue* self = new (ELeave) CMTPGetDevicePropValue(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor.
+should not delete iMtpArray(ownership is belong to devicedatastore)
+*/    
+CMTPGetDevicePropValue::~CMTPGetDevicePropValue()
+    {
+    __FLOG(_L8("~CMTPGetDevicePropValue - Entry"));
+    delete iString;    
+    delete iData;
+    //ownership of the iMtpArray pointer is belongs to devicedatastore so it should not 
+    //deleted.    
+    __FLOG(_L8("~CMTPGetDevicePropValue - Exit"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Constructor.
+*/    
+CMTPGetDevicePropValue::CMTPGetDevicePropValue(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPGetDevicePropDesc(aFramework, aConnection)
+    {
+    
+    }
+
+/**
+Second-phase constructor.
+*/
+void CMTPGetDevicePropValue::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry")); 
+    CMTPGetDevicePropDesc::ConstructL();
+    iString = CMTPTypeString::NewL();
+    __FLOG(_L8("ConstructL - Exit")); 
+    }
+
+/**
+Services the battery level property.
+*/    
+void CMTPGetDevicePropValue::ServiceBatteryLevelL()
+    {
+    __FLOG(_L8("ServiceBatteryLevelL - Entry"));
+    iBatteryLevel.Set(iBatteryLevelValue);
+    SendDataL(iBatteryLevel);
+    __FLOG(_L8("ServiceBatteryLevelL - Exit"));
+    }
+
+/**
+Services the device friendly name property.
+*/   
+void CMTPGetDevicePropValue::ServiceDeviceFriendlyNameL()
+    {
+    __FLOG(_L8("ServiceDeviceFriendlyNameL - Entry")); 
+    iString->SetL(iDpSingletons.DeviceDataStore().DeviceFriendlyName());
+    SendDataL(*iString);  
+    __FLOG(_L8("ServiceDeviceFriendlyNameL - Exit"));   
+    }
+        
+/**
+Services the synchronisation partner property.
+*/ 
+void CMTPGetDevicePropValue::ServiceSynchronisationPartnerL()
+    {
+    __FLOG(_L8("ServiceSynchronisationPartnerL - Entry")); 
+    iString->SetL(iDpSingletons.DeviceDataStore().SynchronisationPartner());
+    SendDataL(*iString);
+    __FLOG(_L8("ServiceSynchronisationPartnerL - Exit"));
+    }
+
+/**
+Services the ServiceSessionInitiatorVersionInfo property. 
+*/ 
+void CMTPGetDevicePropValue::ServiceSessionInitiatorVersionInfoL()
+   {
+   __FLOG(_L8("ServiceSessionInitiatorVersionInfo - Entry")); 
+   iString->SetL(iDpSingletons.DeviceDataStore().SessionInitiatorVersionInfo());
+   SendDataL(*iString);
+   __FLOG(_L8("ServiceSessionInitiatorVersionInfo - Exit"));
+   }
+
+/**
+Services the ServicePerceivedDeviceType property. 
+*/ 
+void CMTPGetDevicePropValue::ServicePerceivedDeviceTypeL()
+   {
+   __FLOG(_L8("ServiceSessionInitiatorVersionInfo - Entry")); 
+   iUint32.Set(iDpSingletons.DeviceDataStore().PerceivedDeviceType());
+   SendDataL(iUint32);
+   __FLOG(_L8("ServiceSessionInitiatorVersionInfo - Exit"));
+   }
+
+/**
+Services the Date time device property. 
+*/ 
+void CMTPGetDevicePropValue::ServiceDateTimeL()
+  {
+  __FLOG(_L8("ServiceDateTime - Entry")); 
+  iString->SetL(iDpSingletons.DeviceDataStore().DateTimeL());
+  SendDataL(*iString);
+  __FLOG(_L8("ServiceDateTime - Exit"));
+  }
+
+/**
+Services the DiviceIcon property. 
+*/ 
+void CMTPGetDevicePropValue::ServiceDeviceIconL()
+    {
+    __FLOG(_L8("DeviceIcon - Entry")); 
+    //iMtpArray is not owned by this class DO NOT DELET IT.
+    iMtpArray = &(iDpSingletons.DeviceDataStore().DeviceIcon());
+    SendDataL(*iMtpArray);
+    __FLOG(_L8("DeviceIcon - Exit"));
+    }
+
+/**
+Services the ServicePerceivedDeviceType property. 
+*/ 
+void CMTPGetDevicePropValue::ServiceSupportedFormatsOrderedL()
+    {
+    __FLOG(_L8("ServiceSessionInitiatorVersionInfo - Entry"));    
+    iUint8.Set(GetFormatOrdered());
+    SendDataL(iUint8);
+    __FLOG(_L8("ServiceSessionInitiatorVersionInfo - Exit"));
+    }
+
+ void CMTPGetDevicePropValue::HandleExtnServiceL(TInt aPropCode, MExtnDevicePropDp* aExtnDevplugin)
+    {
+    MMTPType* mtptype = NULL;
+    aExtnDevplugin->GetDevPropertyL((TMTPDevicePropertyCode)aPropCode, &mtptype);
+
+    if(NULL != mtptype)
+        {
+        SendDataL(*mtptype);	
+        }
+    else
+        {
+        SendResponseL(EMTPRespCodeDevicePropNotSupported); 	
+        }
+    }
+ 
+ /*
+ *Service Supported FuntionalID.
+ */
+ void CMTPGetDevicePropValue::ServiceFunctionalIDL()
+     {
+     __FLOG(_L8("ServiceFuntionalIDL - Entry")); 
+
+    delete iData;
+    iData = GetGUIDL(MMTPFrameworkConfig::EDeviceCurrentFuncationalID); 
+    
+     SendDataL(*iData); 
+     __FLOG(_L8("ServiceFuntionalIDL - Exit")); 
+     }
+
+ /*
+ *Service Supported ModelID.
+ */
+ void CMTPGetDevicePropValue::ServiceModelIDL()
+     {
+     __FLOG(_L8("ServiceModelIDL - Entry")); 
+     
+     delete iData;
+     iData = GetGUIDL(MMTPFrameworkConfig::EDeviceCurrentModelID); 
+ 	
+     SendDataL(*iData); 
+     __FLOG(_L8("ServiceModelIDL - Exit")); 
+     }
+
+ /*
+ *Service Supported UseDeviceStage.
+ */
+ void CMTPGetDevicePropValue::ServiceUseDeviceStageL()
+     {
+     __FLOG(_L8("ServiceUseDeviceStageL - Entry")); 
+ 	iUint8.Set(1);
+ 	SendDataL(iUint8); 
+     __FLOG(_L8("ServiceUseDeviceStageL - Exit")); 
+     }
+
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    
+
+    
+
+
+       
+
+    
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetnumobjects.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,149 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpdataprovider.h>
+#include <mtp/cmtpdataproviderplugin.h>
+
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpdataprovider.h"
+
+#include "cmtpgetnumobjects.h"
+#include "mtpdevicedpconst.h"
+#include "mtpdevdppanic.h"
+
+/**
+Verification data for GetNumObjects request
+*/
+const TMTPRequestElementInfo KMTPGetNumObjectsPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeStorageId, EMTPElementAttrNone, 1, KMTPStorageAll, 0},
+        {TMTPTypeRequest::ERequestParameter2, EMTPElementTypeFormatCode, EMTPElementAttrNone, 1, 0, 0},
+        {TMTPTypeRequest::ERequestParameter3, EMTPElementTypeObjectHandle, EMTPElementAttrDir, 2, KMTPHandleAll, 0}
+    };
+
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/    
+MMTPRequestProcessor* CMTPGetNumObjects::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+	{
+	CMTPGetNumObjects* self = new (ELeave) CMTPGetNumObjects(aFramework, aConnection);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+	}
+
+/**
+Destructor
+*/	
+CMTPGetNumObjects::~CMTPGetNumObjects()
+	{	
+    iSingletons.Close();
+	}
+/**
+Standard c++ constructor
+*/	
+CMTPGetNumObjects::CMTPGetNumObjects(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetNumObjectsPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetNumObjectsPolicy)
+	{
+
+	}
+    
+/**
+Second phase constructor.
+*/
+void CMTPGetNumObjects::ConstructL()
+    {
+    iSingletons.OpenL();
+    }
+
+TMTPResponseCode CMTPGetNumObjects::CheckRequestL()
+	{
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	if(responseCode == EMTPRespCodeOK)
+		{
+		TUint32 formatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+		if(formatCode != 0 && !IsSupportedFormatL(formatCode))
+			{
+			responseCode = EMTPRespCodeInvalidObjectFormatCode;
+			}
+		}
+	return responseCode;	
+	}
+	
+	
+/**
+GetNumObjects request handler
+*/	
+void CMTPGetNumObjects::ServiceL()
+	{
+	TMTPObjectMgrQueryParams params(Request().Uint32(TMTPTypeRequest::ERequestParameter1), Request().Uint32(TMTPTypeRequest::ERequestParameter2), Request().Uint32(TMTPTypeRequest::ERequestParameter3));
+	TUint32 count = iFramework.ObjectMgr().CountL(params);		
+	SendResponseL(EMTPRespCodeOK, 1, &count);	
+	}
+
+/**
+Check if the format code is supported by the current installed data providers
+*/	
+TBool CMTPGetNumObjects::IsSupportedFormatL(TUint32 aFormatCode)
+	{
+	TBool supported(EFalse);
+		
+	CMTPDataProviderController& dps(iSingletons.DpController());
+	const TInt count(dps.Count());
+	for (TInt i(0); ((i < count) && (!supported)); i++)
+		{						
+		CMTPDataProvider& dp = dps.DataProviderByIndexL(i);
+		if (dp.DataProviderId() != dps.ProxyDpId())
+			{
+			supported = (
+			    dp.Supported(EObjectCaptureFormats, aFormatCode) || 
+			    dp.Supported(EObjectPlaybackFormats, aFormatCode));
+			}			
+		}
+	return supported;	
+	}
+
+
+
+
+
+
+
+
+
+
+
+	
+
+	
+
+
+   	
+
+	
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetobjecthandles.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,112 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/mtpdatatypeconstants.h>
+
+#include "cmtpgetobjecthandles.h"
+#include "mtpdevicedpconst.h"
+#include "mtpdevdppanic.h"
+
+
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/    
+MMTPRequestProcessor* CMTPGetObjectHandles::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+	{
+	CMTPGetObjectHandles* self = new (ELeave) CMTPGetObjectHandles(aFramework, aConnection);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+	}
+
+/**
+GetObjectHandles request handler
+*/	
+CMTPGetObjectHandles::~CMTPGetObjectHandles()
+	{
+	delete iHandles;	
+	}
+
+/**
+Standard c++ constructor
+*/	
+CMTPGetObjectHandles::CMTPGetObjectHandles(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPGetNumObjects(aFramework, aConnection)
+	{
+	
+	}
+    
+/**
+Second phase constructor.
+*/
+void CMTPGetObjectHandles::ConstructL()
+    {
+    CMTPGetNumObjects::ConstructL();
+    }
+
+/**
+GetObjectHandles request handler
+*/	
+void CMTPGetObjectHandles::ServiceL()
+	{
+	RMTPObjectMgrQueryContext   context;
+	RArray<TUint>               handles;
+	TMTPObjectMgrQueryParams    params(Request().Uint32(TMTPTypeRequest::ERequestParameter1), Request().Uint32(TMTPTypeRequest::ERequestParameter2), Request().Uint32(TMTPTypeRequest::ERequestParameter3));
+	CleanupClosePushL(context);
+	CleanupClosePushL(handles);
+	
+	delete iHandles;
+	iHandles = CMTPTypeArray::NewL(EMTPTypeAUINT32);
+	
+	do
+	    {
+    	iFramework.ObjectMgr().GetObjectHandlesL(params, context, handles);
+    	iHandles->AppendL(handles);
+	    }
+	while (!context.QueryComplete());
+	
+	CleanupStack::PopAndDestroy(&handles);
+	CleanupStack::PopAndDestroy(&context);					
+	SendDataL(*iHandles);	
+	}
+
+
+
+
+
+
+	
+
+	
+
+
+   	
+
+	
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetserviceids.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,96 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtptypearray.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpgetserviceids.h"
+#include "mtpdevdppanic.h"
+#include "mtpdevicedpconst.h"
+#include "cmtpservicemgr.h"
+
+
+/**
+GetServiceIds request processor factory method.
+@param aPlugin The data provider plugin.
+@param aFramework The data provider framework
+@param aConnection The connection on which the request is being processed.
+@return A pointer to an GetStorageIds request processor. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+MMTPRequestProcessor* CMTPGetServiceIds::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {    
+    CMTPGetServiceIds* self = new (ELeave) CMTPGetServiceIds(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor.
+*/    
+CMTPGetServiceIds::~CMTPGetServiceIds()
+    {    
+    delete iServiceIds;
+    iFrameworkSingletons.Close();
+    }
+
+/**
+Constructor.
+*/    
+CMTPGetServiceIds::CMTPGetServiceIds(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+    {
+    
+    }
+       
+void CMTPGetServiceIds::ServiceL()
+    {
+    BuildServiceIdsL();
+    SendDataL(*iServiceIds);    
+    }
+
+/**
+Second-phase constructor.
+*/        
+void CMTPGetServiceIds::ConstructL()
+    {
+    iFrameworkSingletons.OpenL();
+    }
+
+/**
+Constructs an MTP ServiceID array dataset.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPGetServiceIds::BuildServiceIdsL()
+    {
+    // Retrieve the available ServiceIDs
+        
+    // Construct the dataset.
+    iServiceIds = CMTPTypeArray::NewL(EMTPTypeAUINT32);
+    TInt count = iFrameworkSingletons.ServiceMgr().GetServiceIDs().Count();
+    RArray<TUint> ServiceIDs = iFrameworkSingletons.ServiceMgr().GetServiceIDs();
+    for (TUint i(0); (i < count); i++)
+        {
+        	iServiceIds->AppendUintL(ServiceIDs[i]);
+        }
+    
+   }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetserviceinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,258 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+#include <mtp/cmtpdataproviderplugin.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mtpdataproviderapitypes.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/cmtptypeserviceinfo.h>
+#include <mtp/cmtptypeserviceprop.h>
+#include <mtp/cmtptypeserviceformat.h>
+#include <mtp/cmtptypeservicemethod.h>
+#include <mtp/cmtptypeserviceevent.h>
+#include <mtp/tmtptypeguid.h>
+
+#include "cmtpgetserviceinfo.h"
+#include "rmtpframework.h"
+#include "mtpdevdppanic.h"
+#include "cmtpservicemgr.h"
+
+
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"GetServiceInfo");)
+
+/**
+Two-phase construction method
+@param aPlugin    The data provider plugin
+@param aFramework    The data provider framework
+@param aConnection    The connection from which the request comes
+@return a pointer to the created request processor object
+*/    
+MMTPRequestProcessor* CMTPGetServiceInfo::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPGetServiceInfo* self = new (ELeave) CMTPGetServiceInfo(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor.
+*/    
+CMTPGetServiceInfo::~CMTPGetServiceInfo()
+    {    
+    __FLOG(_L8("~CMTPGetServiceInfo - Entry"));
+    delete iServiceInfo;
+
+    iSingletons.Close();
+    __FLOG(_L8("~CMTPGetServiceInfo - Exit"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Constructor.
+*/    
+CMTPGetServiceInfo::CMTPGetServiceInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+    {
+    
+    }
+    
+/**
+GetServiceInfo request handler. Build and send device info data set.
+*/    
+void CMTPGetServiceInfo::ServiceL()
+    {
+    __FLOG(_L8("ServiceL - Entry"));
+       
+    TUint32 serviceId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    if ( KErrNotFound == iSingletons.ServiceMgr().GetServiceIDs().Find(serviceId) )
+    	{
+    	SendResponseL(EMTPRespCodeInvalidServiceID);
+    	}
+    else if(iSingletons.ServiceMgr().IsSupportedService(serviceId))
+    	{
+    	BuildServiceInfoL();
+    	SendDataL(*iServiceInfo);
+    	}
+    else
+        {
+        //The ServiceID has been allocated by MTP Datacode Generator
+        //but Parser&Router fail to get the target DP.
+        //it may be caused by: 
+        //    1. DP plugin does not register the ServiceID by the Supported() function. Mostly.
+        //    2. Framework have some errors while setup the router mapping table.
+        Panic(EMTPDevDpUnknownServiceID);
+        }
+    
+    __FLOG(_L8("ServiceL - Exit"));
+    }
+
+/**
+Second-phase constructor.
+*/        
+void CMTPGetServiceInfo::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry")); 
+    iSingletons.OpenL();
+    __FLOG(_L8("ConstructL - Exit")); 
+    }
+
+/**
+Populates service info data set
+*/
+void CMTPGetServiceInfo::BuildServiceInfoL()
+    {
+    __FLOG(_L8("BuildServiceInfoL - Entry")); 
+    
+    delete iServiceInfo;
+    iServiceInfo = CMTPTypeServiceInfo::NewL();
+    
+    TUint32 serviceId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    CMTPServiceInfo* svcinfo = iSingletons.ServiceMgr().ServiceInfo( serviceId );
+    if( NULL == svcinfo )
+        {
+        __FLOG_1(_L8("BuildServiceInfoL - CMTPServiceInfo is NULL!!! ServiceID is %d."),serviceId ); 
+        __FLOG(_L8("BuildServiceInfoL - Exit")); 
+        return;
+        }
+    BuildServiceInfoHeadL(*svcinfo);
+    BuildUsedServiceGUIDL(*svcinfo);
+	BuildServicePropertyL(*svcinfo);
+	BuildServiceFormatL(*svcinfo);
+	BuildServiceMethodL(*svcinfo);
+	BuildDataBlockL(*svcinfo);    
+    
+    __FLOG(_L8("BuildServiceInfoL - Exit")); 
+    }
+
+
+void CMTPGetServiceInfo::BuildServiceInfoHeadL(CMTPServiceInfo& aServiceInfo)
+	{
+	__FLOG(_L8("BuildServiceInfoHeadL - Entry"));
+	
+	iServiceInfo->SetUint32L(CMTPTypeServiceInfo::EServiceID,aServiceInfo.ServiceID());
+	iServiceInfo->SetUint32L(CMTPTypeServiceInfo::EServiceStorageID,aServiceInfo.ServiceStorageID());
+	iServiceInfo->SetL(CMTPTypeServiceInfo::EServicePGUID,aServiceInfo.ServicePersistentGUID());
+	iServiceInfo->SetUint32L(CMTPTypeServiceInfo::EServiceVersion,aServiceInfo.ServiceVersion());
+	iServiceInfo->SetL(CMTPTypeServiceInfo::EServiceGUID,aServiceInfo.ServiceGUID());
+	iServiceInfo->SetStringL(CMTPTypeServiceInfo::EServiceName,aServiceInfo.ServiceName());
+	iServiceInfo->SetUint32L(CMTPTypeServiceInfo::EServiceType,aServiceInfo.ServiceType());
+	iServiceInfo->SetUint32L(CMTPTypeServiceInfo::EBaseServiceID,aServiceInfo.BaseServiceID());
+	
+	__FLOG(_L8("BuildServiceInfoHeadL - Exit")); 
+	}
+
+void CMTPGetServiceInfo::BuildUsedServiceGUIDL(CMTPServiceInfo& aServiceInfo)
+	{
+	__FLOG(_L8("BuildUsedServiceGUIDL - Entry"));
+	TInt count = aServiceInfo.UsedServiceGUIDs().Count();
+	const RArray<TMTPTypeGuid> UsedServiceGUIDs = aServiceInfo.UsedServiceGUIDs();
+	for (TInt i=0;i<count;i++)
+		{
+          iServiceInfo->AppendUsedServiceL( UsedServiceGUIDs[i] );
+		}
+	
+	__FLOG(_L8("BuildUsedServiceGUIDL - Exit"));
+	}
+
+void CMTPGetServiceInfo::BuildServicePropertyL(CMTPServiceInfo& aServiceInfo)
+	{
+	__FLOG(_L8("BuildServicePropertyL - Entry"));
+
+	TInt count = aServiceInfo.ServiceProperties().Count();
+	CMTPTypeServicePropertyElement* PropElement = NULL;
+	CServiceProperty* prop = NULL;
+	const RPointerArray<CServiceProperty> ServiceProperties = aServiceInfo.ServiceProperties();
+	for (TInt i=0;i<count;i++)
+		{
+		prop = ServiceProperties[i];
+		if(!prop->IsUsed())
+		    continue;
+		
+		PropElement = CMTPTypeServicePropertyElement::NewLC(prop->Code(),prop->Namespace(),prop->PKeyID(), prop->Name());
+		iServiceInfo->ServicePropList().AppendL(PropElement);
+		CleanupStack::Pop(PropElement);
+		}
+	
+	__FLOG(_L8("BuildServicePropertyL - Exit"));
+	}
+
+void CMTPGetServiceInfo::BuildServiceFormatL(CMTPServiceInfo& aServiceInfo)
+	{
+	__FLOG(_L8("BuildServiceFormatL - Entry"));
+
+	CMTPTypeServiceFormatElement* FormatElement = NULL; 
+	CServiceFormat* format = NULL;  
+	TInt count = aServiceInfo.ServiceFormats().Count();
+	const RPointerArray<CServiceFormat> ServiceFormats = aServiceInfo.ServiceFormats();
+	for (TInt i=0;i<count;i++)
+		{
+		format = ServiceFormats[i];
+		if(!format->IsUsed())
+		    continue;
+		
+		FormatElement = CMTPTypeServiceFormatElement::NewLC( format->Code(), format->GUID(), format->Name(), format->FormatBase(), format->MIMEType1() );
+		iServiceInfo->ServiceFormatList().AppendL(FormatElement);
+		CleanupStack::Pop(FormatElement);
+		}
+	
+	__FLOG(_L8("BuildServiceFormatL - Exit"));
+	}
+
+void CMTPGetServiceInfo::BuildServiceMethodL(CMTPServiceInfo& aServiceInfo)
+	{
+	__FLOG(_L8("BuildServiceMethodL - Entry"));
+
+	CMTPTypeServiceMethodElement* methodElement = NULL;
+	CServiceMethod* method = NULL;
+	TInt count = aServiceInfo.ServiceMethods().Count();
+	const RPointerArray<CServiceMethod> ServiceMethods = aServiceInfo.ServiceMethods();
+	for (TInt i=0;i<count;i++)
+		{
+		method = ServiceMethods[i];
+		if(!method->IsUsed())
+		    continue;
+		methodElement = CMTPTypeServiceMethodElement::NewLC( method->Code(), method->GUID(), method->Name(), method->ObjAssociateFormatCode() );
+		iServiceInfo->ServiceMethodList().AppendL(methodElement);
+		CleanupStack::Pop(methodElement);		
+		}
+	
+	__FLOG(_L8("BuildServiceMethodL - Exit"));
+	}
+
+
+void CMTPGetServiceInfo::BuildDataBlockL(CMTPServiceInfo& aServiceInfo)
+    {
+    __FLOG(_L8("BuildDataBlockL - Entry"));
+    TInt count = aServiceInfo.DataBlockGUIDs().Count();
+    const RArray<TMTPTypeGuid> DataBlockGUIDs = aServiceInfo.DataBlockGUIDs();
+    for (TInt i=0;i<count;i++)
+        {
+        iServiceInfo->AppendServiceDataBlockL( DataBlockGUIDs[i] );
+        }
+
+    __FLOG(_L8("BuildDataBlockL - Exit"));
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageids.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,119 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtptypearray.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mtpdataproviderapitypes.h>
+
+#include "cmtpgetstorageids.h"
+#include "cmtpstoragemgr.h"
+#include "mtpdevdppanic.h"
+#include "mtpdevicedpconst.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpdataprovider.h"
+
+/**
+GetStorageIds request processor factory method.
+@param aPlugin The data provider plugin.
+@param aFramework The data provider framework
+@param aConnection The connection on which the request is being processed.
+@return A pointer to an GetStorageIds request processor. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+MMTPRequestProcessor* CMTPGetStorageIds::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {    
+    CMTPGetStorageIds* self = new (ELeave) CMTPGetStorageIds(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor.
+*/    
+CMTPGetStorageIds::~CMTPGetStorageIds()
+    {    
+    delete iStorageIds;
+    iFrameworkSingletons.Close();
+    }
+
+/**
+Constructor.
+*/    
+CMTPGetStorageIds::CMTPGetStorageIds(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+    {
+    
+    }
+       
+void CMTPGetStorageIds::ServiceL()
+    {
+    BuildStorageIdsL();
+    SendDataL(*iStorageIds);    
+    }
+
+/**
+Second-phase constructor.
+*/        
+void CMTPGetStorageIds::ConstructL()
+    {
+    iFrameworkSingletons.OpenL();
+    }
+
+/**
+Constructs an MTP StorageID array dataset.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPGetStorageIds::BuildStorageIdsL()
+    {
+    // Retrieve the available logical StorageIDs
+    RPointerArray<const CMTPStorageMetaData> storages;
+    CleanupClosePushL(storages);
+    iFrameworkSingletons.StorageMgr().GetLogicalStoragesL(TMTPStorageMgrQueryParams(), storages);
+    
+    // Construct the dataset.
+    iStorageIds = CMTPTypeArray::NewL(EMTPTypeAUINT32);
+    RArray<TUint> storageIds;
+    CleanupClosePushL(storageIds);
+    const TUint KCount(storages.Count());
+    TUint dpid = 0;
+    for (TUint i(0); (i < KCount); i++)
+        {
+        dpid = iFrameworkSingletons.StorageMgr().LogicalStorageOwner( storages[i]->Uint(CMTPStorageMetaData::EStorageId) );
+        // The storage ID of service data providers will not be reported in GetStorageIDs operation.
+        if( iFrameworkSingletons.DpController().DataProviderL(dpid).SupportedCodes( EServiceIDs ).Count() != 0 )
+        	{
+			continue;
+			}
+           
+        TUint storageId = storages[i]->Uint(CMTPStorageMetaData::EStorageId);
+        if(EDriveE == iFrameworkSingletons.StorageMgr().DriveNumber(storageId))
+        	{
+        	storageIds.InsertL(storageId, 0);
+        	}
+        else
+        	{
+        	storageIds.AppendL(storageId);
+        	}
+        }
+    iStorageIds->AppendL(storageIds);
+    CleanupStack::PopAndDestroy(2, &storages);
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,337 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtptypestorageinfo.h>
+#include <mtp/cmtptypestring.h>
+
+#include "cmtpgetstorageinfo.h"
+#include "cmtpstoragemgr.h"
+#include "mtpdevicedpconst.h"
+#include "mtpdevdppanic.h"
+#include "rmtpdevicedpsingletons.h"
+#include "cmtpdevicedpconfigmgr.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"GetStorageInfo");)
+
+/**
+Verification data for GetStorageInfo request
+*/
+const TMTPRequestElementInfo KMTPGetStorageInfoPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeStorageId, EMTPElementAttrNone, 0, 0, 0}
+    };
+
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/    
+MMTPRequestProcessor* CMTPGetStorageInfo::NewL(
+											MMTPDataProviderFramework& aFramework,
+											MMTPConnection& aConnection)
+	{
+	CMTPGetStorageInfo* self = new (ELeave) CMTPGetStorageInfo(aFramework, aConnection);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+/**
+Destructor
+*/	
+CMTPGetStorageInfo::~CMTPGetStorageInfo()
+	{	
+	delete iStorageInfo;
+	iSingletons.Close();
+	__FLOG_CLOSE;
+	}
+	
+/**
+Standard c++ constructor
+*/	
+CMTPGetStorageInfo::CMTPGetStorageInfo(
+									MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection)
+	:CMTPRequestProcessor(aFramework, aConnection,sizeof(KMTPGetStorageInfoPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetStorageInfoPolicy)
+	{
+	}
+
+/**
+GetStorageInfo request handler
+Build storage info data set and send the data to the initiator
+*/		
+void CMTPGetStorageInfo::ServiceL()
+	{
+	TUint32 storageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);	
+	
+	if ( iSingletons.StorageMgr().LogicalStorageId(storageId)  )
+	    {
+	    if ( iSingletons.StorageMgr().LogicalStorageOwner(storageId) == iFramework.DataProviderId() )
+	        {
+	        BuildStorageInfoL();
+	        SendDataL(*iStorageInfo);		
+	        }
+	    else
+	        {
+	        SendResponseL(EMTPRespCodeStoreNotAvailable);
+	        }
+	    }
+	else if ( iSingletons.StorageMgr().PhysicalStorageId(storageId) )
+	    {
+	    if ( iSingletons.StorageMgr().PhysicalStorageOwner(storageId) == iFramework.DataProviderId() )
+	        {
+	        BuildStorageInfoL();
+	        SendDataL(*iStorageInfo);		
+	        }
+	    else
+	        {
+	        SendResponseL(EMTPRespCodeStoreNotAvailable);
+	        }
+	    }
+	else
+	    {
+        // Storage Id is not valid
+        SendResponseL(EMTPRespCodeInvalidStorageID);
+        }
+	}
+
+/**
+Second-phase construction
+*/		
+void CMTPGetStorageInfo::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	iStorageInfo = CMTPTypeStorageInfo::NewL();
+	iSingletons.OpenL();
+	}
+
+/**
+Populate the storage info data set
+*/	
+void CMTPGetStorageInfo::BuildStorageInfoL()
+	{
+	SetupDriveVolumeInfoL();
+    SetStorageTypeL();
+    SetFileSystemTypeL();
+    SetAccessCapabilityL();
+    SetMaxCapacityL();
+    SetFreeSpaceInBytesL();
+    SetFreeSpaceInObjectsL();
+    SetStorageDescriptionL();
+    SetVolumeIdentifierL();		
+	}
+
+/**
+Set the drive volume info in the storage info data set
+*/
+void CMTPGetStorageInfo::SetupDriveVolumeInfoL()
+	{
+	TUint32 storageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);	
+	TInt driveNo(iFramework.StorageMgr().DriveNumber(storageId));
+	User::LeaveIfError(driveNo);
+	RFs& fs = iFramework.Fs();
+	User::LeaveIfError(fs.Drive(iDriveInfo, driveNo));
+	User::LeaveIfError(fs.Volume(iVolumeInfo, driveNo));
+	}
+	
+/**
+Set the storage type in the storage info data set
+*/
+void CMTPGetStorageInfo::SetStorageTypeL()
+	{
+	TUint16 storageType = EMTPStorageUndefined;
+	switch(iDriveInfo.iType)
+		{
+		case EMediaNotPresent:
+			User::Leave(KErrDisMounted);
+			break;
+		case EMediaUnknown:		
+			break;
+			
+		case EMediaCdRom:
+			storageType = EMTPStorageRemovableROM;			
+			 break;
+		case EMediaRam:
+		case EMediaNANDFlash:
+			storageType = EMTPStorageFixedRAM;
+			break;
+		case EMediaRom:
+			storageType = EMTPStorageFixedROM;
+			break;
+		case EMediaHardDisk:
+		case EMediaFlash:					
+		case EMediaRemote:
+		case EMediaFloppy:
+			storageType = EMTPStorageRemovableRAM;
+			break;
+		default:
+			break;
+		}
+	TMTPTypeUint16 mtpStorageType(storageType);	
+	iStorageInfo->SetL(CMTPTypeStorageInfo::EStorageType, mtpStorageType);
+	}
+
+/**
+Set the file system type in the storage info data set
+*/
+void CMTPGetStorageInfo::SetFileSystemTypeL()
+	{
+	TMTPTypeUint16 mtpFileSystemType(EMTPFileSystemGenericHierarchical);	
+	iStorageInfo->SetL(CMTPTypeStorageInfo::EFileSystemType, mtpFileSystemType);	
+	}
+	
+
+/**
+Set the access capability in the storage info data set
+*/
+void CMTPGetStorageInfo::SetAccessCapabilityL()
+	{
+	TMTPTypeUint16 mtpStorageType;
+	iStorageInfo->GetL(CMTPTypeStorageInfo::EStorageType, mtpStorageType);
+	TUint16 storageType = mtpStorageType.Value();
+	TInt accessCapability = EAccessCapabilityReadWrite;
+	if(storageType == EMTPStorageFixedROM || storageType == EMTPStorageRemovableROM)
+		{
+		accessCapability = EAccessCapabilityReadOnlyWithoutDeletion;
+		}
+	TMTPTypeUint16 mtpAccessCapability(accessCapability);	
+	iStorageInfo->SetL(CMTPTypeStorageInfo::EAccessCapability, mtpAccessCapability);		
+	}
+
+/**
+Set the max capacity in the storage info data set
+*/
+void CMTPGetStorageInfo::SetMaxCapacityL()
+	{
+	TMTPTypeUint64 mtpMaxCapacity(iVolumeInfo.iSize);
+	iStorageInfo->SetL(CMTPTypeStorageInfo::EMaxCapacity, mtpMaxCapacity);
+	}
+		
+/**
+Set the free space of the drive in the storage info data set
+*/
+void CMTPGetStorageInfo::SetFreeSpaceInBytesL()
+	{
+	TMTPTypeUint64 mtpFreeSpace(iVolumeInfo.iFree);
+	iStorageInfo->SetL(CMTPTypeStorageInfo::EFreeSpaceInBytes, mtpFreeSpace);	
+	}
+	
+/**
+Set the free space of in objects in the storage info data set
+*/
+void CMTPGetStorageInfo::SetFreeSpaceInObjectsL()
+	{
+	TMTPTypeUint32 mtpFreeSpaceInObj(0xFFFFFFFF); 	//we don't support this property
+	iStorageInfo->SetL(CMTPTypeStorageInfo::EFreeSpaceInObjects, mtpFreeSpaceInObj);	
+	}
+	
+/**
+Set the storage description (volume name) of the drive in the storage info data set
+*/
+void CMTPGetStorageInfo::SetStorageDescriptionL()
+	{
+	__FLOG(_L8("SetStorageDescriptionL - Entry"));
+    TUint32 storage(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
+    TInt driveNumber = iFramework.StorageMgr().DriveNumber(storage);
+	RBuf volumeName;
+	volumeName.CreateL(KMaxFileName);
+	volumeName.CleanupClosePushL();
+	RMTPDeviceDpSingletons devSingletons;
+	devSingletons.OpenL(iFramework);
+	CleanupClosePushL(devSingletons);
+	TRAPD(resError, devSingletons.ConfigMgr().GetFriendlyVolumeNameL(driveNumber, volumeName));
+	if ((KErrNone == resError) && (0 < volumeName.Length()))
+		{
+		__FLOG(_L8("Using volume name from resource file"));
+		CMTPTypeString* mtpDescription = CMTPTypeString::NewLC(volumeName);
+		iStorageInfo->SetL(CMTPTypeStorageInfo::EStorageDescription, *mtpDescription);
+		CleanupStack::PopAndDestroy(mtpDescription);
+		}
+	else if (0 < iVolumeInfo.iName.Length())
+		{
+		__FLOG(_L8("Using standard volume name"));
+		CMTPTypeString* mtpDescription = CMTPTypeString::NewLC(iVolumeInfo.iName);
+		iStorageInfo->SetL(CMTPTypeStorageInfo::EStorageDescription, *mtpDescription);
+	    CleanupStack::PopAndDestroy(mtpDescription);
+		}
+		
+	CleanupStack::PopAndDestroy(&devSingletons);
+	CleanupStack::PopAndDestroy(&volumeName);
+	__FLOG(_L8("SetStorageDescriptionL - Exit"));
+	}
+	
+/**
+Set the volume identifier of the drive in the storage info data set
+*/
+void CMTPGetStorageInfo::SetVolumeIdentifierL()
+	{
+	// Retrieve the StorageID.
+    TUint32 storage(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
+	
+	// Retrieve the volume info.
+	TVolumeInfo volInfo;
+	iFramework.Fs().Volume(volInfo, iFramework.StorageMgr().DriveNumber(storage));
+	
+	// Construct the suffix string.
+	RBuf16 suffix;
+	CleanupClosePushL(suffix);
+	suffix.CreateMaxL(KMTPMaxStringCharactersLength);
+	suffix.Format(_L("%08X"), volInfo.iUniqueID);
+           
+    if (volInfo.iName.Length() != 0)
+        {
+        // Append the separator and volume label, truncating if necessary.
+        suffix.Append(_L("-"));
+        suffix.Append(volInfo.iName.Left(KMTPMaxStringCharactersLength - suffix.Length()));
+        }
+	
+	// Generate the volume ID string.
+	CMTPTypeString* volId(iFramework.StorageMgr().VolumeIdL(iFramework.DataProviderId(), storage, suffix));
+	CleanupStack::PopAndDestroy(&suffix);
+	CleanupStack::PushL(volId);
+	iStorageInfo->SetL(CMTPTypeStorageInfo::EVolumeIdentifier, *volId);
+	CleanupStack::PopAndDestroy(volId);	
+	}
+
+
+
+
+
+
+
+
+
+
+	
+
+	
+
+
+   	
+
+	
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpopensession.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,98 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpopensession.h"
+#include "cmtpconnection.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpdataprovider.h"
+#include "mtpdevdppanic.h"
+#include "cmtpconnectionmgr.h"
+#include "rmtpframework.h"
+
+/**
+Verification data for OpenSession request
+*/
+const TMTPRequestElementInfo KMTPOpenSessionPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeSessionID, EMTPElementAttrNone, 0, 0, 0}
+    };
+
+/**
+Two-phase construction method
+@param aPlugin    The data provider plugin
+@param aFramework    The data provider framework
+@param aConnection    The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+MMTPRequestProcessor* CMTPOpenSession::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPOpenSession* self = new (ELeave) CMTPOpenSession(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+CMTPOpenSession::~CMTPOpenSession()
+    {
+    iSingletons.Close();
+    }
+
+/**
+Standard c++ constructor
+*/    
+CMTPOpenSession::CMTPOpenSession(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPOpenSessionPolicy)/sizeof(TMTPRequestElementInfo), KMTPOpenSessionPolicy)
+    {
+    
+    }
+    
+/**
+Second phase constructor.
+*/
+void CMTPOpenSession::ConstructL()
+    {
+    iSingletons.OpenL();
+    }
+    
+/**
+OpenSession request handler.  Adds the session to the connection.
+*/    
+void CMTPOpenSession::ServiceL()    
+    {
+    iSingletons.DpController().WaitForEnumerationComplete();
+    if(iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumerated)
+    	{
+    	SendResponseL(EMTPRespCodeDeviceBusy);
+    	}
+    else
+    	{
+    	const TUint connectionId = iConnection.ConnectionId();
+    	CMTPConnectionMgr& connectionMgr = iSingletons.ConnectionMgr();
+    	CMTPConnection& connection = connectionMgr.ConnectionL(connectionId);
+    	connection.SessionOpenedL(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
+    	SendResponseL(EMTPRespCodeOK);
+    	}
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpresetdevice.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,102 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpresetdevice.h"
+#include "cmtpconnection.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpdataprovider.h"
+#include "mtpdevdppanic.h"
+#include "cmtpconnectionmgr.h"
+#include "rmtpframework.h"
+
+/**
+Two-phase construction method
+@param aFramework    The data provider framework
+@param aConnection    The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+MMTPRequestProcessor* CMTPResetDevice::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPResetDevice* self = new (ELeave) CMTPResetDevice(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+CMTPResetDevice::~CMTPResetDevice()
+    {
+    iSingletons.Close();
+    }
+
+/**
+Standard c++ constructor
+*/    
+CMTPResetDevice::CMTPResetDevice(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+    {
+    
+    }
+    
+/**
+Second phase constructor.
+*/
+void CMTPResetDevice::ConstructL()
+    {
+    iSingletons.OpenL();
+    }
+    
+/**
+Request checker
+*/
+TMTPResponseCode CMTPResetDevice::CheckRequestL()
+    {
+    TMTPResponseCode response = CMTPRequestProcessor::CheckRequestL();
+    if (response == EMTPRespCodeOK)
+        {
+        TUint32 sessionId = iRequest->Uint32(TMTPTypeRequest::ERequestParameter1);
+        //default session (with id 0) should never be closed
+        if (!iConnection.SessionWithMTPIdExists(sessionId) || sessionId == 0)
+            {
+            response = EMTPRespCodeSessionNotOpen;
+            }
+        }
+    return response;    
+    }
+        
+/**
+ResetDevice request handler. Simply close the session because we don't support multiple session for now.
+*/    
+void CMTPResetDevice::ServiceL()    
+    {
+    // Send response first before close the session
+    SendResponseL(EMTPRespCodeOK);
+     
+    TUint connectionId = iConnection.ConnectionId();
+    CMTPConnectionMgr& connectionMgr = iSingletons.ConnectionMgr();
+    CMTPConnection& connection = connectionMgr.ConnectionL(connectionId);
+    connection.SessionClosedL(0x0FFFFFFF);   
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpresetdevicepropvalue.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,283 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mmtpframeworkconfig.h>
+#include <centralrepository.h>
+
+#include "cmtpdevicedatastore.h"
+#include "cmtpresetdevicepropvalue.h"
+#include "mtpdevicedpconst.h"
+#include "mtpdevdppanic.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"ResetDevicePropValue");)
+
+/**
+Two-phase constructor.
+@param aPlugin  The data provider plugin
+@param aFramework The data provider framework
+@param aConnection The connection from which the request comes
+@return a pointer to the created request processor object.
+*/  
+MMTPRequestProcessor* CMTPResetDevicePropValue::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPResetDevicePropValue* self = new (ELeave) CMTPResetDevicePropValue(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+CMTPResetDevicePropValue::~CMTPResetDevicePropValue()
+    {    
+    __FLOG(_L8("~CMTPResetDevicePropValue - Entry"));
+        iDpSingletons.Close();
+        delete iData;
+        delete iRepository;
+    __FLOG(_L8("~CMTPResetDevicePropValue - Exit"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Standard c++ constructor
+*/    
+CMTPResetDevicePropValue::CMTPResetDevicePropValue(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+ CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+    {
+    
+    }
+    
+/**
+Second-phase construction
+*/    
+void CMTPResetDevicePropValue::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry")); 
+    iDpSingletons.OpenL(iFramework);
+	const TUint32 KUidMTPRepositoryValue(0x10282FCC);
+    const TUid KUidMTPRepository = {KUidMTPRepositoryValue};
+    iRepository = CRepository::NewL(KUidMTPRepository);
+    __FLOG(_L8("ConstructL - Exit")); 
+    }
+
+/**
+SetDevicePropValue request validator.
+@return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
+*/
+TMTPResponseCode CMTPResetDevicePropValue::CheckRequestL()
+    {
+    __FLOG(_L8("CheckRequestL - Entry"));
+    TMTPResponseCode respCode(EMTPRespCodeDevicePropNotSupported);
+    iPropCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    const TInt count = sizeof(KMTPDeviceDpSupportedProperties) / sizeof(KMTPDeviceDpSupportedProperties[0]);
+    for (TUint i(0); ((respCode != EMTPRespCodeOK) && (i < count)); i++)
+        {
+        if (iPropCode == KMTPDeviceDpSupportedProperties[i])
+            {
+            respCode = EMTPRespCodeOK;
+            }
+        }
+
+    if(iDpSingletons.DeviceDataStore().ExtnDevicePropDp())
+        {
+        respCode = EMTPRespCodeOK;
+        }
+    __FLOG(_L8("CheckRequestL - Exit"));
+    return respCode;
+    }
+/**
+ResetDevicePropValue request handler.
+*/ 	
+void CMTPResetDevicePropValue::ServiceL()
+    {
+    __FLOG(_L8("ServiceL - Entry"));
+    iPropCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    MExtnDevicePropDp* extnDevplugin = iDpSingletons.DeviceDataStore().ExtnDevicePropDp();
+    switch (iPropCode)
+        {
+        //Added all new prpoerties here we have to add other properties that not present here*/
+        case EMTPDevicePropCodeSessionInitiatorVersionInfo:
+            ServiceSessionInitiatorVersionInfoL();
+        break;
+        case EMTPDevicePropCodePerceivedDeviceType:
+            ServicePerceivedDeviceTypeL();
+        break;
+
+        case EMTPDevicePropCodeDeviceIcon:
+            ServiceDeviceIconL();
+        break;
+
+        case EMTPDevicePropCodeSupportedFormatsOrdered:
+            ServiceSupportedFormatsOrderedL();
+        break;
+
+        case EMTPDevicePropCodeDateTime:
+            ServiceDateTimeL();
+        break;
+        case EMTPDevicePropCodeFunctionalID:
+        	ServiceFunctionalIDL();
+        break;
+        case EMTPDevicePropCodeModelID:
+        	ServiceModelIDL();
+        break;
+        case EMTPDevicePropCodeUseDeviceStage:
+        	ServiceUseDeviceStageL();
+        break;
+        default:         
+            if(extnDevplugin)
+                { 
+                HandleExtnServiceL(iPropCode, extnDevplugin);
+                }
+            else 
+                { 
+                SendResponseL(EMTPRespCodeDevicePropNotSupported);
+                }
+        break;   
+        }
+    } 
+
+ void CMTPResetDevicePropValue::HandleExtnServiceL(TInt aPropCode, MExtnDevicePropDp* aExtnDevplugin)
+    {
+	  if(aExtnDevplugin->ResetDevPropertyL((TMTPDevicePropertyCode)aPropCode) == KErrNone)
+	  {
+	  SendResponseL(EMTPRespCodeOK);
+	  }
+	  else
+	  {
+	  SendResponseL(EMTPRespCodeDevicePropNotSupported);
+	  }
+    
+    }
+
+/**
+Service session initiator property.
+*/ 
+void CMTPResetDevicePropValue::ServiceSessionInitiatorVersionInfoL()
+    {  
+    __FLOG(_L8("SetSessionInitiatorVersionInfo - Entry")); 
+    iDpSingletons.DeviceDataStore().SetSessionInitiatorVersionInfoL( iDpSingletons.DeviceDataStore().SessionInitiatorVersionInfoDefault());
+    SendResponseL(EMTPRespCodeOK);
+    __FLOG(_L8("SetSessionInitiatorVersionInfo - Exit"));
+    }
+
+/**
+*Service the PerceivedDeviceType property.
+*it is not set type it should be removed 
+**/
+void CMTPResetDevicePropValue::ServicePerceivedDeviceTypeL()
+    {  
+    __FLOG(_L8("ServicePerceivedDeviceType - Entry")); 
+    //PerceivedDeviceType is of type get only .
+    SendResponseL(EMTPRespCodeAccessDenied);
+    __FLOG(_L8("ServicePerceivedDeviceType - Exit"));
+    }
+
+/**
+Service the Date Time property.
+*/ 
+void CMTPResetDevicePropValue::ServiceDateTimeL()
+    {  
+    __FLOG(_L8("ServiceDateTime - Entry")); 
+    SendResponseL(EMTPRespCodeOperationNotSupported);
+    __FLOG(_L8("ServiceDateTime - Exit"));
+    }
+
+
+/*
+*Service the Device Icon property and CompleteDeviceIcon.
+As of now implemented as device property of type get.
+*/   
+void CMTPResetDevicePropValue::ServiceDeviceIconL()
+    {  
+    __FLOG(_L8("ServiceDeviceIcon - Entry")); 
+    //DeviceIcon property is implemented as get only .
+    SendResponseL(EMTPRespCodeAccessDenied);
+    __FLOG(_L8("ServiceDeviceIcon - Exit"));
+    }
+
+/*
+*ServiceSupportedFormatsOrdered property. it is get only type.
+*/
+void CMTPResetDevicePropValue::ServiceSupportedFormatsOrderedL()
+    {  
+    __FLOG(_L8("ServiceSupportedFormatsOrdered - Entry"));  
+    //no need to recive this data beacuse it is Get property
+    //iDpSingletons.DeviceDataStore().SetFormatOrdered( iDpSingletons.DeviceDataStore().FormatOrderedDefault());
+    SendResponseL(EMTPRespCodeAccessDenied);
+    __FLOG(_L8("ServicePerceivedDeviceType - Exit"));
+    }
+
+/*
+*FunctionalID property. 
+*/
+void CMTPResetDevicePropValue::ServiceFunctionalIDL()
+    {	 
+    __FLOG(_L8("ServiceFunctionalIDL - Entry")); 
+    delete iData;
+    iData = GetGUIDL( MMTPFrameworkConfig::EDeviceDefaultFuncationalID ); 
+    SaveGUID(MMTPFrameworkConfig::EDeviceCurrentFuncationalID, *iData);
+    SendResponseL(EMTPRespCodeOK);
+    __FLOG(_L8("ServiceFunctionalIDL - Exit"));
+    }
+
+/*
+*ModelID property. it is get only type.
+*/
+void CMTPResetDevicePropValue::ServiceModelIDL()
+    {	 
+    __FLOG(_L8("ServiceModelIDL - Entry")); 	
+    SendResponseL(EMTPRespCodeAccessDenied);
+    __FLOG(_L8("ServiceModelIDL - Exit"));
+    }
+
+/*
+*UseDeviceStage property. it is get only type.
+*/
+void CMTPResetDevicePropValue::ServiceUseDeviceStageL()
+    {	 
+    __FLOG(_L8("ServiceUseDeviceStageL - Entry")); 	
+    SendResponseL(EMTPRespCodeAccessDenied);
+    __FLOG(_L8("ServiceUseDeviceStageL - Exit"));
+    }
+
+TMTPTypeGuid* CMTPResetDevicePropValue::GetGUIDL(const TUint aKey)
+    {
+    
+    TBuf8<KMTPTypeUINT128Size> ptr;
+    
+    iRepository->Get(aKey,ptr);
+    
+    TMTPTypeGuid* ret = new (ELeave) TMTPTypeGuid( ptr );
+    
+    return ret;
+    }
+
+void CMTPResetDevicePropValue::SaveGUID( const TUint aKey,  TMTPTypeGuid& aValue )
+    {
+    TPtrC8 ptr;
+    if ( KMTPChunkSequenceCompletion == aValue.FirstReadChunk(ptr) )
+    	{
+    	iRepository->Set(aKey,ptr);
+    	}
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpsetdevicepropvalue.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,421 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/rmtpclient.h>
+#include <e32property.h>
+#include <mtp/mmtpframeworkconfig.h>
+#include "cmtpdevicedatastore.h"
+#include "cmtpsetdevicepropvalue.h"
+#include "mtpdevicedpconst.h"
+#include "mtpdevdppanic.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"SetDevicePropValue");)
+
+/**
+Two-phase constructor.
+@param aPlugin  The data provider plugin
+@param aFramework The data provider framework
+@param aConnection The connection from which the request comes
+@return a pointer to the created request processor object.
+*/  
+MMTPRequestProcessor* CMTPSetDevicePropValue::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPSetDevicePropValue* self = new (ELeave) CMTPSetDevicePropValue(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+CMTPSetDevicePropValue::~CMTPSetDevicePropValue()
+    {    
+    __FLOG(_L8("~CMTPSetDevicePropValue - Entry"));
+    delete iString;
+    delete iMtparray;
+    delete iData;
+    __FLOG(_L8("~CMTPSetDevicePropValue - Exit"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Standard c++ constructor
+*/    
+CMTPSetDevicePropValue::CMTPSetDevicePropValue(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPGetDevicePropDesc(aFramework, aConnection)
+    {
+    
+    }
+    
+/**
+Second-phase construction
+*/    
+void CMTPSetDevicePropValue::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry")); 
+    CMTPGetDevicePropDesc::ConstructL();
+    iString = CMTPTypeString::NewL();
+    iMtparray = CMTPTypeArray::NewL(EMTPTypeAUINT8);
+    iData = new(ELeave) TMTPTypeGuid();
+    __FLOG(_L8("ConstructL - Exit")); 
+    }
+
+/**
+Service Battery level property
+*/    
+void CMTPSetDevicePropValue::ServiceBatteryLevelL()
+    {
+    __FLOG(_L8("ServiceBatteryLevelL - Entry"));
+    SendResponseL(EMTPRespCodeAccessDenied); 
+    __FLOG(_L8("ServiceBatteryLevelL - Exit"));   
+    }
+
+/**
+Service the device friendly name property.
+*/   
+void CMTPSetDevicePropValue::ServiceDeviceFriendlyNameL()
+    {
+    __FLOG(_L8("ServiceDeviceFriendlyNameL - Entry"));
+    iString->SetL(KNullDesC);
+    ReceiveDataL(*iString); 
+    __FLOG(_L8("ServiceDeviceFriendlyNameL - Exit"));    
+    }
+        
+/**
+Service the synchronisation partner property.
+*/ 
+void CMTPSetDevicePropValue::ServiceSynchronisationPartnerL()
+    {    
+    __FLOG(_L8("ServiceSynchronisationPartnerL - Entry")); 
+    iString->SetL(KNullDesC);
+    ReceiveDataL(*iString);
+    __FLOG(_L8("ServiceSynchronisationPartnerL - Exit"));
+    }
+    
+/**
+SetDevicePropValue request validator.
+@return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
+*/
+TMTPResponseCode CMTPSetDevicePropValue::CheckRequestL()
+	{
+	__FLOG(_L8("CheckRequestL - Entry")); 
+	TMTPResponseCode responseCode = CMTPGetDevicePropDesc::CheckRequestL();
+	
+	TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+	if( propCode == EMTPDevicePropCodeBatteryLevel)
+		{
+		responseCode = EMTPRespCodeAccessDenied;
+		}
+	__FLOG(_L8("CheckRequestL - Exit")); 
+	return responseCode;
+	}
+
+/**
+Process the transaction response phase.
+*/    
+TBool CMTPSetDevicePropValue::DoHandleResponsePhaseL()
+    {
+    __FLOG(_L8("DoHandleResponsePhaseL - Entry"));
+    MExtnDevicePropDp* extnDevplugin = iDpSingletons.DeviceDataStore().ExtnDevicePropDp();
+    TUint32 propCode(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
+    switch(propCode)
+        {
+    case EMTPDevicePropCodeSynchronizationPartner:
+        CompleteServiceSynchronisationPartnerL();
+        break;
+        
+    case EMTPDevicePropCodeDeviceFriendlyName:
+        CompleteServiceDeviceFriendlyNameL();
+        break;
+
+	case EMTPDevicePropCodeSessionInitiatorVersionInfo:
+		CompleteServiceSessionInitiatorVersionInfoL();
+		break;
+	case EMTPDevicePropCodeDateTime:	
+		CompleteServiceDateTimeL();
+		break;
+	
+	case EMTPDevicePropCodeSupportedFormatsOrdered:		
+		CompleteServiceSupportedFormatsOrderedL();
+		break;
+	
+	case EMTPDevicePropCodeDeviceIcon:		
+		CompleteDeviceIconL();
+		break;
+	case EMTPDevicePropCodePerceivedDeviceType:		
+		CompletePerceivedDeviceTypeL();
+		break;
+	case EMTPDevicePropCodeFunctionalID:		
+		CompleteServiceFunctionalIDL();
+		break;
+	case EMTPDevicePropCodeModelID:		
+		CompleteServiceModelIDL();
+		break;
+	case EMTPDevicePropCodeUseDeviceStage:		
+		CompleteServiceUseDeviceStageL();
+		break;
+    default:
+ 		if(extnDevplugin)
+		{
+		SendResponseL(extnDevplugin->SetDevicePropertyL());
+		}
+		else 
+		{
+		SendResponseL(EMTPRespCodeDevicePropNotSupported); 
+		}
+        break;             
+        }
+    __FLOG(_L8("DoHandleResponsePhaseL - Exit"));
+    return EFalse;    
+    }
+    
+TBool CMTPSetDevicePropValue::HasDataphase() const
+	{
+	return ETrue;
+	}
+    
+/**
+Processes the device friendly name property transaction response phase.
+*/
+void CMTPSetDevicePropValue::CompleteServiceDeviceFriendlyNameL()
+    {
+    __FLOG(_L8("CompleteServiceDeviceFriendlyNameL - Entry"));
+    iDpSingletons.DeviceDataStore().SetDeviceFriendlyNameL(iString->StringChars());
+    SendResponseL(EMTPRespCodeOK);  
+    __FLOG(_L8("CompleteServiceDeviceFriendlyNameL - Exit"));  
+    }
+
+/**
+Processes the synchronisation partner property transaction response phase.
+*/
+void CMTPSetDevicePropValue::CompleteServiceSynchronisationPartnerL()
+    {
+    __FLOG(_L8("CompleteServiceSynchronisationPartnerL - Entry"));
+    iDpSingletons.DeviceDataStore().SetSynchronisationPartnerL(iString->StringChars());
+    SendResponseL(EMTPRespCodeOK);
+    __FLOG(_L8("CompleteServiceSynchronisationPartnerL - Exit"));
+    }
+
+void CMTPSetDevicePropValue::HandleExtnServiceL(TInt aPropCode, MExtnDevicePropDp* aExtnDevplugin)
+	{
+	MMTPType* ammtptype = NULL;
+	aExtnDevplugin->GetDevicePropertyContainerL((TMTPDevicePropertyCode)aPropCode, &ammtptype);	
+	if(ammtptype != NULL)
+	{
+	ReceiveDataL(*ammtptype);
+	}
+	else
+	{
+	SendResponseL(EMTPRespCodeDevicePropNotSupported);	
+	}
+	}
+ 
+/**
+Processes the session initiator version info and set the same to session device data store.
+*/
+void CMTPSetDevicePropValue::CompleteServiceSessionInitiatorVersionInfoL()
+	{
+	__FLOG(_L8("CompleteServiceSynchronisationPartnerL - Entry"));
+	RProcess process;
+	RProperty::Set(process.SecureId(), EMTPConnStateKey, iString->StringChars());
+	iDpSingletons.DeviceDataStore().SetSessionInitiatorVersionInfoL(iString->StringChars());
+	SendResponseL(EMTPRespCodeOK);
+	__FLOG(_L8("CompleteServiceSynchronisationPartnerL - Exit"));
+	}
+
+/**
+Service session initiator property.
+*/ 
+void CMTPSetDevicePropValue::ServiceSessionInitiatorVersionInfoL()
+	{	 
+	__FLOG(_L8("SetSessionInitiatorVersionInfoL - Entry")); 
+	iString->SetL(KNullDesC);
+	ReceiveDataL(*iString);
+	__FLOG(_L8("SetSessionInitiatorVersionInfoL - Exit"));
+	}
+
+
+/**
+This should be removed no set for percived device type.
+*/
+void CMTPSetDevicePropValue::CompletePerceivedDeviceTypeL()
+    {
+    __FLOG(_L8("CompletePerceivedDeviceType - Entry"));
+    SendResponseL(EMTPRespCodeAccessDenied);
+    __FLOG(_L8("CompletePerceivedDeviceType - Exit"));
+    }
+
+/**
+*Service the PerceivedDeviceType property.
+*it is not set type it should be removed 
+**/
+void CMTPSetDevicePropValue::ServicePerceivedDeviceTypeL()
+    {	 
+    __FLOG(_L8("ServicePerceivedDeviceType - Entry")); 	
+    ReceiveDataL(iUint32);
+    __FLOG(_L8("ServicePerceivedDeviceType - Exit"));
+    }
+
+/**
+Processes the Date Time property transaction response phase.
+*/
+void CMTPSetDevicePropValue::CompleteServiceDateTimeL()
+	{
+	__FLOG(_L8("CompleteDateTime - Entry"));
+	//validate the incoming date time string first and then set it.
+	if(KErrNone == iDpSingletons.DeviceDataStore().SetDateTimeL(iString->StringChars()) )
+		{
+		SendResponseL(EMTPRespCodeOK);
+		}
+	else
+		{
+		SendResponseL(EMTPRespCodeInvalidDataset);
+		}
+	
+	__FLOG(_L8("CompleteDateTime - Exit"));
+	}
+
+/**
+Service the Date Time property. 
+*/ 
+void CMTPSetDevicePropValue::ServiceDateTimeL()
+    {	 
+    __FLOG(_L8("ServiceDateTime - Entry")); 
+    iString->SetL(KNullDesC);
+    ReceiveDataL(*iString);
+    __FLOG(_L8("ServiceDateTime - Exit"));
+    }
+
+/*
+*Complete Service the Device Icon property and CompleteDeviceIcon.
+As of now implemented as device property of type get.
+*/
+void CMTPSetDevicePropValue::CompleteDeviceIconL()
+    {   	
+    __FLOG(_L8("CompleteDeviceIcon - Entry"));
+    //it is Get only device property
+    SendResponseL(EMTPRespCodeAccessDenied);
+    __FLOG(_L8("CompleteDeviceIcon - Exit"));
+    }
+
+/*
+*Service the Device Icon property and CompleteDeviceIcon.
+As of now implemented as device property of type get.
+*/   
+void CMTPSetDevicePropValue::ServiceDeviceIconL()
+    {    
+    __FLOG(_L8("ServiceDeviceIcon - Entry")); 	
+    //no need to recive this data beacuse it is Get property
+    ReceiveDataL(*iMtparray);
+    __FLOG(_L8("ServiceDeviceIcon - Exit"));
+    }
+       
+
+/*
+*Processes the PerceivedDeviceType property transaction response phase.
+*/
+void CMTPSetDevicePropValue::CompleteServiceSupportedFormatsOrderedL()
+    {
+    __FLOG(_L8("CompleteServiceSupportedFormatsOrdered - Entry"));
+    //it is Get only device property
+    SendResponseL(EMTPRespCodeAccessDenied);
+    __FLOG(_L8("CompleteServiceSupportedFormatsOrdered - Exit"));
+    }
+
+/*
+*ServiceSupportedFormatsOrdered property. it is get only type.
+*/
+void CMTPSetDevicePropValue::ServiceSupportedFormatsOrderedL()
+    {	 
+    __FLOG(_L8("ServiceSupportedFormatsOrdered - Entry")); 	
+    //no need to recive this data beacuse it is Get property
+    ReceiveDataL(iUint8);
+    __FLOG(_L8("ServicePerceivedDeviceType - Exit"));
+    }
+
+/*
+*Processes the FunctionalID property transaction response phase.
+*/
+void CMTPSetDevicePropValue::CompleteServiceFunctionalIDL()
+    {
+    __FLOG(_L8("CompleteServiceFunctionalIDL - Entry"));
+
+    TPtrC8 ptr(NULL,0);
+    if ( KMTPChunkSequenceCompletion == iData->FirstReadChunk(ptr) )
+   		{
+   		SaveGUID( MMTPFrameworkConfig::EDeviceCurrentFuncationalID, *iData );
+   		SendResponseL(EMTPRespCodeOK);
+    	}
+    
+    __FLOG(_L8("CompleteServiceFunctionalIDL - Exit"));
+    }
+
+/*
+*FunctionalID property. 
+*/
+void CMTPSetDevicePropValue::ServiceFunctionalIDL()
+    {	 
+    __FLOG(_L8("ServiceFunctionalIDL - Entry")); 	
+    ReceiveDataL(*iData);
+    __FLOG(_L8("ServiceFunctionalIDL - Exit"));
+    }
+
+/*
+*Processes the ModelID property transaction response phase.
+*/
+void CMTPSetDevicePropValue::CompleteServiceModelIDL()
+    {
+    __FLOG(_L8("CompleteServiceModelIDL - Entry"));
+    SendResponseL(EMTPRespCodeAccessDenied);
+    __FLOG(_L8("CompleteServiceModelIDL - Exit"));
+    }
+
+/*
+*ModelID property. 
+*/
+void CMTPSetDevicePropValue::ServiceModelIDL()
+    {	 
+    __FLOG(_L8("ServiceModelIDL - Entry")); 	
+    ReceiveDataL(*iData);
+    __FLOG(_L8("ServiceModelIDL - Exit"));
+    }
+
+/*
+*Processes the UseDeviceStage property transaction response phase.
+*/
+void CMTPSetDevicePropValue::CompleteServiceUseDeviceStageL()
+    {
+    __FLOG(_L8("CompleteServiceUseDeviceStageL - Entry"));
+    SendResponseL(EMTPRespCodeAccessDenied);
+    __FLOG(_L8("CompleteServiceUseDeviceStageL - Exit"));
+    }
+
+/*
+*UseDeviceStage property. 
+*/
+void CMTPSetDevicePropValue::ServiceUseDeviceStageL()
+    {	 
+    __FLOG(_L8("ServiceUseDeviceStageL - Entry")); 	
+    ReceiveDataL(iUint8);
+    __FLOG(_L8("ServiceUseDeviceStageL - Exit"));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpstoragewatcher.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,524 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtpdataproviderplugin.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mtpdataproviderapitypes.h>
+
+#include "cmtpdataprovider.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpframeworkconfig.h"
+#include "cmtpstoragemgr.h"
+#include "cmtpobjectmgr.h"
+#include "cmtpstoragewatcher.h"
+#include "rmtpdevicedpsingletons.h"
+#include "cmtpdevicedpconfigmgr.h"
+
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"StorageWatcher");)
+static const TBool KAllDrives(ETrue);
+static const TBool KAvailableDrives(EFalse);
+
+const TInt KFolderExclusionGranularity = 8;
+
+/**
+MTP system storage watcher factory method.
+@return A pointer to an MTP system storage watcher object. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+CMTPStorageWatcher* CMTPStorageWatcher::NewL(MMTPDataProviderFramework& aFramework)
+    {
+    CMTPStorageWatcher* self = new (ELeave) CMTPStorageWatcher(aFramework);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor.
+*/    
+CMTPStorageWatcher::~CMTPStorageWatcher()
+    {
+    __FLOG(_L8("~CMTPStorageWatcher - Entry"));
+    Cancel();
+    delete iFolderExclusionList;
+    iDpSingletons.Close();
+    iDrivesExcluded.Close();
+    iFrameworkSingletons.Close();
+    __FLOG(_L8("~CMTPStorageWatcher - Exit"));
+    __FLOG_CLOSE;
+    }
+    
+void CMTPStorageWatcher::EnumerateStoragesL()
+    {
+    __FLOG(_L8("EnumerateStoragesL - Entry"));
+
+    //Use Hash to replace it
+    AppendFolderExclusionListL();
+    
+    // Retrieve the drive exclusion list.
+    iFrameworkSingletons.FrameworkConfig().GetValueL(CMTPFrameworkConfig::EExcludedStorageDrives, iDrivesExcluded);
+    iDrivesExcluded.Sort();
+    
+    // Claim system storages ownership.
+    CMTPStorageMgr& mgr(iFrameworkSingletons.StorageMgr());
+    mgr.SetFrameworkId(iFramework.DataProviderId());
+    
+    /* 
+    Enumerate the initial drive set. 
+    
+        1.   Enumerate each known drive as a physical storage.
+    */
+    iDrivesConfig = DriveConfigurationL(KAllDrives);
+    CMTPStorageMetaData* storage = CMTPStorageMetaData::NewLC();
+    storage->SetUint(CMTPStorageMetaData::EStorageSystemType, CMTPStorageMetaData::ESystemTypeDefaultFileSystem);
+    _LIT(KSuidTemplate, "?:");
+    RBuf suid;
+    suid.CleanupClosePushL();
+    suid.Assign((KSuidTemplate().AllocL()));
+    
+    for (TInt drive(0); (drive < KMaxDrives); drive++)
+        {
+        const TUint32 mask(1 << drive);
+        if (iDrivesConfig & mask)
+            {
+            TChar driveChar;
+            User::LeaveIfError(iFramework.Fs().DriveToChar(drive, driveChar));
+            suid[0] = driveChar;
+            storage->SetDesCL(CMTPStorageMetaData::EStorageSuid, suid);
+                    
+            TUint32 id(mgr.AllocatePhysicalStorageIdL(iFramework.DataProviderId(), *storage));
+            mgr.SetDriveMappingL(static_cast<TDriveNumber>(drive), id);
+            }
+        }
+        
+    CleanupStack::PopAndDestroy(&suid);
+    CleanupStack::PopAndDestroy(storage);
+    
+    /* 
+        2.  If so configured, enumerate a single logical storage for each of 
+            the available drives.
+    */
+    if (iAllocateLogicalStorages)
+        {
+        iDrivesConfig = DriveConfigurationL(KAvailableDrives);
+
+        for (TInt drive(0); (drive < KMaxDrives); drive++)
+            {
+            const TUint32 mask(1 << drive);
+            if (iDrivesConfig & mask)
+                {
+                StorageAvailableL(static_cast<TDriveNumber>(drive));
+                }
+            }
+        }
+    
+    // Set the default storage.
+    TUint defaultDrive;
+    iFrameworkSingletons.FrameworkConfig().GetValueL(CMTPFrameworkConfig::EDefaultStorageDrive, defaultDrive);
+    
+    if ( defaultDrive <= EDriveZ )
+        {
+        // Default drive is specified by drive number.. retrieve from manager..
+        if (iAllocateLogicalStorages)
+            {
+            mgr.SetDefaultStorageId(mgr.FrameworkStorageId(static_cast<TDriveNumber>(defaultDrive)));
+            }
+        else
+            {
+            mgr.SetDefaultStorageId(mgr.PhysicalStorageId(static_cast<TDriveNumber>(defaultDrive)));
+            }
+        }
+    else
+       {
+       // Default drive is specified by storage number
+       mgr.SetDefaultStorageId(defaultDrive);
+       }
+       
+    __FLOG(_L8("EnumerateStoragesL - Exit"));
+    }
+
+/**
+Initiates storage change notice subscription.
+*/
+void CMTPStorageWatcher::Start()
+    {
+    __FLOG(_L8("Start - Entry"));
+    if (!(iState & EStarted))
+        {
+        __FLOG(_L8("Starting RFs notifier"));
+        TRequestStatus* status(&iStatus);
+        User::RequestComplete(status, KErrNone);
+        SetActive();
+        iState |= EStarted;
+        }
+    __FLOG(_L8("Start - Exit"));    
+    }
+    
+void CMTPStorageWatcher::DoCancel()
+    {
+    __FLOG(_L8("DoCancel - Entry"));
+    __FLOG(_L8("Stopping RFs notifier"));
+    iFrameworkSingletons.Fs().NotifyChangeCancel();
+    iState &= (!EStarted);
+    __FLOG(_L8("DoCancel - Exit"));
+    }
+
+/**
+Append all DPs folder exclusion list strings in Device DP
+ */
+void CMTPStorageWatcher::AppendFolderExclusionListL()
+    {
+    CDesCArraySeg* folderExclusionSets = new (ELeave) CDesCArraySeg(KFolderExclusionGranularity);
+    CleanupStack::PushL(folderExclusionSets);
+    CMTPDataProviderController& dps(iFrameworkSingletons.DpController());
+    TUint currentDpIndex = 0, count = dps.Count();
+    while (currentDpIndex < count)
+        {
+        CMTPDataProvider& dp(dps.DataProviderByIndexL(currentDpIndex));
+        if(KMTPImplementationUidDeviceDp != dp.ImplementationUid().iUid)
+            {
+            folderExclusionSets->Reset();
+            dp.Plugin().SupportedL(EFolderExclusionSets,*folderExclusionSets);
+            for(TInt i = 0; i < folderExclusionSets->Count(); ++i)
+                {
+                TPtrC16 excludedFolder = (*folderExclusionSets)[i];
+                iFolderExclusionList->AppendL(excludedFolder);
+                }
+            }
+        currentDpIndex++;
+        }
+    CleanupStack::PopAndDestroy(folderExclusionSets);
+    }
+
+/**
+Handles leaves occurring in RunL.
+@param aError leave error code
+@return KErrNone
+*/
+#ifdef __FLOG_ACTIVE
+TInt CMTPStorageWatcher::RunError(TInt aError)
+#else
+TInt CMTPStorageWatcher::RunError(TInt /*aError*/)
+#endif
+    {
+    __FLOG(_L8("RunError - Entry"));
+    __FLOG_VA((_L8("Error = %d"), aError));
+
+    // Ignore the error, meaning that the storages may not be accurately accounted for
+    RequestNotification();
+
+    __FLOG(_L8("RunError - Exit"));
+    return KErrNone;
+    }
+    
+void CMTPStorageWatcher::RunL()
+    {
+    __FLOG(_L8("RunL - Entry"));
+    const TUint32 previous(iDrivesConfig);
+    const TUint32 current(DriveConfigurationL(KAvailableDrives));
+    if (current != previous)
+        {        
+        const TUint32 changed(current ^ previous);
+        const TUint32 added(changed & current);
+        const TUint32 removed(changed & previous);
+        TInt i(KMaxDrives);
+        while (i--)
+            {
+            const TUint32 mask(1 << i);
+            if (added & mask)
+                {
+                StorageAvailableL(static_cast<TDriveNumber>(i));
+                }
+            else if (removed & mask)
+                {
+                StorageUnavailableL(static_cast<TDriveNumber>(i));
+                }
+            }
+        }
+    iDrivesConfig = current;
+    RequestNotification();
+    __FLOG(_L8("RunL - Exit"));
+    }
+    
+/**
+Constructor.
+@param aConnectionMgr The MTP connection manager interface.
+*/
+CMTPStorageWatcher::CMTPStorageWatcher(MMTPDataProviderFramework& aFramework) :
+    CActive(EPriorityStandard),
+    iFramework(aFramework)
+    {
+    CActiveScheduler::Add(this);
+    }
+    
+/**
+Second phase constructor.
+*/
+void CMTPStorageWatcher::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry"));
+    iFrameworkSingletons.OpenL();
+    iFrameworkSingletons.FrameworkConfig().GetValueL(CMTPFrameworkConfig::ELogicalStorageIdsAllocationEnable, iAllocateLogicalStorages);
+    
+    RMTPDeviceDpSingletons devSingletons;
+    devSingletons.OpenL(iFramework);
+    CleanupClosePushL(devSingletons);
+    
+    iDpSingletons.OpenL(iFramework);
+    iFolderExclusionList = devSingletons.ConfigMgr().GetArrayValueL(CMTPDeviceDpConfigMgr::EFolderExclusionList); 
+    CleanupStack::PopAndDestroy(&devSingletons);
+    __FLOG(_L8("ConstructL - Exit"));
+    }
+    
+TUint32 CMTPStorageWatcher::DriveConfigurationL(TBool aAllDrives) const
+    {
+    __FLOG(_L8("DriveConfigurationL - Entry"));
+    TUint32     config(0);
+    TDriveList  drives;
+    RFs&        fs(iFrameworkSingletons.Fs());
+    User::LeaveIfError(fs.DriveList(drives));
+    TInt i(KMaxDrives);
+    while (i--)
+        {        
+        __FLOG_VA((_L8("Drive number %d, available = 0x%02d"), i, drives [i]));
+        if ((drives[i]) &&
+            (!Excluded(static_cast<TDriveNumber>(i))))
+            {
+            TDriveInfo info;
+            User::LeaveIfError(fs.Drive(info, i));
+            if ((info.iType != EMediaNotPresent) || (aAllDrives))
+                {
+                TVolumeInfo volumeInfo;
+                if(KErrNone == fs.Volume(volumeInfo,i))
+                	{
+                	config |=  (1 << i);
+                	}
+                }
+            }
+        }
+    __FLOG_VA((_L8("Drives list = 0x%08X, AllDrives = %d"), config, aAllDrives));
+    __FLOG(_L8("DriveConfigurationL - Exit"));
+    return config;
+    }
+
+TBool CMTPStorageWatcher::Excluded(TDriveNumber aDriveNumber) const
+    {
+    __FLOG(_L8("Excluded - Entry"));
+    TBool ret(iDrivesExcluded.FindInOrder(aDriveNumber) != KErrNotFound);
+    __FLOG_VA((_L8("Drive = %d, excluded = %d"), aDriveNumber, ret));
+    __FLOG(_L8("Excluded - Exit"));
+    return ret;
+    }
+    
+void CMTPStorageWatcher::RequestNotification()
+    {
+    __FLOG(_L8("RequestNotification - Entry"));
+    _LIT(KPath, "?:\\..");
+    iFrameworkSingletons.Fs().NotifyChange(ENotifyEntry, iStatus, KPath);
+    SetActive();
+    __FLOG(_L8("RequestNotification - Exit"));
+    }
+ 
+void CMTPStorageWatcher::SendEventL(TUint16 aEvent, TUint32 aStorageId)
+    {
+    __FLOG(_L8("SendEventL - Entry"));
+    if (iState & EStarted)
+        {
+        __FLOG_VA((_L8("Sending event 0x%04X for StorageID 0x%08X"), aEvent, aStorageId));
+        iEvent.Reset();
+        iEvent.SetUint16(TMTPTypeEvent::EEventCode, aEvent);
+        iEvent.SetUint32(TMTPTypeEvent::EEventSessionID, KMTPSessionAll);
+        iEvent.SetUint32(TMTPTypeEvent::EEventTransactionID, KMTPTransactionIdNone);
+        iEvent.SetUint32(TMTPTypeEvent::EEventParameter1, aStorageId);
+        iFramework.SendEventL(iEvent);
+        }
+    __FLOG(_L8("SendEventL - Exit"));
+    }
+
+/**
+Configures the specified drive as an available MTP storage.
+@param aDriveNumber The Symbian OS file system drive number.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/    
+void CMTPStorageWatcher::StorageAvailableL(TDriveNumber aDriveNumber)
+    {
+    __FLOG(_L8("StorageAvailableL - Entry"));
+    __FLOG_VA((_L8("Drive = %d is available."), aDriveNumber));
+    CMTPStorageMgr& mgr(iFrameworkSingletons.StorageMgr());
+    TInt32 physical(mgr.PhysicalStorageId(aDriveNumber));
+    _LIT(KSuidTemplate, "?:");
+    // Generate the storage SUID as the drive root folder.
+    RBuf suid;
+    suid.CleanupClosePushL();
+    suid.Assign((KSuidTemplate().AllocL()));
+    TChar driveChar;
+    User::LeaveIfError(iFramework.Fs().DriveToChar(aDriveNumber, driveChar));
+    driveChar.LowerCase();
+    suid[0] = driveChar;
+    // Create the storage meta-data.
+    CMTPStorageMetaData* storage = CMTPStorageMetaData::NewLC();
+    storage->SetUint(CMTPStorageMetaData::EStorageSystemType, CMTPStorageMetaData::ESystemTypeDefaultFileSystem);
+    storage->SetDesCL(CMTPStorageMetaData::EStorageSuid, suid);
+    if(physical == KErrNotFound)
+    	{
+        TUint32 id(mgr.AllocatePhysicalStorageIdL(iFramework.DataProviderId(), *storage));
+        mgr.SetDriveMappingL(aDriveNumber, id);
+    	}
+    physical = mgr.PhysicalStorageId(aDriveNumber);
+
+    User::LeaveIfError(physical);
+    TUint32 logical(physical);
+
+    // If configured to do so, assign a logical storage ID mapping.
+    if (iAllocateLogicalStorages)
+        {
+        __FLOG(_L8("Assigning local storage ID mapping"));
+        
+        // Try to read from resource file to use a specified root dir path, if available.
+        RBuf rootDirPath;
+        rootDirPath.CreateL(KMaxFileName);
+        rootDirPath.CleanupClosePushL();
+        RMTPDeviceDpSingletons devSingletons;
+        devSingletons.OpenL(iFramework);
+        CleanupClosePushL(devSingletons);
+        TRAPD(resError, devSingletons.ConfigMgr().GetRootDirPathL(aDriveNumber, rootDirPath));
+        __FLOG_VA((_L8("ResError = %d"), resError));
+        if ((KErrNone == resError) && (0 < rootDirPath.Length()))
+            {
+            __FLOG(_L8("Reading resource file succeeded"));
+            // If there is a root directory information in rss file then check the directory exist or not. 
+            // If not exists, then create it. 
+            // Before doing anything, delete the leading and trailing white space.
+            rootDirPath.Trim();       
+            TBuf<KMaxFileName> buffer;
+            buffer.Append(driveChar);
+            _LIT(KSeperator,":");
+            buffer.Append(KSeperator);
+            buffer.Append(rootDirPath);
+            TInt error = iFramework.Fs().MkDir(buffer);
+            suid.Close();
+            _LIT(KSuidTemplate, "?:\\");
+            suid.Assign((KSuidTemplate().AllocL()));
+            driveChar.LowerCase();
+            suid[0] = driveChar;
+
+            if ((KErrNone == error) || (KErrAlreadyExists == error))
+                {
+                __FLOG(_L8("Overwriting SUID to specified root dir path from resource file"));  
+                //if dir already existed or created, make that as root directory
+                suid.ReAllocL(buffer.Length());
+                suid = buffer;
+                }
+            }
+        CleanupStack::PopAndDestroy(&devSingletons);
+        CleanupStack::PopAndDestroy(&rootDirPath);
+        
+        // Set up folder exclusion list
+        CDesCArraySeg* storageExclusions = new (ELeave) CDesCArraySeg(KFolderExclusionGranularity);
+        CleanupStack::PushL(storageExclusions);
+        TInt excludedFolderCount = iFolderExclusionList->Count();
+
+        for (TInt i = 0; i < excludedFolderCount; ++i)
+            {
+            TPtrC16 excludedFolder = (*iFolderExclusionList)[i];
+
+            if (excludedFolder[0] == '?' ||
+                excludedFolder[0] == '*' ||
+                excludedFolder[0] == suid[0])
+                {
+                storageExclusions->AppendL(excludedFolder);
+                }
+            }
+        for ( TInt i=0; i<storageExclusions->Count();++i)
+            {
+            HBufC16* temp = static_cast<TPtrC16>((*storageExclusions)[i]).AllocL();
+            TPtr16 tempptr(temp->Des());
+            tempptr[0] = suid[0];
+            storage->SetHashPath(tempptr,i);
+            delete temp;
+            }
+        
+        storage->SetDesCL(CMTPStorageMetaData::EStorageSuid, suid);
+        storage->SetDesCArrayL(CMTPStorageMetaData::EExcludedAreas, *storageExclusions);
+        CleanupStack::PopAndDestroy(storageExclusions);
+
+        // Create the logical StorageID and drive mapping.
+        logical = mgr.AllocateLogicalStorageIdL(iFramework.DataProviderId(), physical, *storage);
+        mgr.SetDriveMappingL(aDriveNumber, logical);
+
+        __FLOG_VA((_L8("Drive = %d mapped as storage 0x%08X"), aDriveNumber, logical));
+        }
+
+    CleanupStack::PopAndDestroy(storage);
+    CleanupStack::PopAndDestroy(&suid);
+    
+    // Notify the active data providers.
+    if (iState & EStarted)
+        {
+        TMTPNotificationParamsStorageChange params = {physical};
+        iFrameworkSingletons.DpController().NotifyDataProvidersL(EMTPStorageAdded, static_cast<TAny*>(&params));
+        }
+
+    // Notify any connected Initiator(s).
+    if (iAllocateLogicalStorages)
+        {
+        SendEventL(EMTPEventCodeStoreAdded, logical);
+        }
+        
+    __FLOG(_L8("StorageAvailableL - Exit"));
+    }
+
+/**
+Configures the specified drive as an unavailable MTP storage.
+@param aDriveNumber The Symbian OS file system drive number.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/    
+void CMTPStorageWatcher::StorageUnavailableL(TDriveNumber aDriveNumber)
+{
+    __FLOG(_L8("StorageUnavailableL - Entry"));
+    __FLOG_VA((_L8("Drive = %d is unavailable."), aDriveNumber));
+    CMTPStorageMgr& mgr(iFrameworkSingletons.StorageMgr());
+    TInt32 physical(mgr.PhysicalStorageId(aDriveNumber));
+    User::LeaveIfError(physical);
+    TUint32 logical(0);
+    
+    // If configured to do so, assign a logical storage ID mapping.
+    if (iAllocateLogicalStorages)
+        {
+        logical = mgr.FrameworkStorageId(aDriveNumber);
+
+        // Deassign the logical storage ID mapping.
+        mgr.DeallocateLogicalStorageIds(iFramework.DataProviderId(), physical);
+        mgr.SetDriveMappingL(aDriveNumber, physical);
+        __FLOG_VA((_L8("Drive = %d unmapped as storage 0x%08X"), aDriveNumber, logical));
+        }
+
+    // Notify the active data providers.
+    TMTPNotificationParamsStorageChange params = {physical};
+    iFrameworkSingletons.DpController().NotifyDataProvidersL(EMTPStorageRemoved, static_cast<TAny*>(&params));
+
+    // Notify any connected Initiator(s).
+    if (iAllocateLogicalStorages)
+        {
+        SendEventL(EMTPEventCodeStoreRemoved, logical);
+        }   
+    __FLOG(_L8("StorageUnavailableL - Exit"));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtptypedeviceinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,180 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mtptypescomplex.h>
+
+#include "cmtptypedeviceinfo.h"
+
+// Dataset constants
+const TUint KMTPChunk0Size = 8;
+
+// Dataset element metadata.
+const CMTPTypeCompoundBase::TElementInfo CMTPTypeDeviceInfo::iElementMetaData[CMTPTypeDeviceInfo::ENumElements] = 
+    {
+        {EIdFlatChunk,                      EMTPTypeFlat,   {EMTPTypeUINT16,    0,                  KMTPTypeUINT16Size}},   // EStandardVersion
+        {EIdFlatChunk,                      EMTPTypeFlat,   {EMTPTypeUINT32,    2,                  KMTPTypeUINT32Size}},   // EMTPVendorExtensionID
+        {EIdFlatChunk,                      EMTPTypeFlat,   {EMTPTypeUINT16,    6,                  KMTPTypeUINT16Size}},   // EMTPVersion
+        {EIdMTPExtensionsChunk,             EMTPTypeString, {EMTPTypeString,    KMTPNotApplicable,  KMTPNotApplicable}},    // EMTPExtensions
+        {EIdFunctionalModeChunk,            EMTPTypeUINT16, {EMTPTypeUINT16,    KMTPNotApplicable,  KMTPNotApplicable}},    // EFunctionalMode
+        {EIdOperationsSupportedChunk,       EMTPTypeArray,  {EMTPTypeAUINT16,   KMTPNotApplicable,  KMTPNotApplicable}},    // EOperationsSupported
+        {EIdEventsSupportedChunk,           EMTPTypeArray,  {EMTPTypeAUINT16,   KMTPNotApplicable,  KMTPNotApplicable}},    // EventsSupported
+        {EIdDevicePropertiesSupportedChunk, EMTPTypeArray,  {EMTPTypeAUINT16,   KMTPNotApplicable,  KMTPNotApplicable}},    // EDevicePropertiesSupported
+        {EIdCaptureFormatsChunk,            EMTPTypeArray,  {EMTPTypeAUINT16,   KMTPNotApplicable,  KMTPNotApplicable}},    // ECaptureFormats
+        {EIdPlaybackFormatsChunk,           EMTPTypeArray,  {EMTPTypeAUINT16,   KMTPNotApplicable,  KMTPNotApplicable}},    // EPlaybackFormats
+        {EIdManufacturerChunk,              EMTPTypeString, {EMTPTypeString,    KMTPNotApplicable,  KMTPNotApplicable}},    // EManufacturer
+        {EIdModelChunk,                     EMTPTypeString, {EMTPTypeString,    KMTPNotApplicable,  KMTPNotApplicable}},    // EModel  
+        {EIdDeviceVersionChunk,             EMTPTypeString, {EMTPTypeString,    KMTPNotApplicable,  KMTPNotApplicable}},    // EDeviceVersion
+        {EIdSerialNumberChunk,              EMTPTypeString, {EMTPTypeString,    KMTPNotApplicable,  KMTPNotApplicable}},    // ESerialNumber
+    };
+
+/**
+MTP DeviceInfo dataset factory method. This method is used to create an empty 
+MTP DeviceInfo dataset type. A pointer to the MTP array data type is placed on 
+the cleanup stack.
+@return A pointer to an empty MTP DeviceInfo dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/    
+CMTPTypeDeviceInfo* CMTPTypeDeviceInfo::NewL()
+    {
+	CMTPTypeDeviceInfo* self = CMTPTypeDeviceInfo::NewLC(); 
+	CleanupStack::Pop(self);
+	return self; 
+    }
+
+/**
+MTP DeviceInfo dataset factory method. This method is used to create an empty 
+MTP DeviceInfo dataset type.
+@return A pointer to an empty MTP DeviceInfo dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/    
+CMTPTypeDeviceInfo* CMTPTypeDeviceInfo::NewLC()
+    {
+	CMTPTypeDeviceInfo* self = new (ELeave) CMTPTypeDeviceInfo(); 
+	CleanupStack::PushL(self); 
+    self->ConstructL();
+	return self;    
+    }
+
+/**
+Destructor.
+*/    
+CMTPTypeDeviceInfo::~CMTPTypeDeviceInfo()
+    {    
+    iChunkFlat.Close();
+    iArrayChunks.ResetAndDestroy();
+    iStringChunks.ResetAndDestroy();
+    }
+ 
+TUint CMTPTypeDeviceInfo::Type() const
+    {
+    return EMTPTypeDeviceInfoDataset;
+    }
+    
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeDeviceInfo::ElementInfo(TInt aElementId) const
+    {
+    return iElementInfo[aElementId];
+    }
+
+CMTPTypeDeviceInfo::CMTPTypeDeviceInfo() : 
+    CMTPTypeCompoundBase((!KJustInTimeConstruction), EIdNumChunks), 
+    iElementInfo(iElementMetaData, ENumElements),
+    iChunkFlat(KMTPChunk0Size, *this)
+    {
+    
+    }
+    
+void CMTPTypeDeviceInfo::ConstructL()
+    {
+    for (TUint i(0); (i < ENumElements); i++)
+        {
+        const TElementInfo& info(iElementInfo[i]);
+        if (ChunkCount() <= info.iChunkId)
+            {
+            MMTPType* chunk(NULL);
+            
+            switch (info.iType)
+                {
+            case EMTPTypeArray:
+                chunk = NewArrayChunkL(info);
+                break;
+                
+            case EMTPTypeFlat:
+                chunk = NewFlatChunkL(info);
+                break;
+                
+            case EMTPTypeString:
+                chunk = NewStringChunkL(info);
+                break;
+                
+            case EMTPTypeUINT16:
+                chunk = NewUInt16Chunk(info);
+                break;
+                
+            default:
+                break;
+                }
+                
+            __ASSERT_DEBUG(chunk, User::Invariant());
+            ChunkAppendL(*chunk);
+            }
+        }
+    }
+
+MMTPType* CMTPTypeDeviceInfo::NewArrayChunkL(const TElementInfo& aElementInfo)
+    {
+    CMTPTypeArray* chunk(NULL);
+    if (aElementInfo.iFlatChunkInfo.iType)
+        {
+        chunk = CMTPTypeArray::NewLC(EMTPTypeAUINT16);
+        }
+    __ASSERT_DEBUG(chunk, User::Invariant());
+    iArrayChunks.AppendL(chunk);
+    CleanupStack::Pop(chunk);
+    return chunk;
+    }
+
+MMTPType* CMTPTypeDeviceInfo::NewFlatChunkL(const TElementInfo& aElementInfo)
+    {
+    MMTPType* chunk(NULL);
+    if (aElementInfo.iChunkId == EIdFlatChunk)
+        {
+        iChunkFlat.OpenL();
+        chunk = &iChunkFlat;
+        }
+    __ASSERT_DEBUG(chunk, User::Invariant());
+    return chunk;
+    }
+
+MMTPType* CMTPTypeDeviceInfo::NewStringChunkL(const TElementInfo& /*aElementInfo*/)
+    {
+    CMTPTypeString* chunk(CMTPTypeString::NewLC());
+    iStringChunks.AppendL(chunk);
+    CleanupStack::Pop(chunk);
+    return chunk;
+    }
+
+MMTPType* CMTPTypeDeviceInfo::NewUInt16Chunk(const TElementInfo& aElementInfo)
+    {
+    MMTPType* chunk(NULL);
+    if (aElementInfo.iChunkId == EIdFunctionalModeChunk)
+        {
+        chunk = &iChunkFunctionalMode;
+        }
+    __ASSERT_DEBUG(chunk, User::Invariant());
+    return chunk; 
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/mtpdevicedp.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,40 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <ecom/registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theInfo
+    {
+    dll_uid = 0x102827A4;
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            interface_uid = 0x102827AD;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x102827AF;
+                    version_no = 1;
+                    display_name = "MTP Device Data Provider plug-in.";
+                    default_data = "";
+                    opaque_data = "";
+                    }
+                };
+            }
+        };
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/mtpdevicedp_config.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,284 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Device dp specific configuration data
+// 
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdataproviderconfig.rh>
+#include <mtp/mtpdevicedp_config.rh>
+
+RESOURCE MTP_DATA_PROVIDER dpConfig
+    {
+    type = KMTPDataProviderTypeECOM;
+    major_version = 1;
+    object_enumeration_persistent = 0;
+    supported_modes = KMTPModeMTP;  
+    server_name = "";
+    server_image_name = "";
+    opaque_resource = folderConfig;
+    }
+
+
+RESOURCE MTP_DEVICEDP_CONFIG folderConfig
+	{
+	enumeration_iteration_length = 32;
+	folder_exclusion_list = 
+		{
+		"?:\\private",
+		"?:\\resource",
+		"?:\\sys",
+		"?:\\system",
+		"?:\\logs",
+		"z:\\"
+		};
+	}
+	
+
+/**
+ * Incase if needed to provide a user friendly volume name. 
+ * Update the drive number and provide the name that you wish to have. 
+ * Drive number varies from 0 to 25, '0' represent 
+ * A drive and '25' represent Z drive.
+ *
+ */
+RESOURCE DRIVEARRAY drives
+	{
+
+	elements = 
+		{
+		DRIVE
+		    {
+		    driveNo = 0;
+		    driveName = "A Drive";
+		    rootDirPath = "\\";
+		    },
+
+		DRIVE
+		    {
+		    driveNo = 1;
+		    driveName = "B Drive";
+		    rootDirPath = "\\";
+		    },
+		    
+		DRIVE
+		    {
+		    driveNo = 2;
+		    driveName = "Phone Memory";
+		    rootDirPath = "\\Data\\";
+		    },
+		    
+		DRIVE
+		    {
+		    driveNo = 3;
+		    driveName = "D Drive";
+		    rootDirPath = "\\";
+		    },		
+
+		DRIVE
+		    {
+		    driveNo = 4;
+		    driveName = "Mass Memory";
+		    rootDirPath = "\\";
+		    },		    
+
+		DRIVE
+		    {
+		    driveNo = 5;
+		    driveName = "Memory Card";
+		    rootDirPath = "\\";
+		    },
+
+		DRIVE
+		    {
+		    driveNo = 6;
+		    driveName = "G Drive";
+		    rootDirPath = "\\";
+		    },
+
+		DRIVE
+		    {
+		    driveNo = 7;
+		    driveName = "H Drive";
+		    rootDirPath = "\\";
+		    },
+
+		DRIVE
+		   {
+		    driveNo = 8;
+		    driveName = "I Drive";
+		    rootDirPath = "\\";
+		    },
+
+		DRIVE
+		   {
+		    driveNo = 9;
+		    driveName = "J Drive";
+		    rootDirPath = "\\ ";		    
+		    },
+		    
+		DRIVE
+		   {
+		    driveNo = 10;
+		    driveName = "K Drive";
+		    rootDirPath = "\\";		    
+		    },
+
+		DRIVE
+		    {
+		    driveNo = 11;
+		    driveName = "L Drive";
+		    rootDirPath = "\\";
+		    },
+
+		DRIVE
+		    {
+		    driveNo = 12;
+		    driveName = "M Drive";
+		    rootDirPath = "\\";
+		    },
+
+		DRIVE
+		    {
+		    driveNo = 13;
+		    driveName = "N Drive";
+		    rootDirPath = "\\";
+		    },
+
+		DRIVE
+		    {
+		    driveNo = 14;
+		    driveName = "O Drive";
+		    rootDirPath = "\\";
+		    },
+
+		DRIVE
+		    {
+		    driveNo = 15;
+		    driveName = "P Drive";
+		    rootDirPath = "\\";
+		    },
+
+		DRIVE
+		    {
+		    driveNo = 16;
+		    driveName = "Q Drive";
+		    rootDirPath = "\\";
+		    },
+
+		DRIVE
+		    {
+		    driveNo = 17;
+		    driveName = "R Drive";
+		    rootDirPath = "\\";
+		    },
+
+		DRIVE
+		    {
+		    driveNo = 18;
+		    driveName = "S Drive";
+		    rootDirPath = "\\";
+		    },
+
+		DRIVE
+		    {
+		    driveNo = 19;
+		    driveName = "T Drive";
+		    rootDirPath = "\\";
+		    },
+
+		DRIVE
+		    {
+		    driveNo = 20;
+		    driveName = "U Drive";
+		    rootDirPath = "\\";
+		    },
+
+		DRIVE
+		    {
+		    driveNo = 21;
+		    driveName = "V Drive";
+		    rootDirPath = "\\";
+		    },
+
+		DRIVE
+		    {
+		    driveNo = 22;
+		    driveName = "W Drive";
+		    rootDirPath = "\\";
+		    },
+
+		DRIVE
+		   {
+		    driveNo = 23;
+		    driveName = "X Drive";
+		    rootDirPath = "\\";		    
+		    },
+
+		DRIVE
+		    {
+		    driveNo = 24;
+		    driveName = "Y Drive";
+		    rootDirPath = "\\";
+		    },
+		    
+		DRIVE
+		   {
+		    driveNo = 25;
+		    driveName = "Z Drive";
+		    rootDirPath = "\\";		    
+		    } 
+
+		};
+		
+	}
+
+/**
+ *This resource used to create supported format ordered.
+ */ 
+RESOURCE FORMATSARRAY formats
+	{
+	//put the required format code in "" to enable format ordered property
+	objFormats = 
+        {
+        "3000", // Undefined
+        "3001", // Association
+        "B982", // MP4
+        "B984", // 3GP
+        "B903", // AAC
+        "3009", // MP3
+        "B901", // WMA
+        "3008", // WAV
+        "B981", // WMV
+        "300C", // ASF
+        "BA05", // PLA
+        "BA11", // M3U
+        "BA10" // WPL
+        };
+	}
+
+/**
+ * This resource used to load the extension dps for Dev DP.
+ */ 
+RESOURCE PLUGINUIDARRAY extnpluginuids
+	{
+	//Put the extension plugin implementation UID in "" to load particular exn plugin
+	// if more than one plugin is needed then seperate then by ',' eg:- "20010ADB" ,"20010ADC"
+	uid_list = {"20022E92"}; //20022E92, WMPDRM dll id
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/mtpdevicedpimplementations.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,35 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "cmtpdevicedp.h"
+#include <ecom/implementationproxy.h>
+
+// Define the interface UIDs
+static const TImplementationProxy ImplementationTable[] =
+    {
+        {
+        {0x102827AF}, (TProxyNewLPtr)(CMTPDeviceDataProvider::NewL)
+        }
+    };
+
+/**
+ECOM plugin entry point
+*/
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/mtpdevicedpprocessor.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,127 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <mtp/tmtptyperequest.h>
+
+#include "mtpdevicedpprocessor.h"
+#include "cmtprequestprocessor.h"
+#include "cmtpgetdeviceinfo.h"
+#include "cmtpopensession.h"
+#include "cmtpclosesession.h"
+#include "cmtpgetstorageids.h"
+#include "cmtpgetstorageinfo.h"
+#include "cmtpgetnumobjects.h"
+#include "cmtpgetobjecthandles.h"
+#include "cmtpresetdevice.h"
+#include "cmtpgetdevicepropdesc.h"
+#include "cmtpgetdevicepropvalue.h"
+#include "cmtpsetdevicepropvalue.h"
+#include "cmtpdevrequestunknown.h"
+
+#include "cmtpcopyobject.h"
+#include "cmtpmoveobject.h"
+#include "cmtpdeleteobject.h"
+#include "cmtpgetobject.h"
+#include "cmtpgetobjectinfo.h"
+#include "cmtpgetobjectpropdesc.h"
+#include "cmtpgetobjectproplist.h"
+#include "cmtpgetobjectpropssupported.h"
+#include "cmtpgetobjectpropvalue.h"
+#include "cmtpgetreferences.h"
+#include "cmtpsendobjectinfo.h"
+#include "cmtpsetobjectproplist.h"
+#include "cmtpsetobjectpropvalue.h"
+#include "cmtpresetdevicepropvalue.h"
+#include "cmtpsetreferences.h"
+#include "cmtpresetdevicepropvalue.h"
+#include "cmtpgetinterdependentpropdesc.h"
+#include "cmtpgetserviceids.h"
+#include "cmtpgetserviceinfo.h"
+#include "cmtpgetformatcapabilities.h"
+/**
+device data provider mapping table from request ID to factory method of the request processor
+*/
+static const TMTPRequestProcessorEntry KMTPRequestProcessorTable[] = 
+	{
+		{EMTPOpCodeGetDeviceInfo, CMTPGetDeviceInfo::NewL},
+		{EMTPOpCodeOpenSession, CMTPOpenSession::NewL},
+		{EMTPOpCodeCloseSession, CMTPCloseSession::NewL},
+		{EMTPOpCodeGetStorageIDs, CMTPGetStorageIds::NewL},
+		{EMTPOpCodeGetStorageInfo, CMTPGetStorageInfo::NewL},
+		{EMTPOpCodeGetNumObjects, CMTPGetNumObjects::NewL},
+		{EMTPOpCodeGetObjectHandles, CMTPGetObjectHandles::NewL},
+		{EMTPOpCodeResetDevice, CMTPResetDevice::NewL},
+		{EMTPOpCodeGetDevicePropDesc, CMTPGetDevicePropDesc::NewL},
+		{EMTPOpCodeGetDevicePropValue, CMTPGetDevicePropValue::NewL},
+		{EMTPOpCodeSetDevicePropValue, CMTPSetDevicePropValue::NewL},
+		{EMTPOpCodeMoveObject, CMTPMoveObject::NewL},
+		{EMTPOpCodeCopyObject, CMTPCopyObject::NewL},
+		{EMTPOpCodeDeleteObject, CMTPDeleteObject::NewL},
+		{EMTPOpCodeGetObject, CMTPGetObject::NewL},
+		{EMTPOpCodeGetObjectInfo, CMTPGetObjectInfo::NewL},
+		{EMTPOpCodeGetObjectPropDesc, CMTPGetObjectPropDesc::NewL},
+		{EMTPOpCodeGetObjectPropList, CMTPGetObjectPropList::NewL},
+		{EMTPOpCodeGetObjectPropsSupported, CMTPGetObjectPropsSupported::NewL},
+		{EMTPOpCodeGetObjectPropValue, CMTPGetObjectPropValue::NewL},
+		{EMTPOpCodeGetObjectReferences, CMTPGetReferences::NewL},
+		{EMTPOpCodeGetInterdependentPropDesc, CMTPGetInterDependentPropDesc::NewL},
+		{EMTPOpCodeSendObject, CMTPSendObjectInfo::NewL},
+		{EMTPOpCodeSendObjectInfo, CMTPSendObjectInfo::NewL},
+		{EMTPOpCodeSendObjectPropList, CMTPSendObjectInfo::NewL},
+		{EMTPOpCodeSetObjectPropList, CMTPSetObjectPropList::NewL},
+		{EMTPOpCodeSetObjectPropValue, CMTPSetObjectPropValue::NewL},
+		{EMTPOpCodeSetObjectReferences, CMTPSetReferences::NewL},
+		{EMTPOpCodeResetDevicePropValue, CMTPResetDevicePropValue::NewL},
+		{EMTPOpCodeGetServiceIDs, CMTPGetServiceIds::NewL},
+		{EMTPOpCodeGetServiceInfo, CMTPGetServiceInfo::NewL},
+		{EMTPOpCodeGetFormatCapabilities,CMTPGetFormatCapabilities::NewL}
+	};
+
+/**
+Create a request processor that matches the request
+@param aPlugin	The reference to the data provider plugin 
+@param aFramework The reference to the data provider framework
+@param aRequest	The request to be processed
+@param aConnection The connection from which the request comes from
+@return a pointer to the request processor
+*/	
+MMTPRequestProcessor* MTPDeviceDpProcessor::CreateL(
+													MMTPDataProviderFramework& aFramework,
+													const TMTPTypeRequest& aRequest, 
+													MMTPConnection& aConnection)
+	{
+	TMTPRequestProcessorCreateFunc createFunc = NULL; 
+	TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
+	TInt count = sizeof(KMTPRequestProcessorTable) / sizeof(TMTPRequestProcessorEntry);
+	for(TInt i = 0; i < count; i++)
+		{
+		if(KMTPRequestProcessorTable[i].iOperationCode == operationCode)
+			{
+			createFunc = KMTPRequestProcessorTable[i].iCreateFunc;
+			break;
+			}
+		}
+
+	if(!createFunc)	
+		{
+		createFunc = CMTPDevRequestUnknown::NewL;
+		}
+				
+	return (*createFunc)(aFramework, aConnection);
+	}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/rmtpdevicedpsingletons.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,156 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <e32std.h>
+#include "cmtpdevicedatastore.h"
+#include "cmtpdevicedpconfigmgr.h"
+#include "cmtpstoragewatcher.h"
+#include "rmtpdevicedpsingletons.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"DeviceDpSingletons");)
+
+/**
+Constructor.
+*/
+RMTPDeviceDpSingletons::RMTPDeviceDpSingletons() :
+    iSingletons(NULL)
+    {
+    
+    }
+
+/**
+Opens the singletons reference.
+*/
+void RMTPDeviceDpSingletons::OpenL(MMTPDataProviderFramework& aFramework)
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("OpenL - Entry"));
+    iSingletons = &CSingletons::OpenL(aFramework);
+    __FLOG(_L8("OpenL - Exit"));
+    }
+    
+/**
+Closes the singletons reference.
+*/
+void RMTPDeviceDpSingletons::Close()
+    {
+    __FLOG(_L8("Close - Entry"));
+    if (iSingletons)
+        {
+        iSingletons->Close();
+        iSingletons = NULL;
+        }
+    __FLOG(_L8("Close - Exit"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Provides a handle to the MTP device data provider's device information data 
+store singleton.
+@return The device information data store singleton.
+*/
+CMTPDeviceDataStore& RMTPDeviceDpSingletons::DeviceDataStore()
+    {
+    __FLOG(_L8("DeviceDataStore - Entry"));
+    __ASSERT_DEBUG(iSingletons, User::Invariant());
+    __ASSERT_DEBUG(iSingletons->iDeviceDataStore, User::Invariant());
+    __FLOG(_L8("DeviceDataStore - Exit"));
+    return *iSingletons->iDeviceDataStore;
+    }
+
+/**
+Provides a handle to the MTP device data provider's config manager singleton.
+@return The device config manager singleton.
+*/
+    
+CMTPDeviceDpConfigMgr& RMTPDeviceDpSingletons::ConfigMgr()
+	{
+    __FLOG(_L8("ConfigMgr - Entry"));
+    __ASSERT_DEBUG(iSingletons, User::Invariant());
+    __ASSERT_DEBUG(iSingletons->iConfigMgr, User::Invariant());
+    __FLOG(_L8("ConfigMgr - Exit"));
+    return *iSingletons->iConfigMgr;
+	}
+
+RMTPDeviceDpSingletons::CSingletons* RMTPDeviceDpSingletons::CSingletons::NewL(MMTPDataProviderFramework& aFramework)
+    {
+    CSingletons* self(new(ELeave) CSingletons());
+    CleanupStack::PushL(self);
+    self->ConstructL(aFramework);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+RMTPDeviceDpSingletons::CSingletons& RMTPDeviceDpSingletons::CSingletons::OpenL(MMTPDataProviderFramework& aFramework)
+    {
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("CSingletons::OpenL - Entry"));
+    CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
+    if (!self)
+        {
+        self = CSingletons::NewL(aFramework);
+        Dll::SetTls(reinterpret_cast<TAny*>(self));
+        }
+    else
+        {        
+        self->Inc();
+        }
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("CSingletons::OpenL - Exit"));
+    return *self;
+    }
+    
+void RMTPDeviceDpSingletons::CSingletons::Close()
+    {
+    CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
+    if (self)
+        {
+        __FLOG(_L8("CSingletons::Close - Entry"));
+        self->Dec();
+        if (self->AccessCount() == 0)
+            {
+            __FLOG(_L8("CSingletons::Close - Exit"));
+            delete self;
+            Dll::SetTls(NULL);
+            }
+        else
+            {
+            __FLOG(_L8("CSingletons::Close - Exit"));
+            }
+        }
+    }
+    
+RMTPDeviceDpSingletons::CSingletons::~CSingletons()
+    {
+    __FLOG(_L8("CSingletons::~CSingletons - Entry"));
+    delete iConfigMgr;
+    delete iDeviceDataStore;
+    __FLOG(_L8("CSingletons::~CSingletons - Exit"));
+    __FLOG_CLOSE;
+    }
+    
+void RMTPDeviceDpSingletons::CSingletons::ConstructL(MMTPDataProviderFramework& aFramework)
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("CSingletons::ConstructL - Entry"));
+    iDeviceDataStore = CMTPDeviceDataStore::NewL();
+    iConfigMgr = CMTPDeviceDpConfigMgr::NewL(aFramework);
+    __FLOG(_L8("CSingletons::ConstructL - Exit"));
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,29 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// MTP Data Provier Utility Component
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES 
+mtpdataproviderutility.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/group/mtpdataproviderutility.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,95 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+ 
+#include <comms-infras/commsdebugutility.mmh> 
+TARGET              mtpdataproviderutility.dll
+TARGETTYPE          DLL
+UID                 0x1000008D 0x10282FC9
+VENDORID             0x70000001
+
+CAPABILITY          CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+USERINCLUDE         ../inc 
+USERINCLUDE         ../../../common/inc
+USERINCLUDE         ../../../inc
+USERINCLUDE         ../../../transports/transportapi/inc
+
+SOURCEPATH          ../src
+SOURCE              cmtpcopyobject.cpp
+SOURCE              cmtpmoveobject.cpp
+SOURCE              cmtpdeleteobject.cpp
+SOURCE              cmtpfsenumerator.cpp
+SOURCE              cmtpfsexclusionmgr.cpp
+SOURCE              cmtpgetobject.cpp
+SOURCE              cmtpgetobjectinfo.cpp
+SOURCE              cmtpgetobjectpropdesc.cpp
+SOURCE              cmtpgetobjectproplist.cpp
+SOURCE              cmtpgetobjectpropssupported.cpp
+SOURCE              cmtpgetobjectpropvalue.cpp
+SOURCE              cmtpgetreferences.cpp
+SOURCE              cmtpgetinterdependentpropdesc.cpp
+SOURCE              cmtprequestchecker.cpp
+SOURCE              cmtprequestprocessor.cpp
+SOURCE              cmtprequestunknown.cpp
+SOURCE              cmtpsendobjectinfo.cpp
+SOURCE              cmtpsetobjectproplist.cpp
+SOURCE              cmtpsetobjectpropvalue.cpp
+SOURCE              cmtpsetreferences.cpp
+SOURCE				rmtputility.cpp
+SOURCE				cmtpextensionmapping.cpp
+SOURCE              rmtpdpsingletons.cpp
+SOURCE              cmtpgetformatcapabilities.cpp
+SOURCE              cmtpsvcgetreferences.cpp
+SOURCE              cmtpsvcsetreferences.cpp
+SOURCE              cmtpsvccompoundprocessor.cpp
+SOURCE              cmtpsvcdeleteobject.cpp
+SOURCE              cmtpsvcdeleteobjectproplist.cpp
+SOURCE              cmtpsvcdeleteserviceproplist.cpp
+SOURCE              cmtpsvcgetobject.cpp
+SOURCE              cmtpsvcgetobjectinfo.cpp
+SOURCE              cmtpsvcgetobjectproplist.cpp
+SOURCE              cmtpsvcgetservicecapabilities.cpp
+SOURCE              cmtpsvcgetserviceinfo.cpp
+SOURCE              cmtpsvcgetservicepropdesc.cpp
+SOURCE              cmtpsvcgetserviceproplist.cpp
+SOURCE              cmtpsvcgetstorageinfo.cpp
+SOURCE              cmtpsvcsetobjectproplist.cpp
+SOURCE              cmtpsvcsetserviceproplist.cpp
+SOURCE              cmtpknowledgehandler.cpp
+SOURCE              mmtpsvcobjecthandler.cpp
+SOURCE              mmtpservicedataprovider.cpp
+SOURCE              cmtpabstractdatacodemgr.cpp 
+SOURCE              mmtpservicehandler.cpp
+SOURCE              cmtpfullenumservicehandler.cpp
+SOURCE              cmtpcommonrequestprocessor.cpp
+SOURCE              cmtpgetpartialobject.cpp
+SOURCE			cmtpsetobjectprotection.cpp
+
+LIBRARY             euser.lib
+LIBRARY             bafl.lib
+LIBRARY             edbms.lib
+LIBRARY             efsrv.lib
+LIBRARY             estor.lib
+LIBRARY             caf.lib
+LIBRARY             centralrepository.lib
+
+
+LIBRARY             mtpdataproviderapi.lib
+LIBRARY             mtpdatatypes.lib
+LIBRARY				mtpframework.lib
+
+SMPSAFE
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpabstractdatacodemgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,119 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpabstractdatacodemgr.h
+// Abstract service provider's data code manager
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __CMTPABSTRACTDATACODEMGR_H__
+#define __CMTPABSTRACTDATACODEMGR_H__
+
+#include <mtp/mtpdataproviderapitypes.h>
+#include <mtp/tmtptypeguid.h>
+
+#include "mtpdebug.h"
+#include "mtpsvcdpconst.h"
+
+class MMTPDataProviderFramework;
+
+/**
+Keep service prop info, used by service related operation
+@internalComponent
+*/
+class TMTPServicePropertyInfo
+	{
+public:
+	TUint16 iIndex;             // The enum index value of Service Property definition
+	TUint16 iServicePropCode;   // The Property Code, allocated by framework
+	TMTPTypeGuid iServicePropPKeyNamespace;  // The GUID of the NameSpace this property belongs to. Specified by Spec.
+	TUint32 iServicePropPKeyID; // The PKeyID, the index in the NameSpace. Specified by Spec.
+	TPtrC iServicePropertyName; // The Property Name
+
+public:
+	static IMPORT_C TInt LinearOrderServicePropOrder(const TMTPServicePropertyInfo& aLhs, const TMTPServicePropertyInfo& aRhs);
+	static IMPORT_C TInt LinearOrderServicePropOrder(const TUint16* aServicePropCode, const TMTPServicePropertyInfo& aObject);
+	};
+
+/**
+Keep format related info and all object properties belong to the format
+@internalComponent
+*/
+class RMTPServiceFormat
+	{
+public:
+	IMPORT_C ~RMTPServiceFormat();
+
+	TUint16 iIndex;                 // The enum index value of Service Format definition
+	TUint16 iFormatCode;            // The Format Code, allocated by framework
+	TMTPTypeGuid iFormatGUID;    // The Format GUID, specified by Spec.
+	TUint16 iBaseFormatCode;        // The Base Format Code, reserved for further usage according to Spec.
+	TPtrC iFormatName;              // The Format Name
+	TPtrC iMIMEType;                // The Format MIME Type
+
+	// Property Code is TUint16 actually, but RArray<T> need 4 byte alignment.
+	// So use RArray<TUint32> to store property code
+	RArray<TUint32> iProps;         // Store all object properties code to specified format
+public:
+	//static auxiliary function
+	static IMPORT_C TBool FormatRelation(const TUint16* aFormatCode, const RMTPServiceFormat& aObject);
+	};
+
+/**
+Implements the service related data code(format, service prop and object prop) management.
+@internalComponent
+*/
+class CMTPFullEnumDataCodeMgr: public CBase
+	{
+public:
+	IMPORT_C static CMTPFullEnumDataCodeMgr* NewL(MMTPDataProviderFramework& aFramework);
+	IMPORT_C virtual ~CMTPFullEnumDataCodeMgr();
+
+	// Common Service DataCodeMgr APIs
+	IMPORT_C TUint ServiceID() const;
+	IMPORT_C const TMTPTypeGuid& ServiceGUID() const;
+
+	IMPORT_C void GetSevicePropCodesL(RArray<TUint32>& aArray) const;
+	IMPORT_C const TMTPServicePropertyInfo* ServicePropertyInfo(TUint16 aServicePropCode) const;
+
+	// FullEnum specific APIs
+	IMPORT_C const RMTPServiceFormat& KnowledgeFormat() const;
+
+private:
+	CMTPFullEnumDataCodeMgr(MMTPDataProviderFramework& aFramework);
+	void ConstructL();
+
+	void BuildServiceIDL();
+	void BuildFormatL();
+	void BuildServicePropertyL();
+
+private:
+	MMTPDataProviderFramework& iFramework;
+	RArray<TMTPServicePropertyInfo> iServiceProperties;
+
+	// only Knowledge Format supported.
+	RMTPServiceFormat* iKnowledgeFormat;
+
+	TUint iServiceID;
+	TMTPTypeGuid iServiceGUID;
+	TMTPTypeGuid iPersistentServiceGUID;
+
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+#endif // __CMTPABSTRACTDATACODEMGR_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpcommonrequestprocessor.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,66 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPCOMMONREQUESTPROCESSOR_H
+#define CMTPCOMMONREQUESTPROCESSOR_H
+
+#include <mtp/cmtptypetrivialdata.h>
+#include "cmtprequestprocessor.h"
+
+
+/** 
+Defines generic file system object CMTPCommonRequestProcessor request processor.
+@internalTechnology
+*/
+class CMTPCommonRequestProcessor : public CMTPRequestProcessor
+	{
+public:
+
+    template<TMTPResponseCode RESPCODE, TBool HASITORDATA>
+	static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);	
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, TMTPResponseCode aResponseCode, TBool aHasIToRDataPhase);	
+	IMPORT_C ~CMTPCommonRequestProcessor();	
+	
+private:
+	
+    CMTPCommonRequestProcessor(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, TMTPResponseCode aResponseCode, TBool aHasIToRDataPhase);
+    void ConstructL();
+
+private: // From CMTPRequestProcessor
+    virtual void ServiceL();
+    virtual TBool DoHandleResponsePhaseL();
+    virtual TBool HasDataphase() const; 
+    
+private:
+    TMTPResponseCode                iResponseCode;
+    TBool                           iHasIToRDataPhase;	
+    CMTPTypeTrivialData*            iIToRData;
+	};
+
+
+template<TMTPResponseCode RESPCODE, TBool HASITORDATA>
+    MMTPRequestProcessor* CMTPCommonRequestProcessor::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    return CMTPCommonRequestProcessor::NewL(aFramework, aConnection, RESPCODE, HASITORDATA);
+    }
+    
+	
+#endif // CMTPCOMMONREQUESTPROCESSOR_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpcopyobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,83 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPCOPYOBJECT_H
+#define CMTPCOPYOBJECT_H
+
+#include "cmtprequestprocessor.h"
+#include "mtpdebug.h"
+
+class RFs;
+class CFileMan;
+class CMTPObjectMetaData;
+class CMTPObjectPropertyMgr;
+
+/** 
+Defines data provider CopyObject request processor
+
+@internalTechnology
+*/
+class CMTPCopyObject : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(
+									MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection);	
+	IMPORT_C ~CMTPCopyObject();	
+
+	
+	
+private:	
+	CMTPCopyObject(
+					MMTPDataProviderFramework& aFramework,
+					MMTPConnection& aConnection);
+
+private:	//from CMTPRequestProcessor
+	virtual void ServiceL();
+
+private:
+	void ConstructL();
+	void GetParametersL();
+	void SetDefaultParentObjectL();
+	TMTPResponseCode CopyObjectL(TUint32& aNewHandle);
+	TMTPResponseCode CanCopyObjectL(const TDesC& aOldName, const TDesC& aNewName) const;
+	void GetPreviousPropertiesL(const TDesC& aFileName);
+	void SetPreviousPropertiesL(const TDesC& aFileName);
+	TUint32 CopyFileL(const TDesC& aNewFileName);
+	TUint32 CopyFolderL(const TDesC& aNewFolderName);
+	void SetPropertiesL(TUint32 aSourceHandle, const CMTPObjectMetaData& aTargetObject);	
+	TUint32 UpdateObjectInfoL(const TDesC& aNewObject);
+	
+private:
+	CFileMan*				iFileMan;
+	CMTPObjectMetaData*		iObjectInfo;	//Not owned.
+	HBufC*					iDest;
+	TUint32					iNewParentHandle;
+	TUint32					iStorageId;
+	TTime					iPreviousModifiedTime;
+	
+	/**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+	
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpdeleteobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,73 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPDELETEOBJECT_H
+#define CMTPDELETEOBJECT_H
+
+#include <badesca.h>
+#include <f32file.h>
+
+#include "cmtprequestprocessor.h"
+#include "mtpdebug.h"
+
+class MMTPObjectMgr;
+
+/** 
+Defines data provider GetObject request processor.
+@internalComponent
+*/
+class CMTPDeleteObject : public CMTPRequestProcessor, public MFileManObserver
+    {
+public:
+
+    IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    IMPORT_C ~CMTPDeleteObject();    
+
+private: // From CMTPRequestProcessor
+
+    TMTPResponseCode CheckRequestL();
+    void ServiceL();
+ 
+private:    
+
+    CMTPDeleteObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+	void ProcessFinalPhaseL();
+	TBool IsFolderObject(const CMTPObjectMetaData& aObject);
+	TBool IsStoreReadOnlyL(TUint32 aObjectHandle);
+	void DeleteFolderOrFileL(CMTPObjectMetaData* aMeta);
+    void DeleteFolderL(CMTPObjectMetaData* aMeta);
+    void DeleteFileL(CMTPObjectMetaData* aMeta);    
+	
+private:    
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+	
+	/**
+    True if any deletion succeeded
+	*/
+    TBool					iSuccessDeletion;
+    TBool 					iObjectWritePotected;
+	};
+	
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpextensionmapping.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,62 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPEXTENSIONMAPPING_H
+#define CMTPEXTENSIONMAPPING_H
+
+#include <e32base.h>
+#include <mtp/mtpprotocolconstants.h>
+
+class CMTPExtensionMapping :
+	public CBase
+	{
+public:
+	static CMTPExtensionMapping* NewL(const TDesC& aExtension, TMTPFormatCode aFormatCode);
+	static CMTPExtensionMapping* NewL(const TDesC& aExtension, TMTPFormatCode aFormatCode,const TDesC& aMIMEType);
+	~CMTPExtensionMapping();
+	
+	const TDesC& Extension() const;
+	TMTPFormatCode FormatCode() const;
+	const TDesC& MIMEType() const;
+	TUint32 DpId() const;
+	TUint EnumerationFlag() const;
+	
+	void SetExtensionL(const TDesC& aExtension);
+	void SetMIMETypeL(const TDesC& aMIMEType);
+	void SetDpId(const TUint32 aDpId);
+	void SetFormatCode(const TMTPFormatCode aFormatCode);
+	void SetEnumerationFlag(const TUint aNeedFileDp);
+	
+	static TInt Compare(const CMTPExtensionMapping& aFirst, const CMTPExtensionMapping& aSecond);
+	static TInt ComparewithMIME(const CMTPExtensionMapping& aFirst, const CMTPExtensionMapping& aSecond);
+	
+private:
+	CMTPExtensionMapping(TMTPFormatCode aFormatCode);
+	void ConstructL(const TDesC& aExtension,const TDesC& aMIMEType);
+	
+private:
+	HBufC* iExtension;
+	TMTPFormatCode iFormatCode;
+	HBufC* iMIMEType;
+	TUint32 iDpId;
+	TUint   iNeedFileDp;
+	};
+
+#endif // CMTPEXTENSIONMAPPING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpfsenumerator.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,99 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef MTPFILEENUMERATOR_H
+#define MTPFILEENUMERATOR_H
+
+#include <e32base.h>
+#include <f32file.h>
+
+#include "rmtpdpsingletons.h"
+#include "mtpdebug.h"
+#include "rmtpframework.h"
+
+class MMTPDataProviderFramework;
+class MMTPDataProviderFramework;
+class MMTPObjectMgr;
+class MMTPEnumerationCallback;
+class CMTPObjectMetaData;
+class CMTPFSExclusionMgr;
+
+/** 
+Defines file enumerator.  Enumerates all files/directories under a specified path or storage
+
+@internalTechnology
+*/
+class CMTPFSEnumerator : public CActive
+    {
+public:
+    IMPORT_C static CMTPFSEnumerator* NewL(MMTPDataProviderFramework& aFramework, CMTPFSExclusionMgr& aExclusionMgr, MMTPEnumerationCallback& aCallback, TInt aProcessLimit);
+    IMPORT_C ~CMTPFSEnumerator();
+
+	IMPORT_C void StartL(TUint32 aStorageId);	
+	
+private:
+	//from CActive
+	void DoCancel();
+	void RunL();
+	TInt RunError(TInt aError);
+	
+private:
+	CMTPFSEnumerator(MMTPDataProviderFramework& aFramework, CMTPFSExclusionMgr& aExclusionMgr, MMTPEnumerationCallback& aCallback, TInt aProcessLimit);
+	void ConstructL();
+	
+	void ScanDirL();
+	void ScanStorageL(TUint32 aStorageId);
+	void ScanNextL();
+	void ScanNextStorageL();
+	void ScanNextSubdirL();
+	void ProcessEntriesL();
+	void AddEntryL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& aEntry);
+	void AddFileEntryForOtherDpL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& aEntry);
+	void NotifyObjectAddToDP(const TUint32 aHandle,const TUint DpId);
+	
+private: 
+	// Owned
+	MMTPDataProviderFramework&  iFramework;
+	CMTPFSExclusionMgr& 		iExclusionMgr;
+	MMTPEnumerationCallback& 	iCallback;
+	RMTPDpSingletons			iDpSingletons;
+	TUint32 					iParentHandle;
+	TParse						iPath;
+	RDir						iDir;
+	TEntryArray					iEntries;
+	TInt						iFirstUnprocessed;
+	RArray<TEntry>				iDirStack;
+	RArray<TUint>				iStorages;
+	TUint32						iStorageId;
+	// How many entries should be processed in one go
+	TInt 						iProcessLimit;
+	CMTPObjectMetaData* 		iObject;
+	TUint						iDpID;
+	RMTPFramework               iSingletons;
+	TBool                       iSkipCurrentStorage;
+	/**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+       
+    };
+
+#endif // MTPFILEENUMERATOR_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpfsexclusionmgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,65 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPFSEXCLUSIONMGR_H
+#define CMTPFSEXCLUSIONMGR_H
+
+#include <e32base.h>
+#include <mtp/mtpprotocolconstants.h>
+#include "mtpdebug.h"
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/cmtpstoragemetadata.h>
+#include <mtp/cmtpmetadata.h>
+
+class MMTPDataProviderFramework;
+
+/** 
+Base class for exclusion managers. Derived classes are intended to implement
+specific exclusion behaviour.
+
+@internalTechnology
+*/
+class CMTPFSExclusionMgr : public CBase
+	{
+public:
+	IMPORT_C virtual ~CMTPFSExclusionMgr();
+	
+	IMPORT_C virtual TBool IsFolderAcceptedL(const TDesC& aPath, TUint32 aStorageID) const;
+	IMPORT_C virtual TBool IsFileAcceptedL(const TDesC& aFileName, TUint32 aStorageID) const;
+	IMPORT_C virtual TBool IsFormatValid(TMTPFormatCode aFormat) const = 0;
+    IMPORT_C virtual TBool IsExtensionValid(const TDesC& aExtension) const = 0;
+    
+protected:
+	IMPORT_C CMTPFSExclusionMgr(MMTPDataProviderFramework& aFramework);
+		
+	IMPORT_C TBool IsPathAcceptedL(const TDesC& aPath, TUint32 aStorageId) const;
+	
+protected:
+	MMTPDataProviderFramework& iFramework;
+	TLinearOrder<CMTPMetaData::TPathHash> iOrder;
+	
+	/**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+	
+	};
+	
+#endif // CMTPFSEXCLUSIONMGR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpfullenumservicehandler.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,114 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpfullenumservicehandler.h
+// FullEnum Service Handler
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __CMTPFULLENUMSERVICEHANDLER_H__
+#define __CMTPFULLENUMSERVICEHANDLER_H__
+
+#include <mtp/cmtptypeserviceproplist.h>
+#include <mtp/tmtptypeguid.h>
+#include <mtp/cmtptypeobjectpropdesc.h>
+
+#include "mtpdebug.h"
+#include "mmtpservicehandler.h"
+
+class CMTPTypeServiceInfo;
+class CMTPTypeServiceCapabilityList;
+class CMTPTypeDeleteServicePropList;
+class CMTPTypeServicePropDescList;
+class CRepository;
+class CMTPFullEnumDataCodeMgr;
+
+/**
+High level interface to MTP request processor
+@internalComponent
+*/
+class CMTPFullEnumServiceHandler: public CBase
+//                               , public MMTPServiceHandler
+	{
+public:
+	// Basic function
+	static IMPORT_C CMTPFullEnumServiceHandler* NewL(MMTPDataProviderFramework& aFramework,
+			const CMTPFullEnumDataCodeMgr& aDataCodeMgr,
+			CRepository& aRepository,
+			TUint aNormalServiceID,
+			const TDesC& aKnowledgeObjectSUID,
+			const TMTPTypeGuid& aServiceFormatGUID);
+	IMPORT_C ~CMTPFullEnumServiceHandler();
+
+	// MMTPServiceHandler
+	IMPORT_C TMTPResponseCode GetServiceCapabilityL(TUint16 aServiceFormatCode, CMTPTypeServiceCapabilityList& aServiceCapabilityList) const;
+	IMPORT_C TMTPResponseCode GetServicePropDescL(TUint16 aServicePropertyCode, CMTPTypeServicePropDescList& aPropDescList) const;
+
+	// FullEnum specific APIs
+	IMPORT_C TMTPResponseCode GetServicePropetyL(TUint16 aPropertyCode, CMTPTypeServicePropList& aPropList) const;
+	IMPORT_C TMTPResponseCode SetServicePropetyL(TUint16 aPropEnumIndex, const CMTPTypeServicePropListElement& aElement);
+	IMPORT_C TMTPResponseCode DeleteServiceProperty(TUint16 aPropEnumIndex);
+
+private:
+	// Property value of FullEnum Service need store in central repository
+	enum TMTPServiceStoreKeyNum
+		{
+		EVersionProps = 0x1,     // Version Props
+		EReplicaID = 0x2,        // Set by synchost at first sync, store in db.
+		EKnowledgeObjectID = 0x3,// Use object handle which store in framework.
+		ESyncFormat = 0x04,      // Format GUID for the obj that is to be sync.
+		ELocalOnlyDelete = 0x05, // Boolean, set by synchost.
+		EFilterType = 0x06,      // Set by synchost, device just store it.
+		ELastSyncProxyID = 0x07, // a GUID indicating the last sync proxy to perform a sync operation
+		ESyncObjectReference = 0x08, //Describing whether object references should be included as part of the sync process or not
+		};
+
+	CMTPFullEnumServiceHandler(MMTPDataProviderFramework& aFramework,
+							   const CMTPFullEnumDataCodeMgr& aDataCodeMgr,
+							   CRepository& iRepository,
+							   TUint aNormalServiceID,
+							   const TDesC& aKnowledgeObjectSUID,
+							   const TMTPTypeGuid& aServiceFormatGUID);
+	void ConstructL();
+
+	void LoadServicePropValueL();
+
+private:
+	MMTPDataProviderFramework& iFramework;
+	const CMTPFullEnumDataCodeMgr&   iDataCodeMgr;
+
+	// Store service property
+	CRepository&				iRepository;
+
+	// data from Normal Service
+	TUint						iNormalServiceID;
+	TMTPTypeGuid				iNormalServiceFormatGUID;
+	const TDesC&				iKnowledgeObjectSUID;
+
+	//FullEnum Sync Service propterties which are writable
+	TMTPTypeGuid            	iReplicateID;
+	TMTPTypeGuid            	iLastSyncProxyID;
+	TMTPSyncSvcLocalOnlyDelete 	iLocalOnlyDelete;
+	TMTPSyncSvcSyncObjectReferences iSyncObjectReference;
+	TMTPSyncSvcFilterType      	iFilterType;
+
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // __CMTPFULLENUMSERVICEHANDLER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetformatcapabilities.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,71 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+#ifndef CMTPGETFORMATCAPABILITLIST_H_
+#define CMTPGETFORMATCAPABILITLIST_H_
+
+#include <mtp/cmtptypeformatcapabilitylist.h>
+
+#include "cmtprequestprocessor.h"
+#include "rmtpframework.h"
+
+class CMTPTypeObjectPropDesc;
+/** 
+Implements the file data provider CMTPGetFormatCapabilities request processor.
+@internalComponent
+*/
+class CMTPGetFormatCapabilities : public CMTPRequestProcessor
+    {
+public:
+    
+    IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    IMPORT_C ~CMTPGetFormatCapabilities();    
+    
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+    TMTPResponseCode CheckRequestL();
+    
+private:
+
+    CMTPGetFormatCapabilities(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+    void BuildFormatAssociationL();
+    void BuildFormatAsUndefinedL( TUint aFormatCode );
+    CMTPTypeObjectPropDesc* ServiceProtectionStatusL();
+    CMTPTypeObjectPropDesc* ServiceAssociationTypeL();
+    CMTPTypeObjectPropDesc* ServiceNonConsumableL();
+    
+private: // Owned
+
+    //[SP-Format-0x3002]
+    //Make the same behavior betwen 0x3000 and 0x3002.
+	//it is used to judge whether FileDP supports 0x3002 or not.
+	RMTPFramework       						 iSingletons;
+	
+    TUint                                        iFormatCode;
+    /* 
+     * CMTPTypeCapabilityList dataset.
+     */
+    CMTPTypeFormatCapabilityList*                iCapabilityList;
+    };
+
+
+#endif /* CMTPGETFORMATCAPABILITLIST_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetinterdependentpropdesc.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,51 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPGETINTERDEPENDENTPROPDESC_H
+#define CMTPGETINTERDEPENDENTPROPDESC_H
+
+#include "cmtprequestprocessor.h"
+
+class CMTPTypeInterdependentPropDesc;
+
+/** 
+Defines file data provider GetInterDependentPropDesc request processor
+
+@internalTechnology
+*/
+class CMTPGetInterDependentPropDesc : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);	
+	IMPORT_C ~CMTPGetInterDependentPropDesc();	
+	
+private:	
+	CMTPGetInterDependentPropDesc(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+
+private:	//from CMTPRequestProcessor
+	virtual void ServiceL();
+	
+private:
+	/** Dataset to store the prop descriptions*/
+    CMTPTypeInterdependentPropDesc* iDataset;
+	};
+	
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,64 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPGETOBJECT_H
+#define CMTPGETOBJECT_H
+
+#include "cmtprequestprocessor.h"
+#include "mtpdebug.h"
+
+class CMTPTypeFile;
+
+/** 
+Defines file data provider GetObject request processor
+@internalComponent
+*/
+class CMTPGetObject : public CMTPRequestProcessor
+    {
+public:
+
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+	IMPORT_C ~CMTPGetObject();    
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+    TBool DoHandleResponsePhaseL();
+    
+private: 
+   
+    CMTPGetObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+
+    void BuildFileObjectL(const TDesC& aFileName);
+        
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    CMTPTypeFile*       iFileObject;
+    TMTPResponseCode    iError;
+    };
+    
+#endif // CMTPGETOBJECT_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetobjectinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,65 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPGETOBJECTINFO_H
+#define CMTPGETOBJECTINFO_H
+
+#include <f32file.h>
+
+#include "cmtprequestprocessor.h"
+#include "rmtpdpsingletons.h"
+
+class CMTPTypeObjectInfo;
+
+
+/** 
+Defines file data provider GetObjectInfo request processor
+
+@internalTechnology
+*/
+class CMTPGetObjectInfo : public CMTPRequestProcessor
+	{
+public:
+	
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);	
+	IMPORT_C ~CMTPGetObjectInfo();	
+	
+private:
+
+	CMTPGetObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+	void ConstructL();
+
+private: // From CMTPRequestProcessor
+	
+	void ServiceL();
+
+private:
+
+	void BuildObjectInfoL();
+		
+private:
+
+	CMTPTypeObjectInfo*		iObjectInfoToBuild;
+	TEntry					iFileEntry;
+	RFs&					iRfs;
+    RMTPDpSingletons		iDpSingletons; 
+	};
+	
+#endif CMTPGETOBJECTINFO_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetobjectpropdesc.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,72 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __CMTPGETOBJECTPROPDESC_H__
+#define __CMTPGETOBJECTPROPDESC_H__
+
+#include "cmtprequestprocessor.h"
+
+class CMTPTypeObjectPropDesc;
+
+/** 
+Defines file data provider GetObjectPropDesc request processor
+
+@internalTechnology
+*/
+class CMTPGetObjectPropDesc : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(
+									MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection);	
+	IMPORT_C ~CMTPGetObjectPropDesc();	
+	
+private:	
+	CMTPGetObjectPropDesc(
+					MMTPDataProviderFramework& aFramework,
+					MMTPConnection& aConnection);
+	void ConstructL();
+
+private:	//from CMTPRequestProcessor
+	virtual TMTPResponseCode CheckRequestL();
+	virtual void ServiceL();	
+
+private:
+	//helper
+	void ServiceStorageIdL();
+	void ServiceObjectFormatL();
+	void ServiceProtectionStatusL();
+	void ServiceObjectSizeL();
+	void ServiceAssociationTypeL();
+	void ServiceAssociationDescL();
+	void ServiceFileNameL();
+	void ServiceDateModifiedL();
+	void ServiceParentObjectL();
+	void ServicePuidL();
+	void ServiceNameL();
+	void ServiceNonConsumableL();
+	TUint16 GetPropertyGroupNumber(const TUint16 aPropCode) const;
+	
+private:
+	CMTPTypeObjectPropDesc*	iObjectProperty;
+	};
+	
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetobjectproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,77 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPGETOBJECTPROPLIST_H
+#define CMTPGETOBJECTPROPLIST_H
+
+#include "cmtprequestprocessor.h"
+#include "rmtpdpsingletons.h"
+
+class CMTPTypeArray;
+class CMTPTypeObjectPropList;
+
+/** 
+Implements the file data provider GetObjectPropList request processor.
+@internalComponent
+*/
+class CMTPGetObjectPropList : public CMTPRequestProcessor
+    {
+public:
+    
+    IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    IMPORT_C ~CMTPGetObjectPropList();    
+    
+private:    
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+    TMTPResponseCode CheckRequestL();
+    
+private:
+
+    CMTPGetObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+
+    TMTPResponseCode CheckFormatL() const;
+    TMTPResponseCode CheckPropCode() const;
+    TMTPResponseCode CheckDepth() const;
+    
+    void GetObjectHandlesL();
+    void GetObjectHandlesL(TUint32 aStorageId, TUint32 aFormatCode, TUint32 aParentHandle);
+    void GetFolderObjectHandlesL(TUint32 aFormatCode, TUint32 aDepth,TUint32 aParentHandle);
+    void GetRootObjectHandlesL(TUint32 aFormatCode, TUint32 aDepth);
+    void GetSpecificObjectHandlesL(TUint32 aHandle, TUint32 aFormatCode, TUint32 aDepth);
+    
+    void ServiceAllPropertiesL(TUint32 aHandle);
+	void ServiceGroupPropertiesL(TUint32 aHandle,TUint16 aGroupCode);
+    void ServiceOneObjectPropertyL(TUint32 aHandle, TUint32 aPropCode);
+    
+private: // Owned
+
+    CMTPTypeArray*          iHandles;
+    CMTPTypeObjectPropList* iPropertyList;   
+    RMTPDpSingletons		iDpSingletons; 
+	CMTPObjectMetaData*		iObjMeta;
+	TEntry 					iFileEntry;
+    };
+    
+#endif // CMTPGETOBJECTPROPLIST_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetobjectpropssupported.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,56 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __CMTPGETOBJECTPROPSSUPPORTED_H__
+#define __CMTPGETOBJECTPROPSSUPPORTED_H__
+
+#include "cmtprequestprocessor.h"
+
+class CMTPTypeArray;
+
+/** 
+Defines file data provider GetObjectPropsSupported request processor
+
+@internalTechnology
+*/
+class CMTPGetObjectPropsSupported : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(
+									MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection);	
+	IMPORT_C ~CMTPGetObjectPropsSupported();	
+	
+private:	
+	CMTPGetObjectPropsSupported(
+					MMTPDataProviderFramework& aFramework,
+					MMTPConnection& aConnection);
+	void ConstructL();
+
+private:	//from CMTPRequestProcessor
+    virtual TMTPResponseCode CheckRequestL();
+	virtual void ServiceL();
+	
+private:
+	CMTPTypeArray*			iObjectPropsSupported;
+	};
+	
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetobjectpropvalue.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,85 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __CMTPGETOBJECTPROPVALUE_H__
+#define __CMTPGETOBJECTPROPVALUE_H__
+
+#include "cmtprequestprocessor.h"
+#include <mtp/cmtpobjectmetadata.h>
+#include <f32file.h> 
+
+class TMTPTypeUint8;
+class TMTPTypeUint16;
+class TMTPTypeUint32;
+class TMTPTypeUint64;
+class TMTPTypeUint128;
+class CMTPTypeString;
+
+/** 
+Defines file data provider GetObjectPropsSupported request processor
+
+@internalTechnology
+*/
+class CMTPGetObjectPropValue : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(
+									MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection);	
+	IMPORT_C ~CMTPGetObjectPropValue();	
+	
+private:	
+	CMTPGetObjectPropValue(
+					MMTPDataProviderFramework& aFramework,
+					MMTPConnection& aConnection);
+	void ConstructL();
+
+private:	//from CMTPRequestProcessor
+	virtual TMTPResponseCode CheckRequestL();
+	virtual void ServiceL();
+
+private:
+	//helper
+	void ServiceStorageIdL();
+	void ServiceObjectFormatL();
+	void ServiceProtectionStatusL();
+	void ServiceObjectSizeL();
+	void ServiceObjectAssociationTypeL();
+	void ServiceObjectAssociationDescL();
+	void ServiceFileNameL();
+	void ServiceDateModifiedL();
+	void ServiceParentObjectL();
+	void ServicePuidL();
+	void ServiceNameL();
+	void ServiceNonConsumableL();
+private:
+	TMTPTypeUint8			iMTPTypeUint8;
+	TMTPTypeUint16			iMTPTypeUint16;
+	TMTPTypeUint32			iMTPTypeUint32;
+	TMTPTypeUint64			iMTPTypeUint64;
+	TMTPTypeUint128			iMTPTypeUint128;
+	CMTPTypeString*			iMTPTypeString;
+	CMTPObjectMetaData*		iObjMeta;
+	TEntry 					iFileEntry;
+	RFs&					iRfs;
+	};
+	
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetpartialobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,67 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPGETPARTIALOBJECT_H
+#define CMTPGETPARTIALOBJECT_H
+
+#include "cmtprequestprocessor.h"
+#include "mtpdebug.h"
+
+class CMTPTypeFile;
+
+/** 
+Defines file data provider GetObject request processor
+@internalComponent
+*/
+class CMTPGetPartialObject : public CMTPRequestProcessor
+    {
+public:
+
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+	IMPORT_C ~CMTPGetPartialObject();
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+    TBool DoHandleResponsePhaseL();
+    TMTPResponseCode CheckRequestL();
+    
+private: 
+   
+    CMTPGetPartialObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+
+        
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    CMTPTypeFile*       iFileObject;
+    CMTPObjectMetaData* iObjectInfo;    
+    TUint               iOffset;
+    TUint               iLength;
+
+    };
+    
+#endif // CMTPGETPARTIALOBJECT_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpgetreferences.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,54 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPGETREFERENCES_H
+#define CMTPGETREFERENCES_H
+
+#include "cmtprequestprocessor.h"
+
+class CMTPTypeArray;
+
+
+/** 
+Defines generic file system object GetObjectReferences request processor.
+@internalTechnology
+*/
+class CMTPGetReferences : public CMTPRequestProcessor
+	{
+public:
+
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);	
+	IMPORT_C ~CMTPGetReferences();	
+	
+private:
+	
+	CMTPGetReferences(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+
+private: // From CMTPRequestProcessor
+
+	virtual void ServiceL();
+
+private:
+
+	CMTPTypeArray*			iReferences;
+	};
+	
+#endif // CMTPGETREFERENCES_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpknowledgehandler.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,136 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpknowledgehandler.h
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __CMTPKNOWLEDGEHANDLER_H__
+#define __CMTPKNOWLEDGEHANDLER_H__
+
+#include <mtp/cmtptypeserviceproplist.h>
+#include <mtp/mtpprotocolconstants.h>
+
+#include "mtpdebug.h"
+#include "mtpsvcdpconst.h"
+#include "mmtpsvcobjecthandler.h"
+
+class CMTPTypeFile;
+class CRepository;
+
+/** 
+Controls access to the knowledge object.
+@internalComponent
+*/
+class CMTPKnowledgeHandler : public CBase, public MMTPSvcObjectHandler
+	{
+public:
+	// Basic function
+	IMPORT_C static CMTPKnowledgeHandler* NewL(MMTPDataProviderFramework& aFramework, TUint16 aFormatCode, CRepository& aReposotry, const TDesC& aKwgSuid);
+	IMPORT_C ~CMTPKnowledgeHandler();
+
+	
+	IMPORT_C void SetStorageId(TUint32 aStorageId);
+	IMPORT_C void GetObjectSuidL(TDes& aSuid) const;
+
+protected:
+	// MMTPSvcObjectHandler
+	TMTPResponseCode SendObjectInfoL(const CMTPTypeObjectInfo& aObjectInfo, TUint32& aParentHandle, TDes& aSuid);
+	TMTPResponseCode GetObjectInfoL(const CMTPObjectMetaData& aObjectMetaData, CMTPTypeObjectInfo& aObjectInfo);
+
+	TMTPResponseCode SendObjectPropListL(TUint64 aObjectSize, const CMTPTypeObjectPropList& aObjectPropList, TUint32& aParentHandle, TDes& aSuid);
+	TMTPResponseCode SetObjectPropertyL(const TDesC& aSuid, const CMTPTypeObjectPropListElement& aElement, TMTPOperationCode aOperationCode);
+	TMTPResponseCode GetObjectPropertyL(const CMTPObjectMetaData& aObjectMetaData, TUint16 aPropertyCode, CMTPTypeObjectPropList& aPropList);
+	TMTPResponseCode DeleteObjectPropertyL(const CMTPObjectMetaData& aObjectMetaData, const TUint16 aPropertyCode);
+
+	TMTPResponseCode GetBufferForSendObjectL(const CMTPObjectMetaData& aObjectMetaData, MMTPType** aBuffer);
+	TMTPResponseCode GetObjectL(const CMTPObjectMetaData& aObjectMetaData, MMTPType** aBuffer);
+	TMTPResponseCode DeleteObjectL(const CMTPObjectMetaData& aObjectMetaData);
+
+	TMTPResponseCode GetObjectSizeL(const TDesC& aSuid, TUint64& aObjectSize);
+	TMTPResponseCode GetAllObjectPropCodeByGroupL(TUint32 aGroupId, RArray<TUint32>& aPropCodes);
+	
+	void CommitL();
+	void CommitForNewObjectL(TDes& aSuid);
+	void RollBack();
+	void ReleaseObjectBuffer();	
+
+	enum TCacheStatus
+		{
+		EOK,
+		EDirty,
+		EDeleted
+		};
+	//key of central repository
+	enum TMTPKnowledgeStoreKeyNum
+		{
+		ESize = 0x10001, 
+		EDateModified = 0x10002,
+		EName = 0x10003,
+		ELastAuthorProxyID = 0x10004
+		};
+	
+	TMTPResponseCode SetColumnType128Value(TMTPKnowledgeStoreKeyNum aColumnNum, TMTPTypeUint128& aNewData);
+
+private:
+	CMTPKnowledgeHandler(MMTPDataProviderFramework& aFramework,TUint16 aFormatCode, CRepository& aReposotry, const TDesC& aKwgSuid);
+	void ConstructL();
+	
+	/**
+	Get the value from the central repository
+	@leave One of the system wide error codes, if repository get value fail
+	*/
+	void LoadKnowledgeObjPropertiesL();
+	/**
+	Cleanup Item operation for drop all knowledge properties
+	*/
+	static void DropCacheWrapper(TAny* aObject);
+	void DropKnowledgeObjPropertiesCache();
+	/**
+	Helper for GetObjectInfo request handling
+	*/
+	void BuildObjectInfoL(CMTPTypeObjectInfo& aObjectInfo) const;
+	/**
+	Delete knowledge object properties and content
+	@leave One of the system wide error codes, if repository set value fail
+	*/
+	void DeleteAllObjectPropertiesL();
+	
+private:
+	MMTPDataProviderFramework&  iFramework;
+	CRepository&                iRepository;
+	TUint32                     iStorageID;
+	TUint16                     iKnowledgeFormatCode;
+	TUint64                     iKnowledgeObjectSize; 
+	HBufC*                      iDateModified;
+	HBufC*                      iName;
+	TMTPTypeUint128             iLastAuthorProxyID;
+	TCacheStatus                iCacheStatus;
+	TCacheStatus                iCacheStatusFlag;
+	TFileName                   iKnowObjFileName;
+	TFileName                   iKnowObjSwpFileName;
+	// Knowledge object content file
+	CMTPTypeFile*               iKnowledgeObj;
+	// Knowledge object swap file
+	CMTPTypeFile*               iKnowledgeSwpBuffer;
+	const TDesC&               iSuid;
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // __CMTPKNOWLEDGEHANDLER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpmoveobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,87 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPMOVEOBJECT_H
+#define CMTPMOVEOBJECT_H
+
+#include "cmtprequestprocessor.h"
+#include "mtpdebug.h"
+
+class CFileMan;
+class CMTPObjectMetaData;
+
+/** 
+Defines data provider MoveObject request processor
+
+@internalTechnology
+*/
+class CMTPMoveObject : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(
+									MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection);	
+	IMPORT_C ~CMTPMoveObject();	
+
+private:	
+	CMTPMoveObject(
+					MMTPDataProviderFramework& aFramework,
+					MMTPConnection& aConnection);
+
+private:	//from CMTPRequestProcessor
+	virtual void ServiceL();
+	
+private:	//from CActive
+	void RunL();
+	TInt RunError(TInt aError);
+	
+private:
+	void ConstructL();
+	void GetParametersL();
+	void SetDefaultParentObjectL();
+	TMTPResponseCode MoveObjectL();
+	TMTPResponseCode CanMoveObjectL(const TDesC& aOldName, const TDesC& aNewName) const;
+	void GetPreviousPropertiesL(const TDesC& aFileName);
+	void SetPreviousPropertiesL(const TDesC& aFileName);
+	void MoveFileL(const TDesC& aNewFileName);
+	void MoveFolderL();
+	TMTPResponseCode FinalPhaseMove();
+	void MoveAndUpdateL(TUint32 objectHandle);
+	
+private:	
+	CFileMan*				iFileMan;
+	CMTPObjectMetaData*		iObjectInfo;	//Not owned.
+	HBufC*					iDest;
+	HBufC*					iNewRootFolder;
+	TUint32					iNewParentHandle;
+	TUint32					iStorageId;
+	TTime					iPreviousModifiedTime;
+	HBufC*					iPathToMove;
+	RArray<TUint>           iObjectHandles;
+	TInt                    iMoveObjectIndex;
+	
+	/**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+	
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtprequestchecker.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,154 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cmtpequestchecker.h
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __CMTPREQUESTCHECKER_H__
+#define __CMTPREQUESTCHECKER_H__
+
+#include <e32base.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptyperequest.h>
+#include "mtpdebug.h"
+
+class CMTPObjectMetaData;
+class MMTPDataProviderFramework;
+class MMTPConnection;
+
+/**
+element type in the request
+@internalTechnology
+*/        
+enum TMTPElementType
+    {
+    /**
+    Session ID type
+    */
+    EMTPElementTypeSessionID,			
+    
+    /**
+    Object Handle type
+    */    
+    EMTPElementTypeObjectHandle,		
+    
+    /**
+    Format code type	
+    */    
+    EMTPElementTypeFormatCode,			
+    
+    /**
+    Storeage Id type
+    */    
+    EMTPElementTypeStorageId,			
+    }; 
+
+/**
+element attribute to check in the reqeust
+@internalTechnology
+*/
+enum TMTPElementAttr
+	{
+	/**
+	no attribute to check
+	*/
+	EMTPElementAttrNone		=  	0x0000,		
+	
+	/**
+	the object/storage should be readable
+	*/
+	EMTPElementAttrRead		=	0x0001,	
+	
+	/**
+	the object/storage should be writable
+	*/		
+	EMTPElementAttrWrite	=	0x0002,		
+	
+	/**
+	the object should be a file
+	*/
+	EMTPElementAttrFile 	= 	0x0004,		
+	
+	/**
+	the object should be a directory
+	*/
+	EMTPElementAttrDir		=	0x0008,	
+	
+	/**
+	supported format array
+	*/	
+	EMTPElementAttrFormatEnums = 0x0010,
+	
+	/**
+	The object can be either a file or directory.
+	*/
+	EMTPElementAttrFileOrDir = 0x0020,
+	};
+
+/**
+defines the verification data structure
+@internalTechnology
+*/
+struct TMTPRequestElementInfo
+    {
+    TMTPTypeRequest::TElements  iElementIndex;		//which element in the request to check
+    TMTPElementType 		    iElementType;		//the type of the element
+    TInt 				        iElementAttr;		//the attribute of the element
+    TInt 					    iCount;				//number of special values (0, 1, 2)
+    TUint32 				    iValue1;			//special value 1
+    TUint32 					iValue2;			//special value 2
+    }; 
+
+/**
+defines a generic request verification class.  It iterates through the verification data elements,
+and performs the check based on the element type/attribute.
+@internalTechnology
+*/    
+class CMTPRequestChecker : public CBase 
+    {
+public:
+	IMPORT_C static CMTPRequestChecker* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+	IMPORT_C ~CMTPRequestChecker();
+      
+    IMPORT_C TMTPResponseCode VerifyRequestL(const TMTPTypeRequest& aRequest, TInt aCount, const TMTPRequestElementInfo* aElementInfo);
+	IMPORT_C CMTPObjectMetaData* GetObjectInfo(TUint32 aHandle) const; 
+
+private:	    
+    TMTPResponseCode CheckRequestHeader(const TMTPTypeRequest& aRequest) const;
+    TMTPResponseCode VerifySessionId(TUint32 aSessionId, const TMTPRequestElementInfo& aElementInfo) const;    
+    TMTPResponseCode VerifyObjectHandleL(TUint32 aHandle, const TMTPRequestElementInfo& aElementInfo);
+    TMTPResponseCode VerifyStorageIdL(TUint32 aStorageId, const TMTPRequestElementInfo& aElementInfo) const;  
+    TMTPResponseCode VerifyFormatCode(TUint32 aFormatCode, const TMTPRequestElementInfo& aElementInfo) const;
+	TBool IsSpecialValue(TUint32 aParameter, const TMTPRequestElementInfo& aElementInfo) const;
+private:
+	CMTPRequestChecker(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);	
+	
+private:
+    MMTPDataProviderFramework&		    iFramework;
+    MMTPConnection& 				    iConnection;
+	RArray<TUint32>					    iHandles;			//these two arrays contain the mapping from the handle to objectinfo 
+	RPointerArray<CMTPObjectMetaData>   iObjectArray; 
+	/**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+	
+#endif 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtprequestprocessor.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,203 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __CMTPREQUESTPROCESSOR_H__
+#define __CMTPREQUESTPROCESSOR_H__
+
+#include <e32base.h>
+#include <mtp/mtpdataproviderapitypes.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptyperesponse.h>
+#include <mtp/tmtptypenull.h>
+#include "cmtprequestchecker.h"
+#include "mtpdebug.h"
+
+class MMTPConnection;
+class TMTPTypeRequest;
+class CMTPDataProviderPlugin;
+class MMTPDataProviderFramework;
+class TMTPTypeEvent;
+class CMTPObjectInfo;
+
+/** 
+Defines a request processor interface
+
+@internalTechnology
+*/	
+class MMTPRequestProcessor
+	{
+public:	
+	/**
+	Process a request from the initiator
+	@param aRequest	The request to be processed
+	@param aPhase	The transaction phase of the request
+	@return ETrue to signal that the processor object can be deleted, EFalse to keep the processor object
+	*/
+	virtual TBool HandleRequestL(const TMTPTypeRequest& aRequest, TMTPTransactionPhase aPhase) = 0;
+	
+	/**
+	Process an event from the initiator
+	@param aEvent	The event to be processed
+	*/
+	virtual void HandleEventL(const TMTPTypeEvent& aEvent) = 0;
+	
+	/**
+	delete the request processor object
+	*/
+	virtual void Release() = 0;
+	
+	/**
+	Check if the processor matches the request on the connection
+	@param aRequest	The request to be checked
+	@param aConnection The connection from which the request comes
+	@return ETrue to indicate the processor can handle the request, otherwise, EFalse
+	*/
+	virtual TBool Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const = 0;
+
+	/**
+	Check if the processor matches the event on the connection
+	@param aEvent The event to be checked
+	@param aConnection The connection from which the event comes
+	@return ETrue to indicate the processor can handle the event, otherwise, EFalse
+	*/	
+	virtual TBool Match(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) const = 0;
+	
+	/**
+	Get the request object which the processor is currently handling
+	@return the request object which the processor is currently handling
+	*/
+	virtual const TMTPTypeRequest& Request() const = 0;
+	
+	/**
+	Get the connection object associated with the current request object
+	@return the connection object associated with the current request object
+	*/
+	virtual MMTPConnection& Connection() const = 0;
+    /**
+    Get the Session ID associated with the current request object
+    @return Session ID associated with the current request object
+    */	
+	virtual TUint32 SessionId() = 0;
+	
+	};
+
+/** 
+Defines a processor factory function pointer
+
+@internalTechnology
+*/
+typedef MMTPRequestProcessor* (*TMTPRequestProcessorCreateFunc)(
+																MMTPDataProviderFramework& aFramework, 
+																MMTPConnection& aConnection);
+
+/** 
+Defines an entry which maps from operation code to the request processor
+
+@internalTechnology
+*/																
+typedef struct 
+	{
+	TUint16							iOperationCode;
+	TMTPRequestProcessorCreateFunc	iCreateFunc;
+	}TMTPRequestProcessorEntry;
+
+
+/** 
+Defines a generic request processor interface from which all processors derive
+
+@internalTechnology
+*/		
+class CMTPRequestProcessor : public CActive, public MMTPRequestProcessor
+	{
+protected:	
+	IMPORT_C CMTPRequestProcessor(
+						MMTPDataProviderFramework& aFramework,
+						MMTPConnection& aConnection,
+						TInt aElementCount,
+						const TMTPRequestElementInfo* aElements);
+	IMPORT_C virtual ~CMTPRequestProcessor();	
+
+protected:	//utility methods	
+	IMPORT_C void SendResponseL(TMTPResponseCode aResponseCode, TInt aParameterCount = 0, TUint32* aParams = NULL);
+	IMPORT_C void CompleteRequestL();
+	IMPORT_C void SendDataL(const MMTPType& aData);
+	IMPORT_C void ReceiveDataL(MMTPType& aData);
+		
+protected:	//	from MMTPRequestProcessor	
+	IMPORT_C virtual TBool HandleRequestL(const TMTPTypeRequest& aRequest, TMTPTransactionPhase aPhase);
+	IMPORT_C virtual void HandleEventL(const TMTPTypeEvent& aEvent);
+	
+	IMPORT_C virtual void Release();
+
+	IMPORT_C virtual TBool Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const;
+	IMPORT_C virtual TBool Match(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) const;
+		
+	IMPORT_C virtual const TMTPTypeRequest& Request() const;
+	IMPORT_C virtual MMTPConnection& Connection() const;
+	   
+    IMPORT_C virtual TUint32 SessionId();
+
+protected:	// from CActive
+	IMPORT_C virtual void RunL();
+	IMPORT_C virtual void DoCancel();
+	IMPORT_C virtual TInt RunError(TInt aError);
+	
+protected:	//new virtuals 	
+	IMPORT_C virtual TBool DoHandleRequestPhaseL();
+	IMPORT_C virtual TBool DoHandleDataIToRPhaseL();
+	IMPORT_C virtual TBool DoHandleRToIPhaseL();
+	IMPORT_C virtual TBool DoHandleResponsePhaseL();
+	IMPORT_C virtual TBool DoHandleCompletingPhaseL();
+	IMPORT_C virtual TMTPResponseCode CheckRequestL();
+	IMPORT_C virtual TBool HasDataphase() const;
+	
+	/**
+	service a request at request phase
+	*/
+	IMPORT_C virtual void ServiceL() = 0;
+
+
+private:
+	void ExtractSessionTransactionId();					
+	
+protected:
+	MMTPDataProviderFramework&	    iFramework;
+	const TMTPTypeRequest*		    iRequest;			//the pending requst object
+	MMTPConnection&				    iConnection;		//the connection from which the request comes
+	TMTPTypeResponse			    iResponse;			//the response object to send to the initiator
+	TBool						    iCancelled;			//indicates whether the data phase (send/receive) has been cancelled
+	CMTPRequestChecker*		    	iRequestChecker;	//a utility class providing generic request verification service
+	TInt					    	iElementCount;		//number of verification elements used for request checker
+	const TMTPRequestElementInfo*	iElements;	 		//pointer to an array of verification elements
+	TUint32						    iSessionId;			//session id for the pending request
+	TUint32						    iTransactionCode;	//transaction code for the pending request
+
+private:
+	TMTPResponseCode 				iResponseCode;		// contains response from CheckRequestL call
+	RBuf8 							iNullBuffer; 		// buffer to receive data from discarded data phase
+	TMTPTypeNull 					iNull;
+	/**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+	
+#endif // __CMTPREQUESTPROCESSOR_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtprequestunknown.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,51 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __CMTPREQUESTUNKNOWN_H__
+#define __CMTPREQUESTUNKNOWN_H__
+
+#include "cmtprequestprocessor.h"
+
+/** 
+Defines device data provider OpenSession request processor
+
+@internalTechnology
+*/
+class CMTPRequestUnknown : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(
+									MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection);	
+	IMPORT_C ~CMTPRequestUnknown();
+		
+	
+protected:	
+	IMPORT_C CMTPRequestUnknown(
+					MMTPDataProviderFramework& aFramework,
+					MMTPConnection& aConnection);
+
+protected:	//from CMTPRequestProcessor
+	IMPORT_C virtual void ServiceL();
+	IMPORT_C virtual TBool Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const;		
+	};
+	
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsendobjectinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,135 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPSENDOBJECTINFO_H
+#define CMTPSENDOBJECTINFO_H
+
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/tmtptypenull.h>
+
+#include "cmtprequestprocessor.h"
+#include "rmtpdpsingletons.h"
+#include "rmtpframework.h"
+#include "mtpdebug.h"
+
+class CMTPTypeFile;
+class CMTPTypeObjectInfo;
+class CMTPTypeObjectPropList;
+class CMTPTypeObjectPropListElement;
+
+/** 
+Implements the file data provider's SendObjectInfo request processor.
+@internalComponent
+*/
+class CMTPSendObjectInfo : public CMTPRequestProcessor
+    {
+public:
+
+    IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    IMPORT_C ~CMTPSendObjectInfo();    
+    
+private:
+
+    CMTPSendObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+
+private: // From CMTPRequestProcessor
+
+    TBool Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const;
+    TMTPResponseCode CheckRequestL();
+    void ServiceL();
+    TBool DoHandleCompletingPhaseL();
+    TBool DoHandleResponsePhaseL();
+    TBool HasDataphase() const;
+
+private:
+    TMTPResponseCode CheckSendingStateL();
+    void GetDefaultParentObjectL();
+    TMTPResponseCode GetParentObjectAndStorageIdL();
+    
+    void ServiceSendObjectInfoL();
+    void ServiceSendObjectPropListL();
+    void ServiceSendObjectL();
+    
+    TBool DoHandleSendObjectInfoCompleteL();
+    TBool DoHandleSendObjectPropListCompleteL();
+    TBool DoHandleSendObjectCompleteL();
+        
+    TBool GetFullPathNameL(const TDesC& aFileName);
+    
+    TBool CanStoreFileL(TUint32 aStorageId, TInt64 aObjectSize) const;
+    TBool IsTooLarge(TUint64 aObjectSize) const;
+    TBool Exists(const TDesC& aName) const;
+    TMTPResponseCode ExtractPropertyL(const CMTPTypeObjectPropListElement& aElement);
+    void ReserveObjectL();
+    void CreateFsObjectL();
+    void Rollback();
+    TMTPResponseCode ErrorToMTPError(TInt aError) const;
+    
+    TMTPResponseCode VerifyObjectPropListL(TInt& aInvalidParameterIndex);
+    TMTPResponseCode CheckPropCodeL(const CMTPTypeObjectPropListElement& aElement) const; 
+    TMTPResponseCode MatchStoreAndParentL() const;
+
+    void SetPropertiesL();
+    
+private:
+    enum TMTPSendingObjectState
+        {
+        EObjectNone,
+        EObjectInfoInProgress,
+        EObjectInfoSucceed,
+        EObjectInfoFail,
+        ESendObjectInProgress,
+        ESendObjectSucceed,
+        ESendObjectFail
+        };
+        
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+    CMTPTypeFile*           iFileReceived;
+    CMTPTypeObjectInfo*     iObjectInfo;
+    CMTPTypeObjectPropList* iObjectPropList;
+    TMTPSendingObjectState  iProgress;
+    TUint16                 iOperationCode;
+    TUint32                 iStorageId;
+    TUint32                 iParentHandle;
+    TUint64                 iObjectSize;
+    HBufC*                  iParentSuid;
+    TFileName               iFullPath;
+    HBufC*				    iDateMod;// To carry modified date extracted from PropertyList
+    CMTPObjectMetaData*     iReceivedObject;
+    TMTPTypeRequest         iExpectedSendObjectRequest;
+    TBool                   iIsFolder;
+    TMTPTypeNull            iNullObject;
+    TUint16                 iProtectionStatus;
+    TUint32                 iPreviousTransactionID;
+    RMTPDpSingletons		iDpSingletons;
+    TFileName				iName;
+    TBool					iNoRollback;
+    RMTPFramework           iSingletons;
+    };
+    
+#endif //CMTPSENDOBJECTINFO_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsetobjectproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,65 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPSETOBJECTPROPLIST_H
+#define CMTPSETOBJECTPROPLIST_H
+
+#include "cmtprequestprocessor.h"
+#include "rmtpframework.h"
+#include "rmtpdpsingletons.h"
+
+class CMTPTypeObjectPropList;
+
+/** 
+Implements the file data provider SetObjectPropsList request processor.
+@internalComponent
+*/
+class CMTPSetObjectPropList : public CMTPRequestProcessor
+    {
+public:
+
+    IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    IMPORT_C ~CMTPSetObjectPropList();    
+    
+private:
+
+    CMTPSetObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+    TBool DoHandleResponsePhaseL();
+    TBool HasDataphase() const;
+    
+private:
+
+    TMTPResponseCode CheckPropCode(TUint16 aPropertyCode, TUint16 aDataType) const;
+    TMTPResponseCode CheckObjectHandleL(TUint32 aHandle) const;
+
+private:
+    RMTPDpSingletons		iDpSingletons;
+    CMTPTypeObjectPropList* iPropertyList;    
+    RMTPFramework			iSingleton;	
+	CMTPObjectMetaData*		iObjMeta;
+    };
+    
+#endif // CMTPSETOBJECTPROPLIST_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsetobjectpropvalue.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,77 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __CMTPSETOBJECTPROPVALUE_H__
+#define __CMTPSETOBJECTPROPVALUE_H__
+
+#include <e32std.h> 
+#include <mtp/cmtpobjectmetadata.h>
+#include "cmtprequestprocessor.h"
+#include "rmtpframework.h"
+#include "rmtpdpsingletons.h"
+
+class CMTPTypeString;
+class TMTPTypeUint8;
+
+
+/** 
+Defines file data provider SetObjectPropValue request processor
+
+@internalTechnology
+*/
+class CMTPSetObjectPropValue : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(
+									MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection);	
+	IMPORT_C ~CMTPSetObjectPropValue();	
+	
+private:	
+	CMTPSetObjectPropValue(
+					MMTPDataProviderFramework& aFramework,
+					MMTPConnection& aConnection);
+	void ConstructL();
+	TBool IsPropCodeReadonly(TUint32 aObjectPropCode);
+
+private:	//from CMTPRequestProcessor
+	virtual TMTPResponseCode CheckRequestL();
+	virtual void ServiceL();
+	virtual TBool DoHandleResponsePhaseL();
+	TBool HasDataphase() const;
+
+private:
+	CMTPTypeString*			iMTPTypeString;
+	TMTPTypeUint8			iMTPTypeUint8;
+	TMTPTypeUint16			iMTPTypeUint16;
+	TMTPTypeUint32			iMTPTypeUint32;
+	RMTPFramework			iSingleton;
+	TEntry 					iFileEntry;
+	RFs&					iRfs;
+	CMTPObjectMetaData*		iObjMeta;
+	
+    /**
+    DP utility singletons
+    */
+    RMTPDpSingletons					iDpSingletons;
+	};
+	
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsetobjectprotection.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,64 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __CMTPSETOBJECTPROTECTION_H__
+#define __CMTPSETOBJECTPROTECTION_H__
+
+#include <e32std.h> 
+#include <mtp/cmtpobjectmetadata.h>
+#include "cmtprequestprocessor.h"
+#include "rmtpframework.h"
+#include "rmtpdpsingletons.h"
+
+class CMTPTypeString;
+class TMTPTypeUint8;
+
+
+/** 
+Defines file data provider SetObjectPropValue request processor
+
+@internalTechnology
+*/
+class CMTPSetObjectProtection : public CMTPRequestProcessor
+    {
+public:
+    IMPORT_C static MMTPRequestProcessor* NewL(
+                                    MMTPDataProviderFramework& aFramework,
+                                    MMTPConnection& aConnection);   
+    IMPORT_C ~CMTPSetObjectProtection(); 
+    
+private:    
+    CMTPSetObjectProtection(
+                    MMTPDataProviderFramework& aFramework,
+                    MMTPConnection& aConnection);
+    void ConstructL();
+
+private:    //from CMTPRequestProcessor
+    virtual TMTPResponseCode CheckRequestL();
+    virtual void ServiceL();
+
+private:
+    RFs&                    iRfs;
+    CMTPObjectMetaData*     iObjMeta;
+    
+    };
+    
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsetreferences.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,61 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPSETREFERENCES_H
+#define CMTPSETREFERENCES_H
+
+#include "cmtprequestprocessor.h"
+
+class CMTPTypeArray;
+
+
+/** 
+Defines generic file system object SetObjectReferences request processor.
+@internalTechnology
+*/
+class CMTPSetReferences : public CMTPRequestProcessor
+    {
+public:
+
+    IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    IMPORT_C ~CMTPSetReferences();    
+    
+private:    
+
+    CMTPSetReferences(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+
+private: // From CMTPRequestProcessor
+
+    virtual void ServiceL();
+    virtual TBool DoHandleResponsePhaseL();
+    TBool HasDataphase() const;
+    
+private:
+
+    TBool VerifyReferenceHandlesL() const;    
+    
+private:
+
+    CMTPTypeArray*  iReferences;
+    };
+    
+
+#endif // CMTPSETREFERENCES_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvccompoundprocessor.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,135 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvccompoundprocessor.h
+
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __CMTPSVCCOMPOUNDPROCESSOR_H__
+#define __CMTPSVCCOMPOUNDPROCESSOR_H__
+
+#include "cmtprequestprocessor.h"
+
+class MMTPServiceDataProvider;
+class MMTPSvcObjectHandler;
+class CMTPTypeObjectInfo;
+class CMTPTypeObjectPropList;
+class CMTPObjectMetaData;
+
+/** 
+Implements the service data provider's CMTPCompoundProcessor request processor.
+The processor is responsible for SendObjectInfo, SendObjectPropList, UpdateObjectPropList 
+and SendObject requests handling, it will create new object or update existing object. 
+@internalComponent
+*/
+class CMTPSvcCompoundProcessor : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);    
+	IMPORT_C ~CMTPSvcCompoundProcessor();
+
+private:
+	CMTPSvcCompoundProcessor(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);
+	void ConstructL();
+
+	// From CMTPRequestProcessor
+	TBool Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const;
+	TBool HasDataphase() const;
+	
+	TMTPResponseCode CheckRequestL();
+	TMTPResponseCode CheckSendingStateL();
+	TMTPResponseCode CheckRequestParametersL();
+	TMTPResponseCode CheckStoreAndParent();
+	
+	void ServiceL();
+	void ServiceObjectPropertiesL();
+	void ServiceSendObjectInfoL();
+	void ServiceSendObjectPropListL();
+	void ServiceSendObjectL();
+	
+	TBool DoHandleCompletingPhaseL();
+	TBool DoHandleResponsePhaseL();
+	TBool DoHandleResponseSendObjectInfoL();
+	TBool DoHandleResponseSendObjectPropListL();
+	TBool DoHandleResponseUpdateObjectPropListL();
+	TBool DoHandleResponseSendObjectL();
+	
+	/**
+	Extract objectsize property value from UpdateObjectPropList dataset
+	@return See MTP response code definition
+	*/
+	TMTPResponseCode ExtractObjectSizeL();
+	/**
+	Reserve object handle from framework for SendObjectInfo or SendObjectPropList
+	*/
+	void ReserveObjectL();
+	/**
+	Register route next SendObject from framework and send response code
+	*/
+	void RegisterRequestAndSendResponseL(TMTPResponseCode aResponseCode);
+	
+	// Cleanup Item operation for commit rollback including handle and temp object rollback
+	static void RollBackObject(TAny* aObject);
+	void RollBack();
+	
+	// Check object format and set object handler pointer
+	TMTPResponseCode CheckFmtAndSetHandler(TUint32 aFormatCode);
+	TMTPResponseCode SendObjectPropListL(const CMTPTypeObjectPropList& aObjectPropList, TUint32& aParentHandle, 
+															TUint32& aParameter, TDes& aSuid, TUint64 aObjectSize);
+	TMTPResponseCode UpdateObjectPropListL(CMTPObjectMetaData& aObjectMetaData, 
+															const CMTPTypeObjectPropList& aObjectPropList, 
+															TUint32& aParameter);
+
+private:
+	enum TMTPSendingObjectState
+		{
+		EIdle,
+		EObjectInfoProcessing,
+		EObjectInfoSucceed,
+		EObjectSendProcessing,
+		EObjectSendSucceed,
+		EObjectSendFail
+		};
+
+	TUint16                      iOperationCode;   // Current operation code
+	TUint16                      iLastInfoOperationCode;   // Last info category operation code
+	TUint32                      iFormatCode;
+	TUint32                      iStorageId;
+	TUint32                      iParentHandle;
+	TUint64                      iObjectSize;
+	
+	MMTPServiceDataProvider&     iDataProvider;
+	MMTPSvcObjectHandler*        iObjectHandler; // Not own
+	MMTPType*                    iObjectContent; // Not own
+	CMTPTypeObjectInfo*          iObjectInfo;
+	CMTPTypeObjectPropList*      iObjectPropList;
+	CMTPObjectMetaData*          iReceivedObjectMetaData;
+
+	TMTPSendingObjectState       iState; // Compound processor state machine
+	TMTPTypeRequest              iExpectedSendObjectRequest; // Use for register next SendObject
+	TUint32                      iLastTransactionID; // Last valid transaction id
+	TUint32                      iLastSessionID; // Last valid session id
+	TBool                        iIsCommited; // Is received ObjectInfo or ObjectPropList commited
+	TBool                        iIsRollBackHandlerObject; // Roll back handle which has been insert in handler db
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // __CMTPSVCCOMPOUNDPROCESSOR_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcdeleteobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,71 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcdeleteobject.h
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __CMTPSVCDELETEOBJECT_H__
+#define __CMTPSVCDELETEOBJECT_H__
+
+#include "cmtprequestprocessor.h"
+
+class MMTPServiceDataProvider;
+class MMTPSvcObjectHandler;
+
+/** 
+Defines service data provider GetObject request processor.
+@internalComponent
+*/
+class CMTPSvcDeleteObject : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);
+	IMPORT_C ~CMTPSvcDeleteObject();
+
+private:
+	CMTPSvcDeleteObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);
+
+	void LoadAllObjHandlesL(TUint32 aParentHandle);
+	void ProcessFinalPhaseL();
+	void CompleteSelf(TInt aError);
+	
+	// For CMTPRequestProcessor
+	TMTPResponseCode CheckRequestL();
+	void ServiceL();
+	// For CActive
+	void RunL();
+	TInt RunError(TInt aError);
+	// Check object format and set object handler pointer
+	TMTPResponseCode CheckFmtAndSetHandler(TUint32 aFormatCode);
+	TMTPResponseCode DeleteObjectL(const CMTPObjectMetaData& aObjectMetaData);
+
+private:
+	MMTPServiceDataProvider&     iDataProvider;
+	MMTPSvcObjectHandler*        iObjectHandler; // Not own
+	TInt                         iDeleteIndex;
+	TInt                         iDeleteError;
+	RArray<TUint>                iObjectHandles;
+	TBool                        iSuccessDeletion;
+	TInt32                       iFormatCode;
+	CMTPObjectMetaData*          iReceivedObjectMetaData;
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // __CMTPSVCDELETEOBJECT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcdeleteobjectproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,63 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcdeleteobjectproplist.h
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __CMTPSVCDELETEOBJECTPROPLIST_H__
+#define __CMTPSVCDELETEOBJECTPROPLIST_H__
+
+#include "cmtprequestprocessor.h"
+
+class MMTPServiceDataProvider;
+class CMTPTypeDeleteObjectPropList;
+
+/** 
+Implements the service data provider DeleteObjectPropList request processor.
+@internalComponent
+*/
+class CMTPSvcDeleteObjectPropList : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);    
+	IMPORT_C ~CMTPSvcDeleteObjectPropList(); 
+
+private:
+	CMTPSvcDeleteObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);
+	void ConstructL();
+	
+	TMTPResponseCode CheckObjectHandleL(TUint32 aHandle) const;
+	// From CMTPRequestProcessor
+	TMTPResponseCode CheckRequestL();
+	void ServiceL();
+	TBool DoHandleResponsePhaseL();
+	TBool HasDataphase() const;
+	TMTPResponseCode DeleteObjectPropListL(CMTPObjectMetaData& aObjectMetaData, 
+										const CMTPTypeDeleteObjectPropList& aPropList, 
+										TUint32& aParameter);
+
+private:
+	MMTPServiceDataProvider&       iDataProvider;
+	CMTPTypeDeleteObjectPropList*  iPropertyList;
+	CMTPObjectMetaData*            iReceivedObjectMetaData;
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // __CMTPSVCDELETEOBJECTPROPLIST_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcdeleteserviceproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,60 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcdeleteserviceproplist.h
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __CMTPSVCDELETESERVICEPROPLIST_H__
+#define __CMTPSVCDELETESERVICEPROPLIST_H__
+
+#include "cmtprequestprocessor.h"
+#include "mtpdebug.h"
+
+class MMTPServiceDataProvider;
+class CMTPTypeDeleteServicePropList;
+
+/** 
+Implements the service data provider DeleteServicePropList request processor.
+@internalComponent
+*/
+class CMTPSvcDeleteServicePropList : public CMTPRequestProcessor
+{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);
+	IMPORT_C ~CMTPSvcDeleteServicePropList();
+
+private:
+	CMTPSvcDeleteServicePropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);
+	void ConstructL();
+	
+	// From CMTPRequestProcessor
+	TMTPResponseCode CheckRequestL();
+	void ServiceL();
+	TBool DoHandleResponsePhaseL();
+	TBool HasDataphase() const; 
+
+private:
+	CMTPTypeDeleteServicePropList*     iDeleteServicePropList;
+	MMTPServiceDataProvider&           iDataProvider;
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // __CMTPSVCDELETESERVICEPROPLIST_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,56 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetobject.h
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __CMTPSVCGETOBJECT_H__
+#define __CMTPSVCGETOBJECT_H__
+
+#include "cmtprequestprocessor.h"
+
+class MMTPServiceDataProvider;
+class MMTPSvcObjectHandler;
+
+/** 
+Implements the service data provider GetObject request processor.
+@internalComponent
+*/
+class CMTPSvcGetObject : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);    
+	IMPORT_C ~CMTPSvcGetObject();
+
+private:
+	CMTPSvcGetObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);
+	void ConstructL();
+	
+	TMTPResponseCode CheckRequestL();
+	void ServiceL();
+
+private:
+	MMTPServiceDataProvider&    iDataProvider;
+	MMTPSvcObjectHandler*       iObjectHandler; // Not own
+	MMTPType*                   iBuffer; // Not own
+	CMTPObjectMetaData*         iReceivedObjectMetaData;
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+#endif // __CMTPSVCGETOBJECT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetobjectinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,59 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetobjectinfo.h
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __CMTPSVCGETOBJECTINFO_H__
+#define __CMTPSVCGETOBJECTINFO_H__
+
+#include "cmtprequestprocessor.h"
+
+class MMTPServiceDataProvider;
+class MMTPSvcObjectHandler;
+class CMTPTypeObjectInfo;
+
+/** 
+Implements the service data provider GetObjectInfo request processor.
+@internalComponent
+*/
+class CMTPSvcGetObjectInfo : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);    
+	IMPORT_C ~CMTPSvcGetObjectInfo();
+
+private:
+	CMTPSvcGetObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);
+	void ConstructL();
+	
+	// For CMTPRequestProcessor
+	TMTPResponseCode CheckRequestL();
+	void ServiceL();
+
+private:
+	CMTPTypeObjectInfo*         iObjectInfo;
+	MMTPServiceDataProvider&    iDataProvider;
+	MMTPSvcObjectHandler*       iObjectHandler; // Not own
+	CMTPObjectMetaData*         iReceivedObjectMetaData;
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // __CMTPSVCGETOBJECTINFO_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetobjectproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,78 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetobjectproplist.h
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __CMTPSVCGETOBJECTPROPLIST_H__
+#define __CMTPSVCGETOBJECTPROPLIST_H__
+
+#include <e32hashtab.h>
+#include "cmtprequestprocessor.h"
+
+class CMTPTypeObjectPropList;
+class MMTPServiceDataProvider;
+class MMTPSvcObjectHandler;
+
+/** 
+Implements the service data provider GetObjectPropList request processor.
+@internalComponent
+*/
+class CMTPSvcGetObjectPropList : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);
+	IMPORT_C ~CMTPSvcGetObjectPropList();
+
+private:
+	CMTPSvcGetObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);
+	void ConstructL();
+
+	// From CActive
+	void RunL();
+	TInt RunError(TInt aError);
+
+	TMTPResponseCode CheckObjectHandleAndFormatL();
+	TMTPResponseCode CheckDepth() const;
+	TMTPResponseCode CheckRequestL();
+	TMTPResponseCode CheckPropertyCodeForFormatL(TUint32 aFormatCode) const;
+
+	void ServiceL();
+	void ProcessFinalPhaseL();
+	void CompleteSelf(TInt aError);
+	TBool DoHandleResponsePhaseL();
+	// Wraper for getting one format's object proplist according to prop code and group code.
+	void GetObjectPropertyHelperL();
+
+private:
+	RArray<TUint>                iObjectHandles;
+	TUint32                      iPropCode;
+	TInt                         iHandleIndex;
+	TInt                         iError;
+	MMTPServiceDataProvider&     iDataProvider;
+	MMTPSvcObjectHandler*        iObjectHandler; // Not own
+	CMTPTypeObjectPropList*      iPropertyList;
+	TMTPResponseCode             iResponseCode;
+	CMTPObjectMetaData*          iReceivedObjectMetaData;
+	TUint32                      iGroupId;
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // __CMTPSVCGETOBJECTPROPLIST_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetreferences.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,61 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetreferences.h
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __CMTPSVCGETREFERENCES_H__
+#define __CMTPSVCGETREFERENCES_H__
+
+#include "cmtprequestprocessor.h"
+
+class MMTPServiceDataProvider;
+class CMTPTypeArray;
+class CMTPObjectMetaData;
+
+/** 
+Defines generic file system object GetObjectReferences request processor.
+@internalTechnology
+*/
+class CMTPSvcGetReferences : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, 
+											MMTPConnection& aConnection, 
+											MMTPServiceDataProvider& aDataProvider);
+	IMPORT_C ~CMTPSvcGetReferences();	
+	
+private:
+	CMTPSvcGetReferences(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, 
+						MMTPServiceDataProvider& aDataProvider);
+	
+	// From CMTPRequestProcessor
+	TMTPResponseCode CheckRequestL();
+	virtual void ServiceL();
+
+private:
+	CMTPTypeArray*               iReferences;
+	MMTPServiceDataProvider&     iDataProvider;
+	CMTPObjectMetaData*          iReceivedObjectMetaData;
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+	
+#endif // __CMTPSVCGETREFERENCES_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetservicecapabilities.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,61 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetservicecapabilities.h
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __CMTPSVCGETSERVICECAPABILITIES_H__
+#define __CMTPSVCGETSERVICECAPABILITIES_H__
+
+#include "cmtprequestprocessor.h"
+#include "mtpdebug.h"
+
+class CMTPTypeServiceCapabilityList;
+class MMTPServiceDataProvider;
+class MMTPDataProviderFramework;
+
+/** 
+Implements the service data provider GetServiceCapabilities request processor.
+@internalComponent
+*/
+class CMTPSvcGetServiceCapabilities : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);
+	IMPORT_C ~CMTPSvcGetServiceCapabilities();
+
+private:
+	CMTPSvcGetServiceCapabilities(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);
+	void ConstructL();
+
+	// From CMTPRequestProcessor
+	TMTPResponseCode CheckRequestL();
+	void ServiceL();
+	TBool DoHandleResponsePhaseL();
+
+private:
+	CMTPTypeServiceCapabilityList*     iServiceCapabilityList;
+	MMTPServiceDataProvider&           iDataProvider;
+	TMTPResponseCode                   iResponseCode;
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // __CMTPSVCGETSERVICECAPABILITIES_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetserviceinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,60 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetserviceinfo.h
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __CMTPSVCGETSERVICEINFO_H__
+#define __CMTPSVCGETSERVICEINFO_H__
+
+#include "cmtprequestprocessor.h"
+#include "mtpdebug.h"
+#include "cmtpserviceinfo.h"
+
+class MMTPServiceDataProvider;
+class MMTPDataProviderFramework;
+class CMTPTypeServiceInfo;
+/** 
+Implements the service data provider GetServiceInfo request processor.
+@internalComponent
+*/
+class CMTPSvcGetServiceInfo : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);    
+	IMPORT_C ~CMTPSvcGetServiceInfo();
+
+private:
+	CMTPSvcGetServiceInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);
+	void ConstructL();
+
+	// From CMTPRequestProcessor
+	void ServiceL();
+	TMTPResponseCode CheckRequestL();
+	TBool DoHandleResponsePhaseL();
+	
+private:
+	CMTPTypeServiceInfo*      iServiceInfo;
+	MMTPServiceDataProvider&  iDataProvider;
+	TMTPResponseCode          iResponseCode;
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // __CMTPSVCGETSERVICEINFO_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetservicepropdesc.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,58 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetservicepropdesc.h
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __CMTPSVCGETSERVICEPROPDESC_H__
+#define __CMTPSVCGETSERVICEPROPDESC_H__
+
+#include "cmtprequestprocessor.h"
+
+class CMTPTypeServicePropDescList;
+class MMTPServiceDataProvider;
+
+/** 
+Implements the service data provider GetServicePropDesc request processor.
+@internalComponent
+*/
+class CMTPSvcGetServicePropDesc : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);    
+	IMPORT_C ~CMTPSvcGetServicePropDesc();
+
+private:
+	CMTPSvcGetServicePropDesc(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);
+	void ConstructL();
+	
+	// From CMTPRequestProcessor
+	void ServiceL();
+	TMTPResponseCode CheckRequestL();
+	TBool DoHandleResponsePhaseL();
+
+private:
+	MMTPServiceDataProvider&         iDataProvider;
+	CMTPTypeServicePropDescList*     iPropDescList;
+	TMTPResponseCode                 iResponseCode;
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // __CMTPSVCGETSERVICEPROPDESC_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetserviceproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,59 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetserviceproplist.h
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __CMTPSVCGETSERVICEPROPLIST_H__
+#define __CMTPSVCGETSERVICEPROPLIST_H__
+
+#include <mtp/cmtptypeserviceproplist.h>
+#include "cmtprequestprocessor.h"
+
+class MMTPServiceDataProvider;
+
+/** 
+Implements the service data provider GetServicePropList request processor.
+@internalComponent
+*/
+class CMTPSvcGetServicePropList : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);    
+	IMPORT_C ~CMTPSvcGetServicePropList();
+
+	// From CMTPRequestProcessor
+	void ServiceL();
+	TMTPResponseCode CheckRequestL();
+
+private:
+	CMTPSvcGetServicePropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);
+	void ConstructL();
+	TBool DoHandleResponsePhaseL();
+
+private:
+	CMTPTypeServicePropList*     iServicePropList;
+	MMTPServiceDataProvider&     iDataProvider;
+	TMTPResponseCode             iResponseCode;
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // __CMTPSVCGETSERVICEPROPLIST_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetstorageinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,68 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcgetstorageinfo.h
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __CMTPSVCGETSTORAGEINFO_H__
+#define __CMTPSVCGETSTORAGEINFO_H__
+
+#include "cmtprequestprocessor.h"
+#include "mtpdebug.h"
+
+class MMTPServiceDataProvider;
+class CMTPTypeStorageInfo;
+
+/** 
+Implements the service data provider GetStorageInfo request processor.
+@internalComponent
+*/
+class CMTPSvcGetStorageInfo : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(
+									MMTPDataProviderFramework& aFramework, 
+									MMTPConnection& aConnection, 
+									MMTPServiceDataProvider& aDataProvider);
+	IMPORT_C ~CMTPSvcGetStorageInfo();
+
+private:
+	CMTPSvcGetStorageInfo(
+					MMTPDataProviderFramework& aFramework, 
+					MMTPConnection& aConnection, 
+					MMTPServiceDataProvider& aDataProvider);
+	void ConstructL();
+	
+	//from CMTPRequestProcessor
+	virtual void ServiceL();
+	TMTPResponseCode CheckRequestL();
+	//helper
+	void SetStorageDescriptionL();
+	void SetVolumeIdentifierL();
+	void SetMaxCapacityL();
+	void SetFreeSpaceInBytesL();
+
+private:
+	CMTPTypeStorageInfo*         iStorageInfo;
+	MMTPServiceDataProvider&     iDataProvider;
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // __CMTPSVCGETSTORAGEINFO_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcsetobjectproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,57 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcsetobjectproplist.h
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __CMTPSVCSETOBJECTPROPLIST_H__
+#define __CMTPSVCSETOBJECTPROPLIST_H__
+
+#include "cmtprequestprocessor.h"
+
+class CMTPTypeObjectPropList;
+class MMTPServiceDataProvider;
+
+/** 
+Implements the service data provider SetObjectPropsList request processor.
+@internalComponent
+*/
+class CMTPSvcSetObjectPropList : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);    
+	IMPORT_C ~CMTPSvcSetObjectPropList();	
+
+private:
+	CMTPSvcSetObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);
+	void ConstructL();
+	
+	// From CMTPRequestProcessor
+	void ServiceL();
+	TBool DoHandleResponsePhaseL();
+	TMTPResponseCode SetObjectPropListL(const CMTPTypeObjectPropList& aObjectPropList, TUint32& aParameter);
+
+private:
+	MMTPServiceDataProvider&     iDataProvider;
+	CMTPTypeObjectPropList*      iPropertyList;
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // __CMTPSVCSETOBJECTPROPLIST_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcsetreferences.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,63 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcsetreferences.h
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __CMTPSVCSETREFERENCES_H__
+#define __CMTPSVCSETREFERENCES_H__
+
+#include "cmtprequestprocessor.h"
+class MMTPServiceDataProvider;
+class CMTPTypeArray;
+class CMTPObjectMetaData;
+
+/** 
+Defines generic file system object SetObjectReferences request processor.
+@internalTechnology
+*/
+class CMTPSvcSetReferences : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, 
+									MMTPConnection& aConnection, 
+									MMTPServiceDataProvider& aDataProvider);
+	IMPORT_C ~CMTPSvcSetReferences();
+
+private:
+	CMTPSvcSetReferences(MMTPDataProviderFramework& aFramework, 
+						MMTPConnection& aConnection, 
+						MMTPServiceDataProvider& aDataProvider);
+	TMTPResponseCode CheckRequestL();
+	virtual void ServiceL();
+	virtual TBool DoHandleResponsePhaseL();
+	TBool HasDataphase() const;
+
+	TBool VerifyReferenceHandlesL() const;
+
+private:
+	CMTPTypeArray*               iReferences;
+	MMTPServiceDataProvider&     iDataProvider;
+	CMTPObjectMetaData*          iReceivedObjectMetaData;
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // __CMTPSVCSETREFERENCES_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcsetserviceproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,59 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsvcsetserviceproplist.h
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __CMTPSVCSETSERVICEPROPLIST_H__
+#define __CMTPSVCSETSERVICEPROPLIST_H__
+
+#include <mtp/cmtptypeserviceproplist.h>
+#include "cmtprequestprocessor.h"
+
+class MMTPServiceDataProvider;
+
+/** 
+Implements the service data provider SetServicePropList request processor.
+@internalComponent
+*/
+class CMTPSvcSetServicePropList : public CMTPRequestProcessor
+	{
+public:
+	IMPORT_C static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);    
+	IMPORT_C ~CMTPSvcSetServicePropList();
+
+private:
+	CMTPSvcSetServicePropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider);
+	void ConstructL();
+	
+	// From CMTPRequestProcessor    
+	TMTPResponseCode CheckRequestL(); 
+	void ServiceL();
+	virtual TBool DoHandleResponsePhaseL();	
+	TBool HasDataphase() const;
+
+private:
+	CMTPTypeServicePropList*     iServicePropList;
+	MMTPServiceDataProvider&     iDataProvider;
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // __CMTPSVCSETSERVICEPROPLIST_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/mmtpenumerationcallback.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,42 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef MMTPENUMERATIONCALLBACK_H
+#define MMTPENUMERATIONCALLBACK_H
+
+#include <e32std.h>
+
+/** 
+Defines the FileDP enumeration complete notification interface.
+@internalComponent
+*/
+class MMTPEnumerationCallback
+	{
+public:
+
+	/**
+	Notifies that enumeration of the specified storage is completed.
+    @param aStorageId The MTP StorageID of the enumerated storage.
+	@param aError The enumeration completion error status.
+	*/
+	virtual void NotifyEnumerationCompleteL(TUint32 aStorageId, TInt aError) = 0;
+	};
+	
+#endif // MMTPENUMERATIONCALLBACK_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/mmtpservicedataprovider.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,89 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/mmtpservicedataprovider.h
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __MMTPSERVICEDATAPROVIDER_H__
+#define __MMTPSERVICEDATAPROVIDER_H__
+
+#include <mtp/mtpprotocolconstants.h>
+
+class MMTPSvcObjectHandler;
+class MMTPServiceHandler;
+class CMTPTypeStorageInfo;
+
+class MMTPServiceDataProvider
+{
+public:
+	/**
+	Get object handler pointer for request processor.
+	@param aFormatCode Format code which owned by the returned object handler.
+	@return MMTPSvcObjectHandler* object handler's pointer. If the pointer is 
+	NULL, then means the input format code is not supported by the data provider.
+	*/
+	virtual MMTPSvcObjectHandler* ObjectHandler(TUint16 aFormatCode) const = 0;
+	/**
+	Get service handler pointer for request processor.
+	@return MMTPServiceHandler* service handler's pointer. If the pointer is 
+	NULL, then means data provider doesn't support service extension.
+	*/
+	IMPORT_C virtual MMTPServiceHandler* ServiceHandler() const;
+	/**
+	Check if a service property code is valid.
+	@param aPropCode A service property code need to be checked.
+	@return TBool ETrue is valid.
+	*/
+	IMPORT_C virtual TBool IsValidServicePropCodeL(TUint16 aPropCode) const;
+	/**
+	Check if a format code is valid.
+	@param aFormatCode A format code need to be checked data provider.
+	@return TBool ETrue is valid.
+	*/
+	virtual TBool IsValidFormatCodeL(TUint16 aFormatCode) const = 0;
+	/**
+	Check if a object property code is valid.
+	@param aFormatCode A format code which the property code belong to.
+	@param aPropCode A object property code need to be checked.
+	@return TBool ETrue is valid.
+	*/
+	virtual TBool IsValidObjectPropCodeL(TUint16 aFormatCode, TUint16 aPropCode) const = 0;
+	/**
+	Get service id owned by a data provider.
+	@return TUint32 Service id.
+	*/
+	IMPORT_C virtual TUint32 ServiceID() const;
+	/**
+	Get storage id owned by a data provider.
+	@return TUint32 Storage id.
+	*/
+	virtual TUint32 StorageId() const = 0;
+	/**
+	Get the AO's granularity for delete all objects and get object proper list. 
+	@return TUint32 Operation granularity, normally the value is 50.
+	*/
+	IMPORT_C virtual TUint32 OperationGranularity() const;
+	/**
+	Dispatch GetStorageInfo to data provider
+	@param aStorageInfo StorageInfo dataset.
+	@return See MTP response code definition
+	@leave One of the system wide error codes, if a general processing error
+	*/
+	virtual TMTPResponseCode GetStorageInfoL(CMTPTypeStorageInfo& aStorageInfo) const = 0;
+};
+
+#endif // __MMTPSERVICEDATAPROVIDER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/mmtpservicehandler.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,72 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/mmtpservicehandler.h
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __MMTPSERVICEHANDLER_H__
+#define __MMTPSERVICEHANDLER_H__
+
+#include <mtp/cmtptypeserviceproplist.h>
+#include <mtp/cmtptypeobjectpropdesc.h>
+#include <mtp/tmtptypeguid.h>
+#include "mtpsvcdpconst.h"
+
+class CMTPTypeServiceInfo;
+class CMTPTypeServiceCapabilityList;
+class CMTPTypeDeleteServicePropList;
+class CMTPTypeServicePropDescList;
+class CMTPTypeObjectPropDesc;
+class CRepository;
+
+class MMTPServiceHandler
+	{
+public:
+	virtual TMTPResponseCode GetServiceCapabilityL(TUint16 aServiceFormatCode, CMTPTypeServiceCapabilityList& aServiceCapabilityList) const = 0;
+	virtual TMTPResponseCode GetServiceInfoL(CMTPTypeServiceInfo& aServiceInfo) const = 0;
+	virtual TMTPResponseCode GetServicePropDescL(TUint16 aServicePropertyCode, CMTPTypeServicePropDescList& aPropDescList) const = 0;
+	virtual TMTPResponseCode GetServicePropertyL(TUint16 aPropertyCode, CMTPTypeServicePropList& aPropList) const = 0;
+	virtual TMTPResponseCode SetServicePropertyL(const CMTPTypeServicePropListElement& aPropElement) = 0;
+	virtual TMTPResponseCode DeleteServicePropertyL(TUint16 aPropertyCode) = 0;
+	/**
+	Get all service property codes into an array.
+	@param aArray Returned service property codes array.
+	*/
+	virtual void GetAllSevicePropCodesL(RArray<TUint32>& aPropCodes) const = 0;
+	virtual void GetAllServiceFormatCodeL(RArray<TUint32>& aFormatCodes) const = 0;
+
+public:
+	IMPORT_C static CMTPTypeObjectPropDesc* GenerateSvcObjPropertyL(
+		TUint aDataType, const TMTPTypeGuid& aPKNamespace,
+		TUint aPKID, const TDesC& aName, TUint8 aFormFlag,
+		const MMTPType* aForm, CMTPTypeObjectPropDesc::TMTPObjectPropDescGetSet aObjGetSet,
+		TUint16 aObjPropCode, TUint32 aGroupCode = 0);
+	IMPORT_C static CMTPTypeObjectPropDesc* GenerateSvcObjPropertyLC(
+		TUint aDataType, const TMTPTypeGuid& aPKNamespace,
+		TUint aPKID, const TDesC& aName, TUint8 aFormFlag,
+		const MMTPType* aForm, CMTPTypeObjectPropDesc::TMTPObjectPropDescGetSet aObjGetSet,
+		TUint16 aObjPropCode, TUint32 aGroupCode = 0);
+
+	IMPORT_C static CMTPTypeObjectPropDesc* GenerateGenericObjectPropDescLC(TUint16 aObjPropCode);
+
+	IMPORT_C static TMTPResponseCode SaveServicePropValue(
+		CRepository& aRepository, TUint aColumnNum, TInt aNewData);
+	IMPORT_C static TMTPResponseCode SaveServicePropValue(
+		CRepository& aRepository, TUint aColumnNum, TMTPTypeGuid& aNewData);
+	};
+
+#endif // __MMTPSERVICEHANDLER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/mmtpsvcobjecthandler.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,195 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/mmtpsvcobjecthandler.h
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __MMTPSVCOBJHANDLER_H__
+#define __MMTPSVCOBJHANDLER_H__
+
+#include <mtp/mtpprotocolconstants.h>
+
+class CMTPObjectMetaData;
+class CMTPTypeArray;
+class CMTPTypeObjectInfo;
+class CMTPTypeObjectPropList;
+class CMTPTypeObjectPropListElement;
+
+class MMTPSvcObjectHandler
+	{
+public:
+	/**
+	Dispatch SendObjectInfoL to object handler
+	@param aObjectInfo The ObjectInfo dataset specifed in the MTP request
+	@param aParentHandle Specify the new object's parent handle, dp can change the handler if necessary.
+	@param aSuid Concrete object handler need set the parameter with new created object suid
+	@return See MTP response code definition
+	@leave One of the system wide error codes, if a general processing error
+	*/
+	IMPORT_C virtual TMTPResponseCode SendObjectInfoL(const CMTPTypeObjectInfo& aObjectInfo, TUint32& aParentHandle, TDes& aSuid);
+	/**
+	Dispatch GetObjectInfoL to object handler
+	@param aObjectMetaData Specify the getting object's metadata, including suid, objecthandle etc.
+	@param aObjectInfo The returned ObjectInfo dataset.
+	@return See MTP response code definition
+	@leave One of the system wide error codes, if a general processing error
+	*/
+	IMPORT_C virtual TMTPResponseCode GetObjectInfoL(const CMTPObjectMetaData& aObjectMetaData, CMTPTypeObjectInfo& aObjectInfo);
+	/**
+	Dispatch SendObjectPropList to object handler
+	@param aObjectSize The new object size specified in the MTP request
+	@param aObjectPropList Provide info for dp to create object
+	@param aParentHandle Specify the new object's parent handle, dp can change the handler if necessary.
+	@param aSuid Concrete object handler need set the parameter with new created object suid
+	@return See MTP response code definition
+	@leave One of the system wide error codes, if a general processing error
+	*/
+	virtual TMTPResponseCode SendObjectPropListL(TUint64 aObjectSize, const CMTPTypeObjectPropList& aObjectPropList, 
+												TUint32& aParentHandle, TDes& aSuid) = 0;
+	/**
+	Dispatch GetObjectPropListL to object handler, handler only need append the specified object prop code's info.
+	@param aObjectMetaData Specify the getting object's metadata, including suid, objecthandle etc.
+	@param aPropList The returned ObjectPropList dataset.
+	@param aPropertyCode Specify which object property need to be gotten
+	@return See MTP response code definition
+	@leave One of the system wide error codes, if a general processing error
+	*/
+	virtual TMTPResponseCode GetObjectPropertyL(const CMTPObjectMetaData& aObjectMetaData, TUint16 aPropertyCode, CMTPTypeObjectPropList& aPropList) = 0;
+	/**
+	Set a property value of object with concrete object handler
+	@param aSuid Specify the object's suid which will be used by object handle to find the concrete object
+	@param element include the object's property information, including ObjectHandle, PropertyCode, Datatype and Value
+	@param aOperationCode Used to distinguish if the property can be changed by specified operation or not.
+	@return See MTP response code definition
+	@leave One of the system wide error codes, if a general processing error
+	*/
+	virtual TMTPResponseCode SetObjectPropertyL(const TDesC& aSuid, const CMTPTypeObjectPropListElement& aElement, TMTPOperationCode aOperationCode) = 0;
+	/**
+	Dispatch DeleteObjectPropertyL to object handler
+	@param aObjectMetaData Specify the deleting object's metadata, including suid, objecthandle etc.
+	@param aPropertyCode The property code which need to be deleted.
+	@return See MTP response code definition
+	@leave One of the system wide error codes, if a general processing error
+	*/
+	virtual TMTPResponseCode DeleteObjectPropertyL(const CMTPObjectMetaData& aObjectMetaData, TUint16 aPropertyCode) = 0;
+	/**
+	Dispatch GetBufferForSendObjectL to object handler, the function used to get a buffer which 
+	allocated by concrete object handler for the setting object
+	@param aObjectMetaData the new object's metadata, including suid, objecthandle etc.
+	@param aBuffer The new buffer allocated by object handler
+	@return See MTP response code definition
+	@leave One of the system wide error codes, if a general processing error
+	*/
+	virtual TMTPResponseCode GetBufferForSendObjectL(const CMTPObjectMetaData& aObjectMetaData, MMTPType** aBuffer) = 0;
+	/**
+	Dispatch GetObjectL to object handler. the object handler will allocate a new buffer for the object,
+	it will be released by ReleaseObjectBuffer when the request processing is end.
+	@param aObjectMetaData Specify the getting object's metadata, including suid, objecthandle etc.
+	@param aBuffer The object's content.
+	@return See MTP response code definition
+	@leave One of the system wide error codes, if a general processing error
+	*/
+	virtual TMTPResponseCode GetObjectL(const CMTPObjectMetaData& aObjectMetaData, MMTPType** aBuffer) = 0;
+	/**
+	Delete an object with specified parameters
+	@param aObjectMetaData Specify the deleting object's metadata, including suid, objecthandle etc.
+	@return See MTP response code definition
+	@leave One of the system wide error codes, if a general processing error
+	*/
+	virtual TMTPResponseCode DeleteObjectL(const CMTPObjectMetaData& aObjectMetaData) = 0;
+	/**
+	Dispatch SetObjectReferenceL to object handler. the object handler will set reference for specified handle,
+	it will be released by ReleaseObjectBuffer when the request processing is end.
+	@param aObjectMetaData object need to be set refence.
+	@param aReferences reference array.
+	@return See MTP response code definition
+	@leave One of the system wide error codes, if a general processing error
+	*/
+	IMPORT_C virtual TMTPResponseCode SetObjectReferenceL(const CMTPObjectMetaData& aObjectMetaData, const CMTPTypeArray& aReferences);
+	/**
+	Dispatch GetObjectReferenceL to object handler. the object handler will fetch the specified object's reference array,
+	it will be released by ReleaseObjectBuffer when the request processing is end.
+	@param aObjectMetaData object need to get refence.
+	@param aReferences reference array.
+	@return See MTP response code definition
+	@leave One of the system wide error codes, if a general processing error
+	*/
+	IMPORT_C virtual TMTPResponseCode GetObjectReferenceL(const CMTPObjectMetaData& aObjectMetaData, CMTPTypeArray& aReferences);
+	/**
+	Dispatch CopyObject to object handler. This operation causes the device to create a copy of the target object and place 
+	that copy in a location that is indicated by the parameters of this operation.
+	@param aObjectMetaData Specify the getting object's metadata, including suid, objecthandle etc.
+	@param aDestStorageId StorageID that the newly copied object should be placed into.
+	@param aNewParentHandle ObjectHandle of newly copied object’s parent.
+	@return See MTP response code definition
+	@leave One of the system wide error codes, if a general processing error
+	*/
+	IMPORT_C virtual TMTPResponseCode CopyObject(const CMTPObjectMetaData& aObjectMetaData, TUint32 aDestStorageId, TUint32 aNewParentHandle);
+	/**
+	Dispatch MoveObject to object handler. This operation changes the location of an object on the device, by changing the storage on 
+	which it is stored, changing the location in which it is located, or both.
+	@param aObjectMetaData Specify the getting object's metadata, including suid, objecthandle etc.
+	@param aDestStorageId StorageID of store to move object to.
+	@param aNewParentHandle ObjectHandle of the new ParentObject.
+	@return See MTP response code definition
+	@leave One of the system wide error codes, if a general processing error
+	*/
+	IMPORT_C virtual TMTPResponseCode MoveObject(const CMTPObjectMetaData& aObjectMetaData, TUint32 aDestStorageId, TUint32 aNewParentHandle);
+	/**
+	When dp received UpdateObjectPropList, if the dataset don't include object size value, request 
+	processor can use this interface to get object size for the following SendObject.
+	@param aSuid Concrete object handler need set the parameter with new created object suid
+	@param aObjectSize The updating object's size.
+	@return See MTP response code definition
+	*/
+	virtual TMTPResponseCode GetObjectSizeL(const TDesC& aSuid, TUint64& aObjectSize) = 0;
+	/**
+	Commit prevous setted property value
+	@leave One of the system wide error codes, if a general processing error
+	*/
+	IMPORT_C virtual void CommitL();
+	/**
+	Create a new object and commit all cached property value
+	@param aSuid Concrete object handler need set the parameter with new created object suid
+	@leave One of the system wide error codes, if a general processing error
+	*/
+	IMPORT_C virtual void CommitForNewObjectL(TDes& aSuid);
+	/**
+	Rollback setted value for a object, called when SendObject fail or object handler commit fail
+	*/
+	IMPORT_C virtual void RollBack();
+	/**
+	After GetObject called, object handler will allocate a buffer and send to initiator. request processor
+	need call this interface to release the existing buffer.
+	*/
+	IMPORT_C virtual void ReleaseObjectBuffer();
+	/**
+	Get the handler's all supported object prop code with specified group code, if group code is 0, then return
+	all prop codes.
+	@param aGroupId Group id
+	@param aPropCodes Returned object prop code array.
+	@return See MTP response code definition
+	@leave One of the system wide error codes, if a general processing error
+	*/
+	virtual TMTPResponseCode GetAllObjectPropCodeByGroupL(TUint32 aGroupId, RArray<TUint32>& aPropCodes) = 0;
+
+protected:
+	IMPORT_C TMTPResponseCode CheckGenObjectPropertyL(const CMTPTypeObjectPropListElement& element, TMTPOperationCode aOperationCode) const;
+	};
+
+#endif // __MMTPSVCOBJHANDLER_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/mtpdpconst.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,100 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mmtpdpconst.h
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef MTPDPCONST_H
+#define MTPDPCONST_H
+
+#include <mtp/mtpprotocolconstants.h>
+
+/**
+define all the object properties that are supported by the data provider
+@internalTechnology
+*/
+static const TUint16 KMTPDpSupportedProperties[] =
+	{
+	EMTPObjectPropCodeStorageID,
+	EMTPObjectPropCodeObjectFormat,
+	EMTPObjectPropCodeProtectionStatus,
+	EMTPObjectPropCodeObjectSize,
+	EMTPObjectPropCodeObjectFileName,
+	EMTPObjectPropCodeDateModified,
+	EMTPObjectPropCodeParentObject,
+	EMTPObjectPropCodePersistentUniqueObjectIdentifier,
+	EMTPObjectPropCodeName,
+	EMTPObjectPropCodeNonConsumable	
+	};
+
+/**
+Define the supported property number .
+@internalTechnology
+*/
+static const TUint16 KMTPDpPropertyNumber = sizeof(KMTPDpSupportedProperties)/sizeof(KMTPDpSupportedProperties[0]); 
+
+
+/**
+Define the supported property group number .
+@internalTechnology
+*/
+static const TUint16 KMTPDpPropertyGroupNumber = 1; 
+
+/**
+Define the properties groups supported.
+@internalTechnology
+*/
+
+static const TUint16 KMTPDpPropertyGroups[KMTPDpPropertyGroupNumber+1][KMTPDpPropertyNumber] =
+    {
+      	{}, // group 0 is not used.
+      	//               group 1 contains 10 proeprties
+      	{	EMTPObjectPropCodeStorageID,
+			EMTPObjectPropCodeObjectFormat,
+			EMTPObjectPropCodeProtectionStatus,
+			EMTPObjectPropCodeObjectSize,
+			EMTPObjectPropCodeObjectFileName,
+			EMTPObjectPropCodeDateModified,
+			EMTPObjectPropCodeParentObject,
+			EMTPObjectPropCodePersistentUniqueObjectIdentifier,
+			EMTPObjectPropCodeName,
+			EMTPObjectPropCodeNonConsumable	}  
+    };
+
+
+
+/**
+define the granularity from drive list
+@internalTechnology
+*/
+static const TInt KMTPDriveGranularity = 5;
+
+/**
+define the granularity for the exclusion list
+@internalTechnology
+*/
+static const TInt KMTPExclusionListGranularity = 5;
+
+/**
+define the drive root path length
+@internalTechnology
+*/
+static const TInt KMTPDriveLetterPrefixLength = 3; //c:\
+	
+#endif // MTPDPCONST_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/mtpdppanic.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,51 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef MTPDPPANIC_H
+#define MTPDPPANIC_H
+
+#include <e32std.h>
+
+/**
+Defines the MTP Data Provider category panic codes.
+@internalTechnology
+*/
+enum TMTPDpPanic
+	{
+	EMTPDpNoMatchingProcessor = 0,
+	EMTPDpObjectNull = 1,
+	EMTPDpFormatNotSupported = 2,
+	EMTPDpSendObjectStateInvalid = 3,
+	EMTPDpReferencesNull = 4,
+	EMTPDpRequestCheckNull = 5,
+	EMTPDpHandlesNull = 6,
+	EMTPDpUnsupportedProperty = 7,
+	EMTPDpObjectPropertyNull = 8,
+	EMTPDpCannotRenameDir = 9,
+	};
+
+_LIT(KMTPDpPanic, "MTP Data Provider");
+inline void Panic(TMTPDpPanic aCode)
+	{
+	User::Panic(KMTPDpPanic, aCode);
+	};
+	
+
+#endif // MTPDPPANIC_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/mtpsvcdpconst.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,267 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/inc/mtpsvcdpconst.h
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef __MTPSVCDPCONST_H__
+#define __MTPSVCDPCONST_H__
+
+#include <mtp/mtpprotocolconstants.h>
+
+
+/**
+service types defined in MTP
+ */
+typedef enum
+	{
+	EMTPServiceTypeNormal = 0,
+	EMTPServiceTypeAbstract = 1
+	} TMTPServiceType;
+
+/**
+Abstract service types defined in MTP
+ */
+typedef enum
+	{
+	EMTPFullEnumSyncService = 0,
+	EMTPAnchorSyncService
+	} TMTPAbstrctServiceType;
+
+// Service Name definition
+_LIT(KFullEnumServiceName,  "FullEnumSync");
+
+// FullEnum Sync Service GUID, specified by Spec.
+const TUint32 KMTPFullEnumServiceGUID[] = {0x28d3aac9, 0xc07544be, 0x888165f3, 0x8d305909};
+
+// FullEnumm Sync Service Persistent GUID, specified by Symbian/Nokia Implementation.
+const TUint32 KMTPFullEnumServicePSGUID[] = {0x102827A1, 0x00000001, 0x00000000, 0x00000000};
+
+/*
+ Service property definition
+ */
+
+//FullEnum Sync Service Namespace for Service Property, specified by Spec.
+const TUint32 KMTPFullEnumSyncServiceNSGUID[] = {0x63b10e6c, 0x4f3a456d, 0x95cb9894, 0xedec9fa5};
+//SyncSvc Service Namespace for Service Property, specified by Spec.
+const TUint32 KMTPSyncSvcServiceNSGUID[] = {0x703d392c, 0x532c4607, 0x91589cea, 0x742f3a16};
+
+// FullEnum/Anchor Sync service property value definition
+typedef enum
+	{
+	EMTPServicePropertyVersionProps = 0,
+	EMTPServicePropertyReplicaID,
+	EMTPServicePropertyKnowledgeObjectID,
+	EMTPServicePropertyLastSyncProxyID,
+	EMTPServicePropertyProviderVersion,         // In Simulator, it's not supported.
+	EMTPServicePropertySyncFormat,              // In Simulator, it's moved to normal service property
+	EMTPServicePropertyLocalOnlyDelete,
+	EMTPServicePropertyFilterType,
+	EMTPServicePropertySyncObjectReferences,    // In Simulator, it's not supported.
+	EMTPAbstractServicePropertyEnd
+	} TMTPAbstractServiceProperty;
+
+// Define Full Enumeration Sync service property name
+_LIT(KNameFullEnumVersionProps,         "FullEnumVersionProps");
+_LIT(KNameFullEnumReplicaID,            "FullEnumReplicaID");
+_LIT(KNameFullEnumKnowledgeObjectID,    "FullEnumKnowledgeObjectID");
+_LIT(KNameFullEnumLastSyncProxyID,      "FullEnumLastSyncProxyID");
+_LIT(KNameFullEnumProviderVersion,      "FullEnumProviderVersion");
+_LIT(KNameSyncSvcLocalOnlyDelete,       "LocalOnlyDelete");
+_LIT(KNameSyncSvcSyncFormat,            "SyncFormat");
+_LIT(KNameSyncSvcFilterType,            "FilterType");
+_LIT(KNameSyncSvcSyncObjectReferences,  "SyncObjectReferences");
+
+/**
+Abstract service format definition
+ */
+// Define all the abstract service format
+typedef enum
+	{
+	EMTPFormatTypeFullEnumSyncKnowledge,
+	EMTPAbstractFormatTypeEnd
+	} TMTPAbstractServiceFormatType;
+
+_LIT(KNameFullEnumSyncKnowledege, "FullEnumSyncKnowledge");
+_LIT(KNameFullEnumSyncKnowledegeMIMEType, "");
+
+
+/**
+Format property definition
+---------Supported Property Namespaces--------------
+    FullEnum Knowledge Format   : { Generic Object Namespace Properties; }
+ */
+
+// FullEnum Sync Service > Knowledge Format GUID, specified by Spec.
+const TUint32 KMTPFullEnumSyncKnowledgeFormatGUID[] = {0x221bce32, 0x221b4f45, 0xb48b80de, 0x9a93a44a};
+
+// Generic Object Namespace GUID for Service Format, specified by Spec.
+const TUint32 KMTPGenericObjectNSGUID[] = {0xEF6B490D, 0x5CD8437A, 0xAFFCDA8B, 0x60EE4A3C};
+
+//Sync Object Namespace for Service Format, specified by Spec. Current this value comes from Simulator.
+const TUint32 KMTPSyncObjcetNSGUID[] = {0x37364f58, 0x2f744981, 0x99a57ae2, 0x8aeee319};
+
+// Generic Object Namespace prop code value defnition
+typedef enum
+	{
+	EMTPGenObjPropCodeParentID             = EMTPObjectPropCodeParentObject,
+	EMTPGenObjPropCodeName                 = EMTPObjectPropCodeName,
+	EMTPGenObjPropCodePersistentUniqueObjectIdentifier = EMTPObjectPropCodePersistentUniqueObjectIdentifier,
+	EMTPGenObjPropCodeObjectFormat         = EMTPObjectPropCodeObjectFormat,
+	EMTPGenObjPropCodeObjectSize           = EMTPObjectPropCodeObjectSize,
+	EMTPGenObjPropCodeStorageID            = EMTPObjectPropCodeStorageID,
+	EMTPGenObjPropCodeObjectHidden         = EMTPObjectPropCodeHidden,
+	EMTPGenObjPropCodeNonConsumable        = EMTPObjectPropCodeNonConsumable,
+	EMTPGenObjPropCodeDateModified         = EMTPObjectPropCodeDateModified,
+	// LastAuthorProxyID is from Simulator, and is not a Generic Object property. For conveniency, put it here.
+	EMTPSvcObjPropCodeLastAuthorProxyID    = EMTPObjectPropCodeVendorExtensionStart + 1,
+	} TMTPGenericObjectProperty;
+
+// Normal service Object Extension definition should start with this value
+const TUint16 KMTPNormalServiceObjExtensionStart = EMTPObjectPropCodeVendorExtensionStart + 2;
+
+// Define Generic Object Property name string
+_LIT(KObjPropNameParentID,          "ParentID");
+_LIT(KObjPropNameName,              "Name");
+_LIT(KObjPropNamePUOID,             "PersistentUID");
+_LIT(KObjPropNameObjectFormat,      "ObjectFormat");
+_LIT(KObjPropNameObjectSize,        "ObjectSize");
+_LIT(KObjPropNameStorageID,         "StorageID");
+_LIT(KObjPropNameHidden,            "Hidden");
+_LIT(KObjPropNameNonConsumable,     "NonConsumable");
+_LIT(KObjPropNameDateModified,      "DateModified");
+_LIT(KObjPropNameLastAuthorProxyID, "LastAuthorProxyID");
+
+
+// FullEnum Knowledge Format object prop array
+const TUint16 KMTPFullEnumSyncKnowledgeObjectProperties[] =
+	{
+	EMTPGenObjPropCodeParentID,
+	EMTPGenObjPropCodeName,
+	EMTPGenObjPropCodePersistentUniqueObjectIdentifier,
+	EMTPGenObjPropCodeObjectFormat,
+	EMTPGenObjPropCodeObjectSize,
+	EMTPGenObjPropCodeStorageID,
+	EMTPGenObjPropCodeObjectHidden,
+	EMTPGenObjPropCodeNonConsumable,
+	EMTPGenObjPropCodeDateModified,
+	EMTPSvcObjPropCodeLastAuthorProxyID // Simulator defined
+	};
+
+
+/*
+Value Range definition
+ */
+// Enum value describing type of hidden.
+typedef enum 
+	{
+	EMTPUnInitialized                 = 0xFF,
+	EMTPGenObjNotHidden               = 0,
+	EMTPGenObjHidden                  = 1
+	} TMTPGenObjHidden;
+
+// Enum value describing type of the filter
+typedef enum
+	{
+	EMTPSyncSvcFilterNone                         = 0,
+	EMTPSyncSvcFilterContactsWithPhone            = 1,
+	EMTPSyncSvcFilterTaskActive                   = 2,
+	EMTPSyncSvcFilterCalendarWindowWithRecurrence = 3,
+	EMTPSyncSvcFilterUnInitialized                = ~0
+	} TMTPSyncSvcFilterType;
+
+// Boolean flag indicating whether deletion of objects on the service host
+// should be treated as "local only" and not propogated to other sync
+// participants.  The alternative is "true sync" in which deletes on the
+// service host are propogated to all other sync participants.
+typedef enum
+	{
+	EMTPLocalOnlyDeleteFalse          = 0,
+	EMTPLocalOnlyDeleteTrue           = 1,
+	EMTPLocalOnlyDeleteUnInitialized  = ~0
+	} TMTPSyncSvcLocalOnlyDelete;
+
+// Boolean flag describing whether object references should be included
+// as part of the sync process or not.
+typedef enum
+	{
+	EMTPSyncObjectReferencesDisabled = 0x00,
+	EMTPSyncObjectReferencesEnabled  = 0xFF
+	} TMTPSyncSvcSyncObjectReferences;
+
+
+/*
+Simple const value definition
+ */
+// Define abstract service info const variable
+_LIT(KMTPExtension, "microsoft.com/DeviceServices: 1.0");
+
+// the default value of BaseFormat in service info dataset
+const TUint16 KBaseFormatCode = 0x00;
+
+// the default value of ServiceVersion in service info dataset
+const TUint32 KMTPDefaultServiceVersion = 0x64;
+
+// the default value of ProviderVersion in service property, 0 is reserved, so start from 1.
+const TUint32 KMTPDefaultProviderVersion = 0x01;
+
+// the default value of ServiceType in service info dataset
+// 0 if standard service. 1 if abstract
+const TUint32 KMTPDefaultServiceType   = 0x00;
+
+// the default value of BaseServiceID in service info dataset
+const TUint32 KMTPDefaultBaseServiceID = 0x00;
+
+// the value in spec. to sepcify to do some operation on all service properties.
+const TUint32 KMTPServicePropertyAll = 0x00000000;
+
+const TUint32 KMTPUnInitialized32 = 0xFFFFFFFF;
+const TUint32 KMaxSUIDLength = 50;
+const TUint64 KObjectSizeNotAvaiable = ~0;
+const TUint32 KLongStringMaxLength = 0x1000;
+
+//---------------------------------------------------------------
+// the old names, It'd better be renamed.
+
+// Knowledge object prop array Group 2
+const TUint16 KMTPKnowledgeObjectPropertiesGroup2[] =
+	{
+	EMTPGenObjPropCodeParentID,
+	EMTPGenObjPropCodePersistentUniqueObjectIdentifier,
+	EMTPGenObjPropCodeObjectFormat,
+	EMTPGenObjPropCodeObjectSize,
+	EMTPGenObjPropCodeStorageID,
+	EMTPGenObjPropCodeObjectHidden,
+	EMTPGenObjPropCodeDateModified,
+	EMTPSvcObjPropCodeLastAuthorProxyID
+	};
+// Knowledge object prop array Group 5
+const TUint16 KMTPKnowledgeObjectPropertiesGroup5[] =
+	{
+	EMTPGenObjPropCodeName
+	};
+
+// Knowledge object prop array Group 1
+const TUint16 KMTPKnowledgeObjectPropertiesGroup1[] =
+	{
+	EMTPGenObjPropCodeNonConsumable
+	};
+
+//---------------------------------------------------------------
+
+#endif // __MTPSVCDPCONST_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/rmtpdpsingletons.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,116 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef RMTPDPSINGLETONS_H
+#define RMTPDPSINGLETONS_H
+
+#include "mtpdebug.h"
+
+#include "rmtputility.h"
+
+class MMTPDataProviderFramework;
+class CMTPDpConfigMgr;
+class CMTPFSExclusionMgr;
+/** 
+Implements the MTP data processor singletons reference manager.
+@internalComponent
+*/
+
+class RMTPDpSingletons
+    {
+public:  
+    IMPORT_C RMTPDpSingletons();  
+
+    IMPORT_C void OpenL(MMTPDataProviderFramework& aFramework);
+    IMPORT_C void Close();
+    
+    IMPORT_C CMTPFSExclusionMgr& ExclusionMgrL() const;
+    IMPORT_C void SetExclusionMgrL(CMTPFSExclusionMgr& aExclusionMgr);
+    
+    IMPORT_C RMTPUtility& MTPUtility() const;
+    
+private:
+    class TExclusionMgrEntry
+    	{
+    public:
+    	CMTPFSExclusionMgr* iExclusionMgr;
+    	TInt iDpId;
+    	
+    	static TInt Compare(const TExclusionMgrEntry& aFirst, const TExclusionMgrEntry& aSecond);
+    	};
+    
+    /**
+    Implements the singletons reference block.
+    */
+    class CSingletons : public CObject
+        {
+    public: 
+
+        static CSingletons& OpenL(MMTPDataProviderFramework& aFramework);
+        void Close();
+
+    private: // From CObject
+
+    private:
+
+        static CSingletons* NewL(MMTPDataProviderFramework& aFramework);
+        virtual ~CSingletons();
+        void ConstructL(MMTPDataProviderFramework& aFramework);
+
+    public: // Owned
+
+        /**
+        FLOGGER debug trace member variable.
+        */
+        __FLOG_DECLARATION_MEMBER_MUTABLE;
+            
+    	
+    	/**
+    	The file system exclusion manager list. This list contains all the Data Providers'
+    	file system exclusion manager associated with its Data Provider ID. only a single one will 
+    	be used corresponding to the Data Provider ID.
+    	*/
+    	RArray<TExclusionMgrEntry>	iExclusionList;
+    	
+    	/*
+    	 * The utility for DPutility 
+    	 */
+    	RMTPUtility					iMTPUtility;
+      };
+      
+private: //Not owned
+	/**
+	Reference to data provider framework.
+	*/
+	MMTPDataProviderFramework* iFramework;
+    
+private: // Owned
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    /**
+    The singletons reference block.
+    */
+    CSingletons*    iSingletons;
+};
+
+#endif // RMTPDPSINGLETONS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/rmtputility.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,81 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+
+#ifndef RMTPUTILITY_H_
+#define RMTPUTILITY_H_
+
+#include <e32std.h> 
+#include <e32base.h>
+#include <badesca.h>
+#include <mtp/mtpprotocolconstants.h>
+#include "rmtpframework.h"
+#include "mtpdebug.h"
+
+class MMTPDataProviderFramework;
+class CMTPObjectMetaData;
+class CMTPExtensionMapping;
+
+class RMTPUtility
+	{
+public:
+	RMTPUtility();
+	
+    void OpenL(MMTPDataProviderFramework& aFramework);
+    void Close();
+    
+public:
+	IMPORT_C TBool TTime2MTPTimeStr(const TTime& aTime, TDes& aRet ) const;
+	IMPORT_C TBool MTPTimeStr2TTime(const TDesC& aTimeString, TTime& aRet) const;
+	IMPORT_C void RenameObjectL( TUint aObjectHandle, const TDesC& aNewName );
+	IMPORT_C HBufC* ContainerMimeType( const TDesC& aFullPath );
+	IMPORT_C TMTPFormatCode FormatFromFilename( const TDesC& aFullFileName );
+	IMPORT_C void FormatExtensionMapping();
+	IMPORT_C TMTPFormatCode GetFormatByExtension(const TDesC& aExtension);
+	IMPORT_C TUint32 GetDpId(const TDesC& aExtension,const TDesC& aMIMEType);
+    IMPORT_C TUint GetEnumerationFlag(const TDesC& aExtension);	
+	
+private:
+	void RenameAllChildrenL(TUint32 aStorageId, TUint32 aParentHandle, const TDesC& aNewFolderName, const TDesC& aOldFolderName);
+	TBool GetYear(const TDesC& aTimeString, TInt& aYear) const;
+	TBool GetMonth(const TDesC& aTimeString, TMonth& aMonth) const;
+	TBool GetDay(const TDesC& aTimeString, TInt& aDay) const;
+	TBool GetHour(const TDesC& aTimeString, TInt& aHour) const;
+	TBool GetMinute(const TDesC& aTimeString, TInt& aMinute) const;
+	TBool GetSecond(const TDesC& aTimeString, TInt& aSecond) const;
+	TBool GetTenthSecond(const TDesC& aTimeString, TInt& aTenthSecond) const;
+	TBool GetTimeZone(const TDesC& aTimeString, TBool& aPositiveTimeZone, TInt& aTimeZoneInHour, TInt& aTimeZoneInMinute) const;
+	HBufC* OdfMimeTypeL( const TDesC& aFullFileName );
+	void AppendFormatExtensionMapping(const CDesCArray& aFormatExtensionMapping,TUint32 aDpId);
+	
+	
+private:
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+	MMTPDataProviderFramework*  iFramework;
+	RMTPFramework				iSingleton;
+    RPointerArray<CMTPExtensionMapping> iFormatMappings;
+    
+	};
+
+#endif /* RMTPUTILITY_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpabstractdatacodemgr.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,204 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpdataproviders/mtpcontactdp/src/CMTPFullEnumDataCodeMgr.cpp
+
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpdatacodegenerator.h>
+
+#include "cmtpabstractdatacodemgr.h"
+
+__FLOG_STMT(_LIT8(KComponent, "FullEnumDataCodeMgr");)
+
+EXPORT_C RMTPServiceFormat::~RMTPServiceFormat()
+	{
+	iProps.Close();
+	}
+
+EXPORT_C TInt TMTPServicePropertyInfo::LinearOrderServicePropOrder(const TMTPServicePropertyInfo& aLhs, const TMTPServicePropertyInfo& aRhs)
+	{
+	return aLhs.iServicePropCode - aRhs.iServicePropCode;
+	}
+
+EXPORT_C TInt TMTPServicePropertyInfo::LinearOrderServicePropOrder(const TUint16* aServicePropCode, const TMTPServicePropertyInfo& aObject)
+	{
+	return (*aServicePropCode - aObject.iServicePropCode);
+	}
+
+EXPORT_C TBool RMTPServiceFormat::FormatRelation(const TUint16* aFormatCode, const RMTPServiceFormat& aObject)
+	{
+	return *aFormatCode == aObject.iFormatCode;
+	}
+
+EXPORT_C CMTPFullEnumDataCodeMgr* CMTPFullEnumDataCodeMgr::NewL(MMTPDataProviderFramework& aFramework)
+	{
+	CMTPFullEnumDataCodeMgr* self = new(ELeave) CMTPFullEnumDataCodeMgr(aFramework);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+
+EXPORT_C CMTPFullEnumDataCodeMgr::~CMTPFullEnumDataCodeMgr()
+	{
+	__FLOG(_L8("~CMTPFullEnumDataCodeMgr - Entry"));
+	delete iKnowledgeFormat;
+	iServiceProperties.Close();
+	__FLOG(_L8("~CMTPFullEnumDataCodeMgr - Exit"));
+	__FLOG_CLOSE;
+	}
+
+CMTPFullEnumDataCodeMgr::CMTPFullEnumDataCodeMgr(MMTPDataProviderFramework& aFramework) :
+		iFramework(aFramework),
+		iServiceGUID(MAKE_TUINT64(KMTPFullEnumServiceGUID[0], KMTPFullEnumServiceGUID[1]),
+					 MAKE_TUINT64(KMTPFullEnumServiceGUID[2], KMTPFullEnumServiceGUID[3])),
+		iPersistentServiceGUID(MAKE_TUINT64(KMTPFullEnumServicePSGUID[0], KMTPFullEnumServicePSGUID[1]),
+							   MAKE_TUINT64(KMTPFullEnumServicePSGUID[2], KMTPFullEnumServicePSGUID[3]))
+	{
+	}
+
+void CMTPFullEnumDataCodeMgr::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry"));
+	BuildServiceIDL();
+	BuildFormatL();
+	BuildServicePropertyL();
+	__FLOG(_L8("ConstructL - Exit"));
+	}
+
+EXPORT_C TUint CMTPFullEnumDataCodeMgr::ServiceID() const
+	{
+	return iServiceID;
+	}
+
+EXPORT_C const TMTPTypeGuid& CMTPFullEnumDataCodeMgr::ServiceGUID() const
+	{
+	return iServiceGUID;
+	}
+
+void CMTPFullEnumDataCodeMgr::BuildServiceIDL()
+	{
+	__FLOG(_L8("BuildServiceIDL - Entry"));
+	//Allocate abstract service ID
+	User::LeaveIfError(iFramework.DataCodeGenerator().AllocateServiceID(
+						   iPersistentServiceGUID,
+						   EMTPServiceTypeAbstract,
+						   iServiceID));
+	__FLOG(_L8("BuildServiceIDL - Exit"));
+	}
+
+void CMTPFullEnumDataCodeMgr::BuildFormatL()
+	{
+	__FLOG(_L8("BuildFormatL - Entry"));
+
+
+	iKnowledgeFormat = new(ELeave) RMTPServiceFormat;
+	iKnowledgeFormat->iIndex = EMTPFormatTypeFullEnumSyncKnowledge;
+	iKnowledgeFormat->iFormatCode = 0;
+	const TMTPTypeGuid KMTPKnowledgeFormatGUID(
+		MAKE_TUINT64(KMTPFullEnumSyncKnowledgeFormatGUID[0], KMTPFullEnumSyncKnowledgeFormatGUID[1]),
+		MAKE_TUINT64(KMTPFullEnumSyncKnowledgeFormatGUID[2], KMTPFullEnumSyncKnowledgeFormatGUID[3]));
+	iKnowledgeFormat->iFormatGUID = KMTPKnowledgeFormatGUID;
+	iKnowledgeFormat->iBaseFormatCode = KBaseFormatCode;
+	iKnowledgeFormat->iFormatName.Set(KNameFullEnumSyncKnowledege());
+	iKnowledgeFormat->iMIMEType.Set(KNameFullEnumSyncKnowledegeMIMEType());
+	User::LeaveIfError(iFramework.DataCodeGenerator().AllocateServiceFormatCode(
+						   iPersistentServiceGUID,
+						   iKnowledgeFormat->iFormatGUID,
+						   iKnowledgeFormat->iFormatCode));
+	TUint propertyCount = sizeof(KMTPFullEnumSyncKnowledgeObjectProperties) / sizeof(KMTPFullEnumSyncKnowledgeObjectProperties[0]);
+	for (TUint j = 0; j < propertyCount; j++)
+		{
+		iKnowledgeFormat->iProps.AppendL(KMTPFullEnumSyncKnowledgeObjectProperties[j]);
+		}
+
+	__FLOG(_L8("BuildFormatL - Exit"));
+	}
+
+void CMTPFullEnumDataCodeMgr::BuildServicePropertyL()
+	{
+	__FLOG(_L8("BuildServicePropertyL - Entry"));
+
+	const TMTPTypeGuid KMTPFullEnumSyncServiceNamespace(
+		MAKE_TUINT64(KMTPFullEnumSyncServiceNSGUID[0], KMTPFullEnumSyncServiceNSGUID[1]),
+		MAKE_TUINT64(KMTPFullEnumSyncServiceNSGUID[2], KMTPFullEnumSyncServiceNSGUID[3]));
+
+	const TMTPTypeGuid KMTPSyncSvcServiceNamespace(
+		MAKE_TUINT64(KMTPSyncSvcServiceNSGUID[0], KMTPSyncSvcServiceNSGUID[1]),
+		MAKE_TUINT64(KMTPSyncSvcServiceNSGUID[2], KMTPSyncSvcServiceNSGUID[3]));
+
+	// Filtertype only need be allocate once by framework, so put it into abstract service.
+	const TMTPServicePropertyInfo KMTPFullEnumSyncServiceProperties[] =
+		{
+			{EMTPServicePropertyVersionProps,         0, KMTPFullEnumSyncServiceNamespace, 3, KNameFullEnumVersionProps()},
+		{EMTPServicePropertyReplicaID,            0, KMTPFullEnumSyncServiceNamespace, 4, KNameFullEnumReplicaID()},
+		{EMTPServicePropertyKnowledgeObjectID,    0, KMTPFullEnumSyncServiceNamespace, 7, KNameFullEnumKnowledgeObjectID()},
+		{EMTPServicePropertyLastSyncProxyID,      0, KMTPFullEnumSyncServiceNamespace, 8, KNameFullEnumLastSyncProxyID()},
+		{EMTPServicePropertyProviderVersion,      0, KMTPFullEnumSyncServiceNamespace, 9, KNameFullEnumProviderVersion()},
+		{EMTPServicePropertySyncFormat,           0, KMTPSyncSvcServiceNamespace,      2, KNameSyncSvcSyncFormat()},
+		{EMTPServicePropertyLocalOnlyDelete,      0, KMTPSyncSvcServiceNamespace,      3, KNameSyncSvcLocalOnlyDelete()},
+		{EMTPServicePropertyFilterType,           0, KMTPSyncSvcServiceNamespace,      4, KNameSyncSvcFilterType()},
+		{EMTPServicePropertySyncObjectReferences, 0, KMTPSyncSvcServiceNamespace,      5, KNameSyncSvcSyncObjectReferences()}
+		};
+
+	TUint propCount = sizeof(KMTPFullEnumSyncServiceProperties) / sizeof(KMTPFullEnumSyncServiceProperties[0]);
+
+	for (TUint i = 0; i < propCount; i++)
+		{
+		TMTPServicePropertyInfo servicePropertyInfo = KMTPFullEnumSyncServiceProperties[i];
+		User::LeaveIfError(iFramework.DataCodeGenerator().AllocateServicePropertyCode(iPersistentServiceGUID,
+						   servicePropertyInfo.iServicePropPKeyNamespace, servicePropertyInfo.iServicePropPKeyID, servicePropertyInfo.iServicePropCode));
+		iServiceProperties.InsertInOrder(servicePropertyInfo, TMTPServicePropertyInfo::LinearOrderServicePropOrder);
+		}
+
+	__FLOG(_L8("BuildServicePropertyL - Exit"));
+	}
+
+EXPORT_C void CMTPFullEnumDataCodeMgr::GetSevicePropCodesL(RArray<TUint32>& aArray) const
+	{
+	__FLOG(_L8("GetSevicePropCodesL - Entry"));
+	TInt count = iServiceProperties.Count();
+	for (TInt i = 0; i < count; i++)
+		{
+		aArray.AppendL(iServiceProperties[i].iServicePropCode);
+		}
+	__FLOG(_L8("GetSevicePropCodesL - Exit"));
+	}
+
+EXPORT_C const RMTPServiceFormat& CMTPFullEnumDataCodeMgr::KnowledgeFormat() const
+	{
+	// only Knowledge Format supported in FullEnum Sync Service
+	__ASSERT_DEBUG((iKnowledgeFormat != NULL), User::Invariant());
+	return *iKnowledgeFormat;
+	}
+
+/**
+The property code must be valid to call this func
+*/
+EXPORT_C const TMTPServicePropertyInfo* CMTPFullEnumDataCodeMgr::ServicePropertyInfo(TUint16 aPropCode) const
+	{
+	__FLOG(_L8("ServicePropertyInfo - Entry"));
+	const TMTPServicePropertyInfo* pPropInfo = NULL;
+	TInt index = iServiceProperties.FindInOrder(aPropCode, TMTPServicePropertyInfo::LinearOrderServicePropOrder);
+	if (KErrNotFound != index)
+		{
+		pPropInfo = &(iServiceProperties[index]);
+		}
+	__FLOG(_L8("ServicePropertyInfo - Exit"));
+	return pPropInfo;
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpcommonrequestprocessor.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,92 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpcommonrequestprocessor.h"
+#include "mtpdppanic.h"
+
+
+/**
+Two-phase construction method
+@param aPlugin The data provider plugin
+@param aFramework The data provider framework
+@param aConnection The connection from which the request comes
+@return a pointer to the created request processor object
+*/    
+EXPORT_C MMTPRequestProcessor* CMTPCommonRequestProcessor ::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, TMTPResponseCode aResponseCode, TBool aHasIToRDataPhase)
+    {
+    CMTPCommonRequestProcessor * self = new (ELeave) CMTPCommonRequestProcessor (aFramework, aConnection, aResponseCode, aHasIToRDataPhase);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);    
+    return self;
+    }
+
+/**
+Destructor
+*/    
+EXPORT_C CMTPCommonRequestProcessor ::~CMTPCommonRequestProcessor ()
+    {
+    delete iIToRData;
+    }
+
+/**
+Standard c++ constructor
+*/    
+CMTPCommonRequestProcessor ::CMTPCommonRequestProcessor (MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, TMTPResponseCode aResponseCode, TBool aHasIToRDataPhase)
+    :CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
+     iResponseCode(aResponseCode), iHasIToRDataPhase(aHasIToRDataPhase)
+    {
+    
+    }
+
+void CMTPCommonRequestProcessor ::ConstructL ()
+    {
+    if (iHasIToRDataPhase)
+        {
+        iIToRData = CMTPTypeTrivialData::NewL();
+        }
+    }
+
+/**
+GetReferences request handler
+*/    
+void CMTPCommonRequestProcessor ::ServiceL()
+    {
+    if (HasDataphase())
+        {
+        __ASSERT_DEBUG(iIToRData, Panic(EMTPDpObjectNull));
+        ReceiveDataL(*iIToRData);
+        }
+    else
+        {
+        SendResponseL(iResponseCode);
+        }
+    }
+
+TBool CMTPCommonRequestProcessor::DoHandleResponsePhaseL()
+    {
+    SendResponseL(iResponseCode);
+    return EFalse;
+    }
+
+TBool CMTPCommonRequestProcessor::HasDataphase() const
+    {
+    return iHasIToRDataPhase;
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpcopyobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,344 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <f32file.h>
+#include <bautils.h>
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/cmtptypestring.h>
+
+#include "cmtpcopyobject.h"
+#include "mtpdppanic.h"
+
+__FLOG_STMT(_LIT8(KComponent,"CopyObject");)
+
+/**
+Verification data for the CopyObject request
+*/
+const TMTPRequestElementInfo KMTPCopyObjectPolicy[] = 
+    {
+    	{TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrFileOrDir, 0, 0, 0},   	
+        {TMTPTypeRequest::ERequestParameter2, EMTPElementTypeStorageId, EMTPElementAttrWrite, 0, 0, 0},                
+        {TMTPTypeRequest::ERequestParameter3, EMTPElementTypeObjectHandle, EMTPElementAttrDir | EMTPElementAttrWrite, 1, 0, 0}
+    };
+
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/     
+EXPORT_C MMTPRequestProcessor* CMTPCopyObject::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+	{
+	CMTPCopyObject* self = new (ELeave) CMTPCopyObject(aFramework, aConnection);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);	
+	return self;
+	}
+
+
+/**
+Destructor
+*/	
+EXPORT_C CMTPCopyObject::~CMTPCopyObject()
+	{	
+	delete iDest;
+	delete iFileMan;
+
+	__FLOG_CLOSE;
+	}
+
+/**
+Standard c++ constructor
+*/	
+CMTPCopyObject::CMTPCopyObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+	CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPCopyObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPCopyObjectPolicy)
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	}
+
+
+/**
+CopyObject request handler
+*/		
+void CMTPCopyObject::ServiceL()
+	{	
+	TUint32 handle = KMTPHandleNone;
+	TMTPResponseCode responseCode = CopyObjectL(handle);
+	if(responseCode == EMTPRespCodeOK)
+		{
+		SendResponseL(EMTPRespCodeOK, 1, &handle);
+		}
+	else
+		{
+		SendResponseL(responseCode);
+		}
+	}
+
+
+/**
+ Second phase constructor
+*/
+void CMTPCopyObject::ConstructL()
+    {
+
+    }
+
+	
+/**
+A helper function of CopyObjectL.
+@param aNewFileName the new full filename after copy.
+@return objectHandle of new copy of object.
+*/
+TUint32 CMTPCopyObject::CopyFileL(const TDesC& aNewFileName)
+	{
+	__FLOG(_L8("CopyFileL - Entry"));
+	const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
+	GetPreviousPropertiesL(suid);
+	User::LeaveIfError(iFileMan->Copy(suid, *iDest));
+	SetPreviousPropertiesL(aNewFileName);
+	
+	TUint32 handle = UpdateObjectInfoL(aNewFileName);
+	
+	__FLOG(_L8("CopyFileL - Exit"));
+	
+	return handle;
+	}
+
+/**
+A helper function of CopyObjectL.
+@param aNewFolderName the new full file folder name after copy.
+@return objecthandle of new copy of the folder.
+*/
+TUint32 CMTPCopyObject::CopyFolderL(const TDesC& aNewFolderName)
+	{
+	__FLOG(_L8("CopyFolderL - Entry"));
+	const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
+	TUint32 handle;
+	if (iObjectInfo->Uint(CMTPObjectMetaData::EDataProviderId) == iFramework.DataProviderId())
+		{
+		GetPreviousPropertiesL(suid);
+		User::LeaveIfError(iFramework.Fs().MkDir(aNewFolderName));
+		SetPreviousPropertiesL(aNewFolderName);	
+		handle = UpdateObjectInfoL(aNewFolderName);
+		}
+	else
+		{
+		handle = iFramework.ObjectMgr().HandleL(aNewFolderName);
+		}
+	__FLOG(_L8("CopyFolderL - Exit"));
+	return handle;
+	}
+		
+/**
+Copy object operation
+@return the object handle of the resulting object.
+*/
+TMTPResponseCode CMTPCopyObject::CopyObjectL(TUint32& aNewHandle)
+	{
+	__FLOG(_L8("CopyObjectL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	aNewHandle = KMTPHandleNone;
+	
+	GetParametersL();
+			
+	RBuf newObjectName;
+	newObjectName.CleanupClosePushL();
+	newObjectName.CreateL(KMaxFileName);
+	newObjectName = *iDest;
+	
+	const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
+	TParsePtrC fileNameParser(suid);
+	
+	// Check if the object is a folder or a file.
+	TBool isFolder = EFalse;
+	User::LeaveIfError(BaflUtils::IsFolder(iFramework.Fs(), suid, isFolder));	
+	
+	if(!isFolder)
+		{
+		if((newObjectName.Length() + fileNameParser.NameAndExt().Length()) <= newObjectName.MaxLength())
+			{
+			newObjectName.Append(fileNameParser.NameAndExt());
+			}
+		}
+	else // It is a folder.
+		{
+		TFileName rightMostFolderName;
+		User::LeaveIfError(BaflUtils::MostSignificantPartOfFullName(suid, rightMostFolderName));
+		if((newObjectName.Length() + rightMostFolderName.Length() + 1) <= newObjectName.MaxLength())
+			{
+			newObjectName.Append(rightMostFolderName);
+			// Add backslash.
+			_LIT(KBackSlash, "\\");
+			newObjectName.Append(KBackSlash);
+			}
+		}
+	responseCode = CanCopyObjectL(suid, newObjectName);    
+	if(responseCode == EMTPRespCodeOK)
+		{			
+		delete iFileMan;
+		iFileMan = NULL;
+		iFileMan = CFileMan::NewL(iFramework.Fs());
+		
+		if(!isFolder) // It is a file.
+			{
+			aNewHandle = CopyFileL(newObjectName);
+			}
+		else // It is a folder.
+			{
+			aNewHandle = CopyFolderL(newObjectName);
+			}
+		}
+	
+	CleanupStack::PopAndDestroy(); // newObjectName.
+	__FLOG(_L8("CopyObjectL - Exit"));
+	return responseCode;
+	}
+
+/**
+Retrieve the parameters of the request
+*/	
+void CMTPCopyObject::GetParametersL()
+	{
+	__FLOG(_L8("GetParametersL - Entry"));
+	__ASSERT_DEBUG(iRequestChecker, Panic(EMTPDpRequestCheckNull));
+	
+	TUint32 objectHandle  = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+	iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+	TUint32 parentObjectHandle  = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
+	
+	//not taking owernship
+	iObjectInfo = iRequestChecker->GetObjectInfo(objectHandle); 
+	__ASSERT_DEBUG(iObjectInfo, Panic(EMTPDpObjectNull));	
+
+	if(parentObjectHandle == 0)
+		{
+		SetDefaultParentObjectL();
+		}
+	else	
+		{
+		CMTPObjectMetaData* parentObjectInfo = iRequestChecker->GetObjectInfo(parentObjectHandle);
+		__ASSERT_DEBUG(parentObjectInfo, Panic(EMTPDpObjectNull));
+		delete iDest;
+		iDest = NULL;
+		iDest = parentObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocL();
+		iNewParentHandle = parentObjectHandle;
+		}
+	__FLOG(_L8("GetParametersL - Exit"));	
+	}
+	
+/**
+Get a default parent object, ff the request does not specify a parent object, 
+*/
+void CMTPCopyObject::SetDefaultParentObjectL()
+	{
+	__FLOG(_L8("SetDefaultParentObjectL - Entry"));
+
+	const CMTPStorageMetaData& storageMetaData( iFramework.StorageMgr().StorageL(iStorageId) );
+	const TDesC& driveBuf( storageMetaData.DesC(CMTPStorageMetaData::EStorageSuid) );
+	delete iDest;
+	iDest = NULL;
+	iDest = driveBuf.AllocL();
+	iNewParentHandle = KMTPHandleNoParent;
+	    
+	__FLOG(_L8("SetDefaultParentObjectL - Exit"));
+	}
+
+/**
+Check if we can copy the file to the new location
+*/
+TMTPResponseCode CMTPCopyObject::CanCopyObjectL(const TDesC& aOldName, const TDesC& aNewName) const
+	{
+	__FLOG(_L8("CanCopyObjectL - Entry"));
+	TMTPResponseCode result = EMTPRespCodeOK;
+
+	TEntry fileEntry;
+	User::LeaveIfError(iFramework.Fs().Entry(aOldName, fileEntry));
+	TInt drive(iFramework.StorageMgr().DriveNumber(iStorageId));
+	User::LeaveIfError(drive);
+	TVolumeInfo volumeInfo;
+	User::LeaveIfError(iFramework.Fs().Volume(volumeInfo, drive));
+	
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+    if(volumeInfo.iFree < fileEntry.FileSize())
+#else
+    if(volumeInfo.iFree < fileEntry.iSize)
+#endif
+		{
+		result = EMTPRespCodeStoreFull;
+		}
+	else if (BaflUtils::FileExists(iFramework.Fs(), aNewName))			
+		{
+		result = EMTPRespCodeInvalidParentObject;
+		}
+	__FLOG_VA((_L8("CanCopyObjectL - Exit with response code 0x%04X"), result));
+	return result;	
+	}
+
+/**
+Save the object properties before doing the copy
+*/
+void CMTPCopyObject::GetPreviousPropertiesL(const TDesC& aFileName)
+	{
+	__FLOG(_L8("GetPreviousPropertiesL - Entry"));
+	User::LeaveIfError(iFramework.Fs().Modified(aFileName, iPreviousModifiedTime));
+	__FLOG(_L8("GetPreviousPropertiesL - Exit"));
+	}
+
+/**
+Set the object properties after doing the copy
+*/
+void CMTPCopyObject::SetPreviousPropertiesL(const TDesC& aFileName)
+	{
+	__FLOG(_L8("SetPreviousPropertiesL - Entry"));
+	User::LeaveIfError(iFramework.Fs().SetModified(aFileName, iPreviousModifiedTime));
+	__FLOG(_L8("SetPreviousPropertiesL - Exit"));
+	}
+
+/**
+ Update object info in the database.
+*/
+TUint32 CMTPCopyObject::UpdateObjectInfoL(const TDesC& aNewObjectName)
+	{
+	__FLOG(_L8("UpdateObjectInfoL - Entry"));	
+	
+	// We should not modify this object's handle, so just get a "copy".
+	CMTPObjectMetaData* objectInfo(CMTPObjectMetaData::NewLC());
+	const TMTPTypeUint32 objectHandle(iObjectInfo->Uint(CMTPObjectMetaData::EHandle));
+	if(iFramework.ObjectMgr().ObjectL(objectHandle, *objectInfo))
+		{
+		objectInfo->SetDesCL(CMTPObjectMetaData::ESuid, aNewObjectName);
+		objectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle);
+		//Modify storage Id.
+		objectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
+		iFramework.ObjectMgr().InsertObjectL(*objectInfo);
+		}
+	else
+		{
+		User::Leave(KErrCorrupt);
+		}
+	TUint32 handle = objectInfo->Uint(CMTPObjectMetaData::EHandle);	
+	CleanupStack::PopAndDestroy(objectInfo);
+	
+	__FLOG(_L8("UpdateObjectInfoL - Exit"));
+	
+	return handle;	
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpdeleteobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,260 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <bautils.h>
+
+#include <mtp/cmtptypearray.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpdeleteobject.h"
+#include "mtpdpconst.h"
+#include "mtpdppanic.h"
+
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"DeleteObject");)
+
+/**
+Verification data for the DeleteObject request
+*/
+const TMTPRequestElementInfo KMTPDeleteObjectPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrWrite, 1, KMTPHandleAll, 0},
+    };
+    
+    
+/**
+Standard c++ constructor
+*/    
+CMTPDeleteObject::CMTPDeleteObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPDeleteObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPDeleteObjectPolicy)
+    {
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("CMTPDeleteObject - Entry"));
+    __FLOG(_L8("CMTPDeleteObject - Exit"));
+    }
+
+
+/**
+Two-phase construction method
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/     
+EXPORT_C MMTPRequestProcessor* CMTPDeleteObject::NewL(MMTPDataProviderFramework& aFramework,
+                                            MMTPConnection& aConnection)
+    {
+    CMTPDeleteObject* self = new (ELeave) CMTPDeleteObject(aFramework, aConnection);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+EXPORT_C CMTPDeleteObject::~CMTPDeleteObject()
+    {
+    __FLOG(_L8("~CMTPDeleteObject - Entry"));
+    __FLOG(_L8("~CMTPDeleteObject - Exit"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Verify the request
+@return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
+*/ 
+
+ 
+TMTPResponseCode CMTPDeleteObject::CheckRequestL()
+	{
+    __FLOG(_L8("CheckRequestL - Entry"));
+	TMTPResponseCode result(EMTPRespCodeOK);
+	if (IsStoreReadOnlyL(Request().Uint32(TMTPTypeRequest::ERequestParameter1)))
+		{
+		result = EMTPRespCodeStoreReadOnly;
+		}
+	else
+		{
+		result = CMTPRequestProcessor::CheckRequestL();
+		}		
+    __FLOG(_L8("CheckRequestL - Exit"));
+	return result;	
+	} 
+	
+void CMTPDeleteObject::DeleteFolderOrFileL(CMTPObjectMetaData* aMeta)
+    {
+    __ASSERT_DEBUG(aMeta, Panic(EMTPDpObjectNull));
+    if (IsFolderObject(*aMeta))
+        {
+        __FLOG( _L8("Delete the folder itself which is empty ") );
+        DeleteFolderL(aMeta);
+        }
+    else
+        {
+        __FLOG(_L8("Going to delete a file.")); 
+        DeleteFileL(aMeta);
+        }
+    ProcessFinalPhaseL();
+    }
+
+void CMTPDeleteObject::DeleteFolderL(CMTPObjectMetaData* aMeta)
+    {
+    TParsePtrC fileNameParser(aMeta->DesC(CMTPObjectMetaData::ESuid));    
+    TInt err = KErrNone;    
+    if ( fileNameParser.IsWild() )
+        {
+        err = KErrBadName;
+        }
+    else
+        {
+        err = iFramework.Fs().RmDir(aMeta->DesC(CMTPObjectMetaData::ESuid));        
+        }
+    
+    if( KErrNone == err )
+        {
+        iFramework.ObjectMgr().RemoveObjectL(aMeta->Uint(CMTPObjectMetaData::EHandle));
+        iSuccessDeletion = ETrue;
+        }
+    
+    }
+
+void CMTPDeleteObject::DeleteFileL(CMTPObjectMetaData* aMeta)
+    {
+    TParsePtrC fileNameParser(aMeta->DesC(CMTPObjectMetaData::ESuid));
+    TInt err = KErrNone;
+    if ( !fileNameParser.NamePresent() )
+        {
+        err = KErrBadName;
+        }
+    else if ( fileNameParser.IsWild() )
+        {
+        err = KErrBadName;
+        }
+    else
+        {
+        err = iFramework.Fs().Delete(aMeta->DesC(CMTPObjectMetaData::ESuid));
+        }
+    
+    if( KErrNone == err )
+        {
+        iFramework.ObjectMgr().RemoveObjectL(aMeta->Uint(CMTPObjectMetaData::EHandle));
+        iSuccessDeletion = ETrue;
+        }
+    else if(KErrAccessDenied == err)
+        {
+        err = KErrBadHandle;
+        iObjectWritePotected = ETrue;
+        }
+    }
+
+/**
+DeleteObject request handler
+*/    
+void CMTPDeleteObject::ServiceL()
+    {
+    __FLOG(_L8("ServiceL - Entry")); 
+	const TUint32 KHandle(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
+	iObjectWritePotected = EFalse;
+	iSuccessDeletion = EFalse;
+	
+	CMTPObjectMetaData* meta = NULL;
+	meta = iRequestChecker->GetObjectInfo(KHandle);
+	__ASSERT_DEBUG(meta, Panic(EMTPDpObjectNull));
+	__FLOG_VA((_L8("meta->Uint(CMTPObjectMetaData::EDataProviderId) is %d"), meta->Uint(CMTPObjectMetaData::EDataProviderId))); 
+	__FLOG_VA((_L8("iFramework.DataProviderId() is %d"), iFramework.DataProviderId())); 
+	
+	if ( meta != NULL && meta->Uint(CMTPObjectMetaData::EDataProviderId) == iFramework.DataProviderId())
+	    {
+	    DeleteFolderOrFileL(meta);
+	    }
+	else
+	    {
+	    SendResponseL(EMTPRespCodeInvalidObjectHandle);
+	    }
+	
+    __FLOG(_L8("ServiceL - Exit")); 
+    }
+
+/**
+Signal to the initiator that the deletion operation has finished with or without error
+*/
+void CMTPDeleteObject::ProcessFinalPhaseL()
+	{
+    __FLOG(_L8("ProcessFinalPhaseL - Entry"));
+	TMTPResponseCode rsp = EMTPRespCodeOK;
+	if ( iObjectWritePotected )
+	    {
+	    rsp = EMTPRespCodeObjectWriteProtected;
+	    }
+	else if ( !iSuccessDeletion )
+	    {
+	    rsp = EMTPRespCodeAccessDenied;
+	    }
+	SendResponseL(rsp);
+    __FLOG(_L8("ProcessFinalPhaseL - Exit"));	
+	}
+	
+/**
+Indicates if the specified object is a generic folder association.
+@param aObject The object meta-data.
+@return ETrue if the specified object is a generic folder association, 
+otherwise EFalse.
+*/
+TBool CMTPDeleteObject::IsFolderObject(const CMTPObjectMetaData& aObject)
+    {
+    return ((aObject.Uint(CMTPObjectMetaData::EFormatCode) == EMTPFormatCodeAssociation) &&
+            (aObject.Uint(CMTPObjectMetaData::EFormatSubCode) == EMTPAssociationTypeGenericFolder));
+    }
+
+/**
+Check whether the store on which the object resides is read only.
+@return ETrue if the store is read only, EFalse if read-write
+*/
+TBool CMTPDeleteObject::IsStoreReadOnlyL(TUint32 aObjectHandle)
+	{
+    __FLOG(_L8("IsStoreReadOnlyL - Entry"));
+	TBool result(EFalse);
+	CMTPObjectMetaData *info(CMTPObjectMetaData::NewLC());
+    if (iFramework.ObjectMgr().ObjectL(aObjectHandle, *info))
+        {
+    	TInt drive(iFramework.StorageMgr().DriveNumber(info->Uint(CMTPObjectMetaData::EStorageId)));
+    	User::LeaveIfError(drive);
+    	TVolumeInfo volumeInfo;
+    	User::LeaveIfError(iFramework.Fs().Volume(volumeInfo, drive));			
+    	if (volumeInfo.iDrive.iMediaAtt == KMediaAttWriteProtected) 
+    		{
+    		result = ETrue;
+    		}
+        }
+	CleanupStack::PopAndDestroy(info);
+    __FLOG(_L8("IsStoreReadOnlyL - Exit"));
+	return result;	
+	}
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpextensionmapping.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,122 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "cmtpextensionmapping.h"
+
+CMTPExtensionMapping* CMTPExtensionMapping::NewL(const TDesC& aExtension, TMTPFormatCode aFormatCode)
+	{
+	CMTPExtensionMapping* self = new (ELeave) CMTPExtensionMapping(aFormatCode);
+	CleanupStack::PushL(self);
+	self->ConstructL(aExtension,KNullDesC);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CMTPExtensionMapping* CMTPExtensionMapping::NewL(const TDesC& aExtension, TMTPFormatCode aFormatCode,const TDesC& aMIMEType)
+    {
+    CMTPExtensionMapping* self = new (ELeave) CMTPExtensionMapping(aFormatCode);
+    CleanupStack::PushL(self);
+    self->ConstructL(aExtension,aMIMEType);
+    CleanupStack::Pop(self);
+    return self;
+    }
+	
+CMTPExtensionMapping::CMTPExtensionMapping(TMTPFormatCode aFormatCode) :
+	iFormatCode(aFormatCode)
+	{
+	}
+	
+void CMTPExtensionMapping::ConstructL(const TDesC& aExtension,const TDesC& aMIMEType)
+    {
+    iExtension = aExtension.AllocL();
+    iMIMEType = aMIMEType.AllocL();
+    }
+	
+CMTPExtensionMapping::~CMTPExtensionMapping()
+	{
+	delete iExtension;
+	delete iMIMEType;
+	}
+	
+const TDesC& CMTPExtensionMapping::Extension() const
+	{
+	return *iExtension;
+	}
+
+const TDesC& CMTPExtensionMapping::MIMEType() const
+    {
+    return *iMIMEType;
+    }
+	
+TMTPFormatCode CMTPExtensionMapping::FormatCode() const
+	{
+	return iFormatCode;
+	}
+
+TUint32 CMTPExtensionMapping::DpId() const
+    {
+    return iDpId;
+    }
+
+TUint CMTPExtensionMapping::EnumerationFlag() const
+    {
+    return iNeedFileDp;
+    }
+
+void CMTPExtensionMapping::SetExtensionL(const TDesC& aExtension)
+	{
+	delete iExtension;
+	iExtension = NULL;
+	
+	iExtension = aExtension.AllocL();	
+	}
+
+void CMTPExtensionMapping::SetMIMETypeL(const TDesC& aMIMEType)
+    {
+    delete iMIMEType;
+    iMIMEType = NULL;
+    
+    iMIMEType = aMIMEType.AllocL();   
+    }
+	
+void CMTPExtensionMapping::SetDpId(const TUint32 aDpId)
+    {
+    iDpId = aDpId;
+    }
+
+void CMTPExtensionMapping::SetFormatCode(const TMTPFormatCode aFormatCode)
+    {
+    iFormatCode = aFormatCode;
+    }
+
+void CMTPExtensionMapping::SetEnumerationFlag(const TUint aNeedFileDp)
+    {
+    iNeedFileDp = aNeedFileDp;
+    }
+
+TInt CMTPExtensionMapping::Compare(const CMTPExtensionMapping& aFirst, const CMTPExtensionMapping& aSecond)
+	{
+	return (aFirst.Extension().CompareF(aSecond.Extension()));
+	}
+
+TInt CMTPExtensionMapping::ComparewithMIME(const CMTPExtensionMapping& aFirst, const CMTPExtensionMapping& aSecond)
+    {
+     TInt i = Compare(aFirst,aSecond);
+     if ( 0==i )
+         {
+         return aFirst.MIMEType().CompareF(aSecond.MIMEType());
+         }
+     return i;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsenumerator.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,606 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <f32file.h>
+#include <bautils.h>
+#include <mtp/cmtpdataproviderplugin.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptypeevent.h>
+#include "cmtpfsexclusionmgr.h"
+#include "cmtpfsenumerator.h"
+#include "mmtpenumerationcallback.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpdataprovider.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"FSEnumerator");)
+
+/**
+ * the files should not be owned by any dp. 
+ */
+#define FILES_OWNED_BY_NONE             0
+
+/**
+ * the missed files of other dps should be owned by file dp
+ */
+#define MISSED_FILES_OWNED_BY_FILE_DP   1
+
+/**
+ * the missed files of other dps should be owned by counterparter dps
+ */
+#define MISSED_FILES_OWNED_BY_OTHER_DP  2
+
+/**
+ * the files of other dps should be owned by counterparter dps
+ */
+#define FILES_OWNED_BY_OTHER_DP         3
+
+/**
+Two-phase construction
+@param aFramework    data provider framework of data provider
+@param aObjectMgr    the reference to the object manager
+@param aExclusionMgr    the reference to the exclusion manager 
+@param aCallback callback to be called when enumeration is complete
+*/
+EXPORT_C CMTPFSEnumerator* CMTPFSEnumerator::NewL(MMTPDataProviderFramework& aFramework, CMTPFSExclusionMgr& aExclusionMgr, MMTPEnumerationCallback& aCallback, TInt aProcessLimit)
+    {
+    CMTPFSEnumerator* self = new (ELeave) CMTPFSEnumerator(aFramework, aExclusionMgr, aCallback, aProcessLimit);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+destructor
+*/    
+EXPORT_C CMTPFSEnumerator::~CMTPFSEnumerator()
+	{
+	Cancel();	
+	iDir.Close();
+	iDirStack.Close();
+	iStorages.Close();
+	iDpSingletons.Close();
+	iSingletons.Close();
+	delete iObject;
+	__FLOG_CLOSE; 
+	}
+
+/**
+Kick off the enumeration on the specified storage
+@param aStorageId storage to be enumerated
+*/
+EXPORT_C void CMTPFSEnumerator::StartL(TUint32 aStorageId)
+	{
+	__ASSERT_DEBUG(!IsActive(), User::Invariant());
+	MMTPStorageMgr& storageMgr(iFramework.StorageMgr());
+	if (aStorageId == KMTPStorageAll)
+	    {
+        // Retrieve the available logical StorageIDs
+        RPointerArray<const CMTPStorageMetaData> storages;
+        CleanupClosePushL(storages);
+        TMTPStorageMgrQueryParams params(KNullDesC, CMTPStorageMetaData::ESystemTypeDefaultFileSystem);
+        storageMgr.GetLogicalStoragesL(params, storages);
+        
+        // Construct the StorageIDs list.
+        const TUint KCount(storages.Count());
+        for (TUint i(0); (i < KCount); i++)
+            {
+            iStorages.Insert(storages[i]->Uint(CMTPStorageMetaData::EStorageId),0);
+            __FLOG_VA((_L8("FileEnumerator is doing storage id = %x\r\n"), storages[i]->Uint(CMTPStorageMetaData::EStorageId) ));
+            }
+        CleanupStack::PopAndDestroy(&storages);
+	    }
+    else if (aStorageId != KMTPNotSpecified32)
+        {
+		__ASSERT_DEBUG(storageMgr.ValidStorageId(aStorageId), User::Invariant());
+		const CMTPStorageMetaData& storage(storageMgr.StorageL(aStorageId));
+		if (storage.Uint(CMTPStorageMetaData::EStorageSystemType) == CMTPStorageMetaData::ESystemTypeDefaultFileSystem)
+		    {
+    	    if (storageMgr.LogicalStorageId(aStorageId))
+    		    {
+    		    // Logical StorageID.
+    			iStorages.AppendL(aStorageId);
+    		    }
+    		else
+    		    {
+    		    // Physical StorageID. Enumerate all eligible logical storages.
+    		    const RArray<TUint>& logicalIds(storage.UintArray(CMTPStorageMetaData::EStorageLogicalIds));
+    		    const TUint KCountLogicalIds(logicalIds.Count());
+                for (TUint i(0); (i < KCountLogicalIds); i++)
+                    {
+                    iStorages.AppendL(logicalIds[i]);
+                    }
+    		    }
+		    }
+		}
+
+	iStorageId = aStorageId;
+	iSkipCurrentStorage = EFalse;
+	
+	if (iStorages.Count() > 0)
+		{
+		 TRAPD(err, ScanStorageL(iStorages[0]));        
+		 if(err != KErrNone)
+			 {
+			 if( !storageMgr.ValidStorageId(iStorages[0]) )
+				 {
+				 //Scan storage leave because storage(memory card) removed.
+				 //Scan next specified storage in RunL, if there is.
+				 __FLOG_VA(_L8("StartL - iSkipCurrentStorage - ETrue."));
+				 iSkipCurrentStorage = ETrue;
+				TRequestStatus* status = &iStatus;
+				User::RequestComplete(status, iStatus.Int());
+				 SetActive();
+				 }
+			 else
+				 {
+				 User::Leave(err);
+				 }
+			 }
+		}
+	else
+		{
+		iCallback.NotifyEnumerationCompleteL(iStorageId, KErrNone);
+		
+		TMTPTypeEvent event;
+		
+		event.SetUint16(TMTPTypeEvent::EEventCode, EMTPEventCodeUnreportedStatus);
+		event.SetUint32(TMTPTypeEvent::EEventSessionID, KMTPSessionAll);
+		
+		iFramework.SendEventL(event);
+		}
+	}
+	
+/**
+Cancel the enumeration process
+*/    
+void CMTPFSEnumerator::DoCancel()
+	{
+	iDir.Close();
+	}
+
+void CMTPFSEnumerator::ScanStorageL(TUint32 aStorageId)
+	{
+	__FLOG_VA(_L8("ScanStorageL - entry"));
+    const CMTPStorageMetaData& storage(iFramework.StorageMgr().StorageL(aStorageId));
+    __ASSERT_DEBUG((storage.Uint(CMTPStorageMetaData::EStorageSystemType) == CMTPStorageMetaData::ESystemTypeDefaultFileSystem), User::Invariant());
+    TFileName root(storage.DesC(CMTPStorageMetaData::EStorageSuid));
+    
+    #ifdef __FLOG_ACTIVE    
+	TBuf8<KMaxFileName> tmp;
+	tmp.Copy(root);
+ 	__FLOG_VA((_L8("StorageSuid - %S"), &tmp));	
+	#endif // __FLOG_ACTIVE
+ 	
+ 	if ( iExclusionMgr.IsFolderAcceptedL(root, aStorageId) )
+ 	    {
+ 	    iParentHandle = KMTPHandleNoParent;
+ 	    iPath.Set(root, NULL, NULL);
+ 	    User::LeaveIfError(iDir.Open(iFramework.Fs(), iPath.DriveAndPath(), KEntryAttNormal | KEntryAttDir));
+ 	    ScanDirL();
+ 	    }
+ 	else
+ 	    {
+ 	    TRequestStatus* status = &iStatus;
+ 	    User::RequestComplete(status, iStatus.Int());
+ 	    SetActive();
+ 	    }
+ 	__FLOG_VA(_L8("ScanStorageL - exit"));
+	}
+
+/**
+Scans directory at aPath recursing into subdirectories on a depth first basis.
+
+Directory entries are kept in iDirStack - which is a LIFO stack.
+The current path, needed since TEntries don't keep track of it, 
+is kept in iPath.
+
+The algorithm works as follows:
+
+1. Read directory entries.
+2. ProcessEntriesL is called if no error occurs and >= 1 entries are read.
+3. ProcessEntriesL adds entries to database, if entry is directory add to iDirStack.
+4. When all entries are processed pop entry off the dirstack, 
+	if entry is empty TEntry remove one directory from iPath.
+5. Append entry name onto iPath - to update path with new depth (parent/subdir).
+6. Push an empty TEntry onto iDirStack - this tells us we have recursed one,
+	think of it as pushing the '\' separator onto iDirStack.
+7. Repeat 1-7 until iDirStack is empty.
+*/
+
+void CMTPFSEnumerator::ScanDirL()
+	{
+	__FLOG_VA(_L8("ScanDirL - entry"));
+	iFirstUnprocessed = 0;
+	iDir.Read(iEntries, iStatus);
+	SetActive();
+	__FLOG_VA(_L8("ScanDirL - exit"));
+	}
+
+void CMTPFSEnumerator::ScanNextStorageL()
+	{
+	__FLOG_VA(_L8("ScanNextStorageL - entry"));
+	// If there are one or more unscanned storages left
+	// (the currently scanned one is still on the list)
+	if (iStorages.Count() > 1)
+		{
+		iStorages.Remove(0);
+		ScanStorageL(iStorages[0]);
+		}
+	else
+		{
+		// We are done
+		iStorages.Reset();
+		iCallback.NotifyEnumerationCompleteL(iStorageId, KErrNone);
+		}
+	__FLOG_VA(_L8("ScanNextStorageL - exit"));
+	}
+
+void CMTPFSEnumerator::ScanNextSubdirL()
+	{
+	__FLOG_VA(_L8("ScanNextSubdirL - entry"));
+	// A empty (non-constructed) TEntry is our marker telling us to pop a directory 
+	// from iPath when we see this
+	iDirStack.AppendL(TEntry());
+			
+	// Leave with KErrNotFound if we don't find the object handle since it shouldn't be on the 
+	// dirstack if the entry wasn't added
+	TPtrC suid = iPath.DriveAndPath().Left(iPath.DriveAndPath().Length());
+	// Update the current parentId with object of the directory
+	iParentHandle = iFramework.ObjectMgr().HandleL(suid);
+				
+	// Kick-off a scan of the next directory
+	iDir.Close();
+	User::LeaveIfError(iDir.Open(iFramework.Fs(), iPath.DriveAndPath(), KEntryAttNormal | KEntryAttDir));
+	ScanDirL();
+	__FLOG_VA(_L8("ScanNextSubdirL - exit"));
+	}
+
+/**
+Recurse into the next directory on the stack
+and scan it for entries.
+*/
+
+void CMTPFSEnumerator::ScanNextL()
+	{
+	__FLOG_VA(_L8("ScanNextL - entry"));
+	TInt count = iDirStack.Count();
+	
+	if (count == 0)
+		{
+		// No more directories on the stack, try the next storage
+		ScanNextStorageL();
+		}
+	else
+		{
+		TEntry& entry = iDirStack[count - 1];
+		
+		// Empty TEntry, no more subdirectories in
+		// the current path
+		if (entry.iName == KNullDesC)
+			{
+			// Remove current dir from path
+			iPath.PopDir();
+			iDirStack.Remove(count - 1);
+			iDir.Close();
+			
+			// Scan the next directory of the parent
+			ScanNextL();
+			}
+			
+		// Going into a subdirectory of current
+		else 
+			{
+			// Add directory to path		
+			iPath.AddDir(entry.iName);
+			// Remove directory so we don't think it's a subdirectory
+			iDirStack.Remove(count - 1);
+	
+			ScanNextSubdirL();
+			}
+		}
+	__FLOG_VA(_L8("ScanNextL - exit"));
+	}
+
+void CMTPFSEnumerator::RunL()
+	{
+	__FLOG_VA(_L8("RunL - entry"));
+	if(iSkipCurrentStorage)
+		{
+		__FLOG_VA(_L8("RunL - iSkipCurrentStorage - ETrue."));
+		iSkipCurrentStorage = EFalse;
+		ScanNextStorageL();
+		}
+	else if (iEntries.Count() == 0)
+		{
+		// No entries to process, scan next dir or storage
+		ScanNextL();
+		}
+	else if (iFirstUnprocessed < iEntries.Count())
+		{
+		ProcessEntriesL();
+		
+		// Complete ourselves with current TRequestStatus
+		// since we need to run again to either scan a new dir or drive
+		// or process more entries
+		TRequestStatus* status = &iStatus;
+		User::RequestComplete(status, iStatus.Int());
+		SetActive();
+		}
+	else
+		{
+		switch (iStatus.Int())
+			{
+			case KErrNone:
+				// There are still entries left to be read
+				ScanDirL();
+				break;
+			
+			case KErrEof:
+				// There are no more entries
+			default:
+				// Error, ignore and continue with next dir
+				ScanNextL();
+				break;
+			}
+		}
+	__FLOG_VA(_L8("RunL - exit"));
+	}
+
+/**
+Ignore the error, continue with the next one
+*/    
+TInt CMTPFSEnumerator::RunError(TInt aError)
+	{
+	__FLOG_VA((_L8("RunError - entry with error %d"), aError));
+	 if(!iFramework.StorageMgr().ValidStorageId(iStorages[0]))
+		 {
+		 if (iStorages.Count()>1)
+			 {
+			 //Not necessary to process any entry on the storage, since the storage removed.
+			 //Then need to start from root dir of next storage if there is.
+			 //So, the dir stack is popped to bottom.
+			 iDirStack.Reset();
+			 }
+		 iSkipCurrentStorage = ETrue;
+		 }
+	
+	// Reschedule ourselves
+	TRequestStatus* status = &iStatus;
+	User::RequestComplete(status, aError);
+	SetActive();
+	
+	__FLOG(_L8("RunError - Exit"));
+	return KErrNone;
+	}
+	
+/**
+Standard c++ constructor
+*/	
+CMTPFSEnumerator::CMTPFSEnumerator(MMTPDataProviderFramework& aFramework, CMTPFSExclusionMgr& aExclusionMgr, MMTPEnumerationCallback& aCallback, TInt aProcessLimit)
+	: CActive(EPriorityLow),
+  	iFramework(aFramework),
+  	iExclusionMgr(aExclusionMgr),
+    iCallback(aCallback),
+    iProcessLimit(aProcessLimit)
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	CActiveScheduler::Add(this);
+	}
+
+void CMTPFSEnumerator::ConstructL()
+	{
+	iSingletons.OpenL();
+	iDpSingletons.OpenL(iFramework);
+	iObject = CMTPObjectMetaData::NewL();	
+	iDpID = iFramework.DataProviderId();
+	}
+
+/**
+Iterates iEntries adding entries as needed to object manager and iDirStack.
+*/
+
+void CMTPFSEnumerator::ProcessEntriesL()
+	{
+	const TUint KMTPMaxFullFileName = 259;
+
+	TBuf<KMTPMaxFullFileName> path = iPath.DriveAndPath();
+	
+	// Start looping through entries at where we left off
+	TInt count = iEntries.Count() - iFirstUnprocessed;
+	// Process no more than KProcessLimit entries
+	count = Min(count, iProcessLimit);
+	iFirstUnprocessed += count;		
+	
+		
+	for (TInt i = (iFirstUnprocessed - count); i < iFirstUnprocessed; ++i)
+		{
+		const TEntry& entry = iEntries[i];
+		path.Append(entry.iName);
+		
+#ifdef __FLOG_ACTIVE    
+		TBuf8<KMTPMaxFullFileName> tmp;
+        tmp.Copy(path);
+        TInt pathLen=path.Length();
+        if(pathLen > KLogBufferSize)
+            {
+            TBuf8<KLogBufferSize> tmp1;
+            tmp1.Copy(tmp.Ptr(),KLogBufferSize);
+			__FLOG_VA(_L8("Entry - "));
+	        __FLOG_VA((_L8("%S"), &tmp1));
+
+	        tmp1.Copy(tmp.Ptr()+KLogBufferSize, pathLen-KLogBufferSize);
+	        __FLOG_VA((_L8("%S"), &tmp1));
+            }
+        else
+            {
+            __FLOG_VA(_L8("Entry - "));
+			__FLOG_VA((_L8("%S"), &tmp));
+            }
+#endif // __FLOG_ACTIVE
+		
+		TInt len = entry.iName.Length();
+		TInt totalLen = path.Length();
+		if(totalLen > KMaxFileName)
+		    {
+			// Remove filename part
+		    path.SetLength(totalLen - len);
+		    __FLOG_VA(_L8("Full name exceeds KMaxFileName, ignored."));
+		    continue;
+		    }
+		TUint32 handle = 0;
+		TMTPFormatCode format;
+		  TParsePtrC parse(path);
+		if (entry.IsDir())
+			{
+			if (iExclusionMgr.IsFolderAcceptedL(path, iStorages[0]))
+				{
+				path.Append('\\');
+				++len;
+				format = EMTPFormatCodeAssociation;
+				AddEntryL(path, handle, format, iDpID, entry);
+				iDirStack.AppendL(entry);
+				}
+			}
+		else if ( iExclusionMgr.IsFileAcceptedL(path,iStorages[0]) )
+			{
+			format = EMTPFormatCodeUndefined;
+			AddEntryL(path, handle, format, iDpID, entry);
+			}
+		else if ( parse.ExtPresent() )
+		    {
+		    switch(iDpSingletons.MTPUtility().GetEnumerationFlag(parse.Ext().Mid(1)))
+		        {
+            case MISSED_FILES_OWNED_BY_FILE_DP:
+                if (KMTPHandleNone == iFramework.ObjectMgr().HandleL(path))
+                    {
+                    format = EMTPFormatCodeUndefined;
+                    AddEntryL(path, handle, format, iDpID, entry);		   
+                    }
+                break;
+                
+            case MISSED_FILES_OWNED_BY_OTHER_DP:
+                if (KMTPHandleNone == iFramework.ObjectMgr().HandleL(path))
+                    {
+                    format = iDpSingletons.MTPUtility().GetFormatByExtension(parse.Ext().Mid(1));  
+                    TUint32 DpId = iDpSingletons.MTPUtility().GetDpId(parse.Ext().Mid(1), KNullDesC);
+                    AddFileEntryForOtherDpL(path, handle, format, DpId, entry);
+                    }
+                break;
+                
+            case FILES_OWNED_BY_OTHER_DP:
+                {
+                format = iDpSingletons.MTPUtility().GetFormatByExtension(parse.Ext().Mid(1));  
+                TUint32 DpId = iDpSingletons.MTPUtility().GetDpId(parse.Ext().Mid(1), KNullDesC);
+                AddFileEntryForOtherDpL(path, handle, format, DpId, entry);
+                }
+                break;
+                
+//          case FILES_OWNED_BY_NONE:
+            default:
+                //nothing to do
+                break;
+		        }    
+		    }
+		// Remove filename part					
+		path.SetLength(path.Length() - len);
+		}
+		
+	}
+
+/**
+Add a file entry to the object store
+@param aEntry    The file Entry to be added
+@param aPath    The full path name of the entry
+@return MTP object handle, or KMTPHandleNone if entry was not accepted
+*/    
+void CMTPFSEnumerator::AddEntryL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& aEntry)
+	{
+#ifdef __FLOG_ACTIVE    
+	TBuf8<KMaxFileName> tmp;
+	tmp.Copy(aPath);
+	
+	__FLOG_VA((_L8("AddEntryL - entry: %S"), &tmp));
+#endif // __FLOG_ACTIVE
+
+    TUint16 assoc;
+    TPtrC name;
+    if (format == EMTPFormatCodeAssociation)
+        {
+        assoc = EMTPAssociationTypeGenericFolder;
+        TParsePtrC pathParser(aPath.Left(aPath.Length() - 1)); // Ignore the trailing "\".
+		name.Set(aEntry.iName);
+        }
+    else
+        {
+        assoc = EMTPAssociationTypeUndefined;
+        TParsePtrC pathParser(aPath);
+		name.Set(pathParser.Name());	
+        }
+    
+    if(iExclusionMgr.IsFormatValid(format))
+        {
+        aHandle = KMTPHandleNone;
+        
+        iObject->SetUint(CMTPObjectMetaData::EDataProviderId, aDPId);
+        iObject->SetUint(CMTPObjectMetaData::EFormatCode, format);
+        iObject->SetUint(CMTPObjectMetaData::EStorageId, iStorages[0]);
+        iObject->SetDesCL(CMTPObjectMetaData::ESuid, aPath);
+        iObject->SetUint(CMTPObjectMetaData::EFormatSubCode, assoc);
+        iObject->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle);
+        iObject->SetUint(CMTPObjectMetaData::ENonConsumable, EMTPConsumable);
+        iObject->SetDesCL(CMTPObjectMetaData::EName, name);
+        iFramework.ObjectMgr().InsertObjectL(*iObject);
+        }
+	__FLOG_VA(_L8("AddEntryL - exit"));	
+	}
+
+void CMTPFSEnumerator::AddFileEntryForOtherDpL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& /*aEntry*/)
+    {
+#ifdef __FLOG_ACTIVE    
+    TBuf8<KMaxFileName> tmp;
+    tmp.Copy(aPath);
+    
+    __FLOG_VA((_L8("AddFileEntryForOtherDpL - entry: %S"), &tmp));
+#endif // __FLOG_ACTIVE
+
+    TUint16 assoc = EMTPAssociationTypeUndefined;
+    TParsePtrC pathParser(aPath);
+    TPtrC name(pathParser.Name());    
+    
+    aHandle = KMTPHandleNone;
+    
+    iObject->SetUint(CMTPObjectMetaData::EDataProviderId, aDPId);
+    iObject->SetUint(CMTPObjectMetaData::EFormatCode, format);
+    iObject->SetUint(CMTPObjectMetaData::EStorageId, iStorages[0]);
+    iObject->SetDesCL(CMTPObjectMetaData::ESuid, aPath);
+    iObject->SetUint(CMTPObjectMetaData::EFormatSubCode, assoc);
+    iObject->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle);
+    iObject->SetUint(CMTPObjectMetaData::ENonConsumable, EMTPConsumable);
+    iObject->SetDesCL(CMTPObjectMetaData::EName, name);
+    iFramework.ObjectMgr().InsertObjectL(*iObject);
+    __FLOG_VA(_L8("AddEntryL - exit")); 
+    }
+
+void CMTPFSEnumerator::NotifyObjectAddToDP(const TUint32 aHandle,const TUint DpId)
+    {
+    iSingletons.DpController().NotifyDataProvidersL(DpId,EMTPObjectAdded,(TAny*)&aHandle);
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsexclusionmgr.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,109 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "cmtpfsexclusionmgr.h"
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/cmtpstoragemetadata.h>
+#include <mtp/cmtpmetadata.h>
+#include <e32hashtab.h>
+
+//[SP-Format-0x3002]
+//The full path of DDISCVRY.DPS of PictBridge DP.
+_LIT(KFullNameOfPictBridgeDiscovery, "C:\\DATA\\DDISCVRY.DPS");
+
+__FLOG_STMT(_LIT8(KComponent,"CMTPFSExclusionMgr");)
+
+EXPORT_C CMTPFSExclusionMgr::CMTPFSExclusionMgr(MMTPDataProviderFramework& aFramework) :
+	iFramework(aFramework), iOrder(CMTPMetaData::CompareTPathHash)
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	}
+
+EXPORT_C CMTPFSExclusionMgr::~CMTPFSExclusionMgr()
+	{
+	__FLOG_CLOSE;
+	}
+	
+EXPORT_C TBool CMTPFSExclusionMgr::IsFolderAcceptedL(const TDesC& aPath, TUint32 aStorageId) const
+	{
+	return IsPathAcceptedL(aPath, aStorageId);
+	}
+	
+EXPORT_C TBool CMTPFSExclusionMgr::IsFileAcceptedL(const TDesC& aPath, TUint32 /*aStorageId*/) const
+	{
+	__FLOG(_L8("IsFileAcceptedL - Entry"));	
+	
+	TBool accepted = ETrue;
+	TParsePtrC parse(aPath);
+	
+	if (parse.ExtPresent())
+		{
+		accepted = IsExtensionValid(parse.Ext().Mid(1));
+		__FLOG_VA((_L8("IsExtensionValid = %d"), accepted));
+		}
+	
+    //[SP-Format-0x3002]
+	//They are used to exclude DDISCVRY.DPS from the process of file dp's enumeration.
+	if(accepted) 
+		{
+		TFileName tmp = aPath;
+		tmp.UpperCase();
+		if( tmp == KFullNameOfPictBridgeDiscovery )
+			{
+			accepted = EFalse;
+			}
+		}
+	__FLOG_VA((_L8("Exit IsFileAcceptedL = %d"), accepted));
+	return accepted;
+	}
+	
+EXPORT_C TBool CMTPFSExclusionMgr::IsPathAcceptedL(const TDesC& aPath, TUint32 aStorageId) const
+	{
+
+	CMTPStorageMetaData* storageMetaData = (CMTPStorageMetaData *)& iFramework.StorageMgr().StorageL(aStorageId);
+	TBool accepted = EFalse;	
+	
+	if (storageMetaData->Uint(CMTPStorageMetaData::EStorageSystemType) == CMTPStorageMetaData::ESystemTypeDefaultFileSystem)
+		{
+		// Use Hash code to compare.
+		const RArray<CMTPMetaData::TPathHash>& excludedHash = const_cast<CMTPStorageMetaData*>(storageMetaData)->GetHashPathArray();
+		// Calculate hash code for aPath, aPath is always a folder because for file, we only need to check extension
+		CMTPMetaData::TPathHash PathHash;
+		TFileName ex(aPath);
+		ex.LowerCase();
+        PathHash.iHash = DefaultHash::Des16(ex);
+
+		accepted = ETrue;
+		TInt index = KErrNotFound;
+		if ( (index = excludedHash.SpecificFindInOrder(PathHash, iOrder, EArrayFindMode_First)) != KErrNotFound )
+			{
+			// double check if the path need be excluded in case of hash duplicated.
+			const CDesCArray& excludedAreas = const_cast<CMTPStorageMetaData*>(storageMetaData)->DesCArray(CMTPStorageMetaData::EExcludedAreas);
+			
+			for(TInt i=index; (PathHash.iHash==excludedHash[i].iHash)&&(i<excludedHash.Count()); ++i)
+				{
+				if ((aPath.MatchF(excludedAreas[excludedHash[i].iIndex])) != KErrNotFound)
+					{
+					accepted = EFalse;
+					break;
+					}
+				}
+			}
+		}
+		
+	return accepted;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpfullenumservicehandler.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,578 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpfullenumservicehandler.cpp
+
+#include <centralrepository.h>
+#include <mtp/cmtptypearray.h>
+
+#include <mtp/cmtptypeformatcapabilitylist.h>
+#include <mtp/cmtptypeservicepropdesclist.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtpobjectmetadata.h>
+
+#include "mtpsvcdpconst.h"
+#include "cmtpfullenumservicehandler.h"
+#include "cmtpabstractdatacodemgr.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent, "FullEnumServiceHandler");)
+
+EXPORT_C CMTPFullEnumServiceHandler* CMTPFullEnumServiceHandler::NewL(MMTPDataProviderFramework& aFramework,
+		const CMTPFullEnumDataCodeMgr& aDataCodeMgr,
+		CRepository& aRepository,
+		TUint aNormalServiceID,
+		const TDesC& aKnowledgeObjectSUID,
+		const TMTPTypeGuid& aServiceFormatGUID)
+	{
+	CMTPFullEnumServiceHandler* self = new(ELeave) CMTPFullEnumServiceHandler(aFramework, aDataCodeMgr,
+			aRepository, aNormalServiceID,
+			aKnowledgeObjectSUID, aServiceFormatGUID);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CMTPFullEnumServiceHandler::~CMTPFullEnumServiceHandler()
+	{
+	__FLOG(_L8("~CMTPFullEnumServiceHandler - Destructed"));
+	__FLOG_CLOSE;
+	}
+
+CMTPFullEnumServiceHandler::CMTPFullEnumServiceHandler(MMTPDataProviderFramework& aFramework,
+		const CMTPFullEnumDataCodeMgr& aDataCodeMgr, CRepository& aRepository,
+		TUint aNormalServiceID, const TDesC& aKnowledgeObjectSUID,
+		const TMTPTypeGuid& aServiceFormatGUID) :
+		iFramework(aFramework), iDataCodeMgr(aDataCodeMgr), iRepository(aRepository),
+		iNormalServiceID(aNormalServiceID), iKnowledgeObjectSUID(aKnowledgeObjectSUID)
+	{
+	iNormalServiceFormatGUID = aServiceFormatGUID;
+	}
+
+void CMTPFullEnumServiceHandler::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry"));
+	// Initialize the service properties's value stored in iRepository
+	LoadServicePropValueL();
+	__FLOG(_L8("ConstructL - Exit"));
+	}
+
+// GetServiceCapabilities
+EXPORT_C TMTPResponseCode CMTPFullEnumServiceHandler::GetServiceCapabilityL(
+	TUint16 aServiceFormatCode, CMTPTypeServiceCapabilityList& aServiceCapabilityList) const
+	{
+	__FLOG(_L8("GetServiceCapabilitiesL - Entry"));
+
+	__ASSERT_DEBUG((aServiceFormatCode == iDataCodeMgr.KnowledgeFormat().iFormatCode), User::Invariant());
+
+	//only Knowledge format supported
+	CMTPTypeFormatCapability* element = CMTPTypeFormatCapability::NewLC(aServiceFormatCode, NULL);
+
+	//only Generic Object namespace properties supported
+	const RMTPServiceFormat& serviceFormat = iDataCodeMgr.KnowledgeFormat();
+	TUint propCout = serviceFormat.iProps.Count();
+	for (TUint i = 0; i < propCout; i++)
+		{
+		//only Generic Object namespace properties supported
+		CMTPTypeObjectPropDesc* objectProperty
+		= MMTPServiceHandler::GenerateGenericObjectPropDescLC(serviceFormat.iProps[i]);
+		if (objectProperty)
+			{
+			element->AppendL(objectProperty);
+			CleanupStack::Pop(objectProperty);
+			}
+		} // End of loop for every format
+	aServiceCapabilityList.AppendL(element);
+	CleanupStack::Pop(element);
+	__FLOG(_L8("GetServiceCapabilitiesL - Exit"));
+	return EMTPRespCodeOK;
+	}
+
+// GetServicePropDesc
+EXPORT_C TMTPResponseCode CMTPFullEnumServiceHandler::GetServicePropDescL(
+	TUint16 aServicePropertyCode, CMTPTypeServicePropDescList& aPropDescList) const
+	{
+	__FLOG(_L8("GetServicePropDescL - Entry"));
+	TMTPResponseCode respCode(EMTPRespCodeOK);
+	CMTPTypeServicePropDesc* servicePropDesc = NULL;
+	const TMTPServicePropertyInfo* pPropInfo = iDataCodeMgr.ServicePropertyInfo(aServicePropertyCode);
+	TUint16 servicePropEnum = pPropInfo ? pPropInfo->iIndex : EMTPAbstractServicePropertyEnd;
+	switch (servicePropEnum)
+		{
+		case EMTPServicePropertyVersionProps:
+			{
+			const TUint32 KMaxNumVersionProps = 0x000000FF;
+			TMTPTypeUint32 expectedForm(KMaxNumVersionProps);
+			servicePropDesc = CMTPTypeServicePropDesc::NewLC(
+								  aServicePropertyCode,
+								  EMTPTypeAUINT8,
+								  CMTPTypeObjectPropDesc::EReadOnly,
+								  CMTPTypeObjectPropDesc::EByteArrayForm, // Form tag
+								  &expectedForm);
+			break;
+			}
+
+		case EMTPServicePropertyReplicaID:
+			{
+			servicePropDesc = CMTPTypeServicePropDesc::NewLC(
+								  aServicePropertyCode,
+								  EMTPTypeUINT128,
+								  CMTPTypeObjectPropDesc::EReadWrite,
+								  CMTPTypeObjectPropDesc::ENone,
+								  NULL);
+			break;
+			}
+
+		case EMTPServicePropertyKnowledgeObjectID:
+			{
+			servicePropDesc = CMTPTypeServicePropDesc::NewLC(
+								  aServicePropertyCode,
+								  EMTPTypeUINT32,
+								  CMTPTypeObjectPropDesc::EReadOnly,
+								  CMTPTypeObjectPropDesc::EObjectIDForm,
+								  NULL);
+			break;
+			}
+		case EMTPServicePropertyLastSyncProxyID:
+			{
+			servicePropDesc = CMTPTypeServicePropDesc::NewLC(
+								  aServicePropertyCode,
+								  EMTPTypeUINT128,
+								  CMTPTypeObjectPropDesc::EReadWrite,
+								  CMTPTypeObjectPropDesc::ENone,
+								  NULL);
+			break;
+			}
+		case EMTPServicePropertyProviderVersion:
+			{
+			servicePropDesc = CMTPTypeServicePropDesc::NewLC(
+								  aServicePropertyCode,
+								  EMTPTypeUINT16,
+								  CMTPTypeObjectPropDesc::EReadOnly,
+								  CMTPTypeObjectPropDesc::ENone,
+								  NULL);
+			break;
+			}
+		case EMTPServicePropertySyncFormat:
+			{
+			servicePropDesc = CMTPTypeServicePropDesc::NewLC(
+								  aServicePropertyCode,
+								  EMTPTypeUINT128,
+								  CMTPTypeObjectPropDesc::EReadOnly,
+								  CMTPTypeObjectPropDesc::ENone,
+								  NULL);
+			break;
+			}
+		case EMTPServicePropertyLocalOnlyDelete:
+			{
+			CMTPTypeObjectPropDescEnumerationForm* expectedForm
+			= CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT8);
+			CleanupStack::PushL(expectedForm);
+			expectedForm->AppendSupportedValueL(TMTPTypeUint8(EMTPLocalOnlyDeleteFalse));
+			expectedForm->AppendSupportedValueL(TMTPTypeUint8(EMTPLocalOnlyDeleteTrue));
+			servicePropDesc = CMTPTypeServicePropDesc::NewL(
+								  aServicePropertyCode,
+								  EMTPTypeUINT8,
+								  CMTPTypeObjectPropDesc::EReadWrite,
+								  CMTPTypeObjectPropDesc::EEnumerationForm,
+								  expectedForm);
+			// Form can be NULL, so need destroy here for MTPType object here.
+			CleanupStack::PopAndDestroy(expectedForm);
+			CleanupStack::PushL(servicePropDesc);
+			break;
+			}
+
+		case EMTPServicePropertyFilterType:
+			{
+			CMTPTypeObjectPropDescEnumerationForm* expectedForm
+			    = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT8);
+			CleanupStack::PushL(expectedForm);
+			expectedForm->AppendSupportedValueL(TMTPTypeUint8(EMTPSyncSvcFilterNone));
+			expectedForm->AppendSupportedValueL(TMTPTypeUint8(EMTPSyncSvcFilterContactsWithPhone));
+			expectedForm->AppendSupportedValueL(TMTPTypeUint8(EMTPSyncSvcFilterTaskActive));
+			expectedForm->AppendSupportedValueL(TMTPTypeUint8(EMTPSyncSvcFilterCalendarWindowWithRecurrence));
+
+			servicePropDesc = CMTPTypeServicePropDesc::NewL(
+								  aServicePropertyCode,
+								  EMTPTypeUINT8,
+								  CMTPTypeObjectPropDesc::EReadWrite,
+								  CMTPTypeObjectPropDesc::EEnumerationForm,
+								  expectedForm);
+			// Form can be NULL, so need destroy here for MTPType object here.
+			CleanupStack::PopAndDestroy(expectedForm);
+			CleanupStack::PushL(servicePropDesc);
+			break;
+			}
+		case EMTPServicePropertySyncObjectReferences:
+			{
+			CMTPTypeObjectPropDescEnumerationForm* expectedForm
+			    = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT8);
+			CleanupStack::PushL(expectedForm);
+			expectedForm->AppendSupportedValueL(TMTPTypeUint8(EMTPSyncObjectReferencesDisabled));
+			expectedForm->AppendSupportedValueL(TMTPTypeUint8(EMTPSyncObjectReferencesEnabled));
+			servicePropDesc = CMTPTypeServicePropDesc::NewL(
+								  aServicePropertyCode,
+								  EMTPTypeUINT8,
+								  CMTPTypeObjectPropDesc::EReadOnly,
+								  CMTPTypeObjectPropDesc::EEnumerationForm,
+								  expectedForm);
+			// Form can be NULL, so need destroy here for MTPType object here.
+			CleanupStack::PopAndDestroy(expectedForm);
+			CleanupStack::PushL(servicePropDesc);
+			break;
+			}
+
+		default:
+			respCode = EMTPRespCodeParameterNotSupported;
+			break;
+		}
+
+	if (servicePropDesc)
+		{
+		aPropDescList.AppendL(servicePropDesc);
+		CleanupStack::Pop(servicePropDesc);
+		}
+	__FLOG(_L8("GetServicePropDescL - Exit"));
+	return respCode;
+	}
+
+// Get specific property of the service
+EXPORT_C TMTPResponseCode CMTPFullEnumServiceHandler::GetServicePropetyL(TUint16 aPropertyCode, CMTPTypeServicePropList& aPropList) const
+	{
+	__FLOG(_L8("GetServicePropetyL - Entry"));
+
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	const TMTPServicePropertyInfo* pPropInfo = iDataCodeMgr.ServicePropertyInfo(aPropertyCode);
+	TUint16 servicePropEnum = pPropInfo ? pPropInfo->iIndex : EMTPAbstractServicePropertyEnd;
+	CMTPTypeServicePropListElement* propertyElement = NULL;
+	switch (servicePropEnum)
+		{
+		case EMTPServicePropertyVersionProps:
+			{
+			RArray<TUint> elementData;
+			CleanupClosePushL(elementData);
+			const TUint values[] =
+				{
+				// Change Unit Count
+				0x01, 0x00, 0x00, 0x00,
+				// Change Unit 1
+				0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+				0x00, 0x00, 0x00, 0x00,
+				// Count for Change Unit 1
+				0x01, 0x00, 0x00, 0x00,
+				// Version Prop DateModified Namespace and PID
+				0x0D, 0x49, 0x6B, 0xEF, 0xD8, 0x5C, 0x7A, 0x43, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C,
+				0x28, 0x00, 0x00, 0x00
+				};
+			TUint numValues((sizeof(values) / sizeof(values[0])));
+			for (TUint i = 0; i < numValues; i++)
+				{
+				elementData.AppendL(values[i]);
+				}
+
+			CMTPTypeArray* versionProp = CMTPTypeArray::NewLC(EMTPTypeAUINT8, elementData);
+			propertyElement = CMTPTypeServicePropListElement::NewL(iNormalServiceID, aPropertyCode,
+							  EMTPTypeAUINT8, *versionProp);
+			CleanupStack::PopAndDestroy(versionProp);
+			CleanupStack::PopAndDestroy(&elementData);
+			CleanupStack::PushL(propertyElement);
+			break;
+			}
+
+		case EMTPServicePropertyReplicaID:
+			{
+			const TMTPTypeGuid unInitValue(MAKE_TUINT64(KMTPUnInitialized32, KMTPUnInitialized32),
+											  MAKE_TUINT64(KMTPUnInitialized32, KMTPUnInitialized32));
+			if (!unInitValue.Equal(iReplicateID))
+				{
+				propertyElement = CMTPTypeServicePropListElement::NewLC(iNormalServiceID, aPropertyCode,
+								  EMTPTypeUINT128, iReplicateID);
+				}
+			break;
+			}
+
+		case EMTPServicePropertyKnowledgeObjectID:
+			{
+			CMTPObjectMetaData* object = CMTPObjectMetaData::NewLC();
+			if (iFramework.ObjectMgr().ObjectL(iKnowledgeObjectSUID, *object))
+				{
+				// Use knowledge object's handle as service property KnowledgeObjectId.
+				TUint knowledgeObjectID = object->Uint(CMTPObjectMetaData::EHandle);
+				CleanupStack::PopAndDestroy(object);
+				TMTPTypeUint32 objId;
+				objId.Set(knowledgeObjectID);
+				propertyElement = CMTPTypeServicePropListElement::NewLC(iNormalServiceID, aPropertyCode,
+								  EMTPTypeUINT32, objId);
+				}
+			else
+				{
+				CleanupStack::PopAndDestroy(object);
+				}
+			break;
+			}
+		case EMTPServicePropertyLastSyncProxyID:
+			{
+			const TMTPTypeGuid unInitValue(MAKE_TUINT64(KMTPUnInitialized32, KMTPUnInitialized32),
+											  MAKE_TUINT64(KMTPUnInitialized32, KMTPUnInitialized32));
+			if (!unInitValue.Equal(iLastSyncProxyID))
+				{
+				propertyElement = CMTPTypeServicePropListElement::NewLC(iNormalServiceID, aPropertyCode,
+								  EMTPTypeUINT128, iLastSyncProxyID);
+				}
+			break;
+			}
+		case EMTPServicePropertyProviderVersion:
+			{
+			TMTPTypeUint16 version(KMTPDefaultProviderVersion);
+			propertyElement = CMTPTypeServicePropListElement::NewLC(iNormalServiceID, aPropertyCode,
+							  EMTPTypeUINT16, version);
+			break;
+			}
+		case EMTPServicePropertySyncFormat:
+			{
+			propertyElement = CMTPTypeServicePropListElement::NewLC(iNormalServiceID, aPropertyCode,
+							  EMTPTypeUINT128, iNormalServiceFormatGUID);
+			break;
+			}
+		case EMTPServicePropertyLocalOnlyDelete:
+			{
+			if (EMTPLocalOnlyDeleteUnInitialized != iLocalOnlyDelete)
+				{
+				TMTPTypeUint8 localOnlyDelete(iLocalOnlyDelete);
+				propertyElement = CMTPTypeServicePropListElement::NewLC(iNormalServiceID, aPropertyCode,
+								  EMTPTypeUINT8, localOnlyDelete);
+				}
+			break;
+			}
+
+		case EMTPServicePropertyFilterType:
+			if (EMTPSyncSvcFilterUnInitialized != iFilterType)
+				{
+				TMTPTypeUint8 filterType(iFilterType);
+				propertyElement = CMTPTypeServicePropListElement::NewLC(iNormalServiceID, aPropertyCode,
+								  EMTPTypeUINT8, filterType);
+				}
+			break;
+		case EMTPServicePropertySyncObjectReferences:
+		    {
+            TMTPTypeUint8 syncObjectRef(iSyncObjectReference);
+            propertyElement = CMTPTypeServicePropListElement::NewLC(iNormalServiceID, aPropertyCode,
+                              EMTPTypeUINT8, syncObjectRef);
+            break;
+		    }
+			
+		default:
+			responseCode = EMTPRespCodeInvalidServicePropCode;
+		}
+	if (propertyElement)
+		{
+		aPropList.AppendL(propertyElement);
+		CleanupStack::Pop(propertyElement);
+		}
+	__FLOG_VA((_L8("GetServicePropetyL - Exit with responseCode = 0x%04X"), responseCode));
+	return responseCode;
+	}
+
+EXPORT_C TMTPResponseCode CMTPFullEnumServiceHandler::SetServicePropetyL(
+	TUint16 aPropEnumIndex, const CMTPTypeServicePropListElement& aElement)
+	{
+	__FLOG(_L8("SetServicePropetyL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+
+	TUint16 dataType = aElement.Uint16L(CMTPTypeServicePropListElement::EDatatype);
+	switch (aPropEnumIndex)
+		{
+		case EMTPServicePropertyReplicaID:
+			{
+			if (dataType == EMTPTypeUINT128)
+				{
+				TMTPTypeGuid unInitValue;
+				aElement.GetL(CMTPTypeServicePropListElement::EValue, unInitValue);
+				iReplicateID = unInitValue;
+				responseCode = MMTPServiceHandler::SaveServicePropValue(iRepository, EReplicaID, iReplicateID);
+				}
+			else
+				{
+				responseCode = EMTPRespCodeInvalidDataset;
+				}
+			break;
+			}
+		case EMTPServicePropertyLastSyncProxyID:
+			{
+			if (dataType == EMTPTypeUINT128)
+				{
+				TMTPTypeGuid unInitValue;
+				aElement.GetL(CMTPTypeServicePropListElement::EValue, unInitValue);
+				iLastSyncProxyID = unInitValue;
+				responseCode = MMTPServiceHandler::SaveServicePropValue(iRepository, ELastSyncProxyID, iLastSyncProxyID);
+				}
+			else
+				{
+				responseCode = EMTPRespCodeInvalidDataset;
+				}
+			break;
+			}
+		case EMTPServicePropertyLocalOnlyDelete:
+			{
+			if (dataType == EMTPTypeUINT8)
+				{
+				TMTPSyncSvcLocalOnlyDelete localOnlyDelete
+				= static_cast<TMTPSyncSvcLocalOnlyDelete>(aElement.Uint8L(CMTPTypeServicePropListElement::EValue));
+				if (localOnlyDelete < EMTPLocalOnlyDeleteFalse || localOnlyDelete > EMTPLocalOnlyDeleteTrue)
+					{
+					responseCode = EMTPRespCodeInvalidDataset;
+					}
+				else
+					{
+					iLocalOnlyDelete = localOnlyDelete;
+					responseCode = MMTPServiceHandler::SaveServicePropValue(iRepository, ELocalOnlyDelete, iLocalOnlyDelete);
+					}
+				}
+			else
+				{
+				responseCode = EMTPRespCodeInvalidDataset;
+				}
+			break;
+			}
+
+		case EMTPServicePropertyFilterType:
+			{
+			if (dataType == EMTPTypeUINT8)
+				{
+				TMTPSyncSvcFilterType filterType
+				= static_cast<TMTPSyncSvcFilterType>(aElement.Uint8L(CMTPTypeServicePropListElement::EValue));
+				if (filterType < EMTPSyncSvcFilterNone ||
+						filterType > EMTPSyncSvcFilterCalendarWindowWithRecurrence)
+					{
+					responseCode = EMTPRespCodeInvalidDataset;
+					}
+				else
+					{
+					iFilterType = filterType;
+					responseCode = MMTPServiceHandler::SaveServicePropValue(iRepository, EFilterType, iFilterType);
+					}
+				}
+			else
+				{
+				responseCode = EMTPRespCodeInvalidDataset;
+				}
+			break;
+			}
+
+		case EMTPServicePropertyVersionProps:
+		case EMTPServicePropertyKnowledgeObjectID:
+		case EMTPServicePropertyProviderVersion:
+		case EMTPServicePropertySyncFormat:
+		case EMTPServicePropertySyncObjectReferences:
+			responseCode = EMTPRespCodeAccessDenied;
+			break;
+		default:
+			responseCode = EMTPRespCodeInvalidServicePropCode;
+			break;
+		} //End of switch
+	__FLOG_VA((_L8("SetServicePropertyL - Exit with responseCode = 0x%04X"), responseCode));
+	return responseCode;
+	}
+
+EXPORT_C TMTPResponseCode CMTPFullEnumServiceHandler::DeleteServiceProperty(TUint16 aPropEnumIndex)
+	{
+	__FLOG(_L8("DeleteServiceProperty - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	switch (aPropEnumIndex)
+		{
+			// Deleteserviceproplist set all preoperties to uninitialized value
+		case EMTPServicePropertyReplicaID:
+			{
+			TMTPTypeGuid tmp(MAKE_TINT64(KMTPUnInitialized32, KMTPUnInitialized32),
+								MAKE_TINT64(KMTPUnInitialized32, KMTPUnInitialized32));
+			iReplicateID = tmp;
+			responseCode = MMTPServiceHandler::SaveServicePropValue(iRepository, EReplicaID, iReplicateID);
+			break;
+			}
+		case EMTPServicePropertyLastSyncProxyID:
+			{
+			TMTPTypeGuid tmp(MAKE_TINT64(KMTPUnInitialized32, KMTPUnInitialized32),
+								MAKE_TINT64(KMTPUnInitialized32, KMTPUnInitialized32));
+			iLastSyncProxyID = tmp;
+			responseCode = MMTPServiceHandler::SaveServicePropValue(iRepository, ELastSyncProxyID, iLastSyncProxyID);
+			break;
+			}
+		case EMTPServicePropertyLocalOnlyDelete:
+			{
+			iLocalOnlyDelete = EMTPLocalOnlyDeleteUnInitialized;
+			responseCode = MMTPServiceHandler::SaveServicePropValue(iRepository, ELocalOnlyDelete, iLocalOnlyDelete);
+			break;
+			}
+		case EMTPServicePropertyFilterType:
+			{
+			iFilterType = EMTPSyncSvcFilterUnInitialized;
+			responseCode = MMTPServiceHandler::SaveServicePropValue(iRepository, EFilterType, iFilterType);
+			break;
+			}
+		case EMTPServicePropertyVersionProps:
+		case EMTPServicePropertyKnowledgeObjectID:
+		case EMTPServicePropertyProviderVersion:
+		case EMTPServicePropertySyncFormat:
+		case EMTPServicePropertySyncObjectReferences:
+			{
+			responseCode = EMTPRespCodeAccessDenied;
+			break;
+			}
+		default:
+			{
+			responseCode = EMTPRespCodeInvalidServicePropCode;
+			__FLOG(_L8("Invalid service propcode"));
+			break;
+			}
+		}
+	__FLOG(_L8("DeleteServiceProperty - Exit"));
+	return responseCode;
+	}
+
+void CMTPFullEnumServiceHandler::LoadServicePropValueL()
+	{
+	__FLOG(_L8("LoadServicePropValueL - Entry"));
+	// Load ReplicaID:
+	TPtr8 writeBuf(NULL, 0); //walkaroud for the TMTPTypeGuid
+	iReplicateID.FirstWriteChunk(writeBuf);
+	User::LeaveIfError(iRepository.Get(EReplicaID, writeBuf));
+
+	//load LastSyncProxyID
+	iLastSyncProxyID.FirstWriteChunk(writeBuf);
+	User::LeaveIfError(iRepository.Get(ELastSyncProxyID, writeBuf));
+
+	TInt value;
+	// Load LocalOnlyDelete
+	User::LeaveIfError(iRepository.Get(ELocalOnlyDelete, value));
+	iLocalOnlyDelete = static_cast<TMTPSyncSvcLocalOnlyDelete>(value);
+
+	// Load EFilterType
+	User::LeaveIfError(iRepository.Get(EFilterType, value));
+	iFilterType = static_cast<TMTPSyncSvcFilterType>(value);
+
+	//Load SyncObjectReferenceEnabled
+	//Only dp which support SyncObjectReference need to save it into central responsitory
+	value = EMTPSyncObjectReferencesDisabled;
+	TInt ret = iRepository.Get(ESyncObjectReference, value);
+	if (ret != KErrNone && ret != KErrNotFound )
+	    {
+	    User::Leave(ret);
+	    }
+	iSyncObjectReference = static_cast<TMTPSyncSvcSyncObjectReferences>(value);
+	
+	__FLOG(_L8("LoadServicePropValueL - Exit"));
+	return;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetformatcapabilities.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,294 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtptypeinterdependentpropdesc.h>
+#include <mtp/cmtptypeobjectpropdesc.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/cmtptypestring.h>
+
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpdataprovider.h"
+#include "mtpframeworkconst.h"
+#include "cmtpgetformatcapabilities.h"
+
+
+
+EXPORT_C MMTPRequestProcessor* CMTPGetFormatCapabilities::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPGetFormatCapabilities* self = new (ELeave) CMTPGetFormatCapabilities(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+    
+EXPORT_C CMTPGetFormatCapabilities::~CMTPGetFormatCapabilities()
+    {
+    //[SP-Format-0x3002]
+    //Make the same behavior betwen 0x3000 and 0x3002.
+	//iSingletons is used to judge whether FileDP supports 0x3002 or not.
+    iSingletons.Close();
+    
+    delete iCapabilityList;
+    }
+
+void CMTPGetFormatCapabilities::ServiceL()
+    {
+    delete iCapabilityList;
+    iCapabilityList = CMTPTypeFormatCapabilityList::NewL();
+    iFormatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+
+    /**
+     * [SP-Format-0x3002]Special processing for PictBridge DP which own 6 dps file with format 0x3002, 
+     * but it does not really own the format 0x3002.
+     * 
+     * Make the same behavior betwen 0x3000 and 0x3002.
+     */
+    if((EMTPFormatCodeUndefined == iFormatCode) || (EMTPFormatCodeScript == iFormatCode))
+        {
+        BuildFormatAsUndefinedL(iFormatCode);
+        }
+    else if(EMTPFormatCodeAssociation == iFormatCode)
+        {
+        BuildFormatAssociationL();
+        }
+    else
+        {
+        if(iFramework.DataProviderId() == KMTPDeviceDPID)
+           {
+           BuildFormatAssociationL();
+           }
+       else if(iFramework.DataProviderId() == KMTPFileDPID)
+           {
+           BuildFormatAsUndefinedL(EMTPFormatCodeUndefined);
+           
+           //[SP-Format-0x3002]
+           //Make the same behavior betwen 0x3000 and 0x3002.
+           CMTPDataProvider& filedp(iSingletons.DpController().DataProviderL(KMTPFileDPID));
+           if(filedp.SupportedCodes(EObjectCaptureFormats).Find(EMTPFormatCodeScript) != KErrNotFound)
+        	   {
+        	   BuildFormatAsUndefinedL(EMTPFormatCodeScript);
+        	   }
+           }
+        }
+    
+    
+    SendDataL(*iCapabilityList);    
+    }
+    
+void CMTPGetFormatCapabilities::BuildFormatAssociationL()
+    {
+    CMTPTypeInterdependentPropDesc*  interDesc = CMTPTypeInterdependentPropDesc::NewLC();
+    CMTPTypeFormatCapability* frmCap = CMTPTypeFormatCapability::NewLC( EMTPFormatCodeAssociation ,interDesc );
+    
+    //EMTPObjectPropCodeStorageID
+    frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeStorageID) );
+    
+    //EMTPObjectPropCodeObjectFormat
+    frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectFormat) );
+    
+    //EMTPObjectPropCodeProtectionStatus
+    frmCap->AppendL( ServiceProtectionStatusL() );
+    
+    //EMTPObjectPropCodeAssociationType
+    frmCap->AppendL( ServiceAssociationTypeL() );
+    
+    //EMTPObjectPropCodeAssociationDesc
+    frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeAssociationDesc) );
+    
+    //EMTPObjectPropCodeObjectSize
+    frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectSize) );
+    
+    //EMTPObjectPropCodeObjectFileName
+    _LIT(KMtpObjDescObjFileName, "[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 7}\\.[[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 2}]?");
+    CMTPTypeString* form = CMTPTypeString::NewLC( KMtpObjDescObjFileName );   
+    frmCap->AppendL(CMTPTypeObjectPropDesc::NewL( EMTPObjectPropCodeObjectFileName,
+            CMTPTypeObjectPropDesc::ERegularExpressionForm, form));
+    CleanupStack::PopAndDestroy(form );       
+    
+    //EMTPObjectPropCodeDateModified
+    frmCap->AppendL(  CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeDateModified) );
+    
+    //EMTPObjectPropCodeParentObject
+    frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeParentObject) );
+    
+    //EMTPObjectPropCodePersistentUniqueObjectIdentifier
+    frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodePersistentUniqueObjectIdentifier) );
+    
+    //EMTPObjectPropCodeName
+    frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeName)); 
+    
+    //EMTPObjectPropCodeNonConsumable
+    frmCap->AppendL(ServiceNonConsumableL() );
+    
+    iCapabilityList->AppendL(frmCap);
+    CleanupStack::Pop(frmCap);
+    CleanupStack::Pop(interDesc);
+    }
+
+
+void CMTPGetFormatCapabilities::BuildFormatAsUndefinedL( TUint aFormatCode )
+    {
+    CMTPTypeInterdependentPropDesc*  interDesc = CMTPTypeInterdependentPropDesc::NewLC();
+    CMTPTypeFormatCapability* frmCap = CMTPTypeFormatCapability::NewLC( aFormatCode ,interDesc );
+    
+    //EMTPObjectPropCodeStorageID
+    frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeStorageID) );
+    
+    //EMTPObjectPropCodeObjectFormat
+    frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectFormat) );
+    
+    //EMTPObjectPropCodeProtectionStatus
+    frmCap->AppendL( ServiceProtectionStatusL() );
+    
+    //EMTPObjectPropCodeObjectSize
+    frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectSize) );
+    
+    //EMTPObjectPropCodeObjectFileName
+    _LIT(KMtpObjDescObjFileName, "[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 7}\\.[[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 2}]?");
+    CMTPTypeString* form = CMTPTypeString::NewLC( KMtpObjDescObjFileName );   
+    frmCap->AppendL(CMTPTypeObjectPropDesc::NewL( EMTPObjectPropCodeObjectFileName,
+            CMTPTypeObjectPropDesc::ERegularExpressionForm, form));
+    CleanupStack::PopAndDestroy(form );     
+    
+    //EMTPObjectPropCodeDateModified
+    frmCap->AppendL(  CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeDateModified) );
+    
+    //EMTPObjectPropCodeParentObject
+    frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeParentObject) );
+    
+    //EMTPObjectPropCodePersistentUniqueObjectIdentifier
+    frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodePersistentUniqueObjectIdentifier) );
+    
+    //EMTPObjectPropCodeName
+    frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeName)); 
+    
+    //EMTPObjectPropCodeNonConsumable
+    frmCap->AppendL(ServiceNonConsumableL() );
+    
+    iCapabilityList->AppendL(frmCap);
+    CleanupStack::Pop(frmCap);
+    CleanupStack::Pop(interDesc);
+    }
+    
+CMTPTypeObjectPropDesc* CMTPGetFormatCapabilities::ServiceProtectionStatusL()
+    {
+    CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT16);
+    CleanupStack::PushL(expectedForm);
+    //Currently, we only support EMTPProtectionNoProtection and EMTPProtectionReadOnly
+//  TUint16 values[] = {EMTPProtectionNoProtection, EMTPProtectionReadOnly, EMTPProtectionReadOnlyData, EMTPProtectionNonTransferable};
+    TUint16 values[] = {EMTPProtectionNoProtection, EMTPProtectionReadOnly};
+    TUint   numValues((sizeof(values) / sizeof(values[0])));
+    for (TUint i = 0; i < numValues; i++)
+        {
+        TMTPTypeUint16 data(values[i]);
+        expectedForm->AppendSupportedValueL(data);
+        }  
+    CMTPTypeObjectPropDesc* ret = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeProtectionStatus, *expectedForm);          
+    CleanupStack::PopAndDestroy(expectedForm);
+    return ret;
+    }
+
+CMTPTypeObjectPropDesc* CMTPGetFormatCapabilities::ServiceAssociationTypeL()
+    {
+    CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT16);
+    CleanupStack::PushL(expectedForm);
+    const TUint16 KMtpValues[] = {EMTPAssociationTypeUndefined, EMTPAssociationTypeGenericFolder};
+    const TUint KNumMtpValues(sizeof(KMtpValues) / sizeof(KMtpValues[0])); 
+    const TUint16 KPtpValues[] = {EMTPAssociationTypeUndefined, EMTPAssociationTypeGenericFolder, EMTPAssociationTypeAlbum, EMTPAssociationTypeTimeSequence, EMTPAssociationTypeHorizontalPanoramic, EMTPAssociationTypeVerticalPanoramic, EMTPAssociationType2DPanoramic,EMTPAssociationTypeAncillaryData};
+    const TUint KNumPtpValues(sizeof(KPtpValues) / sizeof(KPtpValues[0]));
+
+    TUint numValues(KNumMtpValues);
+    const TUint16* values = KMtpValues;
+    if (EModeMTP != iFramework.Mode())
+         {
+         numValues = KNumPtpValues;
+         values = KPtpValues;            
+         }
+   
+    for (TUint i = 0; i < numValues; i++)
+        {
+        TMTPTypeUint16 data(values[i]);
+        expectedForm->AppendSupportedValueL(data);
+        }  
+    CMTPTypeObjectPropDesc* ret = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeAssociationType, *expectedForm);       
+    CleanupStack::PopAndDestroy(expectedForm);
+    return ret;
+    }
+
+CMTPTypeObjectPropDesc* CMTPGetFormatCapabilities::ServiceNonConsumableL()
+    {
+    CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT8);
+    CleanupStack::PushL(expectedForm);
+    TUint8 values[] = {0,1};
+    TUint   numValues((sizeof(values) / sizeof(values[0])));
+    for (TUint i = 0; i < numValues; i++)
+        {
+        TMTPTypeUint8 data(values[i]);
+        expectedForm->AppendSupportedValueL(data);
+        }   
+    CMTPTypeObjectPropDesc* ret = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeNonConsumable, *expectedForm);     
+    CleanupStack::PopAndDestroy(expectedForm);
+    
+    return ret;
+    }
+
+TMTPResponseCode CMTPGetFormatCapabilities::CheckRequestL()
+    {
+    TMTPResponseCode response = CMTPRequestProcessor::CheckRequestL(); 
+    if( EMTPRespCodeOK != response )
+        return response;
+    
+    TUint32 formatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    
+    //[SP-Format-0x3002]
+	//Make the same behavior betwen 0x3000 and 0x3002.
+    if( (formatCode != EMTPFormatCodeUndefined) && (formatCode != EMTPFormatCodeAssociation) && (formatCode != KMTPFormatsAll) && ( EMTPFormatCodeScript != formatCode ))
+        {
+        return EMTPRespCodeInvalidObjectFormatCode;
+        }
+
+    if( (formatCode == EMTPFormatCodeAssociation) && (iFramework.DataProviderId() != KMTPDeviceDPID) )
+        {
+        return EMTPRespCodeInvalidObjectFormatCode;
+        }
+    
+    if( (formatCode == EMTPFormatCodeUndefined) && (iFramework.DataProviderId() != KMTPFileDPID) )
+        {
+        return EMTPRespCodeInvalidObjectFormatCode;
+        }
+    
+    return EMTPRespCodeOK;    
+    }
+    
+
+CMTPGetFormatCapabilities::CMTPGetFormatCapabilities(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+    {
+    }
+    
+void CMTPGetFormatCapabilities::ConstructL()
+    {
+    //[SP-Format-0x3002]
+    //Make the same behavior betwen 0x3000 and 0x3002.
+	//iSingletons is used to judge whether FileDP supports 0x3002 or not.
+    iSingletons.OpenL();
+    }
+
+
+   
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetinterdependentpropdesc.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,71 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/cmtptypeinterdependentpropdesc.h>
+#include "cmtpgetinterdependentpropdesc.h"
+
+
+
+/**
+Two-phase construction method
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/  
+EXPORT_C MMTPRequestProcessor* CMTPGetInterDependentPropDesc::NewL(MMTPDataProviderFramework& aFramework,
+														MMTPConnection& aConnection)
+	{
+	CMTPGetInterDependentPropDesc* self = new (ELeave) CMTPGetInterDependentPropDesc(aFramework, aConnection);
+	return self;	
+	}
+
+/**
+ Destructor
+*/
+EXPORT_C CMTPGetInterDependentPropDesc::~CMTPGetInterDependentPropDesc()
+	{
+	delete iDataset;
+	}
+
+/**
+Standard c++ constructor
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+*/
+CMTPGetInterDependentPropDesc::CMTPGetInterDependentPropDesc(MMTPDataProviderFramework& aFramework,
+															MMTPConnection& aConnection)
+	:CMTPRequestProcessor(aFramework, aConnection, 0, NULL)														
+	{
+	}
+
+
+/**
+ GetInterDependentPropDesc request handler
+*/
+void CMTPGetInterDependentPropDesc::ServiceL()
+	{
+	// Clear the data set.
+	delete iDataset;
+	iDataset = NULL;
+	iDataset = CMTPTypeInterdependentPropDesc::NewL();
+    
+	// Send the dataset.
+	SendDataL(*iDataset);
+	}
+	
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,143 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <f32file.h>
+
+#include <mtp/cmtptypefile.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpgetobject.h"
+#include "mtpdppanic.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"GetObject");)
+
+/**
+Verification data for the GetNumObjects request
+*/
+const TMTPRequestElementInfo KMTPGetObjectPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrFile, 0, 0, 0}
+    };
+
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/     
+EXPORT_C MMTPRequestProcessor* CMTPGetObject::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+	{
+	CMTPGetObject* self = new (ELeave) CMTPGetObject(aFramework, aConnection);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+Destructor
+*/	
+EXPORT_C CMTPGetObject::~CMTPGetObject()
+	{	
+    __FLOG(_L8("~CMTPGetObject - Entry"));
+	delete iFileObject;
+    __FLOG(_L8("~CMTPGetObject - Exit"));
+    __FLOG_CLOSE;
+	}
+	
+/**
+Standard c++ constructor
+*/	
+CMTPGetObject::CMTPGetObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) : 
+    CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetObjectPolicy),
+	iError(EMTPRespCodeOK)
+	{
+	
+	}
+
+/**
+Second-phase constructor.
+*/        
+void CMTPGetObject::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry"));
+    __FLOG(_L8("ConstructL - Exit"));
+    }
+
+/**
+GetObject request handler
+*/		
+void CMTPGetObject::ServiceL()
+	{
+    __FLOG(_L8("ServiceL - Entry"));
+	__ASSERT_DEBUG(iRequestChecker, Panic(EMTPDpRequestCheckNull));
+	TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+	//does not take ownership
+	CMTPObjectMetaData* objectInfo = iRequestChecker->GetObjectInfo(objectHandle);
+	if (!objectInfo)
+	    {
+	    // The object handle has already been checked, so an invalid handle can
+	    // only occur if it was invalidated during a context switch between
+	    // the validation time and now.
+	    iError = EMTPRespCodeInvalidObjectHandle;
+	    }
+	else if ( objectInfo->Uint(CMTPObjectMetaData::EFormatCode)==EMTPFormatCodeAssociation 
+	        && objectInfo->Uint(CMTPObjectMetaData::EFormatSubCode)==EMTPAssociationTypeGenericFolder)
+	    {
+	    iError = EMTPRespCodeInvalidObjectHandle;
+	    }
+    else
+        {
+    	BuildFileObjectL(objectInfo->DesC(CMTPObjectMetaData::ESuid));
+    	SendDataL(*iFileObject);	
+        }
+    __FLOG(_L8("ServiceL - Exit"));
+	}
+		
+
+/**
+Build the file object data set for the file requested
+@param aFileName	The file name of the requested object
+*/
+void CMTPGetObject::BuildFileObjectL(const TDesC& aFileName)
+	{
+    __FLOG(_L8("BuildFileObjectL - Entry"));
+	delete iFileObject;
+	iFileObject = NULL;
+	iFileObject = CMTPTypeFile::NewL(iFramework.Fs(), aFileName, EFileRead);
+    __FLOG(_L8("BuildFileObjectL - Exit"));
+	}
+	
+
+/**
+Handle the response phase of the current request
+@return EFalse
+*/		
+TBool CMTPGetObject::DoHandleResponsePhaseL()
+	{
+    __FLOG(_L8("DoHandleResponsePhaseL - Entry"));
+	TMTPResponseCode responseCode = (iCancelled ? EMTPRespCodeIncompleteTransfer : iError);
+	SendResponseL(responseCode);
+    __FLOG(_L8("DoHandleResponsePhaseL - Exit"));
+	return EFalse;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,167 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtptypeobjectinfo.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypestring.h>
+
+#include "cmtpgetobjectinfo.h"
+#include "mtpdppanic.h"
+
+/**
+Verification data for GetObjectInfo request
+*/
+const TMTPRequestElementInfo KMTPGetObjectInfoPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrNone, 0, 0, 0}
+    };
+
+/**
+Two-phase construction method
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/    
+EXPORT_C MMTPRequestProcessor* CMTPGetObjectInfo::NewL(MMTPDataProviderFramework& aFramework,											
+											MMTPConnection& aConnection)
+	{
+	CMTPGetObjectInfo* self = new (ELeave) CMTPGetObjectInfo(aFramework, aConnection);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+Destructor
+*/	
+EXPORT_C CMTPGetObjectInfo::~CMTPGetObjectInfo()
+	{	
+	delete iObjectInfoToBuild;
+	iDpSingletons.Close();
+	}
+
+/**
+Standard c++ constructor
+*/	
+CMTPGetObjectInfo::CMTPGetObjectInfo(MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection)
+	:CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetObjectInfoPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetObjectInfoPolicy),
+	iRfs(aFramework.Fs())
+	{
+	}
+
+/**
+GetObjectInfo request handler
+*/		
+void CMTPGetObjectInfo::ServiceL()
+	{
+	BuildObjectInfoL();
+	SendDataL(*iObjectInfoToBuild);	
+	}
+
+/**
+Second-phase construction
+*/		
+void CMTPGetObjectInfo::ConstructL()
+	{
+	iObjectInfoToBuild = CMTPTypeObjectInfo::NewL();
+	iDpSingletons.OpenL(iFramework);
+	}
+
+/**
+Populate the object info dataset
+*/		
+void CMTPGetObjectInfo::BuildObjectInfoL()	
+	{
+	__ASSERT_DEBUG(iRequestChecker, Panic(EMTPDpRequestCheckNull));
+	TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+	//does not take owernship
+	CMTPObjectMetaData* objectInfoFromStore = iRequestChecker->GetObjectInfo(objectHandle);
+	__ASSERT_DEBUG(objectInfoFromStore, Panic(EMTPDpObjectNull));
+	
+	TEntry fileEntry;
+	User::LeaveIfError(iRfs.Entry(objectInfoFromStore->DesC(CMTPObjectMetaData::ESuid), fileEntry));
+			
+	//1. storage id
+	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EStorageID, objectInfoFromStore->Uint(CMTPObjectMetaData::EStorageId));	
+	
+	//2. object format
+	iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EObjectFormat, objectInfoFromStore->Uint(CMTPObjectMetaData::EFormatCode));
+	
+	//3. protection status,
+	iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EProtectionStatus, fileEntry.IsReadOnly());
+	
+	//4. object compressed size
+	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EObjectCompressedSize, fileEntry.FileSize());
+	
+	//5. thumb format	
+	iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EThumbFormat, 0);
+	
+	//6. thumb compressed size
+	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EThumbCompressedSize, 0);
+	
+	//7. thumb pix width
+	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EThumbPixWidth, 0);
+	
+	//8, thumb pix height
+	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EThumbPixHeight, 0);
+	
+	//9. image pix width
+	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EImagePixWidth, 0);
+	
+	//10. image pix height
+	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EImagePixHeight, 0);
+	
+	//11. image bit depth
+	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EImageBitDepth, 0);
+	
+	//12. Parent object
+	TUint32 parentHandle = objectInfoFromStore->Uint(CMTPObjectMetaData::EParentHandle);
+	// refer to 5.3.1.9 of MTP Spec 1.0 
+	if (parentHandle == KMTPHandleNoParent)
+	    {
+	    parentHandle = 0;
+	    }
+	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EParentObject, parentHandle);
+		
+	//13 and 14. Association type and description
+	iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EAssociationType, objectInfoFromStore->Uint(CMTPObjectMetaData::EFormatSubCode));	
+	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EAssociationDescription, 0);
+		
+	//15. sequence number
+	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::ESequenceNumber, 0);
+	
+	//16. file name
+	iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EFilename, fileEntry.iName);
+	
+	//17. Date created
+	TBuf<64> dateString;	
+	iDpSingletons.MTPUtility().TTime2MTPTimeStr(fileEntry.iModified, dateString);
+	//file modified time
+	iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EDateModified, dateString);
+	
+	//18. Date modified
+	//file creation time, set it as the same as modified time, as Symbian does not support this field
+	iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EDateCreated, dateString);	
+		
+	//19. keyword
+	iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EKeywords, KNullDesC);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectpropdesc.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,336 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <f32file.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtptypeobjectpropdesc.h>
+
+#include <mtp/cmtptypestring.h>
+#include "cmtpgetobjectpropdesc.h"
+#include "mtpdpconst.h"
+#include "mtpdppanic.h"
+
+ 
+_LIT(KMtpObjDescObjFileName, "[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 7}\\.[[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 2}]?");
+
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+EXPORT_C MMTPRequestProcessor* CMTPGetObjectPropDesc::NewL(
+											MMTPDataProviderFramework& aFramework,
+											MMTPConnection& aConnection)
+	{
+	CMTPGetObjectPropDesc* self = new (ELeave) CMTPGetObjectPropDesc(aFramework, aConnection);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+Destructor
+*/		
+EXPORT_C CMTPGetObjectPropDesc::~CMTPGetObjectPropDesc()
+	{	
+	delete iObjectProperty;
+	}
+
+/**
+Standard c++ constructor
+*/	
+CMTPGetObjectPropDesc::CMTPGetObjectPropDesc(
+									MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection)
+	:CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+	{
+	}
+
+/**
+check format code and property code
+*/
+TMTPResponseCode CMTPGetObjectPropDesc::CheckRequestL()
+	{
+	TMTPResponseCode response = CMTPRequestProcessor::CheckRequestL(); 
+	TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+	TUint32 formatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+	
+    /**
+     * [SP-Format-0x3002]Special processing for PictBridge DP which own 6 dps file with format 0x3002, 
+     * but it does not really own the format 0x3002.
+     * 
+     * Make the same behavior betwen 0x3000 and 0x3002.
+     */
+	if((formatCode != EMTPFormatCodeUndefined) && (formatCode != EMTPFormatCodeAssociation) &&( EMTPFormatCodeScript != formatCode ))
+		{
+		response = EMTPRespCodeInvalidObjectFormatCode;
+		}
+	else
+		{
+		if(propCode != EMTPObjectPropCodeAssociationType && propCode != EMTPObjectPropCodeAssociationDesc)
+			{			
+			const TInt count = sizeof(KMTPDpSupportedProperties) / sizeof(TUint16);
+			TInt i = 0;
+			for(i = 0; i < count; i++)
+				{
+				if(KMTPDpSupportedProperties[i] == propCode)
+					{
+					break;
+					}
+				}
+			if(i == count)
+				{
+				response = EMTPRespCodeInvalidObjectPropCode;
+				}
+			}
+		else
+			{
+			if(formatCode != EMTPFormatCodeAssociation)
+			response = EMTPRespCodeInvalidObjectPropCode;
+			}
+		}
+	return response;	
+	}
+	
+/**
+GetObjectPropDesc request handler
+*/	
+void CMTPGetObjectPropDesc::ServiceL()
+	{
+	delete iObjectProperty;
+	iObjectProperty = NULL;	
+	
+	TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+	switch(propCode)
+		{
+		case EMTPObjectPropCodeStorageID:
+			ServiceStorageIdL();
+			break;
+		case EMTPObjectPropCodeObjectFormat:
+			ServiceObjectFormatL();
+			break;
+		case EMTPObjectPropCodeProtectionStatus:
+			ServiceProtectionStatusL();
+			break;
+		case EMTPObjectPropCodeObjectSize:
+			ServiceObjectSizeL();
+			break;
+		case EMTPObjectPropCodeAssociationType:
+			ServiceAssociationTypeL();
+			break;
+		case EMTPObjectPropCodeAssociationDesc:
+			ServiceAssociationDescL();
+			break;
+		case EMTPObjectPropCodeObjectFileName:
+			ServiceFileNameL();
+			break;
+		case EMTPObjectPropCodeDateModified:
+			ServiceDateModifiedL();
+			break;
+		case EMTPObjectPropCodeParentObject:
+			ServiceParentObjectL();
+			break;
+		case EMTPObjectPropCodePersistentUniqueObjectIdentifier:
+			ServicePuidL();
+			break;
+		case EMTPObjectPropCodeName:
+			ServiceNameL();
+			break;
+		case EMTPObjectPropCodeNonConsumable:
+			ServiceNonConsumableL();
+			break;
+		default:
+			Panic(EMTPDpUnsupportedProperty);
+		}
+	__ASSERT_DEBUG(iObjectProperty, Panic(EMTPDpObjectPropertyNull));
+	iObjectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(propCode));
+	SendDataL(*iObjectProperty);	
+	}
+
+
+/**
+Second-phase construction
+*/			
+void CMTPGetObjectPropDesc::ConstructL()
+	{
+	}
+		
+
+void CMTPGetObjectPropDesc::ServiceStorageIdL()
+	{
+	iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeStorageID);	
+	}
+	
+void CMTPGetObjectPropDesc::ServiceObjectFormatL()
+	{	
+	iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectFormat);	
+	}
+	
+void CMTPGetObjectPropDesc::ServiceProtectionStatusL()
+	{
+    CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT16);
+    CleanupStack::PushL(expectedForm);
+    //Currently, we only support EMTPProtectionNoProtection and EMTPProtectionReadOnly
+//  TUint16 values[] = {EMTPProtectionNoProtection, EMTPProtectionReadOnly, EMTPProtectionReadOnlyData, EMTPProtectionNonTransferable};
+    TUint16 values[] = {EMTPProtectionNoProtection, EMTPProtectionReadOnly};
+    TUint   numValues((sizeof(values) / sizeof(values[0])));
+    for (TUint i = 0; i < numValues; i++)
+        {
+        TMTPTypeUint16 data(values[i]);
+        expectedForm->AppendSupportedValueL(data);
+        }  
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeProtectionStatus, *expectedForm);      	
+    CleanupStack::PopAndDestroy(expectedForm);
+	}
+	
+void CMTPGetObjectPropDesc::ServiceObjectSizeL()
+	{
+	iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectSize);	
+	}
+	
+void CMTPGetObjectPropDesc::ServiceAssociationTypeL()
+	{
+	CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT16);
+    CleanupStack::PushL(expectedForm);
+
+    const TUint16 KMtpValues[] = { EMTPAssociationTypeGenericFolder };
+    const TUint KNumMtpValues(sizeof(KMtpValues) / sizeof(KMtpValues[0])); 
+    const TUint16 KPtpValues[] = {EMTPAssociationTypeUndefined, EMTPAssociationTypeGenericFolder, EMTPAssociationTypeAlbum, EMTPAssociationTypeTimeSequence, EMTPAssociationTypeHorizontalPanoramic, EMTPAssociationTypeVerticalPanoramic, EMTPAssociationType2DPanoramic,EMTPAssociationTypeAncillaryData};
+    const TUint KNumPtpValues(sizeof(KPtpValues) / sizeof(KPtpValues[0]));
+
+    TUint numValues(KNumMtpValues);
+    const TUint16* values = KMtpValues;
+    if (EModeMTP != iFramework.Mode())
+    	 {
+    	 numValues = KNumPtpValues;
+    	 values = KPtpValues;            
+    	 }
+   
+    for (TUint i = 0; i < numValues; i++)
+        {
+        TMTPTypeUint16 data(values[i]);
+        expectedForm->AppendSupportedValueL(data);
+        }  
+
+    iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeAssociationType, *expectedForm);
+    CleanupStack::PopAndDestroy(expectedForm);
+	}
+
+void CMTPGetObjectPropDesc::ServiceAssociationDescL()
+	{
+	iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeAssociationDesc);	
+	}
+	
+void CMTPGetObjectPropDesc::ServiceFileNameL()
+	{
+        CMTPTypeString* form = CMTPTypeString::NewLC( KMtpObjDescObjFileName ); // + form
+        // Althrough iObjectProperty is released in ServiceL(),
+        // release it here maybe a more safer way 
+        if ( iObjectProperty != NULL )
+        {
+        delete iObjectProperty;
+        iObjectProperty = NULL;
+        }
+
+        iObjectProperty = CMTPTypeObjectPropDesc::NewL( EMTPObjectPropCodeObjectFileName,
+        CMTPTypeObjectPropDesc::ERegularExpressionForm,
+        form );
+
+        CleanupStack::PopAndDestroy( form ); // - form
+
+	}
+	
+void CMTPGetObjectPropDesc::ServiceDateModifiedL()
+	{
+	iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeDateModified);
+	}
+	
+void CMTPGetObjectPropDesc::ServiceParentObjectL()
+	{
+	iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeParentObject);
+	}
+	
+void CMTPGetObjectPropDesc::ServicePuidL()
+	{
+	iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodePersistentUniqueObjectIdentifier);
+	}
+	
+void CMTPGetObjectPropDesc::ServiceNameL()
+	{
+	iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeName);	
+	}
+	
+void CMTPGetObjectPropDesc::ServiceNonConsumableL()
+	{
+    CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT8);
+    CleanupStack::PushL(expectedForm);
+    TUint8 values[] = {0,1};
+    TUint   numValues((sizeof(values) / sizeof(values[0])));
+    for (TUint i = 0; i < numValues; i++)
+        {
+        TMTPTypeUint8 data(values[i]);
+        expectedForm->AppendSupportedValueL(data);
+        } 	
+	iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeNonConsumable, *expectedForm);		
+	CleanupStack::PopAndDestroy(expectedForm);
+	}
+
+
+	
+TUint16  CMTPGetObjectPropDesc::GetPropertyGroupNumber(const TUint16 aPropCode) const
+    {
+    
+    // begin from group 1, since group 0 is not used
+	for(int group = 1; group <= KMTPDpPropertyGroupNumber; group++)
+		{
+		for( int propCodeIndex = 0 ; propCodeIndex < KMTPDpPropertyNumber ; propCodeIndex++)
+			{
+				if(KMTPDpPropertyGroups[group][propCodeIndex] == aPropCode)
+					{
+					return group;
+					}
+			}
+		}
+	
+    // if not foud, the group number should be 0.
+	return 0;
+	}
+
+
+
+
+
+
+
+	
+
+	
+
+
+   	
+
+	
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,458 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <bautils.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/cmtptypeobjectproplist.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpgetobjectproplist.h"
+#include "cmtpfsexclusionmgr.h"
+#include "mtpdpconst.h"
+#include "mtpdppanic.h"
+
+/**
+Verification data for the GetNumObjects request
+*/
+const TMTPRequestElementInfo KMTPGetObjectPropListPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrNone, 2, KMTPHandleAll, KMTPHandleNone}
+    };
+    
+EXPORT_C MMTPRequestProcessor* CMTPGetObjectPropList::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPGetObjectPropList* self = new (ELeave) CMTPGetObjectPropList(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+    
+EXPORT_C CMTPGetObjectPropList::~CMTPGetObjectPropList()
+    {
+    delete iHandles;
+    delete iPropertyList;
+    iDpSingletons.Close();
+    delete iObjMeta;
+    }
+
+void CMTPGetObjectPropList::ServiceL()
+    {
+    TUint32 propCode(Request().Uint32(TMTPTypeRequest::ERequestParameter3));
+	TUint32 groupCode(Request().Uint32(TMTPTypeRequest::ERequestParameter4));
+	
+	if( ( propCode != 0 ) || ( (groupCode !=0) && (groupCode <= KMTPDpPropertyGroupNumber) ) )
+		{
+		GetObjectHandlesL();
+		TInt numObjects(iHandles->NumElements());
+		for (TInt i(0); (i < numObjects); i++)
+			{
+			TUint32 handle(iHandles->ElementUint(i));
+			iFramework.ObjectMgr().ObjectL(handle, *iObjMeta);
+			TFileName file(iObjMeta->DesC(CMTPObjectMetaData::ESuid));
+			User::LeaveIfError(iFramework.Fs().Entry(iObjMeta->DesC(CMTPObjectMetaData::ESuid), iFileEntry));
+			
+			if (propCode == KMaxTUint)
+				{
+				ServiceAllPropertiesL(handle);
+				}
+			else if( propCode == 0)
+				{		
+				ServiceGroupPropertiesL(handle,groupCode);
+				}
+			else    
+				{
+				ServiceOneObjectPropertyL(handle, propCode);
+				}
+			}
+		}
+	//else
+	//it means the groupcode is not supported, return EMTPRespCodeGroupNotSupported(0xA805) response.
+	//but we use one empty ObjectPropList to replace the EMTPRespCodeGroupNotSupported(0xA805) response.
+	
+    SendDataL(*iPropertyList);    
+    }
+    
+TMTPResponseCode CMTPGetObjectPropList::CheckRequestL()
+    {
+    TMTPResponseCode result = CMTPRequestProcessor::CheckRequestL();
+    if (result == EMTPRespCodeOK)
+        {
+        result = CheckFormatL();
+        }
+        
+    if (result == EMTPRespCodeOK)
+        {        
+        result = CheckPropCode();        
+        }
+    
+    if (result == EMTPRespCodeOK)
+        {
+        result = CheckDepth();
+        }
+    
+    return result;    
+    }
+    
+CMTPGetObjectPropList::CMTPGetObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, (sizeof(KMTPGetObjectPropListPolicy) / sizeof(TMTPRequestElementInfo)), KMTPGetObjectPropListPolicy)
+    {
+    }
+    
+void CMTPGetObjectPropList::ConstructL()
+    {
+    iDpSingletons.OpenL(iFramework);
+    iPropertyList = CMTPTypeObjectPropList::NewL();
+	iObjMeta = CMTPObjectMetaData::NewL();
+    }
+
+TMTPResponseCode CMTPGetObjectPropList::CheckFormatL() const
+    {
+    TMTPResponseCode response = EMTPRespCodeOK; 
+    
+    const TUint32 KFormat = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+    
+    if ( (KFormat!=KMTPFormatsAll)&&(KFormat!=EMTPFormatCodeAssociation)&&(KFormat!=EMTPFormatCodeUndefined)&&(KFormat!=EMTPFormatCodeScript) && (iDpSingletons.ExclusionMgrL().IsFormatValid(TMTPFormatCode(KFormat))) )
+        {
+        response = EMTPRespCodeSpecificationByFormatUnsupported;
+        }
+    return response;    
+    }
+    
+TMTPResponseCode CMTPGetObjectPropList::CheckPropCode() const
+    {
+    TMTPResponseCode response = EMTPRespCodeOK; 
+	TUint32 formatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+    TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
+    if (propCode == 0)
+        {
+        //GroupCode should be supported.
+        return response;
+        }
+    else if (propCode != KMaxTUint)
+        {
+        if(propCode != EMTPObjectPropCodeAssociationType && propCode != EMTPObjectPropCodeAssociationDesc)
+			{
+			const TInt count = sizeof(KMTPDpSupportedProperties) / sizeof(TUint16);
+			TInt i(0);
+			for(i = 0; i < count; i++)
+				{
+				if(KMTPDpSupportedProperties[i] == propCode)
+					{
+					break;
+					}
+				}
+			if(i == count)
+				{
+				response = EMTPRespCodeInvalidObjectPropCode;
+				}		
+			}
+		else
+			{
+			if(formatCode != EMTPFormatCodeAssociation && formatCode != KMTPFormatsAll)
+			response = EMTPRespCodeInvalidObjectPropCode;
+			}	
+        }
+    return response;
+    }
+    
+/**
+Ensures that the requested object depth is one we support.
+@return EMTPRespCodeOK, or EMTPRespCodeSpecificationByDepthUnsupported if the depth is unsupported
+*/
+TMTPResponseCode CMTPGetObjectPropList::CheckDepth() const
+    {
+    TMTPResponseCode response = EMTPRespCodeSpecificationByDepthUnsupported;
+    
+    // We either support no depth at all, or 1 depth or (0xFFFFFFFF) with objecthandle as 0x00000000 
+    TUint32 handle(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
+    TUint32 depth = Request().Uint32(TMTPTypeRequest::ERequestParameter5);
+        
+    if ( (depth == 0) || (depth == 1 ) ||
+    	 (depth == KMaxTUint && handle == KMTPHandleNone ) ) 
+    	{
+        response = EMTPRespCodeOK; 
+        }
+    return response;    
+    
+    }
+
+void CMTPGetObjectPropList::GetObjectHandlesL()
+    {
+    TUint32 handle(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
+    TUint32 formatCode(Request().Uint32(TMTPTypeRequest::ERequestParameter2));
+    TUint32 depth(Request().Uint32(TMTPTypeRequest::ERequestParameter5));
+        	
+    delete iHandles;
+    iHandles = NULL;
+    
+    if (handle == KMTPHandleAll)
+        {
+        GetObjectHandlesL(KMTPStorageAll, formatCode, KMTPHandleNone);
+        }
+    else if (handle == KMTPHandleNone)
+        {
+        GetRootObjectHandlesL(formatCode, depth);
+        }
+    else 
+    	{
+    	CMTPObjectMetaData* meta(iRequestChecker->GetObjectInfo(handle));
+		__ASSERT_DEBUG(meta, Panic(EMTPDpObjectNull));
+		
+    	if ((meta->Uint(CMTPObjectMetaData::EFormatCode) == EMTPFormatCodeAssociation) &&
+              (meta->Uint(CMTPObjectMetaData::EFormatSubCode) == EMTPAssociationTypeGenericFolder))
+    		{
+    		GetFolderObjectHandlesL(formatCode, depth, handle);
+    		}
+    		else	
+       		{
+       		GetSpecificObjectHandlesL(handle, formatCode, depth);
+       		}	
+    	}
+    
+    }
+
+void CMTPGetObjectPropList::GetObjectHandlesL(TUint32 aStorageId, TUint32 aFormatCode, TUint32 aParentHandle)
+    {
+	RMTPObjectMgrQueryContext   context;
+	RArray<TUint>               handles;
+	TMTPObjectMgrQueryParams    params(aStorageId, aFormatCode, aParentHandle, iFramework.DataProviderId());
+	CleanupClosePushL(context);
+	CleanupClosePushL(handles);
+	
+	delete iHandles;
+	iHandles = CMTPTypeArray::NewL(EMTPTypeAUINT32);
+	
+	do
+	    {
+    	iFramework.ObjectMgr().GetObjectHandlesL(params, context, handles);
+    	iHandles->AppendL(handles);
+	    }
+	while (!context.QueryComplete());
+	
+	CleanupStack::PopAndDestroy(&handles);
+	CleanupStack::PopAndDestroy(&context);
+    }
+    
+void CMTPGetObjectPropList::GetFolderObjectHandlesL(TUint32 aFormatCode, TUint32 aDepth,TUint32 aParentHandle)
+    {
+    // Folder object request has been filtered by Proxy DP with setting depth as zero
+    __ASSERT_DEBUG( ( 0 == aDepth ), User::Invariant() );
+    GetSpecificObjectHandlesL( aParentHandle, aFormatCode, aDepth );
+    }
+    
+void CMTPGetObjectPropList::GetRootObjectHandlesL(TUint32 aFormatCode, TUint32 aDepth)
+    {
+	if (aDepth == KMaxTUint)
+        {
+        GetObjectHandlesL(KMTPStorageAll, aFormatCode, KMTPHandleNone);
+        }
+    else if (aDepth == 0)
+        {
+        iHandles = CMTPTypeArray::NewL(EMTPTypeAUINT32);    //empty array        
+        }
+    else
+        {
+        GetObjectHandlesL(KMTPStorageAll, aFormatCode, KMTPHandleNoParent);
+        }    
+	}
+    
+void CMTPGetObjectPropList::GetSpecificObjectHandlesL(TUint32 aHandle, TUint32 /*aFormatCode*/, TUint32 /*aDepth*/)
+    {
+    iHandles = CMTPTypeArray::NewL(EMTPTypeAUINT32);
+    iHandles->AppendUintL(aHandle);
+    }
+
+void CMTPGetObjectPropList::ServiceAllPropertiesL(TUint32 aHandle)
+    {
+    if (iFramework.ObjectMgr().ObjectOwnerId(aHandle) == iFramework.DataProviderId())
+        {
+        for (TUint i(0); (i < (sizeof(KMTPDpSupportedProperties) / sizeof(TUint16))); i++)
+            {
+            ServiceOneObjectPropertyL(aHandle, KMTPDpSupportedProperties[i]);
+            }
+        }
+
+
+	if (iObjMeta->Uint( CMTPObjectMetaData::EFormatCode ) == EMTPFormatCodeAssociation)
+		{
+        CMTPTypeObjectPropListElement& propElem1 = iPropertyList->ReservePropElemL(aHandle, static_cast<TUint16>(EMTPObjectPropCodeAssociationType));
+        propElem1.SetUint16L(CMTPTypeObjectPropListElement::EValue, EMTPAssociationTypeGenericFolder);
+        iPropertyList->CommitPropElemL(propElem1);
+        
+        CMTPTypeObjectPropListElement& propElem2 = iPropertyList->ReservePropElemL(aHandle, static_cast<TUint16>(EMTPObjectPropCodeAssociationDesc));
+        propElem2.SetUint32L(CMTPTypeObjectPropListElement::EValue, 0);
+        iPropertyList->CommitPropElemL(propElem2); 
+        
+		}
+			
+    }
+    
+void CMTPGetObjectPropList::ServiceGroupPropertiesL(TUint32 aHandle,TUint16 aGroupCode)
+	{
+	if (iFramework.ObjectMgr().ObjectOwnerId(aHandle) == iFramework.DataProviderId())
+        {
+        for (TUint propCodeIndex(0); propCodeIndex < KMTPDpPropertyNumber; propCodeIndex++)
+            {
+            TUint16 propCode = KMTPDpPropertyGroups[aGroupCode][propCodeIndex];  
+            if(propCode != 0)
+            	{
+            	ServiceOneObjectPropertyL(aHandle, propCode);
+            	}
+            }
+        }
+
+	}
+void CMTPGetObjectPropList::ServiceOneObjectPropertyL(TUint32 aHandle, TUint32 aPropCode)
+    {
+    if (iFramework.ObjectMgr().ObjectOwnerId(aHandle) == iFramework.DataProviderId())
+        {
+        switch(aPropCode)
+            {
+        case EMTPObjectPropCodeNonConsumable:
+            {
+            
+            TUint8 value = iObjMeta->Uint(CMTPObjectMetaData::ENonConsumable);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetUint8L(CMTPTypeObjectPropListElement::EValue, value);
+            iPropertyList->CommitPropElemL(propElem);
+            }        
+            break;
+            
+        case EMTPObjectPropCodeObjectFormat:
+        	{
+            TUint16 value = iObjMeta->Uint(CMTPObjectMetaData::EFormatCode);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetUint16L(CMTPTypeObjectPropListElement::EValue, value);
+            iPropertyList->CommitPropElemL(propElem);
+        	}
+        	break;
+        	
+        case EMTPObjectPropCodeProtectionStatus:
+            {
+            TUint16 value = iFileEntry.IsReadOnly();
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetUint16L(CMTPTypeObjectPropListElement::EValue, value);
+            iPropertyList->CommitPropElemL(propElem);
+            }
+            break;
+            
+        case EMTPObjectPropCodeStorageID:
+        	{
+            TUint32 value = iObjMeta->Uint(CMTPObjectMetaData::EStorageId);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetUint32L(CMTPTypeObjectPropListElement::EValue, value);
+            iPropertyList->CommitPropElemL(propElem);
+        	}
+        	break;
+        	
+        case EMTPObjectPropCodeParentObject:
+            {
+            TUint32 parentHandle = iObjMeta->Uint(CMTPObjectMetaData::EParentHandle);
+            // refer to Appendix B.2.11 of MTP Spec 1.0 
+            if (parentHandle == KMTPHandleNoParent)
+                {
+                parentHandle = 0;
+                }
+
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetUint32L(CMTPTypeObjectPropListElement::EValue, parentHandle);
+            iPropertyList->CommitPropElemL(propElem);
+            }
+            break;
+            
+        case EMTPObjectPropCodeObjectSize:
+            {
+            TUint64 value = iFileEntry.FileSize();
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetUint64L(CMTPTypeObjectPropListElement::EValue, value);
+            iPropertyList->CommitPropElemL(propElem);
+            }
+            break;
+            
+        case EMTPObjectPropCodePersistentUniqueObjectIdentifier:
+            {
+            TMTPTypeUint128 value = iFramework.ObjectMgr().PuidL(aHandle);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetUint128L(CMTPTypeObjectPropListElement::EValue, value.UpperValue(), value.LowerValue());
+            iPropertyList->CommitPropElemL(propElem); 
+            }        
+            break;
+            
+        case EMTPObjectPropCodeDateModified:
+        	{
+            TBuf<64> dateString;    
+            iDpSingletons.MTPUtility().TTime2MTPTimeStr(iFileEntry.iModified, dateString);        	
+            CMTPTypeString* value = CMTPTypeString::NewLC(dateString);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetStringL(CMTPTypeObjectPropListElement::EValue, value->StringChars());
+            iPropertyList->CommitPropElemL(propElem);
+            CleanupStack::PopAndDestroy(value);
+        	}
+        	break;
+        	
+        case EMTPObjectPropCodeObjectFileName:
+        	{
+            CMTPTypeString* value = CMTPTypeString::NewLC(iFileEntry.iName);
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetStringL(CMTPTypeObjectPropListElement::EValue, value->StringChars());
+            iPropertyList->CommitPropElemL(propElem);
+            CleanupStack::PopAndDestroy(value);
+        	}
+        	break;
+        	
+        case EMTPObjectPropCodeName:
+            {
+            CMTPTypeString* value = CMTPTypeString::NewLC(iObjMeta->DesC(CMTPObjectMetaData::EName));
+            CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+            propElem.SetStringL(CMTPTypeObjectPropListElement::EValue, value->StringChars());
+            iPropertyList->CommitPropElemL(propElem);
+            CleanupStack::PopAndDestroy(value);
+            }
+            break;
+        case EMTPObjectPropCodeAssociationType:
+        	{        		
+        	if (iObjMeta->Uint( CMTPObjectMetaData::EFormatCode ) == EMTPFormatCodeAssociation)
+				{
+				TUint16 value = iObjMeta->Uint(CMTPObjectMetaData::EFormatSubCode);
+                CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+                propElem.SetUint16L(CMTPTypeObjectPropListElement::EValue, value);
+                iPropertyList->CommitPropElemL(propElem);
+				}
+        	}
+        	break;
+         case EMTPObjectPropCodeAssociationDesc:
+        	{
+			if (iObjMeta->Uint( CMTPObjectMetaData::EFormatCode ) == EMTPFormatCodeAssociation)
+				{
+                CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, aPropCode);
+                propElem.SetUint32L(CMTPTypeObjectPropListElement::EValue, 0x0000);
+                iPropertyList->CommitPropElemL(propElem);  
+				}
+        	}
+        	break;    
+        default:
+            Panic(EMTPDpUnsupportedProperty);
+            break;
+            }       
+        } 
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectpropssupported.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,157 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <f32file.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/mtpdatatypeconstants.h>
+
+#include "cmtpgetobjectpropssupported.h"
+#include "mtpdpconst.h"
+
+/**
+Verification data for the GetObjectPropSupported request
+*/
+const TMTPRequestElementInfo KMTPGetObjectPropSupportedPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeFormatCode, EMTPElementAttrNone, 1, EMTPFormatCodeUndefined, 0},
+    };
+ 
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/     
+EXPORT_C MMTPRequestProcessor* CMTPGetObjectPropsSupported::NewL(
+											MMTPDataProviderFramework& aFramework,
+											MMTPConnection& aConnection)
+	{
+	CMTPGetObjectPropsSupported* self = new (ELeave) CMTPGetObjectPropsSupported(aFramework, aConnection);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+Destructor
+*/	
+EXPORT_C CMTPGetObjectPropsSupported::~CMTPGetObjectPropsSupported()
+	{
+	delete iObjectPropsSupported;
+	}
+
+/**
+Standard c++ constructor
+*/		
+CMTPGetObjectPropsSupported::CMTPGetObjectPropsSupported(
+									MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection)
+	:CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetObjectPropSupportedPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetObjectPropSupportedPolicy)
+	{
+	}
+									
+/**
+check format code
+*/
+TMTPResponseCode CMTPGetObjectPropsSupported::CheckRequestL()
+    {
+    TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL(); 
+    
+    if (EMTPRespCodeOK == responseCode)
+        {
+        TUint32 formatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+        
+        /**
+         * [SP-Format-0x3002]Special processing for PictBridge DP which own 6 dps file with format 0x3002, 
+         * but it does not really own the format 0x3002.
+         * 
+         * Make the same behavior betwen 0x3000 and 0x3002.
+         */
+        if((formatCode != EMTPFormatCodeUndefined) && (formatCode != EMTPFormatCodeAssociation) &&(EMTPFormatCodeScript != formatCode))
+            {
+            responseCode = EMTPRespCodeInvalidObjectFormatCode;
+            }
+        }
+
+    return responseCode;
+    }									
+	
+/**
+GetObjectPropSupported request handler
+*/
+void CMTPGetObjectPropsSupported::ServiceL()
+	{
+	TInt count = sizeof(KMTPDpSupportedProperties) / sizeof(TUint16);
+	for(TInt i = 0; i < count; i++)
+		{
+		iObjectPropsSupported->AppendUintL(KMTPDpSupportedProperties[i]);
+		}
+	TUint32 objectFormatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+	if(objectFormatCode == EMTPFormatCodeAssociation)
+		{
+		iObjectPropsSupported->AppendUintL(EMTPObjectPropCodeAssociationType);
+		iObjectPropsSupported->AppendUintL(EMTPObjectPropCodeAssociationDesc);
+		}			
+	SendDataL(*iObjectPropsSupported);	
+	}
+
+/**
+Second-phase construction
+*/		
+void CMTPGetObjectPropsSupported::ConstructL()
+	{
+	iObjectPropsSupported = CMTPTypeArray::NewL(EMTPTypeAUINT16);	
+	}
+		
+
+
+
+
+	
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+	
+
+	
+
+
+   	
+
+	
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectpropvalue.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,299 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <f32file.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/tmtptypeuint8.h>
+#include <mtp/tmtptypeuint32.h>
+#include <mtp/tmtptypeuint64.h>
+#include <mtp/tmtptypeuint128.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpobjectmgr.h>
+
+#include "cmtpgetobjectpropvalue.h"
+#include "mtpdpconst.h"
+#include "mtpdppanic.h"
+
+
+/**
+Verification data for the GetObjectPropValue request
+*/
+const TMTPRequestElementInfo KMTPGetObjectPropValuePolicy[] = 
+    {
+    	{TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrNone, 0, 0, 0},   	
+     };
+
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+EXPORT_C MMTPRequestProcessor* CMTPGetObjectPropValue::NewL(
+											MMTPDataProviderFramework& aFramework,
+											MMTPConnection& aConnection)
+	{
+	CMTPGetObjectPropValue* self = new (ELeave) CMTPGetObjectPropValue(aFramework, aConnection);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+Destructor
+*/		
+EXPORT_C CMTPGetObjectPropValue::~CMTPGetObjectPropValue()
+	{
+	delete iMTPTypeString;	
+	delete iObjMeta;
+	}
+
+/**
+Standard c++ constructor
+*/		
+CMTPGetObjectPropValue::CMTPGetObjectPropValue(
+									MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection)
+	:CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetObjectPropValuePolicy)/sizeof(TMTPRequestElementInfo), KMTPGetObjectPropValuePolicy),
+	iRfs(aFramework.Fs())
+	{
+	}
+
+/**
+Verify request
+*/
+TMTPResponseCode CMTPGetObjectPropValue::CheckRequestL()
+	{
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+	
+	if(responseCode == EMTPRespCodeOK)
+		{
+		if(propCode != EMTPObjectPropCodeAssociationType && propCode != EMTPObjectPropCodeAssociationDesc)
+			{
+			const TInt count = sizeof(KMTPDpSupportedProperties) / sizeof(TUint16);
+			TInt i = 0;
+			for(i = 0; i < count; i++)
+				{
+				if(KMTPDpSupportedProperties[i] == propCode)
+					{
+					break;
+					}
+				}
+			if(i == count)
+				{
+				responseCode = EMTPRespCodeInvalidObjectPropCode;
+				}		
+			}
+		else
+			{
+			TUint32 handle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+			CMTPObjectMetaData* meta = iRequestChecker->GetObjectInfo(handle);
+			__ASSERT_DEBUG(meta, Panic(EMTPDpObjectNull));
+			
+			TUint16 format = meta->Uint(CMTPObjectMetaData::EFormatCode);
+			if(format != EMTPFormatCodeAssociation)
+				responseCode = EMTPRespCodeInvalidObjectPropCode;
+			}
+		}
+	return responseCode;	
+	}
+	
+/**
+GetObjectPropValue request handler
+*/		
+void CMTPGetObjectPropValue::ServiceL()
+	{
+	__ASSERT_DEBUG(iRequestChecker, Panic(EMTPDpRequestCheckNull));
+	
+	TUint32 handle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+	iFramework.ObjectMgr().ObjectL(TMTPTypeUint32(handle), *iObjMeta);
+	User::LeaveIfError(iRfs.Entry(iObjMeta->DesC(CMTPObjectMetaData::ESuid), iFileEntry));
+	
+	TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+	switch(propCode)
+		{
+		case EMTPObjectPropCodeStorageID:
+			ServiceStorageIdL();
+			break;
+		case EMTPObjectPropCodeObjectFormat:
+			ServiceObjectFormatL();
+			break;
+		case EMTPObjectPropCodeProtectionStatus:
+			ServiceProtectionStatusL();
+			break;
+		case EMTPObjectPropCodeObjectSize:
+			ServiceObjectSizeL();
+			break;
+		case EMTPObjectPropCodeAssociationType:						
+			ServiceObjectAssociationTypeL();
+			break;
+		case EMTPObjectPropCodeAssociationDesc:
+			ServiceObjectAssociationDescL();
+			break;
+		case EMTPObjectPropCodeObjectFileName:
+			ServiceFileNameL();
+			break;
+		case EMTPObjectPropCodeDateModified:
+			ServiceDateModifiedL();
+			break;
+		case EMTPObjectPropCodeParentObject:
+			ServiceParentObjectL();
+			break;
+		case EMTPObjectPropCodePersistentUniqueObjectIdentifier:
+			ServicePuidL();
+			break;
+		case EMTPObjectPropCodeName:
+			ServiceNameL();
+			break;
+		case EMTPObjectPropCodeNonConsumable:
+			ServiceNonConsumableL();
+			break;
+		default:
+			Panic(EMTPDpUnsupportedProperty);
+		}	
+	}
+
+/**
+Second-phase construction
+*/					
+void CMTPGetObjectPropValue::ConstructL()
+	{
+	iObjMeta	= CMTPObjectMetaData::NewL();
+	iMTPTypeString = CMTPTypeString::NewL();
+	}		
+
+void CMTPGetObjectPropValue::ServiceStorageIdL()
+	{
+	iMTPTypeUint32.Set(iObjMeta->Uint(CMTPObjectMetaData::EStorageId));	
+	SendDataL(iMTPTypeUint32);
+	}
+	
+void CMTPGetObjectPropValue::ServiceObjectFormatL()
+	{
+	iMTPTypeUint16.Set(iObjMeta->Uint(CMTPObjectMetaData::EFormatCode));
+	
+	SendDataL(iMTPTypeUint16);	
+	}
+	
+void CMTPGetObjectPropValue::ServiceProtectionStatusL()
+	{
+	iMTPTypeUint16.Set(iFileEntry.IsReadOnly());
+
+	SendDataL(iMTPTypeUint16);	
+	}
+	
+void CMTPGetObjectPropValue::ServiceObjectSizeL()
+	{
+	iMTPTypeUint64.Set(iFileEntry.iSize);
+
+	SendDataL(iMTPTypeUint64);
+	}
+	
+void CMTPGetObjectPropValue::ServiceObjectAssociationTypeL()	
+	{
+	iMTPTypeUint16.Set(iObjMeta->Uint(CMTPObjectMetaData::EFormatSubCode));
+
+	SendDataL(iMTPTypeUint16);
+	}
+
+void CMTPGetObjectPropValue::ServiceObjectAssociationDescL()	
+	{
+	iMTPTypeUint64.Set(0x00000000);
+	SendDataL(iMTPTypeUint64);
+	}	
+	
+void CMTPGetObjectPropValue::ServiceFileNameL()
+	{
+	iMTPTypeString->SetL(iFileEntry.iName);
+	SendDataL(*iMTPTypeString);
+	}
+	
+void CMTPGetObjectPropValue::ServiceDateModifiedL()
+	{
+	_LIT(KMTPDateStringFormat,"%F%Y%M%DT%H%T%S");	
+	TBuf<64> dateString;	
+	iFileEntry.iModified.FormatL(dateString,KMTPDateStringFormat);
+	iMTPTypeString->SetL(dateString);
+	SendDataL(*iMTPTypeString);
+	}
+	
+void CMTPGetObjectPropValue::ServiceParentObjectL()
+	{
+    TUint32 parentHandle = iObjMeta->Uint(CMTPObjectMetaData::EParentHandle);
+    if (parentHandle == KMTPHandleNoParent)
+        {
+        parentHandle = 0;
+        }
+    iMTPTypeUint32.Set(parentHandle);
+
+    SendDataL(iMTPTypeUint32);
+	}
+	
+void CMTPGetObjectPropValue::ServicePuidL()
+	{
+	iMTPTypeUint128 = iFramework.ObjectMgr().PuidL((TUint32)iObjMeta->Uint(CMTPObjectMetaData::EHandle));
+	SendDataL(iMTPTypeUint128);
+	}
+	
+void CMTPGetObjectPropValue::ServiceNameL()
+	{
+	iMTPTypeString->SetL(iObjMeta->DesC(CMTPObjectMetaData::EName));
+	SendDataL(*iMTPTypeString);
+	}
+	
+void CMTPGetObjectPropValue::ServiceNonConsumableL()
+	{
+	iMTPTypeUint8.Set((iObjMeta->Uint(CMTPObjectMetaData::ENonConsumable)));
+	SendDataL(iMTPTypeUint8);
+	}
+
+
+
+	
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+	
+
+	
+
+
+   	
+
+	
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetpartialobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,162 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <f32file.h>
+
+#include <mtp/cmtptypefile.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpgetpartialobject.h"
+#include "mtpdppanic.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"GetObject");)
+
+/**
+Verification data for the GetNumObjects request
+*/
+const TMTPRequestElementInfo KMTPGetPartialObjectPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrFile, 0, 0, 0}
+    };
+
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/     
+EXPORT_C MMTPRequestProcessor* CMTPGetPartialObject::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+	{
+	CMTPGetPartialObject* self = new (ELeave) CMTPGetPartialObject(aFramework, aConnection);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+Destructor
+*/	
+EXPORT_C CMTPGetPartialObject::~CMTPGetPartialObject()
+	{	
+    __FLOG(_L8("~CMTPGetPartialObject - Entry"));
+	delete iFileObject;
+    __FLOG(_L8("~CMTPGetPartialObject - Exit"));
+    __FLOG_CLOSE;
+	}
+	
+/**
+Standard c++ constructor
+*/	
+CMTPGetPartialObject::CMTPGetPartialObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) : 
+    CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetPartialObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetPartialObjectPolicy)
+	{
+	
+	}
+
+/**
+Second-phase constructor.
+*/        
+void CMTPGetPartialObject::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry"));
+    __FLOG(_L8("ConstructL - Exit"));
+    }
+
+/**
+Check the GetPartialObject reqeust
+@return EMTPRespCodeOK if the request is good, otherwise, one of the error response codes
+*/  
+TMTPResponseCode CMTPGetPartialObject::CheckRequestL()
+    {
+    __FLOG(_L8("CheckRequestL - Entry"));
+    TMTPResponseCode result = CMTPRequestProcessor::CheckRequestL();
+    if(result == EMTPRespCodeOK)
+        {
+        TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+        iOffset = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+        iLength = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
+        
+        //does not take ownership
+        iObjectInfo = iRequestChecker->GetObjectInfo(objectHandle);
+        if (!iObjectInfo)
+            {
+            // The object handle has already been checked, so an invalid handle can
+            // only occur if it was invalidated during a context switch between
+            // the validation time and now.
+            result = EMTPRespCodeInvalidObjectHandle;
+            }
+        else
+            {
+            TEntry fileEntry;
+            User::LeaveIfError(iFramework.Fs().Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), fileEntry));
+
+            if((iOffset >= fileEntry.iSize)) 
+                {
+                result = EMTPRespCodeInvalidParameter;
+                }
+            }
+        }
+
+    __FLOG(_L8("CheckRequestL - Exit"));
+    return result;  
+    }
+
+/**
+GetObject request handler
+*/		
+void CMTPGetPartialObject::ServiceL()
+	{
+    __FLOG(_L8("ServiceL - Entry"));
+    
+	if (!iObjectInfo)
+	    {
+	    SendResponseL(EMTPRespCodeInvalidObjectHandle);
+	    }
+    else
+        {
+        delete iFileObject;
+        iFileObject = CMTPTypeFile::NewL(iFramework.Fs(), iObjectInfo->DesC(CMTPObjectMetaData::ESuid), EFileRead, iLength, iOffset);
+    	SendDataL(*iFileObject);
+        }
+	
+    __FLOG(_L8("ServiceL - Exit"));
+	}
+
+/**
+Handle the response phase of the current request
+@return EFalse
+*/		
+TBool CMTPGetPartialObject::DoHandleResponsePhaseL()
+	{
+    __FLOG(_L8("DoHandleResponsePhaseL - Entry"));
+    __ASSERT_DEBUG(iFileObject, Panic(EMTPDpObjectNull));
+
+    TUint32 dataLength = iFileObject->GetByteSent();
+	SendResponseL(EMTPRespCodeOK, 1, &dataLength);
+	
+    __FLOG(_L8("DoHandleResponsePhaseL - Exit"));
+	return EFalse;
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetreferences.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,74 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtptypearray.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpreferencemgr.h>
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpgetreferences.h"
+
+/**
+Verification data for the GetReferences request
+*/
+const TMTPRequestElementInfo KMTPGetReferencesPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrNone, 0, 0, 0}
+    };
+
+/**
+Two-phase construction method
+@param aPlugin The data provider plugin
+@param aFramework The data provider framework
+@param aConnection The connection from which the request comes
+@return a pointer to the created request processor object
+*/    
+EXPORT_C MMTPRequestProcessor* CMTPGetReferences::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPGetReferences* self = new (ELeave) CMTPGetReferences(aFramework, aConnection);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+EXPORT_C CMTPGetReferences::~CMTPGetReferences()
+    {
+    delete iReferences;
+    }
+
+/**
+Standard c++ constructor
+*/    
+CMTPGetReferences::CMTPGetReferences(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    :CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetReferencesPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetReferencesPolicy)
+    {
+    }
+
+/**
+GetReferences request handler
+*/    
+void CMTPGetReferences::ServiceL()
+    {
+    TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    MMTPReferenceMgr& referenceMgr = iFramework.ReferenceMgr();
+    delete iReferences;
+    iReferences = NULL;
+    iReferences = referenceMgr.ReferencesLC(TMTPTypeUint32(objectHandle));
+    CleanupStack::Pop(iReferences);
+    SendDataL(*iReferences);
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpknowledgehandler.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,751 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpknowledgehandler.cpp
+
+#include <bautils.h> 
+#include <centralrepository.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypeobjectinfo.h>
+#include <mtp/cmtptypeobjectproplist.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtptypefile.h>
+#include <mtp/mtpdatatypeconstants.h>
+
+#include "cmtpknowledgehandler.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"KwgObjHdler");)
+
+const TInt KDateTimeMaxLength = 22;
+const TInt KNameMaxLength = 255;
+
+_LIT16(KEmptyContent16, "");
+_LIT(KMTPKnowledgeObjDriveLocation, "c:");
+_LIT(KMTPNoBackupFolder, "nobackup\\");	
+_LIT(KMTPSlash, "\\");
+_LIT(KMTPKnowledgeObjFileName, "mtp_knowledgeobj.dat");
+_LIT(KMTPKnowledgeObjSwpFileName, "mtp_knowledgeobj.swp");
+
+EXPORT_C CMTPKnowledgeHandler* CMTPKnowledgeHandler::NewL(MMTPDataProviderFramework& aFramework, TUint16 aFormatCode, 
+												CRepository& aReposotry, const TDesC& aKwgSuid)
+	{
+	CMTPKnowledgeHandler *self = new (ELeave) CMTPKnowledgeHandler(aFramework, aFormatCode, aReposotry, aKwgSuid);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CMTPKnowledgeHandler::~CMTPKnowledgeHandler()
+	{
+	__FLOG(_L8("~CMTPKnowledgeHandler - Entry")); 
+	delete iDateModified;
+	delete iName;
+	delete iKnowledgeObj;
+	delete iKnowledgeSwpBuffer;
+	__FLOG(_L8("~CMTPKnowledgeHandler - Exit"));
+	__FLOG_CLOSE;
+	}
+
+CMTPKnowledgeHandler::CMTPKnowledgeHandler(MMTPDataProviderFramework& aFramework, TUint16 aFormatCode, 
+										CRepository& aReposotry, const TDesC& aKwgSuid) :
+	iFramework(aFramework), iRepository(aReposotry), iKnowledgeFormatCode(aFormatCode),
+	iKnowledgeObjectSize(KObjectSizeNotAvaiable), iCacheStatus(EOK), iSuid(aKwgSuid)
+	{
+	}
+
+void CMTPKnowledgeHandler::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("Construct - Entry"));
+	
+	iFramework.Fs().PrivatePath(iKnowObjFileName);
+	iKnowObjFileName.Insert(0, KMTPKnowledgeObjDriveLocation);
+	iKnowObjFileName.Append(KMTPNoBackupFolder);
+	iKnowObjFileName.Append(iSuid);
+	iKnowObjFileName.Append(KMTPSlash);
+
+	iKnowObjSwpFileName.Append(iKnowObjFileName);
+	iKnowObjSwpFileName.Append(KMTPKnowledgeObjSwpFileName);
+	
+	iKnowObjFileName.Append(KMTPKnowledgeObjFileName);
+
+	// Create knowledge object file directory if not exist.
+	BaflUtils::EnsurePathExistsL(iFramework.Fs(), iKnowObjFileName);
+
+	// Recover for previous failed transaction
+	if(BaflUtils::FileExists(iFramework.Fs(), iKnowObjSwpFileName))
+		{
+		// In case DP received some object content
+		User::LeaveIfError(iFramework.Fs().Delete(iKnowObjSwpFileName));
+		}
+
+	LoadKnowledgeObjPropertiesL();
+	__FLOG(_L8("ConstructL - Exit"));
+	}
+
+EXPORT_C void CMTPKnowledgeHandler::SetStorageId(TUint32 aStorageId)
+	{
+	iStorageID = aStorageId;
+	}
+
+void CMTPKnowledgeHandler::CommitL()
+	{
+	__FLOG(_L8("CommitL - Entry"));
+
+	User::LeaveIfError(iRepository.StartTransaction(CRepository::EReadWriteTransaction));
+	iRepository.CleanupCancelTransactionPushL();
+	if(iKnowledgeObjectSize != KObjectSizeNotAvaiable)
+		{
+		User::LeaveIfError(iRepository.Set(ESize, (TInt)iKnowledgeObjectSize));
+		}
+	if(iDateModified)
+		{
+		User::LeaveIfError(iRepository.Set(EDateModified, *iDateModified));
+		}
+	if(iName)
+		{
+		User::LeaveIfError(iRepository.Set(EName, *iName));
+		}
+	
+	if (EMTPRespCodeOK != SetColumnType128Value(ELastAuthorProxyID, iLastAuthorProxyID))
+		{
+		User::Leave(KErrGeneral);
+		}
+	// Close all knowledge file and reset pointer.
+	if (iKnowledgeObj)
+		{
+		delete iKnowledgeObj;
+		iKnowledgeObj = NULL;
+		}
+	
+	if (iKnowledgeSwpBuffer)
+		{
+		delete iKnowledgeSwpBuffer;
+		iKnowledgeSwpBuffer = NULL;
+		}
+
+	if(BaflUtils::FileExists(iFramework.Fs(), iKnowObjSwpFileName))
+		{
+		// In case DP received some object content
+		User::LeaveIfError(iFramework.Fs().Replace(iKnowObjSwpFileName, iKnowObjFileName));
+		}
+	// If swp file isn't exsited, that means 0 sized object received, need do nothing.
+	
+	TUint32 keyInfo;
+	User::LeaveIfError(iRepository.CommitTransaction(keyInfo));
+	CleanupStack::Pop(&iRepository);
+	__FLOG(_L8("CommitL - Exit"));
+	}
+
+void CMTPKnowledgeHandler::CommitForNewObjectL(TDes& aSuid)
+	{
+	aSuid = iSuid;
+	CommitL();
+	}
+	
+void CMTPKnowledgeHandler::RollBack()
+	{
+	__FLOG(_L8("Rollback - Entry"));
+	TRAP_IGNORE(LoadKnowledgeObjPropertiesL());
+	__FLOG(_L8("Rollback - Exit"));
+	}
+
+EXPORT_C void CMTPKnowledgeHandler::GetObjectSuidL(TDes& aSuid) const
+	{
+	__FLOG(_L8("GetObjectSuidL - Entry"));
+	if(iKnowledgeObjectSize != KObjectSizeNotAvaiable)
+		{
+		aSuid.Append(iSuid);
+		}
+	__FLOG(_L8("GetObjectSuidL - Exit"));
+	}
+
+void CMTPKnowledgeHandler::LoadKnowledgeObjPropertiesL()
+	{
+	__FLOG(_L8("LoadKnowledgeObjPropertiesL - Entry"));
+	iCacheStatus = EOK;
+	iCacheStatusFlag = EDirty;
+	TCleanupItem cacheDroper(DropCacheWrapper, this);
+	CleanupStack::PushL(cacheDroper);
+	TInt objSize;
+	User::LeaveIfError(iRepository.Get(ESize, objSize));
+	iKnowledgeObjectSize = objSize;
+
+	// Load DateModify
+	delete iDateModified;
+	iDateModified = NULL;
+	iDateModified = HBufC::NewL(KDateTimeMaxLength);
+	TPtr ptrDate(iDateModified->Des());
+	User::LeaveIfError(iRepository.Get(EDateModified, ptrDate));
+	
+	// Load Name
+	delete iName;
+	iName = NULL;
+	iName = HBufC::NewL(KNameMaxLength);
+	TPtr ptrName(iName->Des());
+	User::LeaveIfError(iRepository.Get(EName, ptrName));
+
+	// Load LastAuthorProxyID:
+	TPtr8 writeBuf(NULL, 0); //walkaroud for the TMTPTypeUint128
+	iLastAuthorProxyID.FirstWriteChunk(writeBuf);
+	User::LeaveIfError(iRepository.Get(ELastAuthorProxyID, writeBuf));
+	CleanupStack::Pop(this);
+	// Doesn't load object content to cache beacause it can grow up to 100KB
+	__FLOG(_L8("LoadKnowledgeObjPropertiesL - Exit"));
+	}
+
+void CMTPKnowledgeHandler::DropCacheWrapper(TAny* aObject)
+	{
+	reinterpret_cast<CMTPKnowledgeHandler*>(aObject)->DropKnowledgeObjPropertiesCache();
+	}
+
+void CMTPKnowledgeHandler::DropKnowledgeObjPropertiesCache()
+	{
+	__FLOG(_L8("DropKnowledgeObjPropertiesCache - Entry"));
+	iCacheStatus = iCacheStatusFlag;
+	iKnowledgeObjectSize = KObjectSizeNotAvaiable;
+	
+	// Load DateModify
+	delete iDateModified;
+	iDateModified = NULL;
+	
+	// Load Name
+	delete iName;
+	iName = NULL;
+	
+	// Reset LastAuthorProxyID
+	TMTPTypeUint128 tmp(MAKE_TINT64(KMTPUnInitialized32, KMTPUnInitialized32), 
+						MAKE_TINT64(KMTPUnInitialized32, KMTPUnInitialized32));
+	iLastAuthorProxyID.Set(tmp.UpperValue(), tmp.LowerValue());
+	__FLOG(_L8("DropKnowledgeObjPropertiesCache - Exit"));
+	}
+
+TMTPResponseCode CMTPKnowledgeHandler::SendObjectInfoL(const CMTPTypeObjectInfo& aObjectInfo, TUint32& aParentHandle, TDes& aSuid)
+	{
+	__FLOG(_L("SendObjectInfoL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	if (aParentHandle != KMTPHandleNone && aParentHandle != KMTPHandleNoParent)
+		{
+		responseCode = EMTPRespCodeInvalidParentObject;
+		}
+	else
+		{
+		//if there's a read error reread
+		if(EDirty == iCacheStatus)
+			{
+			LoadKnowledgeObjPropertiesL();
+			}
+		//already has a knowledge object
+		if(iKnowledgeObjectSize != KObjectSizeNotAvaiable)
+			{
+			responseCode = EMTPRespCodeAccessDenied;
+			}
+		else
+			{
+			iKnowledgeObjectSize = aObjectInfo.Uint32L(CMTPTypeObjectInfo::EObjectCompressedSize);
+			delete iDateModified;
+			iDateModified = NULL;
+			iDateModified = aObjectInfo.StringCharsL(CMTPTypeObjectInfo::EDateModified).AllocL();
+			aSuid = iSuid;
+			}
+		}
+	__FLOG(_L("SendObjectInfoL - Exit"));
+	return responseCode;
+	}
+
+TMTPResponseCode CMTPKnowledgeHandler::SendObjectPropListL(TUint64 aObjectSize, const CMTPTypeObjectPropList& /*aObjectPropList*/, 
+															TUint32& aParentHandle, TDes& aSuid)
+	{
+	__FLOG(_L8("SendObjectPropListL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	if (aParentHandle != KMTPHandleNone && aParentHandle != KMTPHandleNoParent)
+		{
+		responseCode = EMTPRespCodeInvalidParentObject;
+		}
+	else
+		{
+		//if there's a read error reread
+		aParentHandle = KMTPHandleNoParent;
+		if(EDirty == iCacheStatus)
+			{
+			LoadKnowledgeObjPropertiesL();
+			}
+		//already has a knowledge object
+		if(iKnowledgeObjectSize != KObjectSizeNotAvaiable)
+			{
+			responseCode = EMTPRespCodeAccessDenied;
+			}
+		else
+			{
+			iKnowledgeObjectSize = aObjectSize;
+			aSuid = iSuid;
+			}
+		}
+	__FLOG(_L8("SendObjectPropListL - Exit"));
+	return responseCode;
+	}
+
+TMTPResponseCode CMTPKnowledgeHandler::GetObjectPropertyL(const CMTPObjectMetaData& aObjectMetaData, 
+																TUint16 aPropertyCode, CMTPTypeObjectPropList& aPropList)
+	{
+	__FLOG(_L8("GetObjectPropertyL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	CMTPTypeObjectPropListElement* propertyElement = NULL;
+	TUint32 aHandle = aObjectMetaData.Uint(CMTPObjectMetaData::EHandle);
+	
+	switch (aPropertyCode)
+		{
+		case EMTPGenObjPropCodeParentID:
+			{
+			propertyElement = &(aPropList.ReservePropElemL(aHandle, aPropertyCode));
+			propertyElement->SetUint32L(CMTPTypeObjectPropListElement::EValue, 0x0000);
+			break;
+			}
+				
+		case EMTPGenObjPropCodeName:
+			{
+			propertyElement = &(aPropList.ReservePropElemL(aHandle, aPropertyCode));
+			if (iName && iName->Length() > 0)
+				{
+				propertyElement->SetStringL(CMTPTypeObjectPropListElement::EValue, *iName);			
+				}
+			else
+				{
+				_LIT(KDefaultKwgObjName, "GenericObject01");
+				propertyElement->SetStringL(CMTPTypeObjectPropListElement::EValue, KDefaultKwgObjName());	
+				}
+			break;
+			}
+			
+		case EMTPGenObjPropCodePersistentUniqueObjectIdentifier:
+			{
+			propertyElement = &(aPropList.ReservePropElemL(aHandle, aPropertyCode));
+			propertyElement->SetUint128L(CMTPTypeObjectPropListElement::EValue,
+								iFramework.ObjectMgr().PuidL(aHandle).UpperValue(),
+								iFramework.ObjectMgr().PuidL(aHandle).LowerValue());
+			break;
+			}
+			
+		case EMTPGenObjPropCodeObjectFormat:
+			{
+			propertyElement = &(aPropList.ReservePropElemL(aHandle, aPropertyCode));
+			propertyElement->SetUint16L(CMTPTypeObjectPropListElement::EValue, iKnowledgeFormatCode);
+			break;
+			}
+
+		case EMTPGenObjPropCodeObjectSize:
+			{
+			if (iKnowledgeObjectSize != ~0)
+				{
+				propertyElement = &(aPropList.ReservePropElemL(aHandle, aPropertyCode));
+				propertyElement->SetUint64L(CMTPTypeObjectPropListElement::EValue,iKnowledgeObjectSize);
+				}
+			break;
+			}
+
+		case EMTPGenObjPropCodeStorageID:
+			{
+			propertyElement = &(aPropList.ReservePropElemL(aHandle, aPropertyCode));
+			propertyElement->SetUint32L(CMTPTypeObjectPropListElement::EValue, iStorageID);
+			break;
+			}
+
+		case EMTPGenObjPropCodeObjectHidden:
+			{
+			propertyElement = &(aPropList.ReservePropElemL(aHandle, aPropertyCode));
+			propertyElement->SetUint16L(CMTPTypeObjectPropListElement::EValue, 0x0001);
+			break;
+			}
+
+		case EMTPGenObjPropCodeNonConsumable:
+			{
+			propertyElement = &(aPropList.ReservePropElemL(aHandle, aPropertyCode));
+			propertyElement->SetUint8L(CMTPTypeObjectPropListElement::EValue, 0x01);
+			break;
+			}
+
+		case EMTPGenObjPropCodeDateModified:
+			{
+			propertyElement = &(aPropList.ReservePropElemL(aHandle, aPropertyCode));
+			if(iDateModified && iDateModified->Length() > 0)
+				{
+				propertyElement->SetStringL(CMTPTypeObjectPropListElement::EValue, *iDateModified);	
+				}
+			else
+				{
+				TTime now;	
+				now.UniversalTime();
+				const TInt KMaxTimeStringSize = 50;
+				TBuf<KMaxTimeStringSize> dateTimeBuf;
+				_LIT(KFormat,"%F%Y%M%DT%H%T%S");
+				now.FormatL(dateTimeBuf, KFormat);
+				propertyElement->SetStringL(CMTPTypeObjectPropListElement::EValue, dateTimeBuf);	
+				}
+			break;
+			}
+			
+		case EMTPSvcObjPropCodeLastAuthorProxyID:
+			{
+			const TMTPTypeUint128 unInitValue(MAKE_TUINT64(KMTPUnInitialized32, KMTPUnInitialized32), 
+										MAKE_TUINT64(KMTPUnInitialized32, KMTPUnInitialized32));
+			if(!unInitValue.Equal(iLastAuthorProxyID))
+				{
+				propertyElement = &(aPropList.ReservePropElemL(aHandle, aPropertyCode));
+				propertyElement->SetUint128L(CMTPTypeObjectPropListElement::EValue,
+											iLastAuthorProxyID.UpperValue(),
+											iLastAuthorProxyID.LowerValue());
+				}
+			break;	
+			}
+			
+		default:
+			responseCode = EMTPRespCodeInvalidObjectPropCode;
+			break;
+		}
+	if(propertyElement)
+		{
+		aPropList.CommitPropElemL(*propertyElement);
+		}
+	__FLOG(_L8("GetObjectPropertyL - Exit"));
+	return responseCode;
+	}
+
+TMTPResponseCode CMTPKnowledgeHandler::SetObjectPropertyL(const TDesC& /*aSuid*/, 
+															const CMTPTypeObjectPropListElement& aElement, 
+															TMTPOperationCode aOperationCode)
+	{
+	__FLOG(_L8("SetObjectPropertyL - Entry"));
+	TMTPResponseCode responseCode = CheckGenObjectPropertyL(aElement, aOperationCode);
+	if (responseCode == EMTPRespCodeOK)
+		{
+		TInt ret = KErrNone;
+		TUint16 propertyCode(aElement.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode));
+		switch (propertyCode)
+			{
+			case EMTPGenObjPropCodeObjectSize:
+				if(aOperationCode == EMTPOpCodeSetObjectPropList)
+					{
+					ret = iRepository.Set(ESize, (TInt)aElement.Uint64L(CMTPTypeObjectPropListElement::EValue));
+					}
+				iKnowledgeObjectSize = aElement.Uint64L(CMTPTypeObjectPropListElement::EValue);
+				break;
+				
+			case EMTPGenObjPropCodeDateModified:
+				if(aOperationCode == EMTPOpCodeSetObjectPropList)
+					{
+					ret = iRepository.Set(EDateModified, aElement.StringL(CMTPTypeObjectPropListElement::EValue));
+					}
+				delete iDateModified;
+				iDateModified = NULL;
+				iDateModified = aElement.StringL(CMTPTypeObjectPropListElement::EValue).AllocL();
+				break;
+				
+			case EMTPGenObjPropCodeName:
+				if(aOperationCode == EMTPOpCodeSetObjectPropList)
+					{
+					ret = iRepository.Set(EName, aElement.StringL(CMTPTypeObjectPropListElement::EValue));
+					}
+				delete iName;
+				iName = NULL;
+				iName = aElement.StringL(CMTPTypeObjectPropListElement::EValue).AllocL();
+				break;
+				
+			case EMTPSvcObjPropCodeLastAuthorProxyID:
+				{
+				TUint64 high_value = 0;
+				TUint64 low_value  = 0;
+				aElement.Uint128L(CMTPTypeObjectPropListElement::EValue, high_value, low_value);
+				if(aOperationCode == EMTPOpCodeSetObjectPropList)
+					{
+					responseCode = SetColumnType128Value(ELastAuthorProxyID, iLastAuthorProxyID);
+					}
+				iLastAuthorProxyID.Set(high_value, low_value);
+				break;
+				}
+				
+			default:
+				responseCode = EMTPRespCodeObjectPropNotSupported;
+				break;
+			}
+		if (KErrNone != ret)
+			{
+			responseCode = EMTPRespCodeGeneralError;
+			}
+		}
+	__FLOG(_L8("SetObjectPropertyL - Exit"));
+	return responseCode;
+	}
+
+// Remove the knowledge object
+TMTPResponseCode CMTPKnowledgeHandler::DeleteObjectL(const CMTPObjectMetaData& /*aObjectMetaData*/)
+	{
+	__FLOG(_L8("DeleteObjectL - Entry"));
+	iCacheStatusFlag = EDirty;
+	TCleanupItem cacheDroper(DropCacheWrapper, this);
+	CleanupStack::PushL(cacheDroper);
+	// Delete obejct properties in transaction, if leave, mgr will rollback all properties.
+	DeleteAllObjectPropertiesL();
+	CleanupStack::Pop(this);
+	// Drop all cached properties.
+	iCacheStatusFlag = EDeleted;
+	CMTPKnowledgeHandler::DropCacheWrapper(this);
+	LoadKnowledgeObjPropertiesL();
+	__FLOG(_L8("DeleteObjectL - Exit"));
+	return EMTPRespCodeOK;
+	}
+
+// Return the knowledge object content
+TMTPResponseCode CMTPKnowledgeHandler::GetObjectL(const CMTPObjectMetaData& /*aObjectMetaData*/, MMTPType** aBuffer)
+	{
+	__FLOG(_L8("GetObjectL - Entry"));
+	if (!BaflUtils::FileExists(iFramework.Fs(), iKnowObjFileName))
+		{
+		RFile file;
+		CleanupClosePushL(file);
+		User::LeaveIfError(file.Create(iFramework.Fs(), iKnowObjFileName, EFileRead));
+		CleanupStack::PopAndDestroy(&file);
+		}
+	
+	// iKnowledgeObj will be NULL in four cases: 1. Initialize; 2. The Object has been deleted.
+	// 3. it has been commited by SendObject. 4 released by GetObject.
+	if (!iKnowledgeObj)
+		{
+		iKnowledgeObj = CMTPTypeFile::NewL(iFramework.Fs(), iKnowObjFileName, EFileRead);
+		}
+	*aBuffer = iKnowledgeObj;
+	__FLOG(_L8("GetObjectL - Exit"));
+	return EMTPRespCodeOK;
+	}
+
+TMTPResponseCode CMTPKnowledgeHandler::DeleteObjectPropertyL(const CMTPObjectMetaData& /*aObjectMetaData*/, const TUint16 aPropertyCode)
+	{
+	__FLOG(_L8("DeleteObjectPropertyL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	switch (aPropertyCode)
+		{
+		case EMTPGenObjPropCodeDateModified:
+			delete iDateModified;
+			iDateModified = NULL;
+			if (KErrNone != iRepository.Set(EDateModified, KEmptyContent16))
+				{
+				responseCode = EMTPRespCodeGeneralError;
+				}
+			break;
+		case EMTPSvcObjPropCodeLastAuthorProxyID:
+			{
+			TMTPTypeUint128 tmp(MAKE_TINT64(KMTPUnInitialized32, KMTPUnInitialized32), 
+								MAKE_TINT64(KMTPUnInitialized32, KMTPUnInitialized32));
+			iLastAuthorProxyID.Set(tmp.UpperValue(), tmp.LowerValue());
+			responseCode = SetColumnType128Value(ELastAuthorProxyID, iLastAuthorProxyID);
+			break;
+			}
+			
+		case EMTPObjectPropCodeParentObject:
+		case EMTPObjectPropCodeName:
+		case EMTPObjectPropCodePersistentUniqueObjectIdentifier:
+		case EMTPObjectPropCodeObjectFormat:
+		case EMTPObjectPropCodeObjectSize:
+		case EMTPObjectPropCodeStorageID:
+		case EMTPObjectPropCodeHidden:
+		case EMTPObjectPropCodeNonConsumable:
+			responseCode = EMTPRespCodeAccessDenied;
+			break;
+			
+		default:
+			responseCode = EMTPRespCodeInvalidObjectPropCode;
+			break;
+		}
+	__FLOG(_L8("DeleteObjectPropertyL - Exit"));
+	return responseCode;
+	}
+
+TMTPResponseCode CMTPKnowledgeHandler::GetBufferForSendObjectL(const CMTPObjectMetaData& /*aObjectMetaData*/, MMTPType** aBuffer)
+	{
+	__FLOG(_L8("GetBufferForSendObjectL - Entry"));
+	if (iKnowledgeSwpBuffer)
+		{
+		delete iKnowledgeSwpBuffer;
+		iKnowledgeSwpBuffer = NULL;
+		}
+	iKnowledgeSwpBuffer = CMTPTypeFile::NewL(iFramework.Fs(), iKnowObjSwpFileName, EFileWrite);
+	iKnowledgeSwpBuffer->SetSizeL(0);
+	*aBuffer = iKnowledgeSwpBuffer;
+	__FLOG(_L8("GetBufferForSendObjectL - Exit"));
+	return EMTPRespCodeOK;
+	}
+
+void CMTPKnowledgeHandler::BuildObjectInfoL(CMTPTypeObjectInfo& aObjectInfo) const
+	{
+	aObjectInfo.SetUint32L(CMTPTypeObjectInfo::EStorageID, iStorageID);	
+	aObjectInfo.SetUint16L(CMTPTypeObjectInfo::EObjectFormat, iKnowledgeFormatCode);
+	// Not use
+	aObjectInfo.SetUint16L(CMTPTypeObjectInfo::EProtectionStatus, 0x0000);
+	aObjectInfo.SetUint32L(CMTPTypeObjectInfo::EObjectCompressedSize, iKnowledgeObjectSize);
+	aObjectInfo.SetUint16L(CMTPTypeObjectInfo::EThumbFormat, 0);
+	aObjectInfo.SetUint32L(CMTPTypeObjectInfo::EThumbCompressedSize, 0);
+	aObjectInfo.SetUint32L(CMTPTypeObjectInfo::EThumbPixWidth, 0);
+	aObjectInfo.SetUint32L(CMTPTypeObjectInfo::EThumbPixHeight, 0);
+	aObjectInfo.SetUint32L(CMTPTypeObjectInfo::EImagePixWidth, 0);
+	aObjectInfo.SetUint32L(CMTPTypeObjectInfo::EImagePixHeight, 0);
+	aObjectInfo.SetUint32L(CMTPTypeObjectInfo::EImageBitDepth, 0);
+	aObjectInfo.SetUint32L(CMTPTypeObjectInfo::EParentObject, KMTPHandleNoParent);
+	aObjectInfo.SetUint16L(CMTPTypeObjectInfo::EAssociationType, 0x0000);
+	aObjectInfo.SetUint32L(CMTPTypeObjectInfo::EAssociationDescription, 0);
+	aObjectInfo.SetUint32L(CMTPTypeObjectInfo::ESequenceNumber, 0);
+	aObjectInfo.SetStringL(CMTPTypeObjectInfo::EFilename, KNullDesC);
+	aObjectInfo.SetStringL(CMTPTypeObjectInfo::EDateModified, KNullDesC);
+	aObjectInfo.SetStringL(CMTPTypeObjectInfo::EDateCreated, KNullDesC);
+	aObjectInfo.SetStringL(CMTPTypeObjectInfo::EKeywords, KNullDesC);
+	}
+
+TMTPResponseCode CMTPKnowledgeHandler::GetObjectInfoL(const CMTPObjectMetaData& /*aObjectMetaData*/, CMTPTypeObjectInfo& aObjectInfo)
+	{
+	__FLOG(_L8("GetObjectInfoL - Entry"));
+	if(iKnowledgeObjectSize != KObjectSizeNotAvaiable)
+		{
+		BuildObjectInfoL(aObjectInfo);
+		}
+	__FLOG(_L8("GetObjectInfoL - Exit"));
+	return EMTPRespCodeOK;
+	}
+
+
+void CMTPKnowledgeHandler::DeleteAllObjectPropertiesL()
+	{
+	__FLOG(_L8("DeleteAllObjectPropertiesL - Entry"));
+	User::LeaveIfError(iRepository.StartTransaction(CRepository::EReadWriteTransaction));
+	iRepository.CleanupCancelTransactionPushL();
+	User::LeaveIfError(iRepository.Set(EDateModified, KEmptyContent16));
+	User::LeaveIfError(iRepository.Set(EName, KEmptyContent16));
+	User::LeaveIfError(iRepository.Set(ESize, static_cast<TInt>(KObjectSizeNotAvaiable)));
+	
+	TMTPTypeUint128 tmp(MAKE_TINT64(KMTPUnInitialized32, KMTPUnInitialized32), 
+						MAKE_TINT64(KMTPUnInitialized32, KMTPUnInitialized32));
+	if (EMTPRespCodeOK != SetColumnType128Value(ELastAuthorProxyID, tmp))
+		{
+		User::Leave(KErrGeneral);
+		}
+	// Reset knowledgeobject pointer and close the file.
+	if (iKnowledgeObj)
+		{
+		delete iKnowledgeObj;
+		iKnowledgeObj = NULL;
+		}
+	
+	// Keep file delete is atomic.
+	if (BaflUtils::FileExists(iFramework.Fs(), iKnowObjFileName))
+		{
+		User::LeaveIfError(iFramework.Fs().Delete(iKnowObjFileName));
+		}
+	
+	TUint32 keyInfo;
+	User::LeaveIfError(iRepository.CommitTransaction(keyInfo));
+	CleanupStack::Pop(&iRepository);
+	
+	__FLOG(_L8("DeleteAllObjectPropertiesL - Exit"));
+	return;
+	}
+
+void CMTPKnowledgeHandler::ReleaseObjectBuffer()
+	{
+	__FLOG(_L8("ReleaseObjectBuffer - Entry"));
+	if (iKnowledgeObj)
+		{
+		delete iKnowledgeObj;
+		iKnowledgeObj = NULL;
+		}
+	__FLOG(_L8("ReleaseObjectBuffer - Exit"));
+	}
+
+TMTPResponseCode CMTPKnowledgeHandler::GetObjectSizeL(const TDesC& aSuid, TUint64& aObjectSize)
+	{
+	__FLOG(_L8("GetObjectSizeL - Entry"));
+	if (aSuid != iSuid)
+		{
+		return EMTPRespCodeGeneralError;
+		}
+	aObjectSize = iKnowledgeObjectSize;
+	__FLOG(_L8("GetObjectSizeL - Exit"));
+	return EMTPRespCodeOK;
+	}
+
+TMTPResponseCode CMTPKnowledgeHandler::SetColumnType128Value(TMTPKnowledgeStoreKeyNum aColumnNum, TMTPTypeUint128& aNewData)
+	{
+	__FLOG(_L8("SetColumnType128ValueL - Entry"));
+	TInt ret;
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	TBuf8<KMTPTypeINT128Size>  data;
+	data.FillZ(data.MaxLength());
+	TUint64 upperValue = aNewData.UpperValue();
+	TUint64 lowerValue = aNewData.LowerValue();
+	
+	/**
+	Least significant 64-bit buffer offset.
+	*/
+	const TInt           KMTPTypeUint128OffsetLS = 0;
+	/**
+	Most significant 64-bit buffer offset.
+	*/
+	const TInt           KMTPTypeUint128OffsetMS = 8;
+	
+	memcpy(&data[KMTPTypeUint128OffsetMS], &upperValue, sizeof(upperValue));
+	memcpy(&data[KMTPTypeUint128OffsetLS], &lowerValue, sizeof(lowerValue));
+	
+	ret = iRepository.Set(aColumnNum, data);
+	if (KErrNone != ret)
+		{
+		responseCode = EMTPRespCodeGeneralError;
+		}
+	__FLOG_VA((_L8("SetColumnType128ValueL - Exit with responseCode = 0x%04X"), responseCode));
+	return responseCode;
+	}
+
+TMTPResponseCode CMTPKnowledgeHandler::GetAllObjectPropCodeByGroupL(TUint32 aGroupId, RArray<TUint32>& aPropCodes)
+	{
+	__FLOG(_L8("GetAllObjectPropCodeByGroupL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	if (0 == aGroupId)
+		{
+		TInt count = sizeof(KMTPFullEnumSyncKnowledgeObjectProperties) / sizeof(KMTPFullEnumSyncKnowledgeObjectProperties[0]);
+		for (TInt i = 0; i < count; i++)
+			{
+			aPropCodes.Append(KMTPFullEnumSyncKnowledgeObjectProperties[i]);
+			}
+		}
+	else if(2 == aGroupId)
+		{
+		TInt count = sizeof(KMTPKnowledgeObjectPropertiesGroup2) / sizeof(KMTPKnowledgeObjectPropertiesGroup2[0]);
+		for (TInt i = 0; i < count; i++)
+			{
+			aPropCodes.Append(KMTPKnowledgeObjectPropertiesGroup2[i]);
+			}
+		}
+	else if(5 == aGroupId)
+		{
+		TInt count = sizeof(KMTPKnowledgeObjectPropertiesGroup5) / sizeof(KMTPKnowledgeObjectPropertiesGroup5[0]);
+		for (TInt i = 0; i < count; i++)
+			{
+			aPropCodes.Append(KMTPKnowledgeObjectPropertiesGroup5[i]);
+			}
+		}
+	else
+		{
+		responseCode = (TMTPResponseCode)0xA805;
+		}
+	__FLOG(_L8("GetAllObjectPropCodeByGroupL - Exit"));
+	return responseCode;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpmoveobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,402 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <f32file.h>
+#include <bautils.h>
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/cmtptypestring.h>
+
+#include "cmtpmoveobject.h"
+#include "mtpdppanic.h"
+
+
+__FLOG_STMT(_LIT8(KComponent,"MoveObject");)
+
+/**
+Verification data for the MoveObject request
+*/    
+const TMTPRequestElementInfo KMTPMoveObjectPolicy[] = 
+    {
+    	{TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrFileOrDir | EMTPElementAttrWrite, 0, 0, 0},   	
+        {TMTPTypeRequest::ERequestParameter2, EMTPElementTypeStorageId, EMTPElementAttrWrite, 0, 0, 0},                
+        {TMTPTypeRequest::ERequestParameter3, EMTPElementTypeObjectHandle, EMTPElementAttrDir | EMTPElementAttrWrite, 1, 0, 0}
+    };
+
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/     
+EXPORT_C MMTPRequestProcessor* CMTPMoveObject::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+	{
+	CMTPMoveObject* self = new (ELeave) CMTPMoveObject(aFramework, aConnection);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);	
+	return self;
+	}
+
+
+/**
+Destructor
+*/	
+EXPORT_C CMTPMoveObject::~CMTPMoveObject()
+	{	
+	delete iDest;
+	delete iFileMan;
+	delete iPathToMove;
+	delete iNewRootFolder;
+	__FLOG_CLOSE;
+	}
+
+/**
+Standard c++ constructor
+*/	
+CMTPMoveObject::CMTPMoveObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+	CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPMoveObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPMoveObjectPolicy),
+	iMoveObjectIndex(0)
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	}
+	
+/**
+MoveObject request handler
+*/		
+void CMTPMoveObject::ServiceL()
+	{	
+	TMTPResponseCode ret = MoveObjectL();
+	if (EMTPRespCodeOK != ret)
+		{
+		SendResponseL(ret);
+		}
+	}
+
+/**
+ Second phase constructor
+*/
+void CMTPMoveObject::ConstructL()
+    {
+    }
+    
+void CMTPMoveObject::RunL()
+	{
+	__FLOG(_L8("RunL - Entry"));
+    SendResponseL( EMTPRespCodeOK );
+    __FLOG(_L8("RunL - Exit"));
+	}
+    
+TInt CMTPMoveObject::RunError(TInt /*aError*/)
+	{
+	TRAP_IGNORE(SendResponseL(EMTPRespCodeGeneralError));
+    return KErrNone;  
+	}
+
+/**
+A helper function of MoveObjectL.
+@param aNewFileName the new file name after the object is moved.
+*/
+void CMTPMoveObject::MoveFileL(const TDesC& aNewFileName)	
+	{
+	__FLOG(_L8("MoveFileL - Entry"));
+	const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
+	GetPreviousPropertiesL(suid);
+	User::LeaveIfError(iFileMan->Move(suid, *iDest));
+	SetPreviousPropertiesL(aNewFileName);
+	iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, aNewFileName);
+	iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
+	iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle);
+	iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo);
+	__FLOG(_L8("MoveFileL - Exit"));
+	}
+
+/**
+A helper function of MoveObjectL.
+@param aNewFolderName the new file folder name after the folder is moved.
+*/
+void CMTPMoveObject::MoveFolderL()
+	{
+	__FLOG(_L8("MoveFolderL - Entry"));
+	
+	RBuf oldFolderName;
+	oldFolderName.CreateL(KMaxFileName);
+	oldFolderName.CleanupClosePushL();
+	oldFolderName = iObjectInfo->DesC(CMTPObjectMetaData::ESuid);
+	iPathToMove = oldFolderName.AllocL();
+	
+	if (iObjectInfo->Uint(CMTPObjectMetaData::EDataProviderId) == iFramework.DataProviderId())
+		{
+		GetPreviousPropertiesL(oldFolderName);
+		// Remove backslash.
+		oldFolderName.SetLength(oldFolderName.Length() - 1);	
+		SetPreviousPropertiesL(*iNewRootFolder);
+		_LIT(KBackSlash, "\\");
+		oldFolderName.Append(KBackSlash);	
+			
+		iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, *iNewRootFolder);
+		iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle);
+		iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
+		iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo);
+		}
+	
+	CleanupStack::PopAndDestroy(); // oldFolderName.
+		
+	__FLOG(_L8("MoveFolderL - Exit"));
+	}
+		
+/**
+move object operations
+@return A valid MTP response code.
+*/
+TMTPResponseCode CMTPMoveObject::MoveObjectL()
+	{
+	__FLOG(_L8("MoveObjectL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	
+	GetParametersL();
+				
+	RBuf newObjectName;
+	newObjectName.CreateL(KMaxFileName);
+	newObjectName.CleanupClosePushL();
+	newObjectName = *iDest;
+	
+	const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
+	TParsePtrC fileNameParser(suid);
+	
+	// Check if the object is a folder or a file.
+	TBool isFolder = EFalse;
+	User::LeaveIfError(BaflUtils::IsFolder(iFramework.Fs(), suid, isFolder));	
+				
+	if(!isFolder)
+		{
+		if((newObjectName.Length() + fileNameParser.NameAndExt().Length()) <= newObjectName.MaxLength())
+			{
+			newObjectName.Append(fileNameParser.NameAndExt());
+			}
+		responseCode = CanMoveObjectL(suid, newObjectName);			
+		}
+	else // It is a folder.
+		{
+		TFileName rightMostFolderName;		
+		User::LeaveIfError(BaflUtils::MostSignificantPartOfFullName(suid, rightMostFolderName));
+		if((newObjectName.Length() + rightMostFolderName.Length() + 1) <= newObjectName.MaxLength())
+			{
+			newObjectName.Append(rightMostFolderName);
+			// Add backslash.
+			_LIT(KBackSlash, "\\");
+			newObjectName.Append(KBackSlash);
+			}
+		}
+		
+	iNewRootFolder = newObjectName.AllocL();
+	__FLOG(*iNewRootFolder);
+		
+	if(responseCode == EMTPRespCodeOK)
+		{			
+		delete iFileMan;
+		iFileMan = NULL;
+		iFileMan = CFileMan::NewL(iFramework.Fs());
+		
+		if(!isFolder)
+			{
+			MoveFileL(newObjectName);
+			SendResponseL(responseCode);
+			}
+		else
+			{		
+			MoveFolderL();
+			SendResponseL(responseCode);
+			}
+		}
+	CleanupStack::PopAndDestroy(); // newObjectName.
+	__FLOG(_L8("MoveObjectL - Exit"));
+	return responseCode;
+	}
+
+/**
+Retrieve the parameters of the request
+*/	
+void CMTPMoveObject::GetParametersL()
+	{
+	__FLOG(_L8("GetParametersL - Entry"));
+	__ASSERT_DEBUG(iRequestChecker, Panic(EMTPDpRequestCheckNull));
+	
+	TUint32 objectHandle  = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+	iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+	iNewParentHandle  = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
+	
+	//not taking owernship
+	iObjectInfo = iRequestChecker->GetObjectInfo(objectHandle); 
+	__ASSERT_DEBUG(iObjectInfo, Panic(EMTPDpObjectNull));	
+
+	if(iNewParentHandle == 0)
+		{
+		SetDefaultParentObjectL();
+		}
+	else	
+		{
+		CMTPObjectMetaData* parentObjectInfo = iRequestChecker->GetObjectInfo(iNewParentHandle);
+		__ASSERT_DEBUG(parentObjectInfo, Panic(EMTPDpObjectNull));
+		delete iDest;
+		iDest = NULL;
+		iDest = parentObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocL();
+		}
+	__FLOG(_L8("GetParametersL - Exit"));	
+	}
+	
+/**
+Get a default parent object, ff the request does not specify a parent object, 
+*/
+void CMTPMoveObject::SetDefaultParentObjectL()
+	{
+	__FLOG(_L8("SetDefaultParentObjectL - Entry"));
+	const CMTPStorageMetaData& storageMetaData( iFramework.StorageMgr().StorageL(iStorageId) );
+	const TDesC& driveBuf( storageMetaData.DesC(CMTPStorageMetaData::EStorageSuid) );
+	delete iDest;
+	iDest = NULL;
+	iDest = driveBuf.AllocL();
+	iNewParentHandle = KMTPHandleNoParent;
+	__FLOG(_L8("SetDefaultParentObjectL - Exit"));
+	}
+
+/**
+Check if we can move the file to the new location
+*/
+TMTPResponseCode CMTPMoveObject::CanMoveObjectL(const TDesC& aOldName, const TDesC& aNewName) const
+	{
+	__FLOG(_L8("CanMoveObjectL - Entry"));
+	TMTPResponseCode result = EMTPRespCodeOK;
+
+	TEntry fileEntry;
+	User::LeaveIfError(iFramework.Fs().Entry(aOldName, fileEntry));
+	TInt drive(iFramework.StorageMgr().DriveNumber(iStorageId));
+	User::LeaveIfError(drive);
+	TVolumeInfo volumeInfo;
+	User::LeaveIfError(iFramework.Fs().Volume(volumeInfo, drive));
+	
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+    if(volumeInfo.iFree < fileEntry.FileSize())
+#else
+    if(volumeInfo.iFree < fileEntry.iSize)
+#endif
+		{
+		result = EMTPRespCodeStoreFull;
+		}
+	else if (BaflUtils::FileExists(iFramework.Fs(), aNewName))			
+		{
+		result = EMTPRespCodeInvalidParentObject;
+		}
+	__FLOG_VA((_L8("CanMoveObjectL - Exit with response code 0x%04X"), result));
+	return result;	
+	}
+
+/**
+Save the object properties before moving
+*/
+void CMTPMoveObject::GetPreviousPropertiesL(const TDesC& aFileName)
+	{
+	__FLOG(_L8("GetPreviousPropertiesL - Entry"));
+	User::LeaveIfError(iFramework.Fs().Modified(aFileName, iPreviousModifiedTime));
+	__FLOG(_L8("GetPreviousPropertiesL - Exit"));
+	}
+
+/**
+Set the object properties after moving
+*/
+void CMTPMoveObject::SetPreviousPropertiesL(const TDesC& aFileName)
+	{
+	__FLOG(_L8("SetPreviousPropertiesL - Entry"));
+	User::LeaveIfError(iFramework.Fs().SetModified(aFileName, iPreviousModifiedTime));
+	__FLOG(_L8("SetPreviousPropertiesL - Exit"));
+	}
+
+
+/* This function will actually delete the orginal folders from the file system. */
+TMTPResponseCode CMTPMoveObject::FinalPhaseMove()
+	{
+	__FLOG(_L8("FinalPhaseMove - Entry"));
+	TMTPResponseCode ret = EMTPRespCodeOK;
+	__FLOG(*iPathToMove);
+	TInt rel = iFileMan->RmDir(*iPathToMove);
+	__FLOG_VA((_L8("Error code of RmDir is %d"),rel));
+	if (rel != KErrNone)
+		{
+		ret = EMTPRespCodeGeneralError;
+		}
+	__FLOG(_L8("FinalPhaseMove - Exit"));
+	return ret;
+	}
+
+/* Move a single object and update the database */	
+void CMTPMoveObject::MoveAndUpdateL(TUint32 aObjectHandle)
+	{
+	__FLOG(_L8("MoveAndUpdateL - Entry"));
+	CMTPObjectMetaData* objectInfo(CMTPObjectMetaData::NewLC());
+	RBuf fileName;
+	fileName.CreateL(KMaxFileName);
+	fileName.CleanupClosePushL();	
+	RBuf rightPartName;
+	rightPartName.CreateL(KMaxFileName);
+	rightPartName.CleanupClosePushL();
+	RBuf oldName;
+	oldName.CreateL(KMaxFileName);	
+	oldName.CleanupClosePushL();
+		
+	if(iFramework.ObjectMgr().ObjectL(TMTPTypeUint32(aObjectHandle), *objectInfo))
+		{	
+		fileName = objectInfo->DesC(CMTPObjectMetaData::ESuid);
+		oldName = fileName;
+				
+		if (objectInfo->Uint(CMTPObjectMetaData::EDataProviderId) == iFramework.DataProviderId())
+			{	
+			rightPartName = fileName.Right(fileName.Length() - iPathToMove->Length());
+			
+			if((iNewRootFolder->Length() + rightPartName.Length()) > fileName.MaxLength())
+				{
+				User::Leave(KErrCorrupt);
+				}
+				
+			fileName.Zero();
+			fileName.Append(*iNewRootFolder);
+			fileName.Append(rightPartName);
+			objectInfo->SetDesCL(CMTPObjectMetaData::ESuid, fileName);				
+			objectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
+			iFramework.ObjectMgr().ModifyObjectL(*objectInfo);
+			}
+		}
+	else
+		{
+		User::Leave(KErrCorrupt);
+		}	
+			
+	iFileMan->Move(oldName, fileName);
+	
+	CleanupStack::PopAndDestroy(&oldName);	
+	CleanupStack::PopAndDestroy(&rightPartName); 
+	CleanupStack::PopAndDestroy(&fileName); 	
+	CleanupStack::PopAndDestroy(objectInfo);
+	__FLOG(_L8("MoveAndUpdateL - Exit"));	
+	}
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtprequestchecker.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,392 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <f32file.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpconnection.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpstoragemgr.h>
+
+#include "cmtprequestchecker.h"
+#include "rmtpdpsingletons.h"
+#include "cmtpfsexclusionmgr.h"
+
+static const TInt KMTPRequestCheckerHandleGranularity = 2;
+__FLOG_STMT(_LIT8(KComponent,"MTPRequestChecker");)
+
+/**
+Two-phase construction method
+@param aFramework	The data provider framework
+@param aConnection	The connection object
+@return a pointer to the created request checker object
+*/   
+EXPORT_C CMTPRequestChecker* CMTPRequestChecker::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+	{
+	CMTPRequestChecker* self = new (ELeave) CMTPRequestChecker(aFramework, aConnection);
+	return self;
+	}
+
+/**
+Destructor
+*/	
+EXPORT_C CMTPRequestChecker::~CMTPRequestChecker()
+	{
+	iHandles.Close();
+	iObjectArray.ResetAndDestroy();
+	__FLOG_CLOSE;
+	}
+
+/**
+Verfiy the request.  It check the request header first (session id and transaction code), and check for special values, last
+it iterates through the verification elements for checking individul parameters in the request
+
+@param aRequest	The request object to verify
+@param aCount	The number of verification elements
+@param aElementInfo	The array of verification elements
+@return reponse code to return to the initiator
+*/	
+EXPORT_C TMTPResponseCode CMTPRequestChecker::VerifyRequestL(const TMTPTypeRequest& aRequest, TInt aCount, const TMTPRequestElementInfo* aElementInfo)
+	{
+   	TMTPResponseCode result = EMTPRespCodeOK;
+   	iHandles.Close();
+   	iObjectArray.ResetAndDestroy();
+    
+	result = CheckRequestHeader(aRequest);
+	
+	for (TInt i = 0; i < aCount && EMTPRespCodeOK == result; i++)
+		{
+		TUint32 parameter = aRequest.Uint32(aElementInfo[i].iElementIndex);
+		if (!IsSpecialValue(parameter, aElementInfo[i]))
+			{
+			switch (aElementInfo[i].iElementType)
+				{
+				case EMTPElementTypeSessionID:
+					result = VerifySessionId(parameter, aElementInfo[i]);
+					break;
+				case EMTPElementTypeObjectHandle:
+					result = VerifyObjectHandleL(parameter, aElementInfo[i]);
+					break;
+				case EMTPElementTypeStorageId:
+					result = VerifyStorageIdL(parameter, aElementInfo[i]);
+					break;
+				case EMTPElementTypeFormatCode:
+					result = VerifyFormatCode(parameter, aElementInfo[i]);
+					break;				
+				default:
+					User::Invariant();  // Should never run
+					break;				
+				}			
+			}
+	    }
+		
+    return result;     
+	
+	}
+
+/**
+Return the object info for the handle.  This is to remove extra expensive DMBS retrieval operations.
+
+@param aHandle	the handle of the object requested
+@return an object info for the handle
+*/
+EXPORT_C CMTPObjectMetaData* CMTPRequestChecker::GetObjectInfo(TUint32 aHandle) const
+	{
+	CMTPObjectMetaData* result = NULL;
+	TInt count = iHandles.Count();
+	for(TInt i = 0; i < count; i++)
+		{
+		if (iHandles[i] == aHandle)
+			{
+			result = iObjectArray[i];
+			break;
+			}
+		}
+	return result;
+	}
+
+/**
+Check the request header portion (session Id and transaction code)
+@param aRequest	the request object to check
+@return repsonse code to return to initiator
+*/
+TMTPResponseCode CMTPRequestChecker::CheckRequestHeader(const TMTPTypeRequest& aRequest) const
+	{
+    TMTPResponseCode ret = EMTPRespCodeOK; 
+    TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
+  	TUint32 sessionId = aRequest.Uint32(TMTPTypeRequest::ERequestSessionID);
+	TUint32 transactionCode = aRequest.Uint32(TMTPTypeRequest::ERequestTransactionID);
+	
+	if (operationCode == EMTPOpCodeCloseSession || operationCode == EMTPOpCodeResetDevice)
+		{
+		if (sessionId != 0)
+			{
+			ret = EMTPRespCodeInvalidParameter;
+			}
+		}
+	else
+		{		
+	    // requests that are valid when there's no opened session.
+	    if (sessionId == 0)
+	        {
+	        switch (operationCode)
+	            {            	
+	            case EMTPOpCodeGetDeviceInfo:
+	            case EMTPOpCodeOpenSession: 
+	                {
+	                // Transaction id must be 0 when called out side an active session.
+	                if (transactionCode != 0)
+	                    {
+	                    ret = EMTPRespCodeInvalidTransactionID;
+	                    }
+
+	                }
+	                break;
+	            
+	            default:
+	                ret = EMTPRespCodeSessionNotOpen;
+	                break;
+	            }
+	        }
+	    else if (!iConnection.SessionWithMTPIdExists(sessionId))
+	        { 
+	        ret = EMTPRespCodeSessionNotOpen;
+	        }
+		}
+    return ret;	
+	}
+
+/**
+Check the session id in the request parameter (NOTE the session id is different from the one in the request header),
+this usually only applies to the OpenSession request
+@param aSessionId	Session id of the request.
+@param aElementInfo ElementInfo data array to check against.
+@return repsonse code to return to initiator
+*/	
+TMTPResponseCode CMTPRequestChecker::VerifySessionId(TUint32 aSessionId, const TMTPRequestElementInfo& /*aElementInfo*/) const
+	{
+    TMTPResponseCode ret = EMTPRespCodeOK; 
+    
+    if (aSessionId != 0)   
+    	{
+    	if (iConnection.SessionWithMTPIdExists(aSessionId))
+			{
+			ret = EMTPRespCodeSessionAlreadyOpen;			
+			}
+    	}
+    else
+    	{
+    	ret = EMTPRespCodeInvalidParameter;
+    	}
+		
+    return ret;	
+	}
+
+/**
+Check the object handle in the request parameter, whether the handle is in the object store, read/write, file/dir
+@param aHandle	Object handle to be checked.
+@param aElementInfo Element info array to be checked against.
+@return repsonse code to return to initiator
+*/		
+TMTPResponseCode CMTPRequestChecker::VerifyObjectHandleL(TUint32 aHandle, const TMTPRequestElementInfo& aElementInfo)
+	{
+	__FLOG_VA((_L8("VerifyObjectHandleL entry with handle 0x%08X"), aHandle));
+    TMTPResponseCode ret = EMTPRespCodeOK; 
+
+	CMTPObjectMetaData* object(CMTPObjectMetaData::NewLC());
+	TBool result(iFramework.ObjectMgr().ObjectL(aHandle, *object));
+	iObjectArray.AppendL(object);
+	CleanupStack::Pop(object);
+	iHandles.AppendL(aHandle);
+		
+	// Obj handle exists
+	if (result)
+		{
+	    TUint storageID = object->Uint(CMTPObjectMetaData::EStorageId);
+		CMTPStorageMetaData* storageMetaData = (CMTPStorageMetaData *)& iFramework.StorageMgr().StorageL(storageID);
+		if (storageMetaData->Uint(CMTPStorageMetaData::EStorageSystemType) != CMTPStorageMetaData::ESystemTypeDefaultFileSystem)
+			{
+			return ret;
+			}
+		
+		const TDesC& suid(object->DesC(CMTPObjectMetaData::ESuid));
+		TEntry entry;
+        TInt err = iFramework.Fs().Entry(suid, entry);
+        
+        if ( (object->Uint(CMTPObjectMetaData::EFormatCode) == EMTPFormatCodeAssociation) && 
+             (object->Uint(CMTPObjectMetaData::EFormatSubCode) != EMTPAssociationTypeGenericFolder ) )
+            {
+            // Special association type .. not always present on the filesystem.
+            return ret;
+            }   
+        else
+            {
+            User::LeaveIfError(err);
+            }
+		
+		if (aElementInfo.iElementAttr & EMTPElementAttrWrite)
+        	{
+        	if (entry.IsReadOnly())
+        		{
+        		ret = EMTPRespCodeObjectWriteProtected;
+        		}
+        	}
+        	
+        //((EMTPRespCodeOK == ret) && (aElementInfo.iElementAttr & EMTPElementAttrFileOrDir)) is
+        // covered implicitly here, EMTPRespCodeOK will be returned. It is a valid case for an object to be either a folder or file 
+        // for certain operation's request parameter, for instance the first parameter of copyObject or
+        // moveObject can be either a file or a directory.
+        
+		// Other cases.
+        if ((EMTPRespCodeOK == ret) && (aElementInfo.iElementAttr & EMTPElementAttrFile))
+	        	{
+	        	if (entry.IsDir())
+	        		{
+	        		ret = EMTPRespCodeInvalidObjectHandle;
+	        		}
+	        	}
+
+       	if ((EMTPRespCodeOK == ret) && (aElementInfo.iElementAttr & EMTPElementAttrDir))
+	       	{
+	       	if (!entry.IsDir())
+	       		{
+	       		ret = EMTPRespCodeInvalidParentObject;
+	       		}        	
+	       	}
+        	       		         
+		 }
+	else
+		{
+		__FLOG(_L8("Object does not exist."));
+		ret = EMTPRespCodeInvalidObjectHandle;
+		}
+	__FLOG_VA((_L8("VerifyObjectHandleL exit with repsonse code 0x%04X"), ret)); 
+	return ret;	
+	}
+
+/**
+Check the storage id parameter in the request, read/write attributes
+@param aStorageId	Storage id to be checked.
+@param aElementInfo Element info array to be checked against.
+@return repsonse code to return to initiator
+*/			
+TMTPResponseCode CMTPRequestChecker::VerifyStorageIdL(TUint32 aStorageId, const TMTPRequestElementInfo& aElementInfo) const
+	{
+	MMTPStorageMgr& mgr(iFramework.StorageMgr());
+    TMTPResponseCode ret(EMTPRespCodeOK);
+    if (!mgr.ValidStorageId(aStorageId))
+        {
+        ret = EMTPRespCodeInvalidStorageID;
+        }
+    else if (!mgr.LogicalStorageId(aStorageId))
+        {
+        ret = EMTPRespCodeStoreNotAvailable;
+        }
+    else 
+        {
+        TInt drive(mgr.DriveNumber(aStorageId));
+        // StorageIDs which are not system owned do not correspond to drives.
+        if (drive != KErrNotFound)
+            {
+    		TDriveInfo info;
+    		User::LeaveIfError(iFramework.Fs().Drive(info, drive));
+    		if (info.iType == EMediaNotPresent)
+    		    {
+    		    /* 
+    		    Race conditions between media ejection and request processing
+    		    may result in a previously valid storage ID no longer being 
+    		    available.
+    		    */
+    		    ret = EMTPRespCodeStoreNotAvailable;
+    		    }
+    		else if ((aElementInfo.iElementAttr & EMTPElementAttrWrite) &&
+    		            ((info.iMediaAtt & KMediaAttWriteProtected) ||
+    		             (info.iDriveAtt & KDriveAttRom)))
+    		    {
+        		ret = EMTPRespCodeStoreReadOnly;
+    		    }
+            }
+        }
+    return ret; 	
+	}
+	
+/**
+Check the format code parameter in the request,
+@param aStorageId	aFormatCode to be checked.
+@param aElementInfo Element info array to be checked against.
+@return repsonse code to return to initiator
+*/
+TMTPResponseCode CMTPRequestChecker::VerifyFormatCode(TUint32 aFormatCode, const TMTPRequestElementInfo& aElementInfo) const
+	{
+    TMTPResponseCode ret = EMTPRespCodeInvalidObjectFormatCode; 
+
+	if (aElementInfo.iElementAttr == EMTPElementAttrFormatEnums)
+		{
+		TUint32* formatArray = (TUint32*)(aElementInfo.iValue1);
+		TUint32 i = 0;
+		for(i = 0; i < aElementInfo.iValue2; i++)
+			{
+			if (aFormatCode == formatArray[i])
+				{
+				ret = EMTPRespCodeOK;
+				break;
+				}
+			}
+		}
+	else if (aFormatCode >= EMTPFormatCodePTPStart && aFormatCode <= EMTPFormatCodeMTPEnd)
+		{
+		ret = EMTPRespCodeOK;
+		}
+		
+    return ret;	
+	}
+
+/**
+Check if the parameter is one of the special values
+@param aParameter	The parameter value in the request
+@param aElementInfo	The ElementInfo for the parameter
+@return ETrue if the parameter is one of the special values, otherwise, EFalse
+*/
+TBool CMTPRequestChecker::IsSpecialValue(TUint32 aParameter, const TMTPRequestElementInfo& aElementInfo) const
+	{
+	TBool result = EFalse;
+	switch(aElementInfo.iCount)
+		{
+		case 1:
+			result = (aParameter == aElementInfo.iValue1);
+			break;
+		case 2:
+			result = (aParameter == aElementInfo.iValue1 || aParameter == aElementInfo.iValue2);
+			break;
+		default:
+			break;			
+		}
+	return result;
+	}
+
+/**
+Standard c++ constructor
+*/	
+CMTPRequestChecker::CMTPRequestChecker(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+	:iFramework(aFramework), 
+	iConnection(aConnection),
+	iHandles(KMTPRequestCheckerHandleGranularity),
+	iObjectArray(KMTPRequestCheckerHandleGranularity)
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtprequestprocessor.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,399 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/tmtptypeevent.h>
+#include <mtp/mmtpconnection.h>
+#include <mtp/mmtpobjectmgr.h>
+
+#include "cmtprequestprocessor.h"
+#include "cmtprequestchecker.h"
+
+const static TInt KNullBufferSize = 4096;
+__FLOG_STMT(_LIT8(KComponent,"MTPRequestProcessor");)
+
+/**
+Standard c++ constructor
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@param aElementCount Number of element in the request.
+@param aElements	The element info data.
+@return a pointer to the created request processor object
+*/   
+EXPORT_C CMTPRequestProcessor::CMTPRequestProcessor(
+											MMTPDataProviderFramework& aFramework,											
+											MMTPConnection& aConnection,
+											TInt aElementCount,
+											const TMTPRequestElementInfo* aElements)
+	:CActive(EPriorityStandard),
+	iFramework(aFramework),
+	iConnection(aConnection),
+	iElementCount(aElementCount),
+	iElements(aElements)
+	{
+	CActiveScheduler::Add(this);
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	}
+
+/**
+Destructor
+*/	
+EXPORT_C CMTPRequestProcessor::~CMTPRequestProcessor()
+	{
+	Cancel();
+	iNullBuffer.Close();
+	delete iRequestChecker;
+	__FLOG_CLOSE;
+	}
+
+/**
+Relese (delete) this request processor
+*/	
+EXPORT_C void CMTPRequestProcessor::Release()
+	{
+	delete this;
+	}
+
+/**
+Send a response to the initiator
+@param aResponseCode The response code to send
+@param aParamCount	The number of parameters
+@param aParmas	The pointer to array of parameters
+*/	
+EXPORT_C void CMTPRequestProcessor::SendResponseL(TMTPResponseCode aResponseCode, TInt aParameterCount, TUint32* aParams)
+	{
+	__ASSERT_DEBUG(aParameterCount < TMTPTypeRequest::ENumElements, User::Invariant());
+    
+	iResponse.SetUint16(TMTPTypeResponse::EResponseCode, aResponseCode);
+		    
+    iResponse.SetUint32(TMTPTypeResponse::EResponseSessionID, iSessionId);
+	
+	iResponse.SetUint32(TMTPTypeResponse::EResponseTransactionID, iTransactionCode);
+   
+    TInt i = 0;	
+	for(i = 0; i < aParameterCount; i++)
+		{
+		iResponse.SetUint32(TMTPTypeResponse::EResponseParameter1 + i, aParams[i]);
+		}
+
+	i += TMTPTypeResponse::EResponseParameter1;
+	while(i <= TMTPTypeResponse::EResponseParameter5)
+	    {
+	    iResponse.SetUint32(i, KMTPNotSpecified32);
+	    i++;
+	    }
+
+	__ASSERT_DEBUG(iRequest, User::Invariant()); 
+	iFramework.SendResponseL(iResponse, *iRequest, iConnection);
+	}
+
+/**
+The current active request
+@return A reference to the current request
+*/	
+EXPORT_C const TMTPTypeRequest& CMTPRequestProcessor::Request() const
+	{
+	__ASSERT_DEBUG(iRequest, User::Invariant()); 
+	return *iRequest;
+	}
+	
+/**
+The connection from which the current request comes
+@return A reference to the current connection
+*/	
+EXPORT_C MMTPConnection& CMTPRequestProcessor::Connection() const
+	{
+	return iConnection;
+	}
+/**
+The Session ID from the current request
+@return the value of the session ID
+ */
+EXPORT_C TUint32 CMTPRequestProcessor::SessionId()
+    {
+    return iSessionId;
+    }
+/**
+Signal to the framework that the current request transaction has completed
+*/
+EXPORT_C void CMTPRequestProcessor::CompleteRequestL()
+	{
+	__ASSERT_DEBUG(iRequest, User::Invariant()); 
+	iFramework.TransactionCompleteL(*iRequest, iConnection);
+	}
+
+/**
+Send data to the initiator
+@param aData	The data to send
+*/	
+EXPORT_C void CMTPRequestProcessor::SendDataL(const MMTPType& aData)
+	{
+	__ASSERT_DEBUG(iRequest, User::Invariant()); 
+	iFramework.SendDataL(aData, *iRequest, iConnection);
+	}
+
+/**
+Receive data from the initiator
+@param aData 	The data to receive
+*/
+EXPORT_C void CMTPRequestProcessor::ReceiveDataL(MMTPType& aData)
+	{
+	__ASSERT_DEBUG(iRequest, User::Invariant()); 
+	iFramework.ReceiveDataL(aData, *iRequest, iConnection);
+	}
+	
+/**
+Handle the request
+@param aRequest	The request to be processed
+@param aPhase	The current transaction phase of the request
+@return ETrue if the transaction has completed, otherwise, EFalse
+*/	
+EXPORT_C TBool CMTPRequestProcessor::HandleRequestL(const TMTPTypeRequest& aRequest, TMTPTransactionPhase aPhase)
+	{
+	iRequest = &aRequest;
+	__ASSERT_DEBUG(iRequest, User::Invariant()); 
+	TBool result = EFalse;
+	switch(aPhase)
+		{
+		case ERequestPhase:		
+			ExtractSessionTransactionId();
+			result = DoHandleRequestPhaseL();
+			break;
+		case EDataIToRPhase:
+			result = DoHandleDataIToRPhaseL();
+			break;
+		case EDataRToIPhase:
+			result = DoHandleRToIPhaseL();
+			break;
+		case EResponsePhase:
+			if (iResponseCode != EMTPRespCodeOK && HasDataphase())
+				{
+				SendResponseL(TMTPResponseCode(iResponseCode));
+				iNullBuffer.Close();
+				}
+			else
+				{
+				result = DoHandleResponsePhaseL();	
+				}
+			break;
+			
+		case ECompletingPhase:
+			result = DoHandleCompletingPhaseL();
+			break;
+		}
+	return result;	
+	}
+
+/**
+Handle the event
+@param aEvent The event to be processed
+*/	
+EXPORT_C void CMTPRequestProcessor::HandleEventL(const TMTPTypeEvent& aEvent)
+	{
+	TUint16 eventCode = aEvent.Uint16(TMTPTypeEvent::EEventCode);
+	iCancelled = (eventCode == EMTPEventCodeCancelTransaction);
+	}
+	
+/**
+Check whether the processor can process the request
+@param aRequest The request to be processed
+@param aConnection The connection from which the request comes
+@return ETrue if the processor can process the request, otherwise EFalse
+*/	
+EXPORT_C TBool CMTPRequestProcessor::Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const
+	{
+	__ASSERT_DEBUG(iRequest, User::Invariant()); 
+	TBool result = ((&aRequest == iRequest) && (&iConnection == &aConnection));
+	return result;		
+	}
+
+/**
+Check whether the processor can process the event
+@param aEvent The event to be processed
+@param aConnection The connection from which the request comes
+@return ETrue if the processor can process the request, otherwise EFalse
+*/	
+EXPORT_C TBool CMTPRequestProcessor::Match(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) const
+	{
+
+	TUint32 eventSessionId = aEvent.Uint32(TMTPTypeEvent::EEventSessionID);
+	TUint32 eventTransactionCode = aEvent.Uint32(TMTPTypeEvent::EEventTransactionID);
+	
+	TBool result = EFalse;
+	if(iSessionId == eventSessionId && 
+		iTransactionCode == eventTransactionCode &&
+		&iConnection == &aConnection)
+		{
+		result = ETrue;
+		}
+	return result;	
+	}
+
+/**
+Handle the request phase of the current request
+@return EFalse
+*/
+EXPORT_C TBool CMTPRequestProcessor::DoHandleRequestPhaseL()
+	{
+	__FLOG(_L8("DoHandleRequestPhaseL - Entry."));
+	TRAPD(err, iResponseCode = CheckRequestL());
+	if ((err != KErrNone) || (iResponseCode != EMTPRespCodeOK))
+		{
+		if (HasDataphase()) 
+			{
+			// If we have a dataphase
+			// we need to read in the data and discard it
+			__FLOG(_L8("Response code is not OK, there is data phase."));			
+			iNullBuffer.Close();
+			iNullBuffer.CreateMaxL(KNullBufferSize);
+			iNull.SetBuffer(iNullBuffer);
+			ReceiveDataL(iNull);
+			}
+		else
+			{
+			if(err != KErrNone)
+				{
+				User::Leave(err);
+				}
+			SendResponseL(TMTPResponseCode(iResponseCode));
+			}
+		}
+	else
+		{
+		TRAP(err, ServiceL());		
+		if (err != KErrNone)
+			{
+			iResponseCode = EMTPRespCodeGeneralError;
+			if (HasDataphase())
+				{				
+				// If we have a dataphase
+				// we need to read in the data and discard it		
+				iNullBuffer.Close();
+				iNullBuffer.CreateMaxL(KNullBufferSize);					
+				iNull.SetBuffer(iNullBuffer);			
+				ReceiveDataL(iNull);		
+				}
+			else
+				{
+				User::Leave(err);
+				}			
+			}
+		}
+	__FLOG(_L8("DoHandleRequestPhaseL - Exit."));	
+	return EFalse;	
+	}
+	
+/**
+Handle the receiving data phase of the current request
+@return EFalse
+*/	
+EXPORT_C TBool CMTPRequestProcessor::DoHandleDataIToRPhaseL()
+	{
+	User::Invariant();
+	return EFalse;
+	}
+
+/**
+Handle the sending data phase of the current request
+@return EFalse
+*/		
+EXPORT_C TBool CMTPRequestProcessor::DoHandleRToIPhaseL()
+ 	{
+	User::Invariant();
+	return EFalse;
+	}
+
+/**
+Handle the response phase of the current request
+@return EFalse
+*/		
+EXPORT_C TBool CMTPRequestProcessor::DoHandleResponsePhaseL()
+	{
+	TMTPResponseCode responseCode = (iCancelled ? EMTPRespCodeIncompleteTransfer : EMTPRespCodeOK);
+	SendResponseL(responseCode);
+	return EFalse;
+	}
+
+/**
+Handle the completing phase of the current request
+@return ETrue
+*/		
+EXPORT_C TBool CMTPRequestProcessor::DoHandleCompletingPhaseL()
+	{
+	CompleteRequestL();
+	return ETrue;	
+	}
+
+/**
+Check the current request
+@return EMTPRespCodeOK if the reqeust is good, otherwise, one of the error response codes
+*/
+EXPORT_C TMTPResponseCode CMTPRequestProcessor::CheckRequestL()
+	{
+	if(!iRequestChecker)
+		{
+		iRequestChecker = CMTPRequestChecker::NewL(iFramework, iConnection);	
+		}	
+	__ASSERT_DEBUG(iRequest, User::Invariant()); 		
+	return iRequestChecker->VerifyRequestL(*iRequest, iElementCount, iElements);
+	}
+	
+/**
+part of active object framework, provide default implementation
+*/
+EXPORT_C void CMTPRequestProcessor::RunL()
+	{
+	}
+
+/**
+part of active object framework, provide default implementation
+*/
+EXPORT_C void CMTPRequestProcessor::DoCancel()
+	{
+	}
+	
+/**
+part of active object framework, provide default implementation
+*/
+EXPORT_C TInt CMTPRequestProcessor::RunError(TInt /*aError*/)
+	{
+	TRAP_IGNORE(SendResponseL(EMTPRespCodeGeneralError));
+	return KErrNone;
+	}
+
+EXPORT_C TBool CMTPRequestProcessor::HasDataphase() const
+	{
+	return EFalse;
+	}
+
+/**
+retrieve the session id and transaction code from the current request
+*/
+void CMTPRequestProcessor::ExtractSessionTransactionId()
+	{    
+	iSessionId = iRequest->Uint32(TMTPTypeRequest::ERequestSessionID);    
+	iTransactionCode = iRequest->Uint32(TMTPTypeRequest::ERequestTransactionID);		
+	}
+
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtprequestunknown.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,92 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <mtp/tmtptyperequest.h>
+#include "cmtprequestunknown.h"
+
+/**
+Two-phase construction method
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+EXPORT_C MMTPRequestProcessor* CMTPRequestUnknown::NewL( 
+											MMTPDataProviderFramework& aFramework,
+											MMTPConnection& aConnection)
+	{
+	CMTPRequestUnknown* self = new (ELeave) CMTPRequestUnknown(aFramework, aConnection);
+	return self;
+	}
+
+/**
+Destructor
+*/	
+EXPORT_C CMTPRequestUnknown::~CMTPRequestUnknown()
+	{
+		
+	}
+
+/**
+Standard c++ constructor
+*/	
+EXPORT_C CMTPRequestUnknown::CMTPRequestUnknown(
+									MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection)
+	:CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+	{
+	}
+	
+/**
+OpenSession request handler
+*/	
+EXPORT_C void CMTPRequestUnknown::ServiceL()	
+	{
+	SendResponseL(EMTPRespCodeOperationNotSupported);	
+	}
+
+/**
+Override to match both the unknown requests
+@param aRequest	The request to match
+@param aConnection The connection from which the request comes
+@return always return ETrue to process all unknown request
+*/		
+EXPORT_C TBool CMTPRequestUnknown::Match(const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/) const
+	{
+	return ETrue;	
+	}
+
+
+
+
+
+
+
+
+
+	
+
+	
+
+
+   	
+
+	
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1232 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <f32file.h>
+#include <bautils.h>
+#include <mtp/cmtpdataproviderplugin.h>
+#include <mtp/mmtpdataproviderframework.h>
+
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypefile.h>
+#include <mtp/cmtptypeobjectinfo.h>
+#include <mtp/cmtptypeobjectproplist.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/mtpprotocolconstants.h>
+
+
+#include <mtp/tmtptyperequest.h>
+#include "cmtpconnection.h"
+#include "cmtpconnectionmgr.h"
+#include "cmtpsendobjectinfo.h"
+#include "mtpdppanic.h"
+#include "cmtpfsexclusionmgr.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpdataprovider.h"
+
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"SendObjectInfo");)
+
+/**
+Verification data for the SendObjectInfo request
+*/
+const TMTPRequestElementInfo KMTPSendObjectInfoPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeStorageId, EMTPElementAttrWrite, 1, 0, 0},                
+        {TMTPTypeRequest::ERequestParameter2, EMTPElementTypeObjectHandle, EMTPElementAttrDir, 2, KMTPHandleAll, KMTPHandleNone}
+    };
+
+
+/**
+Two-phase construction method
+@param aFramework  The data provider framework
+@param aConnection The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+EXPORT_C MMTPRequestProcessor* CMTPSendObjectInfo::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPSendObjectInfo* self = new (ELeave) CMTPSendObjectInfo(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+EXPORT_C CMTPSendObjectInfo::~CMTPSendObjectInfo()
+    {
+    __FLOG(_L8("~CMTPSendObjectInfo - Entry"));
+    
+    if ((iProgress == EObjectInfoSucceed ||
+        iProgress == EObjectInfoFail || 
+        iProgress == EObjectInfoInProgress) && !iNoRollback)
+        {
+        // Not finished SendObjectInfo/PropList SendObject pair detected.
+        Rollback();
+        }
+    
+    iDpSingletons.Close();
+    delete iDateMod;
+    delete iFileReceived;
+    delete iParentSuid;    
+    delete iReceivedObject;
+    delete iObjectInfo;
+    delete iObjectPropList;
+    iSingletons.Close();
+    __FLOG(_L8("~CMTPSendObjectInfo - Exit"));
+    __FLOG_CLOSE; 
+    }
+
+/**
+Standard c++ constructor
+@param aFramework    The data provider framework
+@param aConnection    The connection from which the request comes
+*/    
+CMTPSendObjectInfo::CMTPSendObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+    {
+    }
+
+/**
+Verify the request
+@return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
+*/    
+TMTPResponseCode CMTPSendObjectInfo::CheckRequestL()
+    {
+    __FLOG(_L8("CheckRequestL - Entry"));
+    TMTPResponseCode result = CheckSendingStateL();
+    
+    if (result != EMTPRespCodeOK) 
+        {
+        return result;
+        }
+    
+    if (iProgress == EObjectNone)    //this is the SendObjectInfo phase
+        {
+        iElementCount = sizeof(KMTPSendObjectInfoPolicy) / sizeof(TMTPRequestElementInfo);
+        iElements = KMTPSendObjectInfoPolicy;            
+        }
+    else if (iProgress == EObjectInfoSucceed)
+        {
+        iElementCount = 0;
+        iElements = NULL;
+        }
+    //coverity[var_deref_model]
+	result = CMTPRequestProcessor::CheckRequestL();     	
+ 
+    if (EMTPRespCodeOK == result)
+        {
+        result = MatchStoreAndParentL();
+        }
+        
+    if (result == EMTPRespCodeOK && iOperationCode == EMTPOpCodeSendObjectPropList)
+        {
+        TMTPFormatCode formatCode = static_cast<TMTPFormatCode>(Request().Uint32(TMTPTypeRequest::ERequestParameter3));
+        if (!iDpSingletons.ExclusionMgrL().IsFormatValid(formatCode))
+            {
+            result = EMTPRespCodeInvalidObjectFormatCode;
+            }
+        else
+            {
+            iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+            TUint32 objectSizeHigh = Request().Uint32(TMTPTypeRequest::ERequestParameter4);
+            TUint32 objectSizeLow = Request().Uint32(TMTPTypeRequest::ERequestParameter5);
+            if (iStorageId == KMTPStorageDefault)
+                {
+                iStorageId = iFramework.StorageMgr().DefaultStorageId();
+                }
+            iObjectSize = MAKE_TUINT64(objectSizeHigh, objectSizeLow);
+            if (IsTooLarge(iObjectSize))
+                {
+                result = EMTPRespCodeObjectTooLarge;            
+                }
+         	   
+            //File size is limited to KMaxTInt64 that is 8ExaBytes
+            //if the object size is more,then report this error.
+            if (!CanStoreFileL(iStorageId, iObjectSize)||(iObjectSize > (KMaxTInt64)))
+                {
+                result = EMTPRespCodeStoreFull;
+                }
+            }
+        }
+        
+    // If the previous request is not SendObjectInfo or SendObjectPropList, SendObject fails
+    if (result == EMTPRespCodeOK && iOperationCode == EMTPOpCodeSendObject)
+        {
+        if (iPreviousTransactionID + 1 != Request().Uint32(TMTPTypeRequest::ERequestTransactionID))
+            {
+            result = EMTPRespCodeNoValidObjectInfo;
+            }
+        }
+        
+    __FLOG_VA((_L8("Result = 0x%04X"), result));
+    __FLOG(_L8("CheckRequestL - Exit"));
+    return result;    
+    }
+    
+TBool CMTPSendObjectInfo::HasDataphase() const
+    {
+    return ETrue;
+    }
+
+/**
+SendObjectInfo/SendObject request handler
+NOTE: SendObjectInfo has to be comes before SendObject requests.  To maintain the state information
+between the two requests, the two requests are combined together in one request processor.
+*/    
+void CMTPSendObjectInfo::ServiceL()
+    {
+    __FLOG(_L8("ServiceL - Entry"));
+    if (iProgress == EObjectNone)
+        {
+        iIsFolder = EFalse;
+        if (iOperationCode == EMTPOpCodeSendObjectInfo)
+            {
+            ServiceSendObjectInfoL();
+            }
+        else
+            {
+            ServiceSendObjectPropListL();
+            }
+        }
+    else
+        {
+        ServiceSendObjectL();
+        }    
+    __FLOG(_L8("ServiceL - Exit"));
+    }
+
+/**
+Second-phase construction
+*/        
+void CMTPSendObjectInfo::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry")); 
+    iExpectedSendObjectRequest.SetUint16(TMTPTypeRequest::ERequestOperationCode, EMTPOpCodeSendObject);
+    iReceivedObject = CMTPObjectMetaData::NewL();
+    iReceivedObject->SetUint(CMTPObjectMetaData::EDataProviderId, iFramework.DataProviderId());
+    iDpSingletons.OpenL(iFramework);
+    iNoRollback = EFalse;
+    iSingletons.OpenL();
+    __FLOG(_L8("ConstructL - Exit"));
+    }
+
+/**
+Override to match both the SendObjectInfo and SendObject requests
+@param aRequest    The request to match
+@param aConnection The connection from which the request comes
+@return ETrue if the processor can handle the request, otherwise EFalse
+*/        
+TBool CMTPSendObjectInfo::Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const
+    {
+    __FLOG(_L8("Match - Entry"));
+    TBool result = EFalse;
+    TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
+    if ((operationCode == EMTPOpCodeSendObjectInfo || 
+        operationCode == EMTPOpCodeSendObject ||
+        operationCode == EMTPOpCodeSendObjectPropList) &&
+        &iConnection == &aConnection)
+        {
+        result = ETrue;
+        }
+    __FLOG(_L8("Match - Exit"));
+    return result;    
+    }
+
+/**
+Override to handle the response phase of SendObjectInfo and SendObject requests
+@return EFalse
+*/
+TBool CMTPSendObjectInfo::DoHandleResponsePhaseL()
+    {
+    __FLOG(_L8("DoHandleResponsePhaseL - Entry"));
+    //to check if the sending/receiving data is successful
+    TBool successful = !iCancelled;
+    if (iProgress == EObjectInfoInProgress)
+        {
+        if (iOperationCode == EMTPOpCodeSendObjectInfo)
+            {            
+            successful = DoHandleSendObjectInfoCompleteL();
+            }
+        else
+            {
+            successful = DoHandleSendObjectPropListCompleteL();
+            }
+        iProgress = (successful ? EObjectInfoSucceed : EObjectInfoFail);
+        if(iIsFolder && iProgress == EObjectInfoSucceed)
+			{
+			iProgress = EObjectNone;
+			}
+        }
+    else if (iProgress == ESendObjectInProgress)
+        {
+        successful = DoHandleSendObjectCompleteL();
+        iProgress = (successful ? ESendObjectSucceed : ESendObjectFail);
+        }
+        
+    __FLOG(_L8("DoHandleResponsePhaseL - Exit"));
+    return EFalse;
+    }
+
+/**
+Override to handle the completing phase of SendObjectInfo and SendObject requests
+@return ETrue if succesfully received the file, otherwise EFalse
+*/    
+TBool CMTPSendObjectInfo::DoHandleCompletingPhaseL()
+    {
+    __FLOG(_L8("DoHandleCompletingPhaseL - Entry"));
+    TBool result = ETrue;
+    CMTPRequestProcessor::DoHandleCompletingPhaseL();
+    if (iProgress == EObjectInfoSucceed)
+        {
+        if (iOperationCode == EMTPOpCodeSendObjectInfo || iOperationCode == EMTPOpCodeSendObjectPropList)
+            {
+            iPreviousTransactionID = Request().Uint32(TMTPTypeRequest::ERequestTransactionID);
+            }
+        result = EFalse;
+        }
+    else if (iProgress == ESendObjectFail)
+        {
+        if (iOperationCode == EMTPOpCodeSendObject)
+            {
+            iPreviousTransactionID++;
+            }
+        iProgress = EObjectInfoSucceed;
+        result = EFalse;
+        }
+    
+    __FLOG(_L8("DoHandleCompletingPhaseL - Exit"));
+    return result;    
+    }
+
+
+/**
+Verify if the SendObject request comes after SendObjectInfo request
+@return EMTPRespCodeOK if SendObject request comes after a valid SendObjectInfo request, otherwise
+EMTPRespCodeNoValidObjectInfo
+*/
+TMTPResponseCode CMTPSendObjectInfo::CheckSendingStateL()
+    {
+    __FLOG(_L8("CheckSendingState - Entry"));
+    TMTPResponseCode result = EMTPRespCodeOK;
+    iOperationCode = Request().Uint16(TMTPTypeRequest::ERequestOperationCode);
+
+    if (iOperationCode == EMTPOpCodeSendObject)
+    	{
+    	//In ParseRouter everytime SendObject gets resolved then will be removed from Registry
+    	//Right away therefore we need reRegister it here again in case possible cancelRequest
+    	//Against this SendObject being raised.
+    	iExpectedSendObjectRequest.SetUint32(TMTPTypeRequest::ERequestSessionID, iSessionId);
+    	iFramework.RouteRequestRegisterL(iExpectedSendObjectRequest, iConnection);
+       	}        
+    
+    if (iProgress == EObjectNone)
+        {
+        if (iOperationCode == EMTPOpCodeSendObject)
+            {
+            result = EMTPRespCodeNoValidObjectInfo;
+            }        
+        }
+    else if (iProgress == EObjectInfoSucceed) 
+        {
+        if (iOperationCode == EMTPOpCodeSendObjectInfo || iOperationCode == EMTPOpCodeSendObjectPropList)
+            {
+            //SendObjectInfo/SendObjectPropList sending the folder over which not necessarily
+            //being followed by SendObject as per MTP Specification in which case we need unregister RouteRequest of 
+            //SendObject made by previous SendObjectInfo/SendObjectPropList transaction without SendObject being followed.
+            if( iIsFolder )
+            	{
+            	iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
+        		}
+        
+            delete iObjectInfo;
+            iObjectInfo = NULL;
+            delete iObjectPropList;
+            iObjectPropList = NULL;
+            iProgress = EObjectNone;
+            }
+        }
+    else 
+        {
+        Panic(EMTPDpSendObjectStateInvalid);
+        }
+    __FLOG(_L8("CheckSendingState - Exit"));
+    return result;    
+    }
+
+/**
+SendObjectInfo request handler
+*/
+void CMTPSendObjectInfo::ServiceSendObjectInfoL()
+    {
+    __FLOG(_L8("ServiceSendObjectInfoL - Entry"));
+    delete iObjectInfo;
+    iObjectInfo = NULL;
+    iObjectInfo = CMTPTypeObjectInfo::NewL();
+    iCancelled = EFalse;
+    ReceiveDataL(*iObjectInfo);
+    iProgress = EObjectInfoInProgress;
+    __FLOG(_L8("ServiceSendObjectInfoL - Exit"));
+    }
+
+/**
+SendObjectPropList request handler
+*/
+void CMTPSendObjectInfo::ServiceSendObjectPropListL()
+    {
+    __FLOG(_L8("ServiceSendObjectPropListL - Entry"));
+    delete iObjectPropList;
+    iObjectPropList = NULL;
+    iObjectPropList = CMTPTypeObjectPropList::NewL();
+    iCancelled = EFalse;
+    iReceivedObject->SetUint(CMTPObjectMetaData::EFormatCode, iRequest->Uint32(TMTPTypeRequest::ERequestParameter3));
+    ReceiveDataL(*iObjectPropList);
+    iProgress = EObjectInfoInProgress;
+    __FLOG(_L8("ServiceSendObjectPropListL - Exit"));
+    }
+    
+/**
+SendObject request handler
+*/    
+void CMTPSendObjectInfo::ServiceSendObjectL()
+    {
+    __FLOG(_L8("ServiceSendObjectL - Entry"));
+    if (iIsFolder)
+        {
+        // A generic folder doesn't have anything interesting during its data phase
+        ReceiveDataL(iNullObject);
+        }
+    else    
+        {        
+        ReceiveDataL(*iFileReceived);
+        }
+    
+    iProgress = ESendObjectInProgress;
+    __FLOG(_L8("ServiceSendObjectL - Exit"));
+    }
+
+/**
+Get a default parent object, if the request does not specify a parent object.
+*/
+void CMTPSendObjectInfo::GetDefaultParentObjectL()
+    {    
+    __FLOG(_L8("GetDefaultParentObjectL - Entry"));
+    if (iStorageId == KMTPStorageDefault)
+        {
+        iStorageId = iFramework.StorageMgr().DefaultStorageId();
+        }
+    TInt drive(iFramework.StorageMgr().DriveNumber(iStorageId));
+    User::LeaveIfError(drive);
+
+    // Obtain the root of the drive.  Logical storages can sometimes have a filesystem root
+    // other than <drive>:\ .  For example an MP3 DP might have a root of c:\media\music\
+    // The DevDP needs to be aware of this when handling associations (folders) so they are
+    // created in the correct location on the filesystem.
+    delete iParentSuid;
+    iParentSuid = NULL;
+    iParentSuid=(iFramework.StorageMgr().StorageL(iStorageId).DesC(CMTPStorageMetaData::EStorageSuid)).AllocL();
+    iReceivedObject->SetUint(CMTPObjectMetaData::EParentHandle, KMTPHandleNoParent);
+    __FLOG(_L8("GetDefaultParentObjectL - Exit"));        
+    }
+
+/**
+Get parent object and storage id
+@return EMTPRespCodeOK if successful, otherwise, EMTPRespCodeInvalidParentObject
+*/
+TMTPResponseCode CMTPSendObjectInfo::GetParentObjectAndStorageIdL()
+    {
+    __FLOG(_L8("GetParentObjectAndStorageIdL - Entry"));    
+    __ASSERT_DEBUG(iRequestChecker, Panic(EMTPDpRequestCheckNull));
+
+    iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    iParentHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+    //does not take ownership
+    CMTPObjectMetaData* parentObjectInfo = iRequestChecker->GetObjectInfo(iParentHandle);
+
+    if (!parentObjectInfo)
+        {
+        GetDefaultParentObjectL();    
+        }
+    else
+        {        
+        delete iParentSuid;
+        iParentSuid = NULL;
+        iParentSuid = parentObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocL();
+        iReceivedObject->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle);
+        }
+
+    __FLOG_VA((_L8("iParentSuid = %S"), iParentSuid));
+    __FLOG(_L8("GetParentObjectAndStorageIdL - Exit"));    
+    return EMTPRespCodeOK;
+    }
+
+/**
+Handling the completing phase of SendObjectInfo request
+@return ETrue if the specified object can be saved on the specified location, otherwise, EFalse
+*/    
+TBool CMTPSendObjectInfo::DoHandleSendObjectInfoCompleteL()
+    {
+    __FLOG(_L8("DoHandleSendObjectInfoCompleteL - Entry"));    
+    TBool result(ETrue);
+    TUint16 format(iObjectInfo->Uint16L(CMTPTypeObjectInfo::EObjectFormat));
+    
+    result = iDpSingletons.ExclusionMgrL().IsFormatValid(TMTPFormatCode(format));
+    
+    if (result)
+        {
+        __FLOG_VA((_L8("ASSOCIATION TYPE IS: %X"), iObjectInfo->Uint16L(CMTPTypeObjectInfo::EAssociationType)));        
+		if(format == EMTPFormatCodeAssociation)
+			{
+			if((iObjectInfo->Uint16L(CMTPTypeObjectInfo::EAssociationType) == EMTPAssociationTypeGenericFolder) ||
+        		      (iObjectInfo->Uint16L(CMTPTypeObjectInfo::EAssociationType) == EMTPAssociationTypeUndefined))
+				iIsFolder = ETrue;
+			else{
+				SendResponseL(EMTPRespCodeInvalidDataset);
+	            result = EFalse;	
+				}
+			}
+        delete iDateMod;
+        iDateMod = NULL;
+    
+        iDateMod = iObjectInfo->StringCharsL(CMTPTypeObjectInfo::EDateModified).AllocL();
+    
+        TMTPResponseCode responseCode(GetParentObjectAndStorageIdL());
+        if (responseCode != EMTPRespCodeOK)
+            {
+            SendResponseL(responseCode);
+            result = EFalse;
+            }
+        }
+    else
+        {
+        SendResponseL(EMTPRespCodeInvalidObjectFormatCode);
+        }
+        
+    if (result)
+        {
+        iObjectSize = iObjectInfo->Uint32L(CMTPTypeObjectInfo::EObjectCompressedSize);
+        
+        if (IsTooLarge(iObjectSize))
+            {
+            SendResponseL(EMTPRespCodeObjectTooLarge);
+            result = EFalse;            
+            }
+        if(result && !CanStoreFileL(iStorageId, iObjectSize))
+            {
+            SendResponseL(EMTPRespCodeStoreFull);
+            result = EFalse;            
+            }
+        }
+
+    if (result)
+        {
+        iProtectionStatus = iObjectInfo->Uint16L(CMTPTypeObjectInfo::EProtectionStatus);
+        result = GetFullPathNameL(iObjectInfo->StringCharsL(CMTPTypeObjectInfo::EFilename));
+        if (!result)
+            {        
+            // File and/or parent pathname invalid.
+            SendResponseL(EMTPRespCodeInvalidDataset);
+            }
+        }
+
+    if (result)
+        {    
+        result &= !Exists(iFullPath);
+        if (!result)
+            {        
+            // Object with the same name already exists.
+            iNoRollback = ETrue;
+            SendResponseL(EMTPRespCodeAccessDenied);
+            }
+        }
+    
+    if (result)
+        {
+        iReceivedObject->SetUint(CMTPObjectMetaData::EFormatCode, format);
+        
+        if (iIsFolder)
+        	{
+        	iReceivedObject->SetUint(CMTPObjectMetaData::EFormatSubCode, EMTPAssociationTypeGenericFolder);
+        	}
+        	
+        TRAPD(err, CreateFsObjectL());
+        
+        if (err != KErrNone)
+            {
+            SendResponseL(ErrorToMTPError(err));
+            }
+        else
+            {
+            ReserveObjectL();
+            }
+        }
+    __FLOG(_L8("DoHandleSendObjectInfoCompleteL - Exit"));
+    return result;    
+    }
+
+/**
+Handling the completing phase of SendObjectPropList request
+@return ETrue if the specified object can be saved on the specified location, otherwise, EFalse
+*/    
+TBool CMTPSendObjectInfo::DoHandleSendObjectPropListCompleteL()
+    {
+    __FLOG(_L8("DoHandleSendObjectPropListCompleteL - Entry"));
+    TBool result(ETrue);
+    
+    TMTPResponseCode responseCode(GetParentObjectAndStorageIdL());
+    if (responseCode != EMTPRespCodeOK)
+        {
+        SendResponseL(responseCode);
+        result = EFalse;
+        }    
+
+    if (result)
+        {
+        // Any kind of association is treated as a folder
+        const TUint32 formatCode(Request().Uint32(TMTPTypeRequest::ERequestParameter3));
+        iIsFolder = (formatCode == EMTPFormatCodeAssociation);
+
+        TInt invalidParameterIndex = KErrNotFound;
+        responseCode = VerifyObjectPropListL(invalidParameterIndex);
+        result = (responseCode == EMTPRespCodeOK);    
+        if (!result)
+            {
+            TUint32 parameters[4];
+            parameters[0] = 0;
+            parameters[1] = 0;
+            parameters[2] = 0;
+            parameters[3] = invalidParameterIndex;
+            SendResponseL(responseCode, 4, parameters);
+            }
+        }
+        
+    if (result) 
+        {
+        result = !Exists(iFullPath);
+        if (!result)
+            {
+            // Object with the same name already exists.
+            iNoRollback = ETrue;
+            SendResponseL(EMTPRespCodeAccessDenied);
+            }
+        }    
+    
+    if (result)
+        {
+        if (iIsFolder)
+        	{
+        	iReceivedObject->SetUint(CMTPObjectMetaData::EFormatSubCode, EMTPAssociationTypeGenericFolder);
+        	}
+        
+        TRAPD(err, CreateFsObjectL());
+        
+        if (err != KErrNone)
+            {
+            SendResponseL(ErrorToMTPError(err));
+            }
+        else
+            {
+            ReserveObjectL();
+            }
+        }
+        
+    __FLOG(_L8("DoHandleSendObjectPropListCompleteL - Exit"));
+    return result;    
+    }
+    
+/**
+Handling the completing phase of SendObject request
+@return ETrue if the object has been successfully saved on the device, otherwise, EFalse
+*/    
+TBool CMTPSendObjectInfo::DoHandleSendObjectCompleteL()
+    {
+    __FLOG(_L8("DoHandleSendObjectCompleteL - Entry"));
+    TBool result(ETrue);
+        
+    if (!iIsFolder)
+        {        
+        delete iFileReceived;
+        iFileReceived = NULL;
+        
+        TEntry fileEntry;
+        User::LeaveIfError(iFramework.Fs().Entry(iFullPath, fileEntry));
+
+        if (fileEntry.FileSize() != iObjectSize)
+            {
+            iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
+            
+            iFramework.Fs().Delete(iFullPath);
+            iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObject);
+            TMTPResponseCode responseCode = EMTPRespCodeObjectTooLarge;
+            if (fileEntry.FileSize() < iObjectSize)
+                {
+                responseCode = EMTPRespCodeInvalidDataset;
+                }
+            SendResponseL(responseCode);
+            result = EFalse;
+            }
+        }
+    
+    
+    // Get the result of the SendObject operation. 
+    RMTPFramework frameworkSingletons;   
+    frameworkSingletons.OpenL();
+    TUint connectionId = iConnection.ConnectionId();
+    CMTPConnectionMgr& connectionMgr = frameworkSingletons.ConnectionMgr();
+    CMTPConnection& connection = connectionMgr.ConnectionL(connectionId);
+    TInt ret = connection.GetDataReceiveResult(); 
+    frameworkSingletons.Close();
+     // SendObject is cancelled or connection is dropped.
+    if(result && (iCancelled || (ret == KErrAbort)))
+        {
+        __FLOG(_L8("It is a cancel for sendObject."));
+        iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
+        Rollback();
+        SendResponseL(EMTPRespCodeTransactionCancelled);        
+        }
+    else if (result && !iCancelled)
+	    {
+	     iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
+        
+        //The MTP spec states that it is not mandatory for SendObjectInfo/SendObjectPropList
+        //to be followed by a SendObject.  An object is reserved in the ObjectStore on 
+        //receiving a SendObjectInfo/SendObjectPropList request, but we only commit it 
+        //on receiving the corresponding SendObject request.  With Associations however 
+        //we commit the object straight away as the SendObject phase is often absent 
+        //with folder creation.
+
+        if(!iIsFolder)
+        	{
+			SetPropertiesL();    
+        	iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObject);
+        	
+        	TParsePtrC file( iFullPath );
+        	_LIT( KTxtExtensionODF, ".odf" );
+        	if ( file.ExtPresent() && file.Ext().CompareF(KTxtExtensionODF)==0 )
+        	    {;
+        	    TUint32 DpId = iFramework.DataProviderId();
+        	    DpId = iDpSingletons.MTPUtility().GetDpId(file.Ext().Mid(1),KNullDesC);
+        	    //The data provider which owns all mimetypes of a file extension is not found 
+        	    if ( 255 == DpId )
+        	        {
+        	        HBufC* mime = NULL;
+        	        mime = iDpSingletons.MTPUtility().ContainerMimeType(iFullPath);
+        	        if ( mime != NULL )
+        	            {
+        	            DpId = iDpSingletons.MTPUtility().GetDpId(file.Ext().Mid(1),*mime);
+        	            delete mime;
+        	            mime = NULL;
+        	            }
+        	        }
+        	    if ( DpId!=iFramework.DataProviderId() && DpId!=255)
+        	        {
+        	        iReceivedObject->SetUint(CMTPObjectMetaData::EDataProviderId,DpId);
+        	        //iReceivedObject->SetUint(CMTPObjectMetaData::EFormatCode,format);
+        	        iFramework.ObjectMgr().ModifyObjectL(*iReceivedObject);
+        	        TUint32 handle = iReceivedObject->Uint(CMTPObjectMetaData::EHandle);
+        	        iSingletons.DpController().NotifyDataProvidersL(DpId,EMTPObjectAdded,(TAny*)&handle);
+        	        }
+        	    }
+        	}
+        
+        SendResponseL(EMTPRespCodeOK);
+	    }
+    __FLOG(_L8("DoHandleSendObjectCompleteL - Exit"));
+    return result;
+    }
+
+
+/**
+Get the full path name of the object to be saved
+@param aFileName, on entry, contains the file name of the object,
+on return, contains the full path name of the object to be saved
+@return ETrue if the name is valid, EFalse otherwise
+*/
+TBool CMTPSendObjectInfo::GetFullPathNameL(const TDesC& aFileName)
+    {
+    __FLOG(_L8("GetFullPathNameL - Entry"));
+    TBool result(EFalse);
+    if (aFileName.Length() > 0)
+        {
+        iFullPath = *iParentSuid;
+        if (iFullPath.Length() + aFileName.Length() < iFullPath.MaxLength())
+            {
+            iFullPath.Append(aFileName);
+            if (iIsFolder)
+                {
+                iFullPath.Append(KPathDelimiter);
+                
+                   TBool valid(EFalse);
+                if (BaflUtils::CheckWhetherFullNameRefersToFolder(iFullPath, valid) == KErrNone)
+                    {
+                    result = valid;
+                    }
+                }
+            else
+                {
+                result = iFramework.Fs().IsValidName(iFullPath);
+                }
+            }
+        }
+
+#ifdef __FLOG_ACTIVE
+    TFileName tempName;
+    tempName.Copy(iFullPath);
+    tempName.Collapse();
+    __FLOG_VA((_L8("iFullPath = %S, Result = %d"), &tempName, result));
+    __FLOG(_L8("GetFullPathNameL - Exit"));
+#endif
+    return result;
+    }
+
+/**
+Check if we can store the file on the storage
+@return ETrue if yes, otherwise EFalse
+*/
+TBool CMTPSendObjectInfo::CanStoreFileL(TUint32 aStorageId, TInt64 aObjectSize) const
+    {
+    __FLOG(_L8("CanStoreFileL - Entry"));
+    TBool result(ETrue);
+    if (aStorageId == KMTPStorageDefault)
+        {
+        aStorageId = iFramework.StorageMgr().DefaultStorageId();
+        }
+    TInt drive( iFramework.StorageMgr().DriveNumber(aStorageId) );
+    User::LeaveIfError(drive);
+    TVolumeInfo volumeInfo;
+    User::LeaveIfError(iFramework.Fs().Volume(volumeInfo, drive));
+    if (volumeInfo.iFree < aObjectSize)
+        {        
+        result = EFalse;
+        }
+    __FLOG_VA((_L8("Result = %d"), result));
+    __FLOG(_L8("CanStoreFileL - Exit"));
+    return result;        
+    }
+
+/**
+Check if the object is too large
+@return ETrue if yes, otherwise EFalse
+*/
+TBool CMTPSendObjectInfo::IsTooLarge(TUint64 aObjectSize) const
+    {
+    __FLOG(_L8("IsTooLarge - Entry"));
+    TBool ret(aObjectSize > KMaxTInt64);
+    
+    if(!ret)
+        {
+        TBuf<255> fsname;
+        TUint32 storageId = iStorageId;
+        if (storageId == KMTPStorageDefault)
+            {
+            storageId = iFramework.StorageMgr().DefaultStorageId();
+            }
+        TInt drive( iFramework.StorageMgr().DriveNumber(storageId) );
+        User::LeaveIfError(drive);
+        iFramework.Fs().FileSystemSubType(drive, fsname);        
+        
+        const TUint64 KMaxFatFileSize = 0xFFFFFFFF; //Maximal file size supported by all FAT filesystems (4GB-1)
+        _LIT(KFsFAT16, "FAT16");
+        _LIT(KFsFAT32, "FAT32");
+        
+        if((fsname.CompareF(KFsFAT16) == 0 || fsname.CompareF(KFsFAT32) == 0) && aObjectSize > KMaxFatFileSize)
+            {
+            ret = ETrue;
+            }
+        }
+    __FLOG_VA((_L8("Result = %d"), ret));
+    __FLOG(_L8("IsTooLarge - Exit"));
+    return ret;
+    }
+    
+/**
+Check if the file already exists on the storage.
+@return ETrue if file is exists, otherwise EFalse
+*/
+TBool CMTPSendObjectInfo::Exists(const TDesC& aName) const
+    {
+    __FLOG(_L8("Exists - Entry"));
+    // This detects both files and folders
+    TBool ret(EFalse); 
+    ret = BaflUtils::FileExists(iFramework.Fs(), aName);
+    __FLOG_VA((_L8("Result = %d"), ret));
+    __FLOG(_L8("Exists - Exit"));
+    return ret;
+    }
+
+/**
+Check if the property list is valid and extract properties (file name)
+@param aInvalidParameterIndex if invalid, contains the index of the property.  Undefined, if it is valid.
+@return if error, one of the error response code; otherwise EMTPRespCodeOK
+*/
+TMTPResponseCode CMTPSendObjectInfo::VerifyObjectPropListL(TInt& aInvalidParameterIndex)
+    {
+    __FLOG(_L8("VerifyObjectPropListL - Entry"));
+    TMTPResponseCode responseCode(EMTPRespCodeOK);
+    const TUint KCount(iObjectPropList->NumberOfElements());
+	iObjectPropList->ResetCursor();
+    for (TUint i(0); (i < KCount); i++)
+        {
+		CMTPTypeObjectPropListElement& KElement=iObjectPropList->GetNextElementL();
+        const TUint32 KHandle(KElement.Uint32L(CMTPTypeObjectPropListElement::EObjectHandle));
+        aInvalidParameterIndex = i;
+        if (KHandle != KMTPHandleNone)
+            {
+            responseCode = EMTPRespCodeInvalidObjectHandle;            
+            break;
+            }
+            
+        responseCode = CheckPropCodeL(KElement);
+        if (responseCode != EMTPRespCodeOK)
+            {
+            break;
+            }
+        responseCode = ExtractPropertyL(KElement);
+        if (responseCode != EMTPRespCodeOK)
+            {
+            break;
+            }        
+        }
+    __FLOG_VA((_L8("Result = 0x%04X"), responseCode));
+    __FLOG(_L8("VerifyObjectPropListL - Exit"));
+    return responseCode;        
+    }
+
+/**
+Extracts the file information from the object property list element
+@param aElement an object property list element
+@param aPropertyCode MTP property code for the element
+@return MTP response code
+*/
+TMTPResponseCode CMTPSendObjectInfo::ExtractPropertyL(const CMTPTypeObjectPropListElement& aElement)
+    {
+    __FLOG(_L8("ExtractPropertyL - Entry"));
+    TMTPResponseCode responseCode(EMTPRespCodeOK);
+    switch (aElement.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode))
+        {
+    case EMTPObjectPropCodeAssociationDesc:
+        // Actually, any association is treated as a folder, and iIsFolder should already be set
+        iIsFolder = ((aElement.Uint32L(CMTPTypeObjectPropListElement::EValue) == EMTPAssociationTypeGenericFolder)||
+					(aElement.Uint32L(CMTPTypeObjectPropListElement::EValue) == EMTPAssociationTypeUndefined));
+        break;
+        
+    case EMTPObjectPropCodeObjectFileName:
+        {
+        const TDesC& KFileName = aElement.StringL(CMTPTypeObjectPropListElement::EValue);
+        if (!GetFullPathNameL(KFileName))
+            {
+            responseCode = EMTPRespCodeInvalidDataset;
+            }
+        }
+        break;
+
+    case EMTPObjectPropCodeProtectionStatus:
+        {
+        iProtectionStatus = aElement.Uint16L(CMTPTypeObjectPropListElement::EValue);
+        if (iProtectionStatus !=  EMTPProtectionNoProtection &&
+            iProtectionStatus != EMTPProtectionReadOnly)
+            {
+            responseCode = EMTPRespCodeParameterNotSupported;
+            }
+        }
+        break;
+
+    case EMTPObjectPropCodeDateModified:
+        delete iDateMod;
+        iDateMod = NULL;
+        iDateMod = aElement.StringL(CMTPTypeObjectPropListElement::EValue).AllocL();
+        break;
+    case EMTPObjectPropCodeName:
+    	iName = aElement.StringL(CMTPTypeObjectPropListElement::EValue);
+    	break;
+    default:
+        break;
+        }
+    __FLOG_VA((_L8("Result = 0x%04X"), responseCode));
+    __FLOG(_L8("ExtractPropertyL - Exit"));
+    return responseCode;    
+    }
+
+/**
+Validates the data type for a given property code.
+@param aElement an object property list element
+@param aPropertyCode MTP property code for the element
+@return EMTPRespCodeOK if the combination is valid, or another MTP response code if not
+*/
+TMTPResponseCode CMTPSendObjectInfo::CheckPropCodeL(const CMTPTypeObjectPropListElement& aElement) const
+    {
+    __FLOG(_L8("CheckPropCode - Entry"));
+    TMTPResponseCode responseCode(EMTPRespCodeOK);
+    switch(aElement.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode))
+        {
+    case EMTPObjectPropCodeStorageID:
+        if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT32)
+            {
+            responseCode = EMTPRespCodeInvalidObjectPropFormat;
+            }
+        else if (iStorageId != aElement.Uint32L(CMTPTypeObjectPropListElement::EValue))
+            {
+            responseCode = EMTPRespCodeInvalidDataset;
+            }
+        break;
+    
+    case EMTPObjectPropCodeObjectFormat:
+        if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT16)
+            {
+            responseCode = EMTPRespCodeInvalidObjectPropFormat;
+            }
+        else if (Request().Uint32(TMTPTypeRequest::ERequestParameter3) != aElement.Uint16L(CMTPTypeObjectPropListElement::EValue))
+            {
+            responseCode = EMTPRespCodeInvalidDataset;
+            }
+        break;
+       
+    case EMTPObjectPropCodeObjectSize:
+        if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT64)
+            {
+            responseCode = EMTPRespCodeInvalidObjectPropFormat;
+            }
+        else if (iObjectSize != aElement.Uint64L(CMTPTypeObjectPropListElement::EValue))
+            {
+            responseCode = EMTPRespCodeInvalidDataset;
+            }
+        break;
+         
+    case EMTPObjectPropCodeParentObject:
+        if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT32)
+            {
+            responseCode = EMTPRespCodeInvalidObjectPropFormat;
+            }
+        else if (Request().Uint32(TMTPTypeRequest::ERequestParameter2) != aElement.Uint32L(CMTPTypeObjectPropListElement::EValue))
+            {
+            responseCode = EMTPRespCodeInvalidDataset;
+            }
+        break;
+
+    case EMTPObjectPropCodePersistentUniqueObjectIdentifier:
+        responseCode =     EMTPRespCodeAccessDenied;
+        break;
+
+    case EMTPObjectPropCodeProtectionStatus:
+        if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT16)
+            {
+            responseCode = EMTPRespCodeInvalidObjectPropFormat;
+            }                        
+        break;
+        
+    case EMTPObjectPropCodeDateModified:                    
+    case EMTPObjectPropCodeObjectFileName:    
+    case EMTPObjectPropCodeName:
+        if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeString)
+            {
+            responseCode = EMTPRespCodeInvalidObjectPropFormat;
+            }
+        break;
+        
+    case EMTPObjectPropCodeNonConsumable:
+        if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT8)
+            {
+            responseCode = EMTPRespCodeInvalidObjectPropFormat;
+            }
+        break;
+        
+    case EMTPObjectPropCodeAssociationType:
+        if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT16)
+             {
+             responseCode = EMTPRespCodeInvalidObjectPropFormat;
+             }
+    	break;
+    	
+    case EMTPObjectPropCodeAssociationDesc:
+        if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT32)
+             {
+             responseCode = EMTPRespCodeInvalidObjectPropFormat;
+             }
+    	break;
+                
+    default:
+        responseCode = EMTPRespCodeInvalidObjectPropCode;
+        break;
+        }
+    __FLOG_VA((_L8("Result = 0x%04X"), responseCode));
+    __FLOG(_L8("CheckPropCode - Exit"));
+    return responseCode;    
+    }
+
+/**
+Validates the data type for a given property code.
+@return EMTPRespCodeOK if the parent handle matches the store id, or another MTP response code if not
+*/
+TMTPResponseCode CMTPSendObjectInfo::MatchStoreAndParentL() const
+    {
+    TMTPResponseCode ret = EMTPRespCodeOK;
+    const TUint32 storeId(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
+    const TUint32 parentHandle(Request().Uint32(TMTPTypeRequest::ERequestParameter2));
+    
+    // this checking is only valid when the second parameter is not a special value.
+    if (parentHandle != KMTPHandleAll && parentHandle != KMTPHandleNone)
+        {
+        //does not take owernship
+        CMTPObjectMetaData* parentObjInfo = iRequestChecker->GetObjectInfo(parentHandle);
+        __ASSERT_DEBUG(parentObjInfo, Panic(EMTPDpObjectNull));
+        
+        if (parentObjInfo->Uint(CMTPObjectMetaData::EStorageId) != storeId)      
+            {
+            ret = EMTPRespCodeInvalidObjectHandle;
+            }
+        }
+        
+    return ret;
+    }
+
+/**
+Reserves space for and assigns an object handle to the received object, then
+sends a success response.
+*/
+void CMTPSendObjectInfo::ReserveObjectL()
+    {
+    __FLOG(_L8("ReserveObjectL - Entry"));    
+    iReceivedObject->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
+    iReceivedObject->SetDesCL(CMTPObjectMetaData::ESuid, iFullPath);
+    
+    iFramework.ObjectMgr().ReserveObjectHandleL(*iReceivedObject, iObjectSize);    
+    
+    if(iIsFolder)
+        {
+        SetPropertiesL(); 
+        iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObject);       
+        }
+    else
+    	{
+    	iExpectedSendObjectRequest.SetUint32(TMTPTypeRequest::ERequestSessionID, iSessionId);
+    	iFramework.RouteRequestRegisterL(iExpectedSendObjectRequest, iConnection);
+    	}
+    TUint32 parameters[3];
+    parameters[0] = iStorageId;
+    parameters[1] = iParentHandle;
+    parameters[2] = iReceivedObject->Uint(CMTPObjectMetaData::EHandle);
+    SendResponseL(EMTPRespCodeOK, (sizeof(parameters) / sizeof(parameters[0])), parameters);
+    __FLOG(_L8("ReserveObjectL - Exit"));    
+    }
+    
+void CMTPSendObjectInfo::CreateFsObjectL()
+    {
+    if (iIsFolder)
+        {
+        User::LeaveIfError(iFramework.Fs().MkDirAll(iFullPath));
+        }
+    else
+        {
+        delete iFileReceived;
+        iFileReceived = NULL;
+        iFileReceived = CMTPTypeFile::NewL(iFramework.Fs(), iFullPath, EFileWrite);
+        iFileReceived->SetSizeL(iObjectSize);
+        }
+    }
+    
+void CMTPSendObjectInfo::Rollback()
+    {
+    if(iIsFolder)
+        {
+        __FLOG(_L8("It is a folder cancel process."));
+        iFramework.Fs().RmDir(iFullPath);
+        // If it is folder, delete it from MTP database, i.e ObjectStore.
+        TRAP_IGNORE(iFramework.ObjectMgr().RemoveObjectL(iFullPath));
+        }
+    else
+        {
+        __FLOG(_L8("It is a file cancel process."));
+        // Delete this object from file system.
+        iFramework.Fs().Delete(iFullPath);
+        TRAP_IGNORE(iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObject));
+        }
+    }
+    
+TMTPResponseCode CMTPSendObjectInfo::ErrorToMTPError(TInt aError) const
+    {
+    TMTPResponseCode resp = EMTPRespCodeGeneralError;
+    
+    switch (aError)
+        {
+    case KErrNone:
+        resp = EMTPRespCodeOK;
+        break;
+        
+    case KErrAccessDenied:
+        resp = EMTPRespCodeAccessDenied;
+        break;
+        
+    case KErrDiskFull:
+        resp = EMTPRespCodeStoreFull;
+        break;
+        }
+        
+    return resp;
+    }
+
+/**
+Sets the read only status on the current file to match the sent object.
+*/
+void CMTPSendObjectInfo::SetPropertiesL()
+    {
+    __FLOG(_L8("SetPropertiesL - Entry"));
+    TEntry entry;
+    User::LeaveIfError(iFramework.Fs().Entry(iFullPath, entry));  
+    
+    TUint16 assoc(EMTPAssociationTypeUndefined);
+	if (entry.IsDir())
+		{
+		assoc = EMTPAssociationTypeGenericFolder;
+		}
+	iReceivedObject->SetUint(CMTPObjectMetaData::EFormatSubCode, assoc);    
+        
+    if (iName.Length() == 0)
+    {
+    	if (entry.IsDir())
+    	{
+    		TParsePtrC pathParser(iFullPath.Left(iFullPath.Length() - 1)); // Ignore the trailing "\".
+    		iName = pathParser.Name();
+    	}
+    	else
+    	{
+        	TParsePtrC pathParser(iFullPath);
+        	iName = pathParser.Name();
+    	}
+    }    
+    
+    if (iProtectionStatus ==  EMTPProtectionNoProtection ||
+        iProtectionStatus == EMTPProtectionReadOnly)
+        {
+        entry.iAtt &= ~(KEntryAttNormal | KEntryAttReadOnly);
+        if (iProtectionStatus == EMTPProtectionNoProtection)
+            {                        
+            entry.iAtt |= KEntryAttNormal;
+            }
+        else
+            {
+            entry.iAtt |= KEntryAttReadOnly;
+            }
+        User::LeaveIfError(iFramework.Fs().SetAtt(iFullPath, entry.iAtt, ~entry.iAtt));
+        }
+    iReceivedObject->SetDesCL(CMTPObjectMetaData::EName, iName);
+    
+    __FLOG(_L8("SetPropertiesL - Exit"));
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,248 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/cmtptypeobjectproplist.h>
+
+#include "cmtpsetobjectproplist.h"
+#include "cmtpdataprovidercontroller.h"
+
+
+EXPORT_C MMTPRequestProcessor* CMTPSetObjectPropList::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+	{
+	CMTPSetObjectPropList* self = new (ELeave) CMTPSetObjectPropList(aFramework, aConnection);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+EXPORT_C CMTPSetObjectPropList::~CMTPSetObjectPropList()
+	{
+	iDpSingletons.Close();
+	iSingleton.Close();		
+	delete iPropertyList;
+	delete iObjMeta;
+	}
+	
+CMTPSetObjectPropList::CMTPSetObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL)		
+	{
+	
+	}
+	
+void CMTPSetObjectPropList::ConstructL()
+	{
+	iDpSingletons.OpenL(iFramework);
+	iSingleton.OpenL();		
+	iPropertyList = CMTPTypeObjectPropList::NewL();
+	iObjMeta = CMTPObjectMetaData::NewL();
+	}
+
+void CMTPSetObjectPropList::ServiceL()
+	{
+	ReceiveDataL(*iPropertyList);
+	}
+
+TBool CMTPSetObjectPropList::DoHandleResponsePhaseL()
+	{
+    MMTPObjectMgr& objects(iFramework.ObjectMgr());
+	TUint32 parameter(0);
+    TMTPResponseCode responseCode(EMTPRespCodeOK);
+    const TUint count(iPropertyList->NumberOfElements());
+    iPropertyList->ResetCursor();
+    for (TUint i(0); ((i < count) && (responseCode == EMTPRespCodeOK)); i++)
+    	{
+    	CMTPTypeObjectPropListElement& element=iPropertyList->GetNextElementL(); 
+    	TUint32 handle = element.Uint32L(CMTPTypeObjectPropListElement::EObjectHandle);
+    	TUint16 propertyCode = element.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode);
+    	TUint16 dataType = element.Uint16L(CMTPTypeObjectPropListElement::EDatatype);
+    	
+		if (objects.ObjectOwnerId(handle) == iFramework.DataProviderId())
+		    {
+		    // Object is owned by the FileDp
+    		responseCode = CheckPropCode(propertyCode, dataType);	
+        	if (responseCode == EMTPRespCodeOK)
+        		{
+    			responseCode = CheckObjectHandleL(handle);
+        		}
+        					
+     		if (responseCode == EMTPRespCodeOK)
+     			{
+     			switch(propertyCode)
+     				{
+    			case EMTPObjectPropCodeObjectFileName:
+    				{
+    				const TDesC& newName =  element.StringL(CMTPTypeObjectPropListElement::EValue);
+					TRAPD(err, iDpSingletons.MTPUtility().RenameObjectL(handle, newName));
+					if(KErrNotFound == err)
+						{
+						responseCode = EMTPRespCodeInvalidObjectHandle;
+						}
+					else if( KErrAlreadyExists == err)
+						{
+						responseCode = EMTPRespCodeInvalidObjectPropValue;
+						}
+					else if(KErrNone != err)
+						{
+						responseCode = EMTPRespCodeAccessDenied;
+						}
+    				}
+    				break;
+    			case EMTPObjectPropCodeName:
+    				{
+    				const TDesC& newName =  element.StringL(CMTPTypeObjectPropListElement::EValue);
+					iObjMeta->SetDesCL( CMTPObjectMetaData::EName, newName);
+					iFramework.ObjectMgr().ModifyObjectL(*iObjMeta);
+
+    				break;
+    				}
+    									
+    			case EMTPObjectPropCodeDateModified:
+    				{
+    				TTime modifiedTime;
+					if( iDpSingletons.MTPUtility().MTPTimeStr2TTime(element.StringL(CMTPTypeObjectPropListElement::EValue), modifiedTime) )
+						{
+						iSingleton.Fs().SetModified( iObjMeta->DesC(CMTPObjectMetaData::ESuid), modifiedTime );
+						}
+					else
+						{
+						responseCode = EMTPRespCodeInvalidObjectPropValue;
+						}
+    				}			
+    				break;
+    				
+    			case EMTPObjectPropCodeNonConsumable:
+    				iObjMeta->SetUint( CMTPObjectMetaData::ENonConsumable, element.Uint8L(CMTPTypeObjectPropListElement::EValue));
+					iFramework.ObjectMgr().ModifyObjectL(*iObjMeta);
+    				break;
+    				
+    			case EMTPObjectPropCodeAssociationType:
+    			    if (EModeMTP != iFramework.Mode())
+    			    	{
+    			    	responseCode = EMTPRespCodeOK;	
+    			    	}
+    			    else if( element.Uint16L(CMTPTypeObjectPropListElement::EValue) == EMTPAssociationTypeGenericFolder )
+						{
+						responseCode = EMTPRespCodeOK;			
+						}
+					else
+						{
+						responseCode = EMTPRespCodeInvalidObjectPropValue;
+						}
+					break;
+					
+				case EMTPObjectPropCodeAssociationDesc:
+					if((element.Uint32L(CMTPTypeObjectPropListElement::EValue)) == 0)
+						{
+						responseCode = EMTPRespCodeOK;
+						}
+					else
+						{
+						responseCode = EMTPRespCodeInvalidObjectPropValue;
+						}
+					break;
+    			default:
+    				responseCode = EMTPRespCodeObjectPropNotSupported;
+    				break;
+     				}
+     			}
+     			
+     		if (responseCode != EMTPRespCodeOK)
+     			{
+     			// Return the index of the failed property in the response.
+     			parameter = i;
+     			}
+		    }
+    	}
+    
+	SendResponseL(responseCode, 1, &parameter);
+	return EFalse;
+	}
+
+TBool CMTPSetObjectPropList::HasDataphase() const
+	{
+	return ETrue;
+	}
+
+TMTPResponseCode CMTPSetObjectPropList::CheckPropCode(TUint16 aPropertyCode, TUint16 aDataType) const
+	{
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	switch(aPropertyCode)
+		{
+		case EMTPObjectPropCodeStorageID:
+		case EMTPObjectPropCodeObjectFormat:
+		case EMTPObjectPropCodeObjectSize:		
+		case EMTPObjectPropCodeParentObject:
+		case EMTPObjectPropCodePersistentUniqueObjectIdentifier:
+		case EMTPObjectPropCodeProtectionStatus:
+			responseCode = 	EMTPRespCodeAccessDenied;
+			break;
+							
+		case EMTPObjectPropCodeObjectFileName:	
+		case EMTPObjectPropCodeName:
+		case EMTPObjectPropCodeDateModified:
+			if (aDataType != EMTPTypeString)
+				{
+				responseCode = EMTPRespCodeInvalidObjectPropFormat;
+				}
+			break;
+		case EMTPObjectPropCodeNonConsumable:
+			if (aDataType != EMTPTypeUINT8)
+				{
+				responseCode = EMTPRespCodeInvalidObjectPropFormat;
+				}
+			break;
+		case EMTPObjectPropCodeAssociationType:
+			if (aDataType != EMTPTypeUINT16)
+				{
+				responseCode = EMTPRespCodeInvalidObjectPropFormat;
+				}
+			break;
+		case EMTPObjectPropCodeAssociationDesc:
+			if (aDataType != EMTPTypeUINT32)
+				{
+				responseCode = EMTPRespCodeInvalidObjectPropFormat;
+				}
+			break;
+		default:
+			responseCode = EMTPRespCodeInvalidObjectPropCode;
+		}
+	return responseCode;
+	}
+	
+TMTPResponseCode CMTPSetObjectPropList::CheckObjectHandleL(TUint32 aHandle) const
+	{
+    TMTPResponseCode responseCode = EMTPRespCodeOK; 
+
+    // Obj handle doesn't exist
+	if (!(iFramework.ObjectMgr().ObjectL(aHandle, *iObjMeta)) )
+		{
+		responseCode = EMTPRespCodeInvalidObjectHandle;
+		}	
+	return responseCode;	
+	}
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectpropvalue.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,334 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <bautils.h>
+#include <f32file.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpobjectmgr.h>
+
+#include "cmtpsetobjectpropvalue.h"
+#include "mtpdpconst.h"
+#include "mtpdppanic.h"
+#include "cmtpdataprovidercontroller.h"
+#include "mtpframeworkconst.h"
+#include "rmtpdpsingletons.h"
+#include "rmtputility.h"
+
+/**
+Verification data for the SetObjectPropValue request
+*/
+const TMTPRequestElementInfo KMTPSetObjectPropValuePolicy[] = 
+    {
+    	{TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrWrite, 0, 0, 0},   	
+     };
+     
+/**
+Two-phase construction method
+@param aPlugin	The data provider plugin
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+EXPORT_C MMTPRequestProcessor* CMTPSetObjectPropValue::NewL(
+											MMTPDataProviderFramework& aFramework,
+											MMTPConnection& aConnection)
+	{
+	CMTPSetObjectPropValue* self = new (ELeave) CMTPSetObjectPropValue(aFramework, aConnection);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+Destructor
+*/	
+EXPORT_C CMTPSetObjectPropValue::~CMTPSetObjectPropValue()
+	{	
+	delete iMTPTypeString;
+	iSingleton.Close();
+	iDpSingletons.Close();
+	delete iObjMeta;
+	}
+
+/**
+Standard c++ constructor
+*/	
+CMTPSetObjectPropValue::CMTPSetObjectPropValue(
+									MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection)
+	:CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPSetObjectPropValuePolicy)/sizeof(TMTPRequestElementInfo), KMTPSetObjectPropValuePolicy),
+	iRfs(aFramework.Fs())
+	{
+	}
+	
+	
+/**
+A helper function of CheckRequestL. To check whether the object property code is readonly.
+@param aObjectPropCode the object property code passed in.
+@return ETrue if the object property code is readonly. Otherwise EFalse.
+*/	
+TBool CMTPSetObjectPropValue::IsPropCodeReadonly(TUint32 aObjectPropCode)
+	{
+	TBool returnCode = EFalse;
+	if(aObjectPropCode == EMTPObjectPropCodeStorageID
+		|| aObjectPropCode == EMTPObjectPropCodeObjectFormat
+		|| aObjectPropCode == EMTPObjectPropCodeProtectionStatus
+		|| aObjectPropCode == EMTPObjectPropCodeObjectSize
+		|| aObjectPropCode == EMTPObjectPropCodeParentObject
+		|| aObjectPropCode == EMTPObjectPropCodePersistentUniqueObjectIdentifier)
+		{
+		returnCode = ETrue;
+		}
+	return returnCode;
+	}
+
+/**
+Verify request
+*/
+TMTPResponseCode CMTPSetObjectPropValue::CheckRequestL()
+	{
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+
+    TUint32 handle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    CMTPObjectMetaData* meta = iRequestChecker->GetObjectInfo(handle);
+    __ASSERT_DEBUG(meta, Panic(EMTPDpObjectNull));
+    
+	if(responseCode == EMTPRespCodeOK)
+		{
+		TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+		
+		if(propCode != EMTPObjectPropCodeAssociationType && propCode != EMTPObjectPropCodeAssociationDesc)
+			{
+			const TInt count = sizeof(KMTPDpSupportedProperties) / sizeof(TUint16);
+			TInt i = 0;
+			for(i = 0; i < count; i++)
+				{
+				if(KMTPDpSupportedProperties[i] == propCode
+					&& IsPropCodeReadonly(propCode))
+					// Object property code supported, but cann't be set.
+					{
+					responseCode = EMTPRespCodeAccessDenied;
+					break;
+					}
+				else if(KMTPDpSupportedProperties[i] == propCode)
+					// Object property code supported and can be set.
+					{
+					break;
+					}
+				}
+			if(i == count)
+				{
+				responseCode = EMTPRespCodeInvalidObjectPropCode;
+				}
+			}
+		else if(meta->Uint(CMTPObjectMetaData::EFormatCode) != EMTPFormatCodeAssociation)
+			{
+			responseCode = EMTPRespCodeInvalidObjectFormatCode;
+			}
+		}
+	else
+	    {
+	    const TDesC& suid(meta->DesC(CMTPObjectMetaData::ESuid));
+	    TEntry entry;
+	    User::LeaveIfError( iFramework.Fs().Entry(suid, entry) );
+        
+	    //According to spec, there are 4 statuses: No Protection; Read-only; Read-only data; Non-transferrable data
+	    //Currently, we only use FS's Read-only attribute to support No Protection and Read-only statuses.
+	    //so if the attribute is read-only, we will return EMTPRespCodeAccessDenied.
+        if (entry.IsReadOnly())
+             {
+             responseCode = EMTPRespCodeAccessDenied;
+             }        
+	    }
+	
+	return responseCode;	
+	}
+		
+/**
+SetObjectPropValue request handler
+*/	
+void CMTPSetObjectPropValue::ServiceL()
+	{
+	__ASSERT_DEBUG(iRequestChecker, Panic(EMTPDpRequestCheckNull));
+	TUint32 handle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+	TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+	
+	iFramework.ObjectMgr().ObjectL(TMTPTypeUint32(handle), *iObjMeta);
+	User::LeaveIfError(iRfs.Entry(iObjMeta->DesC(CMTPObjectMetaData::ESuid), iFileEntry));
+	
+	delete iMTPTypeString;
+	iMTPTypeString = NULL;
+	iMTPTypeString = CMTPTypeString::NewL();
+	switch(propCode)
+		{	
+		case EMTPObjectPropCodeDateModified:
+		case EMTPObjectPropCodeObjectFileName:
+		case EMTPObjectPropCodeName:
+			 ReceiveDataL(*iMTPTypeString);
+			break;
+		case EMTPObjectPropCodeNonConsumable:
+			ReceiveDataL(iMTPTypeUint8);
+			break;
+		case EMTPObjectPropCodeAssociationType:
+			{
+			ReceiveDataL(iMTPTypeUint16);
+			}
+			break;
+		case EMTPObjectPropCodeAssociationDesc:
+			{
+			ReceiveDataL(iMTPTypeUint32);
+			}
+			break;
+			
+		case EMTPObjectPropCodeStorageID:
+		case EMTPObjectPropCodeObjectFormat:
+		case EMTPObjectPropCodeProtectionStatus:
+		case EMTPObjectPropCodeObjectSize:		
+		case EMTPObjectPropCodeParentObject:
+		case EMTPObjectPropCodePersistentUniqueObjectIdentifier:
+			{
+			//!!! Never come here, it should be blocked on CheckRequestL()
+			// and EMTPRespCodeAccessDenied will be reported.
+			//No break sentance, goto Panic
+			}
+		default:
+			Panic(EMTPDpUnsupportedProperty);
+		}	
+	}
+
+/**
+Apply the references to the specified object
+@return EFalse
+*/	
+TBool CMTPSetObjectPropValue::DoHandleResponsePhaseL()
+	{
+	TMTPResponseCode responseCode = EMTPRespCodeInvalidObjectPropFormat;
+	TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+	
+	switch(propCode)
+		{
+		case EMTPObjectPropCodeDateModified:
+			{
+			TTime modifiedTime;
+			if( iDpSingletons.MTPUtility().MTPTimeStr2TTime(iMTPTypeString->StringChars(), modifiedTime) )
+				{
+				iRfs.SetModified( iObjMeta->DesC(CMTPObjectMetaData::ESuid), modifiedTime );
+				responseCode = EMTPRespCodeOK;
+				
+				}
+			else
+				{
+				responseCode = EMTPRespCodeInvalidObjectPropValue;
+				}
+			}
+			break;
+			
+		case EMTPObjectPropCodeObjectFileName:
+			{
+
+			TRAPD(err, iDpSingletons.MTPUtility().RenameObjectL(iObjMeta->Uint(CMTPObjectMetaData::EHandle),iMTPTypeString->StringChars())) ;
+			if( KErrNone == err )
+				{
+				responseCode = EMTPRespCodeOK;
+				}
+			else if(KErrNotFound == err)
+				{
+				responseCode = EMTPRespCodeInvalidObjectHandle;
+				}
+			else if( KErrAlreadyExists == err)
+				{
+				responseCode = EMTPRespCodeInvalidObjectPropValue;
+				}
+			else 
+				{
+				responseCode = EMTPRespCodeAccessDenied;
+				}
+			}
+			break;
+		case EMTPObjectPropCodeName:
+			{			
+			//Might need to consider to save this name into meta-data base.
+			//Notify all the Data Providers if the Owner of the object is DeviceDP
+			const TDesC& name = iMTPTypeString->StringChars();
+			if(name != iFileEntry.iName)
+				{
+				iObjMeta->SetDesCL( CMTPObjectMetaData::EName, name);
+				iFramework.ObjectMgr().ModifyObjectL(*iObjMeta);
+				}
+			responseCode = EMTPRespCodeOK;
+			}
+			break;
+		case EMTPObjectPropCodeNonConsumable:
+			{
+			iObjMeta->SetUint( CMTPObjectMetaData::ENonConsumable, iMTPTypeUint8.Value());
+			iFramework.ObjectMgr().ModifyObjectL(*iObjMeta);
+			responseCode = EMTPRespCodeOK;
+			}
+			break;
+		case EMTPObjectPropCodeAssociationType:
+			{
+		    if (EModeMTP != iFramework.Mode())
+		    	{
+		    	responseCode = EMTPRespCodeOK;	
+		    	}
+		    else if( iMTPTypeUint16.Value() != EMTPAssociationTypeGenericFolder )
+				{
+				responseCode = EMTPRespCodeInvalidObjectPropValue;
+				}
+			else
+				{
+				responseCode = EMTPRespCodeOK;
+				}
+			}
+			break;
+		case EMTPObjectPropCodeAssociationDesc:
+			{
+			if(TUint32(iMTPTypeUint32.Value()) == 0 )
+				{
+				responseCode = EMTPRespCodeOK;
+				}
+			else
+				responseCode = EMTPRespCodeInvalidObjectPropValue;
+			}	
+			break;
+			
+			
+		default:
+			Panic(EMTPDpUnsupportedProperty);
+		}
+
+	SendResponseL(responseCode);
+	return EFalse;	
+	}
+	
+TBool CMTPSetObjectPropValue::HasDataphase() const
+	{
+	return ETrue;
+	}
+	
+/**
+Second-phase construction
+*/			
+void CMTPSetObjectPropValue::ConstructL()
+	{	
+	iSingleton.OpenL();
+	iObjMeta = CMTPObjectMetaData::NewL();
+	iDpSingletons.OpenL(iFramework);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectprotection.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,130 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <bautils.h>
+#include <f32file.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpobjectmgr.h>
+
+#include "cmtpsetobjectprotection.h"
+#include "mtpdpconst.h"
+#include "mtpdppanic.h"
+#include "cmtpdataprovidercontroller.h"
+#include "mtpframeworkconst.h"
+#include "rmtpdpsingletons.h"
+#include "rmtputility.h"
+
+/**
+Verification data for the SetObjectPropValue request
+*/
+const TMTPRequestElementInfo KMTPSetObjectProtectionPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrWrite, 0, 0, 0},      
+     };
+
+/**
+Two-phase construction method
+@param aPlugin  The data provider plugin
+@param aFramework   The data provider framework
+@param aConnection  The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+EXPORT_C MMTPRequestProcessor* CMTPSetObjectProtection::NewL(
+                                            MMTPDataProviderFramework& aFramework,
+                                            MMTPConnection& aConnection)
+    {
+    CMTPSetObjectProtection* self = new (ELeave) CMTPSetObjectProtection(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/  
+EXPORT_C CMTPSetObjectProtection::~CMTPSetObjectProtection()
+    {   
+    delete iObjMeta;
+    }
+
+/**
+Standard c++ constructor
+*/  
+CMTPSetObjectProtection::CMTPSetObjectProtection(
+                                    MMTPDataProviderFramework& aFramework,
+                                    MMTPConnection& aConnection)
+    :CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPSetObjectProtectionPolicy)/sizeof(TMTPRequestElementInfo), KMTPSetObjectProtectionPolicy),
+    iRfs(aFramework.Fs())
+    {
+    }
+                                    
+TMTPResponseCode CMTPSetObjectProtection::CheckRequestL()
+    {
+    //TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+    TUint32 handle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    iFramework.ObjectMgr().ObjectL(TMTPTypeUint32(handle), *iObjMeta);
+    if (!iObjMeta )
+        {
+        return EMTPRespCodeInvalidObjectHandle;
+        }
+    TUint32 statusValue = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+    //Currently we only support EMTPProtectionNoProtection and EMTPProtectionReadOnly
+    if ( statusValue!=EMTPProtectionNoProtection && statusValue!=EMTPProtectionReadOnly )
+        {
+        return EMTPRespCodeInvalidParameter;
+        }
+    
+    return EMTPRespCodeOK;
+    }
+
+void CMTPSetObjectProtection::ServiceL()
+    {
+    TUint32 handle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+    TUint32 statusValue = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+    TMTPResponseCode rsp = EMTPRespCodeOK;
+    //iFramework.ObjectMgr().ObjectL(TMTPTypeUint32(handle), *iObjMeta);
+    
+    switch(statusValue)
+        {
+        case EMTPProtectionNoProtection:
+            {
+            iRfs.SetAtt(iObjMeta->DesC(CMTPObjectMetaData::ESuid),KEntryAttNormal,KEntryAttReadOnly);
+            }
+            break;
+        case EMTPProtectionReadOnly:
+        case EMTPProtectionReadOnlyData:
+            {
+            iRfs.SetAtt(iObjMeta->DesC(CMTPObjectMetaData::ESuid),KEntryAttReadOnly,KEntryAttNormal);
+            }
+            break;
+        default:
+            rsp = EMTPRespCodeInvalidParameter;
+            break;
+
+        }
+    SendResponseL(rsp);
+    }
+
+/**
+Second-phase construction
+*/          
+void CMTPSetObjectProtection::ConstructL()
+    {   
+    iObjMeta = CMTPObjectMetaData::NewL();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetreferences.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,126 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpreferencemgr.h>
+#include <mtp/mtpdatatypeconstants.h>
+
+#include "cmtpsetreferences.h"
+#include "mtpdppanic.h"
+
+/**
+Verification data for the SetReferences request
+*/
+const TMTPRequestElementInfo KMTPSetReferencesPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrNone, 0, 0, 0}
+    };
+
+/**
+Two-phase construction method
+@param aPlugin    The data provider plugin
+@param aFramework    The data provider framework
+@param aConnection    The connection from which the request comes
+@return a pointer to the created request processor object
+*/    
+EXPORT_C MMTPRequestProcessor* CMTPSetReferences::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPSetReferences* self = new (ELeave) CMTPSetReferences(aFramework, aConnection);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+EXPORT_C CMTPSetReferences::~CMTPSetReferences()
+    {
+    delete iReferences;
+    }
+
+/**
+Standard c++ constructor
+*/    
+CMTPSetReferences::CMTPSetReferences(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPSetReferencesPolicy)/sizeof(TMTPRequestElementInfo), KMTPSetReferencesPolicy)
+    {
+    
+    }
+
+/**
+SetReferences request handler
+start receiving reference data from the initiator
+*/
+void CMTPSetReferences::ServiceL()
+    {
+    delete iReferences;
+    iReferences = NULL;
+    iReferences = CMTPTypeArray::NewL(EMTPTypeAUINT32);
+    ReceiveDataL(*iReferences);
+    }
+
+/**
+Apply the references to the specified object
+@return EFalse
+*/    
+TBool CMTPSetReferences::DoHandleResponsePhaseL()
+    {
+    if(!VerifyReferenceHandlesL())
+        {
+        SendResponseL(EMTPRespCodeInvalidObjectReference);
+        }
+    else
+        {
+        MMTPReferenceMgr& referenceMgr = iFramework.ReferenceMgr();
+        TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+        referenceMgr.SetReferencesL(TMTPTypeUint32(objectHandle), *iReferences);
+        SendResponseL(EMTPRespCodeOK);
+        }
+    return EFalse;    
+    }
+
+TBool CMTPSetReferences::HasDataphase() const
+    {
+    return ETrue;
+    }
+
+/**
+Verify if the references are valid handles to objects
+@return ETrue if all the references are good, otherwise, EFalse
+*/    
+TBool CMTPSetReferences::VerifyReferenceHandlesL() const
+    {
+    __ASSERT_DEBUG(iReferences, User::Invariant());
+    TBool result = ETrue;
+    TInt count = iReferences->NumElements();
+    CMTPObjectMetaData* object(CMTPObjectMetaData::NewLC());
+    MMTPObjectMgr& objectMgr = iFramework.ObjectMgr();
+    for(TInt i = 0; i < count; i++)
+        {
+        TMTPTypeUint32 handle;
+        iReferences->ElementL(i, handle);
+        if(!objectMgr.ObjectL(handle, *object))
+            {
+            result = EFalse;
+            break;
+            }
+        }
+    CleanupStack::PopAndDestroy(object);
+    return result;    
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvccompoundprocessor.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,945 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvccompoundprocessor.cpp
+
+#include <mtp/mmtpdataproviderframework.h>
+
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypefile.h>
+#include <mtp/cmtptypeobjectinfo.h>
+#include <mtp/cmtptypeobjectproplist.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpstoragemgr.h>
+#include <mtp/mtpprotocolconstants.h> 
+#include <mtp/tmtptypeint128.h>
+
+#include "cmtpsvccompoundprocessor.h"
+#include "mmtpservicedataprovider.h"
+#include "mmtpsvcobjecthandler.h"
+
+#include "cmtpconnection.h"
+#include "cmtpconnectionmgr.h"
+#include "mtpsvcdpconst.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"SvcCompound");)
+
+EXPORT_C MMTPRequestProcessor* CMTPSvcCompoundProcessor::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider)
+	{
+	CMTPSvcCompoundProcessor* self = new (ELeave) CMTPSvcCompoundProcessor(aFramework, aConnection, aDataProvider);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CMTPSvcCompoundProcessor::~CMTPSvcCompoundProcessor()
+	{
+	__FLOG(_L8("~CMTPSvcCompoundProcessor - Entry"));
+	delete iReceivedObjectMetaData;
+	delete iObjectInfo;
+	delete iObjectPropList;
+	__FLOG(_L8("~CMTPSvcCompoundProcessor - Exit"));
+	__FLOG_CLOSE; 
+	}
+
+CMTPSvcCompoundProcessor::CMTPSvcCompoundProcessor(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider) :
+	CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
+	iDataProvider(aDataProvider), iState(EIdle), iIsCommited(EFalse), iIsRollBackHandlerObject(EFalse)
+	{
+	}
+
+void CMTPSvcCompoundProcessor::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry"));
+	iExpectedSendObjectRequest.SetUint16(TMTPTypeRequest::ERequestOperationCode, EMTPOpCodeSendObject);
+	iReceivedObjectMetaData = CMTPObjectMetaData::NewL();
+	iReceivedObjectMetaData->SetUint(CMTPObjectMetaData::EDataProviderId, iFramework.DataProviderId());
+	__FLOG(_L8("ConstructL - Exit"));
+	}
+
+/**
+Override to match both the SendObjectInfo/SendObjectPropList/UpdateObjectPropList and SendObject requests
+@param aRequest    The request to match
+@param aConnection The connection from which the request comes
+@return ETrue if the processor can handle the request, otherwise EFalse
+*/
+TBool CMTPSvcCompoundProcessor::Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const
+	{
+	__FLOG(_L8("Match - Entry"));
+	TBool result = EFalse;
+	TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
+	if ((&iConnection == &aConnection) && 
+		(operationCode == EMTPOpCodeSendObjectInfo || 
+		operationCode == EMTPOpCodeSendObject ||
+		operationCode == EMTPOpCodeUpdateObjectPropList ||
+		operationCode == EMTPOpCodeSendObjectPropList))
+		{
+		result = ETrue;
+		}
+	__FLOG(_L8("Match - Exit"));
+	return result;
+	}
+
+TBool CMTPSvcCompoundProcessor::HasDataphase() const
+	{
+	return ETrue;
+	}
+
+/**
+Verify the request
+@return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
+*/
+TMTPResponseCode CMTPSvcCompoundProcessor::CheckRequestL()
+	{
+	__FLOG(_L8("CheckRequestL - Entry"));
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	if (EMTPRespCodeOK == responseCode)
+		{
+		responseCode = CheckSendingStateL();
+		if (EMTPRespCodeOK == responseCode)
+			{
+			responseCode = CheckRequestParametersL();
+			}
+		}
+	__FLOG_VA((_L8("CheckRequestL - Exit with code: 0x%04X"), responseCode));
+	return responseCode;
+	}
+
+/**
+Verify if the SendObject request comes after SendObjectInfo/SendObjectPropList request
+@return EMTPRespCodeOK if SendObject request comes after a valid SendObjectInfo request, otherwise
+EMTPRespCodeNoValidObjectInfo
+*/
+TMTPResponseCode CMTPSvcCompoundProcessor::CheckSendingStateL()
+	{
+	__FLOG(_L8("CheckSendingStateL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	iOperationCode = Request().Uint16(TMTPTypeRequest::ERequestOperationCode);
+	
+	if (iOperationCode == EMTPOpCodeSendObject)
+		{
+		//In ParseRouter everytime SendObject gets resolved then will be removed from Registry
+		//Right away therefore we need reRegister it here again in case possible cancelRequest
+		//Against this SendObject being raised.
+		iExpectedSendObjectRequest.SetUint32(TMTPTypeRequest::ERequestSessionID, iSessionId);
+		iFramework.RouteRequestRegisterL(iExpectedSendObjectRequest, iConnection);
+		}
+
+	switch (iState)
+		{
+		case EIdle:
+			// Received an orphan SendObject
+			if (iOperationCode == EMTPOpCodeSendObject)
+				{
+				responseCode = EMTPRespCodeNoValidObjectInfo;
+				__FLOG(_L8("EIdle: Received an orphan SendObject request"));
+				}
+			break;
+		case EObjectInfoSucceed:
+			// If another SendObjectInfo or SendObjectPropList operation occurs before a SendObject
+			// operation, the new ObjectInfo or ObjectPropList shall replace the previously held one. 
+			// If this occurs, any storage or memory space reserved for the object described in the 
+			// overwritten ObjectInfo or ObjectPropList dataset should be freed before overwriting and 
+			// allocating the resources for the new data. 
+			
+			// Here is for the processor received another SendObjectInfo or SendObjectPropList 
+			// before a SendObject or process SendObject failed,
+			if (iOperationCode == EMTPOpCodeSendObjectInfo ||
+				iOperationCode == EMTPOpCodeSendObjectPropList ||
+				iOperationCode == EMTPOpCodeUpdateObjectPropList)
+				{
+				iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
+				if (!iIsCommited)
+					{
+					// Object Size != 0, need roll back all resource for the new SendInfo request
+					CMTPSvcCompoundProcessor::RollBackObject(this);
+					iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObjectMetaData);
+					}
+				delete iObjectInfo;
+				iObjectInfo = NULL;
+				delete iObjectPropList;
+				iObjectPropList = NULL;
+				delete iReceivedObjectMetaData;
+				iReceivedObjectMetaData = NULL;
+				iReceivedObjectMetaData = CMTPObjectMetaData::NewL();
+				iReceivedObjectMetaData->SetUint(CMTPObjectMetaData::EDataProviderId, iFramework.DataProviderId());
+				iObjectHandler = NULL;
+				iState = EIdle;
+				// Reset commit state to false
+				iIsCommited = EFalse;
+				__FLOG(_L8("EObjectInfoSucceed: Receive send obj info request again, return to EIdle"));
+				}
+			break;
+		default:
+			User::Leave(KErrGeneral);
+		}
+	__FLOG_VA((_L8("CheckSendingStateL - Exit with code: 0x%04X, state: %u"), responseCode, iState));
+	return responseCode;
+	}
+
+/**
+Validates the data type for a given property code.
+@return EMTPRespCodeOK if the parent handle matches the store id, or another MTP response code if not
+*/
+TMTPResponseCode CMTPSvcCompoundProcessor::CheckRequestParametersL()
+	{
+	__FLOG(_L8("CheckRequestParametersL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	
+	switch (iOperationCode)
+		{
+		case EMTPOpCodeSendObject:
+			{
+			__FLOG(_L8("Check SendObject request parameters"));
+			// Check SendObject's session ID
+			if (iSessionId != iLastSessionID)
+				{
+				responseCode = EMTPRespCodeNoValidObjectInfo;
+				}
+			else if ((iLastTransactionID + 1) != iTransactionCode)
+				{
+				// Check SendObject's transaction ID
+				responseCode = EMTPRespCodeInvalidTransactionID;
+				}
+			break;
+			}
+
+		case EMTPOpCodeSendObjectInfo:
+			{
+			__FLOG(_L8("Check SendObjectInfo request parameters"));
+			responseCode = CheckStoreAndParent();
+			break;
+			}
+			
+		case EMTPOpCodeSendObjectPropList:
+			{
+			__FLOG(_L8("Check SendObjectPropList request parameters"));
+			responseCode = CheckStoreAndParent();
+			if (EMTPRespCodeOK == responseCode)
+				{
+				// SendObjectPropList need check format code and size in the request
+				TUint32 objectSizeHigh = Request().Uint32(TMTPTypeRequest::ERequestParameter4);
+				TUint32 objectSizeLow  = Request().Uint32(TMTPTypeRequest::ERequestParameter5);
+				iObjectSize = MAKE_TUINT64(objectSizeHigh, objectSizeLow);
+				
+				iFormatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
+				responseCode = CheckFmtAndSetHandler(iFormatCode);
+				iReceivedObjectMetaData->SetUint(CMTPObjectMetaData::EFormatCode, iFormatCode);
+				}
+			break;
+			}
+
+		case EMTPOpCodeUpdateObjectPropList:
+			{
+			__FLOG(_L8("Check UpdateObjectPropList request parameters"));
+			TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+			if (objectHandle != KMTPHandleNone)
+				{
+				// Find the updating object information
+				MMTPObjectMgr& objects(iFramework.ObjectMgr());
+				if (objects.ObjectL(objectHandle, *iReceivedObjectMetaData))
+					{
+					iFormatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode);
+					if (iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EDataProviderId) != iFramework.DataProviderId())
+						{
+						responseCode = EMTPRespCodeInvalidObjectHandle;
+						}
+					else
+						{
+						responseCode = CheckFmtAndSetHandler(iFormatCode);
+						}
+					}
+				else
+					{
+					responseCode = EMTPRespCodeInvalidObjectHandle;
+					}
+				}
+			else
+				{
+				responseCode = EMTPRespCodeInvalidObjectHandle;
+				}
+			break;
+			}
+			
+		default:
+			// Unexpected operation code
+			responseCode = EMTPRespCodeOperationNotSupported;
+			break;
+		}
+	__FLOG_VA((_L8("CheckRequestParametersL exit with code: 0x%x"), responseCode));
+	return responseCode;
+	}
+
+/**
+Validates the data type for a given property code.
+@return EMTPRespCodeOK if the parent handle matches the store id, or another MTP response code if not
+*/
+TMTPResponseCode CMTPSvcCompoundProcessor::CheckStoreAndParent()
+	{
+	__FLOG(_L8("CheckStoreAndParent - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+	iParentHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+	
+	// If the first parameter is unused, it should be set to 0x00000000, and the responder should decide
+	// in which store to place the object
+	if (iStorageId == KMTPStorageDefault)
+		{
+		// If the second parameter is used, the first parameter must also be used.
+		// If the second parameter is unused, it should be set to 0x00000000
+		if (iParentHandle != KMTPHandleNone)
+			{
+			responseCode = EMTPRespCodeInvalidParentObject;
+			}
+		else
+			{
+			// Set storage id as service dp's logical storage id.
+			iStorageId = iDataProvider.StorageId();
+			}
+		}
+	else
+		{
+		// Check logical storage id.
+		if (iStorageId != iDataProvider.StorageId())
+			{
+			responseCode = EMTPRespCodeInvalidStorageID;
+			}
+		}
+	
+	__FLOG_VA((_L8("CheckStoreAndParent - Exit with code: 0x%x"), responseCode));
+	return responseCode;
+	}
+
+/**
+SendObjectInfo/SendObjectPropList/UpdateObjectPropList/SendObject request handler
+To maintain the state information between the two requests, the two requests are 
+combined together in one request processor.
+*/
+void CMTPSvcCompoundProcessor::ServiceL()
+	{
+	__FLOG(_L8("ServiceL - Entry"));
+	switch (iState)
+		{
+		case EIdle:
+			ServiceObjectPropertiesL();
+			break;
+		case EObjectInfoSucceed:
+			ServiceSendObjectL();
+			break;
+		default:
+			__FLOG(_L8("Wrong state in ServiceL"));
+			break;
+		}
+	__FLOG(_L8("ServiceL - Exit"));
+	}
+
+void CMTPSvcCompoundProcessor::ServiceObjectPropertiesL()
+	{
+	__FLOG(_L8("ServiceObjectPropertiesL - Entry"));
+	switch (iOperationCode)
+		{
+		case EMTPOpCodeSendObjectInfo:
+			ServiceSendObjectInfoL();
+			break;
+		
+		case EMTPOpCodeSendObjectPropList:
+		case EMTPOpCodeUpdateObjectPropList:
+			ServiceSendObjectPropListL();
+			break;
+		default:
+			break;
+		}
+	__FLOG(_L8("ServiceObjectPropertiesL - Exit"));
+	}
+
+/**
+SendObject request handler
+*/
+void CMTPSvcCompoundProcessor::ServiceSendObjectL()
+	{
+	__FLOG(_L8("ServiceSendObjectL - Entry"));
+	MMTPSvcObjectHandler* pHandler = iDataProvider.ObjectHandler(iFormatCode);
+	if (pHandler)
+		{
+		pHandler->GetBufferForSendObjectL(*iReceivedObjectMetaData, &iObjectContent);
+		}
+	else
+		{
+		User::Leave(KErrGeneral);
+		}
+	ReceiveDataL(*iObjectContent);
+	iState = EObjectSendProcessing;
+	__FLOG(_L8("ServiceSendObjectL - Exit"));
+	}
+
+/**
+SendObjectInfo request handler
+*/
+void CMTPSvcCompoundProcessor::ServiceSendObjectInfoL()
+	{
+	__FLOG(_L8("ServiceSendObjectInfoL - Entry"));
+	delete iObjectInfo;
+	iObjectInfo = NULL;
+	iObjectInfo = CMTPTypeObjectInfo::NewL();
+	ReceiveDataL(*iObjectInfo);
+	iState = EObjectInfoProcessing;
+	__FLOG(_L8("ServiceSendObjectInfoL - Exit"));
+	}
+
+/**
+SendObjectPropList request handler
+*/
+void CMTPSvcCompoundProcessor::ServiceSendObjectPropListL()
+	{
+	__FLOG(_L8("ServiceSendObjectPropListL - Entry"));
+	delete iObjectPropList;
+	iObjectPropList = NULL;
+	iObjectPropList = CMTPTypeObjectPropList::NewL();
+	ReceiveDataL(*iObjectPropList);
+	iState = EObjectInfoProcessing;
+	__FLOG(_L8("ServiceSendObjectPropListL - Exit"));
+	}
+
+/**
+Override to handle the response phase of SendObjectInfo/SendObjectPropList and SendObject requests
+@return EFalse
+*/
+TBool CMTPSvcCompoundProcessor::DoHandleResponsePhaseL()
+	{
+	__FLOG(_L8("DoHandleResponsePhaseL - Entry"));
+	TBool successful = !iCancelled;
+	switch (iState)
+		{
+		case EObjectInfoProcessing:
+			{
+			if (iOperationCode == EMTPOpCodeSendObjectInfo)
+				{
+				successful = DoHandleResponseSendObjectInfoL();
+				}
+			else if (iOperationCode == EMTPOpCodeSendObjectPropList)
+				{
+				successful = DoHandleResponseSendObjectPropListL();
+				}
+			else if (iOperationCode == EMTPOpCodeUpdateObjectPropList)
+				{
+				successful = DoHandleResponseUpdateObjectPropListL();
+				}
+			iState = (successful ? EObjectInfoSucceed : EIdle);
+			break;
+			}
+		case EObjectSendProcessing:
+			{
+			successful = DoHandleResponseSendObjectL();
+			iState = (successful ? EObjectSendSucceed : EObjectSendFail);
+			break;
+			}
+		default:
+			// Wrong State value.
+			__FLOG_VA((_L8("DoHandleResponsePhaseL enter an abnormal state %d"), iState));
+			break;
+		}
+	__FLOG(_L8("DoHandleResponsePhaseL - Exit"));
+	return EFalse;
+	}
+
+/**
+Override to handle the completing phase of SendObjectInfo/SendObjectPropList and SendObject requests
+@return ETrue if succesfully received the object content, otherwise EFalse
+*/
+TBool CMTPSvcCompoundProcessor::DoHandleCompletingPhaseL()
+	{
+	__FLOG(_L8("DoHandleCompletingPhaseL - Entry"));
+	TBool result = ETrue;
+	CMTPRequestProcessor::DoHandleCompletingPhaseL();
+	
+	__FLOG_VA((_L8("DoHandleCompletingPhaseL - Progress State: %u"), iState));
+	switch (iState)
+		{
+		case EObjectInfoSucceed:
+			{
+			// Two cases will come here:
+			// 1. SendObjInfo OK, Store ID for next SendObject checking;
+			// 2. SendObject check request fail, such as wrong transaction id or wrong session id.
+			//    needn't change transaction id.
+			if (iOperationCode == EMTPOpCodeSendObjectInfo || 
+				iOperationCode == EMTPOpCodeUpdateObjectPropList ||
+				iOperationCode == EMTPOpCodeSendObjectPropList)
+				{
+				// Reset transaction id for new SendObjInfo request, but ignore wrong SendObject.
+				iLastTransactionID = iTransactionCode;
+				iLastSessionID = iSessionId;
+				iLastInfoOperationCode = iOperationCode;
+				}
+			result = EFalse;
+			__FLOG_VA((_L8("EObjectInfoSucceed: Save send info transaction id: %u, operation: 0x%x"), iLastTransactionID, iOperationCode));
+			break;
+			}
+		case EObjectSendFail:
+			{
+			// When process SendObject fail, such as received size is wrong.
+			iLastTransactionID++;
+			iState = EObjectInfoSucceed;
+			result = EFalse;
+			break;
+			}
+		default:
+			// The other cases will delete the processor:
+			// 1. SendObject OK
+			// 2. Framework error and call complete with error state.
+			// 3. SendObjInfo fail
+			// 4. First request is orphan SendObject, state is Idle
+			break;
+		}
+	__FLOG(_L8("DoHandleCompletingPhaseL - Exit"));
+	return result;
+	}
+
+/**
+Handling the completing phase of SendObjectInfo request
+@return ETrue if the specified object can be saved on the specified location, otherwise, EFalse
+*/
+TBool CMTPSvcCompoundProcessor::DoHandleResponseSendObjectInfoL()
+	{
+	__FLOG(_L8("DoHandleResponseSendObjectInfoL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	TBool result(ETrue);
+	iFormatCode = iObjectInfo->Uint16L(CMTPTypeObjectInfo::EObjectFormat);
+	// Check format code and set object handler
+	responseCode = CheckFmtAndSetHandler(iFormatCode);
+	if (responseCode != EMTPRespCodeOK)
+		{
+		SendResponseL(responseCode);
+		}
+	else
+		{
+		iReceivedObjectMetaData->SetUint(CMTPObjectMetaData::EFormatCode, iFormatCode);
+		iObjectSize = iObjectInfo->Uint32L(CMTPTypeObjectInfo::EObjectCompressedSize);
+		
+		TBuf<KMaxSUIDLength> suid;
+		// Object mgr process dataset and create a temp object.
+		responseCode = iObjectHandler->SendObjectInfoL(*iObjectInfo, iParentHandle, suid);
+		if (responseCode != EMTPRespCodeOK)
+			{
+			SendResponseL(responseCode);
+			}
+		else
+			{
+			//if object size is zero, then directly store object without waiting for sendobject operation.
+			if (iObjectSize == 0)
+				{
+				__FLOG(_L8("CommitReservedObject because object size is 0 and register for SendObject"));
+				// Commit new temp object to object mgr, if leave, CleanupStack will rollback new temp object. 
+				TCleanupItem rollBackTempObject(RollBackObject, this);
+				CleanupStack::PushL(rollBackTempObject);
+				// Commit prop to obj mgr
+				iObjectHandler->CommitForNewObjectL(suid);
+				CleanupStack::Pop(this);
+	
+				// Prepare to store the created object to framework
+				iIsRollBackHandlerObject = ETrue;
+				TCleanupItem rollBackTempObjectAndSuid(RollBackObject, this);
+				CleanupStack::PushL(rollBackTempObjectAndSuid);
+				// Set the created suid to meta
+				iReceivedObjectMetaData->SetDesCL(CMTPObjectMetaData::ESuid, suid);
+				// An object handle issued during a successful SendObjectInfo or SendObjectPropList operation should 
+				// be reserved for the duration of the MTP session
+				ReserveObjectL();
+				// Commit the created object to framework, if leave, then framework will return General Error
+				// CleanupStack will rollback the new created object via delete object operation.
+				iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObjectMetaData);
+				CleanupStack::Pop(this);
+				iIsRollBackHandlerObject = EFalse;
+				iIsCommited = ETrue;
+				RegisterRequestAndSendResponseL(responseCode);
+				}
+			else
+				{
+				// An object handle issued during a successful SendObjectInfo or SendObjectPropList operation should 
+				// be reserved for the duration of the MTP session
+				ReserveObjectL();
+				RegisterRequestAndSendResponseL(responseCode);
+				}
+			}
+		}
+	result = (responseCode == EMTPRespCodeOK) ? ETrue : EFalse;
+	__FLOG_VA((_L8("DoHandleResponseSendObjectInfoL exit with code: 0x%x"), responseCode));
+	return result;
+	}
+
+/**
+Handling the completing phase of SendObjectPropList request
+@return ETrue if the specified object can be saved on the specified location, otherwise, EFalse
+*/
+TBool CMTPSvcCompoundProcessor::DoHandleResponseSendObjectPropListL()
+	{
+	__FLOG(_L8("DoHandleResponseSendObjectPropListL - Entry"));
+	TBool result = ETrue;
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	
+	TBuf<KMaxSUIDLength> suid;
+	TUint32 parameter = 0;
+	responseCode = SendObjectPropListL(*iObjectPropList, iParentHandle, parameter, suid, iObjectSize);
+	if (responseCode != EMTPRespCodeOK)
+		{
+		SendResponseL(responseCode, 4, &parameter);
+		}
+	else
+		{
+		//if object size is zero, then directly store object without waiting for sendobject operation.
+		if (iObjectSize == 0)
+			{
+			__FLOG(_L8("CommitReservedObject because object size is 0 and register for SendObject"));
+			// Commit new temp object to object mgr, if leave, CleanupStack will rollback new temp object. 
+			TCleanupItem rollBackTempObject(RollBackObject, this);
+			CleanupStack::PushL(rollBackTempObject);
+			// Commit prop to obj mgr
+			iObjectHandler->CommitForNewObjectL(suid);
+			CleanupStack::Pop(this);
+
+			// Prepare to store the created object to framework
+			iIsRollBackHandlerObject = ETrue;
+			TCleanupItem rollBackTempObjectAndSuid(RollBackObject, this);
+			CleanupStack::PushL(rollBackTempObjectAndSuid);
+			// Set the created suid to meta
+			iReceivedObjectMetaData->SetDesCL(CMTPObjectMetaData::ESuid, suid);
+			// An object handle issued during a successful SendObjectInfo or SendObjectPropList operation should 
+			// be reserved for the duration of the MTP session
+			ReserveObjectL();
+			// Commit the created object to framework, if leave, then framework will return General Error
+			// CleanupStack will rollback the new created object via delete object operation.
+			iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObjectMetaData);
+			CleanupStack::Pop(this);
+			iIsRollBackHandlerObject = EFalse;
+			iIsCommited = ETrue;
+			RegisterRequestAndSendResponseL(responseCode);
+			}
+		else
+			{
+			// An object handle issued during a successful SendObjectInfo or SendObjectPropList operation should 
+			// be reserved for the duration of the MTP session
+			ReserveObjectL();
+			RegisterRequestAndSendResponseL(responseCode);
+			}
+		}
+
+	result = (responseCode == EMTPRespCodeOK) ? ETrue : EFalse;
+	__FLOG_VA((_L8("DoHandleResponseSendObjectPropListL exit with code = 0x%x"), responseCode));
+	return result;
+	}
+
+/**
+Handling the completing phase of UpdateObjectPropList request
+@return ETrue if the specified object can be saved on the specified location, otherwise, EFalse
+*/
+TBool CMTPSvcCompoundProcessor::DoHandleResponseUpdateObjectPropListL()
+	{
+	__FLOG(_L8("DoHandleResponseUpdateObjectPropListL - Entry"));
+	TBool result = ETrue;
+	TUint32 parameter = 0;
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	// Check object size property with format
+	responseCode = ExtractObjectSizeL();
+	if (responseCode == EMTPRespCodeOK)
+		{
+		responseCode = UpdateObjectPropListL(*iReceivedObjectMetaData, *iObjectPropList, parameter);
+		}
+
+	if (responseCode == EMTPRespCodeOK)
+		{
+		if (iObjectSize == 0)
+			{
+			// If commit leave, roll back the temp object.
+			TCleanupItem rollBackTempObject(RollBackObject, this);
+			CleanupStack::PushL(rollBackTempObject);
+			// Commit prop to obj mgr
+			iObjectHandler->CommitL();
+			CleanupStack::Pop(this);
+			// Commit to obj mgr is ok
+			iIsCommited = ETrue;
+			// Update operation needn't change framework property so far.
+			iExpectedSendObjectRequest.SetUint32(TMTPTypeRequest::ERequestSessionID, iSessionId);
+			iFramework.RouteRequestRegisterL(iExpectedSendObjectRequest, iConnection);
+			}
+		else
+			{
+			iExpectedSendObjectRequest.SetUint32(TMTPTypeRequest::ERequestSessionID, iSessionId);
+			iFramework.RouteRequestRegisterL(iExpectedSendObjectRequest, iConnection);
+			}
+		}
+	SendResponseL(responseCode, 1, &parameter);
+	result = (responseCode == EMTPRespCodeOK) ? ETrue: EFalse;
+	__FLOG_VA((_L8("DoHandleResponseUpdateObjectPropListL exit with code: 0x%x"), responseCode));
+	return result;
+	}
+
+/**
+Handling the completing phase of SendObject request
+@return ETrue if the object has been successfully saved on the device, otherwise, EFalse
+*/
+TBool CMTPSvcCompoundProcessor::DoHandleResponseSendObjectL()
+	{
+	__FLOG(_L8("DoHandleResponseSendObjectL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	TBool result = ETrue;
+
+	if (iCancelled)
+		{
+		iObjectHandler->RollBack();
+		responseCode = EMTPRespCodeTransactionCancelled;
+		}
+	else if (iObjectSize != 0)
+		{
+		// For 0 sized object, ignore the object content verify
+		TUint64 receiveSize = iObjectContent->Size();
+		if (iObjectSize < receiveSize)
+			{
+			// If the object sent in the data phase of this operation is larger than 
+			// the size indicated in the ObjectInfo dataset sent in the SendObjectInfo 
+			// which precedes this operation, this operation should fail and a response 
+			// code of Store_Full should be returned.
+			responseCode = EMTPRespCodeStoreFull;
+			}
+		else if (iObjectSize > receiveSize)
+			{
+			responseCode = EMTPRespCodeIncompleteTransfer;
+			}
+		// If size is ok, then just need commit the object to data store.
+		}
+	
+	// Commit or Unreserver from framework if object size is not 0.
+	if (responseCode == EMTPRespCodeOK && iObjectSize != 0)
+		{
+		// For create new object, need commit the reserved handle to framework, but update needn't do that
+		if (iLastInfoOperationCode != EMTPOpCodeUpdateObjectPropList)
+			{
+			TBuf<KMaxSUIDLength> suid;
+			// Commit new temp object to object mgr, if leave, CleanupStack will rollback new temp object. 
+			TCleanupItem rollBackTempObject(RollBackObject, this);
+			CleanupStack::PushL(rollBackTempObject);
+			// Commit prop to obj mgr
+			iObjectHandler->CommitForNewObjectL(suid);
+			CleanupStack::Pop(this);
+
+			// Prepare to store the created object to framework
+			iIsRollBackHandlerObject = ETrue;
+			TCleanupItem rollBackTempObjectAndSuid(RollBackObject, this);
+			CleanupStack::PushL(rollBackTempObjectAndSuid);
+			// Set the created suid to meta
+			iReceivedObjectMetaData->SetDesCL(CMTPObjectMetaData::ESuid, suid);
+			// Commit the created object to framework, if leave, then framework will return General Error
+			// CleanupStack will rollback the new created object via delete object operation.
+			iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObjectMetaData);
+			CleanupStack::Pop(this);
+			iIsRollBackHandlerObject = EFalse;
+			iIsCommited = ETrue;
+			}
+		else
+			{
+			// If commit leave, roll back the temp object.
+			TCleanupItem rollBackNewObject(RollBackObject, this);
+			CleanupStack::PushL(rollBackNewObject);
+			// Commit prop to obj mgr
+			iObjectHandler->CommitL();
+			CleanupStack::Pop(this);
+			// Commit to obj mgr is ok
+			iIsCommited = ETrue;
+			}
+		}
+
+	SendResponseL(responseCode);
+	// Release the processor when SendObject or Transaction Canceled and unregister SendObject.
+	result = (responseCode == EMTPRespCodeOK || responseCode == EMTPRespCodeTransactionCancelled) ? ETrue : EFalse;
+	if (result)
+		{
+		iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
+		}
+	__FLOG_VA((_L8("DoHandleResponseSendObjectL exit with code = 0x%x"), responseCode));
+	return result;
+	}
+
+TMTPResponseCode CMTPSvcCompoundProcessor::ExtractObjectSizeL()
+	{
+	__FLOG(_L8("ExtractObjectSizeL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	TBool foundSizeProp  = EFalse;
+	const TUint KCount(iObjectPropList->NumberOfElements());
+	iObjectPropList->ResetCursor();
+	for (TUint i = 0; i < KCount; i++)
+		{
+		const CMTPTypeObjectPropListElement& KElement = iObjectPropList->GetNextElementL();
+		if (EMTPObjectPropCodeObjectSize == KElement.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode))
+			{
+			iObjectSize = KElement.Uint64L(CMTPTypeObjectPropListElement::EValue);
+			foundSizeProp = ETrue;
+			break;
+			}
+		}
+	
+	if (!foundSizeProp)
+		{
+		// Object size in data set is not available, get the corresponding object's current size property.
+		const TDesC& suid = iReceivedObjectMetaData->DesC(CMTPObjectMetaData::ESuid);
+		responseCode = iObjectHandler->GetObjectSizeL(suid, iObjectSize);
+		if (iObjectSize == KObjectSizeNotAvaiable)
+			{
+			responseCode = EMTPRespCodeGeneralError;
+			}
+		}
+
+	__FLOG(_L8("ExtractObjectSizeL - Exit"));
+	return responseCode;
+	}
+
+/**
+Reserves space for and assigns an object handle to the received object, then
+sends a success response.
+*/
+void CMTPSvcCompoundProcessor::ReserveObjectL()
+	{
+	__FLOG(_L8("ReserveObjectL - Entry"));
+	iReceivedObjectMetaData->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
+	iReceivedObjectMetaData->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle);
+	iReceivedObjectMetaData->SetUint(CMTPObjectMetaData::EFormatCode, iFormatCode);
+	iFramework.ObjectMgr().ReserveObjectHandleL(*iReceivedObjectMetaData, iObjectSize);
+	__FLOG_VA((_L8("ReserveObjectL Exit Storage:%u, ParentHandle:%u, FormatCode:%u, Size:%u "), iStorageId, iParentHandle, iFormatCode, iObjectSize));
+	}
+
+void CMTPSvcCompoundProcessor::RegisterRequestAndSendResponseL(TMTPResponseCode aResponseCode)
+	{
+	__FLOG(_L8("RegisterRequestAndSendResponseL - Entry"));
+	// Register to framework for handle the next sendobj request
+	iExpectedSendObjectRequest.SetUint32(TMTPTypeRequest::ERequestSessionID, iSessionId);
+	iFramework.RouteRequestRegisterL(iExpectedSendObjectRequest, iConnection);
+	TUint32 parameters[3];
+	parameters[0] = iStorageId;
+	parameters[1] = iParentHandle;
+	// Responder’s reserved ObjectHandle for the incoming object
+	parameters[2] = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EHandle);
+	SendResponseL(aResponseCode, 3, parameters);
+	__FLOG(_L8("RegisterRequestAndSendResponseL - Exit"));
+	}
+
+void CMTPSvcCompoundProcessor::RollBackObject(TAny* aObject)
+	{
+	reinterpret_cast<CMTPSvcCompoundProcessor*>(aObject)->RollBack();
+	}
+
+void CMTPSvcCompoundProcessor::RollBack()
+	{
+	iObjectHandler->RollBack();
+	if (iIsRollBackHandlerObject)
+		{
+		TRAP_IGNORE(iObjectHandler->DeleteObjectL(*iReceivedObjectMetaData));
+		iIsRollBackHandlerObject = EFalse;
+		}
+	}
+
+TMTPResponseCode CMTPSvcCompoundProcessor::CheckFmtAndSetHandler(TUint32 aFormatCode)
+	{
+	__FLOG(_L8("CheckFmtAndSetHandler - Entry")); 
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	iObjectHandler = iDataProvider.ObjectHandler(aFormatCode);
+	if (!iObjectHandler)
+		{
+		responseCode = EMTPRespCodeInvalidObjectFormatCode;
+		}
+	__FLOG(_L8("CheckFmtAndSetHandler - Exit"));
+	return responseCode;
+	}
+
+TMTPResponseCode CMTPSvcCompoundProcessor::SendObjectPropListL(const CMTPTypeObjectPropList& aObjectPropList, TUint32& aParentHandle, 
+														TUint32& aParameter, TDes& aSuid, TUint64 aObjectSize)
+	{
+	__FLOG(_L8("SendObjectPropListL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	aParameter = 0;
+
+	responseCode = iObjectHandler->SendObjectPropListL(aObjectSize, aObjectPropList, aParentHandle, aSuid);
+	// If handler cache an entry in SendObjectPropList, then it should never return error code. Processor will 
+	// not rollback in this case
+	if (EMTPRespCodeOK == responseCode)
+		{
+		// Parse elements and set property for the object.
+		const TUint count(aObjectPropList.NumberOfElements());
+		aObjectPropList.ResetCursor();
+		for (TUint i = 0; i < count && responseCode == EMTPRespCodeOK; i++)
+			{
+			CMTPTypeObjectPropListElement& element = aObjectPropList.GetNextElementL();
+			TUint32 handle = element.Uint32L(CMTPTypeObjectPropListElement::EObjectHandle);
+			// All ObjectHandle fields must contain the value 0x00000000, and all properties that are defined in 
+			// this operation will be applied to the object, need check every handle value and keep all properties is atomic.
+			if (handle != KMTPHandleNone)
+				{
+				responseCode = EMTPRespCodeInvalidDataset;
+				aParameter = i;
+				break;
+				}
+			else
+				{
+				// Create a new object, don't commit, it will be done in processor.
+				responseCode = iObjectHandler->SetObjectPropertyL(aSuid, element, EMTPOpCodeSendObjectPropList);
+				}
+			if (responseCode != EMTPRespCodeOK)
+				{
+				aParameter = i;
+				break;
+				}
+			}
+		// Roll back the temp object
+		if (EMTPRespCodeOK != responseCode)
+			{
+			iObjectHandler->RollBack();
+			}
+		}
+	__FLOG_VA((_L8("SendObjectPropListL - Exit with responseCode = 0x%04X"), responseCode));
+	return responseCode;
+	}
+
+// All object handlers current don't support partial update, so once update one parameter failed,
+// all updated will be reverted.
+TMTPResponseCode CMTPSvcCompoundProcessor::UpdateObjectPropListL(CMTPObjectMetaData& aObjectMetaData, 
+														const CMTPTypeObjectPropList& aObjectPropList, 
+														TUint32& /*aParameter*/)
+	{
+	__FLOG(_L8("UpdateObjectPropList - Entry")); 
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	const TUint count = aObjectPropList.NumberOfElements();
+	aObjectPropList.ResetCursor();
+	for (TUint i = 0; i < count; i++)
+		{
+		CMTPTypeObjectPropListElement& element = aObjectPropList.GetNextElementL();
+		TUint32 handle = element.Uint32L(CMTPTypeObjectPropListElement::EObjectHandle);
+		// All object handle in dataset must contain either 0x00000000 or match with the parameter 1
+		if (handle != aObjectMetaData.Uint(CMTPObjectMetaData::EHandle) && handle != KMTPHandleNone)
+			{
+			responseCode = EMTPRespCodeInvalidObjectHandle;
+			}
+		else
+			{
+			const TDesC& suid = aObjectMetaData.DesC(CMTPObjectMetaData::ESuid);
+			// Update will be treated as adding a new object for RO object property.
+			responseCode = iObjectHandler->SetObjectPropertyL(suid, element, EMTPOpCodeUpdateObjectPropList);
+			}
+		if(EMTPRespCodeOK != responseCode)
+			{
+			iObjectHandler->RollBack();
+			break;
+			}
+		}
+	__FLOG_VA((_L8("UpdateObjectPropListL - Exit with responseCode = 0x%04X"), responseCode));
+	return responseCode;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcdeleteobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,267 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcdeleteobject.cpp
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpobjectmgr.h>
+
+#include "cmtpsvcdeleteobject.h"
+#include "mtpdpconst.h"
+#include "mmtpservicedataprovider.h"
+#include "mmtpsvcobjecthandler.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"SvcDeleteObject");)
+
+EXPORT_C MMTPRequestProcessor* CMTPSvcDeleteObject::NewL(MMTPDataProviderFramework& aFramework, 
+												MMTPConnection& aConnection, 
+												MMTPServiceDataProvider& aDataProvider)
+	{
+	CMTPSvcDeleteObject* self = new (ELeave) CMTPSvcDeleteObject(aFramework, aConnection, aDataProvider);
+	return self;
+	}
+
+EXPORT_C CMTPSvcDeleteObject::~CMTPSvcDeleteObject()
+	{
+	__FLOG(_L8("~CMTPSvcDeleteObject - Entry"));
+	iObjectHandles.Close();
+	delete iReceivedObjectMetaData;
+	__FLOG(_L8("~CMTPSvcDeleteObject - Exit"));
+	__FLOG_CLOSE;
+	}
+
+CMTPSvcDeleteObject::CMTPSvcDeleteObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider) :
+	CMTPRequestProcessor(aFramework, aConnection, 0, NULL), iDataProvider(aDataProvider), iDeleteError(KErrNone)
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("CMTPSvcDeleteObject - Constructed"));
+	}
+
+/**
+DeleteObject request handler
+*/
+void CMTPSvcDeleteObject::LoadAllObjHandlesL(TUint32 aParentHandle)
+	{
+	__FLOG(_L8("LoadAllObjHandlesL - Entry"));
+	const TUint32 KFormatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+	RMTPObjectMgrQueryContext context;
+	CleanupClosePushL(context);
+
+	do
+		{ // Append all object handles with service dp's storage id.
+		TUint32 storageId = iDataProvider.StorageId();
+		TMTPObjectMgrQueryParams  params(storageId, KFormatCode, aParentHandle);
+		iFramework.ObjectMgr().GetObjectHandlesL(params, context, iObjectHandles);
+		}
+	while (!context.QueryComplete());
+	CleanupStack::PopAndDestroy(&context);
+	__FLOG(_L8("LoadAllObjHandlesL - Exit"));
+	}
+
+void CMTPSvcDeleteObject::ServiceL()
+	{
+	__FLOG(_L8("ServiceL - Entry"));
+	if (iFormatCode == EMTPFormatCodeAssociation)
+		{
+		// Framework may send deleteobject for a directory, allow framework do this.
+		SendResponseL(EMTPRespCodeOK);
+		return;
+		}
+	
+	const TUint32 KHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+	
+	if (KHandle == KMTPHandleAll)
+		{
+		LoadAllObjHandlesL(KMTPHandleNoParent);
+		iDeleteIndex = 0;
+		iSuccessDeletion = EFalse;
+		CompleteSelf(KErrNone);
+		}
+	else
+		{
+		TMTPResponseCode responseCode = iObjectHandler->DeleteObjectL(*iReceivedObjectMetaData);
+		// Remove from framework.
+		iFramework.ObjectMgr().RemoveObjectL(iReceivedObjectMetaData->DesC(CMTPObjectMetaData::ESuid));
+		SendResponseL(responseCode);
+		__FLOG_VA((_L8("Delete single object exit with response code = 0x%04X"), responseCode));
+		}
+	__FLOG(_L8("ServiceL - Exit"));
+	}
+
+void CMTPSvcDeleteObject::RunL()
+	{
+	__FLOG(_L8("RunL - Entry"));
+	__FLOG_VA((_L8("the number of objects to be deleted is %d, iDeleteIndex is %d"), iObjectHandles.Count(), iDeleteIndex));
+
+	if (iStatus != KErrNone)
+		{
+		iDeleteError = iStatus.Int();
+		}
+
+	CDesCArray* objectDeleted = new (ELeave) CDesCArrayFlat(KMTPDriveGranularity);
+	CleanupStack::PushL(objectDeleted);
+	
+	TInt errCount = 0;
+	TInt count = iObjectHandles.Count();
+	const TUint32 granularity = iDataProvider.OperationGranularity();
+	for (TInt i = 0; iDeleteIndex < count && i < granularity; ++i)
+		{
+		TUint handle = iObjectHandles[iDeleteIndex++];
+		iFramework.ObjectMgr().ObjectL(handle, *iReceivedObjectMetaData);
+		if (DeleteObjectL(*iReceivedObjectMetaData) == EMTPRespCodeOK)
+			{
+			objectDeleted->AppendL(iReceivedObjectMetaData->DesC(CMTPObjectMetaData::ESuid));
+			iSuccessDeletion = ETrue;
+			}
+		else
+			{
+			++errCount;
+			__FLOG_VA((_L8("Delete object failed, SUID:%S"), &(iReceivedObjectMetaData->DesC(CMTPObjectMetaData::ESuid))));
+			}
+		}
+
+	// Remove object from framework
+	iFramework.ObjectMgr().RemoveObjectsL(*objectDeleted);
+	CleanupStack::PopAndDestroy(objectDeleted);
+
+	if (iDeleteIndex >= count)
+		{
+		ProcessFinalPhaseL();
+		}
+	else 
+		{
+		TInt err = (errCount > 0) ? KErrGeneral : KErrNone;
+		CompleteSelf(err);
+		}
+	__FLOG(_L8("RunL - Exit")); 
+	}
+
+/**
+Handle an error in the delete loop by storing the error code and continuing deleting.
+*/
+TInt CMTPSvcDeleteObject::RunError(TInt aError)
+	{
+	__FLOG(_L8("RunError - Entry")); 
+	CompleteSelf(aError);
+	__FLOG(_L8("RunError - Exit"));
+	return KErrNone;
+	}
+
+/**
+Complete myself
+*/
+void CMTPSvcDeleteObject::CompleteSelf(TInt aError)
+	{
+	__FLOG(_L8("CompleteSelf - Entry"));
+	SetActive();
+	TRequestStatus* status = &iStatus;
+	*status = KRequestPending;
+	User::RequestComplete(status, aError);
+	__FLOG(_L8("CompleteSelf - Exit"));
+	}
+
+TMTPResponseCode CMTPSvcDeleteObject::CheckRequestL()
+	{
+	__FLOG(_L8("CheckRequestL - Entry"));
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	if (EMTPRespCodeOK == responseCode)
+		{
+		TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+		iReceivedObjectMetaData = CMTPObjectMetaData::NewL();
+		// Check object handle with dataprovider id, if handle is valid, then ignore format code in parameter 2.
+		if (objectHandle != KMTPHandleAll)
+			{
+			MMTPObjectMgr& objects = iFramework.ObjectMgr();
+			//Check whether object handle is valid
+			// Framework may send a handle which is a directory and dp can't check id in this case
+			if (objects.ObjectL(objectHandle, *iReceivedObjectMetaData))
+				{
+				iFormatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode);
+				if (iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EDataProviderId) != iFramework.DataProviderId() && (iFormatCode != EMTPFormatCodeAssociation))
+					{
+					responseCode = EMTPRespCodeInvalidObjectHandle;
+					__FLOG(_L8("DataProviderId dismatch"));
+					}
+				else
+					{
+					responseCode = CheckFmtAndSetHandler(iFormatCode);
+					}
+				}
+			else
+				{
+				responseCode = EMTPRespCodeInvalidObjectHandle;
+				}
+			}
+		else
+			{
+			// Delete all objects for a format
+			iFormatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+			// Check format code
+			if (iFormatCode != KMTPFormatsAll)
+				{
+				responseCode = CheckFmtAndSetHandler(iFormatCode);
+				}
+			}
+		}
+
+	__FLOG_VA((_L8("CheckRequestL Exit with response code = 0x%04X"), responseCode));
+	return responseCode;
+	}
+
+void CMTPSvcDeleteObject::ProcessFinalPhaseL()
+	{
+	__FLOG(_L8("ProcessFinalPhaseL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	if (iDeleteError != KErrNone)
+		{
+		if (iSuccessDeletion)
+			{
+			responseCode = EMTPRespCodePartialDeletion;
+			}
+		else
+			{
+			responseCode = EMTPRespCodeStoreReadOnly;
+			}
+		}
+	SendResponseL(responseCode);
+	__FLOG_VA((_L8("ProcessFinalPhaseL - Exit with response code = 0x%04X"), responseCode));
+	}
+
+TMTPResponseCode CMTPSvcDeleteObject::CheckFmtAndSetHandler(TUint32 aFormatCode)
+	{
+	__FLOG(_L8("CheckFmtAndSetHandler - Entry")); 
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	iObjectHandler = iDataProvider.ObjectHandler(aFormatCode);
+	if (!iObjectHandler)
+		{
+		responseCode = EMTPRespCodeInvalidObjectFormatCode;
+		}
+	__FLOG(_L8("CheckFmtAndSetHandler - Exit"));
+	return responseCode;
+	}
+
+TMTPResponseCode CMTPSvcDeleteObject::DeleteObjectL(const CMTPObjectMetaData& aObjectMetaData)
+	{
+	__FLOG(_L8("DeleteObjectL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	TUint16 formatCode = aObjectMetaData.Uint(CMTPObjectMetaData::EFormatCode);
+	responseCode = CheckFmtAndSetHandler(formatCode);
+	if (EMTPRespCodeOK == responseCode)
+		{
+		responseCode = iObjectHandler->DeleteObjectL(aObjectMetaData);
+		}
+	__FLOG(_L8("DeleteObjectL - Exit"));
+	return responseCode;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcdeleteobjectproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,270 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcdeleteobjectproplist.cpp
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypedeleteobjectproplist.h>
+#include <mtp/tmtptypedatapair.h>
+
+#include "cmtpsvcdeleteobjectproplist.h"
+#include "mmtpservicedataprovider.h"
+#include "mmtpsvcobjecthandler.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"SvcDelObjPropList");)
+
+EXPORT_C MMTPRequestProcessor* CMTPSvcDeleteObjectPropList::NewL(MMTPDataProviderFramework& aFramework, 
+													MMTPConnection& aConnection, 
+													MMTPServiceDataProvider& aDataProvider)
+	{
+	CMTPSvcDeleteObjectPropList* self = new (ELeave) CMTPSvcDeleteObjectPropList(aFramework, aConnection, aDataProvider);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CMTPSvcDeleteObjectPropList::~CMTPSvcDeleteObjectPropList()
+	{
+	__FLOG(_L8("~CMTPSvcDeleteObjectPropList - Entry"));
+	delete iPropertyList;
+	delete iReceivedObjectMetaData;
+	__FLOG(_L8("~CMTPSvcDeleteObjectPropList - Exit"));
+	__FLOG_CLOSE;
+	}
+
+CMTPSvcDeleteObjectPropList::CMTPSvcDeleteObjectPropList(MMTPDataProviderFramework& aFramework, 
+												MMTPConnection& aConnection, 
+												MMTPServiceDataProvider& aDataProvider) :
+	CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
+	iDataProvider(aDataProvider)
+	{
+	}
+
+void CMTPSvcDeleteObjectPropList::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry"));
+	iPropertyList = CMTPTypeDeleteObjectPropList::NewL();
+	__FLOG(_L8("ConstructL - Exit"));
+	}
+
+TMTPResponseCode CMTPSvcDeleteObjectPropList::CheckRequestL()
+	{
+	__FLOG(_L8("CheckRequestL - Entry"));
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	if (EMTPRespCodeOK == responseCode)
+		{
+		TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+		iReceivedObjectMetaData = CMTPObjectMetaData::NewL();
+		// Check object handle
+		if (objectHandle != KMTPHandleAll)
+			{
+			MMTPObjectMgr& objMgr(iFramework.ObjectMgr());
+			// Check whether object handle is valid
+			if (objMgr.ObjectL(objectHandle, *iReceivedObjectMetaData))
+				{
+				// Check whether the owner of this object is correct service data provider
+				if (iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EDataProviderId) != iFramework.DataProviderId())
+					{
+					responseCode = EMTPRespCodeInvalidObjectHandle;
+					__FLOG(_L8("CheckRequestL - DataProviderId dismatch"));
+					}
+				else
+					{
+					// Check format code
+					TUint16 formatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode);
+					if (!iDataProvider.ObjectHandler(formatCode))
+						{
+						responseCode = EMTPRespCodeInvalidObjectHandle;
+						}
+					}
+				}
+			else
+				{
+				responseCode = EMTPRespCodeInvalidObjectHandle;
+				}
+			}
+		else
+			{
+			iReceivedObjectMetaData->SetUint(CMTPObjectMetaData::EHandle, KMTPHandleAll);
+			}
+		}
+	__FLOG_VA((_L8("CheckRequestL - Exit with responseCode = 0x%04X"), responseCode));
+	return responseCode;
+	}
+
+void CMTPSvcDeleteObjectPropList::ServiceL()
+	{
+	__FLOG(_L8("ServiceL - Entry"));
+	ReceiveDataL(*iPropertyList);
+	__FLOG(_L8("ServiceL - Exit"));
+	}
+
+TBool CMTPSvcDeleteObjectPropList::DoHandleResponsePhaseL()
+	{
+	__FLOG(_L8("DoHandleResponsePhaseL - Entry"));
+	TUint32 parameter(0);
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+
+	responseCode = DeleteObjectPropListL(*iReceivedObjectMetaData, *iPropertyList, parameter);
+	
+	SendResponseL(responseCode, 1, &parameter);
+	__FLOG_VA((_L8("DeleteObjectPropListL responseCode = 0x%x, failed index = %u"), responseCode, parameter));
+	return EFalse;
+	}
+
+TBool CMTPSvcDeleteObjectPropList::HasDataphase() const
+	{
+	return ETrue;
+	}
+
+TMTPResponseCode CMTPSvcDeleteObjectPropList::DeleteObjectPropListL(CMTPObjectMetaData& aObjectMetaData, 
+														const CMTPTypeDeleteObjectPropList& aPropList, 
+														TUint32& aParameter)
+	{
+	__FLOG(_L8("DeleteObjectPropList- Entry")); 
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	TUint handle = aObjectMetaData.Uint(CMTPObjectMetaData::EHandle);
+	MMTPSvcObjectHandler* lastHandler = NULL; 
+	TUint errIndex = 0;
+	
+	if (handle == KMTPHandleAll)
+		{
+		TUint32 lastHandle = 0;
+		// In this case, all object handles specified in the dataset, can be multiple objects
+		const TUint count(aPropList.NumberOfElements());
+		CMTPObjectMetaData* objectMetaData = CMTPObjectMetaData::NewL();
+		CleanupStack::PushL(objectMetaData);
+		for (TUint i = 0; i < count; i++)
+			{
+			TMTPTypeDataPair& element = aPropList.ElementL(i);
+			TUint32 handle = element.Uint32(TMTPTypeDataPair::EOwnerHandle);
+			// Get object handle every time for multiple objects.
+			if (iFramework.ObjectMgr().ObjectL(handle, *objectMetaData))
+				{
+				TUint16 formatCode = objectMetaData->Uint(CMTPObjectMetaData::EFormatCode);
+				TUint16 propCode = element.Uint16(TMTPTypeDataPair::EDataCode);
+				MMTPSvcObjectHandler* pHandler = iDataProvider.ObjectHandler(formatCode);
+				if (pHandler)
+					{
+					// If the handler is not the last handle, need commit all properties now
+					if (lastHandle != 0 && lastHandler && lastHandle != handle)
+						{
+						// Performance can be improved here
+						TRAPD(err, lastHandler->CommitL());
+						if (KErrNone != err)
+							{
+							lastHandler->RollBack();
+							responseCode = EMTPRespCodeInvalidObjectHandle;
+							aParameter = errIndex;
+							break;
+							}
+						// Record the next segment's first index number
+						errIndex = i;
+						}
+					lastHandler = pHandler;
+					lastHandle = handle;
+					responseCode = pHandler->DeleteObjectPropertyL(*objectMetaData, propCode);
+					}
+				else
+					{
+					responseCode = EMTPRespCodeInvalidObjectHandle;
+					}
+				}
+			else
+				{
+				responseCode = EMTPRespCodeInvalidObjectHandle;
+				}
+			if (responseCode != EMTPRespCodeOK)
+				{
+				aParameter = i;
+				// All properties prior to the failed property will be updated.
+				if (i != errIndex && lastHandler)
+					{
+					TRAPD(err, lastHandler->CommitL());
+					if (KErrNone != err)
+						{
+						lastHandler->RollBack();
+						aParameter = errIndex;
+						}
+					}
+				break;
+				}
+			}
+		CleanupStack::PopAndDestroy(objectMetaData);
+		}
+	else 
+		{
+		// The element object handle fields should be either 0x00000000 or match with parameter 1. 
+		TUint16 formatCode = aObjectMetaData.Uint(CMTPObjectMetaData::EFormatCode);
+		const TUint count(aPropList.NumberOfElements());
+		for (TUint i = 0; i < count; i++)
+			{
+			TMTPTypeDataPair& element = aPropList.ElementL(i);
+			TUint32 handle = element.Uint32(TMTPTypeDataPair::EOwnerHandle);	
+			// Check dataset according to spec
+			if (handle != aObjectMetaData.Uint(CMTPObjectMetaData::EHandle) && handle != KMTPHandleNone)
+				{
+				responseCode = EMTPRespCodeInvalidObjectHandle;
+				}
+			else
+				{
+				TUint16 propCode = element.Uint16(TMTPTypeDataPair::EDataCode);
+				MMTPSvcObjectHandler* pHandler = iDataProvider.ObjectHandler(formatCode);
+				if (pHandler)
+					{
+					responseCode = pHandler->DeleteObjectPropertyL(aObjectMetaData, propCode);
+					if (!lastHandler)
+						{
+						lastHandler = pHandler;
+						}
+					}
+				else
+					{
+					responseCode = EMTPRespCodeInvalidObjectHandle;
+					}
+				}
+			if (responseCode != EMTPRespCodeOK)
+				{
+				aParameter = i;
+				if (i != 0 && lastHandler)
+					{
+					TRAPD(err, lastHandler->CommitL());
+					if (KErrNone != err)
+						{
+						lastHandler->RollBack();
+						aParameter = errIndex;
+						}
+					}
+				break;
+				}
+			}
+		}
+	// Commint for each case
+	if (responseCode == EMTPRespCodeOK && lastHandler)
+		{
+		TRAPD(err, lastHandler->CommitL());
+		if (KErrNone != err)
+			{
+			lastHandler->RollBack();
+			responseCode = EMTPRespCodeInvalidObjectHandle;
+			aParameter = errIndex;
+			}
+		}
+	__FLOG_VA((_L8("DeleteObjectPropList - Exit with responseCode = 0x%04X"), responseCode));
+	return responseCode;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcdeleteserviceproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,116 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcdeleteserviceproplist.cpp
+
+#include <mtp/cmtptypedeleteserviceproplist.h>
+#include <mtp/tmtptypedatapair.h>
+
+#include "cmtpsvcdeleteserviceproplist.h"
+#include "mmtpservicedataprovider.h"
+#include "mmtpservicehandler.h"
+
+__FLOG_STMT (_LIT8(KComponent, "SvcDelSvcPList");)
+
+EXPORT_C MMTPRequestProcessor* CMTPSvcDeleteServicePropList::NewL(MMTPDataProviderFramework& aFramework, 
+													MMTPConnection& aConnection, 
+													MMTPServiceDataProvider& aDataProvider)
+	{
+	CMTPSvcDeleteServicePropList* self = new (ELeave) CMTPSvcDeleteServicePropList(aFramework, aConnection,aDataProvider);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CMTPSvcDeleteServicePropList::~CMTPSvcDeleteServicePropList()
+	{    
+	__FLOG(_L8("~CMTPSvcDeleteServicePropList - Entry"));
+	delete iDeleteServicePropList;
+	__FLOG(_L8("~CMTPSvcDeleteServicePropList - Exit"));
+	__FLOG_CLOSE;
+	}
+
+CMTPSvcDeleteServicePropList::CMTPSvcDeleteServicePropList(MMTPDataProviderFramework& aFramework, 
+													MMTPConnection& aConnection, 
+													MMTPServiceDataProvider& aDataProvider) :
+	CMTPRequestProcessor(aFramework, aConnection, 0, NULL), iDataProvider(aDataProvider)
+	{
+	}
+
+void CMTPSvcDeleteServicePropList::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry")); 
+	iDeleteServicePropList = CMTPTypeDeleteServicePropList::NewL();
+	__FLOG(_L8("ConstructL - Exit")); 
+	}
+
+TMTPResponseCode CMTPSvcDeleteServicePropList::CheckRequestL()
+	{
+	__FLOG(_L8("CheckRequestL - Entry"));
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	if (EMTPRespCodeOK == responseCode)
+		{
+		TUint32 serviceId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+		if (serviceId != iDataProvider.ServiceID())
+			{
+			responseCode = EMTPRespCodeInvalidServiceID;
+			}
+		}
+	__FLOG_VA((_L8("CheckRequestL - Exit with responseCode = 0x%04X"), responseCode));
+	return responseCode;
+	}
+
+void CMTPSvcDeleteServicePropList::ServiceL()
+	{
+	__FLOG(_L8("ServiceL - Entry"));
+	//Recieve the data from the property list
+	ReceiveDataL(*iDeleteServicePropList);
+	__FLOG(_L8("ServiceL - Exit"));
+	}
+
+TBool CMTPSvcDeleteServicePropList::DoHandleResponsePhaseL()
+	{
+	__FLOG(_L8("DoHandleResponsePhaseL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	TUint32 parameter = 0;
+	const TUint count = iDeleteServicePropList->NumberOfElements();
+	for (TUint i = 0; i < count && responseCode == EMTPRespCodeOK; i++)
+		{
+		TMTPTypeDataPair& element = iDeleteServicePropList->ElementL(i);
+		
+		if (iDataProvider.ServiceID() != element.Uint32(TMTPTypeDataPair::EOwnerHandle))
+			{
+			parameter = i;
+			responseCode = EMTPRespCodeInvalidServiceID;
+			break;
+			}
+	
+		TUint16 propertyCode = element.Uint16(TMTPTypeDataPair::EDataCode);
+		responseCode = iDataProvider.ServiceHandler()->DeleteServicePropertyL(propertyCode);
+		if (EMTPRespCodeOK != responseCode)
+			{
+			parameter = i;
+			break;
+			}
+		}
+	SendResponseL(responseCode, 1, &parameter);
+	__FLOG_VA((_L8("DoHandleResponsePhaseL - Exit responseCode = 0x%04X, failed index = %u"), responseCode, parameter));
+	return EFalse;
+	}
+
+TBool CMTPSvcDeleteServicePropList::HasDataphase() const
+	{
+	return ETrue;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,107 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetobject.cpp
+
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mtpprotocolconstants.h>
+
+#include "cmtpsvcgetobject.h"
+#include "mmtpservicedataprovider.h"
+#include "mmtpsvcobjecthandler.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"SvcGetObject");)
+
+EXPORT_C MMTPRequestProcessor* CMTPSvcGetObject::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider)
+	{
+	CMTPSvcGetObject* self = new (ELeave) CMTPSvcGetObject(aFramework, aConnection, aDataProvider);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CMTPSvcGetObject::~CMTPSvcGetObject()
+	{
+	__FLOG(_L8("~CMTPSvcGetObject - Entry"));
+	if (iReceivedObjectMetaData && iObjectHandler)
+		{
+		iObjectHandler->ReleaseObjectBuffer();
+		}
+	delete iReceivedObjectMetaData;
+
+	__FLOG(_L8("~CMTPSvcGetObject - Exit"));
+	__FLOG_CLOSE;
+	}
+
+CMTPSvcGetObject::CMTPSvcGetObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider) : 
+	CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
+	iDataProvider(aDataProvider)
+	{	
+	}
+
+void CMTPSvcGetObject::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry"));
+	__FLOG(_L8("ConstructL - Exit"));
+	}
+
+TMTPResponseCode CMTPSvcGetObject::CheckRequestL()
+	{
+	__FLOG(_L8("CheckRequestL - Entry"));
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	if (EMTPRespCodeOK == responseCode)
+		{
+		TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+		
+		MMTPObjectMgr& objectmgr(iFramework.ObjectMgr());
+		iReceivedObjectMetaData = CMTPObjectMetaData::NewL();
+		if (objectmgr.ObjectL(objectHandle, *iReceivedObjectMetaData))
+			{
+			//Check whether the owner of this object is correct data provider
+			if (iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EDataProviderId) != iFramework.DataProviderId())
+				{
+				responseCode = EMTPRespCodeInvalidObjectHandle;
+				__FLOG(_L8("CheckRequestL - DataProviderId dismatch"));
+				}
+			else
+				{
+				// Check format and set handler
+				TUint16 formatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode);
+				iObjectHandler = iDataProvider.ObjectHandler(formatCode);
+				if (!iObjectHandler)
+					{
+					responseCode = EMTPRespCodeInvalidObjectFormatCode;
+					}
+				}
+			}
+		else
+			{
+			responseCode = EMTPRespCodeInvalidObjectHandle;
+			}
+		}
+	__FLOG_VA((_L8("CheckRequestL - Exit with response code = 0x%04X"), responseCode));
+	return responseCode;
+	}
+
+void CMTPSvcGetObject::ServiceL()
+	{
+	__FLOG(_L8("ServiceL - Entry"));
+	iObjectHandler->GetObjectL(*iReceivedObjectMetaData, &iBuffer);
+	SendDataL(*iBuffer);
+	__FLOG(_L8("ServiceL - Exit"));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetobjectinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,109 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetobjectinfo.cpp
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtptypeobjectinfo.h>
+#include <mtp/cmtpobjectmetadata.h>
+
+
+#include "cmtpsvcgetobjectinfo.h"
+#include "mmtpservicedataprovider.h"
+#include "mmtpsvcobjecthandler.h"
+
+__FLOG_STMT(_LIT8(KComponent,"SvcGetObjInfo");)
+
+EXPORT_C MMTPRequestProcessor* CMTPSvcGetObjectInfo::NewL(MMTPDataProviderFramework& aFramework, 
+														MMTPConnection& aConnection, 
+														MMTPServiceDataProvider& aDataProvider)
+	{
+	CMTPSvcGetObjectInfo* self = new (ELeave) CMTPSvcGetObjectInfo(aFramework, aConnection, aDataProvider);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CMTPSvcGetObjectInfo::~CMTPSvcGetObjectInfo()
+	{
+	__FLOG(_L8("~CMTPSvcGetObjectInfo - Destructed"));
+	delete iReceivedObjectMetaData;
+	delete iObjectInfo;
+	__FLOG_CLOSE;
+	}
+
+CMTPSvcGetObjectInfo::CMTPSvcGetObjectInfo(MMTPDataProviderFramework& aFramework,
+									MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider)
+	: CMTPRequestProcessor(aFramework, aConnection, 0, NULL), iDataProvider(aDataProvider)
+	{
+	}
+	
+void CMTPSvcGetObjectInfo::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL -  - Entry"));
+	
+    iObjectInfo = CMTPTypeObjectInfo::NewL();
+    
+    __FLOG(_L8("ConstructL -  - Exit"));
+	}
+
+TMTPResponseCode CMTPSvcGetObjectInfo::CheckRequestL()
+	{
+	__FLOG(_L8("CheckRequestL - Entry"));
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	if (EMTPRespCodeOK == responseCode)
+		{
+		TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+		MMTPObjectMgr& objectMgr(iFramework.ObjectMgr());
+		iReceivedObjectMetaData = CMTPObjectMetaData::NewL();
+		if (objectMgr.ObjectL(objectHandle, *iReceivedObjectMetaData))
+			{
+			//Check whether the owner of this object is correct data provider
+			if (iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EDataProviderId) != iFramework.DataProviderId())
+				{
+				responseCode = EMTPRespCodeInvalidObjectHandle;
+				__FLOG(_L8("CheckRequestL - DataProviderId dismatch"));
+				}
+			else
+				{
+				// Check format and set handler
+				TUint16 formatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode);
+				iObjectHandler = iDataProvider.ObjectHandler(formatCode);
+				if (!iObjectHandler)
+					{
+					responseCode = EMTPRespCodeInvalidObjectFormatCode;
+					}
+				}
+			}
+		else
+			{
+			responseCode = EMTPRespCodeInvalidObjectHandle;
+			}
+		}
+	__FLOG_VA((_L8("CheckRequestL - Exit with response code = 0x%04X"), responseCode));
+	return responseCode;
+	}
+	
+void CMTPSvcGetObjectInfo::ServiceL()
+	{
+	__FLOG(_L8("ServiceL - Entry"));
+	__ASSERT_DEBUG(iObjectHandler, User::Invariant());
+	TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+	iObjectHandler->GetObjectInfoL(*iReceivedObjectMetaData, *iObjectInfo);
+	SendDataL(*iObjectInfo);
+	__FLOG(_L8("ServiceL - Exit"));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetobjectproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,323 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetobjectproplist.cpp
+
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypeobjectproplist.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mtpdatatypeconstants.h>
+
+#include "cmtpsvcgetobjectproplist.h"
+#include "mtpsvcdpconst.h"
+#include "mmtpservicedataprovider.h"
+#include "mmtpsvcobjecthandler.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"SvcGetObjPL");)
+
+EXPORT_C MMTPRequestProcessor* CMTPSvcGetObjectPropList::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider)
+	{
+	CMTPSvcGetObjectPropList* self = new (ELeave) CMTPSvcGetObjectPropList(aFramework, aConnection, aDataProvider);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CMTPSvcGetObjectPropList::~CMTPSvcGetObjectPropList()
+	{
+	__FLOG(_L8("~CMTPSvcGetObjectPropList - Entry"));
+	delete iPropertyList;
+	delete iReceivedObjectMetaData;
+	iObjectHandles.Close();
+	__FLOG(_L8("~CMTPSvcGetObjectPropList - Exit"));
+	__FLOG_CLOSE; 
+	}
+
+CMTPSvcGetObjectPropList::CMTPSvcGetObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider) :
+	CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
+	iError(KErrNone),
+	iDataProvider(aDataProvider),
+	iResponseCode(EMTPRespCodeOK)
+	{
+	}
+
+void CMTPSvcGetObjectPropList::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry"));
+	iPropertyList = CMTPTypeObjectPropList::NewL();
+	__FLOG(_L8("ConstructL - Exit"));
+	}
+
+TMTPResponseCode CMTPSvcGetObjectPropList::CheckRequestL()
+	{
+	__FLOG(_L8("CheckRequestL - Entry"));
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	if (EMTPRespCodeOK == responseCode)
+		{
+		responseCode = CheckObjectHandleAndFormatL();
+		}
+	
+	if (EMTPRespCodeOK == responseCode)
+		{
+		responseCode = CheckDepth();
+		}
+	
+	__FLOG_VA((_L8("CheckRequestL - Exit with responseCode = 0x%04X"), responseCode));
+	return responseCode;
+	}
+
+TMTPResponseCode CMTPSvcGetObjectPropList::CheckObjectHandleAndFormatL()
+	{
+	__FLOG(_L8("CheckObjectHandleAndFormatL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK; 
+	
+	TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+	TUint32 formatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+	iPropCode = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
+	iReceivedObjectMetaData = CMTPObjectMetaData::NewL();
+	// Object is a specified handle
+	if (objectHandle != KMTPHandleAll && objectHandle != KMTPHandleAllRootLevel)
+		{
+		MMTPObjectMgr& objects(iFramework.ObjectMgr());
+		//Check whether object handle is valid
+		if (objects.ObjectL(objectHandle, *iReceivedObjectMetaData))
+			{
+			if (iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EDataProviderId) != iFramework.DataProviderId())
+				{
+				responseCode = EMTPRespCodeInvalidObjectHandle;
+				__FLOG(_L8("CheckRequestL - DataProviderId dismatch"));
+				}
+			else
+				{
+				// If handle is ok, ignore format code parameter
+				formatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode);
+				iObjectHandler = iDataProvider.ObjectHandler(formatCode);
+				if (!iObjectHandler)
+					{
+					responseCode = EMTPRespCodeInvalidObjectHandle;
+					}
+				else
+					{
+					responseCode = CheckPropertyCodeForFormatL(formatCode);
+					}
+				}
+			}
+		else
+			{
+			responseCode = EMTPRespCodeInvalidObjectHandle;
+			}
+		}
+	// If object handle is 0x0000000 or 0xFFFFFFFF
+	else
+		{
+		// A formatCode value of 0x00000000 indicates that this parameter is not being used and properties 
+		// of all Object Formats are desired. 
+		if (formatCode != KMTPNotSpecified32)
+			{
+			iObjectHandler = iDataProvider.ObjectHandler(formatCode);
+			if (!iObjectHandler)
+				{
+				responseCode = EMTPRespCodeSpecificationByFormatUnsupported;
+				}
+			else
+				{
+				responseCode = CheckPropertyCodeForFormatL(formatCode);
+				}
+			}
+		}
+	__FLOG_VA((_L8("CheckObjectHandleAndFormatL - Exit with response code = 0x%04X"), responseCode));
+	return responseCode;
+	}
+
+TMTPResponseCode CMTPSvcGetObjectPropList::CheckPropertyCodeForFormatL(TUint32 aFormatCode) const
+	{
+	__FLOG(_L8("CheckPropertyCodeForFormatL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	if (iPropCode != KMTPObjectPropCodeAll && iPropCode != KMTPNotSpecified32)
+		{
+		if (!iDataProvider.IsValidObjectPropCodeL(aFormatCode, iPropCode))
+			{
+			responseCode = EMTPRespCodeInvalidObjectPropCode;
+			}
+		}
+	__FLOG_VA((_L8("CheckPropertyCodeForFormatL - Exit with response code = 0x%04X"), responseCode));
+	return responseCode;
+	}
+
+/**
+Ensures that the requested object depth is one we support.
+@return EMTPRespCodeOK, or EMTPRespCodeSpecificationByDepthUnsupported if the depth is unsupported
+*/
+TMTPResponseCode CMTPSvcGetObjectPropList::CheckDepth() const
+	{
+	__FLOG(_L8("CheckDepth - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeSpecificationByDepthUnsupported;
+	// Support  depth 0 or 1 or 0xFFFFFFFF
+	TUint32 handle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+	TUint32 depth = Request().Uint32(TMTPTypeRequest::ERequestParameter5);
+	if (depth == 0 || depth == 1 || depth == KMTPHandleNoParent)
+		{
+		responseCode = EMTPRespCodeOK; 
+		}
+	__FLOG_VA((_L8("CheckDepth - Exit with response code = 0x%04X"), responseCode));
+	return responseCode;
+	}
+
+void CMTPSvcGetObjectPropList::ServiceL()
+	{
+	__FLOG(_L8("ServiceL - Entry"));
+	TUint32 handle(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
+	TUint32 formatCode(Request().Uint32(TMTPTypeRequest::ERequestParameter2));
+	TUint32 depth(Request().Uint32(TMTPTypeRequest::ERequestParameter5));
+	iGroupId = Request().Uint32(TMTPTypeRequest::ERequestParameter4);
+	// Get all objects or root objects
+	if (handle == KMTPHandleAll || handle == KMTPHandleAllRootLevel)
+		{
+		// For service DP, the two cases are the same, need all handles with format code.
+		RMTPObjectMgrQueryContext   context;
+		CleanupClosePushL(context);
+		do
+			{
+			TUint32 storageId = iDataProvider.StorageId();
+			TMTPObjectMgrQueryParams params(storageId, formatCode, KMTPHandleNoParent);
+			iFramework.ObjectMgr().GetObjectHandlesL(params, context, iObjectHandles);
+			}
+		while (!context.QueryComplete());
+		CleanupStack::PopAndDestroy(&context);
+		iHandleIndex = 0;
+		CompleteSelf(KErrNone);
+		}
+	else
+		{
+		GetObjectPropertyHelperL();
+		SendDataL(*iPropertyList);
+		}
+	__FLOG(_L8("ServiceL - Exit"));
+	}
+
+/**
+Handle the response phase of the current request
+@return EFalse
+*/		
+TBool CMTPSvcGetObjectPropList::DoHandleResponsePhaseL()
+	{
+	__FLOG(_L8("DoHandleResponsePhaseL - Entry"));
+	TMTPResponseCode responseCode = (iCancelled ? EMTPRespCodeIncompleteTransfer : iResponseCode);
+	SendResponseL(responseCode);
+	__FLOG_VA((_L8("DoHandleResponsePhaseL - Exit with response code = 0x%04X"), responseCode));
+	return EFalse;
+	}
+
+void CMTPSvcGetObjectPropList::RunL()
+	{
+	__FLOG(_L8("RunL - Entry"));
+	__FLOG_VA((_L8("the number of objects to be queried is %d, iHandleIndex is %d"), iObjectHandles.Count(), iHandleIndex));
+	
+	TInt count = iObjectHandles.Count();
+	const TUint32 granularity = iDataProvider.OperationGranularity();
+	for (TInt i = 0; iHandleIndex < count && i < granularity; i++)
+		{
+		TUint handle = iObjectHandles[iHandleIndex++];
+		iFramework.ObjectMgr().ObjectL(handle, *iReceivedObjectMetaData);
+		// Process for each object
+		TUint16 formatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode);
+		iObjectHandler = iDataProvider.ObjectHandler(formatCode);
+		if (iObjectHandler)
+			{
+			GetObjectPropertyHelperL();
+			}
+		else
+			{
+			// An unsupport object got from object mgr.
+			iResponseCode = EMTPRespCodeInvalidObjectHandle;
+			}
+		__FLOG_VA((_L8("Get a object property list, SUID:%S, response code: 0x%4x"), &(iReceivedObjectMetaData->DesC(CMTPObjectMetaData::ESuid)), iResponseCode));
+		}
+	
+	if (iHandleIndex >= count)
+		{
+		ProcessFinalPhaseL();
+		}
+	else 
+		{
+		CompleteSelf(KErrNone);
+		}
+	__FLOG(_L8("RunL - Exit")); 
+	}
+
+TInt CMTPSvcGetObjectPropList::RunError(TInt aError)
+	{
+	__FLOG(_L8("RunError - Entry"));
+	CompleteSelf(aError);
+	__FLOG(_L8("RunError - Exit")); 
+	return KErrNone;
+	}
+
+/**
+Complete myself
+*/
+void CMTPSvcGetObjectPropList::CompleteSelf(TInt aError)
+	{
+	__FLOG(_L8("CompleteSelf - Entry"));
+	SetActive();
+	TRequestStatus* status = &iStatus;
+	*status = KRequestPending;
+	User::RequestComplete(status, aError);
+	__FLOG(_L8("CompleteSelf - Exit"));
+	}
+
+/**
+Signal to the initiator that the deletion operation has finished with or without error
+*/
+void CMTPSvcGetObjectPropList::ProcessFinalPhaseL()
+	{
+	__FLOG(_L8("ProcessFinalPhaseL - Entry"));
+	SendDataL(*iPropertyList);
+	__FLOG(_L8("ProcessFinalPhaseL - Exit"));
+	}
+
+void CMTPSvcGetObjectPropList::GetObjectPropertyHelperL()
+	{
+	if (iPropCode == KMTPObjectPropCodeAll)
+		{
+		// A value of 0xFFFFFFFF indicates that all properties are requested except those 
+		// with a group code of 0xFFFFFFFF
+		iGroupId = 0; // Get all object prop codes
+		}
+	if (iPropCode == KMTPNotSpecified32 || iPropCode == KMTPObjectPropCodeAll)
+		{
+		// A value of 0x00000000 in the third parameter indicates that the fourth 
+		// parameter should be used
+		RArray<TUint32> objectPropCodes;
+		CleanupClosePushL(objectPropCodes);
+		iResponseCode = iObjectHandler->GetAllObjectPropCodeByGroupL(iGroupId, objectPropCodes);
+		if (iResponseCode == EMTPRespCodeOK)
+			{
+			TInt count = objectPropCodes.Count();
+			for (TInt i = 0; i < count && iResponseCode == EMTPRespCodeOK; i++)
+				{
+				iResponseCode = iObjectHandler->GetObjectPropertyL(*iReceivedObjectMetaData, objectPropCodes[i], *iPropertyList);
+				}
+			}
+		CleanupStack::PopAndDestroy(&objectPropCodes);
+		}
+	else
+		{
+		// Get one prop info into objectproplist.
+		iResponseCode = iObjectHandler->GetObjectPropertyL(*iReceivedObjectMetaData, iPropCode, *iPropertyList);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetreferences.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,111 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetreferences.cpp
+
+#include <mtp/cmtptypearray.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpreferencemgr.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpobjectmgr.h>
+
+#include "cmtpsvcgetreferences.h"
+#include "mmtpservicedataprovider.h"
+#include "mmtpsvcobjecthandler.h"
+
+__FLOG_STMT(_LIT8(KComponent,"SvcGetRef");)
+
+EXPORT_C MMTPRequestProcessor* CMTPSvcGetReferences::NewL(MMTPDataProviderFramework& aFramework, 
+														MMTPConnection& aConnection, 
+														MMTPServiceDataProvider& aDataProvider)
+	{
+	CMTPSvcGetReferences* self = new (ELeave) CMTPSvcGetReferences(aFramework, aConnection, aDataProvider);
+	return self;
+	}
+
+/**
+Destructor
+*/
+EXPORT_C CMTPSvcGetReferences::~CMTPSvcGetReferences()
+	{
+	__FLOG(_L8("~CMTPSvcGetReferences - Entry"));
+	delete iReferences;
+	delete iReceivedObjectMetaData;
+	__FLOG(_L8("~CMTPSvcGetReferences - Exit"));
+	__FLOG_CLOSE; 
+	}
+
+/**
+Standard c++ constructor
+*/
+CMTPSvcGetReferences::CMTPSvcGetReferences(MMTPDataProviderFramework& aFramework, 
+										MMTPConnection& aConnection, 
+										MMTPServiceDataProvider& aDataProvider)
+	:CMTPRequestProcessor(aFramework, aConnection, 0, NULL), 
+	iDataProvider(aDataProvider)
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("Constructed"));
+	}
+
+TMTPResponseCode CMTPSvcGetReferences::CheckRequestL()
+	{
+	__FLOG(_L8("CheckRequestL - Entry"));
+
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	if (EMTPRespCodeOK == responseCode)
+		{
+		TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+		iReceivedObjectMetaData = CMTPObjectMetaData::NewL();
+		// Check object handle
+		MMTPObjectMgr& objMgr(iFramework.ObjectMgr());
+		// Check whether object handle is valid
+		if (objMgr.ObjectL(objectHandle, *iReceivedObjectMetaData))
+			{
+			// Check whether the owner of this object is correct data provider
+			if (iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EDataProviderId) != iFramework.DataProviderId())
+				{
+				responseCode = EMTPRespCodeInvalidObjectHandle;
+				__FLOG(_L8("CheckRequestL - DataProviderId dismatch"));
+				}
+			else
+				{
+				// Check format code
+				TUint16 formatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode);
+				if (!iDataProvider.ObjectHandler(formatCode))
+					{
+					responseCode = EMTPRespCodeInvalidObjectHandle;
+					}
+				}
+			}
+		else
+			{
+			responseCode = EMTPRespCodeInvalidObjectHandle;
+			}
+		}
+	__FLOG_VA((_L8("CheckRequestL - Exit with code: 0x%04X"), responseCode));
+	return responseCode;
+	}
+
+void CMTPSvcGetReferences::ServiceL()
+	{
+	__FLOG(_L8("ServiceL - Entry"));
+	TUint16 formatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode);
+	delete iReferences;
+	iReferences = NULL;
+	iReferences = CMTPTypeArray::NewL(EMTPTypeAUINT32);
+	iDataProvider.ObjectHandler(formatCode)->GetObjectReferenceL(*iReceivedObjectMetaData, *iReferences);
+	SendDataL(*iReferences);
+	__FLOG(_L8("ServiceL - Exit"));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetservicecapabilities.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,116 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetservicecapabilities.cpp
+
+#include <mtp/cmtptypeservicecapabilitylist.h>
+
+#include "cmtpsvcgetservicecapabilities.h"
+#include "mmtpservicedataprovider.h"
+#include "mmtpservicehandler.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"SvcGetSvcCap");)
+
+EXPORT_C MMTPRequestProcessor* CMTPSvcGetServiceCapabilities::NewL(MMTPDataProviderFramework& aFramework, 
+													MMTPConnection& aConnection, 
+													MMTPServiceDataProvider& aDataProvider)
+	{
+	CMTPSvcGetServiceCapabilities* self = new (ELeave) CMTPSvcGetServiceCapabilities(aFramework, aConnection, aDataProvider);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CMTPSvcGetServiceCapabilities::~CMTPSvcGetServiceCapabilities()
+	{
+	__FLOG(_L8("~CMTPSvcGetServiceCapabilities - Entry"));
+	delete iServiceCapabilityList;
+	__FLOG(_L8("~CMTPSvcGetServiceCapabilities - Exit"));
+	__FLOG_CLOSE;
+	}
+
+CMTPSvcGetServiceCapabilities::CMTPSvcGetServiceCapabilities(MMTPDataProviderFramework& aFramework, 
+													MMTPConnection& aConnection, 
+													MMTPServiceDataProvider& aDataProvider)
+:CMTPRequestProcessor(aFramework, aConnection, 0, NULL), iDataProvider(aDataProvider), iResponseCode(EMTPRespCodeOK)
+	{	
+	}
+
+void CMTPSvcGetServiceCapabilities::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry")); 
+	iServiceCapabilityList = CMTPTypeServiceCapabilityList::NewL();
+	__FLOG(_L8("ConstructL - Exit")); 
+	}
+
+TMTPResponseCode CMTPSvcGetServiceCapabilities::CheckRequestL()
+{
+	__FLOG(_L8("CheckRequestL - Entry"));
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	if (EMTPRespCodeOK == responseCode)
+		{
+		TUint32 serviceId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+		
+		if (serviceId != iDataProvider.ServiceID())
+			{
+			responseCode = EMTPRespCodeInvalidServiceID;
+			}
+		
+		if (EMTPRespCodeOK == responseCode)
+			{
+			TUint16 formatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2); 
+			if (KMTPFormatsAll != formatCode && !iDataProvider.IsValidFormatCodeL(formatCode))
+				{
+				responseCode = EMTPRespCodeInvalidObjectFormatCode;
+				}
+			}
+		}
+	__FLOG_VA((_L8("CheckRequestL - Exit with response code = 0x%04X"), responseCode));
+	return responseCode;
+}
+
+void CMTPSvcGetServiceCapabilities::ServiceL()
+	{
+	__FLOG(_L8("ServiceL - Entry"));
+	TUint32 formatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+	if (KMTPFormatsAll == formatCode)
+		{
+		RArray<TUint32> formatCodes;
+		CleanupClosePushL(formatCodes);
+		(iDataProvider.ServiceHandler())->GetAllServiceFormatCodeL(formatCodes); 
+		TInt count = formatCodes.Count();
+		for (TInt i = 0; i < count && iResponseCode == EMTPRespCodeOK; i++)
+			{
+			iResponseCode = (iDataProvider.ServiceHandler())->GetServiceCapabilityL(formatCodes[i], *iServiceCapabilityList);
+			}
+		CleanupStack::PopAndDestroy(&formatCodes);
+		}
+	else
+		{
+		iResponseCode = (iDataProvider.ServiceHandler())->GetServiceCapabilityL(formatCode, *iServiceCapabilityList);
+		}
+	SendDataL(*iServiceCapabilityList);
+	__FLOG(_L8("ServiceL - Exit"));
+	}
+
+TBool CMTPSvcGetServiceCapabilities::DoHandleResponsePhaseL()
+	{
+	__FLOG(_L8("DoHandleResponsePhaseL - Entry"));
+	TMTPResponseCode responseCode = (iCancelled ? EMTPRespCodeIncompleteTransfer : iResponseCode);
+	SendResponseL(responseCode);
+	__FLOG_VA((_L8("DoHandleResponsePhaseL - Exit with Response Code: 0x%x"), iResponseCode));
+	return EFalse;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetserviceinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,89 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetserviceinfo.cpp
+
+#include <mtp/cmtptypeserviceinfo.h>
+
+#include "cmtpsvcgetserviceinfo.h"
+#include "mmtpservicedataprovider.h"
+#include "mmtpservicehandler.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent, "SvcGetSvcInfo");)
+
+EXPORT_C MMTPRequestProcessor* CMTPSvcGetServiceInfo::NewL(MMTPDataProviderFramework& aFramework, 
+												MMTPConnection& aConnection, 
+												MMTPServiceDataProvider& aDataProvider)
+	{
+	CMTPSvcGetServiceInfo* self = new (ELeave) CMTPSvcGetServiceInfo(aFramework, aConnection, aDataProvider);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CMTPSvcGetServiceInfo::~CMTPSvcGetServiceInfo()
+	{
+	__FLOG(_L8("~CMTPSvcGetServiceInfo - Entry"));
+	delete iServiceInfo;
+	__FLOG(_L8("~CMTPSvcGetServiceInfo - Exit"));
+	__FLOG_CLOSE;
+	}
+
+CMTPSvcGetServiceInfo::CMTPSvcGetServiceInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, 
+											MMTPServiceDataProvider& aDataProvider) :
+	CMTPRequestProcessor(aFramework, aConnection, 0, NULL), iDataProvider(aDataProvider)
+	{	
+	}
+
+void CMTPSvcGetServiceInfo::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry")); 
+	iServiceInfo = CMTPTypeServiceInfo::NewL();
+	__FLOG(_L8("ConstructL - Exit")); 
+	}
+
+TMTPResponseCode CMTPSvcGetServiceInfo::CheckRequestL()
+	{
+	__FLOG(_L8("CheckRequestL - Entry"));
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	if (EMTPRespCodeOK == responseCode)
+		{
+		TUint32 serviceId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+		if (serviceId != iDataProvider.ServiceID())
+			{
+			responseCode  = EMTPRespCodeInvalidServiceID;
+			}
+		}
+	__FLOG_VA((_L8("CheckRequestL - Exit with response code = 0x%04X"), responseCode));
+	return responseCode;
+	}
+
+void CMTPSvcGetServiceInfo::ServiceL()
+	{
+	__FLOG(_L8("ServiceL - Entry"));
+	iResponseCode = (iDataProvider.ServiceHandler())->GetServiceInfoL(*iServiceInfo);
+	SendDataL(*iServiceInfo);
+	__FLOG(_L8("ServiceL - Exit"));
+	}
+
+TBool CMTPSvcGetServiceInfo::DoHandleResponsePhaseL()
+	{
+	__FLOG(_L8("DoHandleResponsePhaseL - Entry"));
+	TMTPResponseCode responseCode = (iCancelled ? EMTPRespCodeIncompleteTransfer : iResponseCode);
+	SendResponseL(responseCode);
+	__FLOG_VA((_L8("DoHandleResponsePhaseL - Exit with Response Code: 0x%x"), iResponseCode));
+	return EFalse;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetservicepropdesc.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,120 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetservicepropdesc.cpp
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/cmtptypeservicepropdesclist.h>
+
+#include "cmtpsvcgetservicepropdesc.h"
+#include "mmtpservicedataprovider.h"
+#include "mmtpservicehandler.h"
+
+__FLOG_STMT(_LIT8(KComponent,"SvcGetSvcPDesc");)
+
+EXPORT_C MMTPRequestProcessor* CMTPSvcGetServicePropDesc::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider)
+	{
+	CMTPSvcGetServicePropDesc* self = new (ELeave) CMTPSvcGetServicePropDesc(aFramework, aConnection, aDataProvider);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CMTPSvcGetServicePropDesc::~CMTPSvcGetServicePropDesc()
+	{
+	__FLOG(_L8("~CMTPSvcGetServicePropDesc - Entry"));
+	delete iPropDescList;
+	__FLOG(_L8("~CMTPSvcGetServicePropDesc - Exit"));
+	__FLOG_CLOSE;
+	}
+
+CMTPSvcGetServicePropDesc::CMTPSvcGetServicePropDesc(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider) :
+	CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
+	iDataProvider(aDataProvider),
+	iResponseCode(EMTPRespCodeOK)
+	{
+	}
+
+void CMTPSvcGetServicePropDesc::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry"));
+	iPropDescList = CMTPTypeServicePropDescList::NewL();
+	__FLOG(_L8("ConstructL - Exit"));
+	}
+
+TMTPResponseCode CMTPSvcGetServicePropDesc::CheckRequestL()
+	{
+	__FLOG(_L8("CheckRequestL - Entry"));
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	if (EMTPRespCodeOK == responseCode)
+		{
+		TUint32 serviceID = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+		TUint32 propCode(Request().Uint32(TMTPTypeRequest::ERequestParameter2));
+		
+		if ((iDataProvider.ServiceID() != serviceID))
+			{
+			responseCode = EMTPRespCodeInvalidServiceID;
+			__FLOG(_L8("Service Id Parameter don't be supported"));
+			}
+		
+		if (EMTPRespCodeOK == responseCode)
+			{
+			if ((KMTPNotSpecified32 != propCode) && 
+				!(iDataProvider.IsValidServicePropCodeL(propCode)))
+				{
+				responseCode = EMTPRespCodeInvalidServicePropCode;
+				__FLOG(_L8("Service Object PropCode Parameter don't be supported"));
+				}
+			}
+		}
+	__FLOG_VA((_L8("CheckRequestL - Exit with response code = 0x%04X"), responseCode));
+	return responseCode;
+	}
+
+void CMTPSvcGetServicePropDesc::ServiceL()
+	{
+	__FLOG(_L8("ServiceL - Entry"));
+	TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+	
+	if (KMTPNotSpecified32 != propCode)
+		{
+		iResponseCode = (iDataProvider.ServiceHandler())->GetServicePropDescL(propCode, *iPropDescList);
+		}
+	else
+		{
+		RArray<TUint32> propCodeArray;
+		CleanupClosePushL(propCodeArray);
+		(iDataProvider.ServiceHandler())->GetAllSevicePropCodesL(propCodeArray); 
+		TInt count = propCodeArray.Count();
+		for (TInt i = 0; i < count && iResponseCode == EMTPRespCodeOK; i++)
+			{
+			iResponseCode = (iDataProvider.ServiceHandler())->GetServicePropDescL(propCodeArray[i], *iPropDescList);
+			}
+		CleanupStack::PopAndDestroy(&propCodeArray);
+		}
+	SendDataL(*iPropDescList);
+	__FLOG_VA((_L8("ServiceL - Exit with Response Code: 0x%x, Service Property Count: %u"), iResponseCode, iPropDescList->NumberOfElements()));
+	}
+
+TBool CMTPSvcGetServicePropDesc::DoHandleResponsePhaseL()
+	{
+	__FLOG(_L8("DoHandleResponsePhaseL - Entry"));
+	TMTPResponseCode responseCode = (iCancelled ? EMTPRespCodeIncompleteTransfer : iResponseCode);
+	SendResponseL(responseCode);
+	__FLOG_VA((_L8("DoHandleResponsePhaseL - Exit with Response Code: 0x%x"), iResponseCode));
+	return EFalse;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetserviceproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,110 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetserviceproplist.cpp
+
+#include "cmtpsvcgetserviceproplist.h"
+#include "mmtpservicedataprovider.h"
+#include "mmtpservicehandler.h"
+
+__FLOG_STMT (_LIT8(KComponent,"SvcGetSvcPList");)
+
+const TUint16 KMTPServicePropsAll(0x0000);
+
+EXPORT_C MMTPRequestProcessor* CMTPSvcGetServicePropList::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider)
+	{
+	CMTPSvcGetServicePropList* self = new (ELeave) CMTPSvcGetServicePropList(aFramework, aConnection, aDataProvider);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CMTPSvcGetServicePropList::~CMTPSvcGetServicePropList()
+	{
+	__FLOG(_L8("~CMTPSvcGetServicePropList - Entry"));
+	delete iServicePropList;
+	__FLOG(_L8("~CMTPSvcGetServicePropList - Exit"));
+	__FLOG_CLOSE;
+	}
+
+CMTPSvcGetServicePropList::CMTPSvcGetServicePropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider) :
+	CMTPRequestProcessor(aFramework, aConnection, 0, NULL), iDataProvider(aDataProvider), iResponseCode(EMTPRespCodeOK)
+	{	
+	}
+
+void CMTPSvcGetServicePropList::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry")); 
+	iServicePropList = CMTPTypeServicePropList::NewL();
+	__FLOG(_L8("ConstructL - Exit")); 
+	}
+
+void CMTPSvcGetServicePropList::ServiceL()
+	{
+	__FLOG(_L8("ServiceL - Entry"));
+	TUint32 propcode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+	if (KMTPServicePropertyAll == propcode)
+		{
+		RArray<TUint32> servicePropArray;
+		CleanupClosePushL(servicePropArray);
+		(iDataProvider.ServiceHandler())->GetAllSevicePropCodesL(servicePropArray);
+		TInt count = servicePropArray.Count();
+		for (TInt i = 0; i < count && iResponseCode == EMTPRespCodeOK; i++)
+			{
+			iResponseCode = (iDataProvider.ServiceHandler())->GetServicePropertyL(servicePropArray[i], *iServicePropList);
+			}
+		CleanupStack::PopAndDestroy(&servicePropArray);
+		}
+	else
+		{
+		iResponseCode = (iDataProvider.ServiceHandler())->GetServicePropertyL(propcode, *iServicePropList);
+		}
+	SendDataL(*iServicePropList);
+	__FLOG(_L8("ServiceL - Exit"));
+	}
+
+TMTPResponseCode CMTPSvcGetServicePropList::CheckRequestL()
+{
+	__FLOG(_L8("CheckRequestL - Entry")); 
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	if (EMTPRespCodeOK == responseCode)
+		{
+		TUint32 serviceId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+		if (serviceId != iDataProvider.ServiceID())
+			{
+			responseCode  = EMTPRespCodeInvalidServiceID;
+			}
+		
+		if (EMTPRespCodeOK == responseCode)
+			{
+			TUint32 propcode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
+			if (KMTPServicePropsAll != propcode && !iDataProvider.IsValidServicePropCodeL(propcode))
+				{
+				responseCode = EMTPRespCodeInvalidServicePropCode;
+				}
+			}
+		}
+	__FLOG_VA((_L8("CheckRequestL - Exit with responseCode = 0x%04X"), responseCode));
+	return responseCode;
+}
+
+TBool CMTPSvcGetServicePropList::DoHandleResponsePhaseL()
+	{
+	__FLOG(_L8("DoHandleResponsePhaseL - Entry"));
+	TMTPResponseCode responseCode = (iCancelled ? EMTPRespCodeIncompleteTransfer : iResponseCode);
+	SendResponseL(responseCode);
+	__FLOG_VA((_L8("DoHandleResponsePhaseL - Exit with Response Code: 0x%x"), iResponseCode));
+	return EFalse;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetstorageinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,89 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetstorageinfo.cpp
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtptypestorageinfo.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mmtpstoragemgr.h>
+
+#include "cmtpsvcgetstorageinfo.h"
+#include "mmtpservicedataprovider.h"
+
+__FLOG_STMT(_LIT8(KComponent,"SvcGetStgInfo");)
+
+EXPORT_C MMTPRequestProcessor* CMTPSvcGetStorageInfo::NewL(
+											MMTPDataProviderFramework& aFramework, 
+											MMTPConnection& aConnection, 
+											MMTPServiceDataProvider& aDataProvider)
+	{
+	CMTPSvcGetStorageInfo* self = new (ELeave) CMTPSvcGetStorageInfo(aFramework, aConnection, aDataProvider);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CMTPSvcGetStorageInfo::~CMTPSvcGetStorageInfo()
+	{
+	__FLOG(_L8("~CMTPSvcGetStorageInfo - Entry"));
+	delete iStorageInfo;
+	__FLOG(_L8("~CMTPSvcGetStorageInfo - Exit"));
+	__FLOG_CLOSE;
+	}
+
+CMTPSvcGetStorageInfo::CMTPSvcGetStorageInfo(
+									MMTPDataProviderFramework& aFramework, 
+									MMTPConnection& aConnection, 
+									MMTPServiceDataProvider& aDataProvider)
+	: CMTPRequestProcessor(aFramework, aConnection, 0, NULL), iDataProvider(aDataProvider)
+	{
+	}
+
+/**
+GetStorageInfo request handler
+Build storage info data set and send the data to the initiator
+*/		
+void CMTPSvcGetStorageInfo::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry"));
+	iStorageInfo = CMTPTypeStorageInfo::NewL();
+	__FLOG(_L8("ConstructL - Exit"));
+	}
+
+void CMTPSvcGetStorageInfo::ServiceL()
+	{
+	__FLOG(_L8("ServiceL - Entry"));
+	iDataProvider.GetStorageInfoL(*iStorageInfo);
+	SendDataL(*iStorageInfo);
+	__FLOG(_L8("ServiceL - Exit"));
+	}
+
+TMTPResponseCode CMTPSvcGetStorageInfo::CheckRequestL()
+	{
+	__FLOG(_L8("CheckRequestL - Entry"));
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	if (EMTPRespCodeOK == responseCode)
+		{
+		TUint32 storageID = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+		if (storageID != iDataProvider.StorageId())
+			{
+			responseCode = EMTPRespCodeInvalidStorageID;
+			}
+		}
+	__FLOG_VA((_L8("CheckRequestL Exit with response code = 0x%04X"), responseCode));
+	return responseCode;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcsetobjectproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,161 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectproplist.cpp
+
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypeobjectproplist.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mtpdatatypeconstants.h>
+
+#include "cmtpsvcsetobjectproplist.h"
+#include "mmtpservicedataprovider.h"
+#include "mmtpsvcobjecthandler.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"SvcSetObjPropList");)
+
+EXPORT_C MMTPRequestProcessor* CMTPSvcSetObjectPropList::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider)
+	{
+	CMTPSvcSetObjectPropList* self = new (ELeave) CMTPSvcSetObjectPropList(aFramework, aConnection, aDataProvider);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CMTPSvcSetObjectPropList::~CMTPSvcSetObjectPropList()
+	{
+	__FLOG(_L8("~CMTPSvcSetObjectPropList - Entry"));
+	delete iPropertyList;
+	__FLOG(_L8("~CMTPSvcSetObjectPropList - Exit"));
+	__FLOG_CLOSE;
+	}
+
+CMTPSvcSetObjectPropList::CMTPSvcSetObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider) :
+	CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
+	iDataProvider(aDataProvider)
+	{
+	}
+
+void CMTPSvcSetObjectPropList::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry"));
+	iPropertyList = CMTPTypeObjectPropList::NewL();
+	__FLOG(_L8("ConstructL - Exit"));
+	}
+
+void CMTPSvcSetObjectPropList::ServiceL()
+	{
+	__FLOG(_L8("ServiceL - Entry"));
+	ReceiveDataL(*iPropertyList);
+	__FLOG(_L8("ServiceL - Exit"));
+	}
+
+TBool CMTPSvcSetObjectPropList::DoHandleResponsePhaseL()
+	{
+	__FLOG(_L8("DoHandleResponsePhaseL - Entry"));
+	TUint32 parameter = 0;
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	
+	responseCode = SetObjectPropListL(*iPropertyList, parameter);
+	__FLOG_VA((_L8("SetObjectPropListL - ResponsCode: 0x%x, error index: %u"), responseCode, parameter));
+	
+	SendResponseL(responseCode, 1, &parameter);
+	__FLOG_VA((_L8("DoHandleResponsePhaseL - Exit with responseCode = 0x%04X and failed index: %u"), responseCode, parameter));
+	return EFalse;
+	}
+
+TMTPResponseCode CMTPSvcSetObjectPropList::SetObjectPropListL(const CMTPTypeObjectPropList& aObjectPropList, TUint32& aParameter)
+	{
+	__FLOG(_L8("SetObjectPropListL - Entry"));
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	const TUint count = aObjectPropList.NumberOfElements();
+	aObjectPropList.ResetCursor();
+	CMTPObjectMetaData* objectMetaData  = CMTPObjectMetaData::NewL();
+	CleanupStack::PushL(objectMetaData);
+	TUint32 lastHandle = 0;
+	MMTPSvcObjectHandler* lastHandler = NULL; 
+	TUint errIndex = 0; // Index number for each segment with the same object handle.
+	TUint i;
+	for (i = 0; i < count; i++)
+		{
+		CMTPTypeObjectPropListElement& element = aObjectPropList.GetNextElementL();
+		TUint32 handle = element.Uint32L(CMTPTypeObjectPropListElement::EObjectHandle);	
+		if (!iFramework.ObjectMgr().ObjectL(handle, *objectMetaData))
+			{
+			responseCode = EMTPRespCodeInvalidObjectHandle;
+			}
+		else
+			{
+			TUint16 formatCode = objectMetaData->Uint(CMTPObjectMetaData::EFormatCode);
+			const TDesC& suid = objectMetaData->DesC(CMTPObjectMetaData::ESuid);
+			MMTPSvcObjectHandler* pHandler = iDataProvider.ObjectHandler(formatCode);
+			if (pHandler)
+				{
+				// If the handler is not the last handle, need commit all properties now
+				if (lastHandle != 0 && lastHandler && lastHandle != handle)
+					{
+					TRAPD(err, lastHandler->CommitL());
+					if (KErrNone != err)
+						{
+						lastHandler->RollBack();
+						responseCode = EMTPRespCodeInvalidObjectHandle;
+						aParameter = errIndex;
+						break;
+						}
+					// Record the next segment's first index number
+					errIndex = i;
+					}
+				lastHandler = pHandler;
+				lastHandle = handle;
+				responseCode = pHandler->SetObjectPropertyL(suid, element, EMTPOpCodeSetObjectPropList);
+				}
+			else
+				{
+				responseCode = EMTPRespCodeInvalidObjectHandle;
+				}
+			}
+		if (responseCode != EMTPRespCodeOK)
+			{
+			aParameter = i;
+			// All properties prior to the failed property will be updated.
+			if (i != errIndex && lastHandler)
+				{
+				TRAPD(err, lastHandler->CommitL());
+				if (KErrNone != err)
+					{
+					lastHandler->RollBack();
+					aParameter = errIndex;
+					}
+				}
+			break;
+			}
+		}
+	// Commit all correct properties.
+	if (responseCode == EMTPRespCodeOK && lastHandler)
+		{
+		TRAPD(err, lastHandler->CommitL());
+		if (KErrNone != err)
+			{
+			lastHandler->RollBack();
+			responseCode = EMTPRespCodeInvalidObjectHandle;
+			aParameter = errIndex;
+			}
+		}
+	CleanupStack::PopAndDestroy(objectMetaData);
+	__FLOG_VA((_L8("SetObjectPropListL - Exit with responseCode = 0x%04X"), responseCode));
+	return responseCode;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcsetreferences.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,158 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcsetreferences.cpp
+
+
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mmtpreferencemgr.h>
+#include <mtp/mtpdatatypeconstants.h>
+
+#include "cmtpsvcsetreferences.h"
+#include "mmtpservicedataprovider.h"
+#include "mmtpsvcobjecthandler.h"
+
+__FLOG_STMT(_LIT8(KComponent,"SvcSetRef");)
+
+EXPORT_C MMTPRequestProcessor* CMTPSvcSetReferences::NewL(MMTPDataProviderFramework& aFramework, 
+												MMTPConnection& aConnection, 
+												MMTPServiceDataProvider& aDataProvider)
+	{
+	CMTPSvcSetReferences* self = new (ELeave) CMTPSvcSetReferences(aFramework, aConnection, aDataProvider);
+	return self;
+	}
+
+EXPORT_C CMTPSvcSetReferences::~CMTPSvcSetReferences()
+	{
+	__FLOG(_L8("~CMTPSvcGetReferences - Entry"));
+	delete iReferences;
+	delete iReceivedObjectMetaData;
+	__FLOG(_L8("~CMTPSvcGetReferences - Exit"));
+	__FLOG_CLOSE; 
+	}
+
+/**
+Standard c++ constructor
+*/    
+CMTPSvcSetReferences::CMTPSvcSetReferences(MMTPDataProviderFramework& aFramework, 
+										MMTPConnection& aConnection, 
+										MMTPServiceDataProvider& aDataProvider) :
+	CMTPRequestProcessor(aFramework, aConnection, 0, NULL), 
+	iDataProvider(aDataProvider)
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("Constructed"));
+	}
+
+/**
+SetReferences request handler
+start receiving reference data from the initiator
+*/
+void CMTPSvcSetReferences::ServiceL()
+	{
+	__FLOG(_L8("ServiceL - Entry"));
+	delete iReferences;
+	iReferences = NULL;
+	iReferences = CMTPTypeArray::NewL(EMTPTypeAUINT32);
+	ReceiveDataL(*iReferences);
+	__FLOG(_L8("ServiceL - Exit"));
+	}
+
+TBool CMTPSvcSetReferences::DoHandleResponsePhaseL()
+	{
+	__FLOG(_L8("DoHandleResponsePhaseL - Entry"));
+	if(!VerifyReferenceHandlesL())
+		{
+		SendResponseL(EMTPRespCodeInvalidObjectReference);
+		}
+	else
+		{
+		TUint16 formatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode);
+		TMTPResponseCode responseCode = EMTPRespCodeOK;
+		responseCode = (iDataProvider.ObjectHandler(formatCode))->SetObjectReferenceL(*iReceivedObjectMetaData, *iReferences);
+		SendResponseL(responseCode);
+		}
+	__FLOG(_L8("DoHandleResponsePhaseL - Exit"));
+	return EFalse;
+	}
+
+TBool CMTPSvcSetReferences::HasDataphase() const
+	{
+	return ETrue;
+	}
+
+TBool CMTPSvcSetReferences::VerifyReferenceHandlesL() const
+	{
+	__FLOG(_L8("VerifyReferenceHandlesL - Entry"));
+	__ASSERT_DEBUG(iReferences, User::Invariant());
+	TBool result = ETrue;
+	TInt count = iReferences->NumElements();
+	CMTPObjectMetaData* object = CMTPObjectMetaData::NewLC();
+	MMTPObjectMgr& objectMgr = iFramework.ObjectMgr();
+	for(TInt i = 0; i < count; i++)
+		{
+		TMTPTypeUint32 handle;
+		iReferences->ElementL(i, handle);
+		if(!objectMgr.ObjectL(handle, *object))
+			{
+			result = EFalse;
+			break;
+			}
+		}
+	CleanupStack::PopAndDestroy(object);
+	__FLOG(_L8("VerifyReferenceHandlesL - Exit"));
+	return result;
+	}
+
+TMTPResponseCode CMTPSvcSetReferences::CheckRequestL()
+	{
+	__FLOG(_L8("CheckRequestL - Entry"));
+
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	if (EMTPRespCodeOK == responseCode)
+		{
+		TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+		iReceivedObjectMetaData = CMTPObjectMetaData::NewL();
+		// Check object handle
+		MMTPObjectMgr& objMgr(iFramework.ObjectMgr());
+		// Check whether object handle is valid
+		if (objMgr.ObjectL(objectHandle, *iReceivedObjectMetaData))
+			{
+			// Check whether the owner of this object is correct data provider
+			if (iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EDataProviderId) != iFramework.DataProviderId())
+				{
+				responseCode = EMTPRespCodeInvalidObjectHandle;
+				__FLOG(_L8("CheckRequestL - DataProviderId dismatch"));
+				}
+			else
+				{
+				// Check format code
+				TUint16 formatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode);
+				if (!iDataProvider.ObjectHandler(formatCode))
+					{
+					responseCode = EMTPRespCodeInvalidObjectHandle;
+					}
+				}
+			}
+		else
+			{
+			responseCode = EMTPRespCodeInvalidObjectHandle;
+			}
+		}
+	__FLOG_VA((_L8("CheckRequestL - Exit with code: 0x%04X"), responseCode));
+	return responseCode;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcsetserviceproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,109 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetserviceproplist.cpp
+
+#include "cmtpsvcsetserviceproplist.h"
+#include "mmtpservicedataprovider.h"
+#include "mmtpservicehandler.h"
+
+__FLOG_STMT (_LIT8(KComponent, "SvcSetSvcPList");)
+
+EXPORT_C MMTPRequestProcessor* CMTPSvcSetServicePropList::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider)
+	{
+	CMTPSvcSetServicePropList* self = new (ELeave) CMTPSvcSetServicePropList(aFramework, aConnection, aDataProvider);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CMTPSvcSetServicePropList::~CMTPSvcSetServicePropList()
+	{
+	__FLOG(_L8("~CMTPSvcSetServicePropList - Entry"));
+	delete iServicePropList;
+	__FLOG(_L8("~CMTPSvcSetServicePropList - Exit"));
+	__FLOG_CLOSE;
+	}
+ 
+CMTPSvcSetServicePropList::CMTPSvcSetServicePropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider) :
+	CMTPRequestProcessor(aFramework, aConnection, 0, NULL), iDataProvider(aDataProvider)
+	{	
+	}
+
+void CMTPSvcSetServicePropList::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry")); 
+	iServicePropList = CMTPTypeServicePropList::NewL();
+	__FLOG(_L8("ConstructL - Exit")); 
+	}
+
+TMTPResponseCode CMTPSvcSetServicePropList::CheckRequestL()
+{
+	__FLOG(_L8("CheckRequestL - Entry"));
+	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
+	if (EMTPRespCodeOK == responseCode)
+		{
+		TUint32 serviceId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+		if (serviceId != iDataProvider.ServiceID())
+			{
+			responseCode = EMTPRespCodeInvalidServiceID;
+			}
+		}
+
+	__FLOG_VA((_L8("CheckRequestL - Exit with responseCode = 0x%04X"), responseCode));
+	return responseCode;
+}
+
+void CMTPSvcSetServicePropList::ServiceL()
+	{
+	__FLOG(_L8("ServiceL - Entry"));
+	//Recieve the data from the property list
+	ReceiveDataL(*iServicePropList);
+	__FLOG(_L8("ServiceL - Exit"));
+	}
+
+TBool CMTPSvcSetServicePropList::DoHandleResponsePhaseL()
+	{
+	__FLOG(_L8("DoHandleResponsePhaseL - Entry")); 
+	TUint32 parameter = 0;
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	const TUint count = iServicePropList->NumberOfElements();
+	for (TUint i = 0; i < count && responseCode == EMTPRespCodeOK; i++)
+		{
+		CMTPTypeServicePropListElement& element = iServicePropList->Element(i);
+		
+		if(iDataProvider.ServiceID() != element.Uint32L(CMTPTypeServicePropListElement::EObjectHandle))
+			{
+			parameter = i;
+			responseCode = EMTPRespCodeInvalidServiceID;
+			break;
+			}
+
+		responseCode = (iDataProvider.ServiceHandler())->SetServicePropertyL(element);
+		if (EMTPRespCodeOK != responseCode)
+			{
+			parameter = i;
+			break;
+			}
+		}
+	SendResponseL(responseCode, 1, &parameter);
+	__FLOG_VA((_L8("DoHandleResponsePhaseL - Exit with responseCode = 0x%04X and failed index: %u"), responseCode, parameter));
+	return EFalse;
+	}
+
+TBool CMTPSvcSetServicePropList::HasDataphase() const
+	{
+	return ETrue;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/mmtpservicedataprovider.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,39 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/mmtpservicedataprovider.cpp
+
+#include <mtp/mmtptype.h>
+
+#include "mmtpservicedataprovider.h"
+
+EXPORT_C MMTPServiceHandler* MMTPServiceDataProvider::ServiceHandler() const
+	{
+	return NULL;
+	}
+
+EXPORT_C TBool MMTPServiceDataProvider::IsValidServicePropCodeL(TUint16 /*aPropCode*/) const
+	{
+	return EFalse;
+	}
+
+EXPORT_C TUint32 MMTPServiceDataProvider::ServiceID() const
+	{
+	return 0;
+	}
+
+EXPORT_C TUint32 MMTPServiceDataProvider::OperationGranularity() const
+	{
+	// Default granularity of delete object and get object property is 50
+	return 50;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/mmtpservicehandler.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,242 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/mmtpservicehandler.cpp
+
+#include <centralrepository.h>
+#include <mtp/cmtptypeserviceobjpropextnform.h>
+
+#include "mmtpservicehandler.h"
+
+
+
+// Some form need to destroy before the property push to stack.
+EXPORT_C CMTPTypeObjectPropDesc* MMTPServiceHandler::GenerateSvcObjPropertyL(
+	TUint aDataType, const TMTPTypeGuid& aPKNamespace, TUint aPKID, const TDesC& aName,
+	TUint8 aFormFlag, const MMTPType* aForm, CMTPTypeObjectPropDesc::TMTPObjectPropDescGetSet aObjGetSet,
+	TUint16 aObjPropCode, TUint32 aGroupCode)
+	{
+	CMTPTypeServiceObjPropExtnForm* serviceObjectForm
+	= CMTPTypeServiceObjPropExtnForm::NewLC(aDataType, aPKNamespace, aPKID,
+											aName, aFormFlag, aForm);
+	CMTPTypeObjectPropDesc::TPropertyInfo info;
+	info.iDataType     = aDataType;
+	info.iFormFlag     = CMTPTypeObjectPropDesc::EServiceObjPropExtnForm;
+	info.iGetSet       = aObjGetSet;
+	CMTPTypeObjectPropDesc* pObjectProperty
+	= CMTPTypeObjectPropDesc::NewL(aObjPropCode, info, serviceObjectForm);
+	pObjectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode, aGroupCode);
+	// Form pointer is special and need to be deleted by caller.
+	CleanupStack::PopAndDestroy(serviceObjectForm);
+	return pObjectProperty;
+	}
+
+EXPORT_C CMTPTypeObjectPropDesc* MMTPServiceHandler::GenerateSvcObjPropertyLC(
+	TUint aDataType, const TMTPTypeGuid&  aPKNamespace, TUint aPKID, const TDesC& aName,
+	TUint8 aFormFlag, const MMTPType* aForm, CMTPTypeObjectPropDesc::TMTPObjectPropDescGetSet aObjGetSet,
+	TUint16 aObjPropCode, TUint32 aGroupCode)
+	{
+	CMTPTypeObjectPropDesc* pObjectProperty = NULL;
+	pObjectProperty = GenerateSvcObjPropertyL(aDataType, aPKNamespace, aPKID, aName, aFormFlag, aForm, aObjGetSet, aObjPropCode, aGroupCode);
+	CleanupStack::PushL(pObjectProperty);
+	return pObjectProperty;
+	}
+
+EXPORT_C TMTPResponseCode MMTPServiceHandler::SaveServicePropValue(
+	CRepository& aRepository, TUint aColumnNum, TInt aNewData)
+	{
+	TInt ret;
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	ret = aRepository.Set(aColumnNum, aNewData);
+	if (KErrNone != ret)
+		{
+		responseCode = EMTPRespCodeGeneralError;
+		}
+	return responseCode;
+	}
+
+EXPORT_C TMTPResponseCode MMTPServiceHandler::SaveServicePropValue(
+	CRepository& aRepository, TUint aColumnNum, TMTPTypeGuid& aNewData)
+	{
+	TInt ret;
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	TBuf8<KMTPTypeINT128Size>  data;
+	data.FillZ(data.MaxLength());
+	TUint64 upperValue = aNewData.UpperValue();
+	TUint64 lowerValue = aNewData.LowerValue();
+
+	/**
+	Least significant 64-bit buffer offset.
+	*/
+	const TInt           KMTPTypeUint128OffsetLS = 0;
+	/**
+	Most significant 64-bit buffer offset.
+	*/
+	const TInt           KMTPTypeUint128OffsetMS = 8;
+
+	memcpy(&data[KMTPTypeUint128OffsetMS], &upperValue, sizeof(upperValue));
+	memcpy(&data[KMTPTypeUint128OffsetLS], &lowerValue, sizeof(lowerValue));
+
+	ret = aRepository.Set(aColumnNum, data);
+	if (KErrNone != ret)
+		{
+		responseCode = EMTPRespCodeGeneralError;
+		}
+	return responseCode;
+	}
+
+EXPORT_C CMTPTypeObjectPropDesc* MMTPServiceHandler::GenerateGenericObjectPropDescLC(TUint16 aObjPropCode)
+	{
+	const TMTPTypeGuid KMTPGenObjPropNamespaceGUID(
+		MAKE_TUINT64(KMTPGenericObjectNSGUID[0], KMTPGenericObjectNSGUID[1]),
+		MAKE_TUINT64(KMTPGenericObjectNSGUID[2], KMTPGenericObjectNSGUID[3]));
+	const TMTPTypeGuid KMTPSyncObjPropNamespace(
+		MAKE_TUINT64(KMTPSyncObjcetNSGUID[0], KMTPSyncObjcetNSGUID[1]),
+		MAKE_TUINT64(KMTPSyncObjcetNSGUID[2], KMTPSyncObjcetNSGUID[3]));
+
+	CMTPTypeObjectPropDesc* objectProperty = NULL;
+	TMTPTypeUint32 longStringForm(KLongStringMaxLength);
+
+	switch (aObjPropCode)
+		{
+			/* Generic Ojbect Namespace properties */
+			// Parent Object
+		case EMTPGenObjPropCodeParentID:
+			{
+			objectProperty = MMTPServiceHandler::GenerateSvcObjPropertyLC(
+					EMTPTypeUINT32, KMTPGenObjPropNamespaceGUID, 3, KObjPropNameParentID, 
+					CMTPTypeObjectPropDesc::ENone, NULL, CMTPTypeObjectPropDesc::EReadOnly, 
+					EMTPGenObjPropCodeParentID, 0x2);
+			break;
+			}
+
+		// Name
+		case EMTPGenObjPropCodeName:
+			{
+			objectProperty = MMTPServiceHandler::GenerateSvcObjPropertyLC(
+					EMTPTypeString, KMTPGenObjPropNamespaceGUID, 4, KObjPropNameName, 
+					CMTPTypeObjectPropDesc::ENone, NULL, CMTPTypeObjectPropDesc::EReadOnly, 
+					EMTPGenObjPropCodeName, 0x5);
+			break;
+			}
+
+		// Unique Object Identifier
+		case EMTPGenObjPropCodePersistentUniqueObjectIdentifier:
+			{
+			objectProperty = MMTPServiceHandler::GenerateSvcObjPropertyLC(
+					EMTPTypeUINT128, KMTPGenObjPropNamespaceGUID, 5, KObjPropNamePUOID, 
+					CMTPTypeObjectPropDesc::ENone, NULL, CMTPTypeObjectPropDesc::EReadOnly, 
+					EMTPGenObjPropCodePersistentUniqueObjectIdentifier, 0x2);
+			break;
+			}
+
+		// Format Code
+		case EMTPGenObjPropCodeObjectFormat:
+			{
+			objectProperty = MMTPServiceHandler::GenerateSvcObjPropertyLC(
+					EMTPTypeUINT16, KMTPGenObjPropNamespaceGUID, 6, KObjPropNameObjectFormat, 
+					CMTPTypeObjectPropDesc::ENone, NULL, CMTPTypeObjectPropDesc::EReadOnly, 
+					EMTPGenObjPropCodeObjectFormat, 0x2);
+			break;
+			}
+
+		// Object Size
+		case EMTPGenObjPropCodeObjectSize:
+			{
+			objectProperty = MMTPServiceHandler::GenerateSvcObjPropertyLC(
+					EMTPTypeUINT64, KMTPGenObjPropNamespaceGUID, 11, KObjPropNameObjectSize, 
+					CMTPTypeObjectPropDesc::ENone, NULL, CMTPTypeObjectPropDesc::EReadOnly, 
+					EMTPGenObjPropCodeObjectSize, 0x2);
+			break;
+			}
+
+		//Storage ID
+		case EMTPGenObjPropCodeStorageID:
+			{
+			objectProperty = MMTPServiceHandler::GenerateSvcObjPropertyLC(
+					EMTPTypeUINT32, KMTPGenObjPropNamespaceGUID, 23, KObjPropNameStorageID, 
+					CMTPTypeObjectPropDesc::ENone, NULL, CMTPTypeObjectPropDesc::EReadOnly,
+					EMTPGenObjPropCodeStorageID, 0x2);
+			break;
+			}
+
+		// Object Hidden
+		case EMTPGenObjPropCodeObjectHidden:
+			{
+			CMTPTypeObjectPropDescEnumerationForm* hiddenForm
+			= CMTPTypeObjectPropDescEnumerationForm::NewLC(EMTPTypeUINT16);
+			TUint16 values[] = {0x0000, 0x0001};
+			TUint numValues((sizeof(values) / sizeof(values[0])));
+			for (TUint i = 0; i < numValues; i++)
+				{
+				TMTPTypeUint16 data(values[i]);
+				hiddenForm->AppendSupportedValueL(data);
+				}
+			objectProperty = MMTPServiceHandler::GenerateSvcObjPropertyL(
+					EMTPTypeUINT16, KMTPGenObjPropNamespaceGUID, 28, KObjPropNameHidden,
+					CMTPTypeObjectPropDesc::EEnumerationForm, hiddenForm, 
+					CMTPTypeObjectPropDesc::EReadOnly, EMTPGenObjPropCodeObjectHidden, 0x2);
+			CleanupStack::PopAndDestroy(hiddenForm);
+			CleanupStack::PushL(objectProperty);
+			break;
+			}
+
+		// NonConsumable
+		case EMTPGenObjPropCodeNonConsumable:
+			{
+			CMTPTypeObjectPropDescEnumerationForm* nonConsumeForm
+			= CMTPTypeObjectPropDescEnumerationForm::NewLC(EMTPTypeUINT8);
+			TUint8 values[] = {0x00, 0x01};
+			TUint numValues((sizeof(values) / sizeof(values[0])));
+			for (TUint i = 0; i < numValues; i++)
+				{
+				TMTPTypeUint8 data(values[i]);
+				nonConsumeForm->AppendSupportedValueL(data);
+				}
+			objectProperty = MMTPServiceHandler::GenerateSvcObjPropertyL(
+					EMTPTypeUINT8, KMTPGenObjPropNamespaceGUID, 13, KObjPropNameNonConsumable, 
+					CMTPTypeObjectPropDesc::EEnumerationForm, nonConsumeForm,
+					CMTPTypeObjectPropDesc::EReadOnly, EMTPGenObjPropCodeNonConsumable, 0x2);
+			CleanupStack::PopAndDestroy(nonConsumeForm);
+			CleanupStack::PushL(objectProperty);
+			break;
+			}
+
+		// Date Modified
+		case EMTPGenObjPropCodeDateModified:
+			{
+			objectProperty = MMTPServiceHandler::MMTPServiceHandler::GenerateSvcObjPropertyLC(
+					EMTPTypeString, KMTPGenObjPropNamespaceGUID, 40, KObjPropNameDateModified, 
+					CMTPTypeObjectPropDesc::EDateTimeForm, NULL, CMTPTypeObjectPropDesc::EReadWrite, 
+					EMTPGenObjPropCodeDateModified, 0x2);
+			break;
+			}
+
+		case EMTPSvcObjPropCodeLastAuthorProxyID :
+			{
+			objectProperty = MMTPServiceHandler::GenerateSvcObjPropertyLC(
+					EMTPTypeUINT128, KMTPSyncObjPropNamespace, 2, KObjPropNameLastAuthorProxyID, 
+					CMTPTypeObjectPropDesc::ENone, NULL, CMTPTypeObjectPropDesc::EReadWrite, 
+					EMTPSvcObjPropCodeLastAuthorProxyID, 0x2);
+
+			break;
+			}
+		//Error
+		default:
+			{
+			// Internal error, get wrong object property, just ignore the property
+			break;
+			}
+		} // End of switch
+	return objectProperty;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/mmtpsvcobjecthandler.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,205 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/mmtpsvcobjecthandler.cpp
+
+#include <mtp/mmtptype.h>
+
+#include <mtp/cmtptypeobjectproplist.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include "mmtpsvcobjecthandler.h"
+#include "mtpsvcdpconst.h"
+
+EXPORT_C TMTPResponseCode MMTPSvcObjectHandler::SendObjectInfoL(const CMTPTypeObjectInfo& /*aObjectInfo*/, TUint32& /*aParentHandle*/, TDes& /*aSuid*/)
+	{
+	return EMTPRespCodeOperationNotSupported;
+	}
+
+EXPORT_C TMTPResponseCode MMTPSvcObjectHandler::GetObjectInfoL(const CMTPObjectMetaData& /*aObjectMetaData*/, CMTPTypeObjectInfo& /*aObjectInfo*/)
+	{
+	return EMTPRespCodeOperationNotSupported;
+	}
+
+EXPORT_C TMTPResponseCode MMTPSvcObjectHandler::SetObjectReferenceL(const CMTPObjectMetaData& /*aObjectMetaData*/, const CMTPTypeArray& /*aReferences*/)
+	{
+	return EMTPRespCodeOperationNotSupported;
+	}
+
+EXPORT_C TMTPResponseCode MMTPSvcObjectHandler::GetObjectReferenceL(const CMTPObjectMetaData& /*aObjectMetaData*/, CMTPTypeArray& /*aReferences*/)
+	{
+	return EMTPRespCodeOperationNotSupported;
+	}
+
+EXPORT_C TMTPResponseCode MMTPSvcObjectHandler::CopyObject(const CMTPObjectMetaData& /*aObjectMetaData*/, TUint32 /*aDestStorageId*/, TUint32 /*aNewParentHandle*/)
+	{
+	return EMTPRespCodeOperationNotSupported;
+	}
+
+EXPORT_C TMTPResponseCode MMTPSvcObjectHandler::MoveObject(const CMTPObjectMetaData& /*aObjectMetaData*/, TUint32 /*aDestStorageId*/, TUint32 /*aNewParentHandle*/)
+	{
+	return EMTPRespCodeOperationNotSupported;
+	}
+
+EXPORT_C void MMTPSvcObjectHandler::CommitL()
+	{
+	
+	}
+
+EXPORT_C void MMTPSvcObjectHandler::CommitForNewObjectL(TDes& /*aSuid*/)
+	{
+	
+	}
+
+EXPORT_C void MMTPSvcObjectHandler::RollBack()
+	{
+	
+	}
+
+EXPORT_C void MMTPSvcObjectHandler::ReleaseObjectBuffer()
+	{
+	
+	}
+
+EXPORT_C TMTPResponseCode MMTPSvcObjectHandler::CheckGenObjectPropertyL(const CMTPTypeObjectPropListElement& element, TMTPOperationCode aOperationCode) const
+	{
+	TMTPResponseCode responseCode = EMTPRespCodeOK;
+	TUint16 propertyCode = element.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode);
+	TUint16 dataType = element.Uint16L(CMTPTypeObjectPropListElement::EDatatype);
+	// If create new object request, then only SendObjectPropList will call this function
+	switch (propertyCode)
+		{
+		//Access denied Properties, if not for new object purpose , should response access denied.
+		case EMTPGenObjPropCodeParentID:
+		case EMTPGenObjPropCodeStorageID:
+		case EMTPGenObjPropCodeObjectFormat:
+		case EMTPGenObjPropCodeObjectSize:
+			{
+			// Properties which are contained in the operation parameters (StorageID, ParentObject, 
+			// ObjectFormat, ObjectSize) should not be included in the sent dataset for SendObjectPropList
+			if (EMTPOpCodeSendObjectPropList == aOperationCode)
+				{
+				responseCode = EMTPRespCodeInvalidDataset;
+				break;
+				}
+			
+			if(EMTPOpCodeUpdateObjectPropList != aOperationCode)
+				{
+				responseCode = EMTPRespCodeAccessDenied;
+				break;
+				}
+
+			//EMTPOpCodeUpdateObjectPropList == aOperationCode
+			if(EMTPGenObjPropCodeParentID == propertyCode)
+				{
+				if (dataType != EMTPTypeUINT32)
+					{
+					responseCode = EMTPRespCodeInvalidObjectPropFormat;
+					}
+				}
+			else if(EMTPGenObjPropCodeObjectSize == propertyCode)
+				{
+				if (dataType != EMTPTypeUINT64)
+					{
+					responseCode = EMTPRespCodeInvalidObjectPropFormat;
+					}
+				}
+			else
+				{
+				if (dataType != EMTPTypeUINT16)
+					{
+					responseCode = EMTPRespCodeInvalidObjectPropFormat;
+					}
+				}
+			break;
+			}
+		case EMTPGenObjPropCodeName:
+			{
+			if (aOperationCode == EMTPOpCodeSetObjectPropList)
+				{
+				responseCode = EMTPRespCodeAccessDenied;
+				break;
+				}
+			
+			if (dataType != EMTPTypeString)
+				{
+				responseCode = EMTPRespCodeInvalidObjectPropFormat;
+				}
+			break;
+			}
+		case EMTPGenObjPropCodePersistentUniqueObjectIdentifier:
+			{
+			// PC should not set this prop.
+			responseCode = EMTPRespCodeAccessDenied;
+			break;
+			}
+		case EMTPGenObjPropCodeObjectHidden:
+			{
+			if (aOperationCode == EMTPOpCodeSetObjectPropList)
+				{
+				// RO prop can't be changed.
+				responseCode = EMTPRespCodeAccessDenied;
+				break;
+				}
+
+			if (dataType != EMTPTypeUINT16)
+				{
+				responseCode = EMTPRespCodeInvalidObjectPropFormat;
+				}
+			break;
+			}
+		case EMTPGenObjPropCodeDateModified:
+			{
+			if (dataType != EMTPTypeString)
+				{
+				responseCode = EMTPRespCodeInvalidObjectPropFormat;
+				}
+			break;
+			}
+		case EMTPObjectPropCodeNonConsumable:
+			{
+			if (aOperationCode == EMTPOpCodeSetObjectPropList)
+				{
+				responseCode = EMTPRespCodeAccessDenied;
+				break;
+				}
+
+			if (dataType != EMTPTypeUINT8)
+				{
+				responseCode = EMTPRespCodeInvalidObjectPropFormat;
+				break;
+				}
+			
+			// Knowledge object must be non consumable
+			if (0x01 != element.Uint8L(CMTPTypeObjectPropListElement::EValue))
+				{
+				responseCode = EMTPRespCodeInvalidObjectPropValue;
+				}
+			break;
+			}
+		case EMTPSvcObjPropCodeLastAuthorProxyID:
+			{
+			if (dataType != EMTPTypeUINT128)
+				{
+				responseCode = EMTPRespCodeInvalidObjectPropFormat;
+				}
+			break;
+			}
+		default:
+			{
+			// Conform with enhanced spec, but DeleteObjectPropList return invalidpropcode
+			responseCode = EMTPRespCodeObjectPropNotSupported;
+			break;
+			}
+		}
+	return responseCode;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/rmtpdpsingletons.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,157 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "rmtpdpsingletons.h"
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/cmtpobjectmetadata.h>
+
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"DataProviderSingletons");)
+
+/**
+Constructor.
+*/
+EXPORT_C RMTPDpSingletons::RMTPDpSingletons() :
+    iSingletons(NULL)
+    {
+    }
+
+/**
+Opens the singletons reference.
+*/
+EXPORT_C void RMTPDpSingletons::OpenL(MMTPDataProviderFramework& aFramework)
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("OpenL - Entry"));
+    iFramework = &aFramework;
+    iSingletons = &CSingletons::OpenL(aFramework);
+    __FLOG(_L8("OpenL - Exit"));
+    }
+    
+/**
+Closes the singletons reference.
+*/
+EXPORT_C void RMTPDpSingletons::Close()
+    {
+    __FLOG(_L8("Close - Entry"));
+    if (iSingletons)
+        {
+        iSingletons->Close();
+        iSingletons = NULL;
+        }
+    __FLOG(_L8("Close - Exit"));
+    __FLOG_CLOSE;
+    }
+
+
+/**
+This method finds the specific data provider's file system exclusion manager based on the 
+DP ID and returns it.
+@return the calling data provider's file system exclusion manager
+*/	
+EXPORT_C CMTPFSExclusionMgr& RMTPDpSingletons::ExclusionMgrL() const
+	{
+	TExclusionMgrEntry entry = { 0, iFramework->DataProviderId() };
+	TInt index = iSingletons->iExclusionList.FindInOrderL(entry, TLinearOrder<TExclusionMgrEntry>(TExclusionMgrEntry::Compare));
+	return *(iSingletons->iExclusionList[index].iExclusionMgr);
+	}
+
+/**
+Inserts the calling data provider's file system exclusion manager to an ordered list 
+based on the the DP ID.
+@param aExclusionMgr a reference to a data provider's file system exclusion manager.
+*/	
+EXPORT_C void RMTPDpSingletons::SetExclusionMgrL(CMTPFSExclusionMgr& aExclusionMgr)
+	{
+	TExclusionMgrEntry entry = { &aExclusionMgr, iFramework->DataProviderId() };
+	iSingletons->iExclusionList.InsertInOrderL(entry, TLinearOrder<TExclusionMgrEntry>(TExclusionMgrEntry::Compare));
+	}
+
+TInt RMTPDpSingletons::TExclusionMgrEntry::Compare(const TExclusionMgrEntry& aFirst, const TExclusionMgrEntry& aSecond)
+	{
+	return (aFirst.iDpId - aSecond.iDpId);
+	}
+ 
+RMTPDpSingletons::CSingletons* RMTPDpSingletons::CSingletons::NewL(MMTPDataProviderFramework& aFramework)
+    {
+    CSingletons* self(new(ELeave) CSingletons());
+    CleanupStack::PushL(self);
+    self->ConstructL(aFramework);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+RMTPDpSingletons::CSingletons& RMTPDpSingletons::CSingletons::OpenL(MMTPDataProviderFramework& aFramework)
+    {
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("CSingletons::OpenL - Entry"));
+    CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
+    if (!self)
+        {
+        self = CSingletons::NewL(aFramework);
+        Dll::SetTls(reinterpret_cast<TAny*>(self));
+        }
+    else
+        {        
+        self->Inc();
+        }
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("CSingletons::OpenL - Exit"));
+    return *self;
+    }
+    
+void RMTPDpSingletons::CSingletons::Close()
+    {
+    CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
+    if (self)
+        {
+        __FLOG(_L8("CSingletons::Close - Entry"));
+        self->Dec();
+        if (self->AccessCount() == 0)
+            {
+            __FLOG(_L8("CSingletons::Close - Exit"));
+            delete self;
+            Dll::SetTls(NULL);
+            }
+        else
+            {
+            __FLOG(_L8("CSingletons::Close - Exit"));
+            }
+        }
+    }
+    
+RMTPDpSingletons::CSingletons::~CSingletons()
+    {
+    __FLOG(_L8("CSingletons::~CSingletons - Entry"));
+    iExclusionList.Close();
+    iMTPUtility.Close();
+    __FLOG(_L8("CSingletons::~CSingletons - Exit"));
+    __FLOG_CLOSE;
+    }
+    
+void RMTPDpSingletons::CSingletons::ConstructL(MMTPDataProviderFramework& aFramework)
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("CSingletons::ConstructL - Entry"));
+    
+    iMTPUtility.OpenL(aFramework);
+    
+    __FLOG(_L8("CSingletons::ConstructL - Exit"));
+    }
+
+EXPORT_C RMTPUtility& RMTPDpSingletons::MTPUtility() const
+	{
+	return iSingletons->iMTPUtility;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/rmtputility.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,643 @@
+
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <bautils.h>
+#include <f32file.h>
+#include <e32math.h>
+#include <e32def.h>
+#include <caf/content.h>
+
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/cmtpdataproviderplugin.h>
+
+#include "rmtputility.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpextensionmapping.h"
+#include "cmtpdataprovider.h"
+
+using namespace ContentAccess;
+// Class constants.
+const TInt KMTPDateStringLength = 15;
+const TInt KMTPDateStringTIndex = 8;
+const TInt KMimeTypeMaxLength = 76;
+const TInt KMAXPackageIDStringLen = 32;
+
+_LIT( KTxtBackSlash, "\\" );
+    
+_LIT( KTxtExtensionODF, ".odf" );
+    
+_LIT( KMimeTypeAudio3gpp, "audio/3gpp" );
+_LIT( KMimeTypeVideo3gpp, "video/3gpp" );
+_LIT( KMimeTypeAudioMp4, "audio/mp4" );
+_LIT( KMimeTypeVideoMp4, "video/mp4" );
+
+__FLOG_STMT(_LIT8(KComponent,"RMTPUtility");)
+
+RMTPUtility::RMTPUtility():
+	iFramework(NULL)
+	{
+	}
+
+void RMTPUtility::OpenL(MMTPDataProviderFramework& aFramework)
+	{
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("OpenL - Entry"));
+    
+	iFramework = &aFramework;
+	iSingleton.OpenL();
+	
+    __FLOG(_L8("OpenL - Exit"));
+	}
+
+void RMTPUtility::Close()
+	{
+	iSingleton.Close();
+	iFramework = NULL;
+	iFormatMappings.ResetAndDestroy();
+	__FLOG_CLOSE;
+	}
+
+/*
+ * Convert the TTime to the MTP datatime string
+ * 
+ * 	MTP datatime string format: YYYYMMDDThhmmss.s  Optional(.s)
+ *  TTime string format       : YYYYMMDD:HHMMSS.MMMMMM
+ *  
+ */
+EXPORT_C TBool  RMTPUtility::TTime2MTPTimeStr(const TTime& aTime, TDes& aRet ) const
+	{
+	_LIT(KMTPDateStringFormat,"%F%Y%M%DT%H%T%S");		
+	TRAPD(err, aTime.FormatL(aRet,KMTPDateStringFormat));
+	if(err == KErrNone)
+		{
+		return ETrue;
+		}
+	else
+		{
+		return EFalse;
+		}
+	}
+
+/*
+ * Convert the MTP datatime string to TTime:
+ * 
+ * 	MTP datatime string format: YYYYMMDDThhmmss.s  Optional(.s)
+ *  TTime string format       : YYYYMMDD:HHMMSS.MMMMMM
+ *  
+ */
+EXPORT_C TBool RMTPUtility::MTPTimeStr2TTime(const TDesC& aTimeString, TTime& aRet) const
+	{
+    __FLOG(_L8("ConvertMTPTimeStr2TTimeL - Entry"));
+
+	TBool result = EFalse;
+	TInt year = 0;
+	TMonth month = EJanuary;
+	TInt day = 0;
+	TInt hour = 0;
+	TInt minute  = 0;
+	TInt second = 0;
+	TInt tenthSecond = 0;
+	TBool positiveTimeZone = ETrue;
+	TInt timeZoneInHour = 0;
+	TInt timeZoneInMinute = 0;
+
+    const TChar KCharT = 'T';
+	if( aTimeString.Length() >= KMTPDateStringLength && ( aTimeString.Locate(KCharT) == KMTPDateStringTIndex ) && GetYear(aTimeString, year) && GetMonth(aTimeString, month) && 
+		GetDay(aTimeString, day) && GetHour(aTimeString, hour) && GetMinute(aTimeString, minute) && 
+		GetSecond(aTimeString, second) && GetTenthSecond(aTimeString, tenthSecond) && GetTimeZone(aTimeString, positiveTimeZone, timeZoneInHour, timeZoneInMinute))
+		{
+		TDateTime dateTime(year, month, day, hour, minute, second, tenthSecond * 100000);
+		
+		TTime dateTimeInTTime(dateTime);
+		if(positiveTimeZone)
+			{
+			dateTimeInTTime += TTimeIntervalHours(timeZoneInHour);
+			dateTimeInTTime += TTimeIntervalMinutes(timeZoneInMinute);
+			}
+		else
+			{
+			dateTimeInTTime -= TTimeIntervalHours(timeZoneInHour);
+			dateTimeInTTime -= TTimeIntervalMinutes(timeZoneInMinute);
+			}		
+		
+		aRet = dateTimeInTTime.Int64();
+		result = ETrue;
+		}
+	
+	return result;
+	}
+
+TBool RMTPUtility::GetYear(const TDesC& aTimeString, TInt& aYear) const
+	{
+	aYear = 0;
+	TLex dateBuf(aTimeString.Left(4));
+	return dateBuf.Val(aYear) == KErrNone;
+	}
+
+TBool RMTPUtility::GetMonth(const TDesC& aTimeString, TMonth& aMonth) const
+	{
+	TBool result = EFalse;
+	aMonth = EJanuary;
+	TInt month = 0;
+	TLex dateBuf(aTimeString.Mid(4, 2));
+	if(dateBuf.Val(month) == KErrNone && month > 0 && month < 13)
+		{
+		month--;
+		aMonth = (TMonth)month;
+		result = ETrue;
+		}
+	return result;
+	}
+
+TBool RMTPUtility::GetDay(const TDesC& aTimeString, TInt& aDay) const
+	{
+	TBool result = EFalse;
+	aDay = 0;
+	TLex dateBuf(aTimeString.Mid(6, 2));
+	if(dateBuf.Val(aDay) == KErrNone && aDay > 0 && aDay < 32)
+		{
+		aDay--;
+		result = ETrue;
+		}
+	return result;	
+	}
+
+TBool RMTPUtility::GetHour(const TDesC& aTimeString, TInt& aHour) const
+	{
+	aHour = 0;
+	TLex dateBuf(aTimeString.Mid(9, 2));
+	return (dateBuf.Val(aHour) == KErrNone && aHour >=0 && aHour < 60);
+	}
+				
+TBool RMTPUtility::GetMinute(const TDesC& aTimeString, TInt& aMinute) const
+	{
+	aMinute = 0;
+	TLex dateBuf(aTimeString.Mid(11, 2));
+	return (dateBuf.Val(aMinute) == KErrNone && aMinute >=0 && aMinute < 60);
+	}
+
+TBool RMTPUtility::GetSecond(const TDesC& aTimeString, TInt& aSecond) const
+	{
+	aSecond = 0;
+	TLex dateBuf(aTimeString.Mid(13, 2));
+	return (dateBuf.Val(aSecond) == KErrNone && aSecond >= 0 && aSecond < 60);
+	}
+
+TBool RMTPUtility::GetTenthSecond(const TDesC& aTimeString, TInt& aTenthSecond) const
+	{
+	TBool result = EFalse;
+	aTenthSecond = 0;
+	TInt dotPos = aTimeString.Find(_L("."));
+	if(dotPos != KErrNotFound && dotPos == KMTPDateStringLength && aTimeString.Length() > KMTPDateStringLength + 1)
+		{
+		TLex dateBuf(aTimeString.Mid(dotPos + 1, 1));
+		result = (dateBuf.Val(aTenthSecond) == KErrNone && aTenthSecond >=0 && aTenthSecond < 10);
+		}
+	else if(dotPos == KErrNotFound)
+		{
+		result = ETrue;
+		}
+	
+	return result;	
+	}
+
+TBool RMTPUtility::GetTimeZone(const TDesC& aTimeString, TBool& aPositiveTimeZone, TInt& aTimeZoneInHour, TInt& aTimeZoneInMinute) const	 		
+	{
+	TBool result = EFalse;
+	aTimeZoneInHour = 0;
+	aTimeZoneInMinute = 0;
+	TInt plusTimeZonePos = aTimeString.Find(_L("+"));
+	TInt minusTimeZonePos = aTimeString.Find(_L("-"));
+	TInt timeZoneIndicatorPos = Max(plusTimeZonePos, minusTimeZonePos);		
+	aPositiveTimeZone = (plusTimeZonePos != KErrNotFound);
+	if(timeZoneIndicatorPos != KErrNotFound)
+		{
+		if(aTimeString.Length() - timeZoneIndicatorPos == 5)
+			{
+			TLex dateBuf(aTimeString.Mid(timeZoneIndicatorPos + 1, 2));
+			if(dateBuf.Val(aTimeZoneInHour) == KErrNone)
+				{
+				dateBuf.Assign(aTimeString.Mid(timeZoneIndicatorPos + 3, 2));
+				if(dateBuf.Val(aTimeZoneInMinute) == KErrNone)
+					{
+					result = ETrue;
+					}
+				}
+			}
+		}
+	else
+		{
+		result = ETrue;
+		}
+	return result;
+	}
+
+EXPORT_C void RMTPUtility::RenameObjectL( TUint aObjectHandle, const TDesC& aNewName )
+	{
+    __FLOG(_L8("RenameAssocationObjectL - Entry"));
+    
+    CMTPObjectMetaData* meta = CMTPObjectMetaData::NewLC();
+       
+    if( !iFramework->ObjectMgr().ObjectL(aObjectHandle, *meta) )
+    	{
+    	User::Leave(KErrNotFound);
+    	}
+			
+   if( !BaflUtils::FileExists( iFramework->Fs(), meta->DesC(CMTPObjectMetaData::ESuid) ) )
+	   {
+	   User::Leave(KErrNotFound);
+	   }
+	
+	TFileName filename;
+	User::LeaveIfError(BaflUtils::MostSignificantPartOfFullName(meta->DesC(CMTPObjectMetaData::ESuid), filename));
+	RBuf oldFullName;
+	oldFullName.CleanupClosePushL();
+	
+	TInt maxLen = (KMaxFileName > meta->DesC(CMTPObjectMetaData::ESuid).Length()? KMaxFileName: meta->DesC(CMTPObjectMetaData::ESuid).Length());
+	oldFullName.CreateL(maxLen);
+	oldFullName = meta->DesC(CMTPObjectMetaData::ESuid);
+		
+	// Update the folder name using the new passed value.
+	RBuf newFullName;
+	newFullName.CleanupClosePushL();
+	newFullName.CreateL(maxLen);
+	newFullName.Append(oldFullName);
+	if(meta->Uint(CMTPObjectMetaData::EFormatCode) == EMTPFormatCodeAssociation)
+		{
+		newFullName.SetLength(newFullName.Length() - filename.Length() - 1);
+		}
+	else
+		{
+		newFullName.SetLength(newFullName.Length() - filename.Length());
+		}
+	
+	maxLen = newFullName.Length() + aNewName.Length() + 1;
+	if(maxLen > newFullName.MaxLength())
+		{
+		newFullName.ReAllocL(maxLen);
+		}
+	newFullName.Append(aNewName);
+	
+	if(meta->Uint(CMTPObjectMetaData::EFormatCode) != EMTPFormatCodeAssociation)
+		{
+		// Modify the filename
+		User::LeaveIfError( iFramework->Fs().Rename(meta->DesC(CMTPObjectMetaData::ESuid), newFullName) );
+		
+		meta->SetDesCL( CMTPObjectMetaData::ESuid, newFullName );
+		iFramework->ObjectMgr().ModifyObjectL(*meta);
+		}
+	else
+		{
+		// Add backslash.
+		_LIT(KBackSlash, "\\");
+		newFullName.Append(KBackSlash);
+		// Modify the filename
+		User::LeaveIfError( iFramework->Fs().Rename(meta->DesC(CMTPObjectMetaData::ESuid), newFullName) );
+		
+		meta->SetDesCL( CMTPObjectMetaData::ESuid, newFullName );
+		iFramework->ObjectMgr().ModifyObjectL(*meta);
+		
+		RenameAllChildrenL( meta->Uint(CMTPObjectMetaData::EStorageId), meta->Uint(CMTPObjectMetaData::EHandle), newFullName, oldFullName);
+		
+		if(meta->Uint(CMTPObjectMetaData::EFormatCode) == EMTPFormatCodeAssociation)
+			{
+			TMTPNotificationParamsHandle param = { meta->Uint(CMTPObjectMetaData::EHandle) ,oldFullName};
+			iSingleton.DpController().NotifyDataProvidersL(EMTPRenameObject, static_cast<TAny*>(&param));
+			}
+		}
+
+	CleanupStack::PopAndDestroy(3);//oldFullName, newFullName,meta
+    __FLOG(_L8("RenameAssocationObjectL - Exit"));
+	}
+
+EXPORT_C TMTPFormatCode RMTPUtility::FormatFromFilename( const TDesC& aFullFileName )
+    {
+    if ( aFullFileName.Right( 1 ).CompareF( KTxtBackSlash ) == 0 ) 
+        {
+        return EMTPFormatCodeAssociation;
+        }
+
+    TParsePtrC file( aFullFileName );
+
+    if ( file.Ext().CompareF( KTxtExtensionODF ) == 0 )
+        {
+        HBufC* mime =ContainerMimeType( file.FullName() );
+
+        // 3GP
+        if ( mime->CompareF( KMimeTypeAudio3gpp ) == 0 || mime->CompareF( KMimeTypeVideo3gpp ) == 0)
+            {
+            delete mime;
+            mime = NULL;
+            return EMTPFormatCode3GPContainer;
+            }
+        else if (  mime->CompareF( KMimeTypeAudioMp4 ) == 0 || mime->CompareF( KMimeTypeVideoMp4 ) == 0 )
+            {
+            delete mime;
+            mime = NULL;
+            return EMTPFormatCodeMP4Container;
+            }
+        if ( mime != NULL )
+            {
+            delete mime;
+            mime = NULL;
+            }
+        }
+
+    return EMTPFormatCodeUndefined;
+    }
+
+EXPORT_C HBufC* RMTPUtility::ContainerMimeType( const TDesC& aFullPath )
+    {
+
+    TParsePtrC file( aFullPath );
+    HBufC* mime = NULL;
+    TInt err = KErrNone;
+    
+    if ( file.Ext().CompareF( KTxtExtensionODF ) == 0 )
+        {
+        TRAP( err, mime = OdfMimeTypeL( aFullPath ) );
+        }
+
+    return mime;
+    }
+
+EXPORT_C void RMTPUtility::FormatExtensionMapping()
+    {
+     TInt count = iSingleton.DpController().Count();
+    
+    while(count--)
+        {
+        CDesCArraySeg* FormatExtensionMapping = new (ELeave) CDesCArraySeg(4);
+        CleanupStack::PushL(FormatExtensionMapping);
+        TRAP_IGNORE(iSingleton.DpController().DataProviderByIndexL(count).Plugin().SupportedL(EFormatExtensionSets,*FormatExtensionMapping));
+        AppendFormatExtensionMapping(*FormatExtensionMapping,iSingleton.DpController().DataProviderByIndexL(count).DataProviderId());
+        CleanupStack::PopAndDestroy(FormatExtensionMapping);
+        }
+    }
+
+EXPORT_C TMTPFormatCode RMTPUtility::GetFormatByExtension(const TDesC& aExtension)
+    {
+    CMTPExtensionMapping* extensionMapping = CMTPExtensionMapping::NewL(aExtension, EMTPFormatCodeUndefined);
+    CleanupStack::PushL(extensionMapping);
+    TInt  found = iFormatMappings.FindInOrder(extensionMapping, TLinearOrder<CMTPExtensionMapping>(CMTPExtensionMapping::Compare));
+    if ( KErrNotFound != found)
+        {
+        CleanupStack::PopAndDestroy(extensionMapping);
+        return iFormatMappings[found]->FormatCode();
+        }
+    CleanupStack::PopAndDestroy(extensionMapping);
+    return EMTPFormatCodeUndefined;
+    }
+
+EXPORT_C TUint32 RMTPUtility::GetDpId(const TDesC& aExtension,const TDesC& aMIMEType)
+    {
+    CMTPExtensionMapping* extensionMapping = CMTPExtensionMapping::NewL(aExtension, EMTPFormatCodeUndefined,aMIMEType);
+    CleanupStack::PushL(extensionMapping);
+    TInt  found = iFormatMappings.FindInOrder(extensionMapping, TLinearOrder<CMTPExtensionMapping>(CMTPExtensionMapping::ComparewithMIME));
+    if ( KErrNotFound != found)
+        {
+        CleanupStack::PopAndDestroy(extensionMapping);
+        return iFormatMappings[found]->DpId();
+        }
+    CleanupStack::PopAndDestroy(extensionMapping);
+    return 255;
+    }
+
+EXPORT_C TUint RMTPUtility::GetEnumerationFlag(const TDesC& aExtension)
+    {
+    CMTPExtensionMapping* extensionMapping = CMTPExtensionMapping::NewL(aExtension, EMTPFormatCodeUndefined);
+    CleanupStack::PushL(extensionMapping);
+    TInt  found = iFormatMappings.FindInOrder(extensionMapping, TLinearOrder<CMTPExtensionMapping>(CMTPExtensionMapping::Compare));
+    if ( KErrNotFound != found)
+        {
+        CleanupStack::PopAndDestroy(extensionMapping);
+        return iFormatMappings[found]->EnumerationFlag();
+        }
+    CleanupStack::PopAndDestroy(extensionMapping);
+    return 1;
+    }
+
+
+void RMTPUtility::RenameAllChildrenL(TUint32 aStorageId, TUint32 aParentHandle, const TDesC& aNewFolderName, const TDesC& aOldFolderName)
+	{
+    __FLOG(_L8("RenameAllChildrenL - Entry"));
+	
+	RMTPObjectMgrQueryContext   context;
+	RArray<TUint>               handles;
+	TMTPObjectMgrQueryParams    params(aStorageId, KMTPFormatsAll, aParentHandle);
+	CleanupClosePushL(context);
+	CleanupClosePushL(handles);
+	
+	CMTPObjectMetaData* objectInfo(CMTPObjectMetaData::NewLC());
+	TInt count = 0;	
+	TEntry entry;
+	
+	do
+	    {
+	    iFramework->ObjectMgr().GetObjectHandlesL(params, context, handles);
+    	count = handles.Count();
+    	
+    	for(TInt i(0); (i < count); i++)
+    		{
+    		if (!iFramework->ObjectMgr().ObjectL(handles[i], *objectInfo))
+    			{
+    			User::Leave(KErrCorrupt);
+    			}
+    		
+    	    /**
+    	     * [SP-Format-0x3002]Special processing for PictBridge DP which own 6 dps file with format 0x3002, 
+    	     * but it does not really own the format 0x3002.
+    	     * 
+    	     * Make the same behavior betwen 0x3000 and 0x3002.
+    	     */
+    		if( (objectInfo->Uint(CMTPObjectMetaData::EFormatCode) != EMTPFormatCodeAssociation)
+    		    && (objectInfo->Uint(CMTPObjectMetaData::EFormatCode) != EMTPFormatCodeUndefined)
+    		    && (objectInfo->Uint(CMTPObjectMetaData::EFormatCode) != EMTPFormatCodeScript) )
+    		   continue;
+
+			RBuf entryName; 
+			entryName.CreateL(KMaxFileName);
+			entryName.CleanupClosePushL();
+			entryName = objectInfo->DesC(CMTPObjectMetaData::ESuid);
+			
+			RBuf rightPartName;
+			rightPartName.CreateL(KMaxFileName);
+			rightPartName.CleanupClosePushL();
+			rightPartName = entryName.Right(entryName.Length() - aOldFolderName.Length());
+			
+			if ((aNewFolderName.Length() + rightPartName.Length()) > entryName.MaxLength())
+				{
+				entryName.ReAllocL(aNewFolderName.Length() + rightPartName.Length());
+				}
+			
+			entryName.Zero();
+			entryName.Append(aNewFolderName);
+			entryName.Append(rightPartName);
+			
+			if (KErrNone != iFramework->Fs().Entry(entryName, entry))
+				{
+				// Skip objects that don't use the file path as SUID.
+				CleanupStack::PopAndDestroy(&entryName);
+				continue;
+				}
+			
+			// Recursively update all this object's children.
+			// The maximum recursion depth is as deep as the association hierarchy.
+			RenameAllChildrenL(objectInfo->Uint(CMTPObjectMetaData::EStorageId), objectInfo->Uint(CMTPObjectMetaData::EHandle), entryName, objectInfo->DesC(CMTPObjectMetaData::ESuid) );
+			
+			TFileName oldfilename(objectInfo->DesC(CMTPObjectMetaData::ESuid));
+			objectInfo->SetDesCL(CMTPObjectMetaData::ESuid, entryName);
+			iFramework->ObjectMgr().ModifyObjectL(*objectInfo);
+			
+			if(objectInfo->Uint(CMTPObjectMetaData::EFormatCode) == EMTPFormatCodeAssociation)
+				{
+				//Send the Rename notification 
+				TMTPNotificationParamsHandle param = { handles[i], oldfilename};
+				iSingleton.DpController().NotifyDataProvidersL(EMTPRenameObject, static_cast<TAny*>(&param));
+				}
+			CleanupStack::PopAndDestroy(2); // rightPartName, entryName		
+    		}
+	    }
+	while (!context.QueryComplete());
+	
+	CleanupStack::PopAndDestroy(3);//objectInfo; &handles; &context
+	
+    __FLOG(_L8("RenameAllChildrenL - Exit"));
+	}
+
+HBufC* RMTPUtility::OdfMimeTypeL( const TDesC& aFullPath )
+    {
+    HBufC* mimebuf = NULL;
+    
+    TParsePtrC file( aFullPath );
+        
+    if ( file.Ext().CompareF( KTxtExtensionODF ) == 0 )
+        {
+        RFs tempFsSession; 
+        User::LeaveIfError(tempFsSession.Connect());     
+        CleanupClosePushL(tempFsSession);
+        User::LeaveIfError(tempFsSession.ShareProtected());  
+        
+        RFile tempFile; 
+        User::LeaveIfError(tempFile.Open(tempFsSession, aFullPath, EFileRead|EFileShareAny)); 
+        CleanupClosePushL(tempFile); 
+        
+        //CContent* content = CContent::NewL( aFullPath );
+        CContent* content = CContent::NewL( tempFile );
+        CleanupStack::PushL( content ); // + content
+        
+        HBufC* buffer = HBufC::NewL( KMimeTypeMaxLength );
+        CleanupStack::PushL( buffer ); // + buffer
+        
+        TPtr data = buffer->Des();
+        TInt err = content->GetStringAttribute( EMimeType, data );
+                
+        if ( err == KErrNone )
+            {
+            mimebuf = HBufC::New( buffer->Length() );
+    
+            if (mimebuf == NULL)
+                {
+                User::LeaveIfError( KErrNotFound );
+                }
+            
+            mimebuf->Des().Copy( *buffer );
+            }
+        
+        // leave if NULL
+        if ( mimebuf == NULL )
+            {
+            User::Leave( KErrNotFound );
+            }
+        
+        CleanupStack::PopAndDestroy( buffer ); // - buffer
+        CleanupStack::PopAndDestroy( content ); // - content
+        CleanupStack::PopAndDestroy(&tempFile); // close 
+        CleanupStack::PopAndDestroy(&tempFsSession);    // close 
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+    
+    return mimebuf;
+    }
+
+void  RMTPUtility::AppendFormatExtensionMapping(const CDesCArray& aFormatExtensionMapping,TUint32 aDpId)
+    {
+    //Parse the descriptor formatcode,fileextension, e.g. 0x3009:mp3
+     TBuf<KMAXPackageIDStringLen> stringSeg;
+     TInt  splitter1(0);
+     TInt  splitter2(0);
+     TInt  found(0);
+     TUint formatCode = 0;
+     TUint isNeedFileDp = 1;
+     
+     for(TInt i=0; i < aFormatExtensionMapping.Count(); ++i)
+         {
+         CMTPExtensionMapping* extensionMapping = CMTPExtensionMapping::NewL(KNullDesC, EMTPFormatCodeUndefined);
+         CleanupStack::PushL(extensionMapping);
+         _LIT(KSPLITTER,":");
+         splitter1 = aFormatExtensionMapping[i].FindF(KSPLITTER);
+         //Skip "0x", 2 is the length of "0x"
+         stringSeg = aFormatExtensionMapping[i].Mid(2, 4);
+         TLex lex(stringSeg);
+         User::LeaveIfError(lex.Val(formatCode, EHex));
+         //Skip ":"
+         stringSeg = aFormatExtensionMapping[i].Mid(splitter1 + 1);
+         splitter2 = stringSeg.FindF(KSPLITTER);
+         if ( splitter2 == KErrNotFound )
+             {
+             extensionMapping->SetExtensionL(stringSeg);
+             }
+         else
+             {
+             extensionMapping->SetExtensionL(aFormatExtensionMapping[i].Mid(splitter1+1,splitter2));
+             stringSeg = stringSeg.Mid(splitter2+1);
+             splitter1 = stringSeg.FindF(KSPLITTER);
+             if ( splitter1==KErrNotFound )
+                 {
+                 extensionMapping->SetMIMETypeL(stringSeg);
+                 }
+             else if ( splitter1==0 )
+                 {
+                 TLex lex1(stringSeg.Mid(splitter1+1));
+                 User::LeaveIfError(lex1.Val(isNeedFileDp, EDecimal));                 
+                 }
+             else
+                 {
+                 extensionMapping->SetMIMETypeL(stringSeg.Mid(0,splitter1));
+                 TLex lex2(stringSeg.Mid(splitter1+1));
+                 User::LeaveIfError(lex2.Val(isNeedFileDp, EDecimal));
+                 }
+             
+             }
+
+         found = iFormatMappings.FindInOrder(extensionMapping, TLinearOrder<CMTPExtensionMapping>(CMTPExtensionMapping::ComparewithMIME));
+         if (KErrNotFound == found)
+             {
+             extensionMapping->SetFormatCode((TMTPFormatCode)formatCode);
+             extensionMapping->SetDpId(aDpId);
+             extensionMapping->SetEnumerationFlag(isNeedFileDp);
+             iFormatMappings.InsertInOrderL(extensionMapping, TLinearOrder<CMTPExtensionMapping>(CMTPExtensionMapping::ComparewithMIME));
+             }
+         CleanupStack::Pop(extensionMapping);
+         }    
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,29 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// bld.inf for all MTP framework data provider sub-components
+// Media Transfer Protocol Framework Data Provider Components
+// For dependency reasons, dataproviderapi is included from the 
+// MTP daemon bld.inf.
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include "../dputility/group/bld.inf"
+#include  "../devdp/devdpextnapi/group/bld.inf"
+#include "../devdp/group/bld.inf"
+#include "../proxydp/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,29 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// bld.inf for mtpproxydp
+// Media Transfer Protocol proxy data provider
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES 
+mtpproxydp.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/group/mtpproxydp.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,71 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <comms-infras/commsdebugutility.mmh> 
+
+TARGET              mtpproxydp.dll
+TARGETTYPE          PLUGIN
+UID                 0x10009D8D 0x102827A6
+VENDORID            0x70000001
+
+CAPABILITY          CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+USERINCLUDE         ../inc
+USERINCLUDE         ../../dputility/inc
+USERINCLUDE         ../../../common/inc
+USERINCLUDE         ../../../inc
+
+SOURCEPATH          ../src 
+SOURCE              cmtpcopyobject.cpp
+SOURCE              cmtpmoveobject.cpp
+SOURCE              cmtpdeleteobject.cpp
+SOURCE              cmtpgetobjectproplist.cpp
+SOURCE              cmtpgetobjectpropssupported.cpp
+SOURCE              cmtpproxydp.cpp
+SOURCE              cmtpsendobjectinfo.cpp
+SOURCE              cmtpsendobjectproplist.cpp
+SOURCE              cmtpsetobjectproplist.cpp
+SOURCE              mtpproxydpimplementations.cpp
+SOURCE              mtpproxydpprocessor.cpp
+SOURCE              rmtpproxydpsingletons.cpp
+SOURCE              cmtpproxydpconfigmgr.cpp 
+SOURCE              cmtpdeleteobjectproplist.cpp
+SOURCE				cmtpgetformatcapabilities.cpp
+SOURCE              cmtpobjectbrowser.cpp
+
+SOURCEPATH          ../src 
+START RESOURCE      mtpproxydp.rss  
+TARGET              mtpproxydp.rsc  
+END
+
+// Data provider configuration resource file. 
+// The target filename corresponds to the implementation UID.
+START RESOURCE      mtpproxydp_config.rss
+HEADER
+TARGETPATH          /resource/mtp
+TARGET              102827b1.rsc
+END
+
+LIBRARY             euser.lib
+LIBRARY             efsrv.lib
+LIBRARY             bafl.lib 
+
+LIBRARY             mtpdataproviderapi.lib
+LIBRARY             mtpdataproviderutility.lib
+LIBRARY             mtpdatatypes.lib
+LIBRARY             mtpframework.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpcopyobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,85 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPCOPYOBJECT_H
+#define CMTPCOPYOBJECT_H
+
+#include "cmtprequestprocessor.h"
+#include "mmtptransactionproxy.h"
+#include "rmtpframework.h"
+
+class MMTPRequestProcessor;
+class CMTPObjectBrowser;
+class CMTPTypeArray;
+
+/** 
+Implements the proxy data provider CopyObject request processor.
+@internalComponent
+  
+*/
+class CMTPCopyObject : public CMTPRequestProcessor, public MMTPTransactionProxy
+    {
+public:
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPCopyObject(); 
+
+private: // From CMTPRequestProcessor
+    void ServiceL();    
+
+private: // From MMTPTransactionProxy
+    void ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+
+private: // From CActive
+    void RunL();
+    TInt RunError(TInt aError);
+
+private:    
+    CMTPCopyObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+	void ConstructL();
+	
+    void SendResponseL(TUint16 aCode);
+    void Schedule(TInt aError);
+    
+    void BrowseHandlesL();
+    void NextObjectHandleL();
+    static void OnBrowseObjectL( TAny* aSelf, TUint aHandle, TUint32 aCurDepth );
+    
+private:
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    RMTPFramework       iSingletons;
+    TUint                iOwnerDp;
+    
+    CMTPObjectBrowser*  iObjBrowser;
+    RArray< TUint32 >      iHandles;
+    RArray< TUint32 >      iHandleDepths;
+    RArray< TUint32 >   iNewHandleParentStack;
+    TInt                iCurrentHandle;
+    TMTPTypeRequest     iCurrentRequest;
+    TBool               iIsCopyingFolder;
+    TUint32             iRespHandle;
+    RArray<TUint>           iTargetDps;
+    };
+    
+#endif // CMTPCOPYOBJECT_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpdeleteobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,88 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPDELETEOBJECT_H
+#define CMTPDELETEOBJECT_H
+
+#include "cmtprequestprocessor.h"
+#include "mmtptransactionproxy.h"
+#include "rmtpframework.h"
+
+class CMTPDataProvider;
+class MMTPRequestProcessor;
+class CMTPObjectBrowser;
+class CMTPTypeArray;
+
+/** 
+Implements the proxy data provider DeleteObject request processor.
+@internalComponent
+  
+*/
+class CMTPDeleteObject : public CMTPRequestProcessor, public MMTPTransactionProxy
+    {
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPDeleteObject(); 
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();    
+
+private: // From MMTPTransactionProxy
+
+    void ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+
+private: // From CActive
+
+    void RunL();
+
+private:    
+
+    CMTPDeleteObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+	void ConstructL();
+	
+    void SendResponseL(TUint16 aCode);
+    void Schedule(TInt aError);
+    
+    void BrowseHandlesL();
+    void NextObjectHandleL();
+    static void OnBrowseObjectL( TAny* aSelf, TUint aHandle, TUint32 aCurDepth );
+    
+private: 
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+    RMTPFramework       iSingletons;
+    TUint                iOwnerDp;
+    
+    CMTPObjectBrowser*  iObjBrowser;
+    RArray< TUint32 >      iHandles;
+    TInt                iCurrentHandle;
+    TMTPTypeRequest     iCurrentRequest;
+    RArray<TUint>           iTargetDps;
+    
+    TUint16             iDeletedObjectsNumber;
+    };
+    
+#endif // CMTPDELETEOBJECT_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpdeleteobjectproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,105 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef CMTPDELETEOBJECTPROPLIST_H_
+#define CMTPDELETEOBJECTPROPLIST_H_
+
+#include "cmtprequestprocessor.h"
+#include "mmtptransactionproxy.h"
+#include "rmtpframework.h"
+
+class CMTPTypeDeleteObjectPropList;
+class MMTPRequestProcessor;
+
+/** 
+Implements the proxy data provider's DeleteObjectPropList request processor.
+@internalComponent
+  
+*/
+class CMTPDeleteObjectPropList : public CMTPRequestProcessor, public MMTPTransactionProxy
+    {
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPDeleteObjectPropList();    
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+    TBool DoHandleResponsePhaseL();
+    TBool HasDataphase() const;
+
+private: // From MMTPTransactionProxy
+
+    void ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    
+private:    
+    CMTPDeleteObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+    
+    void SendResponseL(TUint16 aCode);
+    void Schedule(TInt aError);
+    
+    void BuildSubRequestsL();
+    
+private: // From CActive
+    void RunL();
+    TInt RunError(TInt aError);
+    
+private: // Owned
+
+    /*
+     *FLOGGER debug trace member variable.
+     */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;  
+
+    /* 
+     * DeleteObjectPropList dataset.
+     */
+    CMTPTypeDeleteObjectPropList*          iDeleteObjectPropList;
+    
+    /*
+     * the current DP id.
+     */
+    TInt                iCurrentTarget;
+
+    /*
+     * the targets DP IDs.
+     */
+    RArray<TUint>       iTargetDps;  
+    
+    /*
+     * 
+     */
+    RPointerArray<CMTPTypeDeleteObjectPropList> iSubDatasets;
+    
+    /*
+     * mtp framework interface. 
+     */
+    RMTPFramework           iSingletons;
+    
+    };
+
+
+
+#endif /* CMTPDELETEOBJECTPROPLIST_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpgetformatcapabilities.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,93 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef CMTPGETFORMATCAPABILITIES_H_
+#define CMTPGETFORMATCAPABILITIES_H_
+
+#include <mtp/cmtptypeformatcapabilitylist.h>
+
+#include "cmtprequestprocessor.h"
+#include "mmtptransactionproxy.h"
+#include "rmtpframework.h"
+
+
+class MMTPRequestProcessor;
+
+
+
+/** 
+Implements the proxy data provider's GetFormatCapabilities request processor.
+@internalComponent
+  
+*/
+class CMTPGetFormatCapabilities : public CMTPRequestProcessor, public MMTPTransactionProxy
+    {
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPGetFormatCapabilities();    
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+
+private: // From MMTPTransactionProxy
+
+    void ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    
+private:    
+    CMTPGetFormatCapabilities(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+    void SendResponseL(TUint16 aCode);
+    void Schedule(TInt aError);
+
+private: // From CActive
+    void RunL();
+    TInt RunError(TInt aError);
+    
+private: // Owned
+
+    /*
+     *FLOGGER debug trace member variable.
+     */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;  
+
+    
+    /* 
+     * CMTPTypeCapabilityList dataset.
+     */
+    CMTPTypeFormatCapabilityList*                iCapabilityList;
+    
+    
+    /*
+     * The current data provider
+     */
+    TInt                                        iCurrentTarget;
+        
+
+    RArray<TUint>                               iTargetDps;
+    
+    /*
+     * mtp framework interface. 
+     */
+    RMTPFramework                               iSingletons;
+    
+    };
+
+
+#endif /*CMTPGETFORMATCAPABILITIES_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpgetobjectproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,89 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPGETOBJECTPROPLIST_H
+#define CMTPGETOBJECTPROPLIST_H
+
+#include "cmtprequestprocessor.h"
+#include "mmtptransactionproxy.h"
+#include "rmtpframework.h"
+
+//forward declarations
+class CMTPTypeObjectPropList;
+class CMTPDataProvider;
+class MMTPRequestProcessor;
+class CMTPObjectBrowser;
+class CMTPTypeArray;
+
+/** 
+Implements the proxy data provider GetObjectPropList request processor.
+@internalComponent
+  
+*/
+class CMTPGetObjectPropList : public CMTPRequestProcessor, public MMTPTransactionProxy
+    {
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPGetObjectPropList(); 
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+
+private: // From MMTPTransactionProxy
+
+    void ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+
+private: // From CActive
+
+    void RunL();
+
+private:    
+
+    CMTPGetObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+    
+    void Schedule(TInt aError);
+    void SendResponseL(TUint16 aCode);
+    
+    void GetObjectHandlesL();
+    void GetNextObjectPropL();
+    static void OnBrowseObjectL( TAny* aSelf, TUint aHandle, TUint32 aCurDepth );
+    
+private: // Owned
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+    CMTPTypeObjectPropList* iObjectPropList;
+    RMTPFramework           iSingletons;
+    TUint                   iOwnerDp;
+    
+    CMTPObjectBrowser*      iObjBrowser;
+    RArray< TUint32 >       iHandles;
+    TInt                    iCurrentHandle;
+    TMTPTypeRequest         iCurrentRequest;
+    RArray<TUint>           iTargetDps;
+    };
+    
+#endif // CMTPGETOBJECTPROPLIST_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpgetobjectpropssupported.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,78 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPGETOBJECTPROPSSUPPORTED_H
+#define CMTPGETOBJECTPROPSSUPPORTED_H
+
+#include "cmtprequestprocessor.h"
+#include "mmtptransactionproxy.h"
+#include "rmtpframework.h"
+
+class CMTPTypeArray;
+class MMTPRequestProcessor;
+
+/** 
+Implements the proxy data provider GetObjectPropsSupported request processor.
+@internalComponent
+  
+*/
+class CMTPGetObjectPropsSupported : 
+    public CMTPRequestProcessor, 
+    public MMTPTransactionProxy
+    {
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPGetObjectPropsSupported(); 
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+
+private: // From MMTPTransactionProxy
+
+    void ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+
+private: // From CActive
+
+    void RunL();
+
+private:    
+
+    CMTPGetObjectPropsSupported(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+    
+    void Schedule(TInt aError);
+    void SendResponseL(TUint16 aCode);
+                    
+private: // Owned
+
+    TInt            iCurrentTarget;
+    CMTPTypeArray*  iDataset;
+    RArray<TUint>   iObjectPropsSupported;
+    RMTPFramework   iSingletons;
+    RArray<TUint>   iTargetDps;
+    };
+    
+#endif // CMTPGETOBJECTPROPSSUPPORTED_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpmoveobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,115 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPMOVEOBJECT_H
+#define CMTPMOVEOBJECT_H
+
+#include <badesca.h>
+
+#include "cmtprequestprocessor.h"
+#include "mmtptransactionproxy.h"
+
+class MMTPRequestProcessor;
+class CMTPObjectBrowser;
+class CFileMan;
+
+/** 
+Implements the proxy data provider MoveObject request processor.
+@internalComponent
+  
+*/
+class CMTPMoveObject : public CMTPRequestProcessor, public MMTPTransactionProxy
+    {
+private:
+    enum TState
+        {
+        EInit,
+        ERemoveSourceFolderTree
+        };
+    
+public:
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPMoveObject(); 
+
+private: // From CMTPRequestProcessor
+    void ServiceL();    
+
+private: // From MMTPTransactionProxy
+    void ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    
+private: // Helpers
+    /*TMTPResponseCode CreateNewFoldersL();
+    void CreateAllSubFoldersL(TUint aParentHandle);
+	TBool IsFolderObject(const CMTPObjectMetaData& aObject);
+	void FinalPhaseCreateL();*/
+	void GetParametersL();
+    void GetDefaultParentObjectL( TDes& aObjectName );
+	TMTPResponseCode CanMoveObjectL(const TDesC& aOldName, const TDesC& aNewName) const;
+	void GetSuidFromHandleL(TUint aHandle, TDes& aSuid) const;
+
+private: // From CActive
+    void RunL();
+    TInt RunError(TInt aError);
+    
+private:    
+    CMTPMoveObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+	void ConstructL();
+    void SendResponseL(TUint16 aCode);
+    void Schedule(TInt aError);
+    
+private:
+    TMTPResponseCode CreateFolderL();
+    void RemoveSourceFolderTreeL();
+    void BrowseHandlesL();
+    void NextObjectHandleL();
+    static void OnBrowseObjectL( TAny* aSelf, TUint aHandle, TUint32 aCurDepth );
+    
+private: 
+	/**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;     
+       
+    RMTPFramework       iSingletons;
+    TUint                iOwnerDp;
+	RBuf				iNewParent;
+	TUint32				iStorageId; 
+	CDesCArray*			iPathToCreate;
+	static const TMTPRequestElementInfo KMTPMoveObjectPolicy[];  	   
+	
+    CMTPObjectBrowser*      iObjBrowser;
+    RArray< TUint32 >      iHandles;
+    RArray< TUint32 >      iHandleDepths;
+    RArray< TUint32 >       iNewHandleParentStack;
+    TInt                    iCurrentHandle;
+    TMTPTypeRequest         iCurrentRequest;
+    TBool                   iIsMovingFolder;
+    CMTPObjectMetaData*     iObjInfoCache;
+    RBuf                    iFolderToRemove;
+    TInt                    iState;
+    CFileMan*               iFileMan;
+    RArray<TUint>           iTargetDps;
+    };
+    
+#endif // CMTPMOVEOBJECT_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpobjectbrowser.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,69 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPOBJECTBROWSER_H
+#define CMTPOBJECTBROWSER_H
+
+#include <e32base.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include "mtpdebug.h"
+
+class CMTPTypeArray;
+class CMTPRequestChecker;
+class CMTPObjectMetaData;
+
+class CMTPObjectBrowser: public CBase
+    {
+public:
+    typedef void ( *TBrowseObjectCallbackProcL )( TAny* aContext, TUint aHandle, TUint32 aCurDepth );
+    
+    struct TBrowseCallback
+        {
+        TBrowseObjectCallbackProcL iCallback;
+        TAny* iContext;
+        };
+    
+public:
+    static CMTPObjectBrowser* NewL( MMTPDataProviderFramework& aDpFw );
+    static TBool IsFolderFormat( TUint aFmtCode, TUint aFmtSubCode );
+    
+public:
+    ~CMTPObjectBrowser();
+    
+    void GoL( TUint32 aFormatCode, TUint32 aHandle, TUint32 aDepth, const TBrowseCallback& aBrowseCallback ) const;
+    
+private:
+    CMTPObjectBrowser( MMTPDataProviderFramework& aDpFw );
+    void ConstructL();
+    
+    void GetObjectHandlesL( TUint32 aCurDepth, TUint32 aStorageId, TUint32 aFormatCode, TUint32 aDepth, TUint32 aParentHandle, const TBrowseCallback& aBrowseCallback ) const;
+    void GetFolderObjectHandlesL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, TUint32 aParentHandle, const TBrowseCallback& aBrowseCallback ) const;
+    void GetRootObjectHandlesL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, const TBrowseCallback& aBrowseCallback ) const;
+    void GetObjectHandlesTreeL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, TUint32 aParentHandle, const TBrowseCallback& aBrowseCallback ) const;
+    
+private:
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    MMTPDataProviderFramework& iDpFw;
+    CMTPObjectMetaData* iObjMetaCache;
+    };
+
+#endif // CMTPOBJECTBROWSER_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpproxydp.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,80 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPPROXYDP_H
+#define CMTPPROXYDP_H
+
+#include <mtp/cmtpdataproviderplugin.h>
+#include "rmtpdpsingletons.h"
+#include "rmtpproxydpsingletons.h"
+class MMTPRequestProcessor;
+
+/** 
+Implements the proxy data provider.
+@internalComponent
+  
+*/
+class CMTPProxyDataProvider : public CMTPDataProviderPlugin
+    {
+public:
+
+    static TAny* NewL(TAny* aParams);
+    ~CMTPProxyDataProvider();
+	
+private: // From CMTPDataProviderPlugin
+
+	void Cancel();
+    void ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection);
+    void ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams);
+    void ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    void StartObjectEnumerationL(TUint32 aStorageId, TBool aPersistentFullEnumeration);
+    void StartStorageEnumerationL();
+    void Supported(TMTPSupportCategory aCategory, RArray<TUint>& aArray) const;
+    TAny* GetExtendedInterface(TUid aInterfaceUid);
+ 	void SupportedL(TMTPSupportCategory aCategory, CDesCArray& aStrings) const;
+	void ConstructL();
+
+private:
+
+    CMTPProxyDataProvider(TAny* aParams);
+	
+	TInt LocateRequestProcessorL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+	TInt LocateRequestProcessorL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection);	 
+    void SessionClosedL(const TMTPNotificationParamsSessionChange& aSession);
+    void SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession);
+private:
+
+	RPointerArray<MMTPRequestProcessor>		iActiveProcessors;	//keep track of the active processors (might from different sessions)
+  
+    /* DP utility singletons
+    */
+    RMTPDpSingletons					iDpSingletons;
+    
+    TInt									iActiveProcessor;
+    TBool									iActiveProcessorRemoved;
+    RMTPProxyDpSingletons   iSingletons;
+
+ 	/**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+    };
+#endif // CMTPPROXYDP_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpproxydpconfigmgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,53 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPPROXYDPPCONFIGMGR_H
+#define CMTPPROXYDPPCONFIGMGR_H
+#include "mtpdebug.h"
+#include <e32base.h>
+#include <badesca.h>
+struct FileMappingStruct
+	{
+	TUint iDpUid;
+	CDesCArray*						iFileArray;
+	};
+class MMTPDataProviderFramework;
+
+class CMTPProxyDpConfigMgr : public CBase
+	{
+public:
+	static CMTPProxyDpConfigMgr* NewL(MMTPDataProviderFramework& aFramework);
+	~CMTPProxyDpConfigMgr();
+	TBool GetFileName(const TDesC& aFileName,TInt& aIndex);
+	TUint GetDPId(const TInt& aIndex);	
+private:
+	CMTPProxyDpConfigMgr(MMTPDataProviderFramework& aFramework);
+	void ConstructL();
+	void InsertToMappingStruct(FileMappingStruct& aRef);
+private:
+	MMTPDataProviderFramework& iFramework;
+	RArray<FileMappingStruct> iMappingStruct;
+	/**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // CMTPPROXYDPPCONFIGMGR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpsendobjectinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,81 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPSENDOBJECTINFO_H
+#define CMTPSENDOBJECTINFO_H
+
+#include "cmtprequestprocessor.h"
+#include "mmtptransactionproxy.h"
+#include "rmtpframework.h"
+#include "rmtpproxydpsingletons.h"
+#include "mtpdebug.h"
+
+class CMTPTypeObjectInfo;
+class MMTPRequestProcessor;
+
+/** 
+Implements proxy data provider SendObjectInfo request processor
+@internalComponent
+  
+*/
+class CMTPSendObjectInfo : public CMTPRequestProcessor, public MMTPTransactionProxy
+	{
+public:
+
+	static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);	
+	~CMTPSendObjectInfo();	
+
+private: // From CMTPRequestProcessor
+
+	void ServiceL();
+	TBool DoHandleResponsePhaseL();
+	TBool HasDataphase() const;
+	
+private:	
+
+	CMTPSendObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+	void ConstructL();
+
+private: // From MMTPTransactionProxy
+
+    void ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+
+private:
+
+	void DoHandleSendObjectInfoCompleteL();
+		
+private:
+
+	CMTPTypeObjectInfo*		iObjectInfo;
+	TMTPTypeResponse		iResponse;
+	RMTPFramework           iSingletons;
+	RMTPProxyDpSingletons   iProxyDpSingletons;
+	
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+	 
+#endif // CMTPSENDOBJECTINFO_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpsendobjectproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,70 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPSENDOBJECTPROPLIST_H
+#define CMTPSENDOBJECTPROPLIST_H
+
+#include "cmtprequestprocessor.h"
+#include "mmtptransactionproxy.h"
+#include "rmtpframework.h"
+
+class CMTPTypeObjectPropList;
+class MMTPRequestProcessor;
+
+/** 
+Implements the proxy data provider's SendObjectPropList request processor.
+@internalComponent
+  
+*/
+class CMTPSendObjectPropList : public CMTPRequestProcessor, public MMTPTransactionProxy
+    {
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPSendObjectPropList();    
+
+private: // From CMTPRequestProcessor
+
+    void ServiceL();
+    TBool DoHandleResponsePhaseL();
+   	TBool HasDataphase() const;
+
+private: // From MMTPTransactionProxy
+
+    void ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    
+private:    
+
+    CMTPSendObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);
+    void ConstructL();
+    
+    void SendResponseL(TUint16 aCode);
+        
+private: // Owned
+
+    CMTPTypeObjectPropList* iObjectPropList;
+    RMTPFramework           iSingletons;
+    };
+     
+#endif // CMTPSENDOBJECTPROPLIST_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpsetobjectproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,78 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPSETOBJECTPROPLIST_H
+#define CMTPSETOBJECTPROPLIST_H
+
+#include "cmtprequestprocessor.h"
+#include "mmtptransactionproxy.h"
+#include "rmtpframework.h"
+
+class CMTPTypeObjectPropList;
+class MMTPRequestProcessor;
+
+/** 
+Implements the proxy data provider SetObjectPropList request processor
+@internalComponent
+  
+*/
+class CMTPSetObjectPropList : public CMTPRequestProcessor, public MMTPTransactionProxy
+    {
+public:
+
+    static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection);    
+    ~CMTPSetObjectPropList(); 
+
+private: // CMTPRequestProcessor
+
+    void ServiceL();
+    TBool DoHandleResponsePhaseL();
+
+private: // From MMTPTransactionProxy
+
+    void ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus);
+    void ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+
+private: // From CActive
+
+    void RunL();
+
+private:    
+
+    CMTPSetObjectPropList(MMTPDataProviderFramework& aFramework,MMTPConnection& aConnection);
+    void ConstructL();
+    
+    void DoHandleSetObjectPropListL();
+    void Reschedule(TInt aError);
+            
+private:
+
+    CMTPTypeObjectPropList* iObjectPropList;
+    TMTPResponseCode        iResponseCode;
+    TUint32                 iPropertyIdx;
+    TUint32                 iDpIdx;
+    RArray<TUint>           iDpList;
+    TBool                   iDpListCreated;
+    RMTPFramework           iSingletons;
+    };
+    
+#endif // CMTPSETOBJECTPROPLIST_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/inc/mtpproxydppanic.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,47 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mmtpproxydppanic.h
+// proxy data provider panic code  
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __MTPPROXYDPPANIC_H__
+#define __MTPPROXYDPPANIC_H__
+
+#include <e32std.h>
+
+enum TMTPProxyDpPanic
+	{
+	EMTPNoMatchingProcessor = 0,
+	EMTPNotSameRequestProxy = 1,
+	EMTPWrongRequestPhase = 2,
+	EMTPElementIndexOutOfBound = 3,
+	EMTPInvalidDataType = 4,
+	EMTPRoutingError = 5,
+	};
+
+_LIT(KMTProxyDpPanic, "MTP Proxy Data Provider");
+inline void Panic(TMTPProxyDpPanic aCode)
+	{
+	User::Panic(KMTProxyDpPanic, aCode);
+	};
+	
+
+#endif // __MTPPROXYDPPANIC_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/inc/mtpproxydpprocessor.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,48 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __MTPPROXYDPPROCESSOR_H__
+#define __MTPPROXYDPPROCESSOR_H__
+
+//forward declaration
+class MMTPConnection;
+class TMTPTypeRequest;
+class CMTPDataProviderPlugin;
+class MMTPDataProviderFramework;
+class MMTPRequestProcessor;
+
+
+/** 
+Defines proxy data provider request processor
+
+@internalTechnology
+  
+*/
+class MTPProxyDpProcessor
+	{
+public:
+	static MMTPRequestProcessor* CreateL(
+										MMTPDataProviderFramework& aFramework,
+										const TMTPTypeRequest& aRequest, 
+										MMTPConnection& aConnection);	
+	};
+	
+#endif // __MTPPROXYDPPROCESSOR_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/inc/rmtpproxydpsingletons.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,70 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+#ifndef RMTPPROXYDPSINGLETONS_H
+#define RMTPPROXYDPSINGLETONS_H
+
+#include <e32base.h>
+class CMTPProxyDpConfigMgr;
+class MMTPDataProviderFramework;
+
+class RMTPProxyDpSingletons
+    {
+public:  
+    RMTPProxyDpSingletons();  
+
+    void OpenL(MMTPDataProviderFramework& aFramework);
+    void Close();
+    
+    CMTPProxyDpConfigMgr& FrameworkConfig();
+    
+private:
+    
+    /**
+    Implements the singletons reference block.
+    */
+    class CSingletons : public CObject
+        {
+    public: 
+    
+        static CSingletons& OpenL(MMTPDataProviderFramework& aFramework);
+        void Close();
+
+    private:
+        static CSingletons* NewL(MMTPDataProviderFramework& aFramework);
+        virtual ~CSingletons();
+        void ConstructL(MMTPDataProviderFramework& aFramework);
+
+    public: // Owned
+
+         /**
+        The file config manager.
+        */
+        CMTPProxyDpConfigMgr*    iConfigMgr;
+    	};
+    
+private: // Owned
+
+    /**
+    The singletons reference block.
+    */
+    CSingletons*    iSingletons;
+};	
+	
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpcopyobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,317 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtptypearray.h>
+
+#include "cmtpdataprovider.h"
+#include "cmtpcopyobject.h"
+#include "cmtpparserrouter.h"
+#include "mtpproxydppanic.h"
+#include "cmtpobjectbrowser.h"
+#include "mtpdppanic.h"
+#include "cmtpobjectmgr.h"
+
+__FLOG_STMT( _LIT8( KComponent,"PrxyCopyObj" ); )
+const TUint KInvalidDpId = 0xFF;
+
+/**
+Two-phase construction method
+@param aFramework    The data provider framework
+@param aConnection    The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+MMTPRequestProcessor* CMTPCopyObject::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPCopyObject* self = new (ELeave) CMTPCopyObject(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+CMTPCopyObject::~CMTPCopyObject()
+    {
+    iSingletons.Close();
+    iTargetDps.Close();
+    iNewHandleParentStack.Close();
+    iHandleDepths.Close();
+    iHandles.Close();
+    delete iObjBrowser;
+    
+    __FLOG( _L8("+/-Dtor") );
+    __FLOG_CLOSE;
+    }
+
+/**
+Constructor
+*/    
+CMTPCopyObject::CMTPCopyObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+    {
+    __FLOG_OPEN( KMTPSubsystem, KComponent );
+    __FLOG( _L8("+/-Ctor") );
+    }
+    
+/**
+Second phase constructor.
+*/
+void CMTPCopyObject::ConstructL()
+    {
+    __FLOG( _L8("+ConstructL") );
+    iSingletons.OpenL();
+    iOwnerDp = KInvalidDpId;
+    __FLOG( _L8("-ConstructL") );
+    }
+    
+/**
+DeleteObject request handler
+*/ 
+void CMTPCopyObject::ServiceL()
+    {
+    __FLOG( _L8("+ServiceL") );
+    iTargetDps.Reset();
+    CMTPParserRouter& router(iSingletons.Router());
+    CMTPParserRouter::TRoutingParameters params(Request(), iConnection);
+    router.ParseOperationRequestL(params);
+    router.RouteOperationRequestL(params, iTargetDps);
+    
+    BrowseHandlesL();
+    
+    __FLOG( _L8("-ServiceL") );
+    }
+
+void CMTPCopyObject::ProxyReceiveDataL(MMTPType& /*aData*/, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& /*aStatus*/)
+    {
+    Panic(EMTPWrongRequestPhase);    
+    }
+    
+void CMTPCopyObject::ProxySendDataL(const MMTPType& /*aData*/, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& /*aStatus*/)
+    {
+    Panic(EMTPWrongRequestPhase);
+    }
+    
+#ifdef _DEBUG    
+void CMTPCopyObject::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
+#else
+void CMTPCopyObject::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
+#endif
+    {
+    __FLOG( _L8("+ProxySendResponseL") );
+    __ASSERT_DEBUG(((&iCurrentRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+    
+    if ( aStatus == KErrNone )
+        {
+        if ( iIsCopyingFolder )
+            {
+            iNewHandleParentStack.AppendL( aResponse.Uint32( TMTPTypeResponse::EResponseParameter1 ) );
+            }
+        if ( KMTPHandleNone == iRespHandle )
+            {
+            iRespHandle = aResponse.Uint32( TMTPTypeResponse::EResponseParameter1 );
+            }
+        }
+    
+    MMTPType::CopyL(aResponse, iResponse);
+	TRequestStatus* status = &aStatus;
+	User::RequestComplete(status, KErrNone);
+    __FLOG( _L8("-ProxySendResponseL") );
+    }
+
+#ifdef _DEBUG    
+void CMTPCopyObject::ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+#else
+void CMTPCopyObject::ProxyTransactionCompleteL(const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/)
+#endif
+    {
+    __FLOG( _L8("+ProxyTransactionCompleteL") );
+    __ASSERT_DEBUG(((&iCurrentRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+    TInt err((iResponse.Uint16(TMTPTypeResponse::EResponseCode) == EMTPRespCodeOK) ? KErrNone : KErrGeneral);    
+    if (err == KErrNone)
+        {
+        iCurrentHandle--;
+        Schedule(err);
+        }
+    else
+        {
+        SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) );        
+        }
+    __FLOG( _L8("-ProxyTransactionCompleteL") );
+    }
+
+void CMTPCopyObject::RunL()
+    {
+    __FLOG( _L8("+RunL") );
+    
+    __FLOG_1( _L8("iStatus == %d"), iStatus.Int() );
+
+    if ( iStatus == KErrNone )
+        {
+        NextObjectHandleL();
+        if ( iOwnerDp != KInvalidDpId )
+            {
+            CMTPDataProvider& dp = iSingletons.DpController().DataProviderL( iOwnerDp );
+            dp.ExecuteProxyRequestL( iCurrentRequest, Connection(), *this );
+            }
+        }
+    else
+        {
+        SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) );
+        }
+    __FLOG( _L8("-RunL") );
+    }
+    
+TInt CMTPCopyObject::RunError(TInt /*aError*/)
+	{
+	TRAP_IGNORE(SendResponseL(EMTPRespCodeGeneralError));
+	return KErrNone;
+	}
+	
+/**
+Completes the current asynchronous request with the specified 
+completion code.
+@param aError The asynchronous request completion request.
+*/
+void CMTPCopyObject::Schedule(TInt aError)
+    {
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete(status, aError);
+    SetActive();
+    }
+
+/**
+Sends a response to the initiator.
+@param aCode MTP response code
+*/
+void CMTPCopyObject::SendResponseL(TUint16 aCode)
+    {
+    const TMTPTypeRequest& req(Request());
+    iResponse.SetUint16(TMTPTypeResponse::EResponseCode, aCode);
+    iResponse.SetUint32(TMTPTypeResponse::EResponseSessionID, req.Uint32(TMTPTypeRequest::ERequestSessionID));
+    iResponse.SetUint32(TMTPTypeResponse::EResponseTransactionID, req.Uint32(TMTPTypeRequest::ERequestTransactionID));
+    iFramework.SendResponseL(iResponse, req, Connection());
+    }
+
+void CMTPCopyObject::BrowseHandlesL()
+    {
+    __FLOG( _L8("+BrowseHandlesL") );
+    
+    delete iObjBrowser;
+    iObjBrowser = NULL;
+    iObjBrowser = CMTPObjectBrowser::NewL( iFramework );
+    
+    iHandles.Reset();
+    iHandleDepths.Reset();
+    iNewHandleParentStack.Reset();
+    
+    iRespHandle = KMTPHandleNone;
+    
+    MMTPType::CopyL( Request(), iCurrentRequest );
+    
+    CMTPObjectBrowser::TBrowseCallback callback = { CMTPCopyObject::OnBrowseObjectL, this };
+    TUint32 handle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 );
+    TUint32 newHandleParent = Request().Uint32( TMTPTypeRequest::ERequestParameter3 );
+    iNewHandleParentStack.AppendL( newHandleParent );
+    iObjBrowser->GoL( KMTPFormatsAll, handle, KMaxTUint32, callback );
+    __FLOG_1( _L8("iHandles.Count() = %d"), iHandles.Count() );
+    
+    if ( iHandles.Count() > 0 )
+        {
+        iCurrentHandle = iHandles.Count() - 1;
+        Schedule( KErrNone );
+        }
+    else
+        {
+        SendResponseL( EMTPRespCodeInvalidObjectHandle );
+        }
+    
+    __FLOG( _L8("-BrowseHandlesL") );
+    }
+
+void CMTPCopyObject::NextObjectHandleL()
+    {
+    __FLOG( _L8("+NextObjectHandleL") );
+    __ASSERT_DEBUG( ( iNewHandleParentStack.Count() > 0 ), User::Invariant() );
+    iOwnerDp = KInvalidDpId;
+    if ( iCurrentHandle >=0 )
+        {
+        __FLOG_1( _L8("iCurrentHandle = %d"), iCurrentHandle );
+        TUint32 handle = iHandles[iCurrentHandle];
+        TUint32 depth = iHandleDepths[iCurrentHandle];
+        __FLOG_1( _L8("depth = %d"), depth );
+        if ( iCurrentHandle != ( iHandles.Count() - 1 ) )
+            {
+            TUint32 previousDepth = iHandleDepths[iCurrentHandle+1];
+            __FLOG_1( _L8("previousDepth = %d"), previousDepth );
+            if ( depth < previousDepth )
+                {
+                // Completed copying folder and all its sub-folder and files, pop all copied folders' handle which are not shallower than the current one.
+                
+                // Step 1: pop the previous handle itself if it is am empty folder
+                if ( iIsCopyingFolder )
+                    {
+                    iNewHandleParentStack.Remove( iNewHandleParentStack.Count() - 1 );
+                    }
+                // Step 2: pop the other folders' handle which are not shallower than the current one
+                TUint32 loopCount = previousDepth - depth;
+                for ( TUint i = 0; i < loopCount; i++ )
+                    {
+                    iNewHandleParentStack.Remove( iNewHandleParentStack.Count() - 1 );
+                    }
+                }
+            else if ( ( depth == previousDepth ) && iIsCopyingFolder )
+                {
+                // Completed copying empty folder, pop its handle
+                iNewHandleParentStack.Remove( iNewHandleParentStack.Count() - 1 );
+                }
+            }
+        
+        iIsCopyingFolder = EFalse;
+        iOwnerDp = iSingletons.ObjectMgr().ObjectOwnerId( handle );
+        if ( iOwnerDp == KInvalidDpId )
+            {
+            SendResponseL( EMTPRespCodeInvalidObjectHandle );
+            }
+        else
+            {
+            iCurrentRequest.SetUint32( TMTPTypeRequest::ERequestParameter1, handle );
+            iCurrentRequest.SetUint32( TMTPTypeRequest::ERequestParameter3, iNewHandleParentStack[iNewHandleParentStack.Count()-1] );
+            }
+        if ( iOwnerDp==iSingletons.DpController().DeviceDpId() )
+            {
+            iIsCopyingFolder = ETrue;
+            }
+        }
+    else
+        {
+        iResponse.SetUint32( TMTPTypeResponse::EResponseParameter1, iRespHandle );
+        SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) );
+        }
+  
+    __FLOG( _L8("-NextObjectHandleL") );
+    }
+
+void CMTPCopyObject::OnBrowseObjectL( TAny* aSelf, TUint aHandle, TUint32 aCurDepth )
+    {
+    CMTPCopyObject* self = reinterpret_cast< CMTPCopyObject* >( aSelf );
+    if ( self->iTargetDps.Find(self->iSingletons.ObjectMgr().ObjectOwnerId(aHandle)) != KErrNotFound )
+        {
+        self->iHandles.AppendL( aHandle );
+        self->iHandleDepths.AppendL( aCurDepth );        
+        }    
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpdeleteobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,280 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtpstoragemetadata.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/cmtptypearray.h>
+
+#include "cmtpdataprovider.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpdeleteobject.h"
+#include "cmtpobjectmgr.h"
+#include "cmtpparserrouter.h"
+#include "cmtpstoragemgr.h"
+#include "mtpproxydppanic.h"
+#include "rmtpframework.h"
+#include "cmtpobjectbrowser.h"
+#include "mtpdppanic.h"
+
+__FLOG_STMT( _LIT8( KComponent,"PrxyDelObj" ); )
+const TUint KInvalidDpId = 0xFF;
+
+/**
+Two-phase construction method
+@param aFramework    The data provider framework
+@param aConnection    The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+MMTPRequestProcessor* CMTPDeleteObject::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPDeleteObject* self = new (ELeave) CMTPDeleteObject(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+CMTPDeleteObject::~CMTPDeleteObject()
+    {
+    iSingletons.Close();
+    iTargetDps.Close();
+    iHandles.Close();
+    delete iObjBrowser;
+    
+    __FLOG( _L8("+/-Dtor") );
+    __FLOG_CLOSE;
+    }
+
+/**
+Constructor
+*/    
+CMTPDeleteObject::CMTPDeleteObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
+    iDeletedObjectsNumber(0)
+    {
+    __FLOG_OPEN( KMTPSubsystem, KComponent );
+    __FLOG( _L8("+/-Ctor") );
+    }
+    
+/**
+Second phase constructor.
+*/
+void CMTPDeleteObject::ConstructL()
+    {
+    __FLOG( _L8("+ConstructL") );
+    
+    iSingletons.OpenL();
+    iOwnerDp = KInvalidDpId;
+    __FLOG( _L8("-ConstructL") );
+    }
+    
+/**
+DeleteObject request handler
+*/ 
+void CMTPDeleteObject::ServiceL()
+    {
+    __FLOG( _L8("+ServiceL") );
+    iTargetDps.Reset();
+    CMTPParserRouter& router(iSingletons.Router());
+    CMTPParserRouter::TRoutingParameters params(Request(), iConnection);
+    router.ParseOperationRequestL(params);
+    router.RouteOperationRequestL(params, iTargetDps);
+    
+    BrowseHandlesL();
+    
+    __FLOG( _L8("-ServiceL") );
+    }
+
+void CMTPDeleteObject::ProxyReceiveDataL(MMTPType& /*aData*/, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& /*aStatus*/)
+    {
+    Panic(EMTPWrongRequestPhase);    
+    }
+    
+void CMTPDeleteObject::ProxySendDataL(const MMTPType& /*aData*/, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& /*aStatus*/)
+    {
+    Panic(EMTPWrongRequestPhase);
+    }
+    
+#ifdef _DEBUG    
+void CMTPDeleteObject::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
+#else
+void CMTPDeleteObject::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
+#endif
+    {
+    __ASSERT_DEBUG(( ( (iRequest == &aRequest) || ( &iCurrentRequest == &aRequest ) ) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+    MMTPType::CopyL(aResponse, iResponse);
+	TRequestStatus* status = &aStatus;
+	User::RequestComplete(status, KErrNone);
+    }
+
+#ifdef _DEBUG    
+void CMTPDeleteObject::ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+#else
+void CMTPDeleteObject::ProxyTransactionCompleteL(const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/)
+#endif
+    {
+    __ASSERT_DEBUG(( ( (iRequest == &aRequest) || ( &iCurrentRequest == &aRequest ) ) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+    TInt err(KErrNone);      
+    TUint16 responseCode = iResponse.Uint16(TMTPTypeResponse::EResponseCode);
+    
+    //Delete one object successfully
+    if (responseCode == EMTPRespCodeOK)
+        {
+        ++iDeletedObjectsNumber;
+        }
+    //if object is write-protected or assocation object is not empty, we continue to schedule the AO to delete the 
+    //following objects. If it is not the 2 cases, just schedule with KErrGeneral so that we can sendresponse directly 
+    //in RunL
+    else if (responseCode != EMTPRespCodeObjectWriteProtected && responseCode != EMTPRespCodeAccessDenied)
+        {
+        err = KErrGeneral;
+        }
+    
+    ++iCurrentHandle;
+    Schedule(err);
+    }
+
+void CMTPDeleteObject::RunL()
+    {
+    __FLOG( _L8("+RunL") );
+    
+    if ( iStatus == KErrNone )
+        {
+        NextObjectHandleL();
+        if ( iOwnerDp != KInvalidDpId )
+            {
+            CMTPDataProvider& dp = iSingletons.DpController().DataProviderL( iOwnerDp );
+            dp.ExecuteProxyRequestL( iCurrentRequest, Connection(), *this );
+            }
+        }
+    else
+        {
+        SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) );
+        }
+   
+    __FLOG( _L8("-RunL") );
+    }
+    
+/**
+Completes the current asynchronous request with the specified 
+completion code.
+@param aError The asynchronous request completion request.
+*/
+void CMTPDeleteObject::Schedule(TInt aError)
+    {
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete(status, aError);
+    SetActive();
+    }
+
+/**
+Sends a response to the initiator.
+@param aCode MTP response code
+*/
+void CMTPDeleteObject::SendResponseL(TUint16 aCode)
+    {
+    const TMTPTypeRequest& req(Request());
+    iResponse.SetUint16(TMTPTypeResponse::EResponseCode, aCode);
+    iResponse.SetUint32(TMTPTypeResponse::EResponseSessionID, req.Uint32(TMTPTypeRequest::ERequestSessionID));
+    iResponse.SetUint32(TMTPTypeResponse::EResponseTransactionID, req.Uint32(TMTPTypeRequest::ERequestTransactionID));
+    iFramework.SendResponseL(iResponse, req, Connection());
+    }
+
+void CMTPDeleteObject::BrowseHandlesL()
+    {
+    __FLOG( _L8("+BrowseHandlesL") );
+    
+    delete iObjBrowser;
+    iObjBrowser = NULL;
+    iObjBrowser = CMTPObjectBrowser::NewL( iFramework );
+    
+    iHandles.Reset();
+    iCurrentHandle = 0;
+    iDeletedObjectsNumber = 0;
+    MMTPType::CopyL( Request(), iCurrentRequest );
+    
+    CMTPObjectBrowser::TBrowseCallback callback = { CMTPDeleteObject::OnBrowseObjectL, this };
+    TUint32 handle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 );
+    TUint32 fmtCode = KMTPFormatsAll;
+    if ( KMTPHandleAll == handle )
+    	{
+    	fmtCode= Request().Uint32( TMTPTypeRequest::ERequestParameter2 );
+    	}
+    iObjBrowser->GoL( fmtCode, handle, KMaxTUint32, callback );
+    
+    if ( 0 == iHandles.Count() )
+        {
+        SendResponseL( EMTPRespCodeOK );        
+        }
+    else
+        {
+        Schedule( KErrNone );
+        }
+
+    __FLOG( _L8("-BrowseHandlesL") );
+    }
+
+void CMTPDeleteObject::NextObjectHandleL()
+    {
+    __FLOG( _L8("+NextObjectHandleL") );
+
+    iOwnerDp = KInvalidDpId;
+    if ( iCurrentHandle < iHandles.Count() )
+        {
+        TUint32 handle = iHandles[iCurrentHandle];
+        iOwnerDp = iSingletons.ObjectMgr().ObjectOwnerId( handle );
+        if ( iOwnerDp == KInvalidDpId )
+            {
+            SendResponseL(EMTPRespCodeInvalidObjectHandle);
+            }
+        else
+            {
+            iCurrentRequest.SetUint32( TMTPTypeRequest::ERequestParameter1, handle );
+            }
+        }
+    else
+        {
+        if (iDeletedObjectsNumber == iHandles.Count())
+            {
+            SendResponseL(EMTPRespCodeOK);
+            }
+        else if (iDeletedObjectsNumber == 0)
+            {
+            SendResponseL(EMTPRespCodeObjectWriteProtected);
+            }
+        else
+            {
+            SendResponseL(EMTPRespCodePartialDeletion);
+            }
+        }
+
+    __FLOG( _L8("-NextObjectHandleL") );
+    }
+
+void CMTPDeleteObject::OnBrowseObjectL( TAny* aSelf, TUint aHandle, TUint32 /*aCurDepth*/ )
+    {
+    CMTPDeleteObject* self = reinterpret_cast< CMTPDeleteObject* >( aSelf );
+    if ( self->iTargetDps.Find(self->iSingletons.ObjectMgr().ObjectOwnerId(aHandle)) != KErrNotFound )
+        {
+        self->iHandles.AppendL( aHandle );
+        }
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpdeleteobjectproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,347 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/cmtptypedeleteobjectproplist.h>
+#include <mtp/tmtptypedatapair.h>
+#include <mtp/mmtpdataproviderframework.h>
+
+#include "cmtpdeleteobjectproplist.h"
+#include "mtpproxydppanic.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpobjectmgr.h"
+#include "cmtpdataprovider.h"
+
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"DeleteObjectPropList");)
+
+
+/**
+Verification data for the DeleteObjectPropList request
+*/
+const TMTPRequestElementInfo KMTPDeleteObjectPropListPolicy[] = 
+    {
+        { TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, (EMTPElementAttrDir | EMTPElementAttrWrite), 1, KMTPHandleAll, 0 }
+    };
+
+/**
+Two-phase construction method
+@param aFramework    The data provider framework
+@param aConnection    The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+MMTPRequestProcessor* CMTPDeleteObjectPropList::NewL( MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection )
+    {
+    CMTPDeleteObjectPropList* self = new (ELeave) CMTPDeleteObjectPropList( aFramework, aConnection );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/ 
+CMTPDeleteObjectPropList::~CMTPDeleteObjectPropList()
+    {
+    __FLOG(_L8("~CMTPDeleteObjectPropList - Entry"));
+    
+    delete iDeleteObjectPropList;
+    iSingletons.Close();
+    iTargetDps.Close();
+    iSubDatasets.ResetAndDestroy();
+    
+    __FLOG(_L8("~CMTPDeleteObjectPropList - Exit"));
+    __FLOG_CLOSE;
+    }
+
+CMTPDeleteObjectPropList::CMTPDeleteObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection):
+CMTPRequestProcessor( aFramework, aConnection, (sizeof(KMTPDeleteObjectPropListPolicy) / sizeof(TMTPRequestElementInfo)), KMTPDeleteObjectPropListPolicy )
+    {
+    
+    }
+
+void CMTPDeleteObjectPropList::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry"));
+    
+    iSingletons.OpenL();
+    
+    __FLOG(_L8("ConstructL - Exit"));
+    }
+
+void CMTPDeleteObjectPropList::ServiceL()
+    {
+    __FLOG(_L8("ServiceL - Entry"));
+    
+    delete iDeleteObjectPropList;
+    iTargetDps.Reset();
+    iSubDatasets.Reset();
+    
+
+    iDeleteObjectPropList = CMTPTypeDeleteObjectPropList::NewL();
+    ReceiveDataL(*iDeleteObjectPropList);
+
+    __FLOG(_L8("ServiceL - Exit"));
+    }
+
+TBool CMTPDeleteObjectPropList::DoHandleResponsePhaseL()
+    {
+    __FLOG(_L8("DoHandleResponsePhaseL - Entry"));
+      
+    //if the ObjectHandle is 0x00000000, 
+    //discard the received data and return Invalid_ObjectHandle error code
+    if ( Request().Uint32(TMTPTypeRequest::ERequestParameter1) == KMTPHandleNone )
+     {  
+     TRAP_IGNORE(SendResponseL(EMTPRespCodeInvalidObjectHandle));
+     }
+    else
+     {
+     BuildSubRequestsL();
+     
+     if(iTargetDps.Count() == 0)
+    	 {
+    	 TRAP_IGNORE(SendResponseL(EMTPRespCodeInvalidDataset));
+    	 }
+     else
+    	 {
+	     iCurrentTarget = 0;
+	     
+	     Schedule(KErrNone);
+    	 }
+     }
+    
+    __FLOG(_L8("DoHandleResponsePhaseL - Exit"));
+    
+    return EFalse;
+    }
+
+void CMTPDeleteObjectPropList::BuildSubRequestsL()
+    {
+    __FLOG(_L8("BuildSubRequests - Entry"));
+
+    TInt count(iDeleteObjectPropList->NumberOfElements());
+    TInt dpid(0);
+    TInt index(-1);
+    TInt tmpDpid(-1);
+    for( TUint i(0); i < count; i++)
+        {
+        TMTPTypeDataPair& temp(iDeleteObjectPropList->ElementL(i));
+        TMTPTypeDataPair* element = new (ELeave) TMTPTypeDataPair();
+        CleanupStack::PushL(element);
+        MMTPType::CopyL( temp, *element );
+        dpid = iSingletons.ObjectMgr().ObjectOwnerId( temp.Uint32(TMTPTypeDataPair::EOwnerHandle) );
+        if ( tmpDpid != dpid )
+            {
+            iTargetDps.Append(dpid);
+            CMTPTypeDeleteObjectPropList* dataset = CMTPTypeDeleteObjectPropList::NewLC();
+            iSubDatasets.AppendL( dataset );
+            dataset->AppendL( element);
+            CleanupStack::Pop(dataset);
+            
+            tmpDpid = dpid;
+            ++index;
+            }
+        else
+            {          
+            iSubDatasets[index]->AppendL( element );
+            }
+        
+        CleanupStack::Pop(element);
+        }
+    
+    __FLOG(_L8("BuildSubRequests - Exit"));
+    }
+
+TBool CMTPDeleteObjectPropList::HasDataphase() const
+    {
+    __FLOG(_L8("HasDataphase - Entry"));
+        
+    
+        
+    __FLOG(_L8("HasDataphase - Exit"));
+    
+    return ETrue;
+    }
+
+
+#ifdef _DEBUG
+void CMTPDeleteObjectPropList::ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
+#else
+void CMTPDeleteObjectPropList::ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
+#endif
+    {
+    __ASSERT_DEBUG(iRequest == &aRequest && &iConnection == &aConnection, Panic(EMTPNotSameRequestProxy));
+
+    MMTPType::CopyL( *iSubDatasets[iCurrentTarget], aData);
+    TRequestStatus* status = &aStatus;
+    User::RequestComplete(status, KErrNone);
+    }
+
+
+void CMTPDeleteObjectPropList::ProxySendDataL(const MMTPType& /*aData*/, const TMTPTypeRequest&  /*aRequest*/, MMTPConnection& /* aConnection */, TRequestStatus& /*aStatus*/)
+    {
+    __FLOG(_L8("ProxySendDataL - Entry"));
+        
+    Panic(EMTPWrongRequestPhase);
+        
+    __FLOG(_L8("ProxySendDataL - Exit"));
+    }
+
+/**
+  Send the corresponding response for the request is routed by Proxy DP
+  ProxySendResponseL will complete the request of framework's AO, then switch the transaction phase to TranscationComplete
+  so ProxyTransactionCompleteL will be called later.
+  @param aResponse      The response which is sent by some DP
+  @param aRequest       The corresponding request 
+  @param aConnection    The corresponding connection
+  @param aStatus        The status of framework AO 
+ */
+#ifdef _DEBUG    
+void CMTPDeleteObjectPropList::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
+#else
+void CMTPDeleteObjectPropList::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
+#endif
+    {
+    __FLOG(_L8("ProxySendResponseL - Entry"));
+    
+    __ASSERT_DEBUG(((iRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+    MMTPType::CopyL(aResponse, iResponse);
+    TRequestStatus* status = &aStatus;
+    User::RequestComplete(status, KErrNone);
+    
+    __FLOG(_L8("ProxySendResponseL - Exit"));
+    }
+
+
+/**
+  Complete the transaction phase for the request is routed by Proxy DP
+  Drive its AO to route other requests or send the response.
+  @param aRequest       The corresponding request 
+  @param aConnection    The corresponding connection
+ */
+#ifdef _DEBUG
+void CMTPDeleteObjectPropList::ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+#else
+void CMTPDeleteObjectPropList::ProxyTransactionCompleteL(const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/)
+#endif
+    {
+    __FLOG(_L8("ProxyTransactionCompleteL - Entry"));
+        
+    __ASSERT_DEBUG(((iRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+    const TUint16 KResponseCode(iResponse.Uint16(TMTPTypeResponse::EResponseCode)); 
+    TInt err((KResponseCode == EMTPRespCodeOK) ? KErrNone : KErrGeneral);    
+    if (err == KErrNone)
+       {
+       ++iCurrentTarget;
+       }
+    else
+        {
+        //when error, calculate the zero-based index of the first failed property
+        TUint index = iResponse.Uint32(TMTPTypeResponse::EResponseParameter1);
+        for(TInt i = 0 ; i < iCurrentTarget; i++ )
+            {
+            index  += iSubDatasets[i]->NumberOfElements();
+            }
+        iResponse.SetUint32(TMTPTypeResponse::EResponseParameter1, index );
+        
+        if(KResponseCode == EMTPRespCodeOperationNotSupported)
+            {
+            iResponse.SetUint16(TMTPTypeResponse::EResponseCode, EMTPRespCodeInvalidObjectHandle );
+            }
+        }
+
+    Schedule(err);
+        
+    __FLOG(_L8("ProxyTransactionCompleteL - Exit"));
+    }
+
+
+    
+void CMTPDeleteObjectPropList::SendResponseL(TUint16 aCode)
+    {
+    __FLOG(_L8("SendResponseL - Entry"));
+        
+    const TMTPTypeRequest& req(Request());
+    iResponse.SetUint16(TMTPTypeResponse::EResponseCode, aCode);
+    iResponse.SetUint32(TMTPTypeResponse::EResponseSessionID, req.Uint32(TMTPTypeRequest::ERequestSessionID));
+    iResponse.SetUint32(TMTPTypeResponse::EResponseTransactionID, req.Uint32(TMTPTypeRequest::ERequestTransactionID));
+    iFramework.SendResponseL(iResponse, req, Connection());
+        
+    __FLOG(_L8("SendResponseL - Exit"));
+    }
+
+void CMTPDeleteObjectPropList::RunL()
+    {
+    __FLOG(_L8("RunL - Entry"));
+    
+    if ( (iStatus == KErrNone) && (iCurrentTarget < iTargetDps.Count()) )    
+        {
+        TUint id(iTargetDps[iCurrentTarget]);
+        
+        if(iSingletons.DpController().IsDataProviderLoaded(id))
+        	{
+        	iSingletons.DpController().DataProviderL(id).ExecuteProxyRequestL( *iRequest, Connection(), *this );
+        	}
+        else
+        	{
+        	 TUint index(0);
+	         for(TInt i = 0 ; i < iCurrentTarget; i++ )
+	            {
+	            index  += iSubDatasets[i]->NumberOfElements();
+	            }
+	         iResponse.SetUint32(TMTPTypeResponse::EResponseParameter1, index );
+        	 TRAP_IGNORE(SendResponseL(EMTPRespCodeInvalidObjectHandle));
+        	}
+        }
+    else        
+        {
+        //Any error will stop the process, and send the corresponding response.
+        SendResponseL(iResponse.Uint16(TMTPTypeResponse::EResponseCode));
+        }  
+    
+    __FLOG(_L8("RunL - Exit"));
+    }
+        
+TInt CMTPDeleteObjectPropList::RunError(TInt /*aError*/)
+    {
+    __FLOG(_L8("RunError - Entry"));
+    
+    TRAP_IGNORE(SendResponseL(EMTPRespCodeGeneralError));
+    
+    __FLOG(_L8("RunError - Exit"));
+    return KErrNone;
+    }
+            
+/**
+Completes the current asynchronous request with the specified 
+completion code.
+@param aError The asynchronous request completion request.
+*/
+void CMTPDeleteObjectPropList::Schedule(TInt aError)
+    {
+    __FLOG(_L8("Schedule - Entry"));
+    
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete(status, aError);
+    SetActive();
+    
+    __FLOG(_L8("Schedule - Exit"));
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpgetformatcapabilities.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,251 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mmtpdataproviderframework.h>
+
+
+#include "cmtpgetformatcapabilities.h"
+#include "mtpproxydppanic.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpobjectmgr.h"
+#include "cmtpdataprovider.h"
+#include "cmtpparserrouter.h"
+
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"GetFormatCapabilityList");)
+
+
+/**
+Two-phase construction method
+@param aFramework    The data provider framework
+@param aConnection    The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+MMTPRequestProcessor* CMTPGetFormatCapabilities::NewL( MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection )
+    {
+    CMTPGetFormatCapabilities* self = new (ELeave) CMTPGetFormatCapabilities( aFramework, aConnection );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/ 
+CMTPGetFormatCapabilities::~CMTPGetFormatCapabilities()
+    {
+    __FLOG(_L8("~CMTPGetFormatCapabilities - Entry"));
+    
+    iSingletons.Close();
+    delete iCapabilityList;
+    iTargetDps.Close();
+    
+    __FLOG(_L8("~CMTPGetFormatCapabilities - Exit"));
+    __FLOG_CLOSE;
+    }
+
+CMTPGetFormatCapabilities::CMTPGetFormatCapabilities(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection):
+CMTPRequestProcessor( aFramework, aConnection, 0, NULL )
+    {
+    
+    }
+
+void CMTPGetFormatCapabilities::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry"));
+    
+    iSingletons.OpenL();
+    
+    __FLOG(_L8("ConstructL - Exit"));
+    }
+
+
+void CMTPGetFormatCapabilities::ServiceL()
+    {
+    __FLOG(_L8("ServiceL - Entry"));
+    
+    delete iCapabilityList;
+    iCapabilityList = CMTPTypeFormatCapabilityList::NewL();
+    iTargetDps.Reset();
+    
+    CMTPParserRouter& router(iSingletons.Router());
+    CMTPParserRouter::TRoutingParameters params(*iRequest, iConnection);
+    router.ParseOperationRequestL(params);
+    router.RouteOperationRequestL(params, iTargetDps);
+    iCurrentTarget = 0;
+    Schedule(KErrNone);
+        
+    __FLOG(_L8("ServiceL - Exit"));
+    }
+
+void CMTPGetFormatCapabilities::ProxyReceiveDataL(MMTPType& /*aData*/, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& /*aStatus*/)
+    {
+    __FLOG(_L8("ProxyReceiveDataL - Entry"));
+    
+    Panic(EMTPWrongRequestPhase);
+    
+    __FLOG(_L8("ProxyReceiveDataL - Exit"));
+    }
+
+
+#ifdef _DEBUG   
+void CMTPGetFormatCapabilities::ProxySendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
+#else
+void CMTPGetFormatCapabilities::ProxySendDataL(const MMTPType& aData, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
+#endif
+    {
+    __FLOG(_L8("ProxySendDataL - Entry"));
+    
+    __ASSERT_DEBUG(((iRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+    __ASSERT_DEBUG(aData.Type() == EMTPTypeFormatCapabilityListDataset, Panic(EMTPInvalidDataType));
+    
+    
+    const CMTPTypeFormatCapabilityList& sourceList(static_cast<const CMTPTypeFormatCapabilityList&>(aData));
+    const TInt count(sourceList.NumberOfElements());
+    for(TInt i(0); (i < count); i++)
+        {
+        CMTPTypeFormatCapability& element(sourceList.ElementL(i)); 
+        CMTPTypeFormatCapability* newElement = CMTPTypeFormatCapability::NewLC();
+        MMTPType::CopyL(element, *newElement);
+        iCapabilityList->AppendL(newElement);
+        CleanupStack::Pop(newElement);
+        }
+
+    TRequestStatus* status = &aStatus;
+    User::RequestComplete(status, KErrNone);
+    
+    __FLOG(_L8("ProxySendDataL - Exit"));
+    }
+
+/**
+  Send the corresponding response for the request is routed by Proxy DP
+  ProxySendResponseL will complete the request of framework's AO, then switch the transaction phase to TranscationComplete
+  so ProxyTransactionCompleteL will be called later.
+  @param aResponse      The response which is sent by some DP
+  @param aRequest       The corresponding request 
+  @param aConnection    The corresponding connection
+  @param aStatus        The status of framework AO 
+ */
+#ifdef _DEBUG
+void CMTPGetFormatCapabilities::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
+#else
+void CMTPGetFormatCapabilities::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
+#endif
+    {
+    __FLOG(_L8("ProxySendResponseL - Entry"));
+    
+    __ASSERT_DEBUG(((iRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+    MMTPType::CopyL(aResponse, iResponse);
+    TRequestStatus* status(&aStatus);
+    User::RequestComplete(status, KErrNone);
+    
+    __FLOG(_L8("ProxySendResponseL - Exit"));
+    }
+
+
+/**
+  Complete the transaction phase for the request is routed by Proxy DP
+  Drive its AO to route other requests or send the response.
+  @param aRequest       The corresponding request 
+  @param aConnection    The corresponding connection
+ */
+#ifdef _DEBUG
+void CMTPGetFormatCapabilities::ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+#else
+void CMTPGetFormatCapabilities::ProxyTransactionCompleteL(const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/)
+#endif
+    {
+    __FLOG(_L8("ProxyTransactionCompleteL - Entry"));
+        
+    __ASSERT_DEBUG(((iRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+    TInt err((iResponse.Uint16(TMTPTypeResponse::EResponseCode) == EMTPRespCodeOK) ? KErrNone : KErrGeneral);    
+    if (err == KErrNone)
+        {
+        ++iCurrentTarget;
+        }
+    Schedule(err);
+        
+    __FLOG(_L8("ProxyTransactionCompleteL - Exit"));
+    }
+
+
+void CMTPGetFormatCapabilities::SendResponseL(TUint16 aCode)
+    {
+    __FLOG(_L8("SendResponseL - Entry"));
+        
+    const TMTPTypeRequest& req(Request());
+    iResponse.SetUint16(TMTPTypeResponse::EResponseCode, aCode);
+    iResponse.SetUint32(TMTPTypeResponse::EResponseSessionID, req.Uint32(TMTPTypeRequest::ERequestSessionID));
+    iResponse.SetUint32(TMTPTypeResponse::EResponseTransactionID, req.Uint32(TMTPTypeRequest::ERequestTransactionID));
+    iFramework.SendResponseL(iResponse, req, Connection());
+        
+    __FLOG(_L8("SendResponseL - Exit"));
+    }
+
+void CMTPGetFormatCapabilities::RunL()
+    {
+    __FLOG(_L8("RunL - Entry"));
+       
+    if (iStatus == KErrNone)
+       {
+       if (iCurrentTarget < iTargetDps.Count())   
+           {
+           TUint id(iTargetDps[iCurrentTarget]);
+           CMTPDataProvider& dp(iSingletons.DpController().DataProviderL(id));
+           dp.ExecuteProxyRequestL(*iRequest, Connection(), *this);
+           }
+       else
+           {
+           SendDataL(*iCapabilityList);
+           }
+       }
+   else
+       {
+       SendResponseL(iResponse.Uint16(TMTPTypeResponse::EResponseCode));
+       }   
+        
+    __FLOG(_L8("RunL - Exit"));
+    }
+        
+TInt CMTPGetFormatCapabilities::RunError(TInt /*aError*/)
+    {
+    __FLOG(_L8("RunError - Entry"));
+    
+    TRAP_IGNORE(SendResponseL(EMTPRespCodeGeneralError));
+    
+    __FLOG(_L8("RunError - Exit"));
+    return KErrNone;
+    }
+            
+/**
+Completes the current asynchronous request with the specified 
+completion code.
+@param aError The asynchronous request completion request.
+*/
+void CMTPGetFormatCapabilities::Schedule(TInt aError)
+    {
+    __FLOG(_L8("Schedule - Entry"));
+    
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete(status, aError);
+    SetActive();
+    
+    __FLOG(_L8("Schedule - Exit"));
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpgetobjectproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,305 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/cmtptypeobjectinfo.h>
+#include <mtp/cmtptypeobjectproplist.h>
+#include <mtp/cmtpdataproviderplugin.h>
+#include <mtp/cmtptypearray.h>
+
+#include "rmtpframework.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpparserrouter.h"
+#include "cmtpdataprovider.h"
+#include "cmtpgetobjectproplist.h"
+#include "mtpproxydppanic.h"
+#include "cmtpobjectbrowser.h"
+#include "mtpdppanic.h"
+#include "cmtpobjectmgr.h"
+
+__FLOG_STMT( _LIT8( KComponent,"PrxyGetObjPrpLst" ); )
+const TUint KInvalidDpId = 0xFF;
+/**
+Factory method.
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object.
+*/ 
+MMTPRequestProcessor* CMTPGetObjectPropList::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+	{
+	CMTPGetObjectPropList* self = new (ELeave) CMTPGetObjectPropList(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+Destructor.
+*/	
+CMTPGetObjectPropList::~CMTPGetObjectPropList()
+	{
+	delete iObjectPropList;
+	iSingletons.Close();
+	iTargetDps.Close();
+    iHandles.Close();
+    delete iObjBrowser;
+    __FLOG( _L8("+/-Dtor") );
+    __FLOG_CLOSE;
+	}
+
+/**
+GetObjectPropList request handler. Builds a list of all the data providers
+that support the request, then starts an active object to send it to them all.
+*/	
+void CMTPGetObjectPropList::ServiceL()
+    {
+    iTargetDps.Reset();
+    CMTPParserRouter& router(iSingletons.Router());
+    CMTPParserRouter::TRoutingParameters params(Request(), iConnection);
+    router.ParseOperationRequestL(params);
+    router.RouteOperationRequestL(params, iTargetDps);
+    
+    GetObjectHandlesL();
+    }
+
+void CMTPGetObjectPropList::ProxyReceiveDataL(MMTPType& /*aData*/, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& /*aStatus*/)
+	{	
+	Panic(EMTPWrongRequestPhase);
+	}
+
+#ifdef _DEBUG	
+void CMTPGetObjectPropList::ProxySendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
+#else
+void CMTPGetObjectPropList::ProxySendDataL(const MMTPType& aData, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
+#endif
+	{
+	__ASSERT_DEBUG((( (iRequest == &aRequest) || ( &iCurrentRequest == &aRequest ) ) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+	__ASSERT_DEBUG(aData.Type() == EMTPTypeObjectPropListDataset, Panic(EMTPInvalidDataType));
+	
+	const CMTPTypeObjectPropList& sourceObjectPropList(static_cast<const CMTPTypeObjectPropList&>(aData));
+
+	iObjectPropList->AppendObjectPropListL(sourceObjectPropList);
+	
+    TRequestStatus* status(&aStatus);
+	User::RequestComplete(status, KErrNone);	
+	}
+
+#ifdef _DEBUG	
+void CMTPGetObjectPropList::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
+#else
+void CMTPGetObjectPropList::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
+#endif
+	{
+    __FLOG( _L8("+ProxySendResponseL") );
+    
+	__ASSERT_DEBUG((( (iRequest == &aRequest) || ( &iCurrentRequest == &aRequest ) ) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+	MMTPType::CopyL(aResponse, iResponse);
+	TRequestStatus* status(&aStatus);
+	User::RequestComplete(status, KErrNone);
+	
+    __FLOG( _L8("-ProxySendResponseL") );
+	}
+
+#ifdef _DEBUG		
+void CMTPGetObjectPropList::ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+#else
+void CMTPGetObjectPropList::ProxyTransactionCompleteL(const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/)
+#endif
+	{
+    __FLOG( _L8("+ProxyTransactionCompleteL") );
+    __FLOG_1( _L8("Response code is 0x%08X,"), iResponse.Uint16(TMTPTypeResponse::EResponseCode) );
+    
+	__ASSERT_DEBUG((( (iRequest == &aRequest) || ( &iCurrentRequest == &aRequest ) ) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+	TUint16 response = iResponse.Uint16(TMTPTypeResponse::EResponseCode);
+	if(( EMTPRespCodeGroupNotSupported == response) || (EMTPRespCodeSpecificationByGroupUnsupported == response))
+		{
+		response = EMTPRespCodeOK;
+		iResponse.SetUint16(TMTPTypeResponse::EResponseCode, response);
+		}
+	
+    TInt err((EMTPRespCodeOK == response) ? KErrNone : KErrGeneral);      
+    if (err == KErrNone)
+        {
+        ++iCurrentHandle;
+        Schedule(err);
+        }
+    else
+        {
+        SendResponseL( response );    
+        }
+    
+    
+    __FLOG( _L8("-ProxyTransactionCompleteL") );
+	}	
+
+/**
+Sends the request to all the data providers that expressed an interest,
+one each iteration of the active object.
+*/
+void CMTPGetObjectPropList::RunL()
+    {
+    __FLOG( _L8("+RunL") );
+    
+    // We cannot use assertion here, because it might be completed with KErrGeneral. See ProxyTransactionCompleteL()
+    
+    if ( iStatus == KErrNone )
+        {
+        GetNextObjectPropL();
+        if ( iOwnerDp != KInvalidDpId )
+            {
+            CMTPDataProvider& dp = iSingletons.DpController().DataProviderL( iOwnerDp );
+            dp.ExecuteProxyRequestL( iCurrentRequest, Connection(), *this );
+            }
+        }
+    else
+        {
+        SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) );
+        }
+    
+    __FLOG( _L8("-RunL") );
+    }
+
+/**
+Constructor.
+*/	
+CMTPGetObjectPropList::CMTPGetObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+    {
+    __FLOG_OPEN( KMTPSubsystem, KComponent );
+    __FLOG( _L8("+/-Ctor") );
+    }
+
+/**
+Second phase constructor.
+*/
+void CMTPGetObjectPropList::ConstructL()
+    {
+    __FLOG( _L8("+ConstructL") );
+    iSingletons.OpenL();
+    iOwnerDp = KInvalidDpId;
+    __FLOG( _L8("-ConstructL") );
+    }
+
+/**
+Completes the current asynchronous request with the specified 
+completion code.
+@param aError The asynchronous request completion request.
+*/
+void CMTPGetObjectPropList::Schedule(TInt aError)
+	{
+	TRequestStatus* status(&iStatus);
+	User::RequestComplete(status, aError);
+	SetActive();
+	}
+
+/**
+Sends a response to the initiator.
+@param aCode MTP response code
+*/
+void CMTPGetObjectPropList::SendResponseL(TUint16 aCode)
+    {
+    const TMTPTypeRequest& req(Request());
+    iResponse.SetUint16(TMTPTypeResponse::EResponseCode, aCode);
+    iResponse.SetUint32(TMTPTypeResponse::EResponseSessionID, req.Uint32(TMTPTypeRequest::ERequestSessionID));
+    iResponse.SetUint32(TMTPTypeResponse::EResponseTransactionID, req.Uint32(TMTPTypeRequest::ERequestTransactionID));
+    iFramework.SendResponseL(iResponse, req, Connection());
+    }
+
+void CMTPGetObjectPropList::GetObjectHandlesL()
+    {
+    __FLOG( _L8("+GetObjectHandlesL") );
+    
+    delete iObjBrowser;
+    iObjBrowser = NULL;
+    iObjBrowser = CMTPObjectBrowser::NewL( iFramework );
+    
+    iHandles.Reset();
+    
+    delete iObjectPropList;
+    iObjectPropList = NULL;
+    iObjectPropList = CMTPTypeObjectPropList::NewL();
+    
+    iCurrentHandle = 0;
+    MMTPType::CopyL( Request(), iCurrentRequest );
+    // Set depth to be zero to avoid the other DPs enumerating objects repeatedly.
+    iCurrentRequest.SetUint32( TMTPTypeRequest::ERequestParameter5, 0 );
+    
+    CMTPObjectBrowser::TBrowseCallback callback = { CMTPGetObjectPropList::OnBrowseObjectL, this };
+    TUint32 handle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 );
+    TUint32 fmtCode = Request().Uint32( TMTPTypeRequest::ERequestParameter2 );
+    TUint32 depth = Request().Uint32( TMTPTypeRequest::ERequestParameter5 );
+    iObjBrowser->GoL( fmtCode, handle, depth, callback );
+    __FLOG_1( _L8("The total of object handles is %d"), iHandles.Count() );
+    
+    if ( 0 == iHandles.Count() )
+        {
+        if ( handle==KMTPHandleNone && depth==0 )
+            {
+            SendDataL( *iObjectPropList );
+            }
+        else if ( fmtCode != KMTPFormatsAll )
+            {
+            SendResponseL(EMTPRespCodeSpecificationByFormatUnsupported);
+            }
+        else if ( handle != KMTPHandleAll )
+            {
+            SendResponseL(EMTPRespCodeInvalidObjectHandle);
+            }
+        }
+    else
+        {
+        Schedule( KErrNone );
+        }
+    
+    __FLOG( _L8("-GetObjectHandlesL") );
+    }
+
+void CMTPGetObjectPropList::GetNextObjectPropL()
+    {
+    __FLOG( _L8("+GetNextObjectPropL") );
+
+    iOwnerDp = KInvalidDpId;
+    if ( iCurrentHandle < iHandles.Count() )
+        {
+        TUint32 handle = iHandles[iCurrentHandle];
+        iOwnerDp = iSingletons.ObjectMgr().ObjectOwnerId( handle );
+        if ( iOwnerDp == KInvalidDpId )
+            {
+            SendResponseL(EMTPRespCodeInvalidObjectHandle);
+            }
+        else
+            {
+            iCurrentRequest.SetUint32( TMTPTypeRequest::ERequestParameter1, handle );
+            }
+        }
+    else
+        {
+        SendDataL( *iObjectPropList );
+        }
+    
+    __FLOG( _L8("-GetNextObjectPropL") );
+    }
+
+void CMTPGetObjectPropList::OnBrowseObjectL( TAny* aSelf, TUint aHandle, TUint32 /*aCurDepth*/ )
+    {
+    CMTPGetObjectPropList* self = reinterpret_cast< CMTPGetObjectPropList* >( aSelf );
+    if ( self->iTargetDps.Find(self->iSingletons.ObjectMgr().ObjectOwnerId(aHandle)) != KErrNotFound )
+        {
+        self->iHandles.AppendL( aHandle );
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpgetobjectpropssupported.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,195 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/cmtpdataproviderplugin.h>
+#include <mtp/cmtptypearray.h>
+
+#include "rmtpframework.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpparserrouter.h"
+#include "cmtpdataprovider.h"
+#include "cmtpgetobjectpropssupported.h"
+#include "mtpproxydppanic.h"
+   
+/**
+Factory method.
+@param aFramework	The data provider framework
+@param aConnection	The connection from which the request comes
+@return a pointer to the created request processor object.
+*/ 
+MMTPRequestProcessor* CMTPGetObjectPropsSupported::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+	{
+	CMTPGetObjectPropsSupported* self = new (ELeave) CMTPGetObjectPropsSupported(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+Destructor.
+*/	
+CMTPGetObjectPropsSupported::~CMTPGetObjectPropsSupported()
+	{
+	iObjectPropsSupported.Reset();
+	delete iDataset;
+    iTargetDps.Close();
+	iSingletons.Close();
+	}
+
+/**
+GetObjectPropsSupported request handler. Obtains a list of all the data providers
+that support the request, then starts an active object to send it to them all.
+*/	
+void CMTPGetObjectPropsSupported::ServiceL()
+	{
+	iObjectPropsSupported.Reset();
+	iTargetDps.Reset();
+	
+	CMTPParserRouter& router(iSingletons.Router());
+    CMTPParserRouter::TRoutingParameters params(*iRequest, iConnection);
+    router.ParseOperationRequestL(params);
+    router.RouteOperationRequestL(params, iTargetDps);
+	iCurrentTarget = 0;	
+	Schedule(KErrNone);
+	}
+
+void CMTPGetObjectPropsSupported::ProxyReceiveDataL(MMTPType& /*aData*/, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& /*aStatus*/)
+	{	
+	Panic(EMTPWrongRequestPhase);
+	}
+
+#ifdef _DEBUG	
+void CMTPGetObjectPropsSupported::ProxySendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
+#else
+void CMTPGetObjectPropsSupported::ProxySendDataL(const MMTPType& aData, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
+#endif
+	{
+	__ASSERT_DEBUG(((iRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+	__ASSERT_DEBUG(aData.Type() == EMTPTypeAUINT16, Panic(EMTPInvalidDataType));
+	const CMTPTypeArray& KProperties(static_cast<const CMTPTypeArray&>(aData));
+	const TInt KCountProperties(KProperties.NumElements());
+	for (TUint i(0); (i < KCountProperties); i++)
+		{
+		const TInt KErr(iObjectPropsSupported.InsertInOrder(KProperties.ElementUint(i)));
+		if ((KErr != KErrNone) &&
+		    (KErr != KErrAlreadyExists))
+		    {
+		    User::Leave(KErr);
+		    }
+		}
+	TRequestStatus* status(&aStatus);
+	User::RequestComplete(status, KErrNone);	
+	}
+
+#ifdef _DEBUG	
+void CMTPGetObjectPropsSupported::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
+#else
+void CMTPGetObjectPropsSupported::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
+#endif
+	{
+	__ASSERT_DEBUG(((iRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+	MMTPType::CopyL(aResponse, iResponse);
+	TRequestStatus* status(&aStatus);
+	User::RequestComplete(status, KErrNone);
+	}
+
+#ifdef _DEBUG		
+void CMTPGetObjectPropsSupported::ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+#else
+void CMTPGetObjectPropsSupported::ProxyTransactionCompleteL(const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/)
+#endif
+	{
+	__ASSERT_DEBUG(((iRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+    TInt err((iResponse.Uint16(TMTPTypeResponse::EResponseCode) == EMTPRespCodeOK) ? KErrNone : KErrGeneral);    
+    if (err == KErrNone)
+        {
+        iCurrentTarget++;
+        }
+    Schedule(err);
+	}	
+
+/**
+Sends the request to all the data providers that expressed an interest,
+one each iteration of the active object.
+*/
+void CMTPGetObjectPropsSupported::RunL()
+	{
+	// We cannot use assertion here, because it might be completed with KErrGeneral. See ProxyTransactionCompleteL()
+    if (iStatus == KErrNone)
+        {
+        if (iCurrentTarget < iTargetDps.Count())   
+            {
+            const TUint KTarget(iTargetDps[iCurrentTarget]);
+            iSingletons.DpController().DataProviderL(KTarget).ExecuteProxyRequestL(*iRequest, Connection(), *this);
+            }
+        else
+    		{
+    		delete iDataset;
+    		iDataset = NULL;
+    		iDataset = CMTPTypeArray::NewL(EMTPTypeAUINT16, iObjectPropsSupported);
+			SendDataL(*iDataset);
+			}
+		}
+    else
+        {
+        SendResponseL(iResponse.Uint16(TMTPTypeResponse::EResponseCode));
+        } 	
+	}
+
+/**
+Constructor.
+*/	
+CMTPGetObjectPropsSupported::CMTPGetObjectPropsSupported(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+	{
+	
+	}
+    
+/**
+Second phase constructor.
+*/
+void CMTPGetObjectPropsSupported::ConstructL()
+    {
+    iSingletons.OpenL();
+    }
+
+/**
+Completes the current asynchronous request with the specified 
+completion code.
+@param aError The asynchronous request completion request.
+*/
+void CMTPGetObjectPropsSupported::Schedule(TInt aError)
+	{
+	TRequestStatus* status(&iStatus);
+	User::RequestComplete(status, aError);
+	SetActive();
+	}
+
+/**
+Sends a response to the initiator.
+@param aCode MTP response code
+*/
+void CMTPGetObjectPropsSupported::SendResponseL(TUint16 aCode)
+    {
+    const TMTPTypeRequest& req(Request());
+    iResponse.SetUint16(TMTPTypeResponse::EResponseCode, aCode);
+    iResponse.SetUint32(TMTPTypeResponse::EResponseSessionID, req.Uint32(TMTPTypeRequest::ERequestSessionID));
+    iResponse.SetUint32(TMTPTypeResponse::EResponseTransactionID, req.Uint32(TMTPTypeRequest::ERequestTransactionID));
+    iFramework.SendResponseL(iResponse, req, Connection());
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpmoveobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,475 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <bautils.h>
+#include <f32file.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/cmtpobjectmetadata.h>
+
+#include "cmtpdataprovider.h"
+#include "cmtpmoveobject.h"
+#include "cmtpobjectmgr.h"
+#include "cmtpparserrouter.h"
+#include "cmtpstoragemgr.h"
+#include "mtpproxydppanic.h"
+#include "cmtpobjectbrowser.h"
+#include "mtpdppanic.h"
+
+__FLOG_STMT(_LIT8(KComponent,"PrxyMoveObj");)
+const TUint KInvalidDpId = 0xFF;
+/**
+Verification data for the MoveObject request
+*/    
+const TMTPRequestElementInfo CMTPMoveObject::KMTPMoveObjectPolicy[] = 
+    {
+    	{TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrFileOrDir | EMTPElementAttrWrite, 0, 0, 0},   	
+        {TMTPTypeRequest::ERequestParameter2, EMTPElementTypeStorageId, EMTPElementAttrWrite, 0, 0, 0},                
+        {TMTPTypeRequest::ERequestParameter3, EMTPElementTypeObjectHandle, EMTPElementAttrDir | EMTPElementAttrWrite, 1, 0, 0}
+    };
+    
+/**
+Two-phase construction method
+@param aFramework    The data provider framework
+@param aConnection    The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+MMTPRequestProcessor* CMTPMoveObject::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPMoveObject* self = new (ELeave) CMTPMoveObject(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+CMTPMoveObject::~CMTPMoveObject()
+    {
+    iSingletons.Close();
+    iNewParent.Close();
+	delete iPathToCreate;
+	
+    delete iFileMan;
+    iFolderToRemove.Close();
+    delete iObjInfoCache;
+    iNewHandleParentStack.Close();
+    iHandleDepths.Close();
+    iHandles.Close();
+    delete iObjBrowser;
+    iTargetDps.Close();
+    __FLOG(_L8("+/-Dtor"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Constructor
+*/    
+CMTPMoveObject::CMTPMoveObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPMoveObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPMoveObjectPolicy)
+    {
+    __FLOG_OPEN( KMTPSubsystem, KComponent );
+    __FLOG( _L8("+/-Ctor") );
+    }
+    
+/**
+Second phase constructor.
+*/
+void CMTPMoveObject::ConstructL()
+    {
+    __FLOG( _L8("+ConstructL") );
+    iNewParent.CreateL(KMaxFileName);
+    iSingletons.OpenL();
+    iFolderToRemove.CreateL( KMaxFileName );
+    iOwnerDp = KInvalidDpId;
+    __FLOG( _L8("-ConstructL") );
+    }
+    
+/**
+MoveObject request handler
+*/ 
+void CMTPMoveObject::ServiceL()
+    {
+    __FLOG( _L8("+ServiceL") );
+    iTargetDps.Reset();
+    CMTPParserRouter& router(iSingletons.Router());
+    CMTPParserRouter::TRoutingParameters params(Request(), iConnection);
+    router.ParseOperationRequestL(params);
+    router.RouteOperationRequestL(params, iTargetDps);
+    
+    BrowseHandlesL();
+    __FLOG( _L8("-ServiceL") );
+    }
+
+void CMTPMoveObject::ProxyReceiveDataL(MMTPType& /*aData*/, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& /*aStatus*/)
+    {
+    Panic(EMTPWrongRequestPhase);    
+    }
+    
+void CMTPMoveObject::ProxySendDataL(const MMTPType& /*aData*/, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& /*aStatus*/)
+    {
+    Panic(EMTPWrongRequestPhase);
+    }
+    
+#ifdef _DEBUG    
+void CMTPMoveObject::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
+#else
+void CMTPMoveObject::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
+#endif
+    {
+    __FLOG( _L8("+ProxySendResponseL") );
+    __ASSERT_DEBUG(((&iCurrentRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+    MMTPType::CopyL(aResponse, iResponse);
+	TRequestStatus* status = &aStatus;
+	User::RequestComplete(status, KErrNone);
+    __FLOG( _L8("-ProxySendResponseL") );
+    }
+
+#ifdef _DEBUG    
+void CMTPMoveObject::ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+#else
+void CMTPMoveObject::ProxyTransactionCompleteL(const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/)
+#endif
+    {
+    __FLOG( _L8("+ProxyTransactionCompleteL") );
+    __ASSERT_DEBUG(((&iCurrentRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+    TInt err((iResponse.Uint16(TMTPTypeResponse::EResponseCode) == EMTPRespCodeOK) ? KErrNone : KErrGeneral);    
+    if (err == KErrNone)
+        {
+        iCurrentHandle--;
+        Schedule(err);
+        }
+    else
+        {
+        SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) ); 
+        }
+
+    __FLOG( _L8("-ProxyTransactionCompleteL") );
+    }
+
+/**
+Retrive the parameters of the request
+*/	
+void CMTPMoveObject::GetParametersL()
+    {
+    __FLOG( _L8("+GetParametersL") );
+    
+    TUint32 objectHandle  = iCurrentRequest.Uint32( TMTPTypeRequest::ERequestParameter1 );
+    TUint32 newParentHandle  = iCurrentRequest.Uint32( TMTPTypeRequest::ERequestParameter3 );
+    
+    if(newParentHandle == 0)
+        {
+        GetDefaultParentObjectL( iNewParent );
+        }
+    else	
+        {
+        iFramework.ObjectMgr().ObjectL( TMTPTypeUint32( newParentHandle ), *iObjInfoCache );
+        iNewParent = iObjInfoCache->DesC(CMTPObjectMetaData::ESuid);
+        }
+    
+    iFramework.ObjectMgr().ObjectL( TMTPTypeUint32( objectHandle ), *iObjInfoCache );
+    __FLOG( _L8("-GetParametersL") );	
+    }
+
+/**
+Get a default parent object, when the current request does not specify a parent object
+*/
+void CMTPMoveObject::GetDefaultParentObjectL( TDes& aObjectName )
+    {
+    __FLOG( _L8("+GetDefaultParentObjectL") );
+    const CMTPStorageMetaData& storageMetaData( iFramework.StorageMgr().StorageL(iStorageId) );
+    aObjectName = storageMetaData.DesC(CMTPStorageMetaData::EStorageSuid);
+    __FLOG( _L8("-GetDefaultParentObjectL") );
+
+    }
+
+/**
+Check if we can move the file to the new location
+*/
+TMTPResponseCode CMTPMoveObject::CanMoveObjectL(const TDesC& aOldName, const TDesC& aNewName) const
+	{
+	__FLOG(_L8("+CanMoveObjectL"));
+	TMTPResponseCode result = EMTPRespCodeOK;
+
+	TEntry fileEntry;
+	User::LeaveIfError(iFramework.Fs().Entry(aOldName, fileEntry));
+	TInt drive(iFramework.StorageMgr().DriveNumber(iStorageId));
+	User::LeaveIfError(drive);
+	TVolumeInfo volumeInfo;
+	User::LeaveIfError(iFramework.Fs().Volume(volumeInfo, drive));
+	
+	if (BaflUtils::FileExists(iFramework.Fs(), aNewName))			
+		{
+		result = EMTPRespCodeInvalidParentObject;
+		}
+	__FLOG_VA((_L8("-CanMoveObjectL (Exit with response code 0x%04X)"), result));
+	return result;	
+	}
+	
+void CMTPMoveObject::GetSuidFromHandleL(TUint aHandle, TDes& aSuid) const
+	{
+	CMTPObjectMetaData* meta(CMTPObjectMetaData::NewLC());	
+	iFramework.ObjectMgr().ObjectL(aHandle, *meta);
+	__ASSERT_DEBUG(meta, Panic(EMTPDpObjectNull));
+	aSuid = meta->DesC(CMTPObjectMetaData::ESuid);
+	CleanupStack::PopAndDestroy(meta);
+	}
+		
+void CMTPMoveObject::RunL()
+    {
+    __FLOG( _L8("+RunL") );
+    if ( iStatus==KErrNone )
+        {
+        switch ( iState )
+            {
+            case ERemoveSourceFolderTree:
+                SendResponseL(iResponse.Uint16(TMTPTypeResponse::EResponseCode));
+                break;
+            default:
+                NextObjectHandleL();
+                if ( iOwnerDp != KInvalidDpId )
+                    {
+                    CMTPDataProvider& dp = iSingletons.DpController().DataProviderL( iOwnerDp );
+                    dp.ExecuteProxyRequestL( iCurrentRequest, Connection(), *this );
+                    }
+                break;
+            }
+        }
+    else
+        {
+        SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) );
+        }
+
+    __FLOG( _L8("-RunL") );
+    }
+    	
+TInt CMTPMoveObject::RunError(TInt /*aError*/)
+	{
+	TRAP_IGNORE(SendResponseL(EMTPRespCodeGeneralError));
+	return KErrNone;
+	}
+		    
+/**
+Completes the current asynchronous request with the specified 
+completion code.
+@param aError The asynchronous request completion request.
+*/
+void CMTPMoveObject::Schedule(TInt aError)
+    {
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete(status, aError);
+    SetActive();
+    }
+        
+/**
+Sends a response to the initiator.
+@param aCode MTP response code
+*/
+void CMTPMoveObject::SendResponseL(TUint16 aCode)
+    {
+    const TMTPTypeRequest& req(Request());
+    iResponse.SetUint16(TMTPTypeResponse::EResponseCode, aCode);
+    iResponse.SetUint32(TMTPTypeResponse::EResponseSessionID, req.Uint32(TMTPTypeRequest::ERequestSessionID));
+    iResponse.SetUint32(TMTPTypeResponse::EResponseTransactionID, req.Uint32(TMTPTypeRequest::ERequestTransactionID));
+    iFramework.SendResponseL(iResponse, req, Connection());
+    }
+
+TMTPResponseCode CMTPMoveObject::CreateFolderL()
+    {
+    __FLOG( _L8("+CreateFolderL") );
+    TMTPResponseCode ret = EMTPRespCodeOK;
+    
+    GetParametersL();
+    __FLOG_1( _L("New folder parent: %S"), &iNewParent );
+    const TDesC& oldPath = iObjInfoCache->DesC( CMTPObjectMetaData::ESuid );
+    if ( iFolderToRemove.Length() == 0 )
+        {
+        iFolderToRemove = oldPath;
+        }
+    
+    TFileName fileNamePart;
+    User::LeaveIfError( BaflUtils::MostSignificantPartOfFullName( oldPath, fileNamePart ) );
+    __FLOG_1( _L("Folder name: %S"), &fileNamePart );
+    
+    if ( ( iNewParent.Length() + fileNamePart.Length() + 1 ) <= iNewParent.MaxLength() )
+        {
+        iNewParent.Append( fileNamePart );
+        iNewParent.Append( KPathDelimiter );
+        }
+    else
+        {
+        ret = EMTPRespCodeInvalidParentObject;
+        }
+    if ( EMTPRespCodeOK == ret )
+        {
+        __FLOG_VA( ( _L("Try to move %S to %S"), &oldPath, &iNewParent ) );
+        ret = CanMoveObjectL( oldPath, iNewParent );
+        
+        if ( EMTPRespCodeOK == ret )
+            {
+            TInt err = iFramework.Fs().MkDir( iNewParent );
+            User::LeaveIfError( err );
+            iNewHandleParentStack.AppendL( iObjInfoCache->Uint( CMTPObjectMetaData::EHandle ) );
+            }
+        }
+    
+    __FLOG( _L8("-CreateFolderL") );
+    return ret;
+    }
+
+void CMTPMoveObject::RemoveSourceFolderTreeL()
+    {
+    __FLOG( _L8("+RemoveSourceFolderTreeL") );
+    
+    if ( iFolderToRemove.Length() > 0 )
+        {
+        __FLOG_1( _L("Removing %S"), &iFolderToRemove );
+        delete iFileMan;
+        iFileMan = NULL;
+        iFileMan = CFileMan::NewL( iFramework.Fs() );
+        
+        iState = ERemoveSourceFolderTree;
+        User::LeaveIfError( iFileMan->RmDir( iFolderToRemove, iStatus ) );
+        SetActive();
+        }
+    else
+        {
+        SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) );
+        }
+    
+    __FLOG( _L8("-RemoveSourceFolderTreeL") );
+    }
+
+void CMTPMoveObject::BrowseHandlesL()
+    {
+    __FLOG( _L8("+BrowseHandlesL") );
+    
+    iFolderToRemove.SetLength( 0 );
+    iState = EInit;
+    
+    delete iObjBrowser;
+    iObjBrowser = NULL;
+    iObjBrowser = CMTPObjectBrowser::NewL( iFramework );
+    
+    iHandles.Reset();
+    iHandleDepths.Reset();
+    
+    delete iObjInfoCache;
+    iObjInfoCache = NULL;
+    iObjInfoCache = CMTPObjectMetaData::NewL();
+    
+    iNewHandleParentStack.Reset();
+    
+    MMTPType::CopyL( Request(), iCurrentRequest );
+    iStorageId = Request().Uint32( TMTPTypeRequest::ERequestParameter2 );
+    
+    CMTPObjectBrowser::TBrowseCallback callback = { CMTPMoveObject::OnBrowseObjectL, this };
+    TUint32 handle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 );
+    TUint32 newHandleParent = Request().Uint32( TMTPTypeRequest::ERequestParameter3 );
+    iNewHandleParentStack.AppendL( newHandleParent );
+    iObjBrowser->GoL( KMTPFormatsAll, handle, KMaxTUint32, callback );
+    __FLOG_1( _L8("iHandles.Count() = %d"), iHandles.Count() );
+    
+    if ( iHandles.Count() > 0 )
+        {
+        iCurrentHandle = iHandles.Count() - 1;
+        Schedule( KErrNone );
+        }
+    else
+        {
+        SendResponseL( EMTPRespCodeInvalidObjectHandle );
+        }
+    
+    __FLOG( _L8("-BrowseHandlesL") );
+    }
+
+void CMTPMoveObject::NextObjectHandleL()
+    {
+    __FLOG( _L8("+NextObjectHandleL") );
+    __ASSERT_DEBUG( ( iNewHandleParentStack.Count() > 0 ), User::Invariant() );
+    iOwnerDp = KInvalidDpId;
+    if ( iCurrentHandle >=0 )
+        {
+        __FLOG_1( _L8("iCurrentHandle = %d"), iCurrentHandle );
+        TUint32 handle = iHandles[iCurrentHandle];
+        TUint32 depth = iHandleDepths[iCurrentHandle];
+        __FLOG_1( _L8("depth = %d"), depth );
+        if ( iCurrentHandle !=  ( iHandles.Count() - 1 ) )
+            {
+            TUint32 previousDepth = iHandleDepths[iCurrentHandle + 1];
+            __FLOG_1( _L8("previousDepth = %d"), previousDepth );
+            if ( depth < previousDepth )
+                {
+                // Completed copying folder and all its sub-folder and files, pop all copied folders' handle which are not shallower than the current one.
+                
+                // Step 1: pop the previous handle itself if it is am empty folder
+                if ( iIsMovingFolder )
+                    {
+                    iNewHandleParentStack.Remove( iNewHandleParentStack.Count() - 1 );
+                    }
+                // Step 2: pop the other folders' handle which are not shallower than the current one
+                TUint loopCount = previousDepth - depth;
+                for ( TUint i = 0; i < loopCount; i++ )
+                    {
+                    iNewHandleParentStack.Remove( iNewHandleParentStack.Count() - 1 );
+                    }
+                }
+            else if ( ( depth == previousDepth ) && iIsMovingFolder )
+                {
+                // Completed moving empty folder, pop its handle
+                iNewHandleParentStack.Remove( iNewHandleParentStack.Count() - 1 );
+                }
+            }
+        iIsMovingFolder = EFalse;
+        iOwnerDp = iSingletons.ObjectMgr().ObjectOwnerId( handle );
+        if ( iOwnerDp == KInvalidDpId )
+            {
+            SendResponseL( EMTPRespCodeInvalidObjectHandle );
+            }
+        else
+            {
+            iCurrentRequest.SetUint32( TMTPTypeRequest::ERequestParameter1, handle );
+            iCurrentRequest.SetUint32( TMTPTypeRequest::ERequestParameter3, iNewHandleParentStack[iNewHandleParentStack.Count()-1] );
+            }
+        if ( iOwnerDp==iSingletons.DpController().DeviceDpId() )
+            {
+            iIsMovingFolder = ETrue;
+            if ( EMTPRespCodeOK != CreateFolderL() )
+			    {
+				iOwnerDp = KInvalidDpId;
+				iIsMovingFolder = EFalse;
+				SendResponseL( EMTPRespCodeInvalidParentObject );
+                }
+            }
+        }
+    else
+        {
+        RemoveSourceFolderTreeL();
+        }
+    
+    __FLOG( _L8("-NextObjectHandleL") );
+    }
+
+void CMTPMoveObject::OnBrowseObjectL( TAny* aSelf, TUint aHandle, TUint32 aCurDepth )
+    {
+    CMTPMoveObject* self = reinterpret_cast< CMTPMoveObject* >( aSelf );
+    if ( self->iTargetDps.Find(self->iSingletons.ObjectMgr().ObjectOwnerId(aHandle)) != KErrNotFound )
+        {
+        self->iHandles.AppendL( aHandle );
+        self->iHandleDepths.AppendL( aCurDepth );        
+        }      
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpobjectbrowser.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,184 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "cmtpobjectbrowser.h"
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/mtpobjectmgrquerytypes.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/cmtpobjectmetadata.h>
+
+#include "cmtprequestchecker.h"
+#include "mtpdppanic.h"
+
+__FLOG_STMT(_LIT8(KComponent,"ObjectBrowser");)
+
+
+CMTPObjectBrowser* CMTPObjectBrowser::NewL( MMTPDataProviderFramework& aDpFw )
+    {
+    CMTPObjectBrowser* self = new( ELeave ) CMTPObjectBrowser( aDpFw );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+TBool CMTPObjectBrowser::IsFolderFormat( TUint aFmtCode, TUint aFmtSubCode )
+    {
+    return ( ( EMTPFormatCodeAssociation == aFmtCode ) && ( EMTPAssociationTypeGenericFolder == aFmtSubCode ) );
+    }
+
+CMTPObjectBrowser::~CMTPObjectBrowser()
+    {
+    delete iObjMetaCache;
+    __FLOG( _L8("+/-Dtor") );
+    __FLOG_CLOSE;
+    }
+
+void CMTPObjectBrowser::GoL( TUint32 aFormatCode, TUint32 aHandle, TUint32 aDepth, const TBrowseCallback& aBrowseCallback ) const
+    {
+    __FLOG_VA( ( _L8("+GoL( 0x%08X, 0x%08X, %d )"), aFormatCode, aHandle, aDepth ) );
+    
+    switch ( aHandle )
+        {
+        case KMTPHandleAll:
+            GetObjectHandlesL( 0, KMTPStorageAll, aFormatCode, KMaxTUint, KMTPHandleNoParent, aBrowseCallback );
+            break;
+        case KMTPHandleNone:
+            GetRootObjectHandlesL( 0, aFormatCode, aDepth, aBrowseCallback );
+            break;
+        default:
+            GetObjectHandlesTreeL( 0, aFormatCode, aDepth, aHandle, aBrowseCallback );
+            break;
+        }
+    
+    __FLOG( _L8("-GoL") );
+    }
+
+CMTPObjectBrowser::CMTPObjectBrowser( MMTPDataProviderFramework& aDpFw ):
+    iDpFw( aDpFw )
+    {
+    __FLOG_OPEN( KMTPSubsystem, KComponent );
+    __FLOG( _L8("+/-Ctor") );
+    }
+
+void CMTPObjectBrowser::ConstructL()
+    {
+    __FLOG( _L8("+ConstructL") );
+    iObjMetaCache = CMTPObjectMetaData::NewL();
+    __FLOG( _L8("-ConstructL") );
+    }
+
+void CMTPObjectBrowser::GetObjectHandlesL( TUint32 aCurDepth, TUint32 aStorageId, TUint32 aFormatCode, TUint32 aDepth, TUint32 aParentHandle, const TBrowseCallback& aBrowseCallback ) const
+    {
+    __FLOG_VA( ( _L8("+GetObjectHandlesL( %d, 0x%08X, 0x%08X, %d, 0x%08X )"), aCurDepth, aStorageId, aFormatCode, aDepth, aParentHandle ) );
+    
+    RMTPObjectMgrQueryContext   context;
+    RArray< TUint >             handles;
+    TMTPObjectMgrQueryParams    params( aStorageId, aFormatCode, aParentHandle );
+    CleanupClosePushL( context );
+    CleanupClosePushL( handles );
+    
+    do
+        {
+        iDpFw.ObjectMgr().GetObjectHandlesL( params, context, handles );
+        TUint handleCount = handles.Count();
+        if ( aDepth > 0 )
+            {
+            for ( TUint i = 0; i < handleCount; i++ )
+                {
+                GetObjectHandlesTreeL( aCurDepth, aFormatCode, aDepth, handles[i], aBrowseCallback );
+                }
+            }
+        else
+            {
+            for ( TUint i = 0; i < handleCount; i++ )
+                {
+                aBrowseCallback.iCallback( aBrowseCallback.iContext, handles[i], aCurDepth );
+                }
+            }
+        }
+    while ( !context.QueryComplete() );
+    
+    CleanupStack::PopAndDestroy( &handles );
+    CleanupStack::PopAndDestroy( &context );
+    
+    __FLOG( _L8("-GetObjectHandlesL") );
+    }
+
+void CMTPObjectBrowser::GetFolderObjectHandlesL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, TUint32 aParentHandle, const TBrowseCallback& aBrowseCallback ) const
+    {
+    __FLOG_VA( ( _L8("+GetFolderObjectHandlesL( %d, 0x%08X, %d, 0x%08X )"), aCurDepth, aFormatCode, aDepth, aParentHandle ) );
+    
+    if ( 0 == aDepth )
+        {
+        aBrowseCallback.iCallback( aBrowseCallback.iContext, aParentHandle, aCurDepth );
+        }
+    else
+        {
+        GetObjectHandlesL( aCurDepth + 1, KMTPStorageAll, aFormatCode, aDepth - 1, aParentHandle, aBrowseCallback );
+        aBrowseCallback.iCallback( aBrowseCallback.iContext, aParentHandle, aCurDepth );
+        }
+    
+    __FLOG( _L8("-GetFolderObjectHandlesL") );
+    }
+
+void CMTPObjectBrowser::GetRootObjectHandlesL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, const TBrowseCallback& aBrowseCallback ) const
+    {
+    __FLOG_VA( ( _L8("+GetRootObjectHandlesL( %d, 0x%08X, %d )"), aCurDepth, aFormatCode, aDepth ) );
+    
+    switch ( aDepth )
+        {
+        case KMaxTUint:
+            GetObjectHandlesL( aCurDepth, KMTPStorageAll, aFormatCode, aDepth, KMTPHandleNoParent, aBrowseCallback );
+            break;
+        case 0:
+            // do nothing
+            break;
+        default:
+            GetObjectHandlesL( aCurDepth, KMTPStorageAll, aFormatCode, aDepth, KMTPHandleNoParent, aBrowseCallback );
+            break;
+        }
+    
+    __FLOG( _L8("-GetRootObjectHandlesL") );
+    }
+
+void CMTPObjectBrowser::GetObjectHandlesTreeL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, TUint32 aParentHandle, const TBrowseCallback& aBrowseCallback ) const
+    {
+    __FLOG_VA( ( _L8("+GetObjectHandlesTreeL( %d, 0x%08X, %d, 0x%08X )"), aCurDepth, aFormatCode, aDepth, aParentHandle ) );
+    
+    iDpFw.ObjectMgr().ObjectL( aParentHandle, *iObjMetaCache );
+#ifdef __FLOG_ACTIVE
+    RBuf suid;
+    suid.Create( iObjMetaCache->DesC( CMTPObjectMetaData::ESuid ) );
+#endif
+    if ( IsFolderFormat( iObjMetaCache->Uint( CMTPObjectMetaData::EFormatCode ), iObjMetaCache->Uint( CMTPObjectMetaData::EFormatSubCode ) ) )
+        {
+        GetFolderObjectHandlesL( aCurDepth, aFormatCode, aDepth, aParentHandle, aBrowseCallback );
+        }
+    else
+        {
+        aBrowseCallback.iCallback( aBrowseCallback.iContext, aParentHandle, aCurDepth );
+        }
+#ifdef __FLOG_ACTIVE
+    __FLOG_1( _L8("recursion_depth: %d"), aCurDepth );
+    __FLOG_1( _L("recursion_suid: %S"), &suid );
+    suid.Close();
+#endif
+    __FLOG( _L8("-GetObjectHandlesTreeL") );
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpproxydp.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,298 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/mmtpconnection.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpdataproviderapitypes.h>
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpproxydp.h"
+#include "cmtprequestprocessor.h"
+#include "mtpproxydppanic.h"
+#include "mtpproxydpprocessor.h" 
+
+static const TInt KMTPProxyDpSessionGranularity = 3;	
+
+__FLOG_STMT(_LIT8(KComponent,"CMTPProxyDataProvider");)
+
+/**
+Standard NewL method
+@param aParams	The pointer to MMTPDataProviderFramework
+*/	
+TAny* CMTPProxyDataProvider::NewL(TAny* aParams)
+	{
+	CMTPProxyDataProvider* self = new (ELeave) CMTPProxyDataProvider(aParams);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+	}
+	
+	
+void CMTPProxyDataProvider::ConstructL()
+	{  
+	__FLOG_OPEN(KMTPSubsystem, KComponent);  
+	__FLOG(_L8("ConstructL - Entry"));
+	iDpSingletons.OpenL(Framework());
+	iSingletons.OpenL(Framework());
+	__FLOG(_L8("ConstructL - Exit"));
+	}
+
+/**
+Destructor
+*/	
+CMTPProxyDataProvider::~CMTPProxyDataProvider()
+	{
+	TInt count = iActiveProcessors.Count();
+	while(count--)
+		{
+		iActiveProcessors[count]->Release();
+		}
+	iActiveProcessors.Close();	
+	iDpSingletons.Close();
+	iSingletons.Close();
+    __FLOG_CLOSE; 
+	}
+    
+void CMTPProxyDataProvider::Cancel()
+    {
+    
+    }
+
+/**
+Process the event from initiator
+@param aEvent	The event to be processed
+@param aConnection	The connection from which the event comes
+*/	
+void CMTPProxyDataProvider::ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection)
+	{
+	TInt index = LocateRequestProcessorL(aEvent, aConnection);
+	if(index != KErrNotFound)
+		{
+		iActiveProcessors[index]->HandleEventL(aEvent);
+		}
+	}
+     
+void CMTPProxyDataProvider::ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams)
+    {
+    switch (aNotification)
+        {
+    case EMTPSessionClosed:
+        SessionClosedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams));
+        break;
+        
+    case EMTPSessionOpened:
+        SessionOpenedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams));
+        break;
+        
+    default:
+        // Ignore all other notifications.
+        break;
+        }
+    }
+
+/**
+Process the request from initiator.  The method first searches if there is any matching active processor;
+if not, it creates a new processor.  It deletes the processor once it finishes.
+@param aPhase	The request transaction phase
+@param aRequest	The request to be processed
+@param aConnection	The connection from which the request comes
+*/	
+void CMTPProxyDataProvider::ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+	{	
+	TInt index = LocateRequestProcessorL(aRequest, aConnection);
+	__ASSERT_DEBUG(index != KErrNotFound, Panic(EMTPNoMatchingProcessor));
+	MMTPRequestProcessor* processor = iActiveProcessors[index];
+	iActiveProcessor = index;
+	iActiveProcessorRemoved = EFalse;
+	TBool result = processor->HandleRequestL(aRequest, aPhase);
+	if (iActiveProcessorRemoved)
+		    {
+		    processor->Release(); // destroy the processor
+		    }
+	else if (result)
+		    {    
+		    processor->Release();    	
+		    iActiveProcessors.Remove(index);
+		    }
+	iActiveProcessor = -1;
+
+	}
+	
+void CMTPProxyDataProvider::StartObjectEnumerationL(TUint32 aStorageId, TBool /*aPersistentFullEnumeration*/)
+    {
+    // The proxy data provider does not manage any data objects.
+    Framework().ObjectEnumerationCompleteL(aStorageId);
+    }
+    
+void CMTPProxyDataProvider::StartStorageEnumerationL()
+    {
+    Framework().StorageEnumerationCompleteL();
+    }
+
+/**
+Append all the operations that are supported by the proxy data provider to
+the operations array.
+@param aCategory category of operations of interest
+@param aArray array to hold the operations
+*/
+void CMTPProxyDataProvider::Supported(TMTPSupportCategory aCategory, RArray<TUint>& /*aArray*/) const
+    {
+
+    __FLOG(_L8("Supported - Entry"));
+    switch (aCategory) 
+        {        
+    case EEvents:
+        break;
+        
+    case EObjectCaptureFormats:
+    case EObjectPlaybackFormats:
+
+        break;
+        
+    case EObjectProperties:
+        break; 
+        
+    case EOperations:
+        break;  
+        
+    case EStorageSystemTypes:
+        break; 
+        
+    default:
+    
+        // Unrecognised category, leave aArray unmodified.
+        break;
+        }
+    __FLOG(_L8("Supported - Exit"));
+
+    }
+    
+
+void CMTPProxyDataProvider::SupportedL(TMTPSupportCategory /*aCategory*/, CDesCArray& /*aStrings*/) const
+	{
+	__FLOG(_L8("SupportedL - Entry"));
+	__FLOG(_L8("SupportedL - Exit"));
+	}
+  
+    
+/**
+Get the pointer to the extended interface
+@param aInterfaceUid	The uid of the extended interface
+@return the pointer to the extended interface
+*/
+TAny* CMTPProxyDataProvider::GetExtendedInterface(TUid /*aInterfaceUid*/)
+    {
+    return NULL;
+    }
+
+/**
+Standard c++ constructor
+*/
+CMTPProxyDataProvider::CMTPProxyDataProvider(TAny* aParams)
+	:CMTPDataProviderPlugin(aParams),
+	iActiveProcessors(KMTPProxyDpSessionGranularity),
+	iActiveProcessor(-1)
+	{
+	}
+
+/**
+Find or create a request processor that can process the request
+@param aRequest	The request to be processed
+@param aConnection The connection from which the request comes
+@return the index of the found/created request processor
+*/
+TInt CMTPProxyDataProvider::LocateRequestProcessorL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {
+    TInt index = KErrNotFound;
+    TInt count = iActiveProcessors.Count();
+    for(TInt i = 0; i < count; i++)
+        {
+        if(iActiveProcessors[i]->Match(aRequest, aConnection))
+            {
+            index = i;
+            break;
+            }
+        }
+    if(index == KErrNotFound)
+        {
+        MMTPRequestProcessor* processor = MTPProxyDpProcessor::CreateL(Framework(), aRequest, aConnection);
+        __ASSERT_DEBUG(processor, Panic(EMTPNoMatchingProcessor));
+        CleanupReleasePushL(*processor);
+        iActiveProcessors.AppendL(processor);
+        CleanupStack::Pop();
+        index = count;
+        }
+    return index;
+
+    }
+
+/**
+Find a request processor that can process the event
+@param aEvent	The event to be processed
+@param aConnection The connection from which the request comes
+@return the index of the found request processor, KErrNotFound if not found
+*/	
+TInt CMTPProxyDataProvider::LocateRequestProcessorL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection)
+    {
+    TInt index = KErrNotFound;
+    TInt count = iActiveProcessors.Count();
+    for(TInt i = 0; i < count; i++)
+        {
+        if(iActiveProcessors[i]->Match(aEvent, aConnection))
+            {
+            index = i;
+            break;
+            }
+        }
+    return index;
+    }
+       
+void CMTPProxyDataProvider::SessionClosedL(const TMTPNotificationParamsSessionChange& aSession)
+    {
+    TInt count = iActiveProcessors.Count();
+    while(count--)
+        {
+        MMTPRequestProcessor* processor = iActiveProcessors[count];
+        TUint32 sessionId = processor->SessionId();
+        if((sessionId == aSession.iMTPId) && (processor->Connection().ConnectionId() == aSession.iConnection.ConnectionId()))
+            {
+            iActiveProcessors.Remove(count);
+            if (count == iActiveProcessor)
+    			{
+    			iActiveProcessorRemoved = ETrue;
+    			}
+			else
+    			{    			
+    			processor->Release();
+    			} 
+            }
+        }  
+    }
+
+/**
+Prepares for a newly-opened session.
+@param aSession notification parameter block
+*/
+#ifdef __FLOG_ACTIVE
+void CMTPProxyDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& /*aSession*/)
+#else
+void CMTPProxyDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& /*aSession*/)
+#endif
+    {
+    __FLOG(_L8("SessionOpenedL - Entry"));
+    __FLOG(_L8("SessionOpenedL - Exit"));
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpproxydpconfigmgr.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,108 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+
+#include "cmtpproxydpconfigmgr.h"
+#include <barsc.h>
+#include <barsread.h>
+#include <mtp/mmtpdataproviderconfig.h>
+#include <mtp/mmtpdataproviderframework.h>
+__FLOG_STMT(_LIT8(KComponent1,"ProxyDPConfigmanager");)
+
+CMTPProxyDpConfigMgr* CMTPProxyDpConfigMgr::NewL(MMTPDataProviderFramework& aFramework)
+	{
+	CMTPProxyDpConfigMgr* self = new (ELeave) CMTPProxyDpConfigMgr(aFramework);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+CMTPProxyDpConfigMgr::CMTPProxyDpConfigMgr(MMTPDataProviderFramework& aFramework) :
+	iFramework(aFramework)
+	{
+	}
+	
+void CMTPProxyDpConfigMgr::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent1);
+	TUint32 resourceId = iFramework.DataProviderConfig().UintValue(MMTPDataProviderConfig::EOpaqueResource);
+	// Reading from resource file mtpproxydp_config.rss 
+	RResourceFile resourceFile;
+	CleanupClosePushL(resourceFile);
+	resourceFile.OpenL(iFramework.Fs(), iFramework.DataProviderConfig().DesCValue(MMTPDataProviderConfig::EResourceFileName));
+	TResourceReader resourceReader;
+	HBufC8* buffer = resourceFile.AllocReadLC(resourceId); 
+	resourceReader.SetBuffer(buffer);
+	FileMappingStruct st;
+	const TInt numberOfEntries=resourceReader.ReadInt16();
+	for(TInt count =0;count<numberOfEntries ; count++)
+		{
+		st.iDpUid=resourceReader.ReadInt32();
+		st.iFileArray = resourceReader.ReadDesCArrayL();
+		InsertToMappingStruct(st);	
+		}	
+		
+	CleanupStack::PopAndDestroy(2, &resourceFile);
+	
+	}
+	
+CMTPProxyDpConfigMgr::~CMTPProxyDpConfigMgr()
+	{
+	TInt count = iMappingStruct.Count();
+	for(TInt i=0 ; i<count ; i++)
+		{
+		delete iMappingStruct[i].iFileArray;
+		}
+	iMappingStruct.Reset();
+	iMappingStruct.Close(); 
+	__FLOG_CLOSE;
+	}
+	
+void CMTPProxyDpConfigMgr::InsertToMappingStruct(FileMappingStruct& aRef)
+	{
+	iMappingStruct.Append(aRef);
+	}
+	
+TBool CMTPProxyDpConfigMgr::GetFileName(const TDesC& aFileName,TInt& aIndex)
+	{
+    __FLOG(_L8("GetFileName - Entry"));
+    
+    __FLOG_1( _L8("aFileName = %s"), &aFileName );
+    
+	TInt count = iMappingStruct.Count();
+    __FLOG_1( _L8("count = %d"), count );
+	for(TInt i=0 ; i<count ; i++)
+		{
+		TInt err=iMappingStruct[i].iFileArray->Find(aFileName,aIndex);
+		if(err == KErrNone)
+			{
+			aIndex=i;
+		    __FLOG_1( _L8("aIndex = %d"), aIndex );
+		    __FLOG(_L8("GetFileName - Exit"));
+			return ETrue;			
+			}
+		}
+	
+    __FLOG(_L8("GetFileName - Exit"));
+	return EFalse;
+	}
+	
+TUint CMTPProxyDpConfigMgr::GetDPId(const TInt& aIndex)
+	{
+	return iMappingStruct[aIndex].iDpUid;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpsendobjectinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,262 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/cmtptypeobjectinfo.h>
+
+#include "rmtpframework.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpparserrouter.h"
+#include "cmtpdataprovider.h"
+#include "cmtpsendobjectinfo.h"
+#include "mtpproxydppanic.h"
+#include "cmtpproxydpconfigmgr.h"
+#include "cmtpstoragemgr.h"
+
+__FLOG_STMT( _LIT8( KComponent,"PrxySendObjectInfo" ); )
+
+/**
+Verification data for the SendObjectInfo request
+*/
+const TMTPRequestElementInfo KMTPSendObjectInfoPolicy[] =
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeStorageId, EMTPElementAttrWrite, 1, 0, 0},
+        {TMTPTypeRequest::ERequestParameter2, EMTPElementTypeObjectHandle, EMTPElementAttrDir | EMTPElementAttrWrite, 2, KMTPHandleAll, KMTPHandleNone}
+    };
+
+/**
+Two-phase construction method
+@param aFramework    The data provider framework
+@param aConnection    The connection from which the request comes
+@return a pointer to the created request processor object
+*/
+MMTPRequestProcessor* CMTPSendObjectInfo::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPSendObjectInfo* self = new (ELeave) CMTPSendObjectInfo(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/
+CMTPSendObjectInfo::~CMTPSendObjectInfo()
+    {
+    __FLOG(_L8("~CMTPSendObjectInfo - Entry"));
+    
+    delete iObjectInfo;
+    iSingletons.Close();
+    iProxyDpSingletons.Close();
+    
+    __FLOG(_L8("~CMTPSendObjectInfo - Exit"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Standard c++ constructor
+*/
+CMTPSendObjectInfo::CMTPSendObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPSendObjectInfoPolicy)/sizeof(TMTPRequestElementInfo), KMTPSendObjectInfoPolicy)
+    {
+
+    }
+
+/**
+Second phase constructor.
+*/
+void CMTPSendObjectInfo::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry"));
+    
+    iSingletons.OpenL();
+    
+    __FLOG(_L8("ConstructL - Exit"));
+    }
+
+/**
+SendObjectInfo/SendObject request handler
+NOTE: SendObjectInfo has to be comes before SendObject requests.  To maintain the state information
+between the two requests, the two requests are combined together in one signal processor.
+*/
+void CMTPSendObjectInfo::ServiceL()
+    {
+    delete iObjectInfo;
+    iObjectInfo = NULL;
+    iObjectInfo = CMTPTypeObjectInfo::NewL();
+    ReceiveDataL(*iObjectInfo);
+    }
+
+/**
+Override to handle the response phase of SendObjectInfo requests
+@return EFalse
+*/
+TBool CMTPSendObjectInfo::DoHandleResponsePhaseL()
+    {
+    DoHandleSendObjectInfoCompleteL();
+    return EFalse;
+    }
+
+TBool CMTPSendObjectInfo::HasDataphase() const
+    {
+    return ETrue;
+    }
+
+/**
+Handling the completing phase of SendObjectInfo request
+@return ETrue if the specified object can be saved on the specified location, otherwise, EFalse
+*/
+void CMTPSendObjectInfo::DoHandleSendObjectInfoCompleteL()
+    {
+    __FLOG(_L8("DoHandleSendObjectInfoCompleteL - Entry"));
+    
+    CMTPParserRouter::TRoutingParameters params(*iRequest, iConnection);
+    iSingletons.Router().ParseOperationRequestL(params);
+    TBool fileFlag=EFalse;
+    RArray<TUint> targets;
+    CleanupClosePushL(targets);
+    params.SetParam(CMTPParserRouter::TRoutingParameters::EParamFormatCode, iObjectInfo->Uint16L(CMTPTypeObjectInfo::EObjectFormat));
+    
+    iProxyDpSingletons.OpenL(iFramework);
+    TInt index(KErrNotFound);
+	const TUint16 formatCode=iObjectInfo->Uint16L(CMTPTypeObjectInfo::EObjectFormat);
+	__FLOG_1( _L8("formatCode = %d"), formatCode );
+	switch(formatCode)
+		{
+	case EMTPFormatCodeAssociation:
+        params.SetParam(CMTPParserRouter::TRoutingParameters::EParamFormatSubCode, iObjectInfo->Uint16L(CMTPTypeObjectInfo::EAssociationType));
+        break;
+
+    case EMTPFormatCodeScript:
+    	{
+    	__FLOG_1( _L8("formatCode = %d"), EMTPFormatCodeScript );
+    	const TDesC& filename = iObjectInfo->StringCharsL(CMTPTypeObjectInfo::EFilename);
+    	HBufC* lowFileName = HBufC::NewLC(filename.Length());
+    	TPtr16 prt(lowFileName->Des());
+    	prt.Append(filename);
+    	prt.LowerCase();   	
+    	__FLOG_1( _L8("lowFileName = %s"), &prt );
+    	if (iProxyDpSingletons.FrameworkConfig().GetFileName(prt,index) )
+    		{
+    		fileFlag=ETrue;
+    		}
+    	CleanupStack::PopAndDestroy(lowFileName);
+    	
+    	params.SetParam(CMTPParserRouter::TRoutingParameters::EParamFormatSubCode, EMTPAssociationTypeUndefined);	
+        break;
+    	}
+    default:
+    	params.SetParam(CMTPParserRouter::TRoutingParameters::EParamFormatSubCode, EMTPAssociationTypeUndefined);
+        break;
+		}
+	
+    __FLOG_1( _L8("fileFlag = %d"), fileFlag );
+    if(fileFlag)
+    	{
+    	TInt  syncdpid =  iSingletons.DpController().DpId(iProxyDpSingletons.FrameworkConfig().GetDPId(index));
+       	iSingletons.DpController().DataProviderL(syncdpid).ExecuteProxyRequestL(Request(), Connection(), *this);
+    	}
+    else
+    	{
+    	iSingletons.Router().RouteOperationRequestL(params, targets);
+        CMTPStorageMgr& storages(iSingletons.StorageMgr());
+    	const TUint KStorageId = Request().Uint32(TMTPTypeResponse::EResponseParameter1);
+        __FLOG_1( _L8("KStorageId = %d"), KStorageId );
+        __FLOG_1( _L8("targets.Count() = %d"), targets.Count() );
+        if( KMTPNotSpecified32 == KStorageId)
+            {
+            iSingletons.DpController().DataProviderL(targets[0]).ExecuteProxyRequestL(Request(), Connection(), *this);
+            }
+        else if( storages.ValidStorageId(KStorageId) )
+            {
+        	if(targets.Count() == 1)
+        		{
+        		__FLOG_1( _L8("targets[0] = %d"), targets[0] );
+        		iSingletons.DpController().DataProviderL(targets[0]).ExecuteProxyRequestL(Request(), Connection(), *this);
+        		}
+        	else
+        		{
+	            TInt dpID(KErrNotFound);
+	            if (storages.LogicalStorageId(KStorageId))
+	                {
+	                dpID = storages.LogicalStorageOwner(KStorageId);
+	                }
+	            else
+	                {
+	                dpID = storages.PhysicalStorageOwner(KStorageId);
+	                }
+	            __FLOG_1( _L8("dpID = %d"), dpID );
+	            if( targets.Find( dpID ) == KErrNotFound )
+	                {
+	                __FLOG(_L8("No target dp is found, so send one GeneralError response."));
+	                SendResponseL( EMTPRespCodeGeneralError );
+	                }
+	            else
+	                {
+	                iSingletons.DpController().DataProviderL(dpID).ExecuteProxyRequestL(Request(), Connection(), *this);
+	                }
+        		}
+            }
+        else
+            {
+            __FLOG(_L8("StorageID is invalid."));
+            SendResponseL( EMTPRespCodeInvalidStorageID );
+            }
+    	}	
+    CleanupStack::PopAndDestroy(&targets);
+    
+    __FLOG(_L8("DoHandleSendObjectInfoCompleteL - Exit"));
+    }
+
+#ifdef _DEBUG
+void CMTPSendObjectInfo::ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
+#else
+void CMTPSendObjectInfo::ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
+#endif
+    {
+    __ASSERT_DEBUG(iRequest == &aRequest && &iConnection == &aConnection, Panic(EMTPNotSameRequestProxy));
+    MMTPType::CopyL(*iObjectInfo, aData);
+    TRequestStatus* status = &aStatus;
+    User::RequestComplete(status, KErrNone);
+    }
+
+void CMTPSendObjectInfo::ProxySendDataL(const MMTPType& /*aData*/, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& /*aStatus*/)
+    {
+    Panic(EMTPWrongRequestPhase);
+    }
+
+#ifdef _DEBUG
+void CMTPSendObjectInfo::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
+#else
+void CMTPSendObjectInfo::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
+#endif
+    {
+    __ASSERT_DEBUG(iRequest == &aRequest && &iConnection == &aConnection, Panic(EMTPNotSameRequestProxy));
+    MMTPType::CopyL(aResponse, iResponse);
+    TRequestStatus* status = &aStatus;
+    User::RequestComplete(status, KErrNone);
+    }
+
+void CMTPSendObjectInfo::ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {
+    __ASSERT_DEBUG(iRequest == &aRequest && &iConnection == &aConnection, Panic(EMTPNotSameRequestProxy));
+    iFramework.SendResponseL(iResponse, aRequest, aConnection);
+    }
+    
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpsendobjectproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,251 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/tmtptyperequest.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/cmtptypeobjectproplist.h>
+
+#include "cmtpdataprovider.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpparserrouter.h"
+#include "cmtpsendobjectproplist.h"
+#include "mtpproxydppanic.h"
+#include "rmtpframework.h"
+#include "cmtpstoragemgr.h"
+
+/**
+Verification data for the SendObjectPropList request
+*/
+const TMTPRequestElementInfo KMTPSendObjectPropListPolicy[] = 
+    {
+        {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeStorageId, EMTPElementAttrWrite, 1, 0, 0}, 
+        {TMTPTypeRequest::ERequestParameter2, EMTPElementTypeObjectHandle, (EMTPElementAttrDir | EMTPElementAttrWrite), 2, KMTPHandleAll, KMTPHandleNone}
+    };
+
+/**
+Two-phase construction method
+@param aFramework    The data provider framework
+@param aConnection    The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+MMTPRequestProcessor* CMTPSendObjectPropList::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPSendObjectPropList* self = new (ELeave) CMTPSendObjectPropList(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+CMTPSendObjectPropList::~CMTPSendObjectPropList()
+    {
+    delete iObjectPropList;
+    iSingletons.Close();
+    }
+
+/**
+Standard c++ constructor
+*/    
+CMTPSendObjectPropList::CMTPSendObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, (sizeof(KMTPSendObjectPropListPolicy) / sizeof(TMTPRequestElementInfo)), KMTPSendObjectPropListPolicy)
+    {
+    
+    }
+    
+/**
+Second phase constructor.
+*/
+void CMTPSendObjectPropList::ConstructL()
+    {
+    iSingletons.OpenL();
+    }
+    
+void CMTPSendObjectPropList::ServiceL()
+    {
+    delete iObjectPropList;
+    iObjectPropList = NULL;
+    iObjectPropList = CMTPTypeObjectPropList::NewL();
+    ReceiveDataL(*iObjectPropList);
+    }
+
+TBool CMTPSendObjectPropList::HasDataphase() const
+    {
+    return ETrue;
+    }
+    
+TBool CMTPSendObjectPropList::DoHandleResponsePhaseL()
+    {
+    TMTPResponseCode rsp(EMTPRespCodeOK);
+    
+    TUint formatcode = Request().Uint32(TMTPTypeResponse::EResponseParameter3);
+    
+    if( EMTPFormatCodeAssociation != formatcode )
+        {
+        //Here, it must be that FormatCode is supported by multi DPs and the first Parameter (StorageID) should be used.
+        //Because if only one target DP, Parser&Router will directly dispatch the request to it
+        //if no target DP, the request will be dispatch to Device DP.
+        
+        RArray<TUint> targets;
+        CleanupClosePushL(targets);
+        CMTPParserRouter::TRoutingParameters params(*iRequest, iConnection);
+        iSingletons.Router().ParseOperationRequestL(params);
+        iSingletons.Router().RouteOperationRequestL(params, targets);
+        CMTPStorageMgr& storages(iSingletons.StorageMgr());
+        const TUint KStorageId = Request().Uint32(TMTPTypeResponse::EResponseParameter1);
+        if( KMTPNotSpecified32 == KStorageId)
+            {
+            rsp = EMTPRespCodeGeneralError;
+            }
+        else if( storages.ValidStorageId(KStorageId) )
+            {
+            TInt dpID(KErrNotFound);
+            if (storages.LogicalStorageId(KStorageId))
+                {
+                dpID = storages.LogicalStorageOwner(KStorageId);
+                }
+            else
+                {
+                dpID = storages.PhysicalStorageOwner(KStorageId);
+                }
+            
+            if( targets.Find( dpID ) == KErrNotFound )
+                {
+                rsp = EMTPRespCodeGeneralError;
+                }
+            else
+                {
+                iSingletons.DpController().DataProviderL(dpID).ExecuteProxyRequestL(Request(), Connection(), *this);
+                }
+            }
+        else
+            {
+            rsp = EMTPRespCodeInvalidStorageID;
+            }
+        
+        CleanupStack::PopAndDestroy(&targets);
+        
+        }
+    else
+        {
+        /* 
+        Only requests with an ObjectFormatCode of EMTPFormatCodeAssociation 
+        are routed to the proxy DP. Locate and extract the association type from 
+        the received ObjectPropList dataset.
+        */
+        TUint32 count(iObjectPropList->NumberOfElements());
+		iObjectPropList->ResetCursor();		
+        TInt    type(KErrNotFound);
+        TUint16 tmpAssocValue(EMTPAssociationTypeGenericFolder);
+        for (TUint i(0); ((rsp == EMTPRespCodeOK) && (type == KErrNotFound) && (i < count)); i++)
+            {
+			CMTPTypeObjectPropListElement& prop=iObjectPropList->GetNextElementL();			
+            if (prop.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode) == EMTPObjectPropCodeAssociationType)
+                {
+                if (prop.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT16)
+                    {
+                    rsp = EMTPRespCodeInvalidObjectPropFormat;
+                    }
+                else
+                    {
+                    type = i;
+					tmpAssocValue = prop.Uint16L(CMTPTypeObjectPropListElement::EValue);
+                    }
+                }
+            }	        
+        TUint16 assocValue;
+        if ((type == KErrNotFound) &&
+            (rsp == EMTPRespCodeOK))
+            {
+            // If no property type is specified, create a generic folder
+            assocValue = EMTPAssociationTypeGenericFolder;
+            }
+        else
+            {
+            assocValue = tmpAssocValue;
+            }
+        
+        if (rsp == EMTPRespCodeOK)
+            {
+            CMTPParserRouter::TRoutingParameters params(*iRequest, iConnection);
+            iSingletons.Router().ParseOperationRequestL(params);
+            params.SetParam(CMTPParserRouter::TRoutingParameters::EParamFormatCode, EMTPFormatCodeAssociation);
+            params.SetParam(CMTPParserRouter::TRoutingParameters::EParamFormatSubCode, assocValue);
+            RArray<TUint> targets;
+            CleanupClosePushL(targets);
+            iSingletons.Router().RouteOperationRequestL(params, targets);
+            __ASSERT_DEBUG((targets.Count() == 1), User::Invariant());
+            iSingletons.DpController().DataProviderL(targets[0]).ExecuteProxyRequestL(Request(), Connection(), *this);
+            CleanupStack::PopAndDestroy(&targets);
+            }
+        }
+    if (rsp != EMTPRespCodeOK)
+        {
+        SendResponseL(rsp);
+        }
+    return EFalse;
+    }
+
+#ifdef _DEBUG
+void CMTPSendObjectPropList::ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
+#else
+void CMTPSendObjectPropList::ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
+#endif
+    {
+    __ASSERT_DEBUG(iRequest == &aRequest && &iConnection == &aConnection, Panic(EMTPNotSameRequestProxy));
+
+	CMTPTypeObjectPropList* targetObjectPropList = static_cast<CMTPTypeObjectPropList*>(&aData); 
+	
+	targetObjectPropList->AppendObjectPropListL(*iObjectPropList);
+
+    TRequestStatus* status = &aStatus;
+    User::RequestComplete(status, KErrNone);
+    }
+    
+void CMTPSendObjectPropList::ProxySendDataL(const MMTPType& /*aData*/, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& /*aStatus*/)
+    {
+    Panic(EMTPWrongRequestPhase);
+    }
+    
+#ifdef _DEBUG    
+void CMTPSendObjectPropList::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
+#else
+void CMTPSendObjectPropList::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
+#endif
+    {
+    __ASSERT_DEBUG(iRequest == &aRequest && &iConnection == &aConnection, Panic(EMTPNotSameRequestProxy));
+    MMTPType::CopyL(aResponse, iResponse);
+    TRequestStatus* status = &aStatus;
+    User::RequestComplete(status, KErrNone);    
+    }
+
+void CMTPSendObjectPropList::ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {
+    __ASSERT_DEBUG(((iRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
+    iFramework.SendResponseL(iResponse, aRequest, aConnection);
+    }
+    
+void CMTPSendObjectPropList::SendResponseL(TUint16 aCode)
+    {
+    const TMTPTypeRequest& req(Request());
+    iResponse.SetUint16(TMTPTypeResponse::EResponseCode, aCode);
+    iResponse.SetUint32(TMTPTypeResponse::EResponseSessionID, req.Uint32(TMTPTypeRequest::ERequestSessionID));
+    iResponse.SetUint32(TMTPTypeResponse::EResponseTransactionID, req.Uint32(TMTPTypeRequest::ERequestTransactionID));
+    iFramework.SendResponseL(iResponse, req, Connection());
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpsetobjectproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,253 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypeobjectinfo.h>
+#include <mtp/cmtptypeobjectproplist.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpdataprovider.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpobjectmgr.h"
+#include "cmtpparserrouter.h"
+#include "cmtpsetobjectproplist.h"
+#include "mtpproxydppanic.h"
+#include "rmtpframework.h"
+
+/**
+Two-phase construction method
+@param aFramework    The data provider framework
+@param aConnection    The connection from which the request comes
+@return a pointer to the created request processor object
+*/ 
+MMTPRequestProcessor* CMTPSetObjectPropList::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
+    {
+    CMTPSetObjectPropList* self = new (ELeave) CMTPSetObjectPropList(aFramework, aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+CMTPSetObjectPropList::~CMTPSetObjectPropList()
+    {
+    delete iObjectPropList;
+    iDpList.Close();
+    iSingletons.Close();
+    }
+
+/**
+Standard c++ constructor
+*/    
+CMTPSetObjectPropList::CMTPSetObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
+    CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+    {
+    
+    }
+    
+/**
+Second phase constructor.
+*/
+void CMTPSetObjectPropList::ConstructL()
+    {
+    iSingletons.OpenL();
+    }
+
+/**
+SetObjectPropList request handler
+*/    
+void CMTPSetObjectPropList::ServiceL()
+    {
+    delete iObjectPropList;
+    iObjectPropList = NULL;
+    iObjectPropList = CMTPTypeObjectPropList::NewL();
+    ReceiveDataL(*iObjectPropList);    
+    }
+
+/**
+Override to handle the response phase of SetObjectPropList requests
+@return EFalse
+*/
+TBool CMTPSetObjectPropList::DoHandleResponsePhaseL()
+    {
+    iDpIdx = 0;
+    iPropertyIdx = 0;
+    iDpListCreated = EFalse;
+    iPropertyIdx = 0;
+    iDpList.Reset();
+    iObjectPropList->ResetCursor();             
+    Reschedule(KErrNone);
+    return EFalse;
+    }
+
+#ifdef _DEBUG
+void CMTPSetObjectPropList::ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
+#else
+void CMTPSetObjectPropList::ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
+#endif
+    {
+    __ASSERT_DEBUG(iRequest == &aRequest && &iConnection == &aConnection, Panic(EMTPNotSameRequestProxy));
+    __ASSERT_DEBUG(aData.Type() == EMTPTypeObjectPropListDataset, Panic(EMTPInvalidDataType));
+    
+
+	CMTPTypeObjectPropList* targetObjectPropList = static_cast<CMTPTypeObjectPropList*>(&aData); 
+	targetObjectPropList->AppendObjectPropListL(*iObjectPropList);
+
+    TRequestStatus* status = &aStatus;
+    User::RequestComplete(status, KErrNone);
+    }
+    
+void CMTPSetObjectPropList::ProxySendDataL(const MMTPType& /*aData*/, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& /*aStatus*/)
+    {
+    Panic(EMTPWrongRequestPhase);
+    }
+    
+#ifdef _DEBUG    
+void CMTPSetObjectPropList::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
+#else
+void CMTPSetObjectPropList::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
+#endif
+    {
+    __ASSERT_DEBUG(iRequest == &aRequest && &iConnection == &aConnection, Panic(EMTPNotSameRequestProxy));
+    iResponseCode = static_cast<TMTPResponseCode>(aResponse.Uint16(TMTPTypeResponse::EResponseCode));
+    iPropertyIdx = aResponse.Uint32(TMTPTypeResponse::EResponseParameter1);
+    TRequestStatus* status = &aStatus;
+    User::RequestComplete(status, KErrNone);
+    }
+
+#ifdef _DEBUG    
+void CMTPSetObjectPropList::ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+#else
+void CMTPSetObjectPropList::ProxyTransactionCompleteL(const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/)
+#endif
+    {
+    __ASSERT_DEBUG(iRequest == &aRequest && &iConnection == &aConnection, Panic(EMTPNotSameRequestProxy));
+    const TInt KErr(iResponseCode == EMTPRespCodeOK ? KErrNone : KErrGeneral);    
+    if (KErr == KErrNone)
+        {
+        ++iDpIdx;
+        }
+    Reschedule(KErr);
+    }
+
+void CMTPSetObjectPropList::RunL()
+    {    
+    if (iStatus == KErrNone) // send request to the next dp
+        {
+        if (!iDpListCreated)
+            {    
+            // Data provider list under construction.
+            iResponseCode = EMTPRespCodeOK;
+            const TUint KElementCount(iObjectPropList->NumberOfElements());
+            const TUint KRunLength(32);
+		
+            for (TUint i(0); ((i < KRunLength) && (iPropertyIdx < KElementCount) && (iResponseCode == EMTPRespCodeOK)); ++i)
+                {
+				iPropertyIdx++;
+				CMTPTypeObjectPropListElement& element=iObjectPropList->GetNextElementL();			
+                const TUint32 KHandle(element.Uint32L(CMTPTypeObjectPropListElement::EObjectHandle));
+                const TUint16 KPropCode(element.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode));
+                CMTPParserRouter::TRoutingParameters params(*iRequest, iConnection);
+                params.SetParam(CMTPParserRouter::TRoutingParameters::EParamObjectHandle, KHandle);
+                params.SetParam(CMTPParserRouter::TRoutingParameters::EParamObjectPropCode, KPropCode);
+                                
+                CMTPObjectMetaData* meta(CMTPObjectMetaData::NewLC());
+                if (!iSingletons.ObjectMgr().ObjectL(KHandle, *meta))
+                    {
+                    // Invalid object handle.
+                    iResponseCode = EMTPRespCodeInvalidObjectHandle;
+                    }
+                else
+                    {
+                    RArray<TUint> targets;
+                    CleanupClosePushL(targets);
+                    iSingletons.Router().RouteOperationRequestL(params, targets);
+                    __ASSERT_DEBUG((targets.Count() <= 1), User::Invariant());
+                    if (targets.Count() == 1)
+                        {
+                        iDpList.InsertInOrder(targets[0]);
+                        }
+                    else
+                        {
+                        // Unsupported object propertycode.
+                        iResponseCode = EMTPRespCodeObjectPropNotSupported;
+                        }
+                    CleanupStack::PopAndDestroy(&targets);
+                    }
+                CleanupStack::PopAndDestroy(meta);
+                
+                if (iResponseCode != EMTPRespCodeOK)
+                    {
+                    // If an error occurs at this point then no properties have been updated.
+                    iPropertyIdx = 0;
+                    iDpList.Reset();
+                    }
+                }	                
+            if ((iPropertyIdx < KElementCount) && (iResponseCode == EMTPRespCodeOK))
+                {
+                Reschedule(KErrNone);
+                }
+            else
+                {
+                iDpListCreated = ETrue;
+                }
+            }
+            
+        if (iDpListCreated)
+            {
+            if (iDpIdx < iDpList.Count())
+                {
+                iSingletons.DpController().DataProviderL(iDpList[iDpIdx]).ExecuteProxyRequestL(Request(), Connection(), *this);
+                }
+            else
+                {
+                SendResponseL(iResponseCode, 1, &iPropertyIdx);                
+                }
+            }
+        }
+    else
+        {
+        if (!iDpListCreated)
+            {
+            /* 
+            If an error occurs prior to starting the proxy transaction cycles 
+            then no properties have been updated.
+            */
+            iPropertyIdx = 0;
+            }
+            
+        if (iResponseCode == EMTPRespCodeOK)
+            {
+            iResponseCode = EMTPRespCodeGeneralError;
+            }
+        SendResponseL(iResponseCode, 1, &iPropertyIdx);
+        }    
+    }
+
+/**
+Reschedules the active object with the specified completion code.
+@param aError The asynchronous request completion code.
+*/
+void CMTPSetObjectPropList::Reschedule(TInt aError)
+    {
+    SetActive();
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete(status, aError);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/mtpproxydp.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,40 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <ecom/registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = 0x102827A6;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x102827AD;
+			implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x102827B1;
+					version_no = 1;
+					display_name = "MTP Proxy Data Provider plug-in.";
+					default_data = "";
+					opaque_data = "r_syncdpdsconfig_info";
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/mtpproxydp_config.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,80 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/mtpdataproviderconfig.rh>
+
+
+STRUCT ELEMENTSARRAY
+	{
+	STRUCT	elements[];
+	}
+
+STRUCT DP_FORMATCODE_CONFIG
+	{
+	LONG	dp_uid;	   //  DP UID
+	LTEXT	file_name[];   //  array of FileNames
+	}
+
+//
+
+
+//
+// Resources.  (*Append* new resources!!)
+//
+
+RESOURCE MTP_DATA_PROVIDER dpConfig
+    {
+    type = KMTPDataProviderTypeECOM;
+    major_version = 1;
+    object_enumeration_persistent = 0;
+    supported_modes = KMTPModeMTP;  
+    server_name = "";
+    server_image_name = "";
+    opaque_resource = r_elements_info;
+    }
+
+RESOURCE ELEMENTSARRAY r_elements_info
+	{
+        elements=
+		{
+		DP_FORMATCODE_CONFIG
+			{
+			dp_uid = 0x2001B137;
+			file_name  = {				
+					"san.ds",
+					"itor.ds" 
+					 }; 
+			},
+			
+		//*
+		//* [SP-Format-0x3002]Special processing for PictBridge DP which own 6 dps file with format 0x3002, 
+		//* but it does not really own the format 0x3002.
+		//* 
+		//* SendObjectInfo with one of the 3 files is directly routed to PictBridge DP.
+		//*	
+		DP_FORMATCODE_CONFIG
+			{
+			dp_uid = 0x2001fe3c;
+			file_name  = {
+					"hdiscvry.dps",
+					"hrequest.dps",
+					"hrsponse.dps"
+					 }; 
+			}
+		//ADD New Data Provider Uid's with the supported FileNames		
+		};
+	
+        }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/mtpproxydpimplementations.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,34 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <ecom/implementationproxy.h>
+#include "cmtpproxydp.h"
+
+// Define the interface UIDs
+static const TImplementationProxy ImplementationTable[] =
+    {
+        {
+        {0x102827B1}, (TProxyNewLPtr)(CMTPProxyDataProvider::NewL)
+        }
+    };
+
+/**
+ECOM entry point
+*/
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/mtpproxydpprocessor.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,71 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpcopyobject.h"
+#include "cmtpmoveobject.h"
+#include "cmtpdeleteobject.h"
+#include "cmtpgetobjectproplist.h"
+#include "cmtpgetobjectpropssupported.h"
+#include "cmtprequestprocessor.h"
+#include "cmtprequestunknown.h"
+#include "cmtpsendobjectinfo.h"
+#include "cmtpsendobjectproplist.h"
+#include "cmtpsetobjectproplist.h"
+#include "mtpproxydpprocessor.h"
+#include "cmtpgetformatcapabilities.h"
+#include "cmtpdeleteobjectproplist.h"
+/**
+proxy data provider mapping table from request ID to factory method of the request processor
+*/
+static const TMTPRequestProcessorEntry KMTPRequestProcessorTable[] = 
+    {
+        {EMTPOpCodeCopyObject,              CMTPCopyObject::NewL},
+        {EMTPOpCodeMoveObject,              CMTPMoveObject::NewL},
+        {EMTPOpCodeDeleteObject,            CMTPDeleteObject::NewL},
+        {EMTPOpCodeGetObjectPropList,       CMTPGetObjectPropList::NewL},
+        {EMTPOpCodeGetObjectPropsSupported, CMTPGetObjectPropsSupported::NewL},
+        {EMTPOpCodeSendObjectInfo,          CMTPSendObjectInfo::NewL},
+        {EMTPOpCodeSendObjectPropList,      CMTPSendObjectPropList::NewL},
+        {EMTPOpCodeSetObjectPropList,       CMTPSetObjectPropList::NewL},
+        {EMTPOpCodeGetFormatCapabilities,   CMTPGetFormatCapabilities::NewL},
+        {EMTPOpCodeDeleteObjectPropList,    CMTPDeleteObjectPropList::NewL}
+   
+    };
+
+/**
+Creates request processor based on the request and connection
+*/    
+MMTPRequestProcessor* MTPProxyDpProcessor::CreateL(MMTPDataProviderFramework& aFramework, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {
+    TMTPRequestProcessorCreateFunc factory(NULL); 
+    TUint16 op(aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode));
+    const TInt count(sizeof(KMTPRequestProcessorTable) / sizeof(TMTPRequestProcessorEntry));
+    for (TInt i(0); ((!factory) && (i < count)); i++)
+        {
+        if (KMTPRequestProcessorTable[i].iOperationCode == op)
+            {
+            factory = KMTPRequestProcessorTable[i].iCreateFunc;
+            }
+        }
+
+    if (!factory)    
+        {
+        factory = CMTPRequestUnknown::NewL;
+        }
+                
+    return (*factory)(aFramework, aConnection);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/rmtpproxydpsingletons.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,107 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+#include "rmtpproxydpsingletons.h"
+#include "cmtpproxydpconfigmgr.h"
+
+	
+/**
+Constructor.
+*/
+RMTPProxyDpSingletons::RMTPProxyDpSingletons() :
+    iSingletons(NULL)
+    {
+    }
+
+/**
+Opens the singletons reference.
+*/
+void RMTPProxyDpSingletons::OpenL(MMTPDataProviderFramework& aFramework)
+    {
+    iSingletons = &CSingletons::OpenL(aFramework);
+    }
+    
+/**
+Closes the singletons reference.
+*/
+void RMTPProxyDpSingletons::Close()
+    {
+    if (iSingletons)
+        {
+        iSingletons->Close();
+        iSingletons = NULL;
+        }
+    }
+
+/**
+Provides a handle to the MTP proxy data provider's configuration manager.
+@return The proxy data provider configuration manager.
+*/
+CMTPProxyDpConfigMgr& RMTPProxyDpSingletons::FrameworkConfig()
+    {
+    __ASSERT_DEBUG(iSingletons, User::Invariant());
+    __ASSERT_DEBUG(iSingletons->iConfigMgr, User::Invariant());
+    return *iSingletons->iConfigMgr;
+    }
+
+RMTPProxyDpSingletons::CSingletons* RMTPProxyDpSingletons::CSingletons::NewL(MMTPDataProviderFramework& aFramework)
+    {
+    CSingletons* self(new(ELeave) CSingletons());
+    CleanupStack::PushL(self);
+    self->ConstructL(aFramework);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+RMTPProxyDpSingletons::CSingletons& RMTPProxyDpSingletons::CSingletons::OpenL(MMTPDataProviderFramework& aFramework)
+    {
+    CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
+    if (!self)
+        {
+        self = CSingletons::NewL(aFramework);
+        Dll::SetTls(reinterpret_cast<TAny*>(self));
+        }
+    else
+        {        
+        self->Inc();
+        }
+    return *self;
+    }
+    
+void RMTPProxyDpSingletons::CSingletons::Close()
+    {
+    CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
+    if (self)
+        {
+        self->Dec();
+        if (self->AccessCount() == 0)
+            {
+            delete self;
+            Dll::SetTls(NULL);
+            }
+        }
+    }
+    
+RMTPProxyDpSingletons::CSingletons::~CSingletons()
+    {
+    delete iConfigMgr;
+    }
+    
+void RMTPProxyDpSingletons::CSingletons::ConstructL(MMTPDataProviderFramework& aFramework)
+    {
+    iConfigMgr = CMTPProxyDpConfigMgr::NewL(aFramework);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,82 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// MTP data types library
+// 
+//
+
+/**
+ @file
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../interface/cmtptypecompoundbase.h	        SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypecompoundbase.h)
+../interface/cmtptypedevicepropdesc.h           SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypedevicepropdesc.h)
+../interface/cmtptypeinterdependentpropdesc.h   SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypeinterdependentpropdesc.h) 
+../interface/cmtptypeobjectinfo.h               SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypeobjectinfo.h) 
+../interface/cmtptypeobjectpropdesc.h           SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypeobjectpropdesc.h) 
+../interface/cmtptypeobjectproplist.h           SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypeobjectproplist.h) 
+../interface/cmtptypefile.h                     SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypefile.h)  
+../interface/cmtptypestorageinfo.h              SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypestorageinfo.h)
+../interface/cmtptypestring.h                   SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypestring.h) 
+../interface/cmtptypearray.h                    SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypearray.h) 
+../interface/mmtptype.h                         SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mmtptype.h) 
+../interface/mtpdatatypeconstants.h             SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mtpdatatypeconstants.h)
+../interface/mtpprotocolconstants.h             SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mtpprotocolconstants.h)
+../interface/mtptypes.h                         SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mtptypes.h) 
+../interface/mtptypescomplex.h                  SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mtptypescomplex.h) 
+../interface/mtptypescompound.h                 SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mtptypescompound.h) 
+../interface/mtptypesflat.h                     SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mtptypesflat.h) 
+../interface/mtptypessimple.h                   SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mtptypessimple.h) 
+../interface/rmtptype.h                         SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/rmtptype.h) 
+../interface/tmtptypeflatbase.h                 SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptypeflatbase.h)  
+../interface/tmtptypeevent.h                    SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptypeevent.h)  
+../interface/tmtptypeint8.h                     SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptypeint8.h)    
+../interface/tmtptypeint16.h                    SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptypeint16.h) 
+../interface/tmtptypeint32.h                    SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptypeint32.h)   
+../interface/tmtptypeint64.h                    SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptypeint64.h)     
+../interface/tmtptypeint128.h                   SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptypeint128.h)  
+../interface/tmtptypeintbase.h                  SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptypeintbase.h)     
+../interface/tmtptypenull.h                     SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptypenull.h)     
+../interface/tmtptyperequest.h                  SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptyperequest.h)  
+../interface/tmtptyperesponse.h                 SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptyperesponse.h) 
+../interface/tmtptypeuint8.h                    SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptypeuint8.h) 
+../interface/tmtptypeuint16.h                   SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptypeuint16.h) 
+../interface/tmtptypeuint32.h                   SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptypeuint32.h)   
+../interface/tmtptypeuint64.h                   SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptypeuint64.h) 
+../interface/tmtptypeuint128.h                  SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptypeuint128.h)   
+../interface/tmtptypeuintbase.h                 SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptypeuintbase.h)  
+../interface/cmtptypeserviceevent.h				SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypeserviceevent.h)
+../interface/cmtptypeserviceformat.h			SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypeserviceformat.h)
+../interface/cmtptypeserviceinfo.h				SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypeserviceinfo.h)
+../interface/cmtptypeservicemethod.h			SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypeservicemethod.h)
+../interface/cmtptypeserviceprop.h				SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypeserviceprop.h)
+../interface/cmtptypeservicecapabilitylist.h	SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypeservicecapabilitylist.h)
+../interface/tmtptypedatapair.h					SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptypedatapair.h)
+../interface/cmtptypeserviceobjpropextnform.h	SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypeserviceobjpropextnform.h)
+../interface/cmtptypeservicemethodparamextnform.h	SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypeservicemethodparamextnform.h)
+../interface/cmtptypeservicepropdesclist.h		SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypeservicepropdesclist.h)
+../interface/cmtptypelist.h						SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypelist.h)
+../interface/cmtptypedeleteobjectproplist.h		SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypedeleteobjectproplist.h)
+../interface/cmtptypedeleteserviceproplist.h		SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypedeleteserviceproplist.h)
+../interface/cmtptypeserviceproplist.h		        SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypeserviceproplist.h)
+../interface/cmtptypeformatcapabilitylist.h			SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypeformatcapabilitylist.h)
+../interface/cmtptypeopaquedata.h			        SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypeopaquedata.h)
+../interface/tmtptypeguid.h					SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/tmtptypeguid.h)
+../interface/cmtptypetrivialdata.h			        SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cmtptypetrivialdata.h)
+
+PRJ_MMPFILES 
+mtpdatatypes.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/group/mtpdatatypes.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,95 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mtpdatatypes.dll Media Transfer Protocol Framework Data Types Library
+// 
+//
+
+/**
+ @file
+*/
+
+TARGET          mtpdatatypes.dll
+TARGETtype      DLL
+UID         	0x1000008D 0x102827A7
+VENDORID        0x70000001
+
+CAPABILITY      All -Tcb
+
+#if defined(WINS)
+#if defined(SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API)
+deffile mtpdatatypes
+#else
+deffile mtpdatatypes_f32
+#endif
+#endif
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+USERINCLUDE     ../inc
+
+SOURCEPATH      ../src
+SOURCE          cmtptypearray.cpp
+SOURCE          cmtptypecompoundbase.cpp
+SOURCE          cmtptypedevicepropdesc.cpp
+SOURCE          cmtptypefile.cpp
+SOURCE          cmtptypeinterdependentpropdesc.cpp
+SOURCE          cmtptypeobjectinfo.cpp
+SOURCE          cmtptypeobjectpropdesc.cpp
+SOURCE          cmtptypeobjectproplist.cpp
+SOURCE          cmtptypestorageinfo.cpp
+SOURCE          cmtptypestring.cpp
+SOURCE          mmtptype.cpp
+SOURCE          rmtptype.cpp
+SOURCE          tmtptypeevent.cpp
+SOURCE          tmtptypeflatbase.cpp
+SOURCE          tmtptypeint8.cpp
+SOURCE          tmtptypeint16.cpp
+SOURCE          tmtptypeint32.cpp
+SOURCE          tmtptypeint64.cpp
+SOURCE          tmtptypeint128.cpp
+SOURCE          tmtptypeintbase.cpp
+SOURCE          tmtptypenull.cpp
+SOURCE          tmtptyperequest.cpp
+SOURCE          tmtptyperesponse.cpp
+SOURCE          tmtptypeuint8.cpp
+SOURCE          tmtptypeuint16.cpp
+SOURCE          tmtptypeuint32.cpp
+SOURCE          tmtptypeuint64.cpp
+SOURCE          tmtptypeuint128.cpp
+SOURCE          tmtptypeuintbase.cpp
+SOURCE          cmtptypecomplexbuffer.cpp
+SOURCE			cmtptypeserviceinfo.cpp 
+SOURCE			cmtptypeserviceprop.cpp 
+SOURCE			cmtptypeserviceformat.cpp 
+SOURCE			cmtptypeservicemethod.cpp 
+SOURCE			cmtptypeserviceevent.cpp
+SOURCE			cmtptypeservicecapabilitylist.cpp
+SOURCE			tmtptypedatapair.cpp
+SOURCE			cmtptypeserviceobjpropextnform.cpp
+SOURCE			cmtptypeservicemethodparamextnform.cpp
+SOURCE			cmtptypeservicepropdesclist.cpp 
+SOURCE			cmtptypelist.cpp 
+SOURCE          cmtptypedeleteobjectproplist.cpp 
+SOURCE          cmtptypedeleteserviceproplist.cpp
+SOURCE			tmtptypeguid.cpp
+SOURCE			cmtptypeserviceproplist.cpp
+SOURCE          cmtptypeopaquedata.cpp
+SOURCE          cmtptypetrivialdata.cpp
+
+LIBRARY         efsrv.lib
+LIBRARY         euser.lib
+LIBRARY         charconv.lib
+
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/inc/cmtptypecomplexbuffer.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,100 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @InternalTechnology
+*/
+
+#ifndef _CMTPTYPECOMPLEXBUFFER_H
+#define _CMTPTYPECOMPLEXBUFFER_H
+
+#include <e32base.h>
+#include <mtp/mmtptype.h>
+    
+/**
+Defines the MTP Buffer data type. 
+@InternalTechnology
+@released 
+*/
+class CMTPTypeComplexBuffer : public CBase, public MMTPType
+    {
+public:
+
+    IMPORT_C static CMTPTypeComplexBuffer* NewL();
+    IMPORT_C static CMTPTypeComplexBuffer* NewL(const TDesC8& aData);
+    IMPORT_C static CMTPTypeComplexBuffer* NewLC();
+    IMPORT_C static CMTPTypeComplexBuffer* NewLC(const TDesC8& aData);
+	IMPORT_C ~CMTPTypeComplexBuffer();
+    
+	
+	IMPORT_C const TDesC8& Buffer();
+	IMPORT_C void SetBuffer(const TDesC8& aData );
+	
+public: // From MMTPType
+
+    IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt NextReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint64 Size() const;
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+    
+private:
+
+    CMTPTypeComplexBuffer();
+	void ConstructL(const TDesC8& aData);	
+
+private:
+
+    /**
+    The read and write data stream states.
+    */
+    enum TReadWriteSequenceState
+        {
+        /**
+        Data stream is inactive.
+        */
+        EIdle,
+        
+        /**
+        Data stream is in progress.
+        */
+        EInProgress            
+        };
+
+    /**
+    The intermediate data buffer. Note that this is declared mutable to allow 
+    state updates while processing a read data stream.
+    */
+	mutable RBuf8   iBuffer;
+
+       
+    /**
+    The read data stream state variable. Note that this is declared mutable 
+    to allow state updates while processing a read data stream.
+    */
+	mutable TUint   iReadSequenceState;
+    
+    /**
+    The write data stream state variable.
+    */
+	TUint           iWriteSequenceState;
+    };
+    
+#endif // _CMTPTypeBuffer_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/inc/mtpdatatypespanic.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,47 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef MTPDATATYPESPANIC_H
+#define MTPDATATYPESPANIC_H
+
+#include <e32std.h>
+
+enum TMTPDataTypesPanic
+	{
+	EMTPTypeReserved        = 0,
+	
+	EMTPTypeBadStorage      = 1,
+	EMTPTypeBoundsError     = 2,
+	EMTPTypeIdMismatch      = 3,
+	EMTPTypeSizeMismatch    = 4,
+	EMTPTypeIdUnknown       = 5,
+	EMTPTypeNotSupported    = 6,
+	EMTPTypeInUse           = 7,
+	};
+
+_LIT(KMTPDataTypesPanic, "MTPDataTypes");
+inline void Panic(TMTPDataTypesPanic aCode)
+	{
+	User::Panic(KMTPDataTypesPanic, aCode);
+	};
+	
+
+#endif // MTPDATATYPESPANIC_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypearray.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,172 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef CMTPTYPEARRAY_H
+#define CMTPTYPEARRAY_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <mtp/mmtptype.h>
+
+/**
+Defines the MTP array data type. MTP arrays consist of a contiguous sequence
+of objects of the same fixed length type, and are zero based. MTP does not 
+define variable length arrays, e.g. of string objects. Arrays are prepended 
+with a single 32-bit unsigned integer that identifies the number of elements 
+to follow. An empty array would consist of a single 32-bit integer containing
+the value 0x00000000. 
+
+MTP arrays are stored in a flat buffer to optimize streaming performance 
+to/from the MTP transport connection. 
+@publishedPartner
+@released 
+*/
+class CMTPTypeArray : public CBase, public MMTPType 
+    {   
+public:
+
+    IMPORT_C static CMTPTypeArray* NewL(TInt aElementType, TUint aElementSize);
+    IMPORT_C static CMTPTypeArray* NewLC(TInt aElementType, TUint aElementSize); 
+    IMPORT_C static CMTPTypeArray* NewL(TInt aArrayType, TInt aElementType, TUint aElementSize);
+    IMPORT_C static CMTPTypeArray* NewLC(TInt aArrayType, TInt aElementType, TUint aElementSize); 
+    IMPORT_C static CMTPTypeArray* NewL(TInt aArrayType);
+    IMPORT_C static CMTPTypeArray* NewL(TInt aArrayType, const RArray<TInt>& aElements);
+    IMPORT_C static CMTPTypeArray* NewL(TInt aArrayType, const RArray<TUint>& aElements);
+    IMPORT_C static CMTPTypeArray* NewL(const RArray<TInt64>& aElements);
+    IMPORT_C static CMTPTypeArray* NewL(const RArray<TUint64>& aElements);
+    IMPORT_C static CMTPTypeArray* NewLC(TInt aArrayType);
+    IMPORT_C static CMTPTypeArray* NewLC(TInt aArrayType, const RArray<TInt>& aElements);
+    IMPORT_C static CMTPTypeArray* NewLC(TInt aArrayType, const RArray<TUint>& aElements);
+    IMPORT_C static CMTPTypeArray* NewLC(const RArray<TInt64>& aElements);
+    IMPORT_C static CMTPTypeArray* NewLC(const RArray<TUint64>& aElements);
+    IMPORT_C ~CMTPTypeArray();
+    
+    IMPORT_C TInt ElementType() const;
+    IMPORT_C TUint32 NumElements() const;
+    
+    IMPORT_C void AppendL(const MMTPType& aElement);
+    IMPORT_C void AppendL(const RArray<TInt>& aElements);
+    IMPORT_C void AppendL(const RArray<TUint>& aElements);
+    IMPORT_C void AppendL(const RArray<TInt64>& aElements);
+    IMPORT_C void AppendL(const RArray<TUint64>& aElements);
+    
+    IMPORT_C void AppendIntL(TInt aElement);
+    IMPORT_C void AppendUintL(TUint aElement);
+    IMPORT_C void AppendInt64L(TInt64 aElement);
+    IMPORT_C void AppendUint64L(TUint64 aElement);
+    
+    IMPORT_C void ElementL(TUint aIndex, MMTPType& aElement) const;
+    
+    IMPORT_C TInt ElementInt(TUint aIndex) const;
+    IMPORT_C TUint ElementUint(TUint aIndex) const;
+    IMPORT_C TInt64 ElementInt64(TUint aIndex) const;
+    IMPORT_C TUint64 ElementUint64(TUint aIndex) const;
+    
+    IMPORT_C void Array(RArray<TInt>& aElements) const;
+    IMPORT_C void Array(RArray<TUint>& aElements) const;
+    IMPORT_C void Array(RArray<TInt64>& aElements) const;
+    IMPORT_C void Array(RArray<TUint64>& aElements) const;
+    IMPORT_C void ToDes( TDes8& aRetDes ) const;
+    IMPORT_C void SetByDesL( const TDesC8& aDesc );
+    
+public: // From MMTPType
+
+    IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt NextReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint64 Size() const;
+    IMPORT_C virtual TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+    IMPORT_C TInt Validate() const;
+    
+private:
+
+    CMTPTypeArray(TInt aArrayType, TInt aElementType, TUint aElementSize);
+    void ConstructL(TUint32 aNumElements);
+    void ConstructL(const RPointerArray<MMTPType>& aElements);
+    
+    void AppendL(const TAny* aElement);
+    void Element(TUint aIndex, TAny* aElement) const;
+    void ReAllocBufferL(TUint32 aNumElements);
+    void SetNumElements(TUint32 aNumElements);
+    TUint64 BufferSize(TUint32 aNumElements) const;
+    TUint Offset(TUint aIndex) const;  
+    void SetInvalidL();
+     
+    static void SimpleArrayTypeMetaDataL(TInt aArrayType, TInt& aElementType, TUint& aElementSize); 
+    
+private:
+
+    /**
+    The write data stream states.
+    */
+    enum TWriteSequenceState
+        {
+        /**
+        Write data stream is inactive.
+        */
+        EIdle,
+        
+        /**
+        Streaming the NumElements data chunk.
+        */
+        ENumElements,
+        
+        /**
+        Streaming the array Element chunks.
+        */
+        EElements            
+        };
+        
+	/**
+	The array type's MTP datatype code.
+	*/
+    TInt    iArrayType;
+    
+    /**
+    The data buffer.
+    */
+    RBuf8   iBuffer;
+        
+	/**
+	The array element type's size in bytes.
+	*/
+    TUint64 iElementSize;
+        
+	/**
+	The array element type's MTP datatype code.
+	*/
+    TInt    iElementType;
+    
+    /**
+    The write data stream state variable.
+    */
+    TUint   iWriteSequenceState;
+    
+    /**
+    The array type's validation state.
+    */
+    TInt    iValidationState;
+    };
+
+#endif // CMTPTYPEARRAY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypecompoundbase.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,286 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef CMTPTYPECOMPOUNDBASE_H
+#define CMTPTYPECOMPOUNDBASE_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <mtp/mmtptype.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypeflatbase.h>
+    
+/**
+Defines the MTP compound data types base class. Compound data types are used 
+to represent MTP datasets comprising mixed sequences of simple, flat, and 
+complex data type elements. These elements may be either of fixed or variable 
+length. This class implements generic compound data type storage management 
+capabilities and is intended for derivation by concrete classes which implement 
+specific MTP datasets. Note that this class does NOT assume ownership of any 
+of the data elements passed to it.
+@publishedPartner
+@released 
+*/
+class CMTPTypeCompoundBase : public CBase, public MMTPType 
+    {
+
+public:
+    IMPORT_C virtual ~CMTPTypeCompoundBase();
+
+    IMPORT_C virtual void GetL(TInt aElementId, MMTPType& aElement) const;
+    IMPORT_C virtual void SetL(TInt aElementId, const MMTPType& aElement);
+    
+    IMPORT_C virtual void SetInt8L(TInt aElementId, TInt8 aData);    
+    IMPORT_C virtual void SetInt16L(TInt aElementId, TInt16 aData);
+    IMPORT_C virtual void SetInt32L(TInt aElementId, TInt32 aData);
+    IMPORT_C virtual void SetInt64L(TInt aElementId, TInt64 aData);
+    
+    IMPORT_C virtual void SetUint8L(TInt aElementId, TUint8 aData);
+    IMPORT_C virtual void SetUint16L(TInt aElementId, TUint16 aData);
+    IMPORT_C virtual void SetUint32L(TInt aElementId, TUint32 aData);    
+    IMPORT_C virtual void SetUint64L(TInt aElementId, TUint64 aData);
+    
+    IMPORT_C virtual void SetStringL(TInt aElementId, const TDesC& aString);
+
+    IMPORT_C virtual TInt8 Int8L(TInt aElementId) const;
+    IMPORT_C virtual TInt16 Int16L(TInt aElementId) const;
+    IMPORT_C virtual TInt32 Int32L(TInt aElementId) const;
+    IMPORT_C virtual TInt64 Int64L(TInt aElementId) const;
+
+    IMPORT_C virtual TUint8 Uint8L(TInt aElementId) const;
+    IMPORT_C virtual TUint16 Uint16L(TInt aElementId) const;
+    IMPORT_C virtual TUint32 Uint32L(TInt aElementId) const;
+    IMPORT_C virtual TUint64 Uint64L(TInt aElementId) const;
+
+    IMPORT_C virtual TUint8 StringNumCharsL(TInt aElementId) const;
+    IMPORT_C virtual const TDesC& StringCharsL(TInt aElementId) const;  
+	
+public: // From MMTPType
+
+    IMPORT_C virtual TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C virtual TInt NextReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C virtual TInt FirstWriteChunk(TPtr8& aChunk);
+    
+    IMPORT_C virtual TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C virtual TInt NextWriteChunk(TPtr8& aChunk, TUint aDataLength);
+    IMPORT_C virtual TUint64 Size() const;
+    IMPORT_C virtual TUint Type() const;
+    IMPORT_C virtual TBool CommitRequired() const;
+    IMPORT_C virtual MMTPType* CommitChunkL(TPtr8& aChunk);
+    IMPORT_C virtual TInt Validate() const;
+    
+public:
+
+    /**
+    Defines the MTP compound data type element meta data.
+    */   
+    struct TElementInfo
+        {
+        /**
+        The element's chunk identifier (sequence number).
+        */
+        TInt                            iChunkId;
+        
+        /**
+        The element's MTP type identifier.
+        */
+        TInt                            iType;
+        
+        /**
+        RMTPTypeCompoundFlatChunk element specific meta data.
+        */
+        TMTPTypeFlatBase::TElementInfo  iFlatChunkInfo;
+        };
+     
+    /**
+    Initialisation value for TElementInfo data values that are non applicable
+    for an element, e.g. when specifying iFlatChunkInfo values for non-flat
+    elements such as arrays and strings.
+    */   
+    static const TInt KMTPNotApplicable         = -1;     
+        
+protected:
+
+    /**
+    Defines the MTP compound data type flat data chunk class. 
+    @publishedPartner
+    @released 
+    */
+    class RMTPTypeCompoundFlatChunk : public TMTPTypeFlatBase
+        {    
+    public:
+
+        IMPORT_C RMTPTypeCompoundFlatChunk(TUint aSize, CMTPTypeCompoundBase& aParent);
+        
+        IMPORT_C void Close();
+        IMPORT_C void OpenL();
+        
+    public: // From MMTPType
+
+        IMPORT_C TUint Type() const;
+
+    private: // From TMTPTypeFlatBase
+
+        const TElementInfo& ElementInfo(TInt aElementId) const;
+        
+    private: // Owned.
+
+        /**
+        The data buffer.
+        */
+        RBuf8                   iBuffer;
+        
+        /**
+        The flat data chunk size.
+        */
+        TUint                   iSize;
+        
+    private: // Not owned.
+        
+        /**
+        The parent compound data type instance of which this flat chunk is an 
+        element.
+        */
+        CMTPTypeCompoundBase*   iParent;
+        };
+        
+protected:
+
+    /**
+    This flag is used by derived classes to signal the use of just-in-time
+    techniques during construction from a write data stream.
+    @see CMTPTypeCompoundBase
+    */
+    static const TBool KJustInTimeConstruction  = ETrue;
+    
+    /**
+    This flag is used by the derived class to indicate that the number of 
+    chunks making up the compound type is variable rather than fixed (e.g. a
+    list of elements.)
+    */
+    static const TUint KVariableChunkCount      = 0;
+
+    friend class RMTPTypeCompoundFlatChunk;
+    IMPORT_C CMTPTypeCompoundBase(TBool aJustInTimeConstruction, TUint aExpectedChunkCount);
+    
+    IMPORT_C void ChunkAppendL(const MMTPType& aElement);
+    IMPORT_C void ChunkRemove(TUint aChunkId);
+    IMPORT_C TUint ChunkCount() const;
+    IMPORT_C void Reset();
+    IMPORT_C void SetExpectedChunkCount(TUint aExpectedChunkCount);
+
+    /**
+    Provides the TElementInfo data for the specified element.
+    @param aElementId The identifier of the requested element.
+    @return The requested element's meta data.
+    */
+    virtual const TElementInfo& ElementInfo(TInt aElementId) const = 0;
+    
+    IMPORT_C virtual TBool ReadableElementL(TInt aElementId) const;
+    IMPORT_C virtual TBool WriteableElementL(TInt aElementId) const;
+    IMPORT_C virtual TInt ValidateChunkCount() const;
+
+    
+protected:
+
+	/**
+	Ordered data type element chunk table.
+	*/
+	RPointerArray<MMTPType> iChunks;
+
+	/**
+	The write data stream data chunk table index. 
+	*/
+	TUint                   iWriteChunk;
+
+	/**
+	The write data stream state variable. 
+	*/
+	TUint                   iWriteSequenceState;
+	/**
+	The read and write data stream states.
+	*/
+	enum TReadWriteSequenceState
+    {
+    /**
+    Data stream is inactive.
+    */
+    EIdle,
+    
+    /**
+    Streaming the first data chunk.
+    */
+    EInProgressFirst,
+    
+    /**
+    Streaming a subsequent data chunk.
+    */
+    EInProgressNext,          
+    };    
+
+private:
+
+    TInt UpdateReadState(TInt aErr) const;
+    
+    TInt UpdateWriteState(TInt aErr);
+	
+    
+private:
+
+           
+    /**
+    This flag indicates the number of chunks which make up the compound type. 
+    A value of KVariableChunkCount indicates that the type is of variable 
+    rather than fixed length (e.g. a list of elements). If KVariableChunkCount
+    is specified then the derived class's @see ValidChunkCount method is invoked 
+    by the default @see Valid implementation.
+    */
+    TUint                   iExpectedChunkCount;
+    
+    /**
+    This flag indicates that the compound data type uses just-in-time 
+    techniques when constructing iteself from a write data stream. Typically 
+    this is used for types whose final structure is dependant upon data 
+    contained within the data stream itself, e.g. a dataset with an element 
+    whose data type is determined by meta data which precedes the 
+    element in the data stream.
+    */
+    TBool                   iJustInTimeConstruction;
+    
+    /**
+    The read data stream data chunk table index. Note that this is declared 
+    mutable to allow state updates while processing a read data stream.
+    */
+    mutable TUint           iReadChunk;
+    
+    /**
+    The read data stream state variable. Note that this is declared mutable 
+    to allow state updates while processing a read data stream.
+    */
+    mutable TUint           iReadSequenceState;        
+    
+    /**
+    The write data stream error state. 
+    */
+    TInt                    iWriteErr;
+    };    
+    
+#endif // CMTPTYPECOMPOUNDBASE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypedeleteobjectproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,49 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef CMTPTYPEDELETEOBJECTPROPLIST_H_
+#define CMTPTYPEDELETEOBJECTPROPLIST_H_
+
+#include <mtp/cmtptypelist.h>
+
+class TMTPTypeDataPair;
+
+class CMTPTypeDeleteObjectPropList : public CMTPTypeList
+    {
+    
+public:
+    IMPORT_C static CMTPTypeDeleteObjectPropList* NewL();
+    IMPORT_C static CMTPTypeDeleteObjectPropList* NewLC();
+    IMPORT_C ~CMTPTypeDeleteObjectPropList();
+    
+  
+    
+public: //CMTPTypeList
+    IMPORT_C  void AppendL(const TMTPTypeDataPair* aElement);
+    IMPORT_C  TMTPTypeDataPair& ElementL(const TInt aIndex) const;
+
+private:
+    CMTPTypeDeleteObjectPropList();
+    void ConstructL();
+    };
+
+
+
+#endif /* CMTPTYPEDELETEOBJECTPROPLIST_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypedeleteserviceproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,49 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef CMTPTYPEDELETESERVICEPROPLIST_H_
+#define CMTPTYPEDELETESERVICEPROPLIST_H_
+
+
+#include <mtp/cmtptypelist.h>
+
+class TMTPTypeDataPair;
+
+class CMTPTypeDeleteServicePropList : public CMTPTypeList
+    {
+    
+public:
+    IMPORT_C static CMTPTypeDeleteServicePropList* NewL();
+    IMPORT_C static CMTPTypeDeleteServicePropList* NewLC();
+    IMPORT_C ~CMTPTypeDeleteServicePropList();
+    
+  
+    
+public: //CMTPTypeList
+    IMPORT_C  void AppendL(const TMTPTypeDataPair* aElement);
+    IMPORT_C  TMTPTypeDataPair& ElementL(const TInt aIndex) const;
+
+private:
+    CMTPTypeDeleteServicePropList();
+    void ConstructL();
+    };
+
+
+#endif /* CMTPTYPEDELETESERVICEPROPLIST_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypedevicepropdesc.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,541 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPTYPEDEVICEPROPDESC_H
+#define CMTPTYPEDEVICEPROPDESC_H
+
+#include <e32std.h>
+#include <mtp/rmtptype.h>
+#include <mtp/cmtptypecompoundbase.h>
+
+/** 
+Defines the MTP DevicePropDesc dataset. The DevicePropDesc dataset describes 
+an MTP device property, and is generated in response to a GetDevicePropDesc 
+operation request.
+@internalComponent
+*/ 
+class CMTPTypeDevicePropDesc : public CMTPTypeCompoundBase
+    {
+public:
+
+    /**
+    MTP DevicePropDesc dataset element identifiers.
+    */
+    enum TMTPDevicePropDescElement
+        {
+        /**
+        Property Code (read-only).
+        */
+        EDevicePropertyCode,
+        
+        /**
+        Datatype (read-only).
+        */
+        EDatatype,
+        
+        /**
+        Get/Set.
+        */
+        EGetSet,
+        
+        /**
+        Factory Default Value.
+        */
+        EFactoryDefaultValue,
+        
+        /**
+        Factory Default Value.
+        */
+        ECurrentValue,
+        
+        /**
+        Form Flag (read-only).
+        */
+        EFormFlag,
+        
+        /**
+        FORM element. This element depends EFormFlag and is absent if EFormFlag 
+        is ENone.
+        */
+        EForm,  
+        
+        /**
+        The number of dataset elements.
+        */
+        ENumElements,
+        };
+
+    /**
+    MTP DevicePropDesc dataset Get/Set element values.
+    */
+    enum TMTPDevicePropDescGetSet
+        {
+        /** 
+        Get.
+        */
+        EReadOnly   = 0x00,
+
+        /** 
+        Get/Set.
+        */
+        EReadWrite  = 0x01,
+        };
+
+    /**
+    MTP DevicePropDesc dataset FormFlag element values.
+    */
+    enum TMTPDevicePropDescFormFlag
+        {
+        /** 
+        None.
+        */
+        ENone               = 0x00,
+
+        /** 
+        Range form.
+        */
+        ERangeForm          = 0x01,
+
+        /** 
+        Enumeration form.
+        */
+        EEnumerationForm    = 0x02,
+        };
+
+    /**
+    Defines the MTP DevicePropDesc dataset meta data.
+    */
+    struct TPropertyInfo
+        {
+        /**
+        The property's MTP data type identifier datacode.
+        */
+        TUint   iDataType;
+        
+        /**
+        The FormFlag identifier.
+        */
+        TUint8  iFormFlag;
+        
+        /**
+        The property's Get/Set flag.
+        */
+        TUint8  iGetSet;
+        };
+
+public:
+    
+    IMPORT_C static CMTPTypeDevicePropDesc* NewL(TUint16 aPropertyCode);
+    IMPORT_C static CMTPTypeDevicePropDesc* NewLC(TUint16 aPropertyCode);
+    
+    IMPORT_C static CMTPTypeDevicePropDesc* NewL(TUint16 aPropertyCode, const MMTPType& aForm);
+    IMPORT_C static CMTPTypeDevicePropDesc* NewLC(TUint16 aPropertyCode, const MMTPType& aForm);
+    
+    IMPORT_C static CMTPTypeDevicePropDesc* CMTPTypeDevicePropDesc::NewL(TUint16 aPropertyCode, TUint8 aGetSet, TUint8 aFormFlag, const MMTPType* aForm);
+    IMPORT_C static CMTPTypeDevicePropDesc* CMTPTypeDevicePropDesc::NewLC(TUint16 aPropertyCode, TUint8 aGetSet, TUint8 aFormFlag, const MMTPType* aForm);
+    
+    IMPORT_C static CMTPTypeDevicePropDesc* NewL(TUint16 aPropertyCode, const TPropertyInfo& aInfo, const MMTPType* aForm);
+    IMPORT_C static CMTPTypeDevicePropDesc* NewLC(TUint16 aPropertyCode, const TPropertyInfo& aInfo, const MMTPType* aForm);
+    
+    IMPORT_C virtual ~CMTPTypeDevicePropDesc();   
+     
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+
+public:
+
+    static void PropertyInfoL(TUint16 aPropertyCode, TPropertyInfo& aInfo);
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    TBool ReadableElementL(TInt aElementId) const;
+    TBool WriteableElementL(TInt aElementId) const;
+
+private:
+
+    /*
+    Defines the MTP DevicePropDesc FORM dataset. The FORM dataset is a 
+    component element of the DevicePropDesc dataset.
+    @internalComponent
+    */ 
+    class RMTPTypeDevicePropDescForm : public RMTPType
+        {
+    public:
+
+        RMTPTypeDevicePropDescForm();
+        
+        void SetMeta(TUint8 aFormFlag, TUint aDataType);
+        
+    private:
+     
+        MMTPType* CreateL(TUint aDataType);
+        void Destroy(MMTPType* aType);
+        
+    private:
+    
+        /**
+        The FORM dataset's MTP datatype code.
+        */
+        TUint   iDataType;
+        
+        /**
+        The FORM dataset's FormFlag code.
+        */
+        TUint8  iFormFlag;
+        };
+        
+private:
+
+    static CMTPTypeDevicePropDesc* NewLC();
+
+    CMTPTypeDevicePropDesc();
+    void ConstructL(TUint16 aPropertyCode, const MMTPType* aForm);
+    void ConstructL(TUint16 aPropertyCode, const TPropertyInfo& aInfo, const MMTPType* aForm);
+
+    TBool HasFormField(TUint8 aFormFlag) const;
+    TInt UpdateWriteSequenceErr(TInt aErr);
+
+private: // Owned
+
+    /**
+    The write data stream states.
+    */
+    enum TWriteSequenceState
+        {
+        /**
+        Data stream is inactive.
+        */
+        EWriteIdle,
+        
+        /**
+        Streaming the first flat data chunk.
+        */
+        EWriteFlat1Chunk,
+        
+        /**
+        Streaming the EFactoryDefaultValue data chunk..
+        */
+        EWriteDefaultValueChunk,
+        
+        /**
+        Streaming the ECurrentValue data chunk..
+        */
+        EWriteCurrentValueChunk,
+        
+        /**
+        Streaming the second flat data chunk.
+        */
+        EWriteFormFlagChunk,
+        
+        /**
+        Streaming the EForm data chunk.
+        */
+        EWriteFormChunk 
+        };
+        
+    /**
+    Data chunk identifiers.
+    */
+    enum TChunkIds
+        {
+        /**
+        The first flat data chunk ID.
+        */
+        EIdFlat1Chunk,
+        
+        /**
+        The EFactoryDefaultValue element data chunk ID.
+        */
+        EIdDefaultValueChunk,
+        
+        /**
+        The ECurrentValue element data chunk ID.
+        */
+        EIdCurrentValueChunk,
+        
+        /**
+        The second flat data chunk ID.
+        */
+        EIdFormFlagChunk,
+        
+        /**
+        The EForm element data chunk ID.
+        */
+        EIdFormChunk,
+        
+        /**
+        The number of data chunks.
+        */
+        EIdNumChunks
+        };
+        
+    /**
+    The write data stream error state. 
+    */
+    TUint                                           iWriteSequenceErr;
+    
+    /**
+    The write data stream state variable. 
+    */
+    TUint                                           iWriteSequenceState;
+    
+    /**
+    The write data stream completion state. This will be set to EFlat2Chunk for 
+    DevicePropDesc datasets with an EForm of ENone, otherwise this will be 
+    EFormChunk.
+    */
+    TUint                                           iWriteSequenceCompletionState;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The initialised flag indicating if construction is completeand that 
+    read-only elements can no longer be modified.
+    */
+    TBool                                           iInitialised;
+    
+    /**
+    The size in bytes of the first flat data chunk.
+    */
+    static const TUint                              KFlat1ChunkSize;
+    
+    /**
+    The data chunk count of DevicePropDesc datasets with an EForm of other than 
+    ENone.
+    */
+    static const TUint                              KNumChunksWithForm;
+    
+    /**
+    The data chunk count of DevicePropDesc datasets with an EForm of ENone.
+    */
+    static const TUint                              KNumChunksWithoutForm;
+    
+    /**
+    The flat data chunk comprising elements EPropertyCode to EGetSet.
+    */    
+    RMTPTypeCompoundFlatChunk                       iChunkFlat1;
+    
+    /**
+    The EFactoryDefaultValue element data chunk.
+    */
+    RMTPType                                        iChunkDefaultValue;
+    
+    /**
+    The ECurrentValue element data chunk.
+    */
+    RMTPType                                        iChunkCurrentValue;
+    
+    /**
+    The EFormFlag data chunk.
+    */
+    TMTPTypeUint8                                   iChunkFormFlag;
+    
+    /**
+    The EForm element data chunk.
+    */
+    RMTPTypeDevicePropDescForm                      iChunkForm;
+    };
+
+/** 
+Defines the MTP DevicePropDesc Enumeration FORM dataset. The Enumeration FORM 
+dataset is a component element of the DevicePropDesc dataset.
+@see CMTPTypeDevicePropDesc
+@internalComponent
+*/ 
+class CMTPTypeDevicePropDescEnumerationForm : public CMTPTypeCompoundBase
+    {
+        
+public:
+    
+    IMPORT_C static CMTPTypeDevicePropDescEnumerationForm* NewL(TUint aDataType);
+    IMPORT_C static CMTPTypeDevicePropDescEnumerationForm* NewLC(TUint aDataType);
+    
+    IMPORT_C virtual ~CMTPTypeDevicePropDescEnumerationForm();
+    
+    IMPORT_C void AppendSupportedValueL(const MMTPType& aValue);
+    
+    IMPORT_C TUint16 NumberOfValues() const;
+    IMPORT_C void SupportedValueL(TUint aIndex, MMTPType& aValue) const;
+     
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    TInt ValidateChunkCount() const;
+    
+private:
+
+    CMTPTypeDevicePropDescEnumerationForm(TUint aDataType);
+    void ConstructL();
+    
+    void AppendValueChunkL();
+    
+private:
+
+    /**
+    The write data stream states.
+    */
+    enum TReadWriteSequenceState
+        {
+        /**
+        Data stream is inactive.
+        */
+        EIdle,
+        
+        /**
+        Data stream is in progress.
+        */
+        EInProgress            
+        };
+
+    /**
+    The write data stream state variable. 
+    */
+    TUint                                       iWriteSequenceState;
+    
+    /**
+    The NumberOfValues element metadata content.
+    */
+    CMTPTypeCompoundBase::TElementInfo          iInfoNumberOfValues;
+    
+    /**
+    The SupportedValue array elements metadata content. Note that this is 
+    declared mutable to allow state updates while processing a read data stream.
+    */
+    mutable CMTPTypeCompoundBase::TElementInfo  iInfoValue;
+    
+    /**
+    The NumberOfValues element data chunk ID.
+    */
+    static const TUint                          KNumberOfValuesChunk;
+    
+    /**
+    The SupportedValue array elements metadata content. Note that this is 
+    declared mutable to allow state updates while processing a read data stream.
+    */
+    static const TUint                          KValueChunks;
+    
+    /**
+    The NumberOfPropDescs element data chunk.
+    */
+    TMTPTypeUint16                              iChunkNumberOfValues;
+    
+    /**
+    The SupportedValue elements array data chunks.
+    */
+    RArray<RMTPType>                            iChunksValue;
+    };
+
+/** 
+Defines the MTP DevicePropDesc Range FORM dataset. The Range FORM dataset is a 
+component element of the DevicePropDesc dataset.
+@see CMTPTypeDevicePropDesc
+@internalComponent
+*/ 
+class CMTPTypeDevicePropDescRangeForm : public CMTPTypeCompoundBase
+    {
+public:
+
+    /**
+    MTP DevicePropDesc Range FORM element dataset identifiers.
+    */
+    enum TMTPDevicePropDescElement
+        {
+        /**
+        Minimum Value.
+        */
+        EMinimumValue,
+        
+        /**
+        Maximum Value.
+        */
+        EMaximumValue,
+        
+        /**
+        Step Size.
+        */
+        EStepSize,
+
+        /**
+        The number of dataset elements.
+        */
+        ENumElements,
+        };
+    
+public:
+    
+    IMPORT_C static CMTPTypeDevicePropDescRangeForm* NewL(TUint aDataType);
+    IMPORT_C static CMTPTypeDevicePropDescRangeForm* NewLC(TUint aDataType);
+    
+    IMPORT_C virtual ~CMTPTypeDevicePropDescRangeForm();  
+     
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C TUint Type() const;
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    
+private:
+
+    CMTPTypeDevicePropDescRangeForm(TUint aDataType);
+    void ConstructL();
+    
+private:
+
+    /**
+    The element metadata content.
+    */
+    mutable CMTPTypeCompoundBase::TElementInfo  iInfoBuf;
+
+    /**
+    The property's MTP data type identifier datacode.
+    */
+    TUint                                       iDataType;
+    
+    /**
+    The element data chunks.
+    */
+    RArray<RMTPType>                            iChunks;
+    };
+
+#endif // CMTPTYPEDEVICEPROPDESC_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypefile.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,174 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef CMTPTYPEFILE_H
+#define CMTPTYPEFILE_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <mtp/mmtptype.h>
+    
+/**
+Defines the MTP file object data type. 
+@publishedPartner
+@released 
+*/
+class CMTPTypeFile : public CActive, public MMTPType
+    {
+public:
+
+    IMPORT_C static CMTPTypeFile* NewL(RFs& aFs, const TDesC& aFileName, TFileMode aFileMode);
+    IMPORT_C static CMTPTypeFile* NewLC(RFs& aFs, const TDesC& aFileName, TFileMode aFileMode);
+	IMPORT_C static CMTPTypeFile* NewL(RFs& aFs, const TDesC& aFileName, TFileMode aFileMode, TInt64 aRequiredSize, TInt64 aOffSet = 0);
+	IMPORT_C static CMTPTypeFile* NewLC(RFs& aFs, const TDesC& aFileName, TFileMode aFileMode, TInt64 aRequiredSize, TInt64 aOffSet = 0);
+    IMPORT_C ~CMTPTypeFile();
+    IMPORT_C void SetSizeL(TUint64 aSize);
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+    IMPORT_C RFile64& File();
+#else
+    IMPORT_C RFile& File();
+#endif
+
+public: // From MMTPType
+    IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt NextReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint64 Size() const;
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+	IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+	IMPORT_C TInt64 GetByteSent();
+    
+private:
+    CMTPTypeFile();
+    void ConstructL(RFs& aFs, const TDesC& aName, TFileMode aMode);
+	void ConstructL(RFs& aFs, const TDesC& aName, TFileMode aMode, TInt64 aRequiredSize, TInt64 aOffSet);
+    void ToggleRdWrBuffer();
+
+protected: // From CActive
+    void DoCancel();
+
+private: // From CActive
+	
+    TInt RunError(TInt aError);
+    void RunL();
+private:
+
+    /**
+    The read and write data stream states.
+    */
+    enum TReadWriteSequenceState
+        {
+        /**
+        Data stream is inactive.
+        */
+        EIdle,
+        
+        /**
+        Data stream is in progress.
+        */
+        EInProgress            
+        };
+
+    /**
+    The intermediate data buffer. Note that this is declared mutable to allow 
+    state updates while processing a read data stream.
+    */
+    mutable RBuf8 iBuffer1;
+
+	
+    /**
+    The intermediate data buffer. Note that this is declared mutable to allow 
+    state updates while processing a read data stream.
+    Used for double-buffering, the 2 buffers(buffer1 and buffer2) will be switched between reading data
+    from USB to buffer and writting data from Buffer into File System.
+    */
+    mutable RBuf8 iBuffer2;
+
+    /**
+    The flag indicate if this buffer is avaiable for writting data into, if true, it is ready for
+    USB-SIC to write file data into it, if false, it already contains file data, and is waiting
+    for writting the file data into file system.
+    The two buffer must be used in strict sequence, if both buffer is available, the buffer1 must
+    be firstly used by USB driver. 
+    */
+    mutable TBool  iBuffer1AvailForWrite; 
+
+    //If there occurs error during writting/reading data into/from this file, mark this flag as true, this will abort
+    //all further writting/reading and set the file size to 0 if needed.
+    mutable TBool  iFileRdWrError;
+
+    //This point to the current chunk which is waiting for being commit into File system. it might point to
+    //either of the 2 buffers.
+    mutable TPtr8  iCurrentCommitChunk;
+
+    //true if the file is opened for reading; false if it is opened for Writting.
+    TBool          iFileOpenForRead;
+
+    //For file reading, used to indicate how much bytes are waiting to be read, for file writting, indicate how much
+    //byte are wating to be received by USB and writting to file.
+    mutable TInt64 iRemainingDataSize;
+
+    //The RFile::SetSize() method may take over 40 seconds if we create a file and set its size
+    //to a very large value, and this will cause timeout in MTP protocol layer. To avoid this 
+    //timeout, when creating a large file(over 512MB), instead of setting its size directly to
+    //the target size by one singile RFile::SetSize() call, we'll call RFile::SetSize() multiple
+    //times and set the file size step by step acumulately. For example, for a 2GB file, its
+    //size will be set to 0.5G first, and then 1G, 1.5G and at last 2G.
+    
+    //For file reading, used to indicate the target size to be transfered to initiator, for file writting, used to 
+    //incicate the target size for a file that being transfering to device.
+    TInt64         iTargetFileSize;
+    
+    //This is the acumulated received size for the file represented by this object.
+    TInt64         iTotalReceivedSize;
+
+    //This represent the current size we call SetSize() to the file.
+    TInt64         iCurrentFileSetSize;
+    /**
+    The data file. Note that this is declared mutable to allow state updates
+    while processing a read data stream.
+    */
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+    mutable RFile64 iFile;
+#else
+    mutable RFile   iFile;
+#endif
+    /**
+    The read data stream state variable. Note that this is declared mutable 
+    to allow state updates while processing a read data stream.
+    */
+    mutable TUint   iReadSequenceState;
+    
+    /**
+    The write data stream state variable.
+    */
+    TUint           iWriteSequenceState;
+
+	TInt64          iOffSet;
+    
+    mutable TInt64          iByteSent;
+
+    };
+    
+#endif // CMTPTYPEFILE_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypeformatcapabilitylist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,31 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+#ifndef CMTPTYPEFORMATCAPABILITYLIST_H_
+#define CMTPTYPEFORMATCAPABILITYLIST_H_
+
+#include <mtp/cmtptypeservicecapabilitylist.h>
+
+typedef  CMTPTypeServiceCapabilityList  CMTPTypeFormatCapabilityList;
+
+
+
+#endif /* CMTPTYPEFORMATCAPABILITYLIST_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypeinterdependentpropdesc.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,238 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef CMTPTYPEINTERDEPENDENTPROPDESC_H
+#define CMTPTYPEINTERDEPENDENTPROPDESC_H
+
+#include <e32std.h>
+#include <mtp/cmtptypecompoundbase.h>
+
+class CMTPTypeInterdependentProperties;
+class CMTPTypeObjectPropDesc;
+
+/** 
+Defines the MTP InterdependentPropDesc dataset. The InterdependentPropDesc 
+implements an array of MTP ObjectPropDesc arrays, each describing a permissable
+collection of ranges. Each array of MTP ObjectPropDesc datasets gives one 
+possible definition for the interdependent properties that are contained in 
+that array; properties not found in that array are constrained only by the 
+usual ObjectPropDesc datasets. This dataset is used in the 
+GetInterdependentPropDesc request.
+@publishedPartner
+@released 
+*/ 
+class CMTPTypeInterdependentPropDesc : public CMTPTypeCompoundBase
+    {
+public:
+    
+    IMPORT_C static CMTPTypeInterdependentPropDesc* NewL();
+    IMPORT_C static CMTPTypeInterdependentPropDesc* NewLC();
+
+    IMPORT_C virtual ~CMTPTypeInterdependentPropDesc();  
+    
+    IMPORT_C void AppendL(CMTPTypeInterdependentProperties* aInterdependentProperties);
+    
+    IMPORT_C TUint32 NumberOfInterdependencies() const;
+    IMPORT_C CMTPTypeInterdependentProperties& InterdependentProperties(TUint aIndex) const;  
+     
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk); 
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    TInt ValidateChunkCount() const;
+    
+private:
+
+    CMTPTypeInterdependentPropDesc();
+    void ConstructL();
+    
+    void AppendElementChunkL(CMTPTypeInterdependentProperties* aElement);
+    TInt UpdateWriteSequenceErr(TInt aErr);
+
+private: // Owned
+
+    /**
+    The write data stream states.
+    */
+    enum TReadWriteSequenceState
+        {
+        /**
+        Data stream is inactive.
+        */
+        EIdle,
+        
+        /**
+        Data stream is in progress.
+        */
+        EInProgress            
+        };
+    
+    /**
+    The NumberOfInterdependencies element data chunk ID.
+    */
+    static const TUint                              KNumberOfInterdependenciesChunk;
+    
+    /**
+    The InterdependentProperties array starting element data chunk ID.
+    */
+    static const TUint                              KInterdependentPropertiesChunks;
+
+    /**
+    The write data stream error state. 
+    */
+    TInt                                            iWriteSequenceErr;
+    
+    /**
+    The write data stream state variable. 
+    */
+    TUint                                           iWriteSequenceState;
+    
+    /**
+    The NumberOfInterdependencies element metadata content.
+    */
+    CMTPTypeCompoundBase::TElementInfo              iInfoNumberOfInterdependencies;
+    
+    /**
+    The InterdependentProperties elements array metadata content. Note that this is 
+    declared mutable to allow state updates while processing a read data stream.
+    */
+    mutable CMTPTypeCompoundBase::TElementInfo      iInfoInterdependentProperties;
+    
+    /**
+    The NumberOfInterdependencies data chunk.
+    */
+    TMTPTypeUint32                                  iChunkNumberOfInterdependencies;
+    
+    /**
+    The InterdependentProperties elements array data chunks.
+    */
+    RPointerArray<CMTPTypeInterdependentProperties> iChunksInterdependentProperties;
+    };
+
+/**
+Defines the MTP InterdependentPropDesc array element dataset. The 
+InterdependentPropDesc array element dataset is itself an array of MTP 
+ObjectPropDesc datasets that specifies one possible definition for the 
+interdependent properties that are contained in that array.
+*/
+class CMTPTypeInterdependentProperties : public CMTPTypeCompoundBase
+    {
+public:
+    
+    IMPORT_C static CMTPTypeInterdependentProperties* NewL();
+    IMPORT_C static CMTPTypeInterdependentProperties* NewLC();
+
+    IMPORT_C virtual ~CMTPTypeInterdependentProperties();  
+    
+    IMPORT_C void AppendL(CMTPTypeObjectPropDesc* aObjectPropDesc);
+    
+    IMPORT_C TUint32 NumberOfPropDescs() const;
+    IMPORT_C CMTPTypeObjectPropDesc& ObjectPropDesc(TUint aIndex) const;  
+     
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk); 
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    TInt ValidateChunkCount() const;
+    
+private:
+
+    CMTPTypeInterdependentProperties();
+    void ConstructL();
+    
+    void AppendElementChunkL(CMTPTypeObjectPropDesc* aElement);
+    TInt UpdateWriteSequenceErr(TInt aErr);
+
+private: // Owned
+
+    /**
+    The write data stream states.
+    */
+    enum TReadWriteSequenceState
+        {
+        /**
+        Data stream is inactive.
+        */
+        EIdle,
+        
+        /**
+        Data stream is in progress.
+        */
+        EInProgress            
+        };
+    
+    /**
+    The NumberOfPropDescs element data chunk ID.
+    */
+    static const TUint                          KNumberOfPropDescsChunk;
+    
+    /**
+    The ObjectPropDesc array starting element data chuck ID.
+    */
+    static const TUint                          KObjectPropDescChunks;
+
+    /**
+    The write data stream error state. 
+    */
+    TInt                                        iWriteSequenceErr;
+    
+    /**
+    The write data stream state variable. 
+    */
+    TUint                                       iWriteSequenceState;
+    
+    /**
+    The NumberOfPropDescs element metadata content.
+    */
+    CMTPTypeCompoundBase::TElementInfo          iInfoNumberOfPropDescs;
+    
+    /**
+    The ObjectPropDesc array elements metadata content. Note that this is 
+    declared mutable to allow state updates while processing a read data stream.
+    */
+    mutable CMTPTypeCompoundBase::TElementInfo  iInfoObjectPropDesc;
+    
+    /**
+    The NumberOfPropDescs element data chunk.
+    */
+    TMTPTypeUint32                              iChunkNumberOfPropDescs;
+    
+    /**
+    The ObjectPropDesc elements array data chunks.
+    */
+    RPointerArray<CMTPTypeObjectPropDesc>       iChunksObjectPropDesc;
+    };
+
+#endif // CMTPTYPEINTERDEPENDENTPROPDESC_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypelist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,122 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// 
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+#ifndef CMTPTYPELIST_H_
+#define CMTPTYPELIST_H_
+
+
+#include <e32std.h>
+#include <mtp/rmtptype.h>
+#include <mtp/cmtptypecompoundbase.h>
+#include <mtp/mtpdatatypeconstants.h>
+
+
+class CMTPTypeList : public CMTPTypeCompoundBase
+    {
+public:
+    IMPORT_C static CMTPTypeList* NewL(TMTPTypeIds aListType, TMTPTypeIds aElementType);
+    IMPORT_C static CMTPTypeList* NewLC(TMTPTypeIds aListType, TMTPTypeIds aElementType);
+    IMPORT_C virtual ~CMTPTypeList();
+    IMPORT_C virtual void AppendL(const MMTPType* aElement);
+    IMPORT_C virtual void Remove(const TInt aIndex);
+    IMPORT_C virtual TInt ElementType() const;
+    IMPORT_C virtual TUint32 NumberOfElements() const;
+    IMPORT_C MMTPType& ElementL(const TInt aIndex) const;
+    IMPORT_C void ResetAndDestroy();
+    
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C virtual TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C virtual TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C virtual TUint Type() const;
+    IMPORT_C virtual TBool CommitRequired() const;
+    IMPORT_C virtual MMTPType* CommitChunkL(TPtr8& aChunk); 
+    IMPORT_C virtual TInt NextWriteChunk(TPtr8& aChunk, TUint aDataLength);
+    
+    
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    TInt ValidateChunkCount() const;
+
+protected:
+	CMTPTypeList(TInt aArrayType, TInt aElementType);
+	void InitListL();
+	
+private:
+    void ConstructL();
+    TInt UpdateWriteSequenceErr(TInt aErr);
+    void AppendElementChunkL(const MMTPType* aElement);
+    
+private:
+
+    /**
+    The write data stream states.
+    */
+    enum TReadWriteSequenceState
+        {
+        /**
+        Data stream is inactive.
+        */
+        EIdle,
+        
+        /**
+        Elements data stream is in progress.
+        */
+        EElementChunks,          
+        };
+
+private:
+
+    /**
+    The write data stream error state. 
+    */
+    TUint                                           iWriteSequenceErr;
+    
+    /**
+    The write data stream state variable. 
+    */
+    TUint                                           iWriteSequenceState;
+
+    /**
+    The NumberOfElements element metadata content.
+    */
+    CMTPTypeCompoundBase::TElementInfo              iInfoNumberOfElements;
+    
+    /**
+    The Element array metadata content. Note that this is declared mutable 
+    to allow state updates while processing a read data stream.
+    */
+    mutable CMTPTypeCompoundBase::TElementInfo      iInfoElement;
+    
+    TInt                                            iListType;
+    TInt                                            iElementType;
+    
+    static const TUint                              KChunckNumberOfHeader;
+    static const TUint                              KChunkNumberofElements;
+    TMTPTypeUint32                                  iChunkNumberOfElements;    
+    
+    RPointerArray<MMTPType>                         iChunksElement;
+    };
+
+
+
+#endif /* CMTPTYPELIST_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypeobjectinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,235 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef CMTPTYPEOBJECT_H
+#define CMTPTYPEOBJECT_H
+
+#include <e32std.h>
+#include <mtp/cmtptypecompoundbase.h>
+
+class CMTPTypeString;
+
+/** 
+Defines the MTP ObjectInfo dataset. The ObjectInfo dataset describes the core
+properties of an MTP data object, and is generated in response to a 
+GetObjectInfo operation request.
+@publishedPartner
+@released 
+*/ 
+class CMTPTypeObjectInfo : public CMTPTypeCompoundBase
+    {
+public:
+
+    /**
+    MTP ObjectInfo dataset element identifiers.
+    */
+    enum TMTPObjectInfoElement
+        {
+        /**
+        StorageID.
+        */
+        EStorageID,
+        
+        /**
+        Object Format.
+        */
+        EObjectFormat,
+        
+        /**
+        Protection Status.
+        */
+        EProtectionStatus,
+        
+        /**
+        Object Compressed Size.
+        */
+        EObjectCompressedSize,
+        
+        /**
+        Thumb Format.
+        */
+        EThumbFormat,
+        
+        /**
+        Thumb Compressed Size.
+        */
+        EThumbCompressedSize,
+        
+        /**
+        Thumb Pix Width.
+        */
+        EThumbPixWidth,
+        
+        /**
+        Thumb Pix Height.
+        */
+        EThumbPixHeight,
+        
+        /**
+        Image Pix Width.
+        */
+        EImagePixWidth,
+        
+        /**
+        Image Pix Height.
+        */
+        EImagePixHeight,
+        
+        /**
+        Image Bit Depth.
+        */
+        EImageBitDepth,
+        
+        /**
+        Parent Object.
+        */
+        EParentObject,
+        
+        /**
+        Association Type.
+        */
+        EAssociationType,
+        
+        /**
+        Association Description.
+        */
+        EAssociationDescription,
+        
+        /**
+        Sequence Number.
+        */
+        ESequenceNumber,
+        
+        /**
+        Filename.
+        */
+        EFilename,
+        
+        /**
+        Date Created.
+        */
+        EDateCreated,
+        
+        /**
+        Date Modified.
+        */
+        EDateModified,
+        
+        /**
+        Keywords.
+        */
+        EKeywords,        
+        
+        /**
+        The number of dataset elements.
+        */
+        ENumElements,
+        };
+
+public:
+    
+    IMPORT_C static CMTPTypeObjectInfo* NewL();
+    IMPORT_C static CMTPTypeObjectInfo* NewLC();
+    
+    IMPORT_C virtual ~CMTPTypeObjectInfo();   
+     
+public: // From MMTPType
+
+    IMPORT_C TUint Type() const;
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+
+private:
+
+    CMTPTypeObjectInfo();
+    void ConstructL();
+
+    MMTPType* NewFlatChunkL(const TElementInfo& aElementInfo);
+    MMTPType* NewStringChunkL(const TElementInfo& aElementInfo);
+
+private:
+        
+    /**
+    Data chunk identifiers.
+    */
+    enum TChunkIds
+        {
+        /**
+        The first flat data chunk ID.
+        */
+        EIdFlat1Chunk,
+        
+        /**
+        The EFilename element data chunk ID.
+        */
+        EIdFilenameChunk,
+        
+        /**
+        The EDateCreated element data chunk ID.
+        */
+        EIdDateCreatedChunk,
+        
+        /**
+        The EDateModified element data chunk ID.
+        */
+        EIdDateModifiedChunk,
+        
+        /**
+        The EKeywords element data chunk ID.
+        */
+        EIdKeywordsChunk,
+        
+        /**
+        The number of data chunks.
+        */
+        EIdNumChunks
+        };
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The size in bytes of the flat data chunk.
+    */
+    static const TUint                              KFlatChunkSize;
+    
+    /**
+    The flat data chunk comprising elements EStorageID to EParentObject.
+    */
+    RMTPTypeCompoundFlatChunk                       iChunkFlat;
+    
+    /**
+    MTP string type data chunks (EFilename, EDateCreated, EDateModified, and 
+    EKeywords).
+    */
+    RPointerArray<CMTPTypeString>                   iChunksString;
+    };
+    
+#endif // CMTPTYPEOBJECT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypeobjectpropdesc.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,587 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef CMTPTYPEOBJECTPROPDESC_H
+#define CMTPTYPEOBJECTPROPDESC_H
+
+#include <e32std.h>
+#include <mtp/rmtptype.h>
+#include <mtp/cmtptypecompoundbase.h>
+#include <mtp/cmtptypeinterdependentpropdesc.h>
+
+
+
+class CMTPTypeServiceObjPropExtnForm;
+class CMTPTypeServiceMethodParamExtnForm;
+/** 
+Defines the MTP ObjectPropDesc dataset. The ObjectPropDesc dataset describes 
+an MTP data object property, and is generated in response to a 
+GetObjectPropDesc operation request.
+@publishedPartner
+@released 
+*/ 
+class CMTPTypeObjectPropDesc : public CMTPTypeCompoundBase
+    {
+    friend class        CMTPTypeServiceObjPropExtnForm;
+    friend class        CMTPTypeServiceMethodParamExtnForm;
+    friend class		CMTPTypeServicePropDesc;
+public:
+
+    /**
+    MTP ObjectPropDesc dataset element identifiers.
+    */
+    enum TMTPObjectPropDescElement
+        {
+        /**
+        Property Code (read-only).
+        */
+        EPropertyCode,
+        
+        /**
+        Datatype (read-only).
+        */
+        EDatatype,
+        
+        /**
+        Get/Set.
+        */
+        EGetSet,
+        
+        /**
+        Default Value.
+        */
+        EDefaultValue,
+        
+        /**
+        Group Code.
+        */
+        EGroupCode,
+        
+        /**
+        Form Flag (read-only).
+        */
+        EFormFlag,
+        
+        /**
+        FORM element. This element depends EFormFlag and is absent if EFormFlag 
+        is ENone.
+        */
+        EForm,  
+        
+        /**
+        The number of dataset elements.
+        */
+        ENumElements,
+        };
+
+    /**
+    MTP ObjectPropDesc dataset Get/Set element values.
+    */
+    enum TMTPObjectPropDescGetSet
+        {
+
+        /** 
+        Get.
+        */
+        EReadOnly       = 0x00,
+
+        /** 
+        Get/Set.
+        */
+        EReadWrite      = 0x01
+        };
+
+    /**
+    MTP ObjectPropDesc dataset FormFlag element values.
+    */
+    enum TMTPObjectPropDescFormFlag
+        {
+        /** 
+        None.
+        */
+        ENone                   = 0x00,
+
+        /** 
+        Range form.
+        */
+        ERangeForm              = 0x01,
+
+        /** 
+        Enumeration form.
+        */
+        EEnumerationForm        = 0x02,
+
+        /** 
+        DateTime form.
+        */
+        EDateTimeForm           = 0x03,
+
+        /** 
+        Fixed-length Array form.
+        */
+        EFixedLengthArrayForm   = 0x04,
+
+        /** 
+        Regular Expression form.
+        */
+        ERegularExpressionForm  = 0x05,
+
+        /** 
+        ByteArray form.
+        */
+        EByteArrayForm          = 0x06,
+
+        /**
+        * Service Object Property Extension Form
+        */
+        EServiceObjPropExtnForm = 0x81,
+        
+        /**
+        * Service Method Parameter Extension Form
+        */
+        EServiceMethodParamExtnForm = 0x82,
+        
+        /**
+        * Object ID Form
+        */
+        EObjectIDForm           = 0x83,
+        
+        /** 
+        LongString form.
+        */
+        ELongStringForm         = 0xFF,
+        };
+
+    /**
+    Defines the MTP ObjectPropDesc dataset meta data.
+    */
+    struct TPropertyInfo
+        {
+        /**
+        The property's MTP data type identifier datacode.
+        */
+        TUint           iDataType;
+        
+        /**
+        The FormFlag identifier.
+        */
+        TUint8          iFormFlag;
+        
+        /**
+        The property's Get/Set flag.
+        */
+        TUint8          iGetSet;
+        };
+
+public:
+    
+    IMPORT_C static CMTPTypeObjectPropDesc* NewL();
+    
+    IMPORT_C static CMTPTypeObjectPropDesc* NewL(TUint16 aPropertyCode);
+    IMPORT_C static CMTPTypeObjectPropDesc* NewLC(TUint16 aPropertyCode);
+    
+    IMPORT_C static CMTPTypeObjectPropDesc* NewL(TUint16 aPropertyCode, const MMTPType& aForm);
+    IMPORT_C static CMTPTypeObjectPropDesc* NewLC(TUint16 aPropertyCode, const MMTPType& aForm);
+    
+    IMPORT_C static CMTPTypeObjectPropDesc* NewL(TUint16 aPropertyCode, TUint8 aFormFlag, const MMTPType* aForm);
+    IMPORT_C static CMTPTypeObjectPropDesc* NewLC(TUint16 aPropertyCode, TUint8 aFormFlag, const MMTPType* aForm);
+    
+    IMPORT_C static CMTPTypeObjectPropDesc* NewL(TUint16 aPropertyCode, const TPropertyInfo& aInfo, const MMTPType* aForm);
+    IMPORT_C static CMTPTypeObjectPropDesc* NewLC(TUint16 aPropertyCode, const TPropertyInfo& aInfo, const MMTPType* aForm);
+    
+    IMPORT_C virtual ~CMTPTypeObjectPropDesc();   
+     
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+
+public:
+
+    static void PropertyInfoL(TUint16 aPropertyCode, TPropertyInfo& aInfo);
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    TBool ReadableElementL(TInt aElementId) const;
+    TBool WriteableElementL(TInt aElementId) const;
+
+private:
+
+    /*
+    Defines the MTP ObjectPropDesc FORM dataset. The FORM dataset is a 
+    component element of the ObjectPropDesc dataset.
+    @internalComponent
+    */ 
+    class RMTPTypeObjectPropDescForm : public RMTPType
+        {
+    public:
+
+        RMTPTypeObjectPropDescForm();
+        
+        void SetMeta(TUint8 aFormFlag, TUint aDataType);
+        
+    private:
+     
+        MMTPType* CreateL(TUint aDataType);
+        void Destroy(MMTPType* aType);
+        
+    private:
+    
+        /**
+        The FORM dataset's MTP datatype code.
+        */
+        TUint   iDataType;
+        
+        /**
+        The FORM dataset's FormFlag code.
+        */
+        TUint8  iFormFlag;
+        };
+        
+private:
+
+    friend MMTPType* CMTPTypeInterdependentProperties::CommitChunkL(TPtr8& aChunk);
+    static CMTPTypeObjectPropDesc* NewLC();
+
+    CMTPTypeObjectPropDesc();
+    void ConstructL(TUint16 aPropertyCode, const MMTPType* aForm);
+    void ConstructL(TUint16 aPropertyCode, const TPropertyInfo& aInfo, const MMTPType* aForm);
+
+    TBool HasFormField(TUint8 aFormFlag) const;
+    TInt UpdateWriteSequenceErr(TInt aErr);
+
+private: // Owned
+
+    /**
+    The write data stream states.
+    */
+    enum TWriteSequenceState
+        {
+        /**
+        Data stream is inactive.
+        */
+        EIdle,
+        
+        /**
+        Streaming the first flat data chunk.
+        */
+        EFlat1Chunk,
+        
+        /**
+        Streaming the EDefaultValue data chunk..
+        */
+        EDefaultValueChunk,
+        
+        /**
+        Streaming the second flat data chunk.
+        */
+        EFlat2Chunk,
+        
+        /**
+        Streaming the EForm data chunk.
+        */
+        EFormChunk   
+        };
+        
+    /**
+    Data chunk identifiers.
+    */
+    enum TChunkIds
+        {
+        /**
+        The first flat data chunk ID.
+        */
+        EIdFlat1Chunk,
+        
+        /**
+        The EDefaultValue element data chunk ID.
+        */
+        EIdDefaultValueChunk,
+        
+        /**
+        The second flat data chunk ID.
+        */
+        EIdFlat2Chunk,
+        
+        /**
+        The EForm element data chunk ID.
+        */
+        EIdFormChunk,
+        
+        /**
+        The number of data chunks.
+        */
+        EIdNumChunks
+        };
+
+    /**
+    The write data stream error state. 
+    */
+    TUint                                           iWriteSequenceErr;
+    
+    /**
+    The write data stream state variable. 
+    */
+    TUint                                           iWriteSequenceState;
+    
+    /**
+    The write data stream completion state. This will be set to EFlat2Chunk for 
+    ObjectPropDesc datasets with an EForm of ENone, otherwise this will be 
+    EFormChunk.
+    */
+    TUint                                           iWriteSequenceCompletionState;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The initialised flag indicating if construction is completeand that 
+    read-only elements can no longer be modified.
+    */
+    TBool                                           iInitialised;
+    
+    /**
+    The size in bytes of the first flat data chunk.
+    */
+    static const TUint                              KFlat1ChunkSize;
+    
+    /**
+    The size in bytes of the second flat data chunk.
+    */
+    static const TUint                              KFlat2ChunkSize;
+    
+    /**
+    The data chunk count of ObjectPropDesc datasets with an EForm of other than 
+    ENone.
+    */
+    static const TUint                              KNumChunksWithForm;
+    
+    /**
+    The data chunk count of ObjectPropDesc datasets with an EForm of ENone.
+    */
+    static const TUint                              KNumChunksWithoutForm;
+    
+    /**
+    The flat data chunk comprising elements EPropertyCode to EGetSet.
+    */    
+    RMTPTypeCompoundFlatChunk                       iChunkFlat1;
+    
+    /**
+    The EDefaultValue element data chunk.
+    */
+    RMTPType                                        iChunkDefaultValue;
+    
+    /**
+    The flat data chunk comprising elements EGroupCode to EFormFlag.
+    */
+    RMTPTypeCompoundFlatChunk                       iChunkFlat2;
+    
+    /**
+    The EForm element data chunk.
+    */
+    RMTPTypeObjectPropDescForm                      iChunkForm;
+    };
+
+/** 
+Defines the MTP ObjectPropDesc Enumeration FORM dataset. The Enumeration FORM 
+dataset is a component element of the ObjectPropDesc dataset.
+@see CMTPTypeObjectPropDesc
+@publishedPartner
+@released
+*/ 
+class CMTPTypeObjectPropDescEnumerationForm : public CMTPTypeCompoundBase
+    {
+        
+public:
+    
+    IMPORT_C static CMTPTypeObjectPropDescEnumerationForm* NewL(TUint aDataType);
+    IMPORT_C static CMTPTypeObjectPropDescEnumerationForm* NewLC(TUint aDataType);
+    
+    IMPORT_C virtual ~CMTPTypeObjectPropDescEnumerationForm();
+    
+    IMPORT_C void AppendSupportedValueL(const MMTPType& aValue);
+    
+    IMPORT_C TUint16 NumberOfValues() const;
+    IMPORT_C void SupportedValueL(TUint aIndex, MMTPType& aValue) const;
+     
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    TInt ValidateChunkCount() const;
+    
+private:
+
+    CMTPTypeObjectPropDescEnumerationForm(TUint aDataType);
+    void ConstructL();
+    
+    void AppendValueChunkL();
+    
+private:
+
+    /**
+    The write data stream states.
+    */
+    enum TReadWriteSequenceState
+        {
+        /**
+        Data stream is inactive.
+        */
+        EIdle,
+        
+        /**
+        Data stream is in progress.
+        */
+        EInProgress            
+        };
+
+    /**
+    The write data stream state variable. 
+    */
+    TUint                                       iWriteSequenceState;
+    
+    /**
+    The NumberOfValues element metadata content.
+    */
+    CMTPTypeCompoundBase::TElementInfo          iInfoNumberOfValues;
+    
+    /**
+    The SupportedValue array elements metadata content. Note that this is 
+    declared mutable to allow state updates while processing a read data stream.
+    */
+    mutable CMTPTypeCompoundBase::TElementInfo  iInfoValue;
+    
+    /**
+    The NumberOfValues element data chunk ID.
+    */
+    static const TUint                          KNumberOfValuesChunk;
+    
+    /**
+    The SupportedValue array elements metadata content. Note that this is 
+    declared mutable to allow state updates while processing a read data stream.
+    */
+    static const TUint                          KValueChunks;
+    
+    /**
+    The NumberOfPropDescs element data chunk.
+    */
+    TMTPTypeUint16                              iChunkNumberOfValues;
+    
+    /**
+    The SupportedValue elements array data chunks.
+    */
+    RArray<RMTPType>                            iChunksValue;
+    };
+
+/** 
+Defines the MTP ObjectPropDesc Range FORM dataset. The Range FORM dataset is a 
+component element of the ObjectPropDesc dataset.
+@see CMTPTypeObjectPropDesc
+@publishedPartner
+@released
+*/ 
+class CMTPTypeObjectPropDescRangeForm : public CMTPTypeCompoundBase
+    {
+public:
+
+    /**
+    MTP ObjectPropDesc Range FORM element dataset identifiers.
+    */
+    enum TMTPObjectPropDescElement
+        {
+        /**
+        Minimum Value.
+        */
+        EMinimumValue,
+        
+        /**
+        Maximum Value.
+        */
+        EMaximumValue,
+        
+        /**
+        Step Size.
+        */
+        EStepSize,
+
+        /**
+        The number of dataset elements.
+        */
+        ENumElements,
+        };
+    
+public:
+    
+    IMPORT_C static CMTPTypeObjectPropDescRangeForm* NewL(TUint aDataType);
+    IMPORT_C static CMTPTypeObjectPropDescRangeForm* NewLC(TUint aDataType);
+    
+    IMPORT_C virtual ~CMTPTypeObjectPropDescRangeForm();  
+     
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C TUint Type() const;
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    
+private:
+
+    CMTPTypeObjectPropDescRangeForm(TUint aDataType);
+    void ConstructL();
+    
+private:
+
+    /**
+    The element metadata content.
+    */
+    mutable CMTPTypeCompoundBase::TElementInfo  iInfoBuf;
+
+    /**
+    The property's MTP data type identifier datacode.
+    */
+    TUint                                       iDataType;
+    
+    /**
+    The element data chunks.
+    */
+    RArray<RMTPType>                            iChunks;
+    };
+
+#endif // CMTPTYPEOBJECTPROPDESC_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypeobjectproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,269 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef CMTPTYPEOBJECTPROPLIST_H
+#define CMTPTYPEOBJECTPROPLIST_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <mtp/rmtptype.h>
+//#include <mtp/cmtptypecompoundbase.h>
+
+class CMTPTypeObjectPropListElement;
+class CMTPTypeArray;
+/** 
+Defines the MTP ObjectPropList dataset. The ObjectPropList dataset provides
+optimised access to object properties without needing to individually query 
+each object/property pair. It also provides a more flexible querying mechanism 
+for object properties in general. This dataset is used in the 
+GetObjectPropList, SetObjectPropList, and SendObjectPropList requests.
+@publishedPartner
+@released 
+*/
+
+class CMTPTypeObjectPropList : public CBase, public MMTPType 
+    {
+public:    
+    IMPORT_C static CMTPTypeObjectPropList* NewL();
+    IMPORT_C static CMTPTypeObjectPropList* NewLC();
+    IMPORT_C virtual ~CMTPTypeObjectPropList();  
+
+    /**
+    Reserve an object property element in buffer page. After setting the element's values, the element should 
+    be committed, otherwise the new element will be discarded without commitment.
+    @param aHandle The object handle of the object property element.
+    @param aPropCode The property code of the object property element.
+    */
+    IMPORT_C CMTPTypeObjectPropListElement& ReservePropElemL(TUint32 aHandle, TUint16 aPropCode);
+    
+    /**
+    Commit the reverved object property element in buffer page.
+    @param aElem The object property element to be committed.
+    */
+    IMPORT_C void CommitPropElemL(CMTPTypeObjectPropListElement& aElem);
+    
+    /**
+    Reset the element cursor, so GetNextElementL() will return the first object property element
+    in the object property list.
+    */
+    IMPORT_C void ResetCursor() const;  
+    
+    /**
+    Get the next object property element in the object property list.
+    */
+    IMPORT_C CMTPTypeObjectPropListElement& GetNextElementL() const;
+    
+    /**
+    Get the size of the object property list.
+    */
+    IMPORT_C TUint64 Size() const;
+    
+    /**
+    Get the number of element in the object property list.
+    */
+    IMPORT_C TUint32 NumberOfElements() const;
+    
+    /**
+    Append all object property elements from another object property list.
+    */
+    IMPORT_C void AppendObjectPropListL(const CMTPTypeObjectPropList& aSource);
+     
+public: // From MMTPType
+    IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt NextReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk, TUint aDataLength);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk, TUint aDataLength);
+    
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+    IMPORT_C TBool ReserveTransportHeader(TUint aHeaderLength, TPtr8& aHeader);
+    IMPORT_C TInt Validate() const;
+    
+private:
+    friend class CMTPTypeObjectPropListElement;
+    CMTPTypeObjectPropList();
+    void  ConstructL();
+    TUint ArrayElemWidth(TUint16& aDataType) const;
+
+    TBool ValueBufferConsistent(TUint aPageIdx, TUint aBufferIdx, TUint aValueSize) const;
+    TBool ValueAddressAligned(TUint aPageIdx, TUint aBufferIdx) const;
+    
+    void ReserveNewPage();
+    
+    void IncreaseIndexL(TUint& aPageIndex, TUint& aBufIndex, TUint aLength, TBool aReserveNewPage) const;   
+    
+    /**
+    Copy data from Element to buffer page.
+    */
+    void MemoryCopyL(TAny* aTrg, TUint aSrcPageIndex, TUint aSrcBufIndex, TUint aLength) const;
+    
+    /**
+    Copy data from buffer page to Element.
+    */
+    void MemoryCopyL(TUint aTrgPageIndex, TUint aTrgBufIndex, const TAny* aSrc, TUint aLength);
+
+    
+
+private: 
+    /*
+    The objectproplist buffer pages, each page is 64k bytes. It will only allocate one page in ContructL
+    */
+    RArray<RBuf8>                                   iIOPages;
+
+    /*
+    The last page number of valid elements
+    */
+    TUint                                           iRevPageEnd;
+    
+    /*
+    The Reserved data length for recieve
+    */
+    TUint                                           iRevDataEnd;
+    
+    /*
+    The chunk index used by NextReadChunk
+    */
+    mutable TUint                                   iChunkIndex;    
+    /*
+    The index of transport buffer header
+    */
+    TUint                                           iTransportHeaderIndex;
+    /*
+    If reserved a element but not committed, iPropElemCommitted will be set to ETrue, otherwise Efalse
+    */    
+    TBool                                           iReservedElemCommitted;
+    /*
+    Pointed to the NumberOfelements field of ObjectPropList
+    */
+    TUint32                                         iNumberOfElements;
+    
+    /*
+    Current element to be read
+    */    
+    mutable CMTPTypeObjectPropListElement*          iCurrentElement;
+    
+    /*
+    The reverved element
+    */
+    CMTPTypeObjectPropListElement*                  iReservedElement;
+    
+    mutable TBool                                   iResetCursor;
+
+	};
+/**
+Defines the MTP ObjectPropList element dataset. The ObjectPropList element 
+dataset describes an object property with a meta data triplet and a value. It
+is a  component element of the ObjectPropList dataset.
+*/
+class CMTPTypeObjectPropListElement : public CBase
+    {
+
+public:
+
+    /**
+    MTP ObjectPropList property quadruple dataset element identifiers.
+    */
+    enum TMTPObjectPropListElement
+        {
+        /**
+        The ObjectHandle of the object to which the property applies.
+        */
+        EObjectHandle,
+        
+        /**
+        The ObjectPropDesc property identifier datacode (read-only).
+        */
+        EPropertyCode,
+        
+        /**
+        The datatype code of the property (read-only).
+        */
+        EDatatype,
+        
+        /**
+        The value of the property.
+        */
+        EValue,
+
+        /**
+        The number of dataset elements.
+        */
+        ENumElements,
+        };
+
+public:
+    IMPORT_C virtual ~CMTPTypeObjectPropListElement(); 
+    IMPORT_C TUint32 Size() const;    
+
+    IMPORT_C TUint8 Uint8L(TInt aElementId) const;
+    IMPORT_C TUint16 Uint16L(TInt aElementId) const;
+    IMPORT_C TUint32 Uint32L(TInt aElementId) const;
+    IMPORT_C TUint64 Uint64L(TInt aElementId) const;
+    IMPORT_C void    Uint128L(TInt aElementId,TUint64& high, TUint64& low) const;
+    IMPORT_C const TDesC& StringL(TInt aElementId) const;
+    IMPORT_C const TDesC8& ArrayL(TInt aElementId) const;    
+    
+    IMPORT_C void SetUint8L(TInt aElementId, TUint8 aData);
+    IMPORT_C void SetUint16L(TInt aElementId, TUint16 aData);
+    IMPORT_C void SetUint32L(TInt aElementId, TUint32 aData);    
+    IMPORT_C void SetUint64L(TInt aElementId, TUint64 aData);
+    IMPORT_C void SetUint128L(TInt aElementId, TUint64 high, TUint64 low);
+    IMPORT_C void SetStringL(TInt aElementId, const TDesC& aString);
+    IMPORT_C void SetArrayL(TInt aElementId, const CMTPTypeArray& aArray);
+    IMPORT_C void SetArrayL(TInt aElementId, const TDesC& aString);
+
+    
+private:
+    friend class CMTPTypeObjectPropList;
+    static CMTPTypeObjectPropListElement* NewL(CMTPTypeObjectPropList* propList);
+    static CMTPTypeObjectPropListElement* NewLC(CMTPTypeObjectPropList* propList);
+    CMTPTypeObjectPropListElement();
+    void ConstructL(CMTPTypeObjectPropList* propList);
+    void SetDataType(TUint16 aDataType);
+    void GetValueL(TAny* aTrg, TUint aLength) const;
+    void SetValueL(const TAny* aTrg, TUint aLength);
+
+private:
+    mutable CMTPTypeObjectPropList*  iPropList;    
+    TUint                    iPageIndex;
+    TUint                    iBufIndex;
+    
+    mutable TUint32          iObjectHandle;
+    mutable TUint16          iPropertyCode;
+    mutable TUint16          iDataType;
+    TUint32 iValueSize;
+    // Pointed to string value
+    mutable TPtrC            iStringValue;
+    // Pointed to array value
+    mutable TPtrC8           iArrayValue;
+    // If the buffer address of string data is not aligned, the data will be copied to iStringHolder
+    mutable RBuf16           iStringHolder;
+    // If the buffer address of string data is not aligned, the data will be copied to iStringHolder
+    mutable TBool            iArrayBuffered;
+
+    };
+
+#endif // CMTPTYPEOBJECTPROPLIST_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypeopaquedata.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,64 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+#ifndef CMTPTYPEOPAQUEDATA_H_
+#define CMTPTYPEOPAQUEDATA_H_
+
+#include <e32base.h>
+#include <mtp/mmtptype.h>
+
+class CMTPTypeOpaqueData : public CBase, public MMTPType
+    {
+public:
+    IMPORT_C static CMTPTypeOpaqueData* NewL();
+    IMPORT_C static CMTPTypeOpaqueData* NewLC();
+    IMPORT_C static CMTPTypeOpaqueData* NewL(const TDesC8 &aDes);
+    IMPORT_C static CMTPTypeOpaqueData* NewLC(const TDesC8 &aDes);
+    IMPORT_C ~CMTPTypeOpaqueData();
+    
+public: //MMTPType
+    IMPORT_C virtual TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C virtual TInt NextReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C virtual TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C virtual TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C virtual TBool CommitRequired() const;
+    IMPORT_C virtual MMTPType* CommitChunkL(TPtr8& aChunk);
+    IMPORT_C virtual TUint64 Size() const;
+    IMPORT_C virtual TUint Type() const;
+    IMPORT_C virtual TInt FirstWriteChunk(TPtr8& aChunk, TUint aDataLength);
+
+public:
+    IMPORT_C TInt Read(TPtrC8 &aDes) const;
+    IMPORT_C TInt Write(const TPtrC8 &aDes);
+    
+private:
+    void ConstructL();
+    void ConstructL(const TDesC8 &aDes);
+    CMTPTypeOpaqueData();
+    TInt CreateBuffer( const TInt aMaxSize );
+
+    
+private:
+    RBuf8    iBuffer;
+    TPtr8    iPtrBuffer;
+    };
+
+
+#endif /* CMTPTYPEOPAQUEDATA_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypeservicecapabilitylist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,143 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+
+#ifndef CMTPTYPESERVICECAPABILITYLIST_H_
+#define CMTPTYPESERVICECAPABILITYLIST_H_
+
+#include <e32std.h>
+#include <mtp/rmtptype.h>
+#include <mtp/cmtptypecompoundbase.h>
+#include <mtp/cmtptypelist.h>
+
+class CMTPTypeList;
+class CMTPTypeObjectPropDesc;
+class CMTPTypeInterdependentPropDesc;
+class CMTPTypeFormatCapability;
+
+class CMTPTypeServiceCapabilityList : public CMTPTypeList
+	{
+public:
+	
+	IMPORT_C static CMTPTypeServiceCapabilityList* NewL();
+	IMPORT_C static CMTPTypeServiceCapabilityList* NewLC();
+    
+	IMPORT_C virtual ~CMTPTypeServiceCapabilityList(); 
+    IMPORT_C void AppendL(CMTPTypeFormatCapability* aFormatCapability);  
+    IMPORT_C CMTPTypeFormatCapability& ElementL(TUint aIndex) const;
+
+private:
+
+	CMTPTypeServiceCapabilityList();
+    void ConstructL();
+	};
+
+
+
+class CMTPTypeFormatCapability : public CMTPTypeCompoundBase
+    {
+public:
+    
+    enum TMTPFormatCapabilityElement
+        {
+        EFormatCode,
+        ENumElements,
+        };
+public:
+
+    IMPORT_C static CMTPTypeFormatCapability* NewL();
+    IMPORT_C static CMTPTypeFormatCapability* NewLC();
+    IMPORT_C static CMTPTypeFormatCapability* NewL( const TUint16 aFormatCode, CMTPTypeInterdependentPropDesc* aInterDependentPropDesc );
+    IMPORT_C static CMTPTypeFormatCapability* NewLC( const TUint16 aFormatCode, CMTPTypeInterdependentPropDesc* aInterDependentPropDesc );
+    
+    IMPORT_C void AppendL(CMTPTypeObjectPropDesc* aElement);
+    IMPORT_C TUint32 NumberOfPropDescs() const;
+    IMPORT_C CMTPTypeObjectPropDesc& ObjectPropDescL(TUint aIndex) const;  
+    
+    IMPORT_C CMTPTypeInterdependentPropDesc& InterdependentPropDesc() const;  
+    IMPORT_C virtual ~CMTPTypeFormatCapability();   
+    
+public: 
+    IMPORT_C TUint Type() const;
+
+    
+private: // From CMTPTypeCompoundBase
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    
+protected:// From CMTPTypeCompoundBase
+    TBool ReadableElementL(TInt aElementId) const;
+    TBool WriteableElementL(TInt aElementId ) const;
+    
+private:
+    CMTPTypeFormatCapability( CMTPTypeInterdependentPropDesc* aInterDependentPropDesc );
+    void ConstructL();
+    void ConstructL( const TUint16 aFormatCode );
+    MMTPType* NewFlatChunkL();
+    
+private:
+
+    /**
+    Data chunk identifiers.
+    */
+    enum TChunkIds
+        {
+        /**
+        The flat data chunk ID.
+        */
+        EIdFlatChunk,
+        
+        /*
+         * The CMTPTypeObjectPropDescList dataset.
+         */
+        EIdObjPropDescListChunk,
+        
+        /*
+         The CMTPTypeInterdependentPropDesc dataset.
+         */
+        EIdInterDependentPropDescChunk,
+        /**
+        The number of data chunks.
+        */
+        EIdNumChunks
+        };
+    /**
+    The dataset element metadata table content.
+    */
+    static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+       
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+     
+    /**
+    The flat data chunk comprising elements EStorageType to EFreeSpaceInObjects.
+    */
+    RMTPTypeCompoundFlatChunk                       iChunkFlat;
+    
+private:
+    
+    CMTPTypeList*                       iObjectPropDescList;
+    CMTPTypeInterdependentPropDesc*    iInterdependentPropDesc;
+    
+    };
+
+#endif /*CMTPTYPESERVICECAPABILITYLIST_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypeserviceevent.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,136 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//  
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+#ifndef CMTPTYPESERVICEEVENT_H_
+#define CMTPTYPESERVICEEVENT_H_
+
+#include <e32std.h>
+#include <mtp/cmtptypecompoundbase.h>
+#include <mtp/cmtptypelist.h>
+
+class CMTPTypeArray;
+class CMTPTypeString;
+class CMTPTypeServiceEventElement;
+
+class CMTPTypeServiceEventList : public CMTPTypeList
+	{
+public:
+    
+	IMPORT_C static CMTPTypeServiceEventList* NewL();
+	IMPORT_C static CMTPTypeServiceEventList* NewLC();
+
+	IMPORT_C virtual ~CMTPTypeServiceEventList();  
+    
+    IMPORT_C void AppendL(CMTPTypeServiceEventElement* aElement);
+    IMPORT_C CMTPTypeServiceEventElement& ElementL(TUint aIndex) const; 
+    
+private:
+
+	CMTPTypeServiceEventList();
+    void ConstructL();
+    
+	};
+
+class CMTPTypeServiceEventElement : public CMTPTypeCompoundBase
+	{
+public:
+	
+	enum TMTPServiceEventElement
+		{
+		EEventCode,
+		EEventGUID,
+		EEventName,
+		ENumElements
+		};
+	
+public:
+    
+	IMPORT_C static CMTPTypeServiceEventElement* NewL();
+	IMPORT_C static CMTPTypeServiceEventElement* NewLC();
+	IMPORT_C static CMTPTypeServiceEventElement* NewL(const TUint16 aEventCode,const TMTPTypeGuid& aEventGUID,const TDesC& aEventName);
+	IMPORT_C static CMTPTypeServiceEventElement* NewLC(const TUint16 aEventCode,const TMTPTypeGuid& aEventGUID,const TDesC& aEventName);
+    
+	IMPORT_C virtual ~CMTPTypeServiceEventElement();   
+     
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C TUint Type() const;
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+
+private:
+
+	CMTPTypeServiceEventElement();
+    void ConstructL();
+    void ConstructL(const TUint16 aEventCode,const TMTPTypeGuid& aEventGUID,const TDesC& aEventName);
+    MMTPType* NewFlatChunkL();
+    
+private:
+    
+	/**
+    Data chunk identifiers.
+    */
+    enum TChunkIds
+    	{
+    	/**
+        The flat data chunk ID.
+        */
+        EIdFlatChunk,
+               
+        EIdServiceEventNameChunk,
+        
+        /**
+        The number of data chunks.
+        */
+        EIdNumChunks
+    	};	
+    
+    
+    /**
+   	The dataset element metadata table content.
+    */
+    static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+       
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+       
+   	/**
+    The size in bytes of the flat data chunk.
+    */
+    static const TUint                              KFlatChunkSize;
+       
+    /**
+    The flat data chunk comprising elements EStorageType to EFreeSpaceInObjects.
+    */
+    RMTPTypeCompoundFlatChunk                       iChunkFlat;
+       
+    /**
+    The MTP string type data chunks (EStorageDescription, and EVolumeIdentifier).
+    */
+    CMTPTypeString*           						iChunkString;  
+
+	};
+
+#endif /*CMTPTYPESERVICEEVENT_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypeserviceformat.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,188 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// 
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+#ifndef CMTPTYPESERVICEFORMAT_H_
+#define CMTPTYPESERVICEFORMAT_H_
+
+#include <e32std.h>
+#include <mtp/cmtptypecompoundbase.h>
+#include <mtp/cmtptypelist.h>
+
+class CMTPTypeArray;
+class CMTPTypeString;
+
+class CMTPTypeServiceFormatElement;
+
+class CMTPTypeServiceFormatList : public CMTPTypeList
+	{
+public:
+    
+	IMPORT_C static CMTPTypeServiceFormatList* NewL();
+	IMPORT_C static CMTPTypeServiceFormatList* NewLC();
+	IMPORT_C virtual ~CMTPTypeServiceFormatList();      
+    IMPORT_C void AppendL(CMTPTypeServiceFormatElement* aElement);    
+    IMPORT_C CMTPTypeServiceFormatElement& ElementL(TUint aIndex) const; 
+     
+private:
+
+	CMTPTypeServiceFormatList();
+    void ConstructL();
+   
+	};
+
+
+class CMTPTypeServiceFormatElement : public CMTPTypeCompoundBase
+	{
+public:
+	
+	enum TMTPServiceFormatElement
+		{
+		EFormatCode,
+		EFormatGUID,
+		EFormatName,
+		EFormatBase,
+		EFormatMIMEType,
+		ENumElements
+		};
+	
+public:
+	
+	IMPORT_C static CMTPTypeServiceFormatElement* NewL();
+	IMPORT_C static CMTPTypeServiceFormatElement* NewLC();
+	IMPORT_C static CMTPTypeServiceFormatElement* NewL(const TUint16 aFormatCode,const TMTPTypeGuid& aFormatGUID,const TDesC& aFormatName,const TUint16 aFormatBase,const TDesC& aMIMEType);
+	IMPORT_C static CMTPTypeServiceFormatElement* NewLC(const TUint16 aFormatCode,const TMTPTypeGuid& aFormatGUID,const TDesC& aFormatName,const TUint16 aFormatBase,const TDesC& aMIMEType);
+    
+	IMPORT_C virtual ~CMTPTypeServiceFormatElement();   
+     
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C TUint Type() const;
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+
+private:
+	CMTPTypeServiceFormatElement();
+    void ConstructL();
+    
+    void ConstructL(const TUint16 aFormatCode,const TMTPTypeGuid& aFormatGUID,const TDesC& aFormatName,const TUint16 aFormatBase,const TDesC& aMIMEType);
+    
+    MMTPType* NewFlatChunkL(const TElementInfo& aElementInfo);
+    MMTPType* NewStringChunkL(const TElementInfo& aElementInfo);
+    
+private:
+
+    enum TWriteSequenceState
+        {
+        /**
+        Data stream is inactive.
+        */
+        EIdle,
+        
+        /**
+        Streaming the property descriptor triplet dataset data chunk.
+        */
+        EFlat1Chunk,
+                
+        EFormatNameChunk,
+        
+        EFlat2Chunk,
+        
+        EFormatMIMETypeChunk
+        
+        };
+    
+	/**
+    Data chunk identifiers.
+    */
+    enum TChunkIds
+    	{
+    	/**
+        The flat data chunk ID.
+        */
+        EIdFlat1Chunk,
+               
+        EIdFormatNameChunk,
+        
+        EIdFlat2Chunk,
+        
+        EIdFormatMIMETypeChunk,
+        
+        /**
+        The number of data chunks.
+        */
+        EIdNumChunks
+    	};	
+    /**
+    The write data stream error state. 
+    */
+    TUint                                           iWriteSequenceErr;
+    
+    /**
+    The write data stream state variable. 
+    */
+    TUint                                           iWriteSequenceState;
+    
+    /**
+    The write data stream completion state. This will be set to EFlat2Chunk for 
+    ObjectPropDesc datasets with an EForm of ENone, otherwise this will be 
+    EFormChunk.
+    */
+    TUint                                           iWriteSequenceCompletionState;
+    
+    /**
+   	The dataset element metadata table content.
+    */
+    static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+       
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+       
+    /**
+    The flat data chunk comprising elements .
+    */
+    RMTPTypeCompoundFlatChunk                       iChunkFlat1;
+    
+    RMTPTypeCompoundFlatChunk						iChunkFlat2;
+
+    /**
+    The size in bytes of the first flat data chunk.
+    */
+    static const TUint                              KFlat1ChunkSize;
+    
+    /**
+    The size in bytes of the second flat data chunk.
+    */
+    static const TUint                              KFlat2ChunkSize;
+    
+    /**
+    The MTP string type data chunks (EStorageDescription, and EVolumeIdentifier).
+    */
+    CMTPTypeString*                                       iChunkFormatNameString;   
+    
+    CMTPTypeString*										 iChunkMIMETypeString;
+    
+	};
+
+#endif /*CMTPTYPESERVICEFORMAT_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypeserviceinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,176 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+#ifndef CMTPTYPESERVICEINFO_H_
+#define CMTPTYPESERVICEINFO_H_
+
+
+#include <e32std.h>
+#include <mtp/cmtptypecompoundbase.h>
+#include <mtp/rmtptype.h>
+#include <mtp/cmtptypearray.h>
+
+class CMTPTypeString;
+class CMTPTypeServiceInfo;
+class CMTPTypeServicePropertyList;
+class CMTPTypeServiceFormatList;
+class CMTPTypeServiceMethodList;
+class CMTPTypeServiceEventList; 
+class TMTPTypeGuid;
+
+class CMTPTypeServiceInfo : public CMTPTypeCompoundBase
+    {
+public:
+    enum TMTPServiceInfoElement
+        {
+        EServiceID,
+        EServiceStorageID,
+        EServicePGUID,
+        EServiceVersion,
+        EServiceGUID,
+        EServiceName,
+        EServiceType,
+        EBaseServiceID,
+
+        /**
+        The number of dataset elements.
+        */
+        ENumElements
+        };
+    
+public:
+    
+    IMPORT_C static CMTPTypeServiceInfo* NewL();
+    IMPORT_C static CMTPTypeServiceInfo* NewLC(); 
+    IMPORT_C virtual ~CMTPTypeServiceInfo();     
+    
+    IMPORT_C TUint32 NumberOfUsedServices() const;
+    IMPORT_C void UsedServiceL( const TUint aIndex, TMTPTypeGuid& aUsedServiceGUID  ) const;  
+    IMPORT_C void AppendUsedServiceL( const TMTPTypeGuid& aElement );
+    
+    IMPORT_C TUint32 NumberOfServiceDataBlock() const;
+    IMPORT_C void SerivceDataBlockL(  const TUint aIndex, TMTPTypeGuid& aGUID ) const;  
+    IMPORT_C void AppendServiceDataBlockL(const TMTPTypeGuid& aElement );    
+public:
+    IMPORT_C TUint Type() const;
+
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    TBool WriteableElementL(TInt aElementId) const;
+    TBool ReadableElementL(TInt aElementId) const;
+    
+private:
+    CMTPTypeServiceInfo();
+    void ConstructL();
+    TInt UpdateWriteSequenceErr(TInt aErr);
+    MMTPType* NewFlatChunkL(const TElementInfo& aElementInfo);
+    
+public:
+    IMPORT_C CMTPTypeServicePropertyList& ServicePropList();
+    IMPORT_C CMTPTypeServiceFormatList& ServiceFormatList();
+    IMPORT_C CMTPTypeServiceMethodList& ServiceMethodList();
+    IMPORT_C CMTPTypeServiceEventList& ServiceEventList();  
+    
+private:
+
+    enum TChunkIds
+        {
+        /**
+        The flat data chunk ID.
+        */
+        EIdFlat1Chunk,
+        /**
+        The EServiceName element data chunk ID
+        */
+        EIdServiceNameChunk,
+        
+        EIdFlat2Chunk,
+        
+        EIdUsedServiceGUIDChunk,
+        
+        EIdServicePropListChunk,
+        
+        EIdServicePropertyListChunk,
+        
+        EIdServiceFormatListChunk,
+        
+        EIdServiceEventListChunk,
+        
+        EIdServiceDataBlockChunk,
+
+        /**
+        The number of data chunks.
+        */
+        EIdNumChunks
+        };
+    
+    
+private:
+    
+        /**
+        The dataset element metadata table content.
+        */
+        static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+           
+        /**
+        The dataset element metadata table.
+        */
+        const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+           
+        /**
+        The flat data chunk comprising elements .
+        */
+        RMTPTypeCompoundFlatChunk                       iChunkFlat1;
+        
+        RMTPTypeCompoundFlatChunk                       iChunkFlat2;
+
+        /**
+        The size in bytes of the first flat data chunk.
+        */
+        static const TUint                              KFlat1ChunkSize;
+        
+        /**
+        The size in bytes of the second flat data chunk.
+        */
+        static const TUint                              KFlat2ChunkSize;
+           
+        /**
+        The MTP string type data chunks (EServiceName).CMTPTypeString
+        */ 
+        CMTPTypeString*                                 iChunkString;
+        
+        /**
+        The MTP array type data chunks .(EUsedServiceGUID) store the used services' GUIDs
+        */
+        CMTPTypeArray*                                   iChunkUsedServices;    
+        
+        CMTPTypeArray*                                   iChunkServiceDataBlock;
+    
+        CMTPTypeServicePropertyList*    iServicePropList;
+        CMTPTypeServiceFormatList*    iServiceFormatList;
+        CMTPTypeServiceMethodList*    iServiceMethodList;
+        CMTPTypeServiceEventList*    iServiceEventList; 
+    
+    };
+
+#endif /*CMTPTYPESERVICEINFO_H_*/
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypeservicemethod.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,146 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// 
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+#ifndef CMTPTYPESERVICEMETHOD_H_
+#define CMTPTYPESERVICEMETHOD_H_
+
+#include <e32std.h>
+#include <mtp/cmtptypecompoundbase.h>
+#include <mtp/cmtptypelist.h>
+
+class CMTPTypeArray;
+class CMTPTypeString;
+class CMTPTypeServiceMethodElement;
+
+class CMTPTypeServiceMethodList : public CMTPTypeList
+	{
+public:
+    
+	IMPORT_C static CMTPTypeServiceMethodList* NewL();
+	IMPORT_C static CMTPTypeServiceMethodList* NewLC();
+	IMPORT_C virtual ~CMTPTypeServiceMethodList();  
+    
+    IMPORT_C void AppendL(CMTPTypeServiceMethodElement* aElement);
+    IMPORT_C CMTPTypeServiceMethodElement& ElementL(TUint aIndex) const; 
+    
+private:
+
+	CMTPTypeServiceMethodList();
+    void ConstructL();
+   
+	};
+
+
+class CMTPTypeServiceMethodElement : public CMTPTypeCompoundBase
+	{
+public:
+	
+	enum TMTPServiceMethodElement
+		{
+		EMethodCode,
+		EMethodGUID,
+		EMethodName,
+		EMethodAssociateFormate,
+		ENumElements
+		};
+	
+public:
+    
+	IMPORT_C static CMTPTypeServiceMethodElement* NewL();
+	IMPORT_C static CMTPTypeServiceMethodElement* NewLC();
+	IMPORT_C static CMTPTypeServiceMethodElement* NewL(const TUint16 aMethodCode,const TMTPTypeGuid& aMethodGUID,const TDesC& aMethodName,const TUint16 aMethodAssociateFormate);
+	IMPORT_C static CMTPTypeServiceMethodElement* NewLC(const TUint16 aMethodCode,const TMTPTypeGuid& aMethodGUID,const TDesC& aMethodName,const TUint16 aMethodAssociateFormate);
+    
+	IMPORT_C virtual ~CMTPTypeServiceMethodElement();   
+     
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C TUint Type() const;
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    
+private:
+
+	CMTPTypeServiceMethodElement();
+    void ConstructL();
+    void ConstructL(const TUint16 aMethodCode,const TMTPTypeGuid& aMethodGUID,const TDesC& aMethodName,const TUint16 aMethodAssociateFormate);
+    MMTPType* NewFlatChunkL(const TElementInfo& aElementInfo);
+    
+private:
+    
+	/**
+    Data chunk identifiers.
+    */
+    enum TChunkIds
+    	{
+    	/**
+        The flat data chunk ID.
+        */
+        EIdFlat1Chunk,
+               
+        EIdServiceMethodNameChunk,
+        
+        EIdFlat2Chunk,
+        
+        /**
+        The number of data chunks.
+        */
+        EIdNumChunks
+    	};	
+    
+    
+    /**
+   	The dataset element metadata table content.
+    */
+    static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+       
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+       
+    /**
+    The flat data chunk comprising elements .
+    */
+    RMTPTypeCompoundFlatChunk                       iChunkFlat1;
+    
+    RMTPTypeCompoundFlatChunk                       iChunkFlat2;
+    
+    /**
+    The size in bytes of the first flat data chunk.
+    */
+    static const TUint                              KFlat1ChunkSize;
+    
+    /**
+    The size in bytes of the second flat data chunk.
+    */
+    static const TUint                              KFlat2ChunkSize;
+       
+    /**
+    The MTP string type data chunks (EStorageDescription, and EVolumeIdentifier).
+    */
+    CMTPTypeString*                                         iChunkString;       
+    
+	};
+
+#endif /*CMTPTYPESERVICEMETHOD_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypeservicemethodparamextnform.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,292 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//  
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+#ifndef CMTPTYPESERVICEMETHODPARAMEXTNFORM_H_
+#define CMTPTYPESERVICEMETHODPARAMEXTNFORM_H_
+
+
+#include <e32std.h>
+#include <mtp/rmtptype.h>
+#include <mtp/cmtptypecompoundbase.h>
+#include <mtp/cmtptypeobjectpropdesc.h>
+
+class CMTPTypeString;
+
+/** 
+Defines the MTP ObjectPropDesc Service Method Parameter Extension FORM . The form is a 
+component element of the ObjectPropDesc dataset.
+@see CMTPTypeObjectPropDesc
+@publishedPartner
+@released
+*/ 
+class CMTPTypeServiceMethodParamExtnForm : public CMTPTypeCompoundBase
+    {
+public:
+
+    /**
+    MTP ObjectPropDesc Service Object Property Extension FORM element dataset identifiers.
+    */
+    enum TMTPObjectPropDescElement
+        {
+        /**
+        Object Property PKeyNamespace.
+        */
+        EPKeyNamespace,
+        
+        /**
+        Object Property PKeyID
+        */
+        EPKeyID,
+        
+        /**
+        PropertyName
+        */
+        EPropertyName,
+        
+        /**
+         * Parameter Type
+         */
+        EParameterType,
+        
+        /**
+         * ParameterNumber
+         */
+        EParameterNumber,
+        
+        /**
+        Form Flag (read-only).
+        */
+        EFormFlag,
+        
+        /**
+        FORM element. This element depends EFormFlag and is absent if EFormFlag 
+        is ENone.
+        */
+        EForm,         
+
+        /**
+        The number of dataset elements.
+        */
+        ENumElements,
+        };
+    
+    enum TMTPServiceMethodParamType
+        {
+        /*
+         * if reserved
+         */
+        EResserved,
+        
+        /*
+         * if in
+         */
+        EIn,
+        /*
+         * if out
+         */
+        EOut,
+        /*
+         * if in/out
+         */
+        EInOut
+        };
+    
+public:
+    IMPORT_C static CMTPTypeServiceMethodParamExtnForm* NewL( const TUint aDataType );
+    IMPORT_C static CMTPTypeServiceMethodParamExtnForm* NewLC( const TUint aDataType );
+    IMPORT_C static CMTPTypeServiceMethodParamExtnForm* NewL( const TUint aDataType, const TMTPTypeGuid  aPKNamespace, const TUint aPKID, const TDesC& aName, const TUint8 aParamType, const TUint8 aParamNum, const TUint8 aFormFlag, const MMTPType* aForm);
+    IMPORT_C static CMTPTypeServiceMethodParamExtnForm* NewLC( const TUint aDataType, const TMTPTypeGuid  aPKNamespace, const TUint aPKID, const TDesC& aName, const TUint8 aParamType, const TUint8 aParamNum, const TUint8 aFormFlag, const MMTPType* aForm);
+    
+    IMPORT_C virtual ~CMTPTypeServiceMethodParamExtnForm();  
+     
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+    
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    
+    
+private:
+
+    CMTPTypeServiceMethodParamExtnForm( const TUint aDataType );
+    void ConstructL( const TMTPTypeGuid  aPKNamespace, const TUint aPKID, const TDesC& aName, const TUint8 aParamType, const TUint8 aParamNum, const TUint8 aFormFlag, const MMTPType* aForm );
+    
+    TBool HasFormField(TUint8 aFormFlag) const;
+    TInt UpdateWriteSequenceErr(TInt aErr);
+    TBool ReadableElementL(TInt aElementId) const;
+    TBool WriteableElementL(TInt aElementId) const;
+private:
+
+    /**
+    The write data stream states.
+    */
+    enum TWriteSequenceState
+      {
+      /**
+      Data stream is inactive.
+      */
+      EIdle,
+      
+      /**
+      Streaming the first flat data chunk.
+      */
+      EFlat1Chunk,
+      
+      /**
+      Streaming the EDefaultValue data chunk..
+      */
+      ENameChunk,
+      
+      /**
+      Streaming the second flat data chunk.
+      */
+      EFlat2Chunk,
+      
+      /**
+      Streaming the EForm data chunk.
+      */
+      EFormChunk   
+      };
+  
+    /**
+    Data chunk identifiers.
+    */
+    enum TChunkIds
+       {
+       /**
+       The first flat data chunk ID.
+       */
+       EIdFlat1Chunk,
+       
+       /**
+       The EPropertyName element data chunk ID.
+       */
+       EIdNameChunk,
+       
+       /**
+       The second flat data chunk ID.
+       */
+       EIdFlat2Chunk,
+       
+       /**
+       The EForm element data chunk ID.
+       */
+       EIdFormChunk,
+       
+       /**
+       The number of data chunks.
+       */
+       EIdNumChunks
+       };
+
+private:
+
+    /**
+    The data chunk count of ObjectPropDesc datasets with an EForm of other than 
+    ENone.
+    */
+    static const TUint                              KNumChunksWithForm;
+    
+    /**
+    The data chunk count of ObjectPropDesc datasets with an EForm of ENone.
+    */
+    static const TUint                              KNumChunksWithoutForm;
+
+    /*
+    The size in bytes of the first flat data chunk.
+    */
+    static const TUint                              KFlat1ChunkSize;
+    
+    /**
+    The size in bytes of the second flat data chunk.
+    */
+    static const TUint                              KFlat2ChunkSize;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+   
+    /**
+    The write data stream error state. 
+    */
+    TUint                                           iWriteSequenceErr;
+    
+    /**
+    The write data stream state variable. 
+    */
+    TUint                                           iWriteSequenceState;
+    
+    /**
+    The write data stream completion state. This will be set to EFlat2Chunk for 
+    ObjectPropDesc datasets with an EForm of ENone, otherwise this will be 
+    EFormChunk.
+    */
+    TUint                                           iWriteSequenceCompletionState;
+    
+    /**
+    The flat data chunk comprising elements EPKeyNamespace and EPKeyID.
+    */    
+    RMTPTypeCompoundFlatChunk                       iChunkFlat1;
+    
+    /**
+    The EPropertyName element data chunk.
+    */
+    CMTPTypeString*                                        iChunkName;
+    
+    /**
+    The flat data chunk comprising elements EFormFlag.
+    */
+    RMTPTypeCompoundFlatChunk                       iChunkFlat2;
+    
+    /**
+    The EForm element data chunk.
+    */
+    CMTPTypeObjectPropDesc::RMTPTypeObjectPropDescForm      iChunkForm;
+    
+    /**
+    The property's MTP data type identifier datacode.
+    */
+    TUint                                       iDataType;
+    
+    /**
+    The initialised flag indicating if construction is completeand that 
+    read-only elements can no longer be modified.
+    */
+    TBool                                           iInitialised;
+    };
+
+
+
+
+#endif /* CMTPTYPESERVICEMETHODPARAMEXTNFORM_H_ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypeserviceobjpropextnform.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,262 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//  
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+#ifndef CMTPTYPESERVICEOBJPROPEXTNFORM_H_
+#define CMTPTYPESERVICEOBJPROPEXTNFORM_H_
+
+
+#include <e32std.h>
+#include <mtp/rmtptype.h>
+#include <mtp/cmtptypecompoundbase.h>
+#include <mtp/cmtptypeobjectpropdesc.h>
+
+
+class CMTPTypeString;
+
+/** 
+Defines the MTP ObjectPropDesc Service Object Property Extension FORM dataset. The dataset is a 
+component element of the ObjectPropDesc dataset.
+@see CMTPTypeObjectPropDesc
+@publishedPartner
+@released
+*/ 
+class CMTPTypeServiceObjPropExtnForm : public CMTPTypeCompoundBase
+    {
+public:
+
+    /**
+    MTP ObjectPropDesc Service Object Property Extension FORM element dataset identifiers.
+    */
+    enum TMTPObjectPropDescElement
+        {
+        /**
+        Object Property PKeyNamespace.
+        */
+        EPKeyNamespace,
+        
+        /**
+        Object Property PKeyID
+        */
+        EPKeyID,
+        
+        /**
+        PropertyName
+        */
+        EPropertyName,
+        
+        /**
+        Form Flag .
+        */
+        EFormFlag,
+        
+        /**
+        FORM element. This element depends EFormFlag and is absent if EFormFlag 
+        is ENone.
+        */
+        EForm,         
+
+        /**
+        The number of dataset elements.
+        */
+        ENumElements,
+        };
+    
+public:
+    IMPORT_C static CMTPTypeServiceObjPropExtnForm* NewL( const TUint aDataType );
+    IMPORT_C static CMTPTypeServiceObjPropExtnForm* NewLC( const TUint aDataType );
+    IMPORT_C static CMTPTypeServiceObjPropExtnForm* NewL( const TUint aDataType, const TMTPTypeGuid  aPKNamespace, const TUint aPKID, const TDesC& aName, const TUint8 aFormFlag, const MMTPType* aForm);
+    IMPORT_C static CMTPTypeServiceObjPropExtnForm* NewLC( const TUint aDataType, const TMTPTypeGuid  aPKNamespace, const TUint aPKID, const TDesC& aName, const TUint8 aFormFlag, const MMTPType* aForm);
+    
+    IMPORT_C virtual ~CMTPTypeServiceObjPropExtnForm();  
+     
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+    
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    
+    
+private:
+
+    CMTPTypeServiceObjPropExtnForm( const TUint aDataType );
+
+    void ConstructL( const TMTPTypeGuid  aPKNamespace, const TUint aPKID, const TDesC& aName, const TUint8 aFormFlag, const MMTPType* aForm );
+    
+    TBool HasFormField(TUint8 aFormFlag) const;
+    TInt UpdateWriteSequenceErr(TInt aErr);
+    TBool ReadableElementL(TInt aElementId) const;
+    TBool WriteableElementL(TInt aElementId) const;
+private:
+
+    /**
+    The write data stream states.
+    */
+    enum TWriteSequenceState
+      {
+      /**
+      Data stream is inactive.
+      */
+      EIdle,
+      
+      /**
+      Streaming the first flat data chunk.
+      */
+      EFlat1Chunk,
+      
+      /**
+      Streaming the EDefaultValue data chunk..
+      */
+      ENameChunk,
+      
+      /**
+      Streaming the second flat data chunk.
+      */
+      EFlat2Chunk,
+      
+      /**
+      Streaming the EForm data chunk.
+      */
+      EFormChunk   
+      };
+  
+    /**
+    Data chunk identifiers.
+    */
+    enum TChunkIds
+       {
+       /**
+       The first flat data chunk ID.
+       */
+       EIdFlat1Chunk,
+       
+       /**
+       The EPropertyName element data chunk ID.
+       */
+       EIdNameChunk,
+       
+       /**
+       The second flat data chunk ID.
+       */
+       EIdFlat2Chunk,
+       
+       /**
+       The EForm element data chunk ID.
+       */
+       EIdFormChunk,
+       
+       /**
+       The number of data chunks.
+       */
+       EIdNumChunks
+       };
+
+private:
+
+    /**
+    The data chunk count of ObjectPropDesc datasets with an EForm of other than 
+    ENone.
+    */
+    static const TUint                              KNumChunksWithForm;
+    
+    /**
+    The data chunk count of ObjectPropDesc datasets with an EForm of ENone.
+    */
+    static const TUint                              KNumChunksWithoutForm;
+
+    /*
+    The size in bytes of the first flat data chunk.
+    */
+    static const TUint                              KFlat1ChunkSize;
+    
+    /**
+    The size in bytes of the second flat data chunk.
+    */
+    static const TUint                              KFlat2ChunkSize;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+   
+    /**
+    The write data stream error state. 
+    */
+    TUint                                           iWriteSequenceErr;
+    
+    /**
+    The write data stream state variable. 
+    */
+    TUint                                           iWriteSequenceState;
+    
+    /**
+    The write data stream completion state. This will be set to EFlat2Chunk for 
+    ObjectPropDesc datasets with an EForm of ENone, otherwise this will be 
+    EFormChunk.
+    */
+    TUint                                           iWriteSequenceCompletionState;
+    
+    /**
+    The flat data chunk comprising elements EPKeyNamespace and EPKeyID.
+    */    
+    RMTPTypeCompoundFlatChunk                       iChunkFlat1;
+    
+    /**
+    The EPropertyName element data chunk.
+    */
+    CMTPTypeString*                                        iChunkName;
+    
+    /**
+    The flat data chunk comprising elements EFormFlag.
+    */
+    RMTPTypeCompoundFlatChunk                       iChunkFlat2;
+    
+    /**
+    The EForm element data chunk.
+    */
+    CMTPTypeObjectPropDesc::RMTPTypeObjectPropDescForm      iChunkForm;
+    
+    /**
+    The property's MTP data type identifier datacode.
+    */
+    TUint                                       iDataType;
+    
+    /**
+    The initialised flag indicating if construction is completeand that 
+    read-only elements can no longer be modified.
+    */
+    TBool                                           iInitialised;
+    };
+
+
+
+#endif /* CMTPTYPESERVICEOBJPROPEXTNFORM_H_ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypeserviceprop.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,135 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// 
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+
+#ifndef CMTPTYPESERVICEPROP_H_
+#define CMTPTYPESERVICEPROP_H_
+
+#include <e32std.h>
+#include <mtp/cmtptypecompoundbase.h>
+#include <mtp/cmtptypelist.h>
+#include <mtp/cmtptypeserviceproplist.h>
+
+class CMTPTypeString;
+class CMTPTypeServicePropertyElement;
+
+class CMTPTypeServicePropertyList : public CMTPTypeList
+	{
+public:
+    
+	IMPORT_C static CMTPTypeServicePropertyList* NewL();
+    IMPORT_C static CMTPTypeServicePropertyList* NewLC();
+
+    IMPORT_C virtual ~CMTPTypeServicePropertyList();  
+    
+    IMPORT_C void AppendL(CMTPTypeServicePropertyElement* aElement);
+    
+    IMPORT_C CMTPTypeServicePropertyElement& ElementL(TUint aIndex) const; 
+     
+private:
+
+	CMTPTypeServicePropertyList();
+    void ConstructL();
+
+	};
+
+class CMTPTypeServicePropertyElement : public CMTPTypeCompoundBase
+	{
+public:
+	
+	enum TMTPServicePropertyElement
+		{
+		EPropertyCode,
+		ENameSpace,
+		EPkeyID,
+		EPorpertyName,
+		ENumElements
+		};
+	
+public:
+    
+	IMPORT_C static CMTPTypeServicePropertyElement* NewL();
+	IMPORT_C static CMTPTypeServicePropertyElement* NewLC();
+    IMPORT_C static CMTPTypeServicePropertyElement* NewL(const TUint16 aPropertyCode, const TMTPTypeGuid& aNameSpace,const TUint32 aPKeyID, const TDesC& aPropertyName);
+    IMPORT_C static CMTPTypeServicePropertyElement* NewLC(const TUint16 aPropertyCode, const TMTPTypeGuid& aNameSpace,const TUint32 aPKeyID, const TDesC& aPropertyName);
+    
+	IMPORT_C virtual ~CMTPTypeServicePropertyElement();   
+     
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C TUint Type() const;
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+
+private:
+
+	CMTPTypeServicePropertyElement();
+    void ConstructL();
+    
+    void ConstructL(const TUint16 aPropertyCode, const TMTPTypeGuid& aNameSpace,const TUint32 aPKeyID, const TDesC& aPropertyName);
+    MMTPType* NewFlatChunkL();
+    
+private:
+
+  
+	/**
+    Data chunk identifiers.
+    */
+    enum TChunkIds
+    	{
+    	/**
+        The flat data chunk ID.
+        */
+        EIdFlatChunk,
+               
+        
+        EIdServicePropNameChunk,
+        /**
+        The number of data chunks.
+        */
+        EIdNumChunks
+    	};
+    
+    
+    /**
+   	The dataset element metadata table content.
+    */
+    static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+       
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+       
+    /**
+    The flat data chunk comprising elements EStorageType to EFreeSpaceInObjects.
+    */
+    RMTPTypeCompoundFlatChunk                       iChunkFlat;
+       
+    /**
+    The MTP string type data chunks (EStorageDescription, and EVolumeIdentifier).
+    */
+    CMTPTypeString*                                          iChunkString;    
+	};
+
+#endif /*CMTPTYPESERVICEPROP_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypeservicepropdesclist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,244 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+#ifndef CMTPTYPESERVICEPROPDESCLIST_H_
+
+#define CMTPTYPESERVICEPROPDESCLIST_H_
+
+
+
+#include <e32std.h>
+#include <mtp/rmtptype.h>
+#include <mtp/cmtptypecompoundbase.h>
+#include <mtp/cmtptypeobjectpropdesc.h>
+#include <mtp/cmtptypelist.h>
+
+class CMTPTypeServicePropDesc;
+
+/** 
+Defines the MTP Service Property Description list dataset. 
+@see CMTPTypeObjectPropDesc
+@publishedPartner
+@released
+*/ 
+class CMTPTypeServicePropDescList : public CMTPTypeList
+    {
+public:
+    
+    IMPORT_C static CMTPTypeServicePropDescList* NewL();
+    IMPORT_C static CMTPTypeServicePropDescList* NewLC();
+
+    IMPORT_C virtual ~CMTPTypeServicePropDescList();  
+    IMPORT_C void AppendL(CMTPTypeServicePropDesc* aServicePropDesc);
+    IMPORT_C CMTPTypeServicePropDesc& ElementL(TUint aIndex) const; 
+    
+private:
+    CMTPTypeServicePropDescList();
+    void ConstructL();   
+
+    };
+
+
+/** 
+Defines the MTP Service Property Description dataset. The dataset is a 
+component element of the CMTPTypeServicePropDescList.
+@see CMTPTypeObjectPropDesc
+@publishedPartner
+@released
+*/ 
+class CMTPTypeServicePropDesc : public CMTPTypeCompoundBase
+    {
+public:
+
+    /**
+    MTP ObjectPropDesc Service Property Description dataset element  identifiers.
+    */
+    enum TMTPObjectPropDescElement
+        {
+        /**
+        Service Property code.
+        */
+        EServicePropertyCode,
+        
+        /**
+        Data-type code
+        */
+        EDataType1,
+        
+        /**
+        Get/Set.
+        */
+        EGetSet1,
+        
+        /**
+        Form Flag .
+        */
+        EFormFlag,
+        
+        /**
+        FORM element. This element depends EFormFlag and is absent if EFormFlag 
+        is ENone.
+        */
+        EForm,         
+
+        /**
+        The number of dataset elements.
+        */
+        ENumElements,
+        };
+    
+    /**
+    MTP ServicePropDesc dataset Get/Set element values.
+    */
+    enum TMTPServicePropDescGetSet
+        {
+
+        /** 
+        Get.
+        */
+        EReadOnly       = 0x00,
+
+        /** 
+        Get/Set.
+        */
+        EReadWrite      = 0x01
+        };
+    
+public:
+    IMPORT_C static CMTPTypeServicePropDesc* NewL();
+    IMPORT_C static CMTPTypeServicePropDesc* NewLC();
+    IMPORT_C static CMTPTypeServicePropDesc* NewL( const TUint16  aServicePropCode, const TUint16 aDataType, const TUint8 aGetSet, const TUint8 aFormFlag, const MMTPType* aForm );
+    IMPORT_C static CMTPTypeServicePropDesc* NewLC( const TUint16  aServicePropCode, const TUint16 aDataType, const TUint8 aGetSet, const TUint8 aFormFlag, const MMTPType* aForm);
+    
+    IMPORT_C virtual ~CMTPTypeServicePropDesc();  
+     
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+    
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    
+    
+private:
+
+    CMTPTypeServicePropDesc();
+    void ConstructL( const TUint16  aServicePropCode, const TUint16 aDataType, const TUint8 aGetSet, const TUint8 aFormFlag, const MMTPType* aForm );
+    
+    TBool HasFormField(TUint8 aFormFlag) const;
+
+private:
+
+/**
+The write data stream states.
+*/
+enum TReadWriteSequenceState
+    {
+    
+    /**
+    Data stream is inactive.
+    */
+    EIdle,
+    
+    /**
+    Streaming the EForm data chunk.
+    */
+    EFormChunk           
+    };
+  
+    /**
+    Data chunk identifiers.
+    */
+    enum TChunkIds
+       {
+       /**
+       The first flat data chunk ID.
+       */
+       EIdFlat1Chunk,
+       
+       /**
+       The EForm element data chunk ID.
+       */
+       EIdFormChunk,
+       
+       /**
+       The number of data chunks.
+       */
+       EIdNumChunks
+       };
+
+private:
+
+    /**
+    The data chunk count of ObjectPropDesc datasets with an EForm of other than 
+    ENone.
+    */
+    static const TUint                              KNumChunksWithForm;
+    
+    /**
+    The data chunk count of ObjectPropDesc datasets with an EForm of ENone.
+    */
+    static const TUint                              KNumChunksWithoutForm;
+
+    /*
+    The size in bytes of the first flat data chunk.
+    */
+    static const TUint                              KFlat1ChunkSize;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The write data stream completion state. This will be set to EFlat2Chunk for 
+    ObjectPropDesc datasets with an EForm of ENone, otherwise this will be 
+    EFormChunk.
+    */
+    TUint                                           iWriteSequenceCompletionState;
+    TUint 											iWriteSequenceState;
+    
+    
+    /**
+    The flat data chunk comprising elements EPKeyNamespace and EPKeyID.
+    */    
+    RMTPTypeCompoundFlatChunk                       iChunkFlat1;
+    
+    /**
+    The EForm element data chunk.
+    */
+    CMTPTypeObjectPropDesc::RMTPTypeObjectPropDescForm      iChunkForm;
+    };
+
+
+
+
+#endif /* CMTPTYPESERVICEPROPDESCLIST_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypeserviceproplist.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,311 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef CMTPTYPESERVICEPROPLIST_H_
+#define CMTPTYPESERVICEPROPLIST_H_
+
+#include <e32std.h>
+#include <mtp/rmtptype.h>
+#include <mtp/cmtptypecompoundbase.h>
+
+class CMTPTypeServicePropListElement;
+
+/** 
+Defines the MTP ObjectPropList dataset. The ObjectPropList dataset provides
+optimised access to object properties without needing to individually query 
+each object/property pair. It also provides a more flexible querying mechanism 
+for object properties in general. This dataset is used in the 
+GetObjectPropList, SetObjectPropList, and SendObjectPropList requests.
+@publishedPartner
+@released 
+*/ 
+class CMTPTypeServicePropList : public CMTPTypeCompoundBase
+    {
+public:
+    
+    IMPORT_C static CMTPTypeServicePropList* NewL();
+    IMPORT_C static CMTPTypeServicePropList* NewLC();
+
+    IMPORT_C virtual ~CMTPTypeServicePropList();  
+    
+    IMPORT_C void AppendL(CMTPTypeServicePropListElement* aElement);
+    IMPORT_C void AppendDataObjectL(MMTPType& aDataObject);
+    
+    IMPORT_C TUint32 NumberOfElements() const;
+    IMPORT_C CMTPTypeServicePropListElement& Element(TUint aIndex) const; 
+    IMPORT_C MMTPType& DataObjectL() const;
+     
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk); 
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    TInt ValidateChunkCount() const;
+    
+private:
+
+    CMTPTypeServicePropList();
+    void ConstructL();
+    
+    void AppendElementChunkL(CMTPTypeServicePropListElement* aElement);
+    TInt UpdateWriteSequenceErr(TInt aErr);
+
+private: // Owned
+
+    /**
+    The write data stream states.
+    */
+    enum TReadWriteSequenceState
+        {
+        /**
+        Data stream is inactive.
+        */
+        EIdle,
+        
+        /**
+        Elements data stream is in progress.
+        */
+        EElementChunks,
+        
+        /**
+        Optional object data stream is in progress.
+        */
+        EDataObjectChunk            
+        };
+
+    /**
+    The write data stream error state. 
+    */
+    TUint                                           iWriteSequenceErr;
+
+    /**
+    The write data stream state variable. 
+    */
+    TUint                                           iWriteSequenceState;
+    
+    /**
+    The NumberOfElements element metadata content.
+    */
+    CMTPTypeCompoundBase::TElementInfo              iInfoNumberOfElements;
+    
+    /**
+    The Element array metadata content. Note that this is declared mutable 
+    to allow state updates while processing a read data stream.
+    */
+    mutable CMTPTypeCompoundBase::TElementInfo      iInfoElement;
+    
+    /**
+    The NumberOfElements element data chunk ID.
+    */
+    static const TUint                              KNumberOfElementsChunk;
+    
+    /**
+    The Element array starting data chuck ID.
+    */
+    static const TUint                              KElementChunks;
+    
+    /**
+    The NumberOfElements element data chunk.
+    */
+    TMTPTypeUint32                                  iChunkNumberOfElements;
+    
+    /**
+    The Element array data chunks.
+    */
+    RPointerArray<CMTPTypeServicePropListElement>    iChunksElement;
+    
+private: // Not owned
+    
+    /**
+    The (optional) MTP data object chunk.
+    */
+    MMTPType*                                       iChunkDataObject;
+    };
+
+/**
+Defines the MTP ObjectPropList element dataset. The ObjectPropList element 
+dataset describes an object property with a meta data triplet and a value. It
+is a  component element of the ObjectPropList dataset.
+*/
+class CMTPTypeServicePropListElement : public CMTPTypeCompoundBase
+    {
+
+public:
+
+    /**
+    MTP ObjectPropList property quadruple dataset element identifiers.
+    */
+    enum TMTPObjectPropListElement
+        {
+        /**
+        The ObjectHandle of the object to which the property applies.
+        */
+        EObjectHandle,
+        
+        /**
+        The ObjectPropDesc property identifier datacode (read-only).
+        */
+        EPropertyCode,
+        
+        /**
+        The datatype code of the property (read-only).
+        */
+        EDatatype,
+        
+        /**
+        The value of the property.
+        */
+        EValue,
+
+        /**
+        The number of dataset elements.
+        */
+        ENumElements,
+        };
+
+public:
+    
+    IMPORT_C static CMTPTypeServicePropListElement* NewL(TUint16 aPropertyCode);
+    IMPORT_C static CMTPTypeServicePropListElement* NewLC(TUint16 aPropertyCode);
+    
+    IMPORT_C static CMTPTypeServicePropListElement* NewL(TUint32 aObjectHandle, TUint16 aPropertyCode, const MMTPType& aValue);
+    IMPORT_C static CMTPTypeServicePropListElement* NewLC(TUint32 aObjectHandle, TUint16 aPropertyCode, const MMTPType& aValue);
+
+    IMPORT_C static CMTPTypeServicePropListElement* NewL(TUint16 aPropertyCode, TUint16 aDataType);
+    IMPORT_C static CMTPTypeServicePropListElement* NewLC(TUint16 aPropertyCode, TUint16 aDataType);
+    
+    IMPORT_C static CMTPTypeServicePropListElement* NewL(TUint32 aObjectHandle, TUint16 aPropertyCode, TUint16 aDataType, const MMTPType& aValue);
+    IMPORT_C static CMTPTypeServicePropListElement* NewLC(TUint32 aObjectHandle, TUint16 aPropertyCode, TUint16 aDataType, const MMTPType& aValue);
+    
+    IMPORT_C virtual ~CMTPTypeServicePropListElement(); 
+     
+public: // From CMTPTypeCompoundBase
+
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk); 
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    TBool WriteableElementL(TInt aElementId) const;
+    
+private:
+
+    friend MMTPType* CMTPTypeServicePropList::CommitChunkL(TPtr8& aChunk);
+    static CMTPTypeServicePropListElement* NewLC();
+
+    CMTPTypeServicePropListElement();
+    void ConstructL();
+    void ConstructL(TUint16 aPropertyCode, TUint16 aDataType, const TUint32* aObjectHandle, const MMTPType* aValue);
+
+    void DestroyChunks();
+
+private: // Owned
+
+    /**
+    The write data stream states.
+    */
+    enum TWriteSequenceState
+        {
+        /**
+        Data stream is inactive.
+        */
+        EIdle,
+        
+        /**
+        Streaming the property descriptor triplet dataset data chunk.
+        */
+        EFlatChunk,
+        
+        /**
+        Streaming the property value data chunk.
+        */
+        EValueChunk 
+        };
+        
+    /**
+    Data chunk identifiers.
+    */
+    enum TChunkIds
+        {
+        /**
+        The flat data chunk ID.
+        */
+        EIdFlatChunk,
+        
+        /**
+        The EValue element data chunk ID.
+        */
+        EIdValueChunk,
+        
+        /**
+        The number of data chunks.
+        */
+        EIdNumChunks
+        };
+
+    /**
+    The write data stream state variable. 
+    */
+    TUint                                           iWriteSequenceState;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const TElementInfo                       iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+
+    /**
+    The initialised flag indicating if construction is complete and that 
+    read-only elements can no longer be modified.
+    */
+    TBool                                           iInitialised;
+    
+    /**
+    The property meta data triplet flat data chunk size in bytes.
+    */
+    static const TUint                              KFlatChunkSize;
+    
+    /**
+    The property meta data flat data chunk, comprising elements EObjectHandle 
+    to EDatatype.
+    */
+    RMTPTypeCompoundFlatChunk                       iChunkFlat;
+    
+    /**
+    The EValue data chunk.
+    */
+    RMTPType                                        iChunkValue;
+    };
+
+#endif // CMTPTYPESERVICEPROPLIST_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypestorageinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,171 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPTYPESTORAGEINFO_H
+#define CMTPTYPESTORAGEINFO_H
+
+#include <e32std.h>
+#include <mtp/cmtptypecompoundbase.h>
+
+class CMTPTypeString;
+
+/** 
+Defines the MTP StorageInfo dataset. The StorageInfo dataset provides a 
+description of the MTP device and is generated in response to a GetStorageInfo
+operation request.
+@internalComponent 
+*/ 
+class CMTPTypeStorageInfo : public CMTPTypeCompoundBase
+    {
+public:    
+
+    /**
+    MTP StotageInfo dataset element identifiers.
+    */
+     enum TMTPStorageInfoElement
+        {
+        /**
+        The physical nature of the storage described by the dataset.
+        */ 
+        EStorageType,
+        
+        /**
+        The logical file system in use on the storage.
+        */ 
+        EFileSystemType,
+        
+        /**
+        The global write-protection status of the storage.
+        */
+        EAccessCapability,
+        
+        /**
+        The maximum capacity of the storage in bytes.
+        */
+        EMaxCapacity,
+        
+        /**
+        The available capacity of the storage in objects.
+         */
+        EFreeSpaceInBytes,
+        
+        /**
+        The available capacity of the storage in objects. This field is only 
+        used if there is a reasonable expectation that the number of objects 
+        that remain to be written can be accurately predicted.
+        */
+        EFreeSpaceInObjects,
+        
+        /**
+        The human-readable string identifying the storage.
+        */
+        EStorageDescription,
+        
+        /**
+        The unique volume identifier of the storage, e.g. serial number.
+        */
+        EVolumeIdentifier,
+        
+        /**
+        The number of dataset elements.
+        */
+        ENumElements
+        };  
+
+public:  
+    
+    IMPORT_C static CMTPTypeStorageInfo* NewL();
+    IMPORT_C static CMTPTypeStorageInfo* NewLC();
+    
+    IMPORT_C virtual ~CMTPTypeStorageInfo();  
+     
+public: // From MMTPType
+
+    IMPORT_C TUint Type() const;
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const; 
+    
+private:
+
+    CMTPTypeStorageInfo();        
+    void ConstructL(); 
+    
+    MMTPType* NewFlatChunkL(const TElementInfo& aElementInfo);
+    MMTPType* NewStringChunkL(const TElementInfo& aElementInfo);
+        
+private:
+        
+    /**
+    Data chunk identifiers.
+    */
+    enum TChunkIds
+        {
+        /**
+        The flat data chunk ID.
+        */
+        EIdFlatChunk,
+        
+        /**
+        The EStorageDescription element data chunk ID.
+        */
+        EIdStorageDescriptionChunk,
+        
+        /**
+        The EVolumeIdentifier element data chunk ID.
+        */
+        EIdVolumeIdentifierChunk,
+        
+        /**
+        The number of data chunks.
+        */
+        EIdNumChunks
+        };
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The size in bytes of the flat data chunk.
+    */
+    static const TUint                              KFlatChunkSize;
+    
+    /**
+    The flat data chunk comprising elements EStorageType to EFreeSpaceInObjects.
+    */
+    RMTPTypeCompoundFlatChunk                       iChunkFlat;
+    
+    /**
+    The MTP string type data chunks (EStorageDescription, and 
+    EVolumeIdentifier).
+    */
+    RPointerArray<CMTPTypeString>                   iStringChunks;
+    };
+    
+#endif // CMTPTYPESTORAGEINFO_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypestring.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,119 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef CMTPTYPESTRING_H
+#define CMTPTYPESTRING_H
+
+#include <e32base.h>
+#include <mtp/mmtptype.h>
+
+/**
+Defines the MTP string data type. MTP strings consist of standard 2-byte 
+Unicode characters and are null-terminated. Strings are prepended with a 
+single 8-bit unsigned integer that identifies the number of characters (NOT 
+bytes) to follow and includes the terminating null value. Strings are limited
+to 255 characters (including the null value). An empty string would consist
+of a single 8-bit integer containing the value 0x00. 
+
+MTP strings are stored in a flat buffer to optimise streaming performance 
+to/from the MTP transport connection.
+@publishedPartner
+@released 
+*/
+class CMTPTypeString : public CBase, public MMTPType
+    {
+public:
+    
+    IMPORT_C static CMTPTypeString* NewL();
+    IMPORT_C static CMTPTypeString* NewL(const TDesC& aString);
+    IMPORT_C static CMTPTypeString* NewLC();
+    IMPORT_C static CMTPTypeString* NewLC(const TDesC& aString);
+    IMPORT_C ~CMTPTypeString();
+    
+    IMPORT_C TUint8 NumChars() const;
+    IMPORT_C const TDesC& StringChars() const;  
+
+    IMPORT_C void SetL(const TDesC& aString);
+
+public: // From MMTPType
+
+    IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt NextReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint64 Size() const;
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+    IMPORT_C TInt Validate() const;
+    
+private:
+
+    CMTPTypeString();
+    void ConstructL(const TDesC& aString);
+    
+    void ReAllocBufferL(TUint aNumNullTerminatedChars);
+    
+private: // Owned
+
+    /**
+    The write data stream states.
+    */
+    enum TWriteSequenceState
+        {
+        /**
+        Write data stream inactive.
+        */
+        EIdle,
+        
+        /**
+        Streaming the NumChars data chunk.
+        */
+        ENumChars,
+        
+        /**
+        Streaming the String Characters data chunk.
+        */
+        EStringChars            
+        };
+
+    /**
+    The data buffer.
+    */
+    RBuf8   iBuffer;
+    
+    /**
+    The String Characters data pointer.
+    */
+    TPtr    iStringChars;
+    
+    /**
+    The write data stream state variable.
+    */
+    TUint   iWriteSequenceState;
+    
+    /**
+    The String type's validation state.
+    */
+    TInt    iValidationState;
+    };
+
+#endif // CMTPTYPESTRING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypetrivialdata.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,54 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+#ifndef CMTPTYPETRIVIALDATA_H_
+#define CMTPTYPETRIVIALDATA_H_
+
+#include <e32base.h>
+#include <mtp/mmtptype.h>
+
+class CMTPTypeTrivialData : public CBase, public MMTPType
+    {
+public:
+    IMPORT_C static CMTPTypeTrivialData* NewL();
+    IMPORT_C static CMTPTypeTrivialData* NewLC();
+    IMPORT_C ~CMTPTypeTrivialData();
+    
+public: //MMTPType
+    IMPORT_C virtual TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C virtual TInt NextReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C virtual TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C virtual TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C virtual TInt FirstWriteChunk(TPtr8& aChunk, TUint aDataLength);
+    IMPORT_C virtual TInt NextWriteChunk(TPtr8& aChunk, TUint aDataLength);
+    
+    IMPORT_C virtual TUint64 Size() const;
+    IMPORT_C virtual TUint Type() const;
+    
+private:
+    void ConstructL();
+    CMTPTypeTrivialData();
+    
+private:
+    RBuf8    iBuffer;
+    };
+
+
+#endif /* CMTPTYPETRIVIALDATA_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/mmtptype.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,234 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef MMTPTYPE_H
+#define MMTPTYPE_H
+
+#include <e32std.h>
+
+/**
+Defines the generic MTP data type interface. All non-opaque MTP data comprises
+either a single atomic value of a simple type, or a set of atomic simple type
+values organised according to some dataset structure. Structured datasets may 
+take one of the following general forms:
+    
+    1. Flat - a contiguous collection of values. 
+    2. Complex - a contiguous array or string of values.
+    3. Compound - a mixed sequence of simple, flat, and complex types.
+    
+Any time data is passed as a parameter to an MTP operation, response or event; 
+or any time data is passed in the data phase of a fully described operation, 
+that data must be of a type that implements the generic MTP data type 
+interface.
+@publishedPartner
+@released 
+*/
+class MMTPType
+    {
+    
+public:
+
+    /**
+    Initiates a data read sequence on the type by providing a const pointer 
+    to the first in the sequence of data chunks that make up the type's data 
+    stream. Subsequent chunks in the sequence can be sequentially retrieved 
+    using NextReadChunk.
+    @param aChunk The const pointer to be set to point to the start of the 
+    first data chunk. This pointer's length is set to zero if no data chunk
+    exists or a processing error occurs.
+    @return KErrNone, if successful and the read sequence IS NOT complete, i.e.
+    there are one or more additional data chunks available in the read 
+    sequence.
+    @return KMTPChunkSequenceCompletion, if successful and the read sequence 
+    IS complete, i.e. there are no more additional data chunks available in 
+    the read sequence.
+    @return KErrNotFound, if no data chunk is found.
+    @return One of the system wide error codes, if a general processing 
+    error occurs.
+    @see NextReadChunk.
+    */
+    virtual TInt FirstReadChunk(TPtrC8& aChunk) const = 0;
+
+    /**
+    Continues a data read sequence on the type by providing a const pointer 
+    to the next in the sequence of data chunks that make up the type's data 
+    stream. This data read sequence should have been previously initiated by 
+    invoking FirstReadChunk.
+    @param aChunk The const pointer to be set to point to the start of the 
+    next data chunk. This pointer's length is set to zero if no data chunk
+    exists or a processing error occurs.
+    @return KErrNone, if successful and the read sequence IS NOT complete, i.e.
+    there are one or more additional data chunks available in the read 
+    sequence.
+    @return KMTPChunkSequenceCompletion, if successful and the read sequence 
+    IS complete, i.e. there are no more additional data chunks available in the 
+    read sequence.
+    @return KErrNotReady, if there is no data read sequence in progress, i.e.
+    a read sequence was not previously initiated by invoking FirstReadChunk.
+    @return One of the system wide error codes, if a general processing 
+    error occurs.
+    @see FirstReadChunk.
+    */
+    virtual TInt NextReadChunk(TPtrC8& aChunk) const = 0;
+
+    /**
+    Initiates a data write sequence on the type by providing a non-const 
+    pointer to the first in the sequence of data chunks that make up the type's 
+    data stream. Subsequent chunks in the sequence can be sequentially 
+    retrieved using NextWriteChunk.
+    @param aChunk The non-const pointer to be set to point to the start of the 
+    first data chunk. If successful, the pointer's Length is set to zero, and 
+    MaxLength is set to the available capacity of the data chunk. If not 
+    successful, the pointer's MaxLength is set to zero.
+    @return KErrNone, if successful and the write sequence IS NOT complete, 
+    i.e. there are one or more additional data chunks available in the write 
+    sequence.
+    @return KMTPChunkSequenceCompletion, if successful and the write sequence 
+    IS complete, i.e. there are no more additional data chunks available in the 
+    write sequence.
+    @return KErrNotFound, if no data chunk is found.
+    @return One of the system wide error codes, if a general processing 
+    error occurs.
+    @see NextWriteChunk.
+    */
+    virtual TInt FirstWriteChunk(TPtr8& aChunk) = 0;
+
+    /**
+    Continues a data write sequence on the type by providing a non-const 
+    pointer to the next in the sequence of data chunks that make up the type's 
+    data stream. This data write sequence should have been previously initiated 
+    by invoking FirstWriteChunk.
+    @param aChunk The non-const pointer to be set to point to the start of the 
+    next data chunk. If successful, the pointer's Length is set to zero, and 
+    MaxLength is set to the available capacity of the data chunk. If not 
+    successful, the pointer's MaxLength is set to zero..
+    @return KErrNone, if successful and the write sequence IS NOT complete, i.e.
+    there are one or more additional data chunks available in the write 
+    sequence.
+    @return KMTPChunkSequenceCompletion, if successful and the write sequence 
+    IS complete, i.e. there are no more additional data chunks available in the 
+    write sequence.
+    @return KErrNotReady, if there is no data write sequence in progress, i.e.
+    a write sequence was not previously initiated by invoking FirstWriteChunk.
+    @return One of the system wide error codes, if a general processing 
+    error occurs.
+    @see FirstReadChunk.
+    */
+    virtual TInt NextWriteChunk(TPtr8& aChunk) = 0;
+    
+    /**
+    Provides the size in bytes of the MTP data type.
+    @return The types size in bytes.
+    */
+    virtual TUint64 Size() const = 0;
+        
+    /**
+    Provides the MTP data type identification datacode.
+    @return The MTP data type identification datacode.
+    */
+    virtual TUint Type() const = 0;
+    
+    /**
+    Commits the specified write data chunk. This method should only be invoked 
+    if the type indicates that committing data is required 
+    (@see CommitRequired). Generally this would only be required by types which 
+    are performing intermediate buffering, e.g. a file data object.
+    @param aChunk The data chunk to be commited.
+    @leave KErrNotSupported, if the type does not support data commit.
+    @leave KMTPDataTypeInvalid, if the data type is structurally invalid.
+    @leave One of the system wide error codes, if a general processing error 
+    occurs.
+    @see CommitRequired
+    */
+    IMPORT_C virtual MMTPType* CommitChunkL(TPtr8& aChunk);
+    
+    /**
+    Indicates if the data type requires that data be committed during data
+    write sequences. Generally this would only be required by types which 
+    perform intermediate buffering (e.g. a file data object), or by data 
+    types whose final structure is determined by the value of meta data 
+    elements within the data stream itself (e.g an MTP ObjectPropDesc dataset).
+    @return ETrue if CommitChunkL should be called after each invocation of 
+    ChunkWritePtr, otherwise EFalse.
+    @see CommitChunkL
+    @see ChunkWritePtr
+    */
+    IMPORT_C virtual TBool CommitRequired() const;
+    
+    /**
+    Validates the structural integrity of the data type. This method can be
+    invoked on completion of a data write sequence to validate that the 
+    received data represents a structurally valid instance of the data type.
+    @return KErrNone if the data type is structurally valid, otherwise 
+    KMTPDataTypeInvalid.
+    */
+    IMPORT_C virtual TInt Validate() const;
+
+    /**
+    Copies the data from one MTP data type object to another. This is 
+    accomplished by attaching read and write data streams from the source 
+    object to the sink object. The source and sink objects are not 
+    required to be of the same type and no type compatibility checking is 
+    performed.
+    @param aFrom The MTP source data type object.
+    @param aTo The MTP source data type object.
+    @leave One of the system wide error codes, if a general processing error 
+    occurs.
+    */
+	IMPORT_C static void CopyL(const MMTPType& aFrom, MMTPType& aTo);
+    
+    /**
+    Provides an MTP data type extension interface implementation 
+    for the specified interface Uid. 
+    @param aInterfaceUid The unique identifier for the extension interface being 
+    requested.
+    @return Pointer to an interface instance or 0 if the interface is not 
+    supported. Ownership is NOT transfered.
+    */
+    IMPORT_C virtual TAny* GetExtendedInterface(TUid aInterfaceUid);
+
+    IMPORT_C virtual TInt FirstWriteChunk(TPtr8& aChunk, TUint aDataLength);
+    
+    IMPORT_C virtual TInt NextWriteChunk(TPtr8& aChunk, TUint aDataLength);
+    
+    IMPORT_C virtual TBool ReserveTransportHeader(TUint aHeaderLength, TPtr8& aHeader);
+    };
+    
+/**
+MTP completion code +17 : Indicates that a data type read or write data 
+sequence has successfully completed. This code does not indicate an error 
+condition.
+@see FirstReadChunk.
+@see NextReadChunk.
+@see FirstWriteChunk.
+@see NextWriteChunk.
+*/
+const TInt KMTPChunkSequenceCompletion = (+17);
+    
+/**
+MTP completion code -20 : Indicates that a data type is structurally invalid.
+@see CommitChunkL
+@see Validate.
+*/
+const TInt KMTPDataTypeInvalid = (-20);
+    
+#endif // MMTPTYPE_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/mtpdatatypeconstants.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,239 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef MTPDATATYPECONSTANTS_H
+#define MTPDATATYPECONSTANTS_H
+
+#include <e32def.h>
+
+/**
+The MTP datatype codes.
+@publishedPartner
+@released  
+*/
+enum TMTPTypeIds
+    {
+    EMTPFirstLibraryDataType                        = 0x00000000,
+    
+    EMTPTypeUndefined                               = EMTPFirstLibraryDataType,
+    
+    EMTPTypeFirstSimpleType                         = 0x00000001,
+    EMTPTypeINT8                                    = EMTPTypeFirstSimpleType,
+    EMTPTypeUINT8                                   = 0x00000002,
+    EMTPTypeINT16                                   = 0x00000003,
+    EMTPTypeUINT16                                  = 0x00000004,
+    EMTPTypeINT32                                   = 0x00000005,
+    EMTPTypeUINT32                                  = 0x00000006,
+    EMTPTypeINT64                                   = 0x00000007,
+    EMTPTypeUINT64                                  = 0x00000008,
+    EMTPTypeINT128                                  = 0x00000009,
+    EMTPTypeUINT128                                 = 0x0000000A,
+    EMTPTypeLastSimpleType                          = EMTPTypeUINT128,
+    
+    EMTPTypeFirstSimpleArrayType                    = 0x00004001,
+    EMTPTypeAINT8                                   = EMTPTypeFirstSimpleArrayType,
+    EMTPTypeAUINT8                                  = 0x00004002,
+    EMTPTypeAINT16                                  = 0x00004003,
+    EMTPTypeAUINT16                                 = 0x00004004,
+    EMTPTypeAINT32                                  = 0x00004005,
+    EMTPTypeAUINT32                                 = 0x00004006,
+    EMTPTypeAINT64                                  = 0x00004007,
+    EMTPTypeAUINT64                                 = 0x00004008,
+    EMTPTypeAINT128                                 = 0x00004009,
+    EMTPTypeAUINT128                                = 0x0000400A,
+    EMTPTypeLastSimpleArrayType                     = EMTPTypeAUINT128,
+    
+    EMTPTypeFirstComplexType                        = 0x0000FFFF,
+    EMTPTypeString                                  = EMTPTypeFirstComplexType,
+    EMTPTypeArray                                   = 0x00010001,
+    EMTPTypeFile                                    = 0x00010002,
+    EMTPTypeOpaqueData								= 0x00010003,
+    EMTPTypeTrivialData                             = 0x00010004,
+    EMTPTypeLastComplexType                         = EMTPTypeTrivialData,
+    
+    EMTPTypeFirstCompoundType                       = 0x00020000,
+    EMTPTypeCompound                                = EMTPTypeFirstCompoundType,
+    EMTPTypeDeviceInfoDataset                       = 0x00020100,
+    EMTPTypeDevicePropDescDataset                   = 0x00020200,
+    EMTPTypeDevicePropDescEnumerationFormDataset    = 0x00020201,
+    EMTPTypeDevicePropDescRangeFormDataset          = 0x00020202,
+    EMTPTypeInterdependentPropDescDataset           = 0x00020300,
+    EMTPTypeInterdependentPropDescElementDataset    = 0x00020301,
+    EMTPTypeObjectInfoDataset                       = 0x00020400,
+    EMTPTypeObjectPropDescDataset                   = 0x00020500,
+    EMTPTypeObjectPropDescEnumerationFormDataset    = 0x00020501,
+    EMTPTypeObjectPropDescRangeFormDataset          = 0x00020502,
+	EMTPTypeServiceObjPropExtnFormDataset			= 0x00020504,
+	EMTPTypeServiceMethodParamExtnFormDataset		= 0x00020505,
+    EMTPTypeObjectPropListDataset                   = 0x00020600,
+    EMTPTypeServicePropListDataset                  = EMTPTypeObjectPropListDataset,
+    EMTPTypeObjectPropListElementDataset            = 0x00020601,
+    EMTPTypeServicePropListElementDataset           = EMTPTypeObjectPropListElementDataset,
+    EMTPTypeStorageInfoDataset                      = 0x00020700,
+    EMTPTypeServiceInfoDataset						= 0x00020800,
+	EMTPTypeServiceFormatElementDataset				= 0x00020801,
+	EMTPTypeServiceFormatListDataset				= 0x00020802,
+	EMTPTypeServicePropertyElementDataset			= 0x00020803,
+	EMTPTypeServicePropertyListDataset					= 0x00020804,
+	EMTPTypeServiceMethodElementDataset				= 0x00020805,
+	EMTPTypeServiceMethodListDataset				= 0x00020806,
+	EMTPTypeServiceEventElementDataset				= 0x00020807,
+	EMTPTypeServiceEventListDataset					= 0x00020808,
+	EMTPTypeServiceSectionDataset					= 0x20020809,
+	EMTPTypeServiceCapabilityListDataset			= 0x00020900,
+	EMTPTypeFormatCapabilityListDataset             = EMTPTypeServiceCapabilityListDataset,
+	EMTPTypeFormatCapabilityDataset					= 0x00020901,
+	EMTPTypeServicePropDescList						= 0x00020902,
+	EMTPTypeServicePropDesc							= 0x00020903,
+	EMTPTypeDeleteObjectPropListDataset             = 0x00020A00,
+	EMTPTypeDeleteServicePropListDataset            = 0x00020B00,
+	EMTPTypeLastCompoundType						= EMTPTypeDeleteServicePropListDataset,
+    
+    EMTPTypeFirstFlatType                           = 0x00040000,
+    EMTPTypeFlat                                    = EMTPTypeFirstFlatType,
+    EMTPTypeEventDataset                            = 0x00040001,
+    EMTPTypeRequestDataset                          = 0x00040002,
+    EMTPTypeResponseDataset                         = 0x00040003,
+    EMTPTypeDataPair                                = 0x00040004,
+    EMTPTypeLastFlatType                            = EMTPTypeDataPair,
+    
+    EMTPTypeReference                               = 0x000FFFFF,
+    EMTPLastLibraryDataType                         = EMTPTypeReference,
+
+	/**
+	The Range for USB   transport is 0x00010000 to 0x000100FF
+	The Range for PTPIP transport is 0x00010100 to 0x000101FF
+	*/    
+    EMTPFirstTransportDataType                      = 0x00010000,
+    EMTPLastTransportDataType                       = 0x0001FFFF,
+    
+    EMTPFirstVendorExtensionDataType                = 0x80000000,
+    EMTPLastVendorExtensionDataType                 = 0xFFFFFFFF,
+    };
+
+/**
+The MTP INT8 data type size (in bytes).
+@publishedPartner
+@released  
+*/
+const TUint KMTPTypeINT8Size(1);
+
+/**
+The MTP UINT8 data type size (in bytes).
+@publishedPartner
+@released  
+*/
+const TUint KMTPTypeUINT8Size(1);
+
+/**
+The MTP INT16 data type size (in bytes).
+@publishedPartner
+@released  
+*/
+const TUint KMTPTypeINT16Size(2);
+
+/**
+The MTP UINT16 data type size (in bytes).
+@publishedPartner
+@released  
+*/
+const TUint KMTPTypeUINT16Size(2);
+
+/**
+The MTP INT32 data type size (in bytes).
+@publishedPartner
+@released  
+*/
+const TUint KMTPTypeINT32Size(4);
+
+/**
+The MTP UINT32 data type size (in bytes).
+@publishedPartner
+@released  
+*/
+const TUint KMTPTypeUINT32Size(4);
+
+/**
+The MTP INT64 data type size (in bytes).
+@publishedPartner
+@released  
+*/
+const TUint KMTPTypeINT64Size(8);
+
+/**
+The MTP UINT64 data type size (in bytes).
+@publishedPartner
+@released  
+*/
+const TUint KMTPTypeUINT64Size(8);
+
+/**
+The MTP INT128 data type size (in bytes).
+@publishedPartner
+@released  
+*/
+const TUint KMTPTypeINT128Size(16);
+
+/**
+The MTP UINT128 data type size (in bytes).
+@publishedPartner
+@released  
+*/
+const TUint KMTPTypeUINT128Size(16);
+
+/**
+The MTP String data type character size (in bytes).
+@publishedPartner
+@released  
+*/
+const TUint     KMTPCharSize(sizeof(TUint16));
+
+/**
+The MTP String data type null character.
+@publishedPartner
+@released  
+*/
+const TUint16   KMTPNullChar(0);
+
+/**
+The MTP String data type null character length.
+@publishedPartner
+@released  
+*/
+const TUint     KMTPNullCharLen(sizeof(KMTPNullChar) / KMTPCharSize);
+
+/**
+The MTP String data type absolute maximum length.
+@publishedPartner
+@released  
+*/
+const TUint     KMTPMaxStringLength(255);
+
+/**
+The MTP String data type maximum character content length.
+@publishedPartner
+@released  
+*/
+const TUint     KMTPMaxStringCharactersLength(KMTPMaxStringLength - KMTPNullCharLen);
+
+#endif // MTPDATATYPECONSTANTS_H
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/mtpprotocolconstants.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,855 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef MTPPROTOCOLCONSTANTS_H
+#define MTPPROTOCOLCONSTANTS_H
+
+#include <e32def.h>
+
+/** 
+Defines constant values specified by the MTP protocol.
+@publishedPartner
+@released 
+*/
+
+/**
+The null MTP 32-bit value.
+@publishedPartner
+@released 
+*/
+const TUint32 KMTPNotSpecified32(0x00000000);
+
+/**
+The MTP ObjectFormatCode that indicates that an operation or event applies to 
+all valid MTP ObjectFormatCodes.
+@publishedPartner
+@released 
+*/
+const TUint32 KMTPFormatsAll(0x00000000);
+
+/**
+The MTP parameter value that indicates that free space counted in number of 
+objects on a storage is not supported.
+@publishedPartner
+@released 
+*/
+const TUint32 KMTPFreeSpaceUnsupported(0xFFFFFFFF);
+
+/**
+The MTP ObjectHandle that indicates that an operation or event applies to all 
+valid ObjectHandles.
+@publishedPartner
+@released 
+*/
+const TUint32 KMTPHandleAll(0xFFFFFFFF);
+
+/**
+The MTP ObjectHandle that indicates that an operation or event applies to all 
+valid root level ObjectHandles.
+@publishedPartner
+@released 
+*/
+const TUint32 KMTPHandleAllRootLevel(0x00000000);
+
+/**
+The null MTP ObjectHandle value.
+@publishedPartner
+@released 
+*/
+const TUint32 KMTPHandleNone(0x00000000);
+
+/**
+The MTP ObjectHandle that indicates that an data object does have an assigned 
+parent data object.
+@publishedPartner
+@released 
+*/
+const TUint32 KMTPHandleNoParent(0xFFFFFFFF);
+
+/**
+The MTP ObjectPropCode value that indicates an operation or event applies to all 
+all valid MTP ObjectPropCodeS.
+@publishedPartner
+@released 
+*/
+const TUint32 KMTPObjectPropCodeAll(0xFFFFFFFF);
+
+/**
+The MTP SessionID value that indicates an operation or event applies to all 
+active MTP sessions.
+@publishedPartner
+@released 
+*/
+const TUint32 KMTPSessionAll(0xFFFFFFFF);
+
+/**
+The MTP SessionID value that indicates an operation or event occurs outside of
+an active MTP sessions
+@publishedPartner
+@released 
+*/
+const TUint32 KMTPSessionNone(0x00000000);
+
+/**
+The MTP StorageID that indicates that an operation or event applies to all 
+valid MTP StorageIDs.
+@publishedPartner
+@released 
+*/
+const TUint32 KMTPStorageAll(0xFFFFFFFF);
+
+/**
+The MTP StorageID that indicates that an operation or event applies to the 
+default MTP StorageID.
+@publishedPartner
+@released 
+*/
+const TUint32 KMTPStorageDefault(0x00000000);
+
+/**
+The null MTP TransactionID value.
+@publishedPartner
+@released 
+*/
+const TUint32 KMTPTransactionIdNone(0x00000000);
+
+/**
+The first in the sequence of valid MTP TransactionIDs. TransactionIDs increment
+sequentially from this value to KMTPTransactionIdLast and then wrap around to 
+this value.
+@publishedPartner
+@released 
+*/
+const TUint32 KMTPTransactionIdFirst(0x00000001);
+
+/**
+The last in the sequence of valid MTP TransactionIDs. TransactionIDs increment 
+sequentially from KMTPTransactionIdFirst to this value and then wrap around to 
+KMTPTransactionIdFirst.
+@publishedPartner
+@released 
+*/
+const TUint32 KMTPTransactionIdLast(0xFFFFFFFF);
+
+
+/**
+The MTP DataProvider that indicates that an Data base searching operation is applied to objects
+owned by any data providers.
+@publishedPartner
+@released 
+*/
+const TUint32 KMTPDataProviderAll(0xFFFFFFFF);
+
+
+const TUint32 KMTPNewPicKey(0x2001FCAE);
+const TUint32 KMTPServerUID(0x102827A2);
+
+
+/**
+The MTP functional modes. For a description of these modes, please refer to the 
+"Media Transfer Protocol Enhanced" specification.
+@publishedPartner
+@released 
+*/
+enum TMTPFunctionalMode
+    {
+    EMTPFunctionalModeStandard              = 0x0000,
+    EMTPFunctionalModeSleepState            = 0x0001,
+    EMTPFunctionalModeReservedStart         = 0x0002,
+    EMTPFunctionalModeReservedEnd           = 0x7FFF,
+    EMTPFunctionalModeNonResponsivePlayback = 0xC001,
+    EMTPFunctionalModeResponsivePlayback    = 0xC002,
+    EMTPFunctionalModeVendorExtStart        = 0x8000,
+    EMTPFunctionalModeVendorExtEnd          = 0xBFFF,
+    EMTPFunctionalModeStandardStart         = 0xC000,
+    EMTPFunctionalModeStandardEnd           = 0xFFFF
+    };
+
+/** 
+The MTP Datacode Summary. For a description of these datacodes, please refer
+to the "Media Transfer Protocol Enhanced" specification.
+@publishedPartner
+@released 
+*/
+
+enum TMTPDatacodeSummary
+    {
+    EMTPCodeUndefined1Start                 = 0x0000,
+    EMTPCodeUndefined1End                   = 0x0FFF,
+    
+    EMTPCodePTPOperationCodeStart           = 0x1000,
+    EMTPCodePTPOperationCodeEnd             = 0x1FFF,
+    
+    EMTPCodePTPResponseCodeStart            = 0x2000,
+    EMTPCodePTPResponseCodeEnd              = 0x2FFF,
+    
+    EMTPCodePTPObjFormatCodeStart           = 0x3000,
+    EMTPCodePTPObjFormatCodeEnd             = 0x3FFF,
+    
+    EMTPCodePTPEventCodeStart               = 0x4000,
+    EMTPCodePTPEventCodeEnd                 = 0x4FFF,
+    
+    EMTPCodePTPDevicePropCodeStart          = 0x5000,
+    EMTPCodePTPDevicePropCodeEnd            = 0x5FFF,
+    
+    EMTPCodePTPReserved1CodeStart           = 0x6000,
+    EMTPCodePTPReserved1CodeEnd             = 0x6FFF,
+    
+    EMTPCodePTPReserved2CodeStart           = 0x7000,
+    EMTPCodePTPReserved2CodeEnd             = 0x7FFF,
+    
+    EMTPCodeUndefined2CodeStart             = 0x8000,
+    EMTPCodeUndefined2CodeEnd               = 0x8FFF,
+    
+    EMTPCodeVenderExtnOpCodeStart           = 0x9000,
+    EMTPCodeVenderExtnOpCodeEnd             = 0x97FF,
+    
+    EMTPCodeMTPOperationCodeStart           = 0x9800,
+    EMTPCodeMTPOperationCodeEnd             = 0x9FFF,
+    
+    EMTPCodeVenderExtnRespCodeStart         = 0xA000,
+    EMTPCodeVenderExtnRespCodeEnd           = 0xA7FF,
+    
+    EMTPCodeMTPRespCodeStart                = 0xA800,
+    EMTPCodeMTPRespCodeEnd                  = 0xAFFF,
+    
+    EMTPCodeVenderExtnObjFormatCodeStart    = 0xB000,
+    EMTPCodeVenderExtnObjFormatCodeEnd      = 0xB7FF,
+    
+    
+    EMTPCodeMTPObjFormatCodeStart           = 0xB800,
+    EMTPCodeMTPObjFormatCodeEnd             = 0xBFFF,
+    
+    EMTPCodeVenderExtnEventCodeStart        = 0xC000,
+    EMTPCodeVenderExtnEventCodeEnd          = 0xC7FF,
+    
+    EMTPCodeMTPEventCodeStart               = 0xC800,
+    EMTPCodeMTPEventCodeEnd                 = 0xCFFF,
+    
+    EMTPCodeVenderExtnDevicePropCodeStart   = 0xD000,
+    EMTPCodeVenderExtnDevicePropCodeEnd     = 0xD3FF,
+    
+
+    
+    EMTPCodeMTPDevicePropCodeStart          = 0xD400,
+    EMTPCodeMTPDevicePropCodeEnd            = 0xD7FF,
+    
+    EMTPCodeVenderExtnObjectPropCodeStart   = 0xD800,
+    EMTPCodeVenderExtnObjectPropCodeEnd     = 0xDBFF,
+    
+    EMTPCodeMTPObjectPropCodeStart          = 0xDC00,
+    EMTPCodeMTPObjectPropCodeEnd            = 0xDFFF,
+    
+    EMTPCodePTPReserved3CodeStart           = 0xE000,
+    EMTPCodePTPReserved3CodeEnd             = 0xEFFF,
+    
+    EMTPCodePTPReserved4CodeStart           = 0xF000,
+    EMTPCodePTPReserved4CodeEnd             = 0xFFFF,
+    };
+
+
+/**
+The MTP operation datacodes. For a description of these datacodes, please refer
+to the "Media Transfer Protocol Enhanced" specification.
+@publishedPartner
+@released 
+*/
+enum TMTPOperationCode
+    {
+    EMTPOpCodePTPStart                  = 0x1000,
+    EMTPOpCodeGetDeviceInfo             = 0x1001,
+    EMTPOpCodeOpenSession               = 0x1002,
+    EMTPOpCodeCloseSession              = 0x1003,
+    EMTPOpCodeGetStorageIDs             = 0x1004,
+    EMTPOpCodeGetStorageInfo            = 0x1005,
+    EMTPOpCodeGetNumObjects             = 0x1006,
+    EMTPOpCodeGetObjectHandles          = 0x1007,
+    EMTPOpCodeGetObjectInfo             = 0x1008,
+    EMTPOpCodeGetObject                 = 0x1009,
+    EMTPOpCodeGetThumb                  = 0x100A,
+    EMTPOpCodeDeleteObject              = 0x100B,
+    EMTPOpCodeSendObjectInfo            = 0x100C,
+    EMTPOpCodeSendObject                = 0x100D,
+    EMTPOpCodeInitiateCapture           = 0x100E,
+    EMTPOpCodeFormatStore               = 0x100F,
+    EMTPOpCodeResetDevice               = 0x1010,
+    EMTPOpCodeSelfTest                  = 0x1011,
+    EMTPOpCodeSetObjectProtection       = 0x1012,
+    EMTPOpCodePowerDown                 = 0x1013,
+    EMTPOpCodeGetDevicePropDesc         = 0x1014,
+    EMTPOpCodeGetDevicePropValue        = 0x1015,
+    EMTPOpCodeSetDevicePropValue        = 0x1016,
+    EMTPOpCodeResetDevicePropValue      = 0x1017,
+    EMTPOpCodeTerminateOpenCapture      = 0x1018,
+    EMTPOpCodeMoveObject                = 0x1019,
+    EMTPOpCodeCopyObject                = 0x101A,
+    EMTPOpCodeGetPartialObject          = 0x101B,
+    EMTPOpCodeInitiateOpenCapture       = 0x101C,
+    EMTPOpCodePTPEnd                    = 0x1FFF,
+    EMTPOpCodeVendorExtensionStart      = 0x9000,
+    EMTPOpCodeGetServiceIDs             = 0x9301,
+    EMTPOpCodeGetServiceInfo            = 0x9302,
+    EMTPOpCodeGetServiceCapabilities    = 0x9303,
+    EMTPOpCodeGetServicePropDesc        = 0x9304,
+    EMTPOpCodeGetServicePropList        = 0x9305,
+    EMTPOpCodeSetServicePropList        = 0x9306,
+    EMTPOpCodeUpdateObjectPropList      = 0x9307,
+    EMTPOpCodeDeleteObjectPropList      = 0x9308,
+    EMTPOpCodeDeleteServicePropList     = 0x9309,
+    EMTPOpCodeGetFormatCapabilities     = 0x930A,
+    EMTPOpCodeVendorExtextensionEnd     = 0x97FF,
+    EMTPOpCodeMTPStart                  = 0x9800,
+    EMTPOpCodeGetObjectPropsSupported   = 0x9801,
+    EMTPOpCodeGetObjectPropDesc         = 0x9802,
+    EMTPOpCodeGetObjectPropValue        = 0x9803,
+    EMTPOpCodeSetObjectPropValue        = 0x9804,
+    EMTPOpCodeGetObjectReferences       = 0x9810,
+    EMTPOpCodeSetObjectReferences       = 0x9811,
+    EMTPOpCodeSkip                      = 0x9820,
+    EMTPOpCodeGetObjectPropList         = 0x9805,
+    EMTPOpCodeSetObjectPropList         = 0x9806,
+    EMTPOpCodeGetInterdependentPropDesc = 0x9807,
+    EMTPOpCodeSendObjectPropList        = 0x9808,
+    EMTPOpCodeGetSanAlertInfo           = 0x93E8,
+    EMTPOpCodeMTPEnd                    = 0x9FFF    
+    };
+
+/**
+The MTP response datacodes. For a description of these datacodes, please refer 
+to the "Media Transfer Protocol Enhanced" specification.
+@publishedPartner
+@released 
+*/
+enum TMTPResponseCode
+    {   
+    EMTPRespCodePTPStart                                = 0x2000,
+    EMTPRespCodeUndefined                               = 0x2000,
+    EMTPRespCodeOK                                      = 0x2001,
+    EMTPRespCodeGeneralError                            = 0x2002,
+    EMTPRespCodeSessionNotOpen                          = 0x2003,
+    EMTPRespCodeInvalidTransactionID                    = 0x2004,
+    EMTPRespCodeOperationNotSupported                   = 0x2005,
+    EMTPRespCodeParameterNotSupported                   = 0x2006,
+    EMTPRespCodeIncompleteTransfer                      = 0x2007,
+    EMTPRespCodeInvalidStorageID                        = 0x2008,
+    EMTPRespCodeInvalidObjectHandle                     = 0x2009,
+    EMTPRespCodeDevicePropNotSupported                  = 0x200A,
+    EMTPRespCodeInvalidObjectFormatCode                 = 0x200B,
+    EMTPRespCodeStoreFull                               = 0x200C,
+    EMTPRespCodeObjectWriteProtected                    = 0x200D,
+    EMTPRespCodeStoreReadOnly                           = 0x200E,
+    EMTPRespCodeAccessDenied                            = 0x200F,
+    EMTPRespCodeNoThumbnailPresent                      = 0x2010,
+    EMTPRespCodeSelfTestFailed                          = 0x2011,
+    EMTPRespCodePartialDeletion                         = 0x2012,
+    EMTPRespCodeStoreNotAvailable                       = 0x2013,
+    EMTPRespCodeSpecificationByFormatUnsupported        = 0x2014,
+    EMTPRespCodeNoValidObjectInfo                       = 0x2015,
+    EMTPRespCodeInvalidCodeFormat                       = 0x2016,
+    EMTPRespCodeUnknownVendorCode                       = 0x2017,
+    EMTPRespCodeCaptureAlreadyTerminated                = 0x2018,
+    EMTPRespCodeDeviceBusy                              = 0x2019,
+    EMTPRespCodeInvalidParentObject                     = 0x201A,
+    EMTPRespCodeInvalidDeviEMTPRespCodecePropFormat     = 0x201B,
+    EMTPRespCodeInvalidDevicePropValue                  = 0x201C,
+    EMTPRespCodeInvalidParameter                        = 0x201D,
+    EMTPRespCodeSessionAlreadyOpen                      = 0x201E,
+    EMTPRespCodeTransactionCancelled                    = 0x201F,
+    EMTPRespCodeSpecificationOfDestinationUnsupported   = 0x2020,
+    EMTPRespCodePTPEnd                                  = 0x2FFF,
+    EMTPRespCodeVendorExtensionStart                    = 0xA000,
+    EMTPRespCodeInvalidServiceID                        = 0xA301,
+    EMTPRespCodeInvalidServicePropCode                  = 0xA302,
+    EMTPRespCodeVendorExtensionEnd                      = 0xA7FF,
+    EMTPRespCodeMTPStart                                = 0xA800,
+    EMTPRespCodeInvalidObjectPropCode                   = 0xA801,
+    EMTPRespCodeInvalidObjectPropFormat                 = 0xA802,
+    EMTPRespCodeInvalidObjectPropValue                  = 0xA803,
+    EMTPRespCodeInvalidObjectReference                  = 0xA804,
+    EMTPRespCodeGroupNotSupported						= 0xA805,
+    EMTPRespCodeInvalidDataset                          = 0xA806,
+    EMTPRespCodeSpecificationByGroupUnsupported         = 0xA807,
+    EMTPRespCodeSpecificationByDepthUnsupported         = 0xA808,
+    EMTPRespCodeObjectTooLarge                          = 0xA809,
+    EMTPRespCodeObjectPropNotSupported                  = 0xA80A,
+    EMTPRespCodeSANStored                               = 0xA391,
+    EMTPRespCodeUserRejectedSAN                         = 0xA392,
+    EMTPRespCodeSANParseError                           = 0xA393,
+    EMTPRespCodeProfileMissing                          = 0xA394,
+    EMTPRespCodeMTPEnd                                  = 0xAFFF   
+    };
+
+/**
+The MTP object format datacodes. For a description of these datacodes, please 
+refer to the "Media Transfer Protocol Enhanced" specification.
+@publishedPartner
+@released 
+*/
+enum TMTPFormatCode
+    {
+    EMTPFormatCodePTPStart                          = 0x3000,
+    EMTPFormatCodeUndefined                         = 0x3000,
+    EMTPFormatCodeAssociation                       = 0x3001,
+    EMTPFormatCodeScript                            = 0x3002,
+    EMTPFormatCodeExecutable                        = 0x3003,
+    EMTPFormatCodeText                              = 0x3004,
+    EMTPFormatCodeHTML                              = 0x3005,
+    EMTPFormatCodeDPOF                              = 0x3006,
+    EMTPFormatCodeAIFF                              = 0x3007,
+    EMTPFormatCodeWAV                               = 0x3008,
+    EMTPFormatCodeMP3                               = 0x3009,
+    EMTPFormatCodeAVI                               = 0x300A,
+    EMTPFormatCodeMPEG                              = 0x300B, 
+    EMTPFormatCodeASF                               = 0x300C,
+    EMTPFormatCodeImageDefined                      = 0x3800,
+    EMTPFormatCodeEXIFJPEG                          = 0x3801,
+    EMTPFormatCodeTIFFEP                            = 0x3802,
+    EMTPFormatCodeFlashPix                          = 0x3803,
+    EMTPFormatCodeBMP                               = 0x3804,
+    EMTPFormatCodeCIFF                              = 0x3805,
+    EMTPFormatCodeImageUndefined1                   = 0x3806,
+    EMTPFormatCodeGIF                               = 0x3807,
+    EMTPFormatCodeJFIF                              = 0x3808,
+    EMTPFormatCodeCD                                = 0x3809,
+    EMTPFormatCodePICT                              = 0x380A,
+    EMTPFormatCodePNG                               = 0x380B,
+    EMTPFormatCodeImageUndefined2                   = 0x380C,
+    EMTPFormatCodeTIFF                              = 0x380D,
+    EMTPFormatCodeTIFFIT                            = 0x380E,
+    EMTPFormatCodeJP2                               = 0x380F,
+    EMTPFormatCodeJPX                               = 0x3810,
+    EMTPFormatCodePTPEnd                            = 0x3FFF,
+    EMTPFormatCodeVendorExtStart                    = 0xB000,
+    
+    EMTPFormatCodeVendorExtDynamicStart            = EMTPFormatCodeVendorExtStart,
+
+    
+    EMTPFormatCodeVendorExtEnd                      = 0xB7FF,
+    EMTPFormatCodeVendorExtDynamicEnd              = EMTPFormatCodeVendorExtEnd,
+    
+    EMTPFormatCodeMTPStart                          = 0xB800,
+    EMTPFormatCodeUndefinedFirmware                 = 0xB802,
+    EMTPFormatCodeWindowsImageFormat                = 0xB881,
+    EMTPFormatCodeUndefinedAudio                    = 0xB900,
+    EMTPFormatCodeWMA                               = 0xB901,
+    EMTPFormatCodeOGG                               = 0xB902,
+    EMTPFormatCodeAAC                               = 0xB903,
+    EMTPFormatCodeAudible                           = 0xB904,
+    EMTPFormatCodeFLAC                              = 0xB906,
+    EMTPFormatCodeUndefinedVideo                    = 0xB980,
+    EMTPFormatCodeWMV                               = 0xB981,
+    EMTPFormatCodeMP4Container                      = 0xB982,
+    EMTPFormatCodeMP2                               = 0xB983,
+    EMTPFormatCode3GPContainer                      = 0xB984,
+    EMTPFormatCodeAVCHD								= 0xB985,
+    EMTPFormatCodeUndefinedCollection               = 0xBA00,
+    EMTPFormatCodeAbstractMultimediaAlbum           = 0xBA01,
+    EMTPFormatCodeAbstractImageAlbum                = 0xBA02,
+    EMTPFormatCodeAbstractAudioAlbum                = 0xBA03,
+    EMTPFormatCodeAbstractVideoAlbum                = 0xBA04,
+    EMTPFormatCodeAbstractAudioVideoPlaylist        = 0xBA05,
+    EMTPFormatCodeAbstractContactGroup              = 0xBA06,
+    EMTPFormatCodeAbstractMessageFolder             = 0xBA07,
+    EMTPFormatCodeAbstractChapteredProduction       = 0xBA08,
+    EMTPFormatCodeAbstractAudioPlaylist             = 0xBA09,
+    EMTPFormatCodeAbstractVideoPlaylist             = 0xBA0A,
+    EMTPFormatCodeWPLPlaylist                       = 0xBA10,
+    EMTPFormatCodeM3UPlaylist                       = 0xBA11,
+    EMTPFormatCodeMPLPlaylist                       = 0xBA12,
+    EMTPFormatCodeASXPlaylist                       = 0xBA13,
+    EMTPFormatCodePLSPlaylist                       = 0xBA14,
+    EMTPFormatCodeUndefinedDocument                 = 0xBA80,
+    EMTPFormatCodeAbstractDocument                  = 0xBA81,
+    EMTPFormatCodeXMLDocument                       = 0xBA82,
+    EMTPFormatCodeMicrosoftWordDocument             = 0xBA83,
+    EMTPFormatCodeMHTCompiledHTMLDocument           = 0xBA84,
+    EMTPFormatCodeMicrosoftExcelSpreadsheet         = 0xBA85,
+    EMTPFormatCodeMicrosoftPowerpointPresentation   = 0xBA86,
+    EMTPFormatCodeUndefinedMessage                  = 0xBB00,
+    EMTPFormatCodeAbstractMessage                   = 0xBB01,
+    EMTPFormatCodeUndefinedContact                  = 0xBB80,
+    EMTPFormatCodeAbstractContact                   = 0xBB81,
+    EMTPFormatCodeVCard2                            = 0xBB82,
+    EMTPFormatCodeMTPEnd                            = 0xBFFF 
+    };
+
+/**
+The MTP event datacodes. For a description of these datacodes, please refer to 
+the "Media Transfer Protocol Enhanced" specification.
+@publishedPartner
+@released 
+*/
+enum TMTPEventCode
+    {
+    EMTPEventCodePTPStart                   = 0x4000,
+    EMTPEventCodeUndefined                  = 0x4000,
+    EMTPEventCodeCancelTransaction          = 0x4001,
+    EMTPEventCodeObjectAdded                = 0x4002,
+    EMTPEventCodeObjectRemoved              = 0x4003,
+    EMTPEventCodeStoreAdded                 = 0x4004,
+    EMTPEventCodeStoreRemoved               = 0x4005,
+    EMTPEventCodeDevicePropChanged          = 0x4006,
+    EMTPEventCodeObjectInfoChanged          = 0x4007,
+    EMTPEventCodeDeviceInfoChanged          = 0x4008,
+    EMTPEventCodeRequestObjectTransfer      = 0x4009,
+    EMTPEventCodeStoreFull                  = 0x400A,
+    EMTPEventCodeDeviceReset                = 0x400B,
+    EMTPEventCodeStorageInfoChanged         = 0x400C,
+    EMTPEventCodeCaptureComplete            = 0x400D,
+    EMTPEventCodeUnreportedStatus           = 0x400E,
+    EMTPEventCodePTPEnd                     = 0x4FFF,
+    EMTPEventCodeVendorExtensionStart       = 0xC000,
+    EMTPEventCodeServiceAdded               = 0xC301,
+    EMTPEventCodeServiceRemoved             = 0xC302,
+    EMTPEventCodeServicePropChanged         = 0xC303,
+    EMTPEventCodeMethodComplete             = 0xC304,
+    EMTPEventCodeVendorExtensionEnd         = 0xC7FF,
+    EMTPEventCodeMTPStart                   = 0xC800,
+    EMTPEventCodeObjectPropChanged          = 0xC801,
+    EMTPEventCodeObjectPropDescChanged      = 0xC802,
+    EMTPEventCodeObjectReferencesChanged    = 0xC803,
+    EMTPEventCodeRequestSyncObjectTransfer  = 0xC390,
+    EMTPEventCodeRequestSanAlertInfo        = 0xC391,
+    EMTPEventCodeMTPEnd                     = 0xCFFF,
+    };
+
+/**
+The MTP device property datacodes. For a description of these datacodes, please 
+refer to the "Media Transfer Protocol Enhanced" specification.
+@publishedPartner
+@released 
+*/
+enum TMTPDevicePropertyCode
+    {
+    EMTPDevicePropCodePTPStart                      = 0x5000,
+    EMTPDevicePropCodeUndefined                     = 0x5000,
+    EMTPDevicePropCodeBatteryLevel                  = 0x5001,
+    EMTPDevicePropCodeFunctionalMode                = 0x5002,
+    EMTPDevicePropCodeImageSize                     = 0x5003,
+    EMTPDevicePropCodeCompressionSetting            = 0x5004,
+    EMTPDevicePropCodeWhiteBalance                  = 0x5005,
+    EMTPDevicePropCodeRGBGain                       = 0x5006,
+    EMTPDevicePropCodeFNumber                       = 0x5007,
+    EMTPDevicePropCodeFocalLength                   = 0x5008,
+    EMTPDevicePropCodeFocusDistance                 = 0x5009,
+    EMTPDevicePropCodeFocusMode                     = 0x500A,
+    EMTPDevicePropCodeExposureMeteringMode          = 0x500B,
+    EMTPDevicePropCodeFlashMode                     = 0x500C,
+    EMTPDevicePropCodeExposureTime                  = 0x500D,
+    EMTPDevicePropCodeExposureProgramMode           = 0x500E,
+    EMTPDevicePropCodeExposureIndex                 = 0x500F,
+    EMTPDevicePropCodeExposureBiasCompensation      = 0x5010,
+    EMTPDevicePropCodeDateTime                      = 0x5011,
+    EMTPDevicePropCodeCaptureDelay                  = 0x5012,
+    EMTPDevicePropCodeStillCaptureMode              = 0x5013,
+    EMTPDevicePropCodeContrast                      = 0x5014,
+    EMTPDevicePropCodeSharpness                     = 0x5015,
+    EMTPDevicePropCodeDigitalZoom                   = 0x5016,
+    EMTPDevicePropCodeEffectMode                    = 0x5017,
+    EMTPDevicePropCodeBurstNumber                   = 0x5018,
+    EMTPDevicePropCodeBurstInterval                 = 0x5019,
+    EMTPDevicePropCodeTimelapseNumber               = 0x501A,
+    EMTPDevicePropCodeTimelapseInterval             = 0x501B,
+    EMTPDevicePropCodeFocusMeteringMode             = 0x501C,
+    EMTPDevicePropCodeUploadURL                     = 0x501D,
+    EMTPDevicePropCodeArtist                        = 0x501E,
+    EMTPDevicePropCodeCopyrightInfo                 = 0x501F,
+    EMTPDevicePropCodePTPEnd                        = 0x5FFF,
+    EMTPDevicePropCodeVendorExtensionStart          = 0xD000,
+    EMTPDevicePropCodeVendorExtensionEnd            = 0xD3FF,
+    EMTPDevicePropCodeMTPStart                      = 0xD400,
+    EMTPDevicePropCodeSynchronizationPartner        = 0xD401,
+    EMTPDevicePropCodeDeviceFriendlyName            = 0xD402,
+    EMTPDevicePropCodeVolume                        = 0xD403,
+    EMTPDevicePropCodeSupportedFormatsOrdered       = 0xD404,
+    EMTPDevicePropCodeDeviceIcon                    = 0xD405,
+    EMTPDevicePropCodePlaybackRate                  = 0xD410,
+    EMTPDevicePropCodePlaybackObject                = 0xD411,
+    EMTPDevicePropCodePlaybackContainerIndex        = 0xD412,
+    EMTPDevicePropCodePlaybackPosition              = 0xD413,
+    EMTPDevicePropCodeSessionInitiatorVersionInfo   = 0xD406,
+    EMTPDevicePropCodePerceivedDeviceType           = 0xD407,
+    EMTPDevicePropCodeMTPEnd                        = 0xD7FF,
+    EMTPDevicePropCodeFunctionalID					= 0xD301,
+    EMTPDevicePropCodeModelID						= 0xD302,    
+    EMTPDevicePropCodeUseDeviceStage				= 0xD303
+    };
+
+/**
+The MTP device property datacodes. For a description of these datacodes, please 
+refer to the "Media Transfer Protocol Enhanced" specification.
+@publishedPartner
+@released 
+*/
+enum TMTPObjectPropertyCode    
+    {
+    EMTPObjectPropCodeUndefined                         = 0x0000,
+    EMTPObjectPropCodeVendorExtensionStart              = 0xD800,
+    EMTPObjectPropCodeVendorExtensionEnd                = 0xDBFF,
+    EMTPObjectPropCodeMTPStart                          = 0xDC01,
+    EMTPObjectPropCodeStorageID                         = EMTPObjectPropCodeMTPStart,
+    EMTPObjectPropCodeObjectFormat                      = 0xDC02,
+    EMTPObjectPropCodeProtectionStatus                  = 0xDC03,
+    EMTPObjectPropCodeObjectSize                        = 0xDC04,
+    EMTPObjectPropCodeAssociationType                   = 0xDC05,
+    EMTPObjectPropCodeAssociationDesc                   = 0xDC06,
+    EMTPObjectPropCodeObjectFileName                    = 0xDC07,
+    EMTPObjectPropCodeDateCreated                       = 0xDC08,
+    EMTPObjectPropCodeDateModified                      = 0xDC09,
+    EMTPObjectPropCodeKeywords                          = 0xDC0A,
+    EMTPObjectPropCodeParentObject                      = 0xDC0B,
+    EMTPObjectPropCodeAllowedFolderContents             = 0xDC0C,
+    EMTPObjectPropCodeHidden                            = 0xDC0D,
+    EMTPObjectPropCodeSystemObject                      = 0xDC0E,
+    EMTPObjectPropCodePersistentUniqueObjectIdentifier  = 0xDC41,
+    EMTPObjectPropCodeSyncID                            = 0xDC42,
+    EMTPObjectPropCodePropertyBag                       = 0xDC43,
+    EMTPObjectPropCodeName                              = 0xDC44,
+    EMTPObjectPropCodeCreatedBy                         = 0xDC45,
+    EMTPObjectPropCodeArtist                            = 0xDC46,
+    EMTPObjectPropCodeDateAuthored                      = 0xDC47,
+    EMTPObjectPropCodeDescription                       = 0xDC48,
+    EMTPObjectPropCodeURLReference                      = 0xDC49,
+    EMTPObjectPropCodeLanguageLocale                    = 0xDC4A,
+    EMTPObjectPropCodeCopyrightInformation              = 0xDC4B,
+    EMTPObjectPropCodeSource                            = 0xDC4C,
+    EMTPObjectPropCodeOriginLocation                    = 0xDC4D,
+    EMTPObjectPropCodeDateAdded                         = 0xDC4E,
+    EMTPObjectPropCodeNonConsumable                     = 0xDC4F,
+    EMTPObjectPropCodeCorruptUnplayable                 = 0xDC50,
+    EMTPObjectPropCodeProducerSerialNumber              = 0xDC51,
+    EMTPObjectPropCodeRepresentativeSampleFormat        = 0xDC81,
+    EMTPObjectPropCodeRepresentativeSampleSize          = 0xDC82,
+    EMTPObjectPropCodeRepresentativeSampleHeight        = 0xDC83,
+    EMTPObjectPropCodeRepresentativeSampleWidth         = 0xDC84,
+    EMTPObjectPropCodeRepresentativeSampleDuration      = 0xDC85,
+    EMTPObjectPropCodeRepresentativeSampleData          = 0xDC86,
+    EMTPObjectPropCodeWidth                             = 0xDC87,
+    EMTPObjectPropCodeHeight                            = 0xDC88,
+    EMTPObjectPropCodeDuration                          = 0xDC89,
+    EMTPObjectPropCodeRating                            = 0xDC8A,
+    EMTPObjectPropCodeTrack                             = 0xDC8B,
+    EMTPObjectPropCodeGenre                             = 0xDC8C,
+    EMTPObjectPropCodeCredits                           = 0xDC8D,
+    EMTPObjectPropCodeLyrics                            = 0xDC8E,
+    EMTPObjectPropCodeSubscriptionContentID             = 0xDC8F,
+    EMTPObjectPropCodeProducedBy                        = 0xDC90,
+    EMTPObjectPropCodeUseCount                          = 0xDC91,
+    EMTPObjectPropCodeSkipCount                         = 0xDC92,
+    EMTPObjectPropCodeLastAccessed                      = 0xDC93,
+    EMTPObjectPropCodeParentalRating                    = 0xDC94,
+    EMTPObjectPropCodeMetaGenre                         = 0xDC95,
+    EMTPObjectPropCodeComposer                          = 0xDC96,
+    EMTPObjectPropCodeEffectiveRating                   = 0xDC97,
+    EMTPObjectPropCodeSubtitle                          = 0xDC98,
+    EMTPObjectPropCodeOriginalReleaseDate               = 0xDC99,
+    EMTPObjectPropCodeAlbumName                         = 0xDC9A,
+    EMTPObjectPropCodeAlbumArtist                       = 0xDC9B,
+    EMTPObjectPropCodeMood                              = 0xDC9C,
+    EMTPObjectPropCodeDRMStatus                         = 0xDC9D,
+    EMTPObjectPropCodeSubDescription                    = 0xDC9E,
+    EMTPObjectPropCodeIsCropped                         = 0xDCD1,
+    EMTPObjectPropCodeIsColourCorrected                 = 0xDCD2,
+    EMTPObjectPropCodeImageBitDepth                     = 0xDCD3,
+    EMTPObjectPropCodeFnumber                           = 0xDCD4,
+    EMTPObjectPropCodeExposureTime                      = 0xDCD5,
+    EMTPObjectPropCodeExposureIndex                     = 0xDCD6,
+    EMTPObjectPropCodeTotalBitRate                      = 0xDE91,
+    EMTPObjectPropCodeBitrateType                       = 0xDE92,
+    EMTPObjectPropCodeSampleRate                        = 0xDE93,
+    EMTPObjectPropCodeNumberOfChannels                  = 0xDE94,
+    EMTPObjectPropCodeAudioBitDepth                     = 0xDE95,
+    EMTPObjectPropCodeScanType                          = 0xDE97,
+    EMTPObjectPropCodeAudioWAVECodec                    = 0xDE99,
+    EMTPObjectPropCodeAudioBitRate                      = 0xDE9A,
+    EMTPObjectPropCodeVideoFourCCCodec                  = 0xDE9B,
+    EMTPObjectPropCodeVideoBitRate                      = 0xDE9C,
+    EMTPObjectPropCodeFramesPerThousandSeconds          = 0xDE9D,
+    EMTPObjectPropCodeKeyFrameDistance                  = 0xDE9E,
+    EMTPObjectPropCodeBufferSize                        = 0xDE9F,
+    EMTPObjectPropCodeEncodingQuality                   = 0xDEA0,
+    EMTPObjectPropCodeEncodingProfile                   = 0xDEA1,
+    EMTPObjectPropCodeDisplayName                       = 0xDCE0,
+    EMTPObjectPropCodeBodyText                          = 0xDCE1,
+    EMTPObjectPropCodeSubject                           = 0xDCE2,
+    EMTPObjectPropCodePriority                          = 0xDCE3,
+    EMTPObjectPropCodeGivenName                         = 0xDD00,
+    EMTPObjectPropCodeMiddleNames                       = 0xDD01,
+    EMTPObjectPropCodeFamilyName                        = 0xDD02,
+    EMTPObjectPropCodePrefix                            = 0xDD03,
+    EMTPObjectPropCodeSuffix                            = 0xDD04,
+    EMTPObjectPropCodePhoneticGivenName                 = 0xDD05,
+    EMTPObjectPropCodePhoneticFamilyName                = 0xDD06,
+    EMTPObjectPropCodeEmailPrimary                      = 0xDD07,
+    EMTPObjectPropCodeEmailPersonal1                    = 0xDD08,
+    EMTPObjectPropCodeEmailPersonal2                    = 0xDD09,
+    EMTPObjectPropCodeEmailBusiness1                    = 0xDD0A,
+    EMTPObjectPropCodeEmailBusiness2                    = 0xDD0B,
+    EMTPObjectPropCodeEmailOthers                       = 0xDD0C,
+    EMTPObjectPropCodePhoneNumberPrimary                = 0xDD0D,
+    EMTPObjectPropCodePhoneNumberPersonal               = 0xDD0E,
+    EMTPObjectPropCodePhoneNumberPersonal2              = 0xDD0F,
+    EMTPObjectPropCodePhoneNumberBusiness               = 0xDD10,
+    EMTPObjectPropCodePhoneNumberBusiness2              = 0xDD11,
+    EMTPObjectPropCodePhoneNumberMobile                 = 0xDD12,
+    EMTPObjectPropCodePhoneNumberMobile2                = 0xDD13,
+    EMTPObjectPropCodeFaxNumberPrimary                  = 0xDD14,
+    EMTPObjectPropCodeFaxNumberPersonal                 = 0xDD15,
+    EMTPObjectPropCodeFaxNumberBusiness                 = 0xDD16,
+    EMTPObjectPropCodePagerNumber                       = 0xDD17,
+    EMTPObjectPropCodePhoneNumberOthers                 = 0xDD18,
+    EMTPObjectPropCodePrimaryWebAddress                 = 0xDD19,
+    EMTPObjectPropCodePersonalWebAddress                = 0xDD1A,
+    EMTPObjectPropCodeBusinessWebAddress                = 0xDD1B,
+    EMTPObjectPropCodeInstantMessengerAddress           = 0xDD1C,
+    EMTPObjectPropCodeInstantMessengerAddress2          = 0xDD1D,
+    EMTPObjectPropCodeInstantMessengerAddress3          = 0xDD1E,
+    EMTPObjectPropCodePostalAddressPersonalFull         = 0xDD1F,
+    EMTPObjectPropCodePostalAddressPersonalLine1        = 0xDD20,
+    EMTPObjectPropCodePostalAddressPersonalLine2        = 0xDD21,
+    EMTPObjectPropCodePostalAddressPersonalCity         = 0xDD22,
+    EMTPObjectPropCodePostalAddressPersonalRegion       = 0xDD23,
+    EMTPObjectPropCodePostalAddressPersonalPostalCode   = 0xDD24,
+    EMTPObjectPropCodePostalAddressPersonalCountry      = 0xDD25,
+    EMTPObjectPropCodePostalAddressBusinessFull         = 0xDD26,
+    EMTPObjectPropCodePostalAddressBusinessLine1        = 0xDD27,
+    EMTPObjectPropCodePostalAddressBusinessLine2        = 0xDD28,
+    EMTPObjectPropCodePostalAddressBusinessCity         = 0xDD29,
+    EMTPObjectPropCodePostalAddressBusinessRegion       = 0xDD2A,
+    EMTPObjectPropCodePostalAddressBusinessPostalCode   = 0xDD2B,
+    EMTPObjectPropCodePostalAddressBusinessCountry      = 0xDD2C,
+    EMTPObjectPropCodePostalAddressOtherFull            = 0xDD2D,
+    EMTPObjectPropCodePostalAddressOtherLine1           = 0xDD2E,
+    EMTPObjectPropCodePostalAddressOtherLine2           = 0xDD2F,
+    EMTPObjectPropCodePostalAddressOtherCity            = 0xDD30,
+    EMTPObjectPropCodePostalAddressOtherRegion          = 0xDD31,
+    EMTPObjectPropCodePostalAddressOtherPostalCode      = 0xDD32,
+    EMTPObjectPropCodePostalAddressOtherCountry         = 0xDD33,
+    EMTPObjectPropCodeOrganizationName                  = 0xDD34,
+    EMTPObjectPropCodePhoneticOrganizationName          = 0xDD35,
+    EMTPObjectPropCodeRole                              = 0xDD36,
+    EMTPObjectPropCodeBirthdate                         = 0xDD37,
+    EMTPObjectPropCodeMessageTo                         = 0xDD40,
+    EMTPObjectPropCodeMessageCC                         = 0xDD41,
+    EMTPObjectPropCodeMessageBCC                        = 0xDD42,
+    EMTPObjectPropCodeMessageRead                       = 0xDD43,
+    EMTPObjectPropCodeMessageReceivedTime               = 0xDD44,
+    EMTPObjectPropCodeMessageSender                     = 0xDD45,
+    EMTPObjectPropCodeActivityBeginTime                 = 0xDD50,
+    EMTPObjectPropCodeActivityEndTime                   = 0xDD51,
+    EMTPObjectPropCodeActivityLocation                  = 0xDD52,
+    EMTPObjectPropCodeActivityRequiredAttendees         = 0xDD54,
+    EMTPObjectPropCodeActivityOptionalAttendees         = 0xDD55,
+    EMTPObjectPropCodeActivityResources                 = 0xDD56,
+    EMTPObjectPropCodeActivityAccepted                  = 0xDD57,
+    EMTPObjectPropCodeActivityTentative                 = 0xDD58,
+    EMTPObjectPropCodeActivityDeclined                  = 0xDD59,
+    EMTPObjectPropCodeActivityReminderTime              = 0xDD5A,
+    EMTPObjectPropCodeActivityOwner                     = 0xDD5B,
+    EMTPObjectPropCodeActivityStatus                    = 0xDD5C,
+    EMTPObjectPropCodeMTPEnd = EMTPObjectPropCodeActivityStatus    
+    };
+
+/**
+The MTP association type datacodes. For a description of these datacodes, 
+please refer to the "Media Transfer Protocol Enhanced" specification.
+@publishedPartner
+@released 
+*/
+enum TMTPAssociationType
+    {    
+    EMTPAssociationTypeUndefined            = 0x0000,
+    EMTPAssociationTypeGenericFolder        = 0x0001,
+    EMTPAssociationTypeAlbum                = 0x0002,
+    EMTPAssociationTypeTimeSequence         = 0x0003,
+    EMTPAssociationTypeHorizontalPanoramic  = 0x0004,
+    EMTPAssociationTypeVerticalPanoramic    = 0x0005,
+    EMTPAssociationType2DPanoramic          = 0x0006,
+    EMTPAssociationTypeAncillaryData        = 0x0007
+    };
+
+/**
+The MTP protection status atacodes. For a description of these datacodes, 
+please refer to the "Media Transfer Protocol Enhanced" specification.
+@publishedPartner
+@released 
+*/
+enum TMTPProtectionStatus
+    {
+    EMTPProtectionNoProtection      = 0x0000,
+    EMTPProtectionReadOnly          = 0x0001,
+    EMTPProtectionReadOnlyData      = 0x8002, 
+    EMTPProtectionNonTransferable   = 0x8003
+    };
+
+/**
+The MTP consumable status datacodes. For a description of these datacodes, 
+please refer to the "Media Transfer Protocol Enhanced" specification.
+@publishedPartner
+@released 
+*/
+enum TMTPNonConsumable
+	{
+	EMTPConsumable		= 0x00,
+	EMTPNonConsumable	= 0x01,
+	};
+
+/**
+The MTP storage type datacodes. For a description of these datacodes, please 
+refer to the "Media Transfer Protocol Enhanced" specification.
+*/
+enum TMTPStorageType
+	{
+	EMTPStorageUndefined 	= 0x0000,
+	EMTPStorageFixedROM 	= 0x0001,
+	EMTPStorageRemovableROM = 0x0002,
+	EMTPStorageFixedRAM 	= 0x0003,
+	EMTPStorageRemovableRAM = 0x0004	
+	};
+
+/**
+The MTP filesystem type datacodes. For a description of these datacodes, please 
+refer to the "Media Transfer Protocol Enhanced" specification.
+@publishedPartner
+@released 
+*/
+enum TMTPFileSystemType
+	{
+	EMTPFileSystemUndefined 			= 0x0000,
+	EMTPFileSystemGenericFlat 			= 0x0001,
+	EMTPFileSystemGenericHierarchical 	= 0x0002,
+	EMTPFileSystemDCF					= 0x0003
+	};
+
+/**
+The MTP storage access capability type datacodes. For a description of these datacodes, 
+please refer to the "Media Transfer Protocol Enhanced" specification.
+@publishedPartner
+@released 
+*/
+enum TMTPAccessCapability
+	{	
+	EAccessCapabilityReadWrite						= 0x0000,
+	EAccessCapabilityReadOnlyWithoutDeletion		= 0x0001,	
+	EAccessCapabilityReadOnlyWithDeletion 			= 0x0002
+	};
+
+#endif // MTPPROTOCOLCONSTANTS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/mtptypes.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,25 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#include <mtp/mtptypescomplex.h>
+#include <mtp/mtptypescompound.h>
+#include <mtp/mtptypesflat.h>
+#include <mtp/mtptypessimple.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/mtptypescomplex.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,25 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#include <mtp/cmtptypearray.h>
+#include <mtp/cmtptypefile.h>
+#include <mtp/cmtptypestring.h>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/mtptypescompound.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,26 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#include <mtp/cmtptypecompoundbase.h>
+#include <mtp/cmtptypeinterdependentpropdesc.h>
+#include <mtp/cmtptypeobjectinfo.h>
+#include <mtp/cmtptypeobjectpropdesc.h>
+#include <mtp/cmtptypeobjectproplist.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/mtptypesflat.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,26 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#include <mtp/tmtptypeflatbase.h>
+#include <mtp/tmtptypeevent.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/tmtptyperesponse.h>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/mtptypessimple.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,33 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#include <mtp/tmtptypeint8.h>
+#include <mtp/tmtptypeint16.h>
+#include <mtp/tmtptypeint32.h>
+#include <mtp/tmtptypeint64.h>
+#include <mtp/tmtptypeint128.h>
+#include <mtp/tmtptypeuint8.h>
+#include <mtp/tmtptypeuint16.h>
+#include <mtp/tmtptypeuint32.h>
+#include <mtp/tmtptypeuint64.h>
+#include <mtp/tmtptypeuint128.h>
+#include <mtp/tmtptypeguid.h>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/rmtptype.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,92 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef RMTPTYPE_H
+#define RMTPTYPE_H
+
+#include <e32std.h>
+#include <mtp/mmtptype.h>
+
+/**
+Defines a general purpose class for containing, accessing, and manipulating 
+a reference to any MMTPType derived data type. The data type buffer itself 
+resides on the heap and is managed by this class.
+
+By default all MTP simple (signed and unsigned integer), array (signed and 
+unsigned integer), and string types are supported. Support for any other data 
+types can be provided by derived subclasses which provide suitable 
+implementions of the CreateL and Destroy methods.
+
+This class and it's derived subclasses can be freely contained as member 
+variables within any CBase derived class (typically a CMTPTypeCompoundBase 
+derived class). When used as a stack variable the class's CleanupClosePushL
+method should always be used to ensure that the heap storage managed by the 
+class is correctly deallocated.
+
+@publishedPartner
+@released 
+*/
+class RMTPType : public MMTPType
+    {
+public:
+
+    IMPORT_C RMTPType();    
+    IMPORT_C virtual ~RMTPType();
+    
+    IMPORT_C void CleanupClosePushL();
+    IMPORT_C void Close();
+    IMPORT_C void OpenL(TUint aDataType);
+    
+    IMPORT_C MMTPType& Data();
+    
+    //internal API
+    static MMTPType* AllocL(const TUint aDataType);
+    static void Destroy(const TUint aDataType, MMTPType* aType);
+public: // From MMTPType
+
+    IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt NextReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint64 Size() const;
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+    IMPORT_C TInt Validate() const;
+    
+protected:
+    
+    IMPORT_C virtual MMTPType* CreateL(TUint aDataType);
+    IMPORT_C virtual void Destroy(MMTPType* aType);
+    
+private:
+
+//   MMTPType* AllocL(TUint aDataType);
+    
+private: // Owned
+   
+    /**
+    The data type buffer.
+    */
+    MMTPType*   iData;
+    };
+
+#endif // RMTPTYPE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptypedatapair.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,99 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//  
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+#ifndef TMTPTYPEDATAPAIR_H_
+#define TMTPTYPEDATAPAIR_H_
+
+
+#include <mtp/tmtptypeflatbase.h> 
+
+
+/**
+Defines the ObjectHandle-PropertyCode pair or ServiceID-PropertyCode pair. This data pair is stored in a 
+contiguous flat buffer to optimise data transfer to/from the MTP transport 
+layer.
+@publishedPartner
+@released 
+*/
+class TMTPTypeDataPair : public TMTPTypeFlatBase
+    {
+public:
+
+    /**
+    MTP operation response dataset element identifiers.
+    */      
+    enum TElements
+        {
+        /**
+        The identifier of owner: ObjectHandle or ServiceID.
+        */
+        EOwnerHandle, 
+        
+        /**
+        data code: PropertyCode.
+        */
+        EDataCode,
+        
+        /**
+        The number of dataset elements.
+        */
+        ENumElements, 
+        }; 
+    
+public:
+
+    IMPORT_C TMTPTypeDataPair();
+    IMPORT_C TMTPTypeDataPair( const TUint32 aHandle, const TUint16 aCode );
+    IMPORT_C TMTPTypeDataPair(const TMTPTypeDataPair& aPair);    
+    
+public: // From TMTPTypeFlatBase
+
+    IMPORT_C TUint Type() const;
+    
+private: // From TMTPTypeFlatBase
+    
+    const TMTPTypeFlatBase::TElementInfo& ElementInfo(TInt aElementId) const;
+    
+private: 
+   
+    /**
+    The data pair size in bytes.
+    */
+    static const TInt                               KSize = 6;
+    
+    /**
+    The data pair element metadata table content.
+    */
+    static const TMTPTypeFlatBase::TElementInfo     iElementMetaData[];
+    
+    /**
+    The data pair element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The data buffer.
+    */
+    TBuf8<KSize>                                    iBuffer; 
+    };
+
+
+#endif /* TMTPTYPEDATAPAIR_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptypeevent.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,115 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPEEVENT_H
+#define TMTPTYPEEVENT_H
+
+#include <mtp/tmtptypeflatbase.h> 
+
+/**
+Defines the MTP event dataset. This dataset is stored in a contiguous flat 
+buffer to optimise data transfer to/from the MTP transport layer.
+@publishedPartner
+@released 
+*/
+class TMTPTypeEvent : public TMTPTypeFlatBase
+    {
+    
+public: 
+
+    /**
+    MTP event dataset element identifiers.
+    */
+    enum TElements
+        {        
+        /**
+        Event Code.
+        */
+        EEventCode,
+        
+        /**
+        SessionID.
+        */
+        EEventSessionID,
+        
+        /**
+        TransactionID
+        */
+        EEventTransactionID,
+        
+        /**
+        Parameter 1.
+        */
+        EEventParameter1,
+        
+        /**
+        Parameter 2.
+        */
+        EEventParameter2,
+        
+        /**
+        Parameter 3.
+        */
+        EEventParameter3,
+        
+        /**
+        The number of dataset elements.
+        */
+        ENumElements,
+        };
+    
+public:
+
+    IMPORT_C TMTPTypeEvent(); 
+    IMPORT_C TMTPTypeEvent(const TMTPTypeEvent& aEvent);
+    
+public: // From TMTPTypeFlatBase
+    
+    IMPORT_C TUint Type() const;
+    
+private: // From TMTPTypeFlatBase
+    
+    IMPORT_C const TMTPTypeFlatBase::TElementInfo& ElementInfo(TInt aElementId) const;    
+
+private: 
+   
+    /**
+    The dataset size in bytes.
+    */
+    static const TInt                               KSize = 22;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const TMTPTypeFlatBase::TElementInfo     iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The data buffer.
+    */
+    TBuf8<KSize>                                    iBuffer; 
+    };
+
+#endif // TMTPTYPEEVENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptypeflatbase.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,129 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPEFLATBASE_H
+#define TMTPTYPEFLATBASE_H
+
+#include <e32std.h>
+#include <mtp/mmtptype.h>
+#include <mtp/mtptypessimple.h>
+
+
+
+/**
+Defines the MTP flat data types base class. Flat data types are used to
+represent MTP datasets comprising a single contiguous sequence of data
+elements, each of a known type and length. This class implements generic
+flat data type storage management capabilities and is intended for derivation
+by concrete classes which implement specific MTP datasets.
+@publishedPartner
+@released
+*/
+class TMTPTypeFlatBase : public MMTPType
+    {
+public:
+
+    IMPORT_C TMTPTypeFlatBase();
+
+    IMPORT_C virtual void Reset();
+
+    IMPORT_C virtual void GetL(TInt aElementId, MMTPType& aElement) const;
+    IMPORT_C virtual void SetL(TInt aElementId, const MMTPType& aElement);
+
+    IMPORT_C virtual void SetInt8(TInt aElementId, TInt8 aData);
+    IMPORT_C virtual void SetInt16(TInt aElementId, TInt16 aData);
+    IMPORT_C virtual void SetInt32(TInt aElementId, TInt32 aData);
+    IMPORT_C virtual void SetInt64(TInt aElementId, TInt64 aData);
+
+    IMPORT_C virtual void SetUint8(TInt aElementId, TUint8 aData);
+    IMPORT_C virtual void SetUint16(TInt aElementId, TUint16 aData);
+    IMPORT_C virtual void SetUint32(TInt aElementId, TUint32 aData);
+    IMPORT_C virtual void SetUint64(TInt aElementId, TUint64 aData);
+
+    IMPORT_C virtual TInt8 Int8(TInt aElementId) const;
+    IMPORT_C virtual TInt16 Int16(TInt aElementId) const;
+    IMPORT_C virtual TInt32 Int32(TInt aElementId) const;
+    IMPORT_C virtual TInt64 Int64(TInt aElementId) const;
+
+    IMPORT_C virtual TUint8 Uint8(TInt aElementId) const;
+    IMPORT_C virtual TUint16 Uint16(TInt aElementId) const;
+    IMPORT_C virtual TUint32 Uint32(TInt aElementId) const;
+    IMPORT_C virtual TUint64 Uint64(TInt aElementId) const;
+
+	inline TPtr8& DataBuffer()
+    {
+    return iBuffer;
+    }
+
+
+
+public: // From MMTPType
+
+    IMPORT_C virtual TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C virtual TInt NextReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C virtual TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C virtual TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C virtual TUint64 Size() const;
+    IMPORT_C virtual TUint Type() const;
+
+public:
+
+    /**
+    Defines the MTP flat data types element meta data.
+    */
+    struct TElementInfo
+        {
+        /**
+        The element's MTP type identifier.
+        */
+        TInt iType;
+
+        /**
+        The offset (in bytes) of the element data from the start of the managed
+        dataset buffer.
+        */
+        TInt iOffset;
+
+        /**
+        The size (in bytes) of the element data.
+        */
+        TInt iSize;
+        };
+
+protected:
+
+    IMPORT_C virtual void SetBuffer(const TDes8& aBuffer);
+
+	/**
+	Provides the meta data for the specified element.
+	@param aElementId The identifier of the requested element.
+	@return The requested element's meta data.
+	*/
+	virtual const TElementInfo& ElementInfo(TInt aElementId) const = 0;
+
+	//not owned
+	/**
+	The managed MTP dataset buffer.
+	*/
+	TPtr8   iBuffer;
+    };
+
+#endif //TMTPTYPEFLATBASE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptypeguid.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,89 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPEGUID_H
+#define TMTPTYPEGUID_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <mtp/mmtptype.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypeuint128.h>
+
+/**
+Defines the MTP Guid data type.
+@publishedPartner
+@released 
+*/
+class TMTPTypeGuid : public TMTPTypeUint128
+    {
+
+public:
+
+	IMPORT_C TMTPTypeGuid();	
+	IMPORT_C TMTPTypeGuid(const TPtrC8& aData);
+	IMPORT_C TMTPTypeGuid(const TUint64 aData1,const TUint64 aData2);
+    IMPORT_C void Set(const TUint64 aData1,const TUint64 aData2);
+    IMPORT_C TInt SetL(const TDesC& aData);
+    
+private:
+    TInt IsGuidFormat(const TDesC& aData);
+    
+private:
+    /*
+     * The number of Uint16 elements in GUID
+     */
+    static const TUint                               KMTPGUIDUint16Num = 2;
+    
+    /*
+     * The number of Uint8 elements in GUID
+     */
+    static const TUint                               KMTPGUIDUint8Num = 8;
+    
+    /*
+     * GUID struct
+     */
+    typedef struct T_GUID
+        {
+        TUint32 iUint32;
+        TUint16 iUint16[KMTPGUIDUint16Num];
+        TUint8  iByte[KMTPGUIDUint8Num];
+        } TGUID;
+    
+private:
+   
+    /**
+    Least significant 64-bit buffer offset.
+    */
+    //static const TInt           KMTPTypeUint128OffsetLS = 0;
+   
+    /**
+    Most significant 64-bit buffer offset.
+    */
+    //static const TInt           KMTPTypeUint128OffsetMS = 8;
+    
+    /**
+    The data buffer.
+    */
+	//TBuf8<KMTPTypeUINT128Size>  iData;
+    };
+
+#endif // TMTPTYPEGUID_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptypeint128.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,73 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPEINT128_H
+#define TMTPTYPEINT128_H
+
+#include <e32std.h>
+#include <mtp/mmtptype.h>
+#include <mtp/mtpdatatypeconstants.h>
+
+/**
+Defines the MTP signed 128-bit integer data type.
+@publishedPartner
+@released 
+*/
+class TMTPTypeInt128 : public MMTPType
+    {
+
+public:
+
+	IMPORT_C TMTPTypeInt128();	
+	IMPORT_C TMTPTypeInt128(const TPtrC8& aData);
+
+    IMPORT_C void Set(TInt64 aUpperValue, TUint64 aLowerValue);
+    IMPORT_C TUint64 LowerValue() const;
+    IMPORT_C TInt64 UpperValue() const;
+    
+public: // From MMTPType
+
+    IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt NextReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint64 Size() const;
+    IMPORT_C TUint Type() const;
+	
+private:
+   
+    /**
+    Least significant 64-bit buffer offset.
+    */
+    static const TInt           KMTPTypeInt128OffsetLS = 0;
+   
+    /**
+    Most significant 64-bit buffer offset.
+    */
+    static const TInt           KMTPTypeInt128OffsetMS = 8;
+    
+    /**
+    The data buffer.
+    */
+	TBuf8<KMTPTypeINT128Size>   iData;
+    };
+
+#endif // TMTPTYPEINT128_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptypeint16.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,45 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPEINT16_H
+#define TMTPTYPEINT16_H
+
+#include <e32std.h>
+#include <mtp/tmtptypeintbase.h>
+
+/**
+Defines the MTP signed 16-bit integer data type.
+@publishedPartner
+@released 
+*/
+class TMTPTypeInt16 : public TMTPTypeIntBase
+    {
+
+public:
+
+	IMPORT_C TMTPTypeInt16();	
+	IMPORT_C TMTPTypeInt16(TInt16 aData);
+
+    IMPORT_C void Set(TInt16 aValue);
+    IMPORT_C TInt16 Value() const;
+    };
+
+#endif // TMTPTYPEINT16_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptypeint32.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,45 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPEINT32_H
+#define TMTPTYPEINT32_H
+
+#include <e32std.h>
+#include <mtp/tmtptypeintbase.h>
+
+/**
+Defines the MTP signed 32-bit integer data type.
+@publishedPartner
+@released 
+*/
+class TMTPTypeInt32 : public TMTPTypeIntBase
+    {
+
+public:
+
+	IMPORT_C TMTPTypeInt32();	
+	IMPORT_C TMTPTypeInt32(TInt32 aData);	
+
+    IMPORT_C void Set(TInt32 aValue);
+    IMPORT_C TInt32 Value() const;
+    };
+
+#endif // TMTPTYPEINT32_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptypeint64.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,62 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPEINT64_H
+#define TMTPTYPEINT64_H
+
+#include <e32std.h>
+#include <mtp/mmtptype.h>
+
+/**
+Defines the MTP signed 64-bit integer data type.
+@publishedPartner
+@released 
+*/
+class TMTPTypeInt64 : public MMTPType
+    {
+
+public:
+
+	IMPORT_C TMTPTypeInt64();	
+	IMPORT_C TMTPTypeInt64(TInt64 aData);
+	IMPORT_C virtual ~TMTPTypeInt64();
+
+    IMPORT_C void Set(TInt64 aValue);
+    IMPORT_C TInt64 Value() const;
+    
+public: // From MMTPType
+
+    IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt NextReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint64 Size() const;
+    IMPORT_C TUint Type() const;
+	
+private:
+
+    /**
+    The data buffer.
+    */
+	TInt64 iData;
+    };
+
+#endif // TMTPTYPEINT64_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptypeint8.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,45 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPEINT8_H
+#define TMTPTYPEINT8_H
+
+#include <e32std.h>
+#include <mtp/tmtptypeintbase.h>
+
+/**
+Defines the MTP signed 8-bit integer data type.
+@publishedPartner
+@released 
+*/
+class TMTPTypeInt8 : public TMTPTypeIntBase
+    {
+
+public:
+
+	IMPORT_C TMTPTypeInt8();	
+	IMPORT_C TMTPTypeInt8(TInt8 aData);	
+
+    IMPORT_C void Set(TInt8 aValue);
+    IMPORT_C TInt8 Value() const;
+    };
+
+#endif // TMTPTYPEINT8_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptypeintbase.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,70 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPEINTBASE_H
+#define TMTPTYPEINTBASE_H
+
+#include <e32std.h>
+#include <mtp/mmtptype.h>
+
+/**
+Defines the MTP signed integer data type base class for 8 to 32-bit integers.
+This class is intended for derivation.
+@publishedPartner
+@released 
+*/
+class TMTPTypeIntBase : public MMTPType
+    {
+
+public: // From MMTPType
+
+    IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt NextReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint64 Size() const;
+    IMPORT_C TUint Type() const;
+    
+protected:
+
+	IMPORT_C TMTPTypeIntBase(TInt aData, TUint aSize, TInt aType);
+	
+protected:
+
+    /**
+    The data buffer.
+    */
+	TInt    iData;
+	
+private:
+
+	/**
+	The type's size in bytes.
+	*/
+	TUint64 iSize;
+	
+	/**
+	The type's MTP datatype code.
+	*/
+	TUint   iType;
+    };
+
+#endif // TMTPTYPEINTBASE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptypenull.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,53 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPENULL_H
+#define TMTPTYPENULL_H
+
+#include <e32std.h>
+#include <mtp/mmtptype.h>
+
+/**
+Defines the MTP null (zero length) data type base class. 
+@publishedPartner
+@released 
+*/
+class TMTPTypeNull : public MMTPType
+    {    
+public:
+
+    IMPORT_C TMTPTypeNull();
+	IMPORT_C void SetBuffer(const TDes8& aBuffer);
+    
+public: // From MMTPType
+
+    IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt NextReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint64 Size() const;
+    IMPORT_C TUint Type() const;
+    
+private:
+	TPtr8 iNullBuffer;
+    };
+
+#endif //TMTPTYPENULL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptyperequest.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,129 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPEREQUEST_H
+#define TMTPTYPEREQUEST_H
+
+#include <mtp/tmtptypeflatbase.h> 
+
+/**
+Defines the MTP operation request dataset. This dataset is stored in a 
+contiguous flat buffer to optimise data transfer to/from the MTP transport 
+layer.
+@publishedPartner
+@released 
+*/
+class TMTPTypeRequest : public TMTPTypeFlatBase
+    {
+public:
+
+    /**
+    MTP operation request dataset element identifiers.
+    */      
+    enum TElements
+        {
+        /**
+        Operation Code.
+        */
+        ERequestOperationCode,
+        
+        /**
+        SessionID.
+        */
+        ERequestSessionID,
+        
+        /**
+        TransactionID.
+        */
+        ERequestTransactionID,
+        
+        /**
+        Parameter 1.
+        */
+        ERequestParameter1,
+        
+        /**
+        Parameter 2.
+        */
+        ERequestParameter2,
+        
+        /**
+        Parameter 3.
+        */
+        ERequestParameter3,
+        
+        /**
+        Parameter 4.
+        */
+        ERequestParameter4,
+        
+        /**
+        Parameter 5.
+        */
+        ERequestParameter5,
+        
+        /**
+        The number of dataset elements.
+        */
+        ENumElements, 
+        };  
+        
+public:
+
+    IMPORT_C TMTPTypeRequest();
+    
+	IMPORT_C TBool operator==(const TMTPTypeRequest& aRequest) const;
+	IMPORT_C TBool operator!=(const TMTPTypeRequest& aRequest) const;
+    IMPORT_C TMTPTypeRequest(const TMTPTypeRequest& aRequest);
+    
+public: // From TMTPTypeFlatBase
+    
+    IMPORT_C TUint Type() const;
+    
+private: // From TMTPTypeFlatBase
+    
+    IMPORT_C const TMTPTypeFlatBase::TElementInfo& ElementInfo(TInt aElementId) const; 
+
+private: 
+   
+    /**
+    The dataset size in bytes.
+    */
+    static const TInt                               KSize = 30;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const TMTPTypeFlatBase::TElementInfo     iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The data buffer.
+    */
+    TBuf8<KSize>                                    iBuffer;
+    };
+
+#endif //TMTPTYPEREQUEST_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptyperesponse.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,126 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPERESPONSE_H
+#define TMTPTYPERESPONSE_H 
+
+#include <mtp/tmtptypeflatbase.h> 
+
+/**
+Defines the MTP operation response dataset. This dataset is stored in a 
+contiguous flat buffer to optimise data transfer to/from the MTP transport 
+layer.
+@publishedPartner
+@released 
+*/
+class TMTPTypeResponse : public TMTPTypeFlatBase
+    {
+public:
+
+    /**
+    MTP operation response dataset element identifiers.
+    */      
+    enum TElements
+        {
+        /**
+        ResponseCode.
+        */
+        EResponseCode, 
+        
+        /**
+        SessionID.
+        */
+        EResponseSessionID, 
+        
+        /**
+        TransactionID
+        */
+        EResponseTransactionID, 
+        
+        /**
+        Parameter 1.
+        */
+        EResponseParameter1, 
+        
+        /**
+        Parameter 2.
+        */
+        EResponseParameter2, 
+        
+        /**
+        Parameter 3.
+        */
+        EResponseParameter3, 
+        
+        /**
+        Parameter 4.
+        */
+        EResponseParameter4, 
+        
+        /**
+        Parameter 5.
+        */
+        EResponseParameter5, 
+        
+        /**
+        The number of dataset elements.
+        */
+        ENumElements, 
+        }; 
+    
+public:
+
+    IMPORT_C TMTPTypeResponse();
+    IMPORT_C TMTPTypeResponse(const TMTPTypeResponse& aResponse);
+    
+public: // From TMTPTypeFlatBase
+
+    IMPORT_C TUint Type() const;
+    
+private: // From TMTPTypeFlatBase
+    
+    IMPORT_C const TMTPTypeFlatBase::TElementInfo& ElementInfo(TInt aElementId) const;
+    
+private: 
+   
+    /**
+    The dataset size in bytes.
+    */
+    static const TInt                               KSize = 30;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const TMTPTypeFlatBase::TElementInfo     iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The data buffer.
+    */
+    TBuf8<KSize>                                    iBuffer; 
+    };
+
+#endif // TMTPTYPERESPONSE_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptypeuint128.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,79 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPEUINT128_H
+#define TMTPTYPEUINT128_H
+
+#include <e32std.h>
+#include <mtp/mmtptype.h>
+#include <mtp/mtpdatatypeconstants.h>
+
+/**
+Defines the MTP unsigned 128-bit integer data type.
+@publishedPartner
+@released 
+*/
+class TMTPTypeUint128 : public MMTPType
+    {
+
+public:
+
+	IMPORT_C TMTPTypeUint128();	
+	IMPORT_C TMTPTypeUint128(const TPtrC8& aData);
+	IMPORT_C TMTPTypeUint128(const TUint64 aUpperValue, const TUint64 aLowerValue);
+
+    IMPORT_C void Set(TUint64 aUpperValue, TUint64 aLowerValue);
+    IMPORT_C TUint64 LowerValue() const;
+    IMPORT_C TUint64 UpperValue() const;
+    
+public: // From MMTPType
+
+    IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt NextReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint64 Size() const;
+    IMPORT_C TUint Type() const;
+    
+    IMPORT_C TBool Equal(const TMTPTypeUint128& aR) const;
+    IMPORT_C TInt Compare(const TMTPTypeUint128& aR) const;
+    IMPORT_C TInt Compare(const TUint64 aRUpper, const TUint64 aRLower) const;
+
+private:
+   
+    /**
+    Least significant 64-bit buffer offset.
+    */
+    static const TInt           KMTPTypeUint128OffsetLS = 0;
+   
+    /**
+    Most significant 64-bit buffer offset.
+    */
+    static const TInt           KMTPTypeUint128OffsetMS = 8;
+
+protected:
+    /**
+    The data buffer.
+    */
+	TBuf8<KMTPTypeUINT128Size>  iData;
+    };
+
+#endif // TMTPTYPEUINT128_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptypeuint16.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,45 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPEUINT16_H
+#define TMTPTYPEUINT16_H
+
+#include <e32std.h>
+#include <mtp/tmtptypeuintbase.h>
+
+/**
+Defines the MTP unsigned 16-bit integer data type.
+@publishedPartner
+@released 
+*/
+class TMTPTypeUint16 : public TMTPTypeUintBase
+    {
+
+public:
+
+	IMPORT_C TMTPTypeUint16();	
+	IMPORT_C TMTPTypeUint16(TUint16 aData);
+
+    IMPORT_C void Set(TUint16 aValue);
+    IMPORT_C TUint16 Value() const;
+    };
+
+#endif // TMTPTYPEUINT16_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptypeuint32.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,45 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPEUINT32_H
+#define TMTPTYPEUINT32_H
+
+#include <e32std.h>
+#include <mtp/tmtptypeuintbase.h>
+
+/**
+Defines the MTP signed 32-bit integer data type.
+@publishedPartner
+@released
+*/
+class TMTPTypeUint32 : public TMTPTypeUintBase
+    {
+
+public:
+
+	IMPORT_C TMTPTypeUint32();	
+	IMPORT_C TMTPTypeUint32(TUint32 aData);	
+
+    IMPORT_C void Set(TUint32 aValue);
+    IMPORT_C TUint32 Value() const;
+    };
+
+#endif // TMTPTYPEUINT32_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptypeuint64.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,61 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPEUINT64_H
+#define TMTPTYPEUINT64_H
+
+#include <e32std.h>
+#include <mtp/mmtptype.h>
+
+/**
+Defines the MTP unsigned 64-bit integer data type.
+@publishedPartner
+@released
+*/
+class TMTPTypeUint64 : public MMTPType
+    {
+
+public:
+
+	IMPORT_C TMTPTypeUint64();	
+	IMPORT_C TMTPTypeUint64(TUint64 aData);
+
+    IMPORT_C void Set(TUint64 aValue);
+    IMPORT_C TUint64 Value() const;
+    
+public: // From MMTPType
+
+    IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt NextReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint64 Size() const;
+    IMPORT_C TUint Type() const;	
+	
+private:
+
+    /**
+    The data buffer.
+    */
+	TUint64 iData;
+    };
+
+#endif // TMTPTYPEUINT64_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptypeuint8.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,45 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPEUINT8_H
+#define TMTPTYPEUINT8_H
+
+#include <e32std.h>
+#include <mtp/tmtptypeuintbase.h>
+
+/**
+Defines the MTP unsigned 8-bit integer data type.
+@publishedPartner
+@released
+*/
+class TMTPTypeUint8 : public TMTPTypeUintBase
+    {
+
+public:
+
+	IMPORT_C TMTPTypeUint8();	
+	IMPORT_C TMTPTypeUint8(TUint8 aData);
+
+    IMPORT_C void Set(TUint8 aValue);
+    IMPORT_C TUint8 Value() const;
+    };
+
+#endif // TMTPTYPEUINT8_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/interface/tmtptypeuintbase.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,69 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef TMTPTYPEUINTBASE_H
+#define TMTPTYPEUINTBASE_H
+
+#include <e32std.h>
+#include <mtp/mmtptype.h>
+
+/**
+Defines the MTP unsigned integer data type base class for 8 to 32-bit integers.
+This class is intended for derivation.
+@publishedPartner
+@released
+*/
+class TMTPTypeUintBase : public MMTPType
+    {
+public: // From MMTPType
+
+    IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt NextReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+    IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+    IMPORT_C TUint64 Size() const;
+    IMPORT_C TUint Type() const;
+    
+protected:
+
+	IMPORT_C TMTPTypeUintBase(TUint aData, TUint aSize, TInt aType);
+	
+protected:
+
+    /**
+    The data buffer.
+    */
+	TUint   iData;
+	
+private:
+
+	/**
+	The type's size in bytes.
+	*/
+	TUint64 iSize;
+	
+	/**
+	The type's MTP datatype code.
+	*/
+	TUint   iType;
+    };
+
+#endif // TMTPTYPEUINTBASE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypearray.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,979 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/cmtptypearray.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include "mtpdatatypespanic.h"
+
+// Array type constants.
+const TUint KMTPNumElementsLen(sizeof(TUint32));
+const TUint KMTPNumElementsOffset(0);
+const TUint KMTPFirstElementOffset(KMTPNumElementsLen);
+const TUint KMTPGranularity(8);
+
+/**
+MTP array data type factory method. This method is used to create an empty MTP
+array.
+@param aElementType The MTP type identifier of the elements contained in the 
+array.
+@param aElementSize The size (in bytes) of the elements contained in the array.
+@return A pointer to an empty MTP array data type. Ownership IS transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/   
+EXPORT_C CMTPTypeArray* CMTPTypeArray::NewL(TInt aElementType, TUint aElementSize)
+    {
+    return NewL(EMTPTypeArray, aElementType, aElementSize);
+    }
+
+/**
+MTP array data type factory method. This method is used to create an empty MTP
+array. A pointer to the MTP array data type is placed on the cleanup stack.
+@param aElementType The MTP type identifier of the elements contained in the 
+array.
+@param aElementSize The size (in bytes) of the elements which contained in 
+array.
+@return A pointer to an empty MTP array data type. Ownership IS transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/  
+EXPORT_C CMTPTypeArray* CMTPTypeArray::NewLC(TInt aElementType, TUint aElementSize)
+    {
+    return CMTPTypeArray::NewLC(EMTPTypeArray, aElementType, aElementSize);
+    }
+
+/**
+MTP array data type factory method. This method is used to create an empty MTP
+array of the specified MTP array type.
+@param aArrayType The MTP type identifier to be assigned to the array.
+@param aElementType The MTP type identifier of the elements contained in the 
+array.
+@param aElementSize The size (in bytes) of the elements contained in the array.
+@return A pointer to an empty MTP array data type. Ownership IS transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/   
+EXPORT_C CMTPTypeArray* CMTPTypeArray::NewL(TInt aArrayType, TInt aElementType, TUint aElementSize)
+    {
+    CMTPTypeArray* self = NewLC(aArrayType, aElementType, aElementSize);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+MTP array data type factory method. This method is used to create an empty MTP
+array of the specified MTP array type. A pointer to the MTP array data type is 
+placed on the cleanup stack.
+@param aArrayType The MTP type identifier to be assigned to the array.
+@param aElementType The MTP type identifier of the elements contained in the 
+array.
+@param aElementSize The size (in bytes) of the elements which contained in 
+array.
+@return A pointer to an empty MTP array data type. Ownership IS transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/  
+EXPORT_C CMTPTypeArray* CMTPTypeArray::NewLC(TInt aArrayType, TInt aElementType, TUint aElementSize)
+    {
+    CMTPTypeArray* self = new(ELeave) CMTPTypeArray(aArrayType, aElementType, aElementSize);
+    CleanupStack::PushL(self);
+    self->ConstructL(KMTPGranularity);
+    return self;
+    }
+    
+/**
+MTP simple data type array factory method. This method is used to create
+an empty MTP array of the specified MTP simple data type.
+@param aArrayType The array data type indentifier datacode. This must be in 
+the range EMTPTypeFirstSimpleArrayType ... EMTPTypeLastSimpleArrayType.
+@return A pointer to an empty MTP array data type. Ownership IS transfered.
+@leave KErrArgument, if aArrayType is not in the range 
+EMTPTypeFirstSimpleArrayType ... EMTPTypeLastSimpleArrayType.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/ 
+EXPORT_C CMTPTypeArray* CMTPTypeArray::NewL(TInt aArrayType)
+    {
+    CMTPTypeArray* self = NewLC(aArrayType);
+    CleanupStack::Pop(self);
+    return self;   
+    } 
+
+/**
+MTP simple data type array factory method. This method is used to create
+an MTP array of the specified MTP simple data type with the specified element 
+content.
+@param aArrayType The array data type indentifier datacode. This must be in 
+the range EMTPTypeFirstSimpleArrayType ... EMTPTypeLastSimpleArrayType.
+@param aElements The initial set of element values.
+@return A pointer to an empty MTP array data type. Ownership IS transfered.
+@leave KErrArgument, if aArrayType is not in the range 
+EMTPTypeFirstSimpleArrayType ... EMTPTypeLastSimpleArrayType.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/ 
+EXPORT_C CMTPTypeArray* CMTPTypeArray::NewL(TInt aArrayType, const RArray<TInt>& aElements)
+    {
+    CMTPTypeArray* self = NewLC(aArrayType, aElements);
+    CleanupStack::Pop(self);
+    return self; 
+    }
+
+/**
+MTP simple data type array factory method. This method is used to create
+an MTP array of the specified MTP simple data type with the specified element 
+content.
+@param aArrayType The array data type indentifier datacode. This must be in 
+the range EMTPTypeFirstSimpleArrayType ... EMTPTypeLastSimpleArrayType.
+@param aElements The initial set of element values.
+@return A pointer to an empty MTP array data type. Ownership IS transfered.
+@leave KErrArgument, if aArrayType is not in the range 
+EMTPTypeFirstSimpleArrayType ... EMTPTypeLastSimpleArrayType.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/ 
+EXPORT_C CMTPTypeArray* CMTPTypeArray::NewL(TInt aArrayType, const RArray<TUint>& aElements)
+    {
+    CMTPTypeArray* self = NewLC(aArrayType, aElements);
+    CleanupStack::Pop(self);
+    return self; 
+    }
+
+/**
+MTP AINT64 array factory method. This method is used to create an MTP AINT64 
+array with the specified element content.
+@param aElements The initial set of element values.
+@return A pointer to an empty MTP array data type. Ownership IS transfered.
+@leave KErrArgument, if aArrayType is not in the range 
+EMTPTypeFirstSimpleArrayType ... EMTPTypeLastSimpleArrayType.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/ 
+EXPORT_C CMTPTypeArray* CMTPTypeArray::NewL(const RArray<TInt64>& aElements)
+    {
+    CMTPTypeArray* self = NewLC(aElements);
+    CleanupStack::Pop(self); 
+    return self; 
+    }
+
+/**
+MTP AUINT64 array factory method. This method is used to create an MTP AINT64 
+array with the specified element content.
+@param aElements The initial set of element values.
+@return A pointer to an empty MTP array data type. Ownership IS transfered.
+@leave KErrArgument, if aArrayType is not in the range 
+EMTPTypeFirstSimpleArrayType ... EMTPTypeLastSimpleArrayType.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/ 
+EXPORT_C CMTPTypeArray* CMTPTypeArray::NewL(const RArray<TUint64>& aElements)
+    {
+    CMTPTypeArray* self = NewLC(aElements);
+    CleanupStack::Pop(self);
+    return self; 
+    }
+    
+/**
+MTP simple data type array factory method. This method is used to create
+an empty MTP array of the specified MTP simple data type. A pointer to the MTP 
+array data type is placed on the cleanup stack.
+@param aArrayType The array data type indentifier datacode. This must be in 
+the range EMTPTypeFirstSimpleArrayType ... EMTPTypeLastSimpleArrayType.
+@return A pointer to an empty MTP array data type. Ownership IS transfered.
+@leave KErrArgument, if aArrayType is not in the range 
+EMTPTypeFirstSimpleArrayType ... EMTPTypeLastSimpleArrayType.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/ 
+EXPORT_C CMTPTypeArray* CMTPTypeArray::NewLC(TInt aArrayType)
+    {
+    TInt    type(aArrayType);
+    TUint   size(0);
+    SimpleArrayTypeMetaDataL(aArrayType, type, size);
+    CMTPTypeArray* self = new(ELeave) CMTPTypeArray(aArrayType, type, size);
+    CleanupStack::PushL(self);
+    self->ConstructL(KMTPGranularity);
+    return self;   
+    }
+
+/**
+MTP simple data type array factory method. This method is used to create
+an MTP array of the specified MTP simple data type with the specified element 
+content. A pointer to the MTP array data type is placed on the cleanup stack.
+@param aArrayType The array data type indentifier datacode. This must be in 
+the range EMTPTypeFirstSimpleArrayType ... EMTPTypeLastSimpleArrayType.
+@param aElements The initial set of element values.
+@return A pointer to an empty MTP array data type. Ownership IS transfered.
+@leave KErrArgument, if aArrayType is not in the range 
+EMTPTypeFirstSimpleArrayType ... EMTPTypeLastSimpleArrayType.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/ 
+EXPORT_C CMTPTypeArray* CMTPTypeArray::NewLC(TInt aArrayType, const RArray<TInt>& aElements)
+    {
+    TInt    type(aArrayType);
+    TUint   size(0);
+    SimpleArrayTypeMetaDataL(aArrayType, type, size);
+    CMTPTypeArray* self = new(ELeave) CMTPTypeArray(aArrayType, type, size);
+    CleanupStack::PushL(self);
+    
+    TUint count(aElements.Count());
+    self->ConstructL(count);
+    
+    for (TUint i(0); (i < count); i++)
+        {
+        self->AppendIntL(aElements[i]);
+        }
+    
+    return self; 
+    }
+
+/**
+MTP simple data type array factory method. This method is used to create
+an MTP array of the specified MTP simple data type with the specified element 
+content. A pointer to the MTP array data type is placed on the cleanup stack.
+@param aArrayType The array data type indentifier datacode. This must be in 
+the range EMTPTypeFirstSimpleArrayType ... EMTPTypeLastSimpleArrayType.
+@param aElements The initial set of element values.
+@return A pointer to an empty MTP array data type. Ownership IS transfered.
+@leave KErrArgument, if aArrayType is not in the range 
+EMTPTypeFirstSimpleArrayType ... EMTPTypeLastSimpleArrayType.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/ 
+EXPORT_C CMTPTypeArray* CMTPTypeArray::NewLC(TInt aArrayType, const RArray<TUint>& aElements)
+    {
+    TInt    type(aArrayType);
+    TUint   size(0);
+    SimpleArrayTypeMetaDataL(aArrayType, type, size);
+    CMTPTypeArray* self = new(ELeave) CMTPTypeArray(aArrayType, type, size);
+    CleanupStack::PushL(self);
+    
+    TUint count(aElements.Count());
+    self->ConstructL(count);
+    
+    for (TUint i(0); (i < count); i++)
+        {
+        self->AppendUintL(aElements[i]);
+        }
+    
+    return self; 
+    }
+
+/**
+MTP AINT64 array factory method. This method is used to create an MTP AINT64 
+array with the specified element content. A pointer to the MTP array data type 
+is placed on the cleanup stack.
+@param aElements The initial set of element values.
+@return A pointer to an empty MTP array data type. Ownership IS transfered.
+@leave KErrArgument, if aArrayType is not in the range 
+EMTPTypeFirstSimpleArrayType ... EMTPTypeLastSimpleArrayType.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/ 
+EXPORT_C CMTPTypeArray* CMTPTypeArray::NewLC(const RArray<TInt64>& aElements)
+    {
+    TInt    type(EMTPTypeINT64);
+    TUint   size(0);
+    SimpleArrayTypeMetaDataL(EMTPTypeAINT64, type, size);
+    CMTPTypeArray* self = new(ELeave) CMTPTypeArray(EMTPTypeAINT64, type, size);
+    CleanupStack::PushL(self);
+    
+    TUint count(aElements.Count());
+    self->ConstructL(count);
+    
+    for (TUint i(0); (i < count); i++)
+        {
+        self->AppendInt64L(aElements[i]);
+        }
+    
+    return self; 
+    }
+
+/**
+MTP AUINT64 array factory method. This method is used to create an MTP AUINT64 
+array with the specified element content. A pointer to the MTP array data type 
+is placed on the cleanup stack.
+@param aElements The initial set of element values.
+@return A pointer to an empty MTP array data type. Ownership IS transfered.
+@leave KErrArgument, if aArrayType is not in the range 
+EMTPTypeFirstSimpleArrayType ... EMTPTypeLastSimpleArrayType.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/ 
+EXPORT_C CMTPTypeArray* CMTPTypeArray::NewLC(const RArray<TUint64>& aElements)
+    {
+    TInt    type(EMTPTypeUINT64);
+    TUint   size(0);
+    SimpleArrayTypeMetaDataL(EMTPTypeAUINT64, type, size);
+    CMTPTypeArray* self = new(ELeave) CMTPTypeArray(EMTPTypeAUINT64, type, size);
+    CleanupStack::PushL(self);
+    
+    TUint count(aElements.Count());
+    self->ConstructL(count);
+    
+    for (TUint i(0); (i < count); i++)
+        {
+        self->AppendUint64L(aElements[i]);
+        }
+    
+    return self; 
+    }
+
+/**
+Destructor
+*/
+EXPORT_C CMTPTypeArray::~CMTPTypeArray()
+    {
+    iBuffer.Close();    
+    }
+    
+/**
+Provides the MTP identifier of the elements contained in the array.
+@return The MTP identifier of the elements contained in the array.
+*/ 
+EXPORT_C TInt CMTPTypeArray::ElementType() const
+    {
+    return iElementType;    
+    }
+    
+/**
+Provides the number of elements contained in the MTP array.
+@return The number of elements contained in the MTP array.
+*/ 
+EXPORT_C TUint32 CMTPTypeArray::NumElements() const
+    {
+    return *(reinterpret_cast<const TUint32*>(&iBuffer[KMTPNumElementsOffset]));
+    }
+
+/**
+Appends the specified element to the end of the MTP array.
+@param aElement The element to be appended to the MTP array.
+@leave One of the system wide error codes, if a processing failure occurs.
+@panic MTPDataTypes 3, if aElement does not match the MTP type of the elements
+contained in the array.
+*/
+EXPORT_C void CMTPTypeArray::AppendL(const MMTPType& aElement)
+    {    
+    __ASSERT_ALWAYS((aElement.Type() == iElementType), Panic(EMTPTypeIdMismatch));
+    const TUint index(NumElements());
+    TUint32 numElements(index + 1);
+    
+    if (iBuffer.MaxLength() < BufferSize(numElements))
+        {
+        ReAllocBufferL(numElements);
+        }
+        
+    TBool complete(EFalse);
+    TUint offset(Offset(index));
+    TPtrC8 src;
+    const TUint startOffset(offset);
+    
+    TInt err(aElement.FirstReadChunk(src));
+    while (((err == KMTPChunkSequenceCompletion) || (err == KErrNone)) && (!complete))
+        {
+        __ASSERT_ALWAYS(((offset - startOffset) <= iElementSize), Panic(EMTPTypeSizeMismatch));
+        memcpy(&iBuffer[offset], src.Ptr(), src.Length());
+        offset += src.Length();
+        
+        complete = (err == KMTPChunkSequenceCompletion);
+        if (!complete)
+            {
+            err = aElement.NextReadChunk(src);                
+            } 
+        }
+        
+    if (err != KMTPChunkSequenceCompletion)
+        {
+        User::Leave(err);            
+        }
+        
+    SetNumElements(numElements);
+    }
+
+/**
+Appends the specified elements to the end of the MTP array. The array 
+element type MUST be one of the MTP INT8, INT16, or INT32 types.
+@param aElements The elements to be appended to the MTP array.
+@leave One of the system wide error codes, if a processing failure occurs.
+@panic MTPDataTypes 3, if aElement does not match the MTP array's element type.
+*/   
+EXPORT_C void CMTPTypeArray::AppendL(const RArray<TInt>& aElements)
+    {
+    TUint count(aElements.Count());
+    for (TUint i(0); (i < count); i++)
+        {
+        AppendIntL(aElements[i]);
+        }
+    }
+
+/**
+Appends the specified elements to the end of the MTP array. The array 
+element type MUST be one of the MTP UINT8, UINT16, or UINT32 types.
+@param aElements The elements to be appended to the MTP array.
+@leave One of the system wide error codes, if a processing failure occurs.
+@panic MTPDataTypes 3, if aElement does not match the MTP array's element type.
+*/    
+EXPORT_C void CMTPTypeArray::AppendL(const RArray<TUint>& aElements)
+    {
+    TUint count(aElements.Count());
+    for (TUint i(0); (i < count); i++)
+        {
+        AppendUintL(aElements[i]);
+        }
+    }
+
+/**
+Appends the specified elements to the end of the MTP array. The array 
+element type MUST be of the MTP INT64 type.
+@param aElements The elements to be appended to the MTP array.
+@leave One of the system wide error codes, if a processing failure occurs.
+@panic MTPDataTypes 3, if aElement does not match the MTP array's element type.
+*/   
+EXPORT_C void CMTPTypeArray::AppendL(const RArray<TInt64>& aElements)
+    {
+    TUint count(aElements.Count());
+    for (TUint i(0); (i < count); i++)
+        {
+        AppendInt64L(aElements[i]);
+        }
+    }
+
+/**
+Appends the specified elements to the end of the MTP array. The array 
+element type MUST be of the MTP UINT64 type.
+@param aElements The elements to be appended to the MTP array.
+@leave One of the system wide error codes, if a processing failure occurs.
+@panic MTPDataTypes 3, if aElement does not match the MTP array's element type.
+*/
+EXPORT_C void CMTPTypeArray::AppendL(const RArray<TUint64>& aElements)
+    {
+    TUint count(aElements.Count());
+    for (TUint i(0); (i < count); i++)
+        {
+        AppendUint64L(aElements[i]);
+        }
+    }
+
+/**
+Appends the specified element to the end of the MTP array. The array 
+element type MUST be one of the MTP INT8, INT16, or INT32 types.
+@param aElement The element to be appended to the MTP array.
+@leave One of the system wide error codes, if a processing failure occurs.
+@panic MTPDataTypes 3, if aElement does not match the MTP array's element type.
+*/
+EXPORT_C void CMTPTypeArray::AppendIntL(TInt aElement)
+    {
+    __ASSERT_ALWAYS(((iElementType == EMTPTypeINT8) || (iElementType == EMTPTypeINT16) || (iElementType == EMTPTypeINT32)), Panic(EMTPTypeIdMismatch));
+    // Relies on Symbian OS little-endianess.
+    AppendL(&aElement);
+    }
+
+/**
+Appends the specified element to the end of the MTP array. The array 
+element type MUST be one of the MTP UINT8, UINT16, or UINT32 types.
+@param aElement The element to be appended to the MTP array.
+@leave One of the system wide error codes, if a processing failure occurs.
+@panic MTPDataTypes 3, if aElement does not match the MTP array's element type.
+*/
+EXPORT_C void CMTPTypeArray::AppendUintL(TUint aElement)
+    {  
+    __ASSERT_ALWAYS(((iElementType == EMTPTypeUINT8) || (iElementType == EMTPTypeUINT16) || (iElementType == EMTPTypeUINT32)), Panic(EMTPTypeIdMismatch));
+    // Relies on Symbian OS little-endianess.
+    AppendL(&aElement);  
+    }
+
+/**
+Appends the specified element to the end of the MTP array. The array 
+element type MUST be of the MTP INT64 type.
+@param aElement The element to be appended to the MTP array.
+@leave One of the system wide error codes, if a processing failure occurs.
+@panic MTPDataTypes 3, if aElement does not match the MTP array's element type.
+*/
+EXPORT_C void CMTPTypeArray::AppendInt64L(TInt64 aElement)
+    {    
+    __ASSERT_ALWAYS((iElementType == EMTPTypeINT64) ,Panic(EMTPTypeIdMismatch));
+    AppendL(&aElement);
+    }
+
+/**
+Appends the specified element to the end of the MTP array. The array 
+element type MUST be of the MTP UINT64 type.
+@param aElement The element to be appended to the MTP array.
+@leave One of the system wide error codes, if a processing failure occurs.
+@panic MTPDataTypes 3, if aElement does not match the MTP array's element type.
+*/
+EXPORT_C void CMTPTypeArray::AppendUint64L(TUint64 aElement)
+    {    
+    __ASSERT_ALWAYS((iElementType == EMTPTypeUINT64) ,Panic(EMTPTypeIdMismatch));
+    AppendL(&aElement);
+    }
+
+/**
+Provides a copy of the MTP element at the specified array index.
+@param aIndex The index in the MTP array of the required element.
+@param aElement On completion, a copy of the required element.
+@leave One of the system wide error codes, if a processing failure occurs.
+@panic MTPDataTypes 2, if aIndex is greater than or equal to the number of 
+objects currently contained in the array.
+@panic MTPDataTypes 3, if aElement does not match the MTP type of the elements
+contained in the array.
+@panic MTPDataTypes 4, if aElement's size does not match that of the elements
+contained in the array.
+*/
+EXPORT_C void CMTPTypeArray::ElementL(TUint aIndex, MMTPType& aElement) const
+    {
+    __ASSERT_ALWAYS((aIndex < NumElements()), Panic(EMTPTypeBoundsError));
+    __ASSERT_ALWAYS((aElement.Type() == iElementType), Panic(EMTPTypeIdMismatch));
+    __ASSERT_ALWAYS((aElement.Size() == iElementSize), Panic(EMTPTypeSizeMismatch));
+    
+    TBool commit(aElement.CommitRequired());
+    TBool complete(EFalse);
+    TPtr8 dest(NULL, 0);
+    TInt err(aElement.FirstWriteChunk(dest));
+    TUint offset(Offset(aIndex));
+    
+    while (((err == KMTPChunkSequenceCompletion) || (err == KErrNone)) && (!complete))
+        {
+        dest.Copy(&iBuffer[offset], dest.MaxLength());
+        offset += dest.MaxLength();
+        
+        if (commit)
+            {
+            aElement.CommitChunkL(dest);
+            }
+        
+        complete = (err == KMTPChunkSequenceCompletion);
+        if (!complete)
+            {
+            err = aElement.NextWriteChunk(dest);
+            }
+        }
+        
+    if (err != KMTPChunkSequenceCompletion)
+        {
+        User::Leave(err);            
+        }
+    }
+
+/**
+Provides a copy of the MTP element at the specified array index. The array 
+element type MUST be one of the MTP INT8, INT16, or INT32 types.
+@param aIndex The index in the MTP array of the required element.
+@panic MTPDataTypes 2, if aIndex is greater than or equal to the number of 
+objects currently contained in the array.
+@panic MTPDataTypes 3, if aElement does not match the MTP array's element type.
+@return aElement On completion, a copy of the required element.
+*/
+EXPORT_C TInt CMTPTypeArray::ElementInt(TUint aIndex) const
+    {
+    __ASSERT_ALWAYS(((iElementType == EMTPTypeINT8) || (iElementType == EMTPTypeINT16) || (iElementType == EMTPTypeINT32)), Panic(EMTPTypeIdMismatch));
+    // Relies on Symbian OS little-endianess.
+    TInt ret(0);
+    Element(aIndex, &ret);
+    return ret;
+    }
+
+/**
+Provides a copy of the MTP element at the specified array index. The array 
+element type MUST be one of the MTP UINT8, UINT16, or UINT32 types.
+@param aIndex The index in the MTP array of the required element.
+@panic MTPDataTypes 2, if aIndex is greater than or equal to the number of 
+objects currently contained in the array.
+@panic MTPDataTypes 3, if aElement does not match the MTP array's element type.
+@return aElement On completion, a copy of the required element.
+*/
+EXPORT_C TUint CMTPTypeArray::ElementUint(TUint aIndex) const
+    {
+    __ASSERT_ALWAYS(((iElementType == EMTPTypeUINT8) || (iElementType == EMTPTypeUINT16) || (iElementType == EMTPTypeUINT32)), Panic(EMTPTypeIdMismatch));
+    // Relies on Symbian OS little-endianess.
+    TUint ret(0);
+    Element(aIndex, &ret);
+    return ret;
+    }
+
+/**
+Provides a copy of the MTP element at the specified array index. The array 
+element type MUST be of the MTP INT64 type.
+@param aIndex The index in the MTP array of the required element.
+@panic MTPDataTypes 2, if aIndex is greater than or equal to the number of 
+objects currently contained in the array.
+@panic MTPDataTypes 3, if aElement does not match the MTP array's element type.
+@return aElement On completion, a copy of the required element.
+*/
+EXPORT_C TInt64 CMTPTypeArray::ElementInt64(TUint aIndex) const
+    {
+    __ASSERT_ALWAYS((iElementType == EMTPTypeINT64) ,Panic(EMTPTypeIdMismatch));
+    TInt64 ret(0);
+    Element(aIndex, &ret);
+    return ret;
+    }
+
+/**
+Provides a copy of the MTP element at the specified array index. The array 
+element type MUST be of the MTP UINT64 type.
+@param aIndex The index in the MTP array of the required element.
+@panic MTPDataTypes 2, if aIndex is greater than or equal to the number of 
+objects currently contained in the array.
+@panic MTPDataTypes 3, if aElement does not match the MTP array's element type.
+@return aElement On completion, a copy of the required element.
+*/
+EXPORT_C TUint64 CMTPTypeArray::ElementUint64(TUint aIndex) const
+    {
+    __ASSERT_ALWAYS((iElementType == EMTPTypeUINT64) ,Panic(EMTPTypeIdMismatch));
+    TUint64 ret(0);
+    Element(aIndex, &ret);
+    return ret;
+    }
+
+/**
+Provides a copy of the MTP array's element content. The array element type MUST
+be one of the MTP INT8, INT16, or INT32 types.
+@param aElements On completion, a copy of the MTP array's element content.
+@panic MTPDataTypes 3, if aElement does not match the MTP array's element type.
+*/
+EXPORT_C void CMTPTypeArray::Array(RArray<TInt>& aElements) const
+    {
+    // Clear the array    
+    aElements.Close();
+
+    TUint numElements(NumElements());
+    for (TUint i(0); (i < numElements); i++)
+        {
+        aElements.Append(ElementInt(i));
+        }
+    }
+
+/**
+Provides a copy of the MTP array's element content. The array element type MUST
+be one of the MTP UINT8, UINT16, or UINT32 types.
+@param aElements On completion, a copy of the MTP array's element content.
+@panic MTPDataTypes 3, if aElement does not match the MTP array's element type.
+*/
+EXPORT_C void CMTPTypeArray::Array(RArray<TUint>& aElements) const
+    {
+    // Clear the array    
+    aElements.Close();
+
+    TUint numElements(NumElements());
+    for (TUint i(0); (i < numElements); i++)
+        {
+        aElements.Append(ElementUint(i));
+        }
+    }
+
+/**
+Provides a copy of the MTP array's element content. The array element type MUST
+be of the MTP INT64 type.
+@param aElements On completion, a copy of the MTP array's element content.
+@panic MTPDataTypes 3, if aElement does not match the MTP array's element type.
+*/
+EXPORT_C void CMTPTypeArray::Array(RArray<TInt64>& aElements) const
+    {
+    // Clear the array    
+    aElements.Close();
+
+    TUint numElements(NumElements());
+    for (TUint i(0); (i < numElements); i++)
+        {
+        aElements.Append(ElementInt64(i));
+        }
+    }
+
+/**
+Provides a copy of the MTP array's element content. The array element type MUST
+be of the MTP UINT64 type.
+@param aElements On completion, a copy of the MTP array's element content.
+@panic MTPDataTypes 3, if aElement does not match the MTP array's element type.
+*/
+EXPORT_C void CMTPTypeArray::Array(RArray<TUint64>& aElements) const
+    {
+    // Clear the array    
+    aElements.Close();
+
+    TUint numElements(NumElements());
+    for (TUint i(0); (i < numElements); i++)
+        {
+        aElements.Append(ElementUint64(i));
+        }
+    }
+
+EXPORT_C void CMTPTypeArray::ToDes( TDes8& aRetDes ) const
+    {  
+    TInt retSize = aRetDes.MaxSize();
+    if( 0 == retSize )
+       {
+       return ;
+       }
+    
+    TInt length = NumElements() * iElementSize ;
+    if(retSize < length)
+        length = retSize;
+    
+    TPtrC8 ptrL = iBuffer.Left( length + KMTPNumElementsLen );
+    TPtrC8 ptr = ptrL.Right(length);
+    aRetDes.Copy(ptr);
+    }
+
+
+EXPORT_C void CMTPTypeArray::SetByDesL( const TDesC8& aDesc ) 
+    {
+    TUint32 num = (aDesc.Length() / iElementSize);
+    SetNumElements( num );
+    if ( num > 0 )
+    	{
+    	ReAllocBufferL( num );
+    	memcpy(&iBuffer[KMTPFirstElementOffset], aDesc.Ptr(), aDesc.Length());
+    	}
+    }
+
+EXPORT_C TInt CMTPTypeArray::FirstReadChunk(TPtrC8& aChunk) const
+    {
+    aChunk.Set(&iBuffer[KMTPNumElementsOffset], Size());
+    return KMTPChunkSequenceCompletion;
+    }
+
+EXPORT_C TInt CMTPTypeArray::NextReadChunk(TPtrC8& aChunk) const
+    {
+    aChunk.Set(NULL, 0);
+    return KErrNotReady;
+    }
+
+EXPORT_C TInt CMTPTypeArray::FirstWriteChunk(TPtr8& aChunk)
+    {    
+    TInt ret(KErrNone);
+    aChunk.Set(&iBuffer[KMTPNumElementsOffset], 0, KMTPNumElementsLen);
+    iWriteSequenceState = ENumElements;
+    return ret;
+    }
+
+EXPORT_C TInt CMTPTypeArray::NextWriteChunk(TPtr8& aChunk)
+    {
+    TInt ret(KMTPChunkSequenceCompletion);
+    
+    if (iWriteSequenceState != ENumElements)
+        {
+        ret = KErrNotReady;
+        }
+    else
+        {
+        const TUint capacity(iBuffer.MaxLength() - KMTPNumElementsLen);
+        if (capacity > 0)
+            {
+            aChunk.Set(&iBuffer[KMTPFirstElementOffset], 0, capacity);
+            }
+        else
+            {
+            aChunk.Set(NULL, 0, 0);
+            }
+            
+        iWriteSequenceState = EElements;
+        }
+        
+    return ret;
+    }
+
+EXPORT_C TUint64 CMTPTypeArray::Size() const
+    {
+    return (KMTPNumElementsLen + (NumElements() * iElementSize));
+    }
+
+EXPORT_C TUint CMTPTypeArray::Type() const
+    {
+    return iArrayType;
+    }
+
+EXPORT_C TBool CMTPTypeArray::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* CMTPTypeArray::CommitChunkL(TPtr8& aChunk)
+    {
+    switch (iWriteSequenceState)
+        {
+    case ENumElements:
+        /* 
+        The first chunk specifies the NumElements field, and is used to re-size 
+        the array buffer.
+        */
+        ReAllocBufferL(NumElements());
+        break;
+        
+    case EElements:
+        // Check that the correct number of array elements has been received.
+        {            
+        TUint count(aChunk.Length() / iElementSize);
+        if (count != NumElements())
+            {
+            SetInvalidL();
+            }
+        iWriteSequenceState = EIdle;
+        }
+        break;
+        
+    case EIdle:
+    default:
+        User::Leave(KErrNotReady);
+        break;
+        }
+    return NULL;
+    }
+    
+EXPORT_C TInt CMTPTypeArray::Validate() const
+    {
+    return iValidationState;
+    }
+    
+CMTPTypeArray::CMTPTypeArray(TInt aArrayType, TInt aElementType, TUint aElementSize) :
+    iArrayType(aArrayType),
+    iElementSize(aElementSize),
+    iElementType(aElementType)
+    {
+        
+    }
+    
+void CMTPTypeArray::ConstructL(TUint32 aNumElements)
+    {
+    ReAllocBufferL(aNumElements);
+    SetNumElements(0);
+    }
+
+void CMTPTypeArray::ConstructL(const RPointerArray<MMTPType>& aElements)
+    {
+    TUint count(aElements.Count());
+    ConstructL(count);
+    
+    for (TUint i(0); (i < count); i++)
+        {
+        AppendL(aElements[i]);
+        }
+    }
+    
+void CMTPTypeArray::AppendL(const TAny* aElement)
+    {    
+    const TUint index(NumElements());
+    TUint32 numElements(index + 1);
+    
+    if (iBuffer.MaxLength() < BufferSize(numElements))
+        {
+        ReAllocBufferL(numElements);
+        }
+
+    memcpy(&iBuffer[Offset(index)], aElement, iElementSize);
+    SetNumElements(numElements);
+    }
+    
+void CMTPTypeArray::Element(TUint aIndex, TAny* aElement) const
+    {
+    __ASSERT_ALWAYS((aIndex < NumElements()), Panic(EMTPTypeBoundsError));
+    memcpy(aElement, &iBuffer[Offset(aIndex)], iElementSize);
+    }
+    
+void CMTPTypeArray::ReAllocBufferL(TUint32 aNumElements)
+    {
+    TInt currentSize(iBuffer.MaxLength());
+    TUint64 newSize(BufferSize(aNumElements));
+    
+    if (newSize != currentSize)
+        {
+        if (newSize > KMaxTInt)
+            {
+            SetInvalidL();
+            }
+        else
+            {
+            if (newSize < currentSize)
+                {
+                // Buffer is shrinking.
+                iBuffer.Close();   
+                }
+            iBuffer.ReAllocL(newSize);
+            iBuffer.SetMax();
+            SetNumElements(aNumElements);   
+            }
+        }
+    }
+
+void CMTPTypeArray::SetNumElements(TUint32 aNumElements)
+    {
+    memcpy(&iBuffer[KMTPNumElementsOffset], &aNumElements, KMTPNumElementsLen);
+    }
+
+TUint64 CMTPTypeArray::BufferSize(TUint32 aNumElements) const
+    {
+    return ((iElementSize * aNumElements) + KMTPNumElementsLen);
+    }
+    
+TUint CMTPTypeArray::Offset(TUint aIndex) const
+    {
+    return (KMTPFirstElementOffset + (aIndex * iElementSize));
+    }
+    
+void CMTPTypeArray::SetInvalidL()
+    {
+    iValidationState = KMTPDataTypeInvalid;
+    User::Leave(iValidationState);
+    }
+    
+void CMTPTypeArray::SimpleArrayTypeMetaDataL(TInt aArrayType, TInt& aElementType, TUint& aElementSize)
+    {            
+    switch (aArrayType)
+        {
+    case EMTPTypeAINT8:
+        aElementType    = EMTPTypeINT8;
+        aElementSize    = KMTPTypeINT8Size;
+        break; 
+        
+    case EMTPTypeAUINT8:
+        aElementType    = EMTPTypeUINT8;
+        aElementSize    = KMTPTypeUINT8Size;
+        break; 
+        
+    case EMTPTypeAINT16:
+        aElementType    = EMTPTypeINT16;
+        aElementSize    = KMTPTypeINT16Size;
+        break; 
+        
+    case EMTPTypeAUINT16:
+        aElementType    = EMTPTypeUINT16;
+        aElementSize    = KMTPTypeUINT16Size;
+        break; 
+        
+    case EMTPTypeAINT32:
+        aElementType    = EMTPTypeINT32;
+        aElementSize    = KMTPTypeINT32Size;
+        break; 
+        
+    case EMTPTypeAUINT32:
+        aElementType    = EMTPTypeUINT32;
+        aElementSize    = KMTPTypeUINT32Size;
+        break; 
+        
+    case EMTPTypeAINT64:
+        aElementType    = EMTPTypeINT64;
+        aElementSize    = KMTPTypeINT64Size;
+        break; 
+        
+    case EMTPTypeAUINT64:
+        aElementType    = EMTPTypeUINT64;
+        aElementSize    = KMTPTypeUINT64Size;
+        break; 
+        
+    case EMTPTypeAINT128:
+        aElementType    = EMTPTypeINT128;
+        aElementSize    = KMTPTypeINT128Size;
+        break; 
+        
+    case EMTPTypeAUINT128:
+        aElementType    = EMTPTypeUINT128;
+        aElementSize    = KMTPTypeUINT128Size;
+        break; 
+        
+    default:
+        User::Leave(KErrArgument);
+        } 
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypecomplexbuffer.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,194 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @InternalTechnology
+*/
+
+#include "cmtptypecomplexbuffer.h"
+#include <mtp/mtpdatatypeconstants.h>
+
+// File type constants.
+const TInt KMTPBufferChunkSize(0x00019000); // 100KB
+
+/**
+MTP string data type factory method. This method is used to create a 
+zero-length MTP string.
+@return A pointer to a zero-length MTP string data type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/   
+EXPORT_C CMTPTypeComplexBuffer* CMTPTypeComplexBuffer::NewL()
+    {
+	CMTPTypeComplexBuffer* self = NewLC(); 
+	CleanupStack::Pop(self);
+	return self; 
+    }
+
+/**
+MTP string data type factory method. This method is used to create an 
+MTP string with the specified value.
+@param aString The initial string value.
+@return A pointer to the MTP string data type. Ownership IS transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/     
+EXPORT_C CMTPTypeComplexBuffer* CMTPTypeComplexBuffer::NewL(const TDesC8& aData)
+    {
+	CMTPTypeComplexBuffer* self = NewLC(aData);
+	CleanupStack::Pop(self);
+	return self;
+    }
+
+/**
+MTP file object data type factory method. 
+@param aFs The handle of an active file server session.
+@param aName The name of the file. Any path components (i.e. drive letter
+or directory), which are not specified, are taken from the session path. 
+@param aMode The mode in which the file is opened (@see TFileMode).
+@return A pointer to the MTP file object data type. Ownership IS transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+@see TFileMode
+*/   
+EXPORT_C CMTPTypeComplexBuffer* CMTPTypeComplexBuffer::NewLC()
+    {
+    CMTPTypeComplexBuffer* self = NewLC(KNullDesC8);
+    return self;
+    }
+
+/**
+MTP file object data type factory method. A pointer to the MTP file object data
+type is placed on the cleanup stack.
+@param aFs The handle of an active file server session.
+@param aName The name of the file. Any path components (i.e. drive letter
+or directory), which are not specified, are taken from the session path. 
+@param aMode The mode in which the file is opened (@see TFileMode).
+@return A pointer to the MTP file object data type. Ownership IS transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+@see TFileMode
+*/   
+EXPORT_C CMTPTypeComplexBuffer* CMTPTypeComplexBuffer::NewLC(const TDesC8& aData)
+    {
+    CMTPTypeComplexBuffer* self = new(ELeave) CMTPTypeComplexBuffer;
+    CleanupStack::PushL(self);
+    self->ConstructL(aData);
+    return self;
+    }
+
+/**
+Destructor
+*/
+EXPORT_C CMTPTypeComplexBuffer::~CMTPTypeComplexBuffer()
+    {
+    iBuffer.Close();
+    }
+
+/**
+Provides a reference to the native file object encapsulate by the MTP file 
+object data type.
+@return The native file object reference.
+*/
+EXPORT_C const TDesC8& CMTPTypeComplexBuffer::Buffer()
+    {
+    return iBuffer;
+    }    
+    
+EXPORT_C void CMTPTypeComplexBuffer::SetBuffer(const TDesC8& aData )
+	{
+    iBuffer.Zero();
+    if(aData == KNullDesC8)
+        {
+    	return;
+        }
+
+	iBuffer.Copy(aData);   	
+	}
+
+EXPORT_C TInt CMTPTypeComplexBuffer::FirstReadChunk(TPtrC8& aChunk) const
+    {
+	aChunk.Set(iBuffer.Ptr(), iBuffer.Length());
+    return KMTPChunkSequenceCompletion;
+    }
+
+EXPORT_C TInt CMTPTypeComplexBuffer::NextReadChunk(TPtrC8& aChunk) const
+    {
+    aChunk.Set(NULL, 0);
+    return KErrNotReady;
+    }
+
+EXPORT_C TInt CMTPTypeComplexBuffer::FirstWriteChunk(TPtr8& aChunk)
+    {
+    TInt err(KErrNone);
+	aChunk.Set(NULL, 0, 0);
+    iWriteSequenceState = EIdle;
+    aChunk.Set(&iBuffer[0], 0, iBuffer.MaxLength());
+    iWriteSequenceState = EInProgress;
+    return err;
+    }
+    
+EXPORT_C TInt CMTPTypeComplexBuffer::NextWriteChunk(TPtr8& aChunk)
+    {
+    TInt err(KErrNone);
+	aChunk.Set(NULL, 0, 0);
+    
+    if (iWriteSequenceState != EInProgress)
+        {
+        err = KErrNotReady;            
+        }
+    else
+        {
+    	aChunk.Set(&iBuffer[0], 0, iBuffer.MaxLength());
+        }
+       
+    return err;
+    }
+
+EXPORT_C TUint64 CMTPTypeComplexBuffer::Size() const
+    {
+    return iBuffer.Size();
+    }
+
+EXPORT_C TUint CMTPTypeComplexBuffer::Type() const
+    {
+    return EMTPTypeString;
+    }
+
+EXPORT_C TBool CMTPTypeComplexBuffer::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* CMTPTypeComplexBuffer::CommitChunkL(TPtr8& aChunk)
+    {
+    iBuffer.Zero(); 
+    iBuffer.Copy(aChunk);
+    return NULL;
+    }
+    
+CMTPTypeComplexBuffer::CMTPTypeComplexBuffer()
+    {
+        
+    }
+
+void CMTPTypeComplexBuffer::ConstructL(const TDesC8& aData)
+    {    
+    iBuffer.CreateMaxL(KMTPBufferChunkSize);
+    if(aData != KNullDesC8)
+    	{
+    	iBuffer.Zero();
+    	iBuffer.Copy(aData);
+    	}
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypecompoundbase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1389 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/cmtptypecompoundbase.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/rmtptype.h>
+
+#include "mtpdatatypespanic.h"
+
+/**
+Destructor
+*/
+EXPORT_C CMTPTypeCompoundBase::~CMTPTypeCompoundBase()
+    {
+    Reset();    
+    }
+    
+/**
+Provides a copy of the specified element.
+@param aElementId The identifier of the requested element.
+@param aElement The MMTPType target data buffer.
+@leave KErrNotSupported, if the element is not readable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the target buffer type does not match the requested
+element.
+*/
+EXPORT_C void CMTPTypeCompoundBase::GetL(TInt aElementId, MMTPType& aElement) const
+    {
+    if (!ReadableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+    
+    const TElementInfo& info(ElementInfo(aElementId));
+    if (info.iType == EMTPTypeFlat)
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        chunk->GetL(aElementId, aElement);
+        }
+    else
+        {
+        CopyL(*iChunks[info.iChunkId], aElement);
+        }
+    }
+
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aElement The MMTPType source data buffer.
+@leave KErrNotSupported, if the element is not writeable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/  
+EXPORT_C void CMTPTypeCompoundBase::SetL(TInt aElementId, const MMTPType& aElement)
+    {
+    if (!WriteableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    const TElementInfo& info(ElementInfo(aElementId));
+    if (info.iType == EMTPTypeFlat)
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        chunk->SetL(aElementId, aElement);
+        }
+    else
+        {
+        CopyL(aElement, *iChunks[info.iChunkId]);
+        }
+    }
+    
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aData The source data.
+@leave KErrNotSupported, if the element is not writeable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source data type does not match the requested 
+element.
+*/    
+EXPORT_C void CMTPTypeCompoundBase::SetInt8L(TInt aElementId, TInt8 aData)
+    {
+    if (!WriteableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeFlat:
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        chunk->SetInt8(aElementId, aData);
+        }
+        break;
+        
+    case EMTPTypeReference:
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeINT8, Panic(EMTPTypeIdMismatch));   
+        static_cast<TMTPTypeInt8&>(chunk->Data()).Set(aData);
+        }
+        break;
+        
+    case EMTPTypeINT8:
+        {
+        TMTPTypeInt8* chunk(static_cast<TMTPTypeInt8*>(iChunks[info.iChunkId]));
+        chunk->Set(aData);
+        }
+        break;
+        
+    default:
+        Panic(EMTPTypeIdMismatch);
+        break;
+        }
+    }
+    
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aData The source data.
+@leave KErrNotSupported, if the element is not writeable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source data type does not match the requested 
+element.
+*/    
+EXPORT_C void CMTPTypeCompoundBase::SetInt16L(TInt aElementId, TInt16 aData)
+    {
+    if (!WriteableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeFlat:
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        chunk->SetInt16(aElementId, aData);
+        }
+        break;
+        
+    case EMTPTypeReference:
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeINT16, Panic(EMTPTypeIdMismatch)); 
+        static_cast<TMTPTypeInt16&>(chunk->Data()).Set(aData);
+        }
+        break;
+        
+    case EMTPTypeINT16:
+        {
+        TMTPTypeInt16* chunk(static_cast<TMTPTypeInt16*>(iChunks[info.iChunkId]));
+        chunk->Set(aData);
+        }
+        break;
+        
+    default:
+        Panic(EMTPTypeIdMismatch);
+        break;
+        }
+    }
+    
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aData The source data.
+@leave KErrNotSupported, if the element is not writeable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source data type does not match the requested 
+element.
+*/    
+EXPORT_C void CMTPTypeCompoundBase::SetInt32L(TInt aElementId, TInt32 aData)
+    {
+    if (!WriteableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeFlat:
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        chunk->SetInt32(aElementId, aData);
+        }
+        break;
+        
+    case EMTPTypeReference:
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeINT32, Panic(EMTPTypeIdMismatch)); 
+        static_cast<TMTPTypeInt32&>(chunk->Data()).Set(aData);
+        }
+        break;
+        
+    case EMTPTypeINT32:
+        {
+        TMTPTypeInt32* chunk(static_cast<TMTPTypeInt32*>(iChunks[info.iChunkId]));
+        chunk->Set(aData);
+        }
+        break;
+        
+    default:
+        Panic(EMTPTypeIdMismatch);
+        break;
+        }
+    }
+    
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aData The source data.
+@leave KErrNotSupported, if the element is not writeable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source data type does not match the requested 
+element.
+*/    
+EXPORT_C void CMTPTypeCompoundBase::SetInt64L(TInt aElementId, TInt64 aData)
+    {
+    if (!WriteableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeFlat:
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        chunk->SetInt64(aElementId, aData);
+        }
+        break;
+        
+    case EMTPTypeReference:
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeINT64, Panic(EMTPTypeIdMismatch)); 
+        static_cast<TMTPTypeInt64&>(chunk->Data()).Set(aData);
+        }
+        break;
+        
+    case EMTPTypeINT64:
+        {
+        TMTPTypeInt64* chunk(static_cast<TMTPTypeInt64*>(iChunks[info.iChunkId]));
+        chunk->Set(aData);
+        }
+        break;
+        
+    default:
+        Panic(EMTPTypeIdMismatch);
+        break;
+        }
+    }
+    
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aData The source data.
+@leave KErrNotSupported, if the element is not writeable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source data type does not match the requested 
+element.
+*/    
+EXPORT_C void CMTPTypeCompoundBase::SetUint8L(TInt aElementId, TUint8 aData)
+    {
+    if (!WriteableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeFlat:
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        chunk->SetUint8(aElementId, aData);
+        }
+        break;
+        
+    case EMTPTypeReference:
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeUINT8, Panic(EMTPTypeIdMismatch)); 
+        static_cast<TMTPTypeUint8&>(chunk->Data()).Set(aData);
+        }
+        break;
+        
+    case EMTPTypeUINT8:
+        {
+        TMTPTypeUint8* chunk(static_cast<TMTPTypeUint8*>(iChunks[info.iChunkId]));
+        chunk->Set(aData);
+        }
+        break;
+        
+    default:
+        Panic(EMTPTypeIdMismatch);
+        break;
+        }
+    }
+    
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aData The source data.
+@leave KErrNotSupported, if the element is not writeable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source data type does not match the requested 
+element.
+*/    
+EXPORT_C void CMTPTypeCompoundBase::SetUint16L(TInt aElementId, TUint16 aData)
+    {
+    if (!WriteableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeFlat:
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        chunk->SetUint16(aElementId, aData);
+        }
+        break;
+        
+    case EMTPTypeReference:
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeUINT16, Panic(EMTPTypeIdMismatch)); 
+        static_cast<TMTPTypeUint16&>(chunk->Data()).Set(aData);
+        }
+        break;
+        
+    case EMTPTypeUINT16:
+        {
+        TMTPTypeUint16* chunk(static_cast<TMTPTypeUint16*>(iChunks[info.iChunkId]));
+        chunk->Set(aData);
+        }
+        break;
+        
+    default:
+        Panic(EMTPTypeIdMismatch);
+        break;
+        }
+    }
+    
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aData The source data.
+@leave KErrNotSupported, if the element is not writeable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source data type does not match the requested 
+element.
+*/    
+EXPORT_C void CMTPTypeCompoundBase::SetUint32L(TInt aElementId, TUint32 aData)
+    {
+    if (!WriteableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeFlat:
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        chunk->SetUint32(aElementId, aData);
+        }
+        break;
+        
+    case EMTPTypeReference:
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeUINT32, Panic(EMTPTypeIdMismatch)); 
+        static_cast<TMTPTypeUint32&>(chunk->Data()).Set(aData);
+        }
+        break;
+        
+    case EMTPTypeUINT32:
+        {
+        TMTPTypeUint32* chunk(static_cast<TMTPTypeUint32*>(iChunks[info.iChunkId]));
+        chunk->Set(aData);
+        }
+        break;
+        
+    default:
+        Panic(EMTPTypeIdMismatch);
+        break;
+        }
+    }
+    
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aData The source data.
+@leave KErrNotSupported, if the element is not writeable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source data type does not match the requested 
+element.
+*/    
+EXPORT_C void CMTPTypeCompoundBase::SetUint64L(TInt aElementId, TUint64 aData)
+    {
+    if (!WriteableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeFlat:
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        chunk->SetUint64(aElementId, aData);
+        }
+        break;
+        
+    case EMTPTypeReference:
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeUINT64, Panic(EMTPTypeIdMismatch)); 
+        static_cast<TMTPTypeUint64&>(chunk->Data()).Set(aData);
+        }
+        break;
+        
+    case EMTPTypeUINT64:
+        {
+        TMTPTypeUint64* chunk(static_cast<TMTPTypeUint64*>(iChunks[info.iChunkId]));
+        chunk->Set(aData);
+        }
+        break;
+        
+    default:
+        Panic(EMTPTypeIdMismatch);
+        break;
+        }
+    }
+    
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aString The source data.
+@leave KErrNotSupported, if the element is not writeable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source data type does not match the requested 
+element.
+*/    
+EXPORT_C void CMTPTypeCompoundBase::SetStringL(TInt aElementId, const TDesC& aString)
+    {
+    if (!WriteableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeReference:
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeString, Panic(EMTPTypeIdMismatch)); 
+        static_cast<CMTPTypeString&>(chunk->Data()).SetL(aString);
+        }
+        break;
+        
+    case EMTPTypeString:
+        {
+        CMTPTypeString* chunk(static_cast<CMTPTypeString*>(iChunks[info.iChunkId]));
+        chunk->SetL(aString);
+        }
+        break;
+        
+    default:
+        Panic(EMTPTypeIdMismatch);
+        break;
+        }
+    }
+
+
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@leave KErrNotSupported, if the element is not readable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C TInt8 CMTPTypeCompoundBase::Int8L(TInt aElementId) const
+    {
+    if (!ReadableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    TInt8 ret(0);
+    
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeFlat:
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        ret = chunk->Int8(aElementId); 
+        }
+        break;
+        
+    case EMTPTypeReference:
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeINT8, Panic(EMTPTypeIdMismatch)); 
+        ret = static_cast<TMTPTypeInt8&>(chunk->Data()).Value();
+        }
+        break;
+        
+    case EMTPTypeINT8:
+        {
+        TMTPTypeInt8* chunk(static_cast<TMTPTypeInt8*>(iChunks[info.iChunkId]));
+        ret = chunk->Value();
+        }
+        break;
+        
+    default:
+        Panic(EMTPTypeIdMismatch);
+        break;
+        }
+        
+    return ret;
+    }
+
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@leave KErrNotSupported, if the element is not readable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C TInt16 CMTPTypeCompoundBase::Int16L(TInt aElementId) const
+    {
+    if (!ReadableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    TInt16 ret(0);
+    
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeFlat:
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        ret = chunk->Int16(aElementId); 
+        }
+        break;
+        
+    case EMTPTypeReference:
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeINT16, Panic(EMTPTypeIdMismatch)); 
+        ret = static_cast<TMTPTypeInt16&>(chunk->Data()).Value();
+        }
+        break;
+        
+    case EMTPTypeINT16:
+        {
+        TMTPTypeInt16* chunk(static_cast<TMTPTypeInt16*>(iChunks[info.iChunkId]));
+        ret = chunk->Value();
+        }
+        break;
+        
+    default:
+        Panic(EMTPTypeIdMismatch);
+        break;
+        }
+        
+    return ret;
+    }
+
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@leave KErrNotSupported, if the element is not readable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C TInt32 CMTPTypeCompoundBase::Int32L(TInt aElementId) const
+    {
+    if (!ReadableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    TInt32 ret(0);
+    
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeFlat:
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        ret = chunk->Int32(aElementId); 
+        }
+        break;
+        
+    case EMTPTypeReference:
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeINT32, Panic(EMTPTypeIdMismatch)); 
+        ret = static_cast<TMTPTypeInt32&>(chunk->Data()).Value();
+        }
+        break;
+        
+    case EMTPTypeINT32:
+        {
+        TMTPTypeInt32* chunk(static_cast<TMTPTypeInt32*>(iChunks[info.iChunkId]));
+        ret = chunk->Value();
+        }
+        break;
+        
+    default:
+        Panic(EMTPTypeIdMismatch);
+        break;
+        }
+        
+    return ret;
+    }
+
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@leave KErrNotSupported, if the element is not readable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C TInt64 CMTPTypeCompoundBase::Int64L(TInt aElementId) const
+    {
+    if (!ReadableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    TInt64 ret(0);
+    
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeFlat:
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        ret = chunk->Int64(aElementId); 
+        }
+        break;
+        
+    case EMTPTypeReference:
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeINT64, Panic(EMTPTypeIdMismatch)); 
+        ret = static_cast<TMTPTypeInt64&>(chunk->Data()).Value();
+        }
+        break;
+        
+    case EMTPTypeINT64:
+        {
+        TMTPTypeInt64* chunk(static_cast<TMTPTypeInt64*>(iChunks[info.iChunkId]));
+        ret = chunk->Value();
+        }
+        break;
+        
+    default:
+        Panic(EMTPTypeIdMismatch);
+        break;
+        }
+        
+    return ret;
+    }
+
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@leave KErrNotSupported, if the element is not readable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C TUint8 CMTPTypeCompoundBase::Uint8L(TInt aElementId) const
+    {
+    if (!ReadableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    TUint8 ret(0);
+    
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeFlat:
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        ret = chunk->Uint8(aElementId); 
+        }
+        break;
+        
+    case EMTPTypeReference:
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeUINT8, Panic(EMTPTypeIdMismatch)); 
+        ret = static_cast<TMTPTypeUint8&>(chunk->Data()).Value();
+        }
+        break;
+        
+    case EMTPTypeUINT8:
+        {
+        TMTPTypeUint8* chunk(static_cast<TMTPTypeUint8*>(iChunks[info.iChunkId]));
+        ret = chunk->Value();
+        }
+        break;
+        
+    default:
+        Panic(EMTPTypeIdMismatch);
+        break;
+        }
+        
+    return ret;
+    }
+
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@leave KErrNotSupported, if the element is not readable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C TUint16 CMTPTypeCompoundBase::Uint16L(TInt aElementId) const
+    {
+    if (!ReadableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    TUint16 ret(0);
+    
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeFlat:
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        ret = chunk->Uint16(aElementId); 
+        }
+        break;
+        
+    case EMTPTypeReference:
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeUINT16, Panic(EMTPTypeIdMismatch)); 
+        ret = static_cast<TMTPTypeUint16&>(chunk->Data()).Value();
+        }
+        break;
+        
+    case EMTPTypeUINT16:
+        {
+        TMTPTypeUint16* chunk(static_cast<TMTPTypeUint16*>(iChunks[info.iChunkId]));
+        ret = chunk->Value();
+        }
+        break;
+        
+    default:
+        Panic(EMTPTypeIdMismatch);
+        break;
+        }
+        
+    return ret;
+    }
+
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@leave KErrNotSupported, if the element is not readable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C TUint32 CMTPTypeCompoundBase::Uint32L(TInt aElementId) const
+    {
+    if (!ReadableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+    
+    TUint32 ret(0);
+    
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeFlat:
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        ret = chunk->Uint32(aElementId); 
+        }
+        break;
+        
+    case EMTPTypeReference:
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeUINT32, Panic(EMTPTypeIdMismatch)); 
+        ret = static_cast<TMTPTypeUint32&>(chunk->Data()).Value();
+        }
+        break;
+        
+    case EMTPTypeUINT32:
+        {
+        TMTPTypeUint32* chunk(static_cast<TMTPTypeUint32*>(iChunks[info.iChunkId]));
+        ret = chunk->Value();
+        }
+        break;
+        
+    case EMTPTypeUndefined:
+    default:
+        {
+        TMTPTypeUint32 chunk;
+        GetL(aElementId, chunk);
+        ret = chunk.Value();
+        }
+        break;
+        }
+        
+    return ret;
+    }
+
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@leave KErrNotSupported, if the element is not readable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C TUint64 CMTPTypeCompoundBase::Uint64L(TInt aElementId) const
+    {
+    if (!ReadableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+    
+    TUint64 ret(0);
+    
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeFlat:
+        {
+        RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId]));
+        ret = chunk->Uint64(aElementId); 
+        }
+        break;
+        
+    case EMTPTypeReference:
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeUINT64, Panic(EMTPTypeIdMismatch)); 
+        ret = static_cast<TMTPTypeUint64&>(chunk->Data()).Value();
+        }
+        break;
+        
+    case EMTPTypeUINT64:
+        {
+        TMTPTypeUint64* chunk(static_cast<TMTPTypeUint64*>(iChunks[info.iChunkId]));
+        ret = chunk->Value();
+        }
+        break;
+        
+    default:
+        Panic(EMTPTypeIdMismatch);
+        break;
+        }
+        
+    return ret;
+    }
+    
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@leave KErrNotSupported, if the element is not readable.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C TUint8 CMTPTypeCompoundBase::StringNumCharsL(TInt aElementId) const
+    {
+    if (!ReadableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    TUint8 ret(0);
+
+    const TElementInfo& info(ElementInfo(aElementId));
+    switch (info.iType)
+        {
+    case EMTPTypeReference:
+        {
+             
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeString, Panic(EMTPTypeIdMismatch));   
+        ret = static_cast<CMTPTypeString&>(chunk->Data()).NumChars();
+        }
+        break;
+        
+    case EMTPTypeString:
+        {
+        CMTPTypeString* chunk(static_cast<CMTPTypeString*>(iChunks[info.iChunkId]));
+        ret = chunk->NumChars();
+        }
+        break;
+        
+    default:
+        Panic(EMTPTypeIdMismatch);
+        break;
+        }
+        
+    return ret;
+    }
+   
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@leave KErrNotSupported, if the element is not readable.
+@leave One of the system wide error code, if a processing error occurs.
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C const TDesC& CMTPTypeCompoundBase::StringCharsL(TInt aElementId) const
+    {
+    if (!ReadableElementL(aElementId))
+        {
+        User::Leave(KErrNotSupported);            
+        }
+        
+    const TElementInfo& info(ElementInfo(aElementId));
+    if (info.iType == EMTPTypeString)
+        {
+        CMTPTypeString* chunk(static_cast<CMTPTypeString*>(iChunks[info.iChunkId]));
+        return chunk->StringChars();
+        }
+    else if (info.iType == EMTPTypeReference)
+        {
+        RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId]));
+        __ASSERT_DEBUG(chunk->Type() == EMTPTypeString, Panic(EMTPTypeIdMismatch));   
+        return static_cast<CMTPTypeString&>(chunk->Data()).StringChars();
+        }
+    else
+        {
+        Panic(EMTPTypeIdMismatch);
+        }
+        
+    return KNullDesC;
+    }
+
+EXPORT_C TInt CMTPTypeCompoundBase::FirstReadChunk(TPtrC8& aChunk) const
+    {
+    TInt err(KErrNone);
+    aChunk.Set(NULL, 0);
+    
+    if (iChunks.Count() == 0)
+        {
+        err = KErrNotFound;            
+        }
+    else
+        {
+        iReadChunk = 0;
+        err = UpdateReadState(iChunks[iReadChunk]->FirstReadChunk(aChunk));
+        }
+    
+    return err;
+    }
+
+EXPORT_C TInt CMTPTypeCompoundBase::NextReadChunk(TPtrC8& aChunk) const
+    {
+    TInt err(KErrNotReady);
+    aChunk.Set(NULL, 0);
+    
+    switch (iReadSequenceState)
+        {
+    case EInProgressFirst:
+        err = UpdateReadState(iChunks[iReadChunk]->FirstReadChunk(aChunk));
+        break;
+        
+    case EInProgressNext:
+        err = UpdateReadState(iChunks[iReadChunk]->NextReadChunk(aChunk));
+        break;
+        
+    case EIdle:
+    default:
+        err = KErrNotReady;
+        break;
+        }
+    
+    return err;
+    }
+
+EXPORT_C TInt CMTPTypeCompoundBase::FirstWriteChunk(TPtr8& aChunk)
+    {
+    TInt err(KErrNone);
+    aChunk.Set(NULL, 0, 0);
+    
+    if (iChunks.Count() == 0)
+        {
+        err = KErrNotFound;            
+        }
+    else
+        {
+        iWriteChunk = 0;
+        err = UpdateWriteState(iChunks[iWriteChunk]->FirstWriteChunk(aChunk));
+        }
+    
+    return err;
+    }
+
+EXPORT_C TInt CMTPTypeCompoundBase::NextWriteChunk(TPtr8& aChunk)
+    {
+    TInt err(KErrNotReady);
+    aChunk.Set(NULL, 0, 0);
+    
+    switch (iWriteSequenceState)
+        {
+    case EInProgressFirst:
+        err = UpdateWriteState(iChunks[iWriteChunk]->FirstWriteChunk(aChunk));
+        break;
+        
+    case EInProgressNext:
+        err = UpdateWriteState(iChunks[iWriteChunk]->NextWriteChunk(aChunk));
+        break;
+        
+    case EIdle:
+    default:
+        err = KErrNotReady;
+        break;
+        }
+    
+    return err;
+    }
+
+EXPORT_C TInt CMTPTypeCompoundBase::NextWriteChunk(TPtr8& aChunk, TUint aDataLength)
+    {
+    TInt err(KErrNotReady);
+    aChunk.Set(NULL, 0, 0);
+    
+    switch (iWriteSequenceState)
+        {
+    case EInProgressFirst:
+        err = UpdateWriteState(iChunks[iWriteChunk]->FirstWriteChunk(aChunk, aDataLength));
+        break;
+        
+    case EInProgressNext:
+        err = UpdateWriteState(iChunks[iWriteChunk]->NextWriteChunk(aChunk, aDataLength));
+        break;
+        
+    case EIdle:
+    default:
+        err = KErrNotReady;
+        break;
+        }
+    
+    return err;
+    }
+
+EXPORT_C TUint64 CMTPTypeCompoundBase::Size() const
+    {
+    TUint64 size(0);
+    TUint numChunks(iChunks.Count());
+    for (TUint i(0); (i < numChunks); i++)
+        {
+        TUint64 chunkSize(iChunks[i]->Size());
+        size += chunkSize;
+        }
+        
+    return size;  
+    }
+
+EXPORT_C TUint CMTPTypeCompoundBase::Type() const
+    {
+    return EMTPTypeCompound;        
+    }
+
+EXPORT_C TBool CMTPTypeCompoundBase::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* CMTPTypeCompoundBase::CommitChunkL(TPtr8& aChunk)
+    {        
+    MMTPType *chunk(iChunks[iWriteChunk]);
+    MMTPType* res = NULL;
+    if (chunk->CommitRequired())
+        {
+        res = chunk->CommitChunkL(aChunk);
+        }
+        
+    if (iJustInTimeConstruction)
+        {
+        UpdateWriteState(iWriteErr);   
+        }
+    
+    if (iWriteSequenceState == EInProgressFirst)
+        {
+        iWriteChunk++;            
+        }
+    return res;
+    }
+    
+    
+EXPORT_C TInt CMTPTypeCompoundBase::Validate() const
+    {
+    const TUint count(ChunkCount());
+    TInt ret(KMTPDataTypeInvalid);
+    if (iExpectedChunkCount == KVariableChunkCount)
+        {
+        ret = ValidateChunkCount();
+        }
+    else if (count == iExpectedChunkCount)
+        {
+        /*
+        The element count is correct. Verify that the last element was 
+        correctly received.
+        */
+        ret = KErrNone;
+        }
+        
+    if (ret == KErrNone)
+        {
+        /*
+        The element count is correct. Verify that the last element was 
+        correctly received.
+        */
+        ret = iChunks[count - 1]->Validate();
+        }
+    return ret;
+    }
+
+/**
+Constructor.
+@param aJustInTimeConstruction This flag indicates that the derived class uses 
+a just-in-time construction technique when constructing iteself from a write
+data stream. Typically this is used for types whose final structure is dependant
+upon data contained within the data stream itself, e.g. a dataset with an 
+element whose data type is determined by meta data which precedes the element 
+in the data stream.
+@param aExpectedChunkCount This flag is used by the derived class to indicate 
+the number of chunks which make up the compound type. A value of 
+KVariableChunkCount indicates that the type is of variable rather than fixed 
+length (e.g. a list of elements). If KVariableChunkCount is specified then the
+derived class's ValidChunkCount method is invoked when the compound type is
+validated (@see ValidateChunkCount).
+@see Validate
+@see ValidateChunkCount
+@see KVariableChunkCount
+*/
+EXPORT_C CMTPTypeCompoundBase::CMTPTypeCompoundBase(TBool aJustInTimeConstruction, TUint aExpectedChunkCount) :
+    iExpectedChunkCount(aExpectedChunkCount),
+    iJustInTimeConstruction(aJustInTimeConstruction)
+    {
+        
+    }
+
+/**
+Appends the specified data chunk to the compound type's sequence of chunks.
+@param aChunk The chunk to be appended.
+*/
+EXPORT_C void CMTPTypeCompoundBase::ChunkAppendL(const MMTPType& aChunk)
+    {
+    iChunks.AppendL(&aChunk);
+    }
+
+/**
+Removes the chunk at the specified position in the chunk sequence.
+@param aChunkId The index of the chunk in in the chunk sequence.
+*/
+EXPORT_C void CMTPTypeCompoundBase::ChunkRemove(TUint aChunkId) 
+    {
+    iChunks.Remove(aChunkId);
+    }
+    
+/**
+Provides the number of discrete data chunks of which the compound type is
+composed.
+@return The number of discrete data chunks components which make up the 
+compound type.
+*/
+EXPORT_C TUint CMTPTypeCompoundBase::ChunkCount() const
+    {
+    return iChunks.Count();   
+    }
+    
+/**
+Resets the compound base, removing all data chunk references.
+*/
+EXPORT_C void CMTPTypeCompoundBase::Reset()
+    {
+    iChunks.Close();    
+    }
+    
+/**
+Sets the expected chunk count. This flag is used by the derived class to 
+indicate the number of chunks which make up the compound type. A value of 
+KVariableChunkCount indicates that the type is of variable rather than fixed 
+length (e.g. a list of elements). If KVariableChunkCount is specified then the
+derived class's ValidChunkCount method is invoked when the compound type is
+validated (@see ValidateChunkCount).
+@param aExpectedChunkCount The new expected chunk count.
+*/
+EXPORT_C void CMTPTypeCompoundBase::SetExpectedChunkCount(TUint aExpectedChunkCount)
+    {
+    iExpectedChunkCount = aExpectedChunkCount;
+    }
+    
+/**
+Indicates if the specified element can be read from.
+@param aElementId The identifier of the requested element.
+@return ETrue if the element is readable, otherwise EFalse.
+*/
+EXPORT_C TBool CMTPTypeCompoundBase::ReadableElementL(TInt /*aElementId*/) const
+    {
+    return ETrue;        
+    }
+    
+/**
+Indicates if the specified element can be written to.
+@param aElementId The identifier of the requested element.
+@return ETrue if the element is writeable, otherwise EFalse.
+*/
+EXPORT_C TBool CMTPTypeCompoundBase::WriteableElementL(TInt /*aElementId*/) const
+    {
+    return ETrue;        
+    }
+    
+TInt CMTPTypeCompoundBase::UpdateReadState(TInt aErr) const
+    {
+    TInt ret(aErr);
+    
+    switch (aErr)
+        {
+    case KMTPChunkSequenceCompletion:
+        if (++iReadChunk < iChunks.Count())
+            {
+            iReadSequenceState = EInProgressFirst;
+            ret = KErrNone;                    
+            }
+        else
+            {
+            iReadSequenceState = EIdle;                 
+            }
+        break;
+        
+    case KErrNone:
+        iReadSequenceState = EInProgressNext;
+        break;
+        
+    default:
+        break;
+        }
+        
+    return ret;
+    }
+    
+/**
+Validates that the number of chunks making up the compound type is valid. This
+method is invoked on variable length compound types by the default @see Valid 
+implementation.
+@see Valid
+@see KVariableChunkCount
+*/
+EXPORT_C TInt CMTPTypeCompoundBase::ValidateChunkCount() const
+    {
+    return KMTPDataTypeInvalid;
+    }
+
+TInt CMTPTypeCompoundBase::UpdateWriteState(TInt aErr)
+    {
+    TInt ret(aErr);
+    
+    iWriteErr = aErr;
+    switch (iWriteErr)
+        {
+    case KMTPChunkSequenceCompletion:
+        if ((iWriteChunk + 1) < iChunks.Count())
+            {
+            iWriteSequenceState = EInProgressFirst;
+            ret = KErrNone;
+            }
+        else
+            {
+            iWriteSequenceState = EIdle;                 
+            }
+        break;
+        
+    case KErrNone:
+        iWriteSequenceState = EInProgressNext;
+        break;
+        
+    default:
+        break;
+        }
+        
+    return ret;
+    }
+
+/**
+Constructor.
+@param aSize The size (in bytes) of the flat data chunk.
+@param aParent The compound data type of which the flat data chunk is a component.
+*/
+EXPORT_C CMTPTypeCompoundBase::RMTPTypeCompoundFlatChunk::RMTPTypeCompoundFlatChunk(TUint aSize, CMTPTypeCompoundBase& aParent) :
+    iSize(aSize),
+    iParent(&aParent)
+    {
+
+    }
+
+/**
+Releases the storage assigned to the flat data chunk.
+*/
+EXPORT_C void CMTPTypeCompoundBase::RMTPTypeCompoundFlatChunk::Close()
+    {
+    iBuffer.Close(); 
+    }
+
+/**
+Allocates storage for the flat data chunk.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C void CMTPTypeCompoundBase::RMTPTypeCompoundFlatChunk::OpenL()
+    {
+    iBuffer.CreateMaxL(iSize);
+    iBuffer.FillZ();
+    SetBuffer(iBuffer);
+    }
+    
+EXPORT_C TUint CMTPTypeCompoundBase::RMTPTypeCompoundFlatChunk::Type() const
+    {
+    return EMTPTypeFlat;
+    }
+
+const TMTPTypeFlatBase::TElementInfo& CMTPTypeCompoundBase::RMTPTypeCompoundFlatChunk::ElementInfo(TInt aElementId) const
+    {
+    return iParent->ElementInfo(aElementId).iFlatChunkInfo;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypedeleteobjectproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,63 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+/**
+@file
+@publishedPartner
+*/
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypedatapair.h>
+#include <mtp/cmtptypedeleteobjectproplist.h>
+
+EXPORT_C CMTPTypeDeleteObjectPropList* CMTPTypeDeleteObjectPropList::NewL()
+    {
+    CMTPTypeDeleteObjectPropList* self = CMTPTypeDeleteObjectPropList::NewLC(); 
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+EXPORT_C CMTPTypeDeleteObjectPropList* CMTPTypeDeleteObjectPropList::NewLC()
+    {
+    CMTPTypeDeleteObjectPropList* self = new(ELeave) CMTPTypeDeleteObjectPropList();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+EXPORT_C CMTPTypeDeleteObjectPropList::~CMTPTypeDeleteObjectPropList()
+    {
+    
+    }
+
+EXPORT_C void CMTPTypeDeleteObjectPropList::AppendL(const TMTPTypeDataPair* aElement)
+    {
+    CMTPTypeList::AppendL( aElement );
+    }
+
+
+EXPORT_C TMTPTypeDataPair& CMTPTypeDeleteObjectPropList::ElementL(const TInt aIndex) const
+    {
+    return static_cast<TMTPTypeDataPair&>( CMTPTypeList::ElementL( aIndex ) );
+    }
+
+CMTPTypeDeleteObjectPropList::CMTPTypeDeleteObjectPropList():
+    CMTPTypeList( EMTPTypeDeleteObjectPropListDataset , EMTPTypeDataPair )
+    {
+    
+    }
+
+void CMTPTypeDeleteObjectPropList::ConstructL()
+    {
+    InitListL();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypedeleteserviceproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,64 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@publishedPartner
+*/
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypedatapair.h>
+#include <mtp/cmtptypedeleteserviceproplist.h>
+
+EXPORT_C CMTPTypeDeleteServicePropList* CMTPTypeDeleteServicePropList::NewL()
+    {
+    CMTPTypeDeleteServicePropList* self = CMTPTypeDeleteServicePropList::NewLC(); 
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+EXPORT_C CMTPTypeDeleteServicePropList* CMTPTypeDeleteServicePropList::NewLC()
+    {
+    CMTPTypeDeleteServicePropList* self = new(ELeave) CMTPTypeDeleteServicePropList();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+EXPORT_C CMTPTypeDeleteServicePropList::~CMTPTypeDeleteServicePropList()
+    {
+    
+    }
+
+EXPORT_C void CMTPTypeDeleteServicePropList::AppendL(const TMTPTypeDataPair* aElement)
+    {
+    CMTPTypeList::AppendL( aElement );
+    }
+
+
+EXPORT_C TMTPTypeDataPair& CMTPTypeDeleteServicePropList::ElementL(const TInt aIndex) const
+    {
+    return static_cast<TMTPTypeDataPair&>( CMTPTypeList::ElementL( aIndex ) );
+    }
+
+CMTPTypeDeleteServicePropList::CMTPTypeDeleteServicePropList():
+    CMTPTypeList( EMTPTypeDeleteServicePropListDataset , EMTPTypeDataPair )
+    {
+    
+    }
+
+void CMTPTypeDeleteServicePropList::ConstructL()
+    {
+    InitListL();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypedevicepropdesc.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1163 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <mtp/cmtptypedevicepropdesc.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mtpprotocolconstants.h>
+
+#include "mtpdatatypespanic.h"
+
+// Dataset constants
+const TUint CMTPTypeDevicePropDesc::KFlat1ChunkSize(5);
+const TUint CMTPTypeDevicePropDesc::KNumChunksWithoutForm(EIdFormFlagChunk + 1);
+const TUint CMTPTypeDevicePropDesc::KNumChunksWithForm(EIdFormChunk + 1);
+
+const TUint CMTPTypeDevicePropDescEnumerationForm::KNumberOfValuesChunk(0);
+const TUint CMTPTypeDevicePropDescEnumerationForm::KValueChunks(1);
+
+// Dataset element metadata    
+const CMTPTypeCompoundBase::TElementInfo CMTPTypeDevicePropDesc::iElementMetaData[CMTPTypeDevicePropDesc::ENumElements] = 
+    {
+        {EIdFlat1Chunk,         EMTPTypeFlat,       {EMTPTypeUINT16,    0,                  KMTPTypeUINT16Size}},   // EDevicePropertyCode
+        {EIdFlat1Chunk,         EMTPTypeFlat,       {EMTPTypeUINT16,    2,                  KMTPTypeUINT16Size}},   // EDatatype
+        {EIdFlat1Chunk,         EMTPTypeFlat,       {EMTPTypeUINT8,     4,                  KMTPTypeUINT8Size}},    // EGetSet
+        {EIdDefaultValueChunk,  EMTPTypeReference,  {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}},    // EFactoryDefaultValue
+        {EIdCurrentValueChunk,  EMTPTypeReference,  {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}},    // ECurrentValue
+        {EIdFormFlagChunk,      EMTPTypeUINT8,      {EMTPTypeUINT8,     KMTPNotApplicable,  KMTPNotApplicable}},    // EFormFlag
+        {EIdFormChunk,          EMTPTypeReference,  {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}},    // EForm
+    };
+
+/**
+MTP DevicePropDesc dataset factory method. This method is used to create an 
+empty MTP DevicePropDesc dataset type with the default Datatype and Form Flag 
+defined for the specified PropertyCode. 
+@param aPropertyCode The ObjectPropertyCode of the property being described by 
+the DevicePropDesc dataset.
+@return A pointer to the MTP DevicePropDesc dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeDevicePropDesc* CMTPTypeDevicePropDesc::NewL(TUint16 aPropertyCode)
+    {
+    CMTPTypeDevicePropDesc* self = NewLC(aPropertyCode);
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+/**
+MTP DevicePropDesc dataset factory method. This method is used to create an 
+empty MTP DevicePropDesc dataset type with the default Datatype and Form Flag 
+defined for the specified PropertyCode. A pointer to the data type is placed on
+the cleanup stack.
+@param aPropertyCode The ObjectPropertyCode of the property being described by 
+the DevicePropDesc dataset.
+@return A pointer to the MTP DevicePropDesc dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeDevicePropDesc* CMTPTypeDevicePropDesc::NewLC(TUint16 aPropertyCode)
+    {    
+    CMTPTypeDevicePropDesc* self = new (ELeave) CMTPTypeDevicePropDesc(); 
+    CleanupStack::PushL(self); 
+    self->ConstructL(aPropertyCode, NULL);
+    return self;    
+    }
+
+/**
+MTP DevicePropDesc dataset factory method. This method is used to create an 
+MTP DevicePropDesc dataset type with the default Datatype and Form Flag 
+defined for the specified PropertyCode, and the specified FORM. 
+@param aPropertyCode The ObjectPropertyCode of the property being described by 
+the DevicePropDesc dataset.
+@param aForm The optional DevicePropDesc FORM dataset.
+@return A pointer to the MTP DevicePropDesc dataset type. Ownership IS 
+transfered.
+@leave KErrNotSupported, if a FORM dataset is not defined for the property.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeDevicePropDesc* CMTPTypeDevicePropDesc::NewL(TUint16 aPropertyCode, const MMTPType& aForm)
+    {
+    CMTPTypeDevicePropDesc* self = NewLC(aPropertyCode, aForm);
+    CleanupStack::Pop(self); 
+    return self;    
+    }
+
+/**
+MTP DevicePropDesc dataset factory method. This method is used to create an 
+MTP DevicePropDesc dataset type with the default Datatype and Form Flag 
+defined for the specified PropertyCode, and the specified FORM. A pointer 
+to the data type is placed on the cleanup stack.
+@param aPropertyCode The ObjectPropertyCode of the property being described by 
+the DevicePropDesc dataset.
+@param aForm The optional DevicePropDesc FORM dataset.
+@return A pointer to the MTP DevicePropDesc dataset type. Ownership IS 
+transfered.
+@leave KErrNotSupported, if a FORM dataset is not defined for the property.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeDevicePropDesc* CMTPTypeDevicePropDesc::NewLC(TUint16 aPropertyCode, const MMTPType& aForm)
+    {    
+    CMTPTypeDevicePropDesc* self = new (ELeave) CMTPTypeDevicePropDesc(); 
+    CleanupStack::PushL(self); 
+    self->ConstructL(aPropertyCode, &aForm);
+    return self;    
+    }
+
+/**
+MTP DevicePropDesc dataset factory method. This method is used to create an 
+MTP DevicePropDesc dataset type with the default Datatype defined for the 
+specified PropertyCode, and the specified Form Flag and FORM.  
+@param aPropertyCode The ObjectPropertyCode of the property being described by 
+the DevicePropDesc dataset.
+@param aGetSet The Get/Set flag of the DevicePropDesc.
+@param aFormFlag The required Form Flag of the DevicePropDesc.
+@param aForm The optional DevicePropDesc FORM dataset.
+@return A pointer to the MTP DevicePropDesc dataset type. Ownership IS 
+transfered.
+@leave KErrNotSupported, if a FORM dataset is not defined for the property.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeDevicePropDesc* CMTPTypeDevicePropDesc::NewL(TUint16 aPropertyCode, TUint8 aGetSet, TUint8 aFormFlag, const MMTPType* aForm)
+    {
+    CMTPTypeDevicePropDesc* self = NewLC(aPropertyCode, aGetSet, aFormFlag, aForm);
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+/**
+MTP DevicePropDesc dataset factory method. This method is used to create an 
+MTP DevicePropDesc dataset type with the default Datatype defined for the 
+specified PropertyCode, and the specified Form Flag and FORM. A pointer 
+to the data type is placed on the cleanup stack.
+@param aPropertyCode The ObjectPropertyCode of the property being described by 
+the DevicePropDesc dataset.
+@param aGetSet The Get/Set flag of the DevicePropDesc.
+@param aFormFlag The required Form Flag of the DevicePropDesc.
+@param aForm The optional DevicePropDesc FORM dataset.
+@return A pointer to the MTP DevicePropDesc dataset type. Ownership IS 
+transfered.
+@leave KErrNotSupported, if a FORM dataset is not defined for the property.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeDevicePropDesc* CMTPTypeDevicePropDesc::NewLC(TUint16 aPropertyCode, TUint8 aGetSet, TUint8 aFormFlag, const MMTPType* aForm)
+    {
+    CMTPTypeDevicePropDesc* self = new (ELeave) CMTPTypeDevicePropDesc(); 
+    CleanupStack::PushL(self); 
+    TPropertyInfo info;
+    PropertyInfoL(aPropertyCode, info);
+    info.iGetSet    = aGetSet;
+    info.iFormFlag  = aFormFlag;
+    self->ConstructL(aPropertyCode, info, aForm);
+    return self;    
+    }
+
+/**
+MTP DevicePropDesc dataset factory method. This method is used to create an  
+MTP DevicePropDesc dataset type with the specified values.
+@param aPropertyCode The ObjectPropertyCode of the property being described by 
+the DevicePropDesc dataset.
+@param aInfo The MTP DevicePropDesc dataset characteristics (meta data).
+@param aForm The optional DevicePropDesc FORM dataset.
+@return A pointer to the MTP DevicePropDesc dataset type. Ownership IS 
+transfered.
+@leave KErrNotSupported, if a FORM dataset is not defined for the property.
+@leave One of the system wide error codes, if unsuccessful.
+*/    
+EXPORT_C CMTPTypeDevicePropDesc* CMTPTypeDevicePropDesc::NewL(TUint16 aPropertyCode, const TPropertyInfo& aInfo, const MMTPType* aForm)
+    {
+    CMTPTypeDevicePropDesc* self = CMTPTypeDevicePropDesc::NewLC(aPropertyCode, aInfo, aForm); 
+    CleanupStack::Pop(self);
+    return self; 
+    }
+
+/**
+MTP DevicePropDesc dataset factory method. This method is used to create an  
+MTP DevicePropDesc dataset type with the specified values. A pointer to the 
+data type is placed on the cleanup stack.
+@param aPropertyCode The ObjectPropertyCode of the property being described by 
+the DevicePropDesc dataset.
+@param aInfo The MTP DevicePropDesc dataset characteristics (meta data).
+@param aForm The optional DevicePropDesc FORM dataset.
+@return A pointer to the MTP DevicePropDesc dataset type. Ownership IS 
+transfered.
+@leave KErrNotSupported, if a FORM dataset is not defined for the property.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeDevicePropDesc* CMTPTypeDevicePropDesc::NewLC(TUint16 aPropertyCode, const TPropertyInfo& aInfo, const MMTPType* aForm)
+    {
+    CMTPTypeDevicePropDesc* self = new (ELeave) CMTPTypeDevicePropDesc(); 
+    CleanupStack::PushL(self); 
+    self->ConstructL(aPropertyCode, aInfo, aForm);
+    return self;    
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPTypeDevicePropDesc::~CMTPTypeDevicePropDesc()
+    {
+    iChunkFlat1.Close();
+    iChunkDefaultValue.Close();
+    iChunkCurrentValue.Close();
+    iChunkForm.Close();
+    }
+
+EXPORT_C TInt CMTPTypeDevicePropDesc::FirstWriteChunk(TPtr8& aChunk)
+    {  
+    /* 
+    Reset the type in preparation for the data stream, by deleting all
+    except the first chunk.
+    */
+    for (TUint i(ChunkCount() - 1); (i >= (EIdFlat1Chunk + 1)); i--)
+        {
+        ChunkRemove(i);
+        }
+        
+    // Setup the write chunk pointer.
+    TInt err(UpdateWriteSequenceErr(CMTPTypeCompoundBase::FirstWriteChunk(aChunk)));
+    switch (err)
+        {
+    case KMTPChunkSequenceCompletion:
+        err = KErrNone;
+        // Don't break, fall through to set the write sequence state.
+        
+    case KErrNone:
+        // Set the write sequence state.
+        iWriteSequenceState = EWriteFlat1Chunk; 
+        
+        /* 
+        Set the write sequence completion state. Initially assume that the 
+        DevicePropDesc has a FORM field. If no FORM field is subsequently
+        detected in the write data stream then the completion state is 
+        adjusted accordingly.
+        */
+        iWriteSequenceCompletionState = EWriteFormChunk;
+        break;
+        
+    default:
+        break;
+        }
+        
+    return  err;
+    }
+    
+EXPORT_C TInt CMTPTypeDevicePropDesc::NextWriteChunk(TPtr8& aChunk)
+    {
+    TInt err(KMTPChunkSequenceCompletion);
+    
+    if (iWriteSequenceState != EWriteIdle)
+        {
+        err = UpdateWriteSequenceErr(CMTPTypeCompoundBase::NextWriteChunk(aChunk));
+        if ((iWriteSequenceErr == KMTPChunkSequenceCompletion) && (iWriteSequenceState != EWriteIdle))
+            {
+            err = KErrNone;
+            }   
+        }    
+    return err;
+    }
+ 
+EXPORT_C TUint CMTPTypeDevicePropDesc::Type() const
+    {
+    return EMTPTypeDevicePropDescDataset;
+    }
+    
+EXPORT_C TBool CMTPTypeDevicePropDesc::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* CMTPTypeDevicePropDesc::CommitChunkL(TPtr8& aChunk)
+    {
+    if (iWriteSequenceErr == KMTPChunkSequenceCompletion)
+        {
+        switch (iWriteSequenceState)
+            {
+        case EWriteFlat1Chunk:     
+            /* 
+            Datatype is available, allocate sufficient chunk storage for 
+            and append the EFactoryDefaultValue and ECurrentValue chunks.
+            */
+            iChunkDefaultValue.Close();
+            iChunkDefaultValue.OpenL(Uint16L(EDatatype));
+            ChunkAppendL(iChunkDefaultValue);
+            break;
+            
+        case EWriteDefaultValueChunk:
+            iChunkCurrentValue.Close();
+            iChunkCurrentValue.OpenL(Uint16L(EDatatype));
+            ChunkAppendL(iChunkCurrentValue);                        
+            break;
+            
+        case EWriteCurrentValueChunk:
+        	ChunkAppendL(iChunkFormFlag);
+        	break;
+            
+        case EWriteFormFlagChunk: 
+            /* 
+            FormFlag and Datatype are available, allocate sufficient storage for 
+            and append the FORM chunk.
+            */
+            {
+            iChunkForm.Close();
+            
+            TUint8 flag(Uint8L(EFormFlag));
+            iChunkForm.SetMeta(flag, Uint16L(EDatatype));
+            
+            if (HasFormField(flag))
+                {
+                iChunkForm.OpenL(iElementInfo[EIdFormChunk].iType);
+                ChunkAppendL(iChunkForm);
+                SetExpectedChunkCount(KNumChunksWithForm);
+                }
+            else
+                {
+                // Adjust the write sequence completion state.            
+                iWriteSequenceCompletionState = EWriteFormFlagChunk;
+                }   
+            }
+            break;
+            
+        case EWriteFormChunk:
+        case EWriteIdle:
+        default:
+            break;
+            }
+    if (iWriteSequenceState < iWriteSequenceCompletionState)
+        {
+        iWriteSequenceState++;
+        }
+    else
+        {
+        iWriteSequenceState = EWriteIdle;
+        }
+    }
+        
+    if (CMTPTypeCompoundBase::CommitRequired())
+        {
+        CMTPTypeCompoundBase::CommitChunkL(aChunk);
+        }
+    return NULL;
+    }
+    
+void CMTPTypeDevicePropDesc::PropertyInfoL(TUint16 aPropertyCode, TPropertyInfo& aInfo)
+    {    
+    switch (aPropertyCode)
+        {        
+    case EMTPDevicePropCodeUndefined:
+        aInfo.iDataType     = EMTPTypeUndefined;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeBatteryLevel:
+        aInfo.iDataType     = EMTPTypeUINT8;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeFunctionalMode:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeImageSize:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeCompressionSetting:
+        aInfo.iDataType     = EMTPTypeUINT8;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeWhiteBalance:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeRGBGain:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeFNumber:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeFocalLength:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeFocusDistance:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeFocusMode:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeExposureMeteringMode:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeFlashMode:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeExposureTime:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeExposureProgramMode:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeExposureIndex:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeExposureBiasCompensation:
+        aInfo.iDataType     = EMTPTypeINT16;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeDateTime:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeCaptureDelay:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeStillCaptureMode:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeContrast:
+        aInfo.iDataType     = EMTPTypeUINT8;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeSharpness:
+        aInfo.iDataType     = EMTPTypeUINT8;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeDigitalZoom:
+        aInfo.iDataType     = EMTPTypeUINT8;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeEffectMode:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeBurstNumber:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeBurstInterval:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeTimelapseNumber:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeTimelapseInterval:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeFocusMeteringMode:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeUploadURL:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeArtist:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeCopyrightInfo:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeSynchronizationPartner:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPDevicePropCodeDeviceFriendlyName:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPDevicePropCodeVolume:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPDevicePropCodeSupportedFormatsOrdered:
+        aInfo.iDataType     = EMTPTypeUINT8;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeDeviceIcon:
+        aInfo.iDataType     = EMTPTypeAUINT8;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodePlaybackRate:
+        aInfo.iDataType     = EMTPTypeINT32;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPDevicePropCodePlaybackObject:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPDevicePropCodePlaybackContainerIndex:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPDevicePropCodePlaybackPosition:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPDevicePropCodeSessionInitiatorVersionInfo:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPDevicePropCodePerceivedDeviceType:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeFunctionalID:
+        aInfo.iDataType     = EMTPTypeUINT128;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPDevicePropCodeModelID:
+        aInfo.iDataType     = EMTPTypeUINT128;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPDevicePropCodeUseDeviceStage:
+        aInfo.iDataType     = EMTPTypeUINT8;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    default:
+        User::Leave(KErrNotSupported);
+        break;
+        }
+    }
+    
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeDevicePropDesc::ElementInfo(TInt aElementId) const
+    {
+    return iElementInfo[aElementId];
+    }
+    
+TBool CMTPTypeDevicePropDesc::ReadableElementL(TInt aElementId) const
+    {
+    TBool ret(ETrue);
+    if (aElementId == EForm)
+        {
+        ret = HasFormField(Uint8L(EFormFlag));
+        }
+    return ret;
+    }
+    
+TBool CMTPTypeDevicePropDesc::WriteableElementL(TInt aElementId) const
+    {
+    TBool ret(EFalse);
+
+    if (!iInitialised)
+        {
+        ret = ETrue;    
+        }
+    else
+        {
+        switch (aElementId)
+            {
+        case EGetSet:
+        case EFactoryDefaultValue:
+        case ECurrentValue:
+            ret = ETrue;
+            break;
+
+        default:
+            break;
+            }   
+        }
+        
+    return ret;
+    }
+
+/*
+MTP DevicePropDesc dataset "pre-production" factory method for datasets
+which will be populated from an MTP write data stream. This method is used to 
+create a partially constructed MTP DevicePropDesc element dataset type prior to
+the construction characteristics being known. Construction of the element 
+dataset is completed on-the-fly as it is written to from an MTP write data 
+stream. A pointer to the data type is placed on the cleanup stack.
+@return A pointer to the ObjectPropList element dataset type. 
+Ownership IS transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/
+CMTPTypeDevicePropDesc* CMTPTypeDevicePropDesc::NewLC()
+    {
+    CMTPTypeDevicePropDesc* self = new(ELeave) CMTPTypeDevicePropDesc();
+    CleanupStack::PushL(self);
+    TPropertyInfo info;
+    PropertyInfoL(EMTPObjectPropCodeUndefined, info);
+    self->ConstructL(EMTPObjectPropCodeUndefined, info, NULL);
+    
+    return self;
+    }
+
+CMTPTypeDevicePropDesc::CMTPTypeDevicePropDesc() :
+    CMTPTypeCompoundBase(KJustInTimeConstruction, KNumChunksWithoutForm),
+    iElementInfo(iElementMetaData, ENumElements),
+    iChunkFlat1(KFlat1ChunkSize, *this)
+    {
+    
+    }
+
+void CMTPTypeDevicePropDesc::ConstructL(TUint16 aPropertyCode, const MMTPType* aForm)
+    {
+    TPropertyInfo info;
+    PropertyInfoL(aPropertyCode, info);
+    ConstructL(aPropertyCode, info, aForm);
+    }
+    
+void CMTPTypeDevicePropDesc::ConstructL(TUint16 aPropertyCode, const TPropertyInfo& aInfo, const MMTPType* aForm)
+    {    
+    // Construct the DevicePropDesc chunk sequence.
+    for (TUint i(0); (i < ENumElements); i++)
+        {
+        const TElementInfo& element(iElementInfo[i]);
+        if (ChunkCount() <= element.iChunkId)
+            {
+            MMTPType* chunk(NULL);
+            switch (element.iChunkId)
+                {
+            case EIdFlat1Chunk:
+                iChunkFlat1.OpenL();
+                chunk = &iChunkFlat1;
+                break;
+                
+            case EIdDefaultValueChunk:
+                if (aInfo.iDataType != EMTPTypeUndefined)
+                    {
+                    iChunkDefaultValue.OpenL(aInfo.iDataType);
+                    }
+                chunk = &iChunkDefaultValue;
+                break;
+                
+            case EIdCurrentValueChunk:
+                if (aInfo.iDataType != EMTPTypeUndefined)
+                    {
+                    iChunkCurrentValue.OpenL(aInfo.iDataType);
+                    }
+                chunk = &iChunkCurrentValue;
+                break;
+                
+            case EIdFormFlagChunk:
+                chunk = &iChunkFormFlag;
+                break;
+                
+            case EIdFormChunk:
+                iChunkForm.SetMeta(aInfo.iFormFlag, aInfo.iDataType);
+                if (HasFormField(aInfo.iFormFlag))
+                    {
+                    iChunkForm.OpenL(element.iType);
+                    chunk = &iChunkForm;
+                    }
+                break;
+                
+            default:
+                Panic(EMTPTypeBoundsError);
+                break;
+                }
+                    
+            // Some chunks (i.e. FORM) are optional.
+            if (chunk)
+                {
+                ChunkAppendL(*chunk);   
+                }
+            }
+        }
+        
+    // Set the construction values.
+    SetUint16L(EDevicePropertyCode, aPropertyCode);
+    SetUint16L(EDatatype, aInfo.iDataType);
+    SetUint8L(EGetSet, aInfo.iGetSet);
+    SetUint8L(EFormFlag, aInfo.iFormFlag);
+    
+    if (aForm)
+        {
+        if (!HasFormField(aInfo.iFormFlag))
+            { 
+            User::Leave(KMTPDataTypeInvalid);
+            } 
+        else
+            {
+            SetL(EForm, *aForm); 
+            }
+        }
+    
+    iInitialised = ETrue;
+    }    
+    
+TBool CMTPTypeDevicePropDesc::HasFormField(TUint8 aFormFlag) const
+    {
+    return (aFormFlag != ENone);
+    }
+    
+TInt CMTPTypeDevicePropDesc::UpdateWriteSequenceErr(TInt aErr)
+    {
+    iWriteSequenceErr = aErr;
+    return iWriteSequenceErr;        
+    }
+    
+CMTPTypeDevicePropDesc::RMTPTypeDevicePropDescForm::RMTPTypeDevicePropDescForm() : 
+    RMTPType()
+    {
+
+    }
+
+void CMTPTypeDevicePropDesc::RMTPTypeDevicePropDescForm::SetMeta(TUint8 aFormFlag, TUint aDataType)
+    {
+    iFormFlag = aFormFlag;
+    iDataType = aDataType;
+    }
+
+MMTPType* CMTPTypeDevicePropDesc::RMTPTypeDevicePropDescForm::CreateL(TUint aDataType)
+    {
+    if (aDataType != EMTPTypeReference)
+        {
+        User::Leave(KMTPDataTypeInvalid);
+        }
+        
+    MMTPType* type(NULL);
+    switch (iFormFlag)
+        {
+    case ERangeForm:
+        type = CMTPTypeDevicePropDescRangeForm::NewL(iDataType);
+        break;
+        
+    case EEnumerationForm:
+        type = CMTPTypeDevicePropDescEnumerationForm::NewL(iDataType);
+        break;
+        
+    default:
+        // Invalid Form Flag.
+        User::Leave(KMTPDataTypeInvalid);
+        break;
+        }
+        
+    return type;
+    }
+
+void CMTPTypeDevicePropDesc::RMTPTypeDevicePropDescForm::Destroy(MMTPType* aType)
+    {
+    switch (iFormFlag)
+        {
+    case ERangeForm:
+        delete static_cast<CMTPTypeDevicePropDescRangeForm*>(aType);
+        break;
+        
+    case EEnumerationForm:
+        delete static_cast<CMTPTypeDevicePropDescEnumerationForm*>(aType);
+        break;
+        
+    default:
+        // All other FORM types are managed by the base class.
+        RMTPType::Destroy(aType);
+        break;
+        }
+    }
+
+/**
+MTP DevicePropDesc Enumeration FORM dataset factory method. This method is used to 
+create an empty MTP DevicePropDesc FORM dataset of the specified Datatype. 
+@param aDataType The data type identifier datacode of the dataset.
+@return A pointer to the MTP DevicePropDesc dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/     
+EXPORT_C CMTPTypeDevicePropDescEnumerationForm* CMTPTypeDevicePropDescEnumerationForm::NewL(TUint aDataType)
+    {
+    CMTPTypeDevicePropDescEnumerationForm* self = CMTPTypeDevicePropDescEnumerationForm::NewLC(aDataType);
+    CleanupStack::Pop(self);
+    return self;   
+    }
+
+/**
+MTP DevicePropDesc Enumeration FORM dataset factory method. This method is used to 
+create an empty MTP DevicePropDesc FORM dataset of the specified Datatype. A 
+pointer to the data type is placed on the cleanup stack.
+@param aDataType The data type identifier datacode of the dataset.
+@return A pointer to the MTP DevicePropDesc dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/   
+EXPORT_C CMTPTypeDevicePropDescEnumerationForm* CMTPTypeDevicePropDescEnumerationForm::NewLC(TUint aDataType)
+    {
+    CMTPTypeDevicePropDescEnumerationForm* self = new(ELeave) CMTPTypeDevicePropDescEnumerationForm(aDataType);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPTypeDevicePropDescEnumerationForm::~CMTPTypeDevicePropDescEnumerationForm()
+    {
+    TInt count(iChunksValue.Count());
+    while (count--)
+    	{
+        iChunksValue[count].Close();
+        }
+    iChunksValue.Close();
+    }
+
+/**
+Appends the specified value to the set of supported enumeration values.
+@param aValue The enumeration value to append.
+@leave One of the system wide error codes, if unsuccessful.
+@panic MTPDataTypes 3, if the source value type does not match the property 
+data type.
+*/
+EXPORT_C void CMTPTypeDevicePropDescEnumerationForm::AppendSupportedValueL(const MMTPType& aValue)
+    {
+    __ASSERT_ALWAYS(aValue.Type() == iInfoValue.iType, Panic(EMTPTypeIdMismatch));
+    
+    // Increment NumberOfValues.
+    const TUint index(iChunkNumberOfValues.Value());
+    iChunkNumberOfValues.Set(index + 1);
+    
+    // Create and populate the SupportedValue chunk.
+    AppendValueChunkL();
+    SetL((KValueChunks + index), aValue);
+    }
+
+/**
+Provides the NumberOfValues element value.
+*/
+EXPORT_C TUint16 CMTPTypeDevicePropDescEnumerationForm::NumberOfValues() const
+    {
+    return iChunkNumberOfValues.Value();
+    }
+
+/**
+Provides the SupportedValue element at the specified index.
+@param aIndex The index of the required value.
+@param aValue On successful completion, the requested value.
+@leave One of the system wide error codes, if unsuccessful.
+@panic MTPDataTypes 3, if the target value type does not match the property 
+data type.
+*/
+EXPORT_C void CMTPTypeDevicePropDescEnumerationForm::SupportedValueL(TUint aIndex, MMTPType& aValue) const
+    {
+    __ASSERT_ALWAYS(aValue.Type() == iInfoValue.iType, Panic(EMTPTypeIdMismatch));
+    GetL((KValueChunks + aIndex), aValue);
+    }
+    
+EXPORT_C TInt CMTPTypeDevicePropDescEnumerationForm::FirstWriteChunk(TPtr8& aChunk)
+    {
+    /* 
+    Reset the type in preparation for the data stream, by deleting all
+    except the first chunk.
+    */
+    for (TUint i(ChunkCount() - 1); (i >= (KNumberOfValuesChunk + 1)); i--)
+        {
+        ChunkRemove(i);
+        }
+    iChunksValue.Close();
+    
+    // Setup the write chunk pointer.
+    TInt err(CMTPTypeCompoundBase::FirstWriteChunk(aChunk));
+    switch (err)
+        {
+    case KMTPChunkSequenceCompletion:
+        err = KErrNone;
+        // Don't break, fall through to set the write sequence state.
+        
+    case KErrNone:
+        // Set the write sequence state.
+        iWriteSequenceState = EInProgress;
+        break;
+        
+    default:
+        break;
+        }
+        
+    return  err;
+    }
+    
+EXPORT_C TInt CMTPTypeDevicePropDescEnumerationForm::NextWriteChunk(TPtr8& aChunk)
+    {
+    TInt err(CMTPTypeCompoundBase::NextWriteChunk(aChunk));
+    if ((err == KMTPChunkSequenceCompletion) &&
+        (iChunksValue.Count() < iChunkNumberOfValues.Value()))
+        {
+        err = KErrNone; 
+        }
+    return err;
+    }
+ 
+EXPORT_C TUint CMTPTypeDevicePropDescEnumerationForm::Type() const
+    {
+    return EMTPTypeDevicePropDescEnumerationFormDataset;
+    }
+    
+EXPORT_C TBool CMTPTypeDevicePropDescEnumerationForm::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* CMTPTypeDevicePropDescEnumerationForm::CommitChunkL(TPtr8& aChunk)
+    {
+    switch (iWriteSequenceState)
+        {
+    case EInProgress:
+        if (iChunksValue.Count() < iChunkNumberOfValues.Value())
+            {
+            AppendValueChunkL(); 
+            }
+        else
+            {
+            iWriteSequenceState = EIdle;
+            }
+        break;
+        
+    case EIdle:
+        // Completing the last element in the write sequence.
+        break;
+        
+    default:
+        Panic(EMTPTypeBadStorage);
+        break;
+        }
+        
+    if (CMTPTypeCompoundBase::CommitRequired())
+        {
+        CMTPTypeCompoundBase::CommitChunkL(aChunk);
+        }     
+    return NULL;
+    }
+ 
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeDevicePropDescEnumerationForm::ElementInfo(TInt aElementId) const
+    {
+    if (aElementId == KNumberOfValuesChunk)
+        {
+        return iInfoNumberOfValues;
+        }
+    else
+        {
+        __ASSERT_ALWAYS(((aElementId - KValueChunks) < iChunkNumberOfValues.Value()), Panic(EMTPTypeBoundsError));
+        iInfoValue.iChunkId = aElementId;
+        return iInfoValue; 
+        }
+    }
+
+TInt CMTPTypeDevicePropDescEnumerationForm::ValidateChunkCount() const
+    {
+    TInt ret(KErrNone);
+    if (NumberOfValues() != (ChunkCount() - 1))
+        {
+        ret = KMTPDataTypeInvalid;
+        }
+    return ret;
+    }
+
+CMTPTypeDevicePropDescEnumerationForm::CMTPTypeDevicePropDescEnumerationForm(TUint aDataType) :
+    CMTPTypeCompoundBase(KJustInTimeConstruction, KVariableChunkCount)
+    {
+    const CMTPTypeCompoundBase::TElementInfo KDefaultInfo = {0, EMTPTypeUndefined, {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}};
+    iInfoNumberOfValues         = KDefaultInfo; 
+    iInfoNumberOfValues.iType   = EMTPTypeUINT16;
+    iInfoValue                  = KDefaultInfo; 
+    iInfoValue.iType            = aDataType;
+    }
+
+void CMTPTypeDevicePropDescEnumerationForm::ConstructL()
+    {
+    ChunkAppendL(iChunkNumberOfValues);
+    }
+    
+void CMTPTypeDevicePropDescEnumerationForm::AppendValueChunkL()
+    {
+    iChunksValue.AppendL(RMTPType());
+    
+    RMTPType& chunk(iChunksValue[iChunksValue.Count() - 1]);
+    chunk.OpenL(iInfoValue.iType);
+    ChunkAppendL(chunk);
+    }
+
+/**
+MTP DevicePropDesc Range FORM dataset factory method. This method is used to 
+create an empty MTP DevicePropDesc FORM dataset of the specified Datatype. 
+@param aDataType The data type identifier datacode of the dataset.
+@return A pointer to the MTP DevicePropDesc dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/   
+EXPORT_C CMTPTypeDevicePropDescRangeForm* CMTPTypeDevicePropDescRangeForm::NewL(TUint aDataType)
+    {
+    CMTPTypeDevicePropDescRangeForm* self = CMTPTypeDevicePropDescRangeForm::NewLC(aDataType);
+    CleanupStack::Pop(self); 
+    return self;
+    }
+
+/**
+MTP DevicePropDesc Range FORM dataset factory method. This method is used to 
+create an empty MTP DevicePropDesc FORM dataset of the specified Datatype. A 
+pointer to the data type is placed on the cleanup stack.
+@param aDataType The data type identifier datacode of the dataset.
+@return A pointer to the MTP DevicePropDesc dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/   
+EXPORT_C CMTPTypeDevicePropDescRangeForm* CMTPTypeDevicePropDescRangeForm::NewLC(TUint aDataType)
+    {
+    CMTPTypeDevicePropDescRangeForm* self = new(ELeave) CMTPTypeDevicePropDescRangeForm(aDataType);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPTypeDevicePropDescRangeForm::~CMTPTypeDevicePropDescRangeForm()
+    {
+    TInt count(iChunks.Count());
+    while (count--)
+        {
+        iChunks[count].Close();
+        }
+    iChunks.Reset();
+    }
+
+EXPORT_C TUint CMTPTypeDevicePropDescRangeForm::Type() const
+    {
+    return EMTPTypeDevicePropDescRangeFormDataset;
+    } 
+
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeDevicePropDescRangeForm::ElementInfo(TInt aElementId) const
+    {
+    __ASSERT_ALWAYS((aElementId < ENumElements), Panic(EMTPTypeBoundsError));
+    iInfoBuf.iChunkId = aElementId;
+    return iInfoBuf;    
+    }
+
+CMTPTypeDevicePropDescRangeForm::CMTPTypeDevicePropDescRangeForm(TUint aDataType) : 
+    CMTPTypeCompoundBase((!KJustInTimeConstruction), ENumElements), 
+    iDataType(aDataType)
+    {
+    const CMTPTypeCompoundBase::TElementInfo KDefaultInfo = {0, EMTPTypeReference, {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}};
+    iInfoBuf = KDefaultInfo;
+    }
+
+void CMTPTypeDevicePropDescRangeForm::ConstructL()
+    {
+    for (TUint i(0); (i < ENumElements); i++)   
+        {
+        iChunks.AppendL(RMTPType());
+        iChunks[i].OpenL(iDataType);
+        ChunkAppendL(iChunks[i]);
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypefile.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,620 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ */
+
+#include <mtp/cmtptypefile.h>
+#include <mtp/mtpdatatypeconstants.h>
+
+// File type constants.
+const TInt KMTPFileChunkSizeForLargeFile(0x00080000); // 512K
+
+//For file size less than 512K, we will use this smaller chunk size to reduce the heap usage.
+const TInt KMTPFileChunkSizeForSmallFile(0x00010000); //64K
+
+//For file size larger than it, we will split one setSize() to several smaller one, each with the following size.
+const TInt64 KMTPFileSetSizeChunk(1<<30); //1G
+
+const TUint KUSBHeaderLen = 12;
+
+/**
+ MTP file object data type factory method. 
+ @param aFs The handle of an active file server session.
+ @param aName The name of the file. Any path components (i.e. drive letter
+ or directory), which are not specified, are taken from the session path. 
+ @param aMode The mode in which the file is opened (@see TFileMode).
+ @return A pointer to the MTP file object data type. Ownership IS transfered.
+ @leave One of the system wide error codes, if a processing failure occurs.
+ @see TFileMode
+ */
+EXPORT_C CMTPTypeFile* CMTPTypeFile::NewL(RFs& aFs, const TDesC& aName, TFileMode aMode)
+    {
+    CMTPTypeFile* self = NewLC(aFs, aName, aMode);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+ MTP file object data type factory method. A pointer to the MTP file object data
+ type is placed on the cleanup stack.
+ @param aFs The handle of an active file server session.
+ @param aName The name of the file. Any path components (i.e. drive letter
+ or directory), which are not specified, are taken from the session path. 
+ @param aMode The mode in which the file is opened (@see TFileMode).
+ @return A pointer to the MTP file object data type. Ownership IS transfered.
+ @leave One of the system wide error codes, if a processing failure occurs.
+ @see TFileMode
+ */
+EXPORT_C CMTPTypeFile* CMTPTypeFile::NewLC(RFs& aFs, const TDesC& aName, TFileMode aMode)
+    {
+    CMTPTypeFile* self = new(ELeave) CMTPTypeFile;
+    CleanupStack::PushL(self);
+    self->ConstructL(aFs, aName, aMode);
+    return self;
+    }
+
+EXPORT_C CMTPTypeFile* CMTPTypeFile::NewL(RFs& aFs, const TDesC& aName, TFileMode aMode, TInt64 aRequiredSize, TInt64 aOffSet)
+    {
+    CMTPTypeFile* self = NewLC(aFs, aName, aMode,aRequiredSize,aOffSet);
+	CleanupStack::Pop(self);
+    return self;
+    }
+
+EXPORT_C CMTPTypeFile* CMTPTypeFile::NewLC(RFs& aFs, const TDesC& aName, TFileMode aMode, TInt64 aRequiredSize, TInt64 aOffSet)
+    {
+    CMTPTypeFile* self = new(ELeave) CMTPTypeFile;
+    CleanupStack::PushL(self);
+    self->ConstructL(aFs, aName, aMode, aRequiredSize, aOffSet);
+    return self;
+    }
+
+/**
+ Destructor
+ */
+EXPORT_C CMTPTypeFile::~CMTPTypeFile()
+    {
+    if(iCurrentCommitChunk.Length() != 0)
+        {
+        ToggleRdWrBuffer();
+        }
+
+    iFile.Close();
+
+    iBuffer1.Close();
+    iBuffer2.Close();
+    Cancel();
+    }
+
+/**
+ Sets the size of the file, this function must be called in case of file writting/receiving. related resouce
+ will be allocated in this function to prepare to receive the incoming data.
+ @param aSize The new size of the file (in bytes).
+ @leave One of the system wide error codes, if a processing failure occurs.
+ */
+EXPORT_C void CMTPTypeFile::SetSizeL(TUint64 aSize)
+    {
+    iTargetFileSize = (TInt64)aSize; //keep a record for the target file size
+    
+    iRemainingDataSize = (TInt64)aSize;//Current implemenation does not support file size with 2 x64 
+
+    if(iRemainingDataSize> KMTPFileChunkSizeForLargeFile) //512K
+        {
+        iBuffer1.CreateMaxL(KMTPFileChunkSizeForLargeFile);
+        iBuffer2.CreateMaxL(KMTPFileChunkSizeForLargeFile);
+        }
+    else
+        {
+        iBuffer1.CreateMaxL(KMTPFileChunkSizeForSmallFile);
+        iBuffer2.CreateMaxL(KMTPFileChunkSizeForSmallFile);
+        }
+    if(iRemainingDataSize> KMTPFileSetSizeChunk)
+        {
+        //split the setSize to multiple calling of 512M
+        User::LeaveIfError(iFile.SetSize(KMTPFileSetSizeChunk));
+        iCurrentFileSetSize = KMTPFileSetSizeChunk;
+        }
+    else
+        {
+        User::LeaveIfError(iFile.SetSize(aSize));
+        iCurrentFileSetSize = aSize;
+        }
+    }
+
+/**
+ Provides a reference to the native file object encapsulate by the MTP file 
+ object data type.
+ @return The native file object reference.
+ */
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+EXPORT_C RFile64& CMTPTypeFile::File()
+#else
+EXPORT_C RFile& CMTPTypeFile::File()
+#endif
+    {
+    return iFile;
+    }
+
+EXPORT_C TInt CMTPTypeFile::FirstReadChunk(TPtrC8& aChunk) const
+    {
+    aChunk.Set(NULL, 0);
+    iReadSequenceState = EIdle;
+    iBuffer1.Zero();
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+    TInt64 pos =iOffSet;
+#else
+    TInt pos = static_cast<TInt>(iOffSet);
+#endif
+    TInt err(iFile.Seek(ESeekStart, pos));
+    if (err == KErrNone)
+        {
+        // The USB SIC header is 12 bytes long. If the first chunk is 128K - 12 bytes, 
+        // the USB SIC transport will not buffer data, which will improve the transfer rate.
+        err = iFile.Read(iBuffer1, iBuffer1.MaxLength() - KUSBHeaderLen);
+        if (err == KErrNone)
+            {
+            //this chunk is going to be used by USB to read  data from it, only CMTPTypefile::RunL() can toggle this flag
+            //When it finishe reading data into Buffer2.
+            iBuffer1AvailForWrite = EFalse;
+
+            aChunk.Set(iBuffer1.Ptr(), iBuffer1.Length());
+
+            //Set the commit chunk to be filled in by CMTPTypeFile::RunL()
+            iCurrentCommitChunk.Set(&iBuffer2[0], 0, iBuffer2.MaxLength());
+
+            iRemainingDataSize -= aChunk.Length();
+
+            if (aChunk.Length() == 0)
+                {
+                // Empty File.
+                iReadSequenceState = EIdle;
+                err = KMTPChunkSequenceCompletion;
+                }
+            else
+                {
+                if (iRemainingDataSize <= 0)
+                    {
+                    // EOF.
+                    iReadSequenceState = EIdle;
+                    aChunk.Set(aChunk.Ptr(), aChunk.Length() + iRemainingDataSize);  //for partial
+                    err = KMTPChunkSequenceCompletion;
+                    }
+                else
+                    {
+                    iReadSequenceState = EInProgress;
+                    //This is NOT the last chunk, issue more CMTPTypeFile::RunL()
+                    if (!IsActive())
+                        {
+                        //Since the writting data into file sever will take a long time, will issue a dedicated Active Object to do that.
+                        const_cast<CMTPTypeFile*>(this)->SetActive();
+                        TRequestStatus* status = (TRequestStatus*)&iStatus;
+                        User::RequestComplete(status, KErrNone);
+                        }
+                    else
+                        {
+                        //This is a very extreme cases, it only occurs when the following assumption is met
+                        //1. USB already took buffer1 and already issue CMTPTypeFileRunL(), therefore, the ActiveObject has completed itself, 
+                        //2. Somehow, this active object is not scheduled to be running even after the USB already use out the other buffer.
+                        //3. USB's active object is scheduled to be running prior to the last File active object(this should not happen if ActiveScheduler follow the priority scheduler).
+                        //4. USB call this function again to get the other data buffer.
+                        //5. Then it find the previous active is not scheduled to run.
+                        //in single-core platform, the code rely on the CActiveScheduler to guarantee the first active call which has higher priority to be running firstly before
+                        //the 2nd USB active. but for multi-core platform, this should be re-evaluated .
+                        iReadSequenceState = EIdle;
+                        err = KMTPChunkSequenceCompletion;
+                        }
+                    }
+                }
+            }
+        else
+            {
+            iReadSequenceState = EIdle;
+            iFileRdWrError = ETrue;
+            }
+        }
+    iByteSent += aChunk.Length();
+    return err;
+    }
+
+EXPORT_C TInt CMTPTypeFile::NextReadChunk(TPtrC8& aChunk) const
+    {
+    TInt err(KErrNone);
+
+    if((iReadSequenceState != EInProgress) || (iFileRdWrError))
+        {
+        aChunk.Set(NULL, 0);
+        return KErrNotReady;
+        }
+
+    //This is called by USB's RunL(), here, the only possible scenarios is that the CMTPTypleFile::RunL() issued in FirReadChunk or last NextReadChunk must 
+    //have already finished. Now take the buffer which is filled in by data in CMTPTypleFile::RunL().
+    aChunk.Set(iCurrentCommitChunk.Ptr(), iCurrentCommitChunk.Length());
+    if(iBuffer1AvailForWrite)
+        {//We have already used buffer_1, now buffer2 contains data read into by CMTPTypeFile::RunL();
+        //Set the commit chunk to be filled in by CMTPTypeFile::RunL()
+        iCurrentCommitChunk.Set(&iBuffer1[0], 0, iBuffer1.MaxLength());
+        }
+    else
+        {
+        //Set the commit chunk to be filled in by CMTPTypeFile::RunL()
+        iCurrentCommitChunk.Set(&iBuffer2[0], 0, iBuffer2.MaxLength());
+        }
+
+    iRemainingDataSize -= aChunk.Length();
+
+    if(aChunk.Length() == 0)
+        {
+        iReadSequenceState = EIdle;
+        err = KMTPChunkSequenceCompletion;
+        }
+    else if(iRemainingDataSize> 0)
+        {
+        //This is NOT the last chunk, issue more CMTPTypeFile::RunL()
+        if (!IsActive())
+            {
+            //Since the writting data into file sever will take a long time, will issue a dedicated Active Object to do that.
+            ((CMTPTypeFile*)this)->SetActive();
+            TRequestStatus* status = (TRequestStatus*)&iStatus;
+            User::RequestComplete(status, KErrNone);
+            }
+        else
+            {
+            //This is a very extreme cases, it only occurs when the following assumption is met
+            //1. USB already took buffer1 and already issue CMTPTypeFileRunL(), therefore, the ActiveObject has completed itself, 
+            //2. Somehow, this active object is not scheduled to be running even after the USB already use out the other buffer.
+            //3. USB's active object is scheduled to be running prior to the last File active object(this should not happen if ActiveScheduler follow the priority scheduler).
+            //4. USB call this function again to get the other data buffer.
+            //5. Then it find the previous active is not scheduled to run.
+            //in single-core platform, the code rely on the CActiveScheduler to guarantee the first active call which has higher priority to be running firstly before
+            //the 2nd USB active. but for multi-core platform, this should be re-evaluated .
+            iReadSequenceState = EIdle;
+            err = KMTPChunkSequenceCompletion;
+            }
+        }
+    else
+        {//Last Chunk. Do not issue Active object. and indicate this completion of the chunk
+        iReadSequenceState = EIdle;
+        aChunk.Set(aChunk.Ptr(), aChunk.Length() + iRemainingDataSize); //for partial
+        err = KMTPChunkSequenceCompletion;
+        }
+    iByteSent += aChunk.Length();
+    return err;
+    }
+
+EXPORT_C TInt CMTPTypeFile::FirstWriteChunk(TPtr8& aChunk)
+    {
+    __ASSERT_DEBUG(iBuffer1AvailForWrite, User::Invariant());
+    __ASSERT_DEBUG(!iFileRdWrError, User::Invariant());
+
+    aChunk.Set(NULL, 0, 0);
+    iWriteSequenceState = EIdle;
+    
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+    TInt64 pos =0;
+#else
+    TInt pos =0;
+#endif
+    TInt err(iFile.Seek(ESeekStart, pos));
+    if (err == KErrNone)
+        {
+        //Because USB HS's transmission rate is several time faster than the rate of writting data into File System.
+        //If the first packet is a full chunk size packet, then the writting of that data will not start until the full-chunk
+        //sized packet is received. Here we intentionly reduce the first packet size to 1/4 of the full chunk size, therefore,
+        //the start of writting data into File system will start only after 1/4 of the full chunk size data is received.
+        //This can make the writting of data to FS start earlier.
+        aChunk.Set(&iBuffer1[0], 0, iBuffer1.MaxLength());
+        iWriteSequenceState = EInProgress;
+
+        //this chunk is going to be used by Transport to write data into it, and when it is full, transport
+        //will call back CommitChunkL(), at that time, the EFalse means it already contains data in it.
+        //it is ready for reading data from it. 
+        //This is a initial value for it to trigger the double-buffering mechanism.
+        iBuffer1AvailForWrite = EFalse;
+        }
+
+    return err;
+    }
+
+EXPORT_C TInt CMTPTypeFile::NextWriteChunk(TPtr8& aChunk)
+    {
+    TInt err(KErrNone);
+    aChunk.Set(NULL, 0, 0);
+
+    if (iWriteSequenceState != EInProgress)
+        {
+        err = KErrNotReady;
+        }
+    else
+        {//toggle between buffer 1 and buffer 2 here.
+        if(iBuffer1AvailForWrite)
+            {
+            aChunk.Set(&iBuffer1[0], 0, iBuffer1.MaxLength());
+            }
+        else
+            {
+            aChunk.Set(&iBuffer2[0], 0, iBuffer2.MaxLength());
+            }
+        }
+
+    return err;
+    }
+
+EXPORT_C TUint64 CMTPTypeFile::Size() const
+    {
+    //The USB transport layer uses USB Container Length to determine the total size of data to be
+    //transfered. In USB protocol, the Container Length is 32 bits long which is up to 4G-1, so 
+    //for synchronization of a large file >=4G-12 bytes (the USB header is 12 bytes long), the
+    //Container Length can't be used to determine the total size of data any more. In this kind of
+    //case, our USB transport layer implementation will call this function to get the actual data size.
+    
+    //The RFile::SetSize() method may take over 40 seconds if we create a file and set its size
+    //to a very large value, and this will cause timeout in MTP protocol layer. To avoid this 
+    //timeout, when creating a large file(over 512MB), instead of setting its size directly to
+    //the target size by one singile RFile::SetSize() call, we'll call RFile::SetSize() multiple
+    //times and set the file size step by step acumulately. For example, for a 2GB file, its
+    //size will be set to 0.5G first, and then 1G, 1.5G and at last 2G.
+    
+    //So if a file is transfering to device, the size of the file that returned by RFile::Size() is
+    //just a temporary value and means nothing. In this case, let's return the target file size instead.
+    if(!iFileOpenForRead && iRemainingDataSize)
+        {        
+        return iTargetFileSize;
+        }
+    
+    //If the initiator get partial of the file, return the requested partial size 
+    if (iFileOpenForRead && iTargetFileSize)
+        {
+        return iTargetFileSize;
+        }
+    
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+    TInt64 size;
+#else
+    TInt size;
+#endif
+    iFile.Size(size);
+    return size;
+    }
+
+EXPORT_C TUint CMTPTypeFile::Type() const
+    {
+    return EMTPTypeFile;
+    }
+
+EXPORT_C TBool CMTPTypeFile::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* CMTPTypeFile::CommitChunkL(TPtr8& aChunk)
+    {
+	if(iFileRdWrError)
+		{
+		return NULL;
+		}
+	if(0 == aChunk.Length())
+		{
+		ToggleRdWrBuffer();
+		return NULL;
+		}
+    iCurrentCommitChunk.Set(aChunk);
+
+    if(iRemainingDataSize> iCurrentCommitChunk.Length())
+        {//This is NOT the last chunk, we issue an active object to commit it to File system.
+        iRemainingDataSize -= iCurrentCommitChunk.Length();
+		/*
+		if (!IsActive())
+			{
+			//Since the writting data into file sever will take a long time, will issue a dedicated Active Object to do that.
+			SetActive();
+			TRequestStatus* thisAO = &iStatus;
+			User::RequestComplete(thisAO, KErrNone);
+			}
+		else
+			{
+			//This is a very extreme cases, it only occurs when the following assumption is met
+			//1. USB received buffer1 and already call this CommitChunkL(), therefore, the ActiveObject has completed itself, and USB then use another buffer to
+			//receive the data.
+			//2. Somehow, this active object is not scheduled to be running even after the USB already fill out the other buffer.
+			//3. USB's active object is scheduled to be running prior to the last File active object(this should not happen if ActiveScheduler follow the priority scheduler).
+			//4. USB call this function again to commit the other data buffer.
+			//5. Then it find the previous active is not scheduled to run.
+			//in single-core platform, the code rely on the CActiveScheduler to guarantee the first active call which has higher priority to be running firstly before
+			//the 2nd USB active. but for multi-core platform, this should be re-evaluated .
+			iFileRdWrError = ETrue;//if it really discard the incoming recevied file.			
+			//__FLOG(_L8("\nThe program should not arrive here !!!!!\n"));
+			}
+			*/
+        }
+    else
+        {//This is the last chunk, we synchronous commit it 
+        iRemainingDataSize = 0;
+        ToggleRdWrBuffer();
+			return NULL;
+        }
+	return this;
+    }
+
+//for partial
+EXPORT_C Int64 CMTPTypeFile::GetByteSent()
+    {
+    return iByteSent;
+    }
+
+CMTPTypeFile::CMTPTypeFile() :
+    CActive(EPriorityUserInput), iBuffer1AvailForWrite(ETrue),
+        iFileRdWrError(EFalse), iCurrentCommitChunk(NULL, 0)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+void CMTPTypeFile::ConstructL(RFs& aFs, const TDesC& aName, TFileMode aMode)
+    {
+    if (aMode & EFileWrite)
+        {
+        iFileOpenForRead = EFalse;
+        User::LeaveIfError(iFile.Replace(aFs, aName, aMode|EFileWriteDirectIO));
+        }
+    else
+        {
+        iFileOpenForRead = ETrue;
+        User::LeaveIfError(iFile.Open(aFs, aName, aMode|EFileReadDirectIO|EFileShareReadersOnly));
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+        TInt64 size = 0;
+#else
+        TInt size = 0;
+#endif
+        User::LeaveIfError(iFile.Size(size));
+        iRemainingDataSize = size;
+
+        //For File reading, NO "SetSizeL()" will be called, therefore, create the buffer here.
+        if (iRemainingDataSize > KMTPFileChunkSizeForLargeFile) //512K
+            {
+            iBuffer1.CreateMaxL(KMTPFileChunkSizeForLargeFile);
+            iBuffer2.CreateMaxL(KMTPFileChunkSizeForLargeFile);
+            }
+        else
+            {
+            iBuffer1.CreateMaxL(KMTPFileChunkSizeForSmallFile);
+            iBuffer2.CreateMaxL(KMTPFileChunkSizeForSmallFile);
+            }
+        }
+    }
+
+void CMTPTypeFile::ConstructL(RFs& aFs, const TDesC& aName, TFileMode aMode, TInt64 aRequiredSize, TInt64 aOffSet)
+	{
+    if (aMode & EFileWrite)
+        {
+        iFileOpenForRead = EFalse;
+        User::LeaveIfError(iFile.Replace(aFs, aName, aMode|EFileWriteDirectIO));
+        }
+    else
+        {
+        iFileOpenForRead = ETrue;
+        iOffSet = aOffSet;
+        User::LeaveIfError(iFile.Open(aFs, aName, aMode|EFileReadDirectIO|EFileShareReadersOnly));
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+        TInt64 size = 0;
+#else
+        TInt size = 0;
+#endif
+        User::LeaveIfError(iFile.Size(size));
+        
+        if(aRequiredSize < size)
+            {
+            iTargetFileSize = aRequiredSize;
+            }
+        else
+            {
+            iTargetFileSize = size;
+            }
+        iRemainingDataSize = iTargetFileSize;
+        
+        //For File reading, NO "SetSizeL()" will be called, therefore, create the buffer here.
+        if (iRemainingDataSize > KMTPFileChunkSizeForLargeFile) //512K
+            {
+            iBuffer1.CreateMaxL(KMTPFileChunkSizeForLargeFile);
+            iBuffer2.CreateMaxL(KMTPFileChunkSizeForLargeFile);
+            }
+        else
+            {
+            iBuffer1.CreateMaxL(KMTPFileChunkSizeForSmallFile);
+            iBuffer2.CreateMaxL(KMTPFileChunkSizeForSmallFile);
+            }
+        }
+	}
+
+void CMTPTypeFile::DoCancel()
+    {
+    // Nothing to cancel here because this Active object does not issue any asynchronous call to others.
+    }
+
+// Catch any leaves - the CActiveScheduler can't handle it.
+TInt CMTPTypeFile::RunError(TInt /* aError*/)
+    {
+    //We did not throw exception in RunL() in reality, therefore, we need not to cope with it.
+    return KErrNone;
+    }
+
+void CMTPTypeFile::RunL()
+    {
+    ToggleRdWrBuffer();
+    }
+
+void CMTPTypeFile::ToggleRdWrBuffer()
+    {
+    //This is triggered by CommitChunkL(), this will write the received data into File system synchronously.
+    //Since someone trigger this RunL(), therefore, there must be one of 2 buffer which is full of data to wait for writing buffer data into File system.
+    //Each RunL(), only need to commit one chunk because transport only prepare one chunk for file system in one RunL().
+
+    TInt err = KErrNone;
+
+    if (!iFileOpenForRead)
+        {
+        if (!iFileRdWrError)
+            {
+            TInt64 temp = iCurrentCommitChunk.Length();            
+            iTotalReceivedSize += temp;
+            if (iTotalReceivedSize > iCurrentFileSetSize)
+                {
+                //temp += iRemainingDataSize;//Total uncommitted file size.
+                temp = iTotalReceivedSize-iCurrentFileSetSize+iRemainingDataSize;
+                if (temp >= KMTPFileSetSizeChunk)
+                    {
+                    iCurrentFileSetSize += KMTPFileSetSizeChunk;
+                    }
+                else
+                    {
+                    iCurrentFileSetSize += temp;
+                    }
+                err = iFile.SetSize(iCurrentFileSetSize);
+                }
+                        
+            if (err != KErrNone)
+                {
+                iFileRdWrError = ETrue;
+                }
+            else
+                {
+                err = iFile.Write(iCurrentCommitChunk);
+                if (err != KErrNone)
+                    {// file Write failed,	this means we cannot successfully received this file but however, we cannot disrupt a current DIOR phase according to MTP spec.
+                    // We should continue to receive the data and discard this data, only after the data  phase is finished can we send back an error response
+                    //to Initiator. Therefore, we pretend to continue to write this data into file, and let final processor to check the file size and then give back a 
+                    //corresponding error code to MTP initiator.
+                    iFileRdWrError = ETrue;
+                    iFile.SetSize(0);
+                    }
+                }
+            }
+        iCurrentCommitChunk.Zero();
+        }
+    else
+        {
+        if (!iFileRdWrError)
+            {
+            err = iFile.Read(iCurrentCommitChunk,
+                    iCurrentCommitChunk.MaxLength());
+            if (err != KErrNone)
+                {//Error, abort the current file reading.
+                iFileRdWrError = ETrue;
+                }
+            }
+        }
+
+    iBuffer1AvailForWrite = !iBuffer1AvailForWrite;//toggle the flag.
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypeinterdependentpropdesc.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,478 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/cmtptypeobjectpropdesc.h>
+#include <mtp/cmtptypeinterdependentpropdesc.h>
+#include <mtp/mtpdatatypeconstants.h>
+
+#include "mtpdatatypespanic.h"
+
+// Dataset constants    
+const TUint CMTPTypeInterdependentPropDesc::KNumberOfInterdependenciesChunk(0);
+const TUint CMTPTypeInterdependentPropDesc::KInterdependentPropertiesChunks(1);
+
+const TUint CMTPTypeInterdependentProperties::KNumberOfPropDescsChunk(0);
+const TUint CMTPTypeInterdependentProperties::KObjectPropDescChunks(1);
+
+/**
+MTP InterdependentPropDesc dataset factory method. This method is used to create an 
+empty MTP InterdependentPropDesc dataset. 
+@return A pointer to the MTP InterdependentPropDesc dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeInterdependentPropDesc* CMTPTypeInterdependentPropDesc::NewL()
+    {
+    CMTPTypeInterdependentPropDesc* self = CMTPTypeInterdependentPropDesc::NewLC(); 
+    CleanupStack::Pop(self); 
+    return self;  
+    }
+
+/**
+MTP InterdependentPropDesc dataset factory method. This method is used to create an 
+empty MTP InterdependentPropDesc dataset. A pointer to the data type is placed on the
+cleanup stack.
+@return A pointer to the MTP InterdependentPropDesc dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeInterdependentPropDesc* CMTPTypeInterdependentPropDesc::NewLC()
+    {
+    CMTPTypeInterdependentPropDesc* self = new(ELeave) CMTPTypeInterdependentPropDesc();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPTypeInterdependentPropDesc::~CMTPTypeInterdependentPropDesc()
+    {
+    iChunksInterdependentProperties.ResetAndDestroy();
+    }
+
+/**
+Appends the specified InterdependentPropDesc value quadruple to the InterdependentPropDesc. 
+Ownership of the specified InterdependentPropDesc value quadruple is passed to the 
+InterdependentPropDesc.
+@param aElement The InterdependentPropDesc value quadruple to append. Ownership IS
+transferred.
+@leave One of the system wide error codes, if unsuccessful.
+*/
+EXPORT_C void CMTPTypeInterdependentPropDesc::AppendL(CMTPTypeInterdependentProperties* aInterdependentProperties)
+    {
+    // Increment NumberOfElements.
+    const TUint index(iChunkNumberOfInterdependencies.Value());
+    iChunkNumberOfInterdependencies.Set(index + 1);
+    
+    // Append the element.
+    AppendElementChunkL(aInterdependentProperties);
+    }
+
+/**
+Provides the NumberOfElements element value.
+*/
+EXPORT_C TUint32 CMTPTypeInterdependentPropDesc::NumberOfInterdependencies() const
+    {
+    return iChunkNumberOfInterdependencies.Value();
+    }
+
+/**
+Provides a non-const reference to the InterdependentPropDesc value quadruple element at
+the specified index.
+@param aIndex The index of the required element.
+@param aValue On successful completion, a non-const reference to the requested
+element.
+@leave One of the system wide error codes, if unsuccessful.
+*/
+EXPORT_C CMTPTypeInterdependentProperties& CMTPTypeInterdependentPropDesc::InterdependentProperties(TUint aIndex) const
+    {
+    return *iChunksInterdependentProperties[aIndex];
+    }
+
+EXPORT_C TInt CMTPTypeInterdependentPropDesc::FirstWriteChunk(TPtr8& aChunk)
+    {   
+    /* 
+    Reset the type in preparation for the data stream, by deleting all
+    except the first chunk.
+    */
+    for (TUint i(ChunkCount() - 1); (i >= (KNumberOfInterdependenciesChunk + 1)); i--)
+        {
+        ChunkRemove(i);
+        }
+    iChunksInterdependentProperties.ResetAndDestroy();
+    
+    // Setup the write chunk pointer.
+    TInt err(UpdateWriteSequenceErr(CMTPTypeCompoundBase::FirstWriteChunk(aChunk)));
+    switch (err)
+        {
+    case KMTPChunkSequenceCompletion:
+        err = KErrNone;
+        // Don't break, fall through to set the write sequence state.
+        
+    case KErrNone:
+        // Set the write sequence state.
+        iWriteSequenceState = EInProgress;
+        break;
+        
+    default:
+        break;
+        }
+        
+    return  err;
+    }
+    
+EXPORT_C TInt CMTPTypeInterdependentPropDesc::NextWriteChunk(TPtr8& aChunk)
+    {
+    TInt err(KMTPChunkSequenceCompletion);
+    
+    if (iWriteSequenceState != EIdle)
+       {
+       err = UpdateWriteSequenceErr(CMTPTypeCompoundBase::NextWriteChunk(aChunk));
+       if ((iWriteSequenceErr == KMTPChunkSequenceCompletion) && (iWriteSequenceState != EIdle))
+           {
+           err = KErrNone;
+           }   
+       }    
+    return err;
+       
+    }
+
+EXPORT_C TUint CMTPTypeInterdependentPropDesc::Type() const
+    {
+    return EMTPTypeInterdependentPropDescDataset;
+    }
+
+EXPORT_C TBool CMTPTypeInterdependentPropDesc::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* CMTPTypeInterdependentPropDesc::CommitChunkL(TPtr8& aChunk)
+    {
+    if (iWriteSequenceErr == KMTPChunkSequenceCompletion)
+        {
+        switch (iWriteSequenceState)
+            {
+        case EInProgress:
+            if ((iChunkNumberOfInterdependencies.Value()) && 
+                (iChunksInterdependentProperties.Count() < iChunkNumberOfInterdependencies.Value()))
+                {
+                // Allocate the next element chunk.
+                CMTPTypeInterdependentProperties* element = CMTPTypeInterdependentProperties::NewLC();
+                AppendElementChunkL(element);
+                CleanupStack::Pop(element);
+                }
+            else
+                {
+                iWriteSequenceState = EIdle;
+                }
+            break;
+            
+        case EIdle:
+            // Completing the last element in the write sequence.
+            break;
+            
+        default:
+            Panic(EMTPTypeBadStorage);
+            break;
+            }
+        }
+        
+    if (CMTPTypeCompoundBase::CommitRequired())
+        {
+        CMTPTypeCompoundBase::CommitChunkL(aChunk);
+        }     
+    return NULL;
+    }
+ 
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeInterdependentPropDesc::ElementInfo(TInt aElementId) const
+    {
+    if (aElementId == KNumberOfInterdependenciesChunk)
+        {
+        return iInfoNumberOfInterdependencies;
+        }
+    else
+        {
+        __ASSERT_ALWAYS(((aElementId - KInterdependentPropertiesChunks) < iChunkNumberOfInterdependencies.Value()), Panic(EMTPTypeBoundsError));
+        iInfoInterdependentProperties.iChunkId = aElementId;
+        return iInfoInterdependentProperties; 
+        }
+    }
+
+TInt CMTPTypeInterdependentPropDesc::ValidateChunkCount() const
+    {
+    TInt ret(KErrNone);
+    if (NumberOfInterdependencies() != (ChunkCount() - 1))
+        {
+        ret = KMTPDataTypeInvalid;
+        }
+    return ret;
+    }
+
+CMTPTypeInterdependentPropDesc::CMTPTypeInterdependentPropDesc() :
+    CMTPTypeCompoundBase(KJustInTimeConstruction, KVariableChunkCount)
+    {
+    const CMTPTypeCompoundBase::TElementInfo KDefaultInfo = {0, EMTPTypeUndefined, {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}};
+    iInfoNumberOfInterdependencies          = KDefaultInfo; 
+    iInfoNumberOfInterdependencies.iType    = EMTPTypeUINT32;
+    iInfoInterdependentProperties           = KDefaultInfo; 
+    iInfoInterdependentProperties.iType     = EMTPTypeInterdependentPropDescElementDataset;
+    }
+
+void CMTPTypeInterdependentPropDesc::ConstructL()
+    {
+    ChunkAppendL(iChunkNumberOfInterdependencies);
+    }
+    
+void CMTPTypeInterdependentPropDesc::AppendElementChunkL(CMTPTypeInterdependentProperties* aElement)
+    {
+    iChunksInterdependentProperties.AppendL(aElement);
+    ChunkAppendL(*aElement);
+    }
+    
+TInt CMTPTypeInterdependentPropDesc::UpdateWriteSequenceErr(TInt aErr)
+    {
+    iWriteSequenceErr = aErr;
+    return iWriteSequenceErr;        
+    }
+
+/**
+MTP InterdependentPropDesc array element dataset factory method. This method is
+used to create an empty MTP InterdependentPropDesc array element dataset. 
+@return A pointer to the MTP InterdependentPropDesc array element dataset type.
+Ownership IS transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeInterdependentProperties* CMTPTypeInterdependentProperties::NewL()
+    {
+    CMTPTypeInterdependentProperties* self = CMTPTypeInterdependentProperties::NewLC(); 
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+/**
+MTP InterdependentPropDesc array element dataset factory method. This method is
+used to create an empty MTP InterdependentPropDesc array element dataset. A 
+pointer to the data type is placed on the cleanup stack.
+@return A pointer to the MTP InterdependentPropDesc array element dataset type. 
+Ownership IS transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeInterdependentProperties* CMTPTypeInterdependentProperties::NewLC()
+    {
+    CMTPTypeInterdependentProperties* self = new(ELeave) CMTPTypeInterdependentProperties();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPTypeInterdependentProperties::~CMTPTypeInterdependentProperties()
+    {
+    iChunksObjectPropDesc.ResetAndDestroy();
+    }
+
+/**
+Appends the specified ObjectPropDesc dataset to the InterdependentPropDesc 
+array element array. Ownership of the specified ObjectPropDesc dataset is 
+passed to the InterdependentPropDesc array element array.
+@param aElement The ObjectPropDesc dataset to append. Ownership IS transferred.
+@leave One of the system wide error codes, if unsuccessful.
+*/
+EXPORT_C void CMTPTypeInterdependentProperties::AppendL(CMTPTypeObjectPropDesc* aElement)
+    {
+    // Increment NumberOfElements.
+    const TUint index(iChunkNumberOfPropDescs.Value());
+    iChunkNumberOfPropDescs.Set(index + 1);
+    
+    // Append the element.
+    AppendElementChunkL(aElement);
+    }
+
+/**
+Provides the NumberOfPropDescs element value.
+*/
+EXPORT_C TUint32 CMTPTypeInterdependentProperties::NumberOfPropDescs() const
+    {
+    return iChunkNumberOfPropDescs.Value();
+    }
+
+/**
+Provides a non-const reference to the InterdependentPropDesc value quadruple element at
+the specified index.
+@param aIndex The index of the required element.
+@param aValue On successful completion, a non-const reference to the requested
+element.
+@leave One of the system wide error codes, if unsuccessful.
+*/
+EXPORT_C CMTPTypeObjectPropDesc& CMTPTypeInterdependentProperties::ObjectPropDesc(TUint aIndex) const
+    {
+    return *iChunksObjectPropDesc[aIndex];
+    }
+
+EXPORT_C TInt CMTPTypeInterdependentProperties::FirstWriteChunk(TPtr8& aChunk)
+    {   
+    /* 
+    Reset the type in preparation for the data stream, by deleting all
+    except the first chunk.
+    */
+    for (TUint i(ChunkCount() - 1); (i >= (KNumberOfPropDescsChunk + 1)); i--)
+        {
+        ChunkRemove(i);
+        }
+    iChunksObjectPropDesc.ResetAndDestroy();
+    
+    // Setup the write chunk pointer.
+    TInt err(UpdateWriteSequenceErr(CMTPTypeCompoundBase::FirstWriteChunk(aChunk)));
+    switch (err)
+        {
+    case KMTPChunkSequenceCompletion:
+        err = KErrNone;
+        // Don't break, fall through to set the write sequence state.
+        
+    case KErrNone:
+        // Set the write sequence state.
+        iWriteSequenceState = EInProgress;
+        break;
+        
+    default:
+        break;
+        }
+        
+    return  err;
+    }
+    
+EXPORT_C TInt CMTPTypeInterdependentProperties::NextWriteChunk(TPtr8& aChunk)
+    {
+    TInt err(KMTPChunkSequenceCompletion);
+    
+    if (iWriteSequenceState != EIdle)
+       {
+       err = UpdateWriteSequenceErr(CMTPTypeCompoundBase::NextWriteChunk(aChunk));
+       if ((iWriteSequenceErr == KMTPChunkSequenceCompletion) && (iWriteSequenceState != EIdle))
+           {
+           err = KErrNone;
+           }   
+       }    
+    return err;
+    }
+
+EXPORT_C TUint CMTPTypeInterdependentProperties::Type() const
+    {
+    return EMTPTypeInterdependentPropDescElementDataset;
+    }
+
+EXPORT_C TBool CMTPTypeInterdependentProperties::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* CMTPTypeInterdependentProperties::CommitChunkL(TPtr8& aChunk)
+    {
+    if (iWriteSequenceErr == KMTPChunkSequenceCompletion)
+        {
+        switch (iWriteSequenceState)
+            {
+        case EInProgress:
+            if ( ( iChunkNumberOfPropDescs.Value() ) &&
+            (iChunksObjectPropDesc.Count() < iChunkNumberOfPropDescs.Value()))
+                {
+                // Allocate the next element chunk.
+                CMTPTypeObjectPropDesc* element = CMTPTypeObjectPropDesc::NewLC();
+                AppendElementChunkL(element);
+                CleanupStack::Pop(element); 
+                }
+            else
+                {
+                iWriteSequenceState = EIdle;
+                }
+            break;
+            
+        case EIdle:
+            // Completing the last element in the write sequence.
+            break;
+            
+        default:
+            Panic(EMTPTypeBadStorage);
+            break;
+            }
+        }
+        
+    if (CMTPTypeCompoundBase::CommitRequired())
+        {
+        CMTPTypeCompoundBase::CommitChunkL(aChunk);
+        }     
+    return NULL;
+    }
+ 
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeInterdependentProperties::ElementInfo(TInt aElementId) const
+    {
+    if (aElementId == KNumberOfPropDescsChunk)
+        {
+        return iInfoNumberOfPropDescs;
+        }
+    else
+        {
+        __ASSERT_ALWAYS(((aElementId - KObjectPropDescChunks) < iChunkNumberOfPropDescs.Value()), Panic(EMTPTypeBoundsError));
+        iInfoObjectPropDesc.iChunkId = aElementId;
+        return iInfoObjectPropDesc; 
+        }
+    }
+
+TInt CMTPTypeInterdependentProperties::ValidateChunkCount() const
+    {
+    TInt ret(KErrNone);
+    if (NumberOfPropDescs() != (ChunkCount() - 1))
+        {
+        ret = KMTPDataTypeInvalid;
+        }
+    return ret;
+    }
+
+CMTPTypeInterdependentProperties::CMTPTypeInterdependentProperties() :
+    CMTPTypeCompoundBase(KJustInTimeConstruction, KVariableChunkCount)
+    {
+    const CMTPTypeCompoundBase::TElementInfo KDefaultInfo = {0, EMTPTypeUndefined, {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}};
+    iInfoNumberOfPropDescs          = KDefaultInfo; 
+    iInfoNumberOfPropDescs.iType    = EMTPTypeUINT32;
+    iInfoObjectPropDesc             = KDefaultInfo; 
+    iInfoObjectPropDesc.iType       = EMTPTypeInterdependentPropDescElementDataset;
+    }
+
+void CMTPTypeInterdependentProperties::ConstructL()
+    {
+    ChunkAppendL(iChunkNumberOfPropDescs);
+    }
+    
+void CMTPTypeInterdependentProperties::AppendElementChunkL(CMTPTypeObjectPropDesc* aElement)
+    {
+    iChunksObjectPropDesc.AppendL(aElement);
+    ChunkAppendL(*aElement);
+    }
+    
+TInt CMTPTypeInterdependentProperties::UpdateWriteSequenceErr(TInt aErr)
+    {
+    iWriteSequenceErr = aErr;
+    return iWriteSequenceErr;        
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypelist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,259 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// 
+
+/**
+@file
+@publishedPartner
+*/
+
+#include <mtp/cmtptypelist.h>
+
+#include "mtpdatatypespanic.h"
+#include <mtp/tmtptypedatapair.h>
+
+const TUint CMTPTypeList::KChunkNumberofElements(0);
+
+
+const TUint CMTPTypeList::KChunckNumberOfHeader(1);
+
+EXPORT_C CMTPTypeList* CMTPTypeList::NewL(TMTPTypeIds aListType, TMTPTypeIds aElementType)
+    {
+    CMTPTypeList* self = CMTPTypeList::NewLC(aListType, aElementType); 
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+EXPORT_C CMTPTypeList* CMTPTypeList::NewLC(TMTPTypeIds aListType, TMTPTypeIds aElementType)
+    {
+    CMTPTypeList* self = new(ELeave) CMTPTypeList(aListType, aElementType);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+EXPORT_C  CMTPTypeList::~CMTPTypeList()
+    {
+    ResetAndDestroy();
+    }
+
+CMTPTypeList::CMTPTypeList(TInt aListType, TInt aElementType):
+    CMTPTypeCompoundBase(KJustInTimeConstruction, KVariableChunkCount),
+    iListType(aListType),
+    iElementType(aElementType),
+    iChunkNumberOfElements(KChunkNumberofElements)
+    {
+    const CMTPTypeCompoundBase::TElementInfo KDefaultInfo = {0, EMTPTypeUndefined, {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}};
+    iInfoNumberOfElements       = KDefaultInfo; 
+    iInfoNumberOfElements.iType = EMTPTypeUINT32;
+    iInfoElement                = KDefaultInfo; 
+    iInfoElement.iType          = aElementType;
+    }
+
+void CMTPTypeList::InitListL()
+    {
+    ChunkAppendL(iChunkNumberOfElements);
+    }
+
+void CMTPTypeList::ConstructL()
+    {
+    InitListL();
+    }
+
+
+EXPORT_C void CMTPTypeList::AppendL(const MMTPType* aElement)
+    {
+    if (aElement == NULL)
+        {
+        User::Leave(KMTPDataTypeInvalid);
+        }
+             
+    // Append the element.
+    AppendElementChunkL(aElement);
+    
+    // Increment NumberOfElements.
+    const TUint index(iChunkNumberOfElements.Value());
+    iChunkNumberOfElements.Set(index + 1);
+    }
+
+EXPORT_C void CMTPTypeList::Remove(const TInt aIndex)
+    {
+        
+    MMTPType* tmp = iChunksElement[aIndex];
+    iChunksElement.Remove(aIndex);
+    ChunkRemove(aIndex + 1);
+    RMTPType::Destroy(iElementType,tmp );
+    
+    const TUint index(iChunkNumberOfElements.Value());
+    iChunkNumberOfElements.Set(index - 1);
+    }
+
+EXPORT_C TInt CMTPTypeList::ElementType() const
+    {
+    return iElementType;
+    }
+
+EXPORT_C TUint32 CMTPTypeList::NumberOfElements() const
+    {
+    return iChunkNumberOfElements.Value();
+    }
+
+EXPORT_C MMTPType& CMTPTypeList::ElementL(const TInt aIndex) const
+	{
+	__ASSERT_ALWAYS(( aIndex < NumberOfElements() ), User::Leave(EMTPTypeBoundsError));
+
+	return *iChunksElement[aIndex];
+	}
+
+EXPORT_C TInt CMTPTypeList::FirstWriteChunk(TPtr8& aChunk)
+    {
+    ResetAndDestroy();
+    
+    // Setup the write chunk pointer.
+    TInt err(UpdateWriteSequenceErr(CMTPTypeCompoundBase::FirstWriteChunk(aChunk)));
+    switch (err)
+        {
+    case KMTPChunkSequenceCompletion:
+        err = KErrNone;
+        // Don't break, fall through to set the write sequence state.
+        
+    case KErrNone:
+        // Set the write sequence state.
+        iWriteSequenceState = EElementChunks;
+        break;
+        
+    default:
+        break;
+        }
+        
+    return  err;
+    }
+
+EXPORT_C TInt CMTPTypeList::NextWriteChunk(TPtr8& aChunk)
+    {
+    TInt err(KMTPChunkSequenceCompletion);
+    if (iWriteSequenceState != EIdle)
+        {
+        err = UpdateWriteSequenceErr(CMTPTypeCompoundBase::NextWriteChunk(aChunk));
+        if ((iWriteSequenceErr == KMTPChunkSequenceCompletion) && (iWriteSequenceState != EIdle))
+            {
+            err = KErrNone;
+            }   
+        }    
+    return err;
+    }
+
+EXPORT_C TInt CMTPTypeList::NextWriteChunk(TPtr8& aChunk, TUint /*aDataLength*/)
+	{
+	return NextWriteChunk(aChunk);
+	}
+
+EXPORT_C TUint CMTPTypeList::Type() const
+    {
+    return iListType;
+    }
+
+EXPORT_C TBool CMTPTypeList::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* CMTPTypeList::CommitChunkL(TPtr8& aChunk)
+    {
+    if (iWriteSequenceErr == KMTPChunkSequenceCompletion)
+        {
+        switch (iWriteSequenceState)
+            {
+        case EElementChunks:
+            if ((iChunkNumberOfElements.Value()) && 
+                (iChunksElement.Count() < iChunkNumberOfElements.Value()))
+                {
+                MMTPType* element = RMTPType::AllocL(iElementType);
+                CleanupStack::PushL(element);
+                AppendElementChunkL(element);
+                CleanupStack::Pop(element); 
+                }
+            else
+                {
+                iWriteSequenceState = EIdle;
+                }
+            break;
+            
+        case EIdle:
+            // Completing the last chunk in the write sequence.
+            break;
+            
+        default:
+            Panic(EMTPTypeBadStorage);
+            break;
+            }
+        }
+        
+    if (CMTPTypeCompoundBase::CommitRequired())
+        {
+        CMTPTypeCompoundBase::CommitChunkL(aChunk);
+        }     
+    return NULL;
+    }
+
+
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeList::ElementInfo(TInt aElementId) const
+    {
+    if (aElementId == KChunkNumberofElements)
+        {
+        return iInfoNumberOfElements;
+        }
+    else
+        {
+        __ASSERT_ALWAYS(((aElementId - KChunckNumberOfHeader) < iChunkNumberOfElements.Value()), Panic(EMTPTypeBoundsError));
+        iInfoElement.iChunkId = aElementId;
+        return iInfoElement; 
+        }
+    }
+
+
+TInt CMTPTypeList::ValidateChunkCount() const
+    {
+    if (NumberOfElements() != (ChunkCount() - 1))
+        {
+        return KMTPDataTypeInvalid;
+        }
+    
+    return KErrNone;
+    }
+
+TInt CMTPTypeList::UpdateWriteSequenceErr(TInt aErr)
+    {
+    iWriteSequenceErr = aErr;
+    return iWriteSequenceErr;        
+    }
+
+
+void CMTPTypeList::AppendElementChunkL(const MMTPType* aElement)
+    {
+    iChunksElement.AppendL(aElement);
+    ChunkAppendL(*aElement);
+    }
+
+EXPORT_C void CMTPTypeList::ResetAndDestroy()
+    {
+    const TUint num = iChunksElement.Count();
+    for(TInt i = num -1  ; i  >= 0 ; i-- )
+        {
+        Remove(i);
+        }
+    
+    iChunksElement.Close();
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypeobjectinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,154 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <mtp/cmtptypeobjectinfo.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mtptypescomplex.h>
+
+#include "mtpdatatypespanic.h"
+
+// Dataset constants
+const TUint CMTPTypeObjectInfo::KFlatChunkSize(52);
+
+// Dataset element metadata.
+const CMTPTypeCompoundBase::TElementInfo CMTPTypeObjectInfo::iElementMetaData[CMTPTypeObjectInfo::ENumElements] = 
+    {
+        {EIdFlat1Chunk,         EMTPTypeFlat,   {EMTPTypeUINT32,    0,                  KMTPTypeUINT32Size}},   // EStorageID
+        {EIdFlat1Chunk,         EMTPTypeFlat,   {EMTPTypeUINT16,    4,                  KMTPTypeUINT16Size}},   // EObjectFormat
+        {EIdFlat1Chunk,         EMTPTypeFlat,   {EMTPTypeUINT16,    6,                  KMTPTypeUINT16Size}},   // EProtectionStatus
+        {EIdFlat1Chunk,         EMTPTypeFlat,   {EMTPTypeUINT32,    8,                  KMTPTypeUINT32Size}},   // EObjectCompressedSize
+        {EIdFlat1Chunk,         EMTPTypeFlat,   {EMTPTypeUINT16,    12,                 KMTPTypeUINT16Size}},   // EThumbFormat
+        {EIdFlat1Chunk,         EMTPTypeFlat,   {EMTPTypeUINT32,    14,                 KMTPTypeUINT32Size}},   // EThumbCompressedSize
+        {EIdFlat1Chunk,         EMTPTypeFlat,   {EMTPTypeUINT32,    18,                 KMTPTypeUINT32Size}},   // EThumbPixWidth
+        {EIdFlat1Chunk,         EMTPTypeFlat,   {EMTPTypeUINT32,    22,                 KMTPTypeUINT32Size}},   // EThumbPixHeight
+        {EIdFlat1Chunk,         EMTPTypeFlat,   {EMTPTypeUINT32,    26,                 KMTPTypeUINT32Size}},   // EImagePixWidth
+        {EIdFlat1Chunk,         EMTPTypeFlat,   {EMTPTypeUINT32,    30,                 KMTPTypeUINT32Size}},   // EImagePixHeight
+        {EIdFlat1Chunk,         EMTPTypeFlat,   {EMTPTypeUINT32,    34,                 KMTPTypeUINT32Size}},   // EImageBitDepth
+        {EIdFlat1Chunk,         EMTPTypeFlat,   {EMTPTypeUINT32,    38,                 KMTPTypeUINT32Size}},   // EParentObject  
+        {EIdFlat1Chunk,         EMTPTypeFlat,   {EMTPTypeUINT16,    42,                 KMTPTypeUINT16Size}},   // EAssociationType
+        {EIdFlat1Chunk,         EMTPTypeFlat,   {EMTPTypeUINT32,    44,                 KMTPTypeUINT32Size}},   // EAssociationDescription
+        {EIdFlat1Chunk,         EMTPTypeFlat,   {EMTPTypeUINT32,    48,                 KMTPTypeUINT32Size}},   // ESequenceNumber
+        {EIdFilenameChunk,      EMTPTypeString, {EMTPTypeString,    KMTPNotApplicable,  KMTPNotApplicable}},    // EFilename
+        {EIdDateCreatedChunk,   EMTPTypeString, {EMTPTypeString,    KMTPNotApplicable,  KMTPNotApplicable}},    // EDateCreated
+        {EIdDateModifiedChunk,  EMTPTypeString, {EMTPTypeString,    KMTPNotApplicable,  KMTPNotApplicable}},    // EDateModified
+        {EIdKeywordsChunk,      EMTPTypeString, {EMTPTypeString,    KMTPNotApplicable,  KMTPNotApplicable}},    // EKeywords
+    };
+
+/**
+MTP ObjectInfo dataset factory method. This method is used to create an empty 
+MTP ObjectInfo dataset type. A pointer to the data type is placed on the 
+cleanup stack.
+@return A pointer to an empty MTP ObjectInfo dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/    
+EXPORT_C CMTPTypeObjectInfo* CMTPTypeObjectInfo::NewL()
+    {
+	CMTPTypeObjectInfo* self = CMTPTypeObjectInfo::NewLC(); 
+	CleanupStack::Pop(self);
+	return self; 
+    }
+
+/**
+MTP ObjectInfo dataset factory method. This method is used to create an empty 
+MTP ObjectInfo dataset type.
+@return A pointer to an empty MTP ObjectInfo dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeObjectInfo* CMTPTypeObjectInfo::NewLC()
+    {
+	CMTPTypeObjectInfo* self = new (ELeave) CMTPTypeObjectInfo(); 
+	CleanupStack::PushL(self); 
+    self->ConstructL();
+	return self;    
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPTypeObjectInfo::~CMTPTypeObjectInfo()
+    {    
+    iChunkFlat.Close();
+    iChunksString.ResetAndDestroy();
+    }
+ 
+EXPORT_C TUint CMTPTypeObjectInfo::Type() const
+    {
+    return EMTPTypeObjectInfoDataset;
+    }
+    
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeObjectInfo::ElementInfo(TInt aElementId) const
+    {
+    return iElementInfo[aElementId];
+    }
+
+CMTPTypeObjectInfo::CMTPTypeObjectInfo() : 
+    CMTPTypeCompoundBase((!KJustInTimeConstruction), EIdNumChunks), 
+    iElementInfo(iElementMetaData, ENumElements),
+    iChunkFlat(KFlatChunkSize, *this)
+    {
+    
+    }
+    
+void CMTPTypeObjectInfo::ConstructL()
+    {
+    for (TUint i(0); (i < ENumElements); i++)
+        {
+        const TElementInfo& info(iElementInfo[i]);
+        if (ChunkCount() <= info.iChunkId)
+            {
+            MMTPType* chunk(NULL);
+            
+            switch (info.iType)
+                {                
+            case EMTPTypeFlat:
+                chunk = NewFlatChunkL(info);
+                break;
+                
+            case EMTPTypeString:
+                chunk = NewStringChunkL(info);
+                break;
+                
+            default:
+                break;
+                }
+                
+            __ASSERT_DEBUG(chunk, User::Invariant());
+            ChunkAppendL(*chunk);
+            }
+        }
+    }
+
+MMTPType* CMTPTypeObjectInfo::NewFlatChunkL(const TElementInfo& aElementInfo)
+    {
+    MMTPType* chunk(NULL);
+    if (aElementInfo.iChunkId == 0)
+        {
+        iChunkFlat.OpenL();
+        chunk = &iChunkFlat;
+        }
+    __ASSERT_DEBUG(chunk, User::Invariant());
+    return chunk;
+    }
+
+MMTPType* CMTPTypeObjectInfo::NewStringChunkL(const TElementInfo& /*aElementInfo*/)
+    {
+    CMTPTypeString* chunk(CMTPTypeString::NewLC());
+    iChunksString.AppendL(chunk);
+    CleanupStack::Pop(chunk); 
+    return chunk;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypeobjectpropdesc.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1887 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/cmtptypeobjectpropdesc.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/cmtptypeserviceobjpropextnform.h>
+#include <mtp/cmtptypeservicemethodparamextnform.h>
+
+#include "mtpdatatypespanic.h"
+
+// Dataset constants
+const TUint CMTPTypeObjectPropDesc::KFlat1ChunkSize(5);
+const TUint CMTPTypeObjectPropDesc::KFlat2ChunkSize(5);
+
+const TUint CMTPTypeObjectPropDesc::KNumChunksWithoutForm(EIdFlat2Chunk + 1);
+const TUint CMTPTypeObjectPropDesc::KNumChunksWithForm(EIdFormChunk + 1);
+
+const TUint CMTPTypeObjectPropDescEnumerationForm::KNumberOfValuesChunk(0);
+const TUint CMTPTypeObjectPropDescEnumerationForm::KValueChunks(1);
+
+// Dataset element metadata    
+const CMTPTypeCompoundBase::TElementInfo CMTPTypeObjectPropDesc::iElementMetaData[CMTPTypeObjectPropDesc::ENumElements] = 
+    {
+        {EIdFlat1Chunk,         EMTPTypeFlat,       {EMTPTypeUINT16,    0,                  KMTPTypeUINT16Size}},   // EPropertyCode
+        {EIdFlat1Chunk,         EMTPTypeFlat,       {EMTPTypeUINT16,    2,                  KMTPTypeUINT16Size}},   // EDatatype
+        {EIdFlat1Chunk,         EMTPTypeFlat,       {EMTPTypeUINT8,     4,                  KMTPTypeUINT8Size}},    // EGetSet
+        {EIdDefaultValueChunk,  EMTPTypeReference,  {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}},    // EDefaultValue
+        {EIdFlat2Chunk,         EMTPTypeFlat,       {EMTPTypeUINT32,    0,                  KMTPTypeUINT32Size}},   // EGroupCode
+        {EIdFlat2Chunk,         EMTPTypeFlat,       {EMTPTypeUINT8,     4,                  KMTPTypeUINT8Size}},    // EFormFlag
+        {EIdFormChunk,          EMTPTypeReference,  {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}},    // EForm
+    };
+
+
+EXPORT_C CMTPTypeObjectPropDesc* CMTPTypeObjectPropDesc::NewL()
+    {
+    CMTPTypeObjectPropDesc* self = NewLC();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+
+/**
+MTP ObjectPropDesc dataset factory method. This method is used to create an 
+empty MTP ObjectPropDesc dataset type with the default Datatype and Form Flag 
+defined for the specified PropertyCode. 
+@param aPropertyCode The ObjectPropertyCode of the property being described by 
+the ObjectPropDesc dataset.
+@return A pointer to the MTP ObjectPropDesc dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeObjectPropDesc* CMTPTypeObjectPropDesc::NewL(TUint16 aPropertyCode)
+    {
+    CMTPTypeObjectPropDesc* self = NewLC(aPropertyCode);
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+/**
+MTP ObjectPropDesc dataset factory method. This method is used to create an 
+empty MTP ObjectPropDesc dataset type with the default Datatype and Form Flag 
+defined for the specified PropertyCode. A pointer to the data type is placed on
+the cleanup stack.
+@param aPropertyCode The ObjectPropertyCode of the property being described by 
+the ObjectPropDesc dataset.
+@return A pointer to the MTP ObjectPropDesc dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeObjectPropDesc* CMTPTypeObjectPropDesc::NewLC(TUint16 aPropertyCode)
+    {    
+    CMTPTypeObjectPropDesc* self = new (ELeave) CMTPTypeObjectPropDesc(); 
+    CleanupStack::PushL(self); 
+    self->ConstructL(aPropertyCode, NULL);
+    return self;    
+    }
+
+/**
+MTP ObjectPropDesc dataset factory method. This method is used to create an 
+MTP ObjectPropDesc dataset type with the default Datatype and Form Flag 
+defined for the specified PropertyCode, and the specified FORM. 
+@param aPropertyCode The ObjectPropertyCode of the property being described by 
+the ObjectPropDesc dataset.
+@param aForm The optional ObjectPropDesc FORM dataset.
+@return A pointer to the MTP ObjectPropDesc dataset type. Ownership IS 
+transfered.
+@leave KMTPDataTypeInvalid, if a FORM dataset is not defined for the property.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeObjectPropDesc* CMTPTypeObjectPropDesc::NewL(TUint16 aPropertyCode, const MMTPType& aForm)
+    {
+    CMTPTypeObjectPropDesc* self = NewLC(aPropertyCode, aForm);
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+/**
+MTP ObjectPropDesc dataset factory method. This method is used to create an 
+MTP ObjectPropDesc dataset type with the default Datatype and Form Flag 
+defined for the specified PropertyCode, and the specified FORM. A pointer 
+to the data type is placed on the cleanup stack.
+@param aPropertyCode The ObjectPropertyCode of the property being described by 
+the ObjectPropDesc dataset.
+@param aForm The optional ObjectPropDesc FORM dataset.
+@return A pointer to the MTP ObjectPropDesc dataset type. Ownership IS 
+transfered.
+@leave KMTPDataTypeInvalid, if a FORM dataset is not defined for the property.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeObjectPropDesc* CMTPTypeObjectPropDesc::NewLC(TUint16 aPropertyCode, const MMTPType& aForm)
+    {    
+    CMTPTypeObjectPropDesc* self = new (ELeave) CMTPTypeObjectPropDesc(); 
+    CleanupStack::PushL(self); 
+    self->ConstructL(aPropertyCode, &aForm);
+    return self;    
+    }
+
+/**
+MTP ObjectPropDesc dataset factory method. This method is used to create an 
+MTP ObjectPropDesc dataset type with the default Datatype defined for the 
+specified PropertyCode, and the specified Form Flag and FORM.  
+@param aPropertyCode The ObjectPropertyCode of the property being described by 
+the ObjectPropDesc dataset.
+@param aFormFlag The required Form Flag of the ObjectPropDesc.
+@param aForm The optional ObjectPropDesc FORM dataset.
+@return A pointer to the MTP ObjectPropDesc dataset type. Ownership IS 
+transfered.
+@leave KMTPDataTypeInvalid, if a FORM dataset is not defined for the property.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeObjectPropDesc* CMTPTypeObjectPropDesc::NewL(TUint16 aPropertyCode, TUint8 aFormFlag, const MMTPType* aForm)
+    {
+    CMTPTypeObjectPropDesc* self = NewLC(aPropertyCode, aFormFlag, aForm);
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+/**
+MTP ObjectPropDesc dataset factory method. This method is used to create an 
+MTP ObjectPropDesc dataset type with the default Datatype defined for the 
+specified PropertyCode, and the specified Form Flag and FORM. A pointer 
+to the data type is placed on the cleanup stack.
+@param aPropertyCode The ObjectPropertyCode of the property being described by 
+the ObjectPropDesc dataset.
+@param aFormFlag The required Form Flag of the ObjectPropDesc.
+@param aForm The optional ObjectPropDesc FORM dataset.
+@return A pointer to the MTP ObjectPropDesc dataset type. Ownership IS 
+transfered.
+@leave KMTPDataTypeInvalid, if a FORM dataset is not defined for the property.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeObjectPropDesc* CMTPTypeObjectPropDesc::NewLC(TUint16 aPropertyCode, TUint8 aFormFlag, const MMTPType* aForm)
+    {
+    CMTPTypeObjectPropDesc* self = new (ELeave) CMTPTypeObjectPropDesc(); 
+    CleanupStack::PushL(self); 
+    TPropertyInfo info;
+    PropertyInfoL(aPropertyCode, info);
+    info.iFormFlag = aFormFlag;
+    self->ConstructL(aPropertyCode, info, aForm);
+    return self;    
+    }
+
+/**
+MTP ObjectPropDesc dataset factory method. This method is used to create an  
+MTP ObjectPropDesc dataset type with the specified values.
+@param aPropertyCode The ObjectPropertyCode of the property being described by 
+the ObjectPropDesc dataset.
+@param aInfo The MTP ObjectPropDesc dataset characteristics (meta data).
+@param aForm The optional ObjectPropDesc FORM dataset.
+@return A pointer to the MTP ObjectPropDesc dataset type. Ownership IS 
+transfered.
+@leave KMTPDataTypeInvalid, if a FORM dataset is not defined for the property.
+@leave One of the system wide error codes, if unsuccessful.
+*/    
+EXPORT_C CMTPTypeObjectPropDesc* CMTPTypeObjectPropDesc::NewL(TUint16 aPropertyCode, const TPropertyInfo& aInfo, const MMTPType* aForm)
+    {
+    CMTPTypeObjectPropDesc* self = CMTPTypeObjectPropDesc::NewLC(aPropertyCode, aInfo, aForm); 
+    CleanupStack::Pop(self);
+    return self; 
+    }
+
+/**
+MTP ObjectPropDesc dataset factory method. This method is used to create an  
+MTP ObjectPropDesc dataset type with the specified values. A pointer to the 
+data type is placed on the cleanup stack.
+@param aPropertyCode The ObjectPropertyCode of the property being described by 
+the ObjectPropDesc dataset.
+@param aInfo The MTP ObjectPropDesc dataset characteristics (meta data).
+@param aForm The optional ObjectPropDesc FORM dataset.
+@return A pointer to the MTP ObjectPropDesc dataset type. Ownership IS 
+transfered.
+@leave KMTPDataTypeInvalid, if a FORM dataset is not defined for the property.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeObjectPropDesc* CMTPTypeObjectPropDesc::NewLC(TUint16 aPropertyCode, const TPropertyInfo& aInfo, const MMTPType* aForm)
+    {
+    CMTPTypeObjectPropDesc* self = new (ELeave) CMTPTypeObjectPropDesc(); 
+    CleanupStack::PushL(self); 
+    self->ConstructL(aPropertyCode, aInfo, aForm);
+    return self;    
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPTypeObjectPropDesc::~CMTPTypeObjectPropDesc()
+    {
+    iChunkFlat1.Close();
+    iChunkDefaultValue.Close();
+    iChunkFlat2.Close();
+    iChunkForm.Close();
+    }
+
+EXPORT_C TInt CMTPTypeObjectPropDesc::FirstWriteChunk(TPtr8& aChunk)
+    {  
+    /* 
+    Reset the type in preparation for the data stream, by deleting all
+    except the first chunk.
+    */
+    for (TUint i(ChunkCount() - 1); (i >= (EIdFlat1Chunk + 1)); i--)
+        {
+        ChunkRemove(i);
+        }
+        
+    // Setup the write chunk pointer.
+    TInt err(UpdateWriteSequenceErr(CMTPTypeCompoundBase::FirstWriteChunk(aChunk)));
+    switch (err)
+        {
+    case KMTPChunkSequenceCompletion:
+        err = KErrNone;
+        // Don't break, fall through to set the write sequence state.
+        
+    case KErrNone:
+        // Set the write sequence state.
+        iWriteSequenceState = EFlat1Chunk; 
+        
+        /* 
+        Set the write sequence completion state. Initially assume that the 
+        ObjectPropDesc has a FORM field. If no FORM field is subsequently
+        detected in the write data stream then the completion state is 
+        adjusted accordingly.
+        */
+        iWriteSequenceCompletionState = EFormChunk;
+        break;
+        
+    default:
+        break;
+        }
+        
+    return  err;
+    }
+    
+EXPORT_C TInt CMTPTypeObjectPropDesc::NextWriteChunk(TPtr8& aChunk)
+    {
+    TInt err(KMTPChunkSequenceCompletion);
+    
+    if (iWriteSequenceState != EIdle)
+        {
+        err = UpdateWriteSequenceErr(CMTPTypeCompoundBase::NextWriteChunk(aChunk));
+        if ((iWriteSequenceErr == KMTPChunkSequenceCompletion) && (iWriteSequenceState != EIdle))
+            {
+            err = KErrNone;
+            }   
+        }    
+    return err;
+    }
+ 
+EXPORT_C TUint CMTPTypeObjectPropDesc::Type() const
+    {
+    return EMTPTypeObjectPropDescDataset;
+    }
+    
+EXPORT_C TBool CMTPTypeObjectPropDesc::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* CMTPTypeObjectPropDesc::CommitChunkL(TPtr8& aChunk)
+    {
+    if (iWriteSequenceErr == KMTPChunkSequenceCompletion)
+        {
+        switch (iWriteSequenceState)
+            {
+        case EFlat1Chunk:     
+            /* 
+            Datatype is available, allocate sufficient chunk storage for 
+            and append the DefaultValue chunk.
+            */
+            iChunkDefaultValue.Close();
+            iChunkDefaultValue.OpenL(Uint16L(EDatatype));
+            ChunkAppendL(iChunkDefaultValue);
+            break;
+            
+        case EDefaultValueChunk:
+            // Append the next chunk.
+            ChunkAppendL(iChunkFlat2);
+            break;
+            
+        case EFlat2Chunk: 
+            /* 
+            FormFlag and Datatype are available, allocate sufficient storage for 
+            and append the FORM chunk.
+            */
+            {
+            iChunkForm.Close();
+            TUint8 flag(Uint8L(EFormFlag));
+            iChunkForm.SetMeta(flag, Uint16L(EDatatype));
+            if (HasFormField(flag))
+                {
+                iChunkForm.OpenL(iElementInfo[EIdFormChunk].iType);
+                ChunkAppendL(iChunkForm);
+                SetExpectedChunkCount(KNumChunksWithForm);
+                }
+            else
+                {
+                // Adjust the write sequence completion state.            
+                iWriteSequenceCompletionState = EFlat2Chunk;
+                }   
+            }
+            break;
+            
+        case EFormChunk:
+        case EIdle:
+        default:
+            break;
+            }
+    if ((iWriteSequenceState != EIdle ) && (iWriteSequenceState < iWriteSequenceCompletionState))
+        {
+        iWriteSequenceState++;
+        }
+    else
+        {
+        iWriteSequenceState = EIdle;
+        }
+    }
+        
+    if (CMTPTypeCompoundBase::CommitRequired())
+        {
+        CMTPTypeCompoundBase::CommitChunkL(aChunk);
+        }
+    return NULL;
+    }
+    
+void CMTPTypeObjectPropDesc::PropertyInfoL(TUint16 aPropertyCode, TPropertyInfo& aInfo)
+    {    
+    switch (aPropertyCode)
+        {        
+    case EMTPObjectPropCodeUndefined:
+        aInfo.iDataType     = EMTPTypeUndefined;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+         
+    case EMTPObjectPropCodeStorageID:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPObjectPropCodeObjectFormat:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPObjectPropCodeProtectionStatus:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPObjectPropCodeObjectSize:
+        aInfo.iDataType     = EMTPTypeUINT64;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPObjectPropCodeAssociationType:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeAssociationDesc:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeObjectFileName:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeDateCreated:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = EDateTimeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeDateModified:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = EDateTimeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeKeywords:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeParentObject:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPObjectPropCodeAllowedFolderContents:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPObjectPropCodeHidden:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeSystemObject:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePersistentUniqueObjectIdentifier:
+        aInfo.iDataType     = EMTPTypeUINT128;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPObjectPropCodeSyncID:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePropertyBag:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeName:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeCreatedBy:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeArtist:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeDateAuthored:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = EDateTimeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeDescription:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeURLReference:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeLanguageLocale:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPObjectPropCodeCopyrightInformation:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeSource:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeOriginLocation:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeDateAdded:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = EDateTimeForm;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPObjectPropCodeNonConsumable:
+        aInfo.iDataType     = EMTPTypeUINT8;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeCorruptUnplayable:
+        aInfo.iDataType     = EMTPTypeUINT8;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPObjectPropCodeProducerSerialNumber:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeRepresentativeSampleFormat:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadOnly;
+        break;
+        
+    case EMTPObjectPropCodeRepresentativeSampleSize:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeRepresentativeSampleHeight:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeRepresentativeSampleWidth:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeRepresentativeSampleDuration:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeRepresentativeSampleData:
+        aInfo.iDataType     = EMTPTypeAUINT8;
+        aInfo.iFormFlag     = EByteArrayForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeWidth:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeHeight:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeDuration:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeRating:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeTrack:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeGenre:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeCredits:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeLyrics:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeSubscriptionContentID:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeProducedBy:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeUseCount:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeSkipCount:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeLastAccessed:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = EDateTimeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeParentalRating:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeMetaGenre:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeComposer:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeEffectiveRating:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeSubtitle:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeOriginalReleaseDate:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = EDateTimeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeAlbumName:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeAlbumArtist:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeMood:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeDRMStatus:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeSubDescription:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeIsCropped:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeIsColourCorrected:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeImageBitDepth:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeFnumber:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeExposureTime:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeExposureIndex:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeTotalBitRate:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeBitrateType:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeSampleRate:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeNumberOfChannels:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeAudioBitDepth:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeScanType:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeAudioWAVECodec:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeAudioBitRate:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeVideoFourCCCodec:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeVideoBitRate:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeFramesPerThousandSeconds:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeKeyFrameDistance:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeBufferSize:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeEncodingQuality:
+        aInfo.iDataType     = EMTPTypeUINT32;
+        aInfo.iFormFlag     = ERangeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeEncodingProfile:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeDisplayName:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeBodyText:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeSubject:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePriority:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeGivenName:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeMiddleNames:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeFamilyName:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePrefix:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeSuffix:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePhoneticGivenName:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePhoneticFamilyName:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeEmailPrimary:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeEmailPersonal1:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeEmailPersonal2:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeEmailBusiness1:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeEmailBusiness2:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeEmailOthers:
+        aInfo.iDataType     = EMTPTypeAINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePhoneNumberPrimary:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePhoneNumberPersonal:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePhoneNumberPersonal2:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePhoneNumberBusiness:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePhoneNumberBusiness2:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePhoneNumberMobile:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePhoneNumberMobile2:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeFaxNumberPrimary:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeFaxNumberPersonal:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeFaxNumberBusiness:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePagerNumber:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePhoneNumberOthers:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePrimaryWebAddress:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePersonalWebAddress:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeBusinessWebAddress:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeInstantMessengerAddress:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeInstantMessengerAddress2:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeInstantMessengerAddress3:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ERegularExpressionForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressPersonalFull:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressPersonalLine1:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressPersonalLine2:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressPersonalCity:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressPersonalRegion:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressPersonalPostalCode:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressPersonalCountry:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressBusinessFull:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressBusinessLine1:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressBusinessLine2:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressBusinessCity:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressBusinessRegion:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressBusinessPostalCode:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressBusinessCountry:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressOtherFull:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressOtherLine1:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressOtherLine2:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressOtherCity:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressOtherRegion:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressOtherPostalCode:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePostalAddressOtherCountry:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeOrganizationName:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodePhoneticOrganizationName:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeRole:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeBirthdate:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = EDateTimeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeMessageTo:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeMessageCC:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeMessageBCC:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeMessageRead:
+        aInfo.iDataType     = EMTPTypeUINT16;
+        aInfo.iFormFlag     = EEnumerationForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeMessageReceivedTime:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = EDateTimeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeMessageSender:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeActivityBeginTime:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = EDateTimeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeActivityEndTime:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = EDateTimeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeActivityLocation:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeActivityRequiredAttendees:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeActivityOptionalAttendees:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeActivityResources:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeActivityAccepted:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;	
+        
+    case EMTPObjectPropCodeActivityTentative:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeActivityDeclined:
+        aInfo.iDataType     = EMTPTypeAUINT16;
+        aInfo.iFormFlag     = ELongStringForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeActivityReminderTime:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = EDateTimeForm;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeActivityOwner:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    case EMTPObjectPropCodeActivityStatus:
+        aInfo.iDataType     = EMTPTypeString;
+        aInfo.iFormFlag     = ENone;
+        aInfo.iGetSet       = EReadWrite;
+        break;
+        
+    default:
+        if( aPropertyCode <= EMTPCodeUndefined1End )
+            {
+            aInfo.iDataType     = EMTPTypeUndefined;
+            aInfo.iFormFlag     = ENone;
+            aInfo.iGetSet       = EReadOnly;
+            }
+        else
+            {
+            User::Leave(KErrNotSupported);
+            }
+        break;
+        }
+    }
+    
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeObjectPropDesc::ElementInfo(TInt aElementId) const
+    {
+    return iElementInfo[aElementId];
+    }
+    
+TBool CMTPTypeObjectPropDesc::ReadableElementL(TInt aElementId) const
+    {
+    TBool ret(ETrue);
+    if (aElementId == EForm)
+        {
+        ret = HasFormField(Uint8L(EFormFlag));
+        }
+    return ret;
+    }
+    
+TBool CMTPTypeObjectPropDesc::WriteableElementL(TInt aElementId) const
+    {
+    TBool ret(EFalse);
+
+    if (!iInitialised)
+        {
+        ret = ETrue;    
+        }
+    else
+        {
+        switch (aElementId)
+            {
+        case EDefaultValue:
+        case EGroupCode:
+            ret = ETrue;
+            break;
+
+        default:
+            break;
+            }   
+        }
+        
+    return ret;
+    }
+
+/*
+MTP ObjectPropDesc dataset "pre-production" factory method for datasets
+which will be populated from an MTP write data stream. This method is used to 
+create a partially constructed MTP ObjectPropDesc element dataset type prior to
+the construction characteristics being known. Construction of the element 
+dataset is completed on-the-fly as it is written to from an MTP write data 
+stream. A pointer to the data type is placed on the cleanup stack.
+@return A pointer to the ObjectPropList element dataset type. 
+Ownership IS transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/
+CMTPTypeObjectPropDesc* CMTPTypeObjectPropDesc::NewLC()
+    {
+    CMTPTypeObjectPropDesc* self = new(ELeave) CMTPTypeObjectPropDesc();
+    CleanupStack::PushL(self);
+    self->ConstructL(EMTPObjectPropCodeUndefined, NULL); 
+    return self;
+    }
+
+CMTPTypeObjectPropDesc::CMTPTypeObjectPropDesc() :
+    CMTPTypeCompoundBase(KJustInTimeConstruction, KNumChunksWithoutForm),
+    iElementInfo(iElementMetaData, ENumElements),
+    iChunkFlat1(KFlat1ChunkSize, *this),
+    iChunkFlat2(KFlat2ChunkSize, *this)
+    {
+    
+    }
+    
+void CMTPTypeObjectPropDesc::ConstructL(TUint16 aPropertyCode, const MMTPType* aForm)
+    { 
+    TPropertyInfo info;
+    PropertyInfoL(aPropertyCode, info);
+    ConstructL(aPropertyCode, info, aForm);
+    }
+    
+void CMTPTypeObjectPropDesc::ConstructL(TUint16 aPropertyCode, const TPropertyInfo& aInfo, const MMTPType* aForm)
+    {    
+    // Construct the ObjectPropDesc chunk sequence.
+    for (TUint i(0); (i < ENumElements); i++)
+        {
+        const TElementInfo& element(iElementInfo[i]);
+        if (ChunkCount() <= element.iChunkId)
+            {
+            MMTPType* chunk(NULL);
+            switch (element.iChunkId)
+                {
+            case EIdFlat1Chunk:
+                iChunkFlat1.OpenL();
+                chunk = &iChunkFlat1;
+                break;
+                
+            case EIdDefaultValueChunk:
+                if (aInfo.iDataType != EMTPTypeUndefined)
+                    {
+                    iChunkDefaultValue.OpenL(aInfo.iDataType);
+                    }
+                chunk = &iChunkDefaultValue;
+                break;
+                
+            case EIdFlat2Chunk:
+                iChunkFlat2.OpenL();
+                chunk = &iChunkFlat2;
+                break;
+                
+            case EIdFormChunk:
+                iChunkForm.SetMeta(aInfo.iFormFlag, aInfo.iDataType);
+                if (HasFormField(aInfo.iFormFlag))
+                    {
+                    iChunkForm.OpenL(element.iType);
+                    chunk = &iChunkForm;
+                    }
+                break;
+                
+            default:
+                Panic(EMTPTypeBoundsError);
+                break;
+                }
+                    
+            // Some chunks (i.e. FORM) are optional.
+            if (chunk)
+                {
+                ChunkAppendL(*chunk);   
+                }
+            }
+        }
+        
+    // Set the construction values.
+    SetUint16L(EPropertyCode, aPropertyCode);
+    SetUint16L(EDatatype, aInfo.iDataType);
+    SetUint8L(EGetSet, aInfo.iGetSet);
+    SetUint8L(EFormFlag, aInfo.iFormFlag);
+    
+    if (aForm)
+        {
+        if (!HasFormField(aInfo.iFormFlag))
+            { 
+            User::Leave(KMTPDataTypeInvalid);
+            } 
+        else
+            {
+            SetL(EForm, *aForm); 
+            }
+        }
+    
+    iInitialised = ETrue;
+    }    
+    
+TBool CMTPTypeObjectPropDesc::HasFormField(TUint8 aFormFlag) const
+    {
+    return ((aFormFlag != EDateTimeForm) && (aFormFlag != ENone) && (aFormFlag != EObjectIDForm) );
+    }
+    
+TInt CMTPTypeObjectPropDesc::UpdateWriteSequenceErr(TInt aErr)
+    {
+    iWriteSequenceErr = aErr;
+    return iWriteSequenceErr;        
+    }
+    
+CMTPTypeObjectPropDesc::RMTPTypeObjectPropDescForm::RMTPTypeObjectPropDescForm() : 
+    RMTPType()
+    {
+
+    }
+
+void CMTPTypeObjectPropDesc::RMTPTypeObjectPropDescForm::SetMeta(TUint8 aFormFlag, TUint aDataType)
+    {
+    iFormFlag = aFormFlag;
+    iDataType = aDataType;
+    }
+
+MMTPType* CMTPTypeObjectPropDesc::RMTPTypeObjectPropDescForm::CreateL(TUint aDataType)
+    {
+    if (aDataType != EMTPTypeReference)
+        {
+        User::Leave(KMTPDataTypeInvalid);
+        }
+        
+    MMTPType* type(NULL);
+    switch (iFormFlag)
+        {
+    case ERangeForm:
+        type = CMTPTypeObjectPropDescRangeForm::NewL(iDataType);
+        break;
+        
+    case EEnumerationForm:
+        type = CMTPTypeObjectPropDescEnumerationForm::NewL(iDataType);
+        break;
+        
+    case EFixedLengthArrayForm:
+        type = RMTPType::CreateL(EMTPTypeUINT32);
+        break;
+        
+    case ERegularExpressionForm:
+        type = RMTPType::CreateL(EMTPTypeString);
+        break;
+        
+    case EByteArrayForm:
+    case ELongStringForm:
+        type = RMTPType::CreateL(EMTPTypeUINT32);
+        break;
+    case EServiceObjPropExtnForm:
+        {
+        type = CMTPTypeServiceObjPropExtnForm::NewL(iDataType);
+        }
+        break;
+    case EServiceMethodParamExtnForm:
+        {
+        type = CMTPTypeServiceMethodParamExtnForm::NewL(iDataType);
+        }
+        break;
+        
+    case EDateTimeForm:
+    default:
+        // Invalid Form Flag.
+        User::Leave(KErrNotSupported);
+        break;
+        }
+        
+    return type;
+    }
+
+void CMTPTypeObjectPropDesc::RMTPTypeObjectPropDescForm::Destroy(MMTPType* aType)
+    {
+    switch (iFormFlag)
+        {
+    case ERangeForm:
+        delete static_cast<CMTPTypeObjectPropDescRangeForm*>(aType);
+        break;
+        
+    case EEnumerationForm:
+        delete static_cast<CMTPTypeObjectPropDescEnumerationForm*>(aType);
+        break;
+        
+    case EServiceObjPropExtnForm:
+        delete static_cast<CMTPTypeServiceObjPropExtnForm*>(aType);
+        break;
+        
+    case EServiceMethodParamExtnForm:
+        delete static_cast<CMTPTypeServiceMethodParamExtnForm*>(aType);
+        break;
+        
+    default:
+        // All other FORM types are managed by the base class.
+        RMTPType::Destroy(aType);
+        break;
+        }
+    }
+
+/**
+MTP ObjectPropDesc Enumeration FORM dataset factory method. This method is used to 
+create an empty MTP ObjectPropDesc FORM dataset of the specified Datatype. 
+@param aDataType The data type identifier datacode of the dataset.
+@return A pointer to the MTP ObjectPropDesc dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/     
+EXPORT_C CMTPTypeObjectPropDescEnumerationForm* CMTPTypeObjectPropDescEnumerationForm::NewL(TUint aDataType)
+    {
+    CMTPTypeObjectPropDescEnumerationForm* self = CMTPTypeObjectPropDescEnumerationForm::NewLC(aDataType);
+    CleanupStack::Pop(self);
+    return self;   
+    }
+
+/**
+MTP ObjectPropDesc Enumeration FORM dataset factory method. This method is used to 
+create an empty MTP ObjectPropDesc FORM dataset of the specified Datatype. A 
+pointer to the data type is placed on the cleanup stack.
+@param aDataType The data type identifier datacode of the dataset.
+@return A pointer to the MTP ObjectPropDesc dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/   
+EXPORT_C CMTPTypeObjectPropDescEnumerationForm* CMTPTypeObjectPropDescEnumerationForm::NewLC(TUint aDataType)
+    {
+    CMTPTypeObjectPropDescEnumerationForm* self = new(ELeave) CMTPTypeObjectPropDescEnumerationForm(aDataType);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPTypeObjectPropDescEnumerationForm::~CMTPTypeObjectPropDescEnumerationForm()
+    {
+    TInt count(iChunksValue.Count());
+    while (count--)
+        {
+        iChunksValue[count].Close();
+        }
+    iChunksValue.Close();
+    }
+
+/**
+Appends the specified value to the set of supported enumeration values.
+@param aValue The enumeration value to append.
+@leave One of the system wide error codes, if unsuccessful.
+@panic MTPDataTypes 3, if the source value type does not match the property 
+data type.
+*/
+EXPORT_C void CMTPTypeObjectPropDescEnumerationForm::AppendSupportedValueL(const MMTPType& aValue)
+    {
+    __ASSERT_ALWAYS(aValue.Type() == iInfoValue.iType, Panic(EMTPTypeIdMismatch));
+    
+    // Increment NumberOfValues.
+    const TUint index(iChunkNumberOfValues.Value());
+    iChunkNumberOfValues.Set(index + 1);
+    
+    // Create and populate the SupportedValue chunk.
+    AppendValueChunkL();
+    SetL((KValueChunks + index), aValue);
+    }
+
+/**
+Provides the NumberOfValues element value.
+*/
+EXPORT_C TUint16 CMTPTypeObjectPropDescEnumerationForm::NumberOfValues() const
+    {
+    return iChunkNumberOfValues.Value();
+    }
+
+/**
+Provides the SupportedValue element at the specified index.
+@param aIndex The index of the required value.
+@param aValue On successful completion, the requested value.
+@leave One of the system wide error codes, if unsuccessful.
+@panic MTPDataTypes 3, if the target value type does not match the property 
+data type.
+*/
+EXPORT_C void CMTPTypeObjectPropDescEnumerationForm::SupportedValueL(TUint aIndex, MMTPType& aValue) const
+    {
+    __ASSERT_ALWAYS(aValue.Type() == iInfoValue.iType, Panic(EMTPTypeIdMismatch));
+    GetL((KValueChunks + aIndex), aValue);
+    }
+    
+EXPORT_C TInt CMTPTypeObjectPropDescEnumerationForm::FirstWriteChunk(TPtr8& aChunk)
+    {
+    /* 
+    Reset the type in preparation for the data stream, by deleting all
+    except the first chunk.
+    */
+    for (TUint i(ChunkCount() - 1); (i >= (KNumberOfValuesChunk + 1)); i--)
+        {
+        ChunkRemove(i);
+        }
+    iChunksValue.Close();
+    
+    // Setup the write chunk pointer.
+    TInt err(CMTPTypeCompoundBase::FirstWriteChunk(aChunk));
+    switch (err)
+        {
+    case KMTPChunkSequenceCompletion:
+        err = KErrNone;
+        // Don't break, fall through to set the write sequence state.
+        
+    case KErrNone:
+        // Set the write sequence state.
+        iWriteSequenceState = EInProgress;
+        break;
+        
+    default:
+        break;
+        }
+        
+    return  err;
+    }
+    
+EXPORT_C TInt CMTPTypeObjectPropDescEnumerationForm::NextWriteChunk(TPtr8& aChunk)
+    {
+    TInt err(CMTPTypeCompoundBase::NextWriteChunk(aChunk));
+    if ((err == KMTPChunkSequenceCompletion) &&
+        (iChunksValue.Count() < iChunkNumberOfValues.Value()))
+        {
+        err = KErrNone; 
+        }
+    return err;
+    }
+ 
+EXPORT_C TUint CMTPTypeObjectPropDescEnumerationForm::Type() const
+    {
+    return EMTPTypeObjectPropDescEnumerationFormDataset;
+    }
+    
+EXPORT_C TBool CMTPTypeObjectPropDescEnumerationForm::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* CMTPTypeObjectPropDescEnumerationForm::CommitChunkL(TPtr8& aChunk)
+    {
+    switch (iWriteSequenceState)
+        {
+    case EInProgress:
+        if (iChunksValue.Count() < iChunkNumberOfValues.Value())
+            {
+            AppendValueChunkL(); 
+            }
+        else
+            {
+            iWriteSequenceState = EIdle;
+            }
+        break;
+        
+    case EIdle:
+        // Completing the last element in the write sequence.
+        break;
+        
+    default:
+        Panic(EMTPTypeBadStorage);
+        break;
+        }
+        
+    if (CMTPTypeCompoundBase::CommitRequired())
+        {
+        CMTPTypeCompoundBase::CommitChunkL(aChunk);
+        }     
+    return NULL;
+    }
+ 
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeObjectPropDescEnumerationForm::ElementInfo(TInt aElementId) const
+    {
+    if (aElementId == KNumberOfValuesChunk)
+        {
+        return iInfoNumberOfValues;
+        }
+    else
+        {
+        __ASSERT_ALWAYS(((aElementId - KValueChunks) < iChunkNumberOfValues.Value()), Panic(EMTPTypeBoundsError));
+        iInfoValue.iChunkId = aElementId;
+        return iInfoValue; 
+        }
+    }
+
+TInt CMTPTypeObjectPropDescEnumerationForm::ValidateChunkCount() const
+    {
+    TInt ret(KErrNone);
+    if (NumberOfValues() != (ChunkCount() - 1))
+        {
+        ret = KMTPDataTypeInvalid;
+        }
+    return ret;
+    }
+
+CMTPTypeObjectPropDescEnumerationForm::CMTPTypeObjectPropDescEnumerationForm(TUint aDataType) :
+    CMTPTypeCompoundBase(KJustInTimeConstruction, KVariableChunkCount)
+    {
+    const CMTPTypeCompoundBase::TElementInfo KDefaultInfo = {0, EMTPTypeUndefined, {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}};
+    iInfoNumberOfValues         = KDefaultInfo; 
+    iInfoNumberOfValues.iType   = EMTPTypeUINT16;
+    iInfoValue                  = KDefaultInfo; 
+    iInfoValue.iType            = aDataType;
+    }
+
+void CMTPTypeObjectPropDescEnumerationForm::ConstructL()
+    {
+    ChunkAppendL(iChunkNumberOfValues);
+    }
+    
+void CMTPTypeObjectPropDescEnumerationForm::AppendValueChunkL()
+    {
+    iChunksValue.AppendL(RMTPType());
+    
+    RMTPType& chunk(iChunksValue[iChunksValue.Count() - 1]);
+    chunk.OpenL(iInfoValue.iType);
+    ChunkAppendL(chunk);
+    }
+
+/**
+MTP ObjectPropDesc Range FORM dataset factory method. This method is used to 
+create an empty MTP ObjectPropDesc FORM dataset of the specified Datatype. 
+@param aDataType The data type identifier datacode of the dataset.
+@return A pointer to the MTP ObjectPropDesc dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/   
+EXPORT_C CMTPTypeObjectPropDescRangeForm* CMTPTypeObjectPropDescRangeForm::NewL(TUint aDataType)
+    {
+    CMTPTypeObjectPropDescRangeForm* self = CMTPTypeObjectPropDescRangeForm::NewLC(aDataType);
+    CleanupStack::Pop(self); 
+    return self;
+    }
+
+/**
+MTP ObjectPropDesc Range FORM dataset factory method. This method is used to 
+create an empty MTP ObjectPropDesc FORM dataset of the specified Datatype. A 
+pointer to the data type is placed on the cleanup stack.
+@param aDataType The data type identifier datacode of the dataset.
+@return A pointer to the MTP ObjectPropDesc dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/   
+EXPORT_C CMTPTypeObjectPropDescRangeForm* CMTPTypeObjectPropDescRangeForm::NewLC(TUint aDataType)
+    {
+    CMTPTypeObjectPropDescRangeForm* self = new(ELeave) CMTPTypeObjectPropDescRangeForm(aDataType);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPTypeObjectPropDescRangeForm::~CMTPTypeObjectPropDescRangeForm()
+    {
+    TInt count(iChunks.Count());
+    while (count--)
+    	{
+    	iChunks[count].Close();    	
+    	}
+    iChunks.Close();
+    }
+
+EXPORT_C TUint CMTPTypeObjectPropDescRangeForm::Type() const
+    {
+    return EMTPTypeObjectPropDescRangeFormDataset;
+    } 
+
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeObjectPropDescRangeForm::ElementInfo(TInt aElementId) const
+    {
+    __ASSERT_ALWAYS((aElementId < ENumElements), Panic(EMTPTypeBoundsError));
+    iInfoBuf.iChunkId = aElementId;
+    return iInfoBuf;    
+    }
+
+CMTPTypeObjectPropDescRangeForm::CMTPTypeObjectPropDescRangeForm(TUint aDataType) : 
+    CMTPTypeCompoundBase((!KJustInTimeConstruction), ENumElements), 
+    iDataType(aDataType)
+    {
+    const CMTPTypeCompoundBase::TElementInfo KDefaultInfo = {0, EMTPTypeReference, {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}};
+    iInfoBuf = KDefaultInfo;
+    }
+
+void CMTPTypeObjectPropDescRangeForm::ConstructL()
+    {
+    for (TUint i(0); (i < ENumElements); i++)   
+        {
+        iChunks.AppendL(RMTPType());
+        iChunks[i].OpenL(iDataType);
+        ChunkAppendL(iChunks[i]);
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypeobjectproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,964 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/cmtptypeobjectpropdesc.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/cmtptypeobjectproplist.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <e32debug.h> 
+#include "mtpdatatypespanic.h"
+#include "e32cmn.h" 
+#include <utf.h>
+// Dataset constants
+
+const TInt KMTPPropListBufferPageSize(0x00010000); // 64kB
+const TInt KReservedTransportHeaderSize(32);
+const TInt KMaxStringSize(255);
+const TUint8 KPropElemHeaderSize(sizeof(TUint32) + sizeof(TUint16) + sizeof(TUint16));
+_LIT8(KMtpStringTerminator, "\0\0");
+
+/**
+MTP ObjectPropList dataset factory method. This method is used to create an 
+empty MTP ObjectPropList dataset. 
+@return A pointer to the MTP ObjectPropList dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeObjectPropList* CMTPTypeObjectPropList::NewL()
+    {
+    CMTPTypeObjectPropList* self = CMTPTypeObjectPropList::NewLC(); 
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+/**
+MTP ObjectPropList dataset factory method. This method is used to create an 
+empty MTP ObjectPropList dataset. A pointer to the data type is placed on the
+cleanup stack.
+@return A pointer to the MTP ObjectPropList dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeObjectPropList* CMTPTypeObjectPropList::NewLC()
+    {
+    CMTPTypeObjectPropList* self = new(ELeave) CMTPTypeObjectPropList();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+CMTPTypeObjectPropList::CMTPTypeObjectPropList()
+    {
+	
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPTypeObjectPropList::~CMTPTypeObjectPropList()
+    {
+    TInt pageCount = iIOPages.Count();
+    for(TInt i =0; i< pageCount; i++)
+    	{
+		iIOPages[i].Close();    	
+    	}
+	iIOPages.Close();
+	delete iCurrentElement;
+	delete iReservedElement;
+    }
+
+void CMTPTypeObjectPropList::ConstructL()
+{
+    ReserveNewPage();
+	iNumberOfElements = 0;
+	memcpy(&(iIOPages[0][KReservedTransportHeaderSize]), &iNumberOfElements, sizeof(TUint32));
+	iTransportHeaderIndex = KReservedTransportHeaderSize;
+	iRevPageEnd = 0;
+	iRevDataEnd = KReservedTransportHeaderSize + 4;
+	iReservedElemCommitted = ETrue;
+}
+
+EXPORT_C CMTPTypeObjectPropListElement& CMTPTypeObjectPropList::ReservePropElemL(TUint32 aHandle, TUint16 aPropCode)
+    {
+    if (NULL == iReservedElement)
+        {
+        iReservedElement = CMTPTypeObjectPropListElement::NewL(this);
+        }
+    
+    iReservedElement->iObjectHandle = aHandle;
+    iReservedElement->iPropertyCode = aPropCode;
+    iReservedElement->iDataType = 0x0000;
+    iReservedElement->iPageIndex = iRevPageEnd;
+    iReservedElement->iBufIndex = iRevDataEnd;
+    iReservedElement->iArrayBuffered = EFalse;
+    
+    TUint pageIndex = iReservedElement->iPageIndex;
+    TUint bufIndex = iReservedElement->iBufIndex;
+    
+    MemoryCopyL(pageIndex, bufIndex, &(iReservedElement->iObjectHandle), sizeof(TUint32));
+    IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint32), ETrue);
+    MemoryCopyL(pageIndex, bufIndex, &(iReservedElement->iPropertyCode), sizeof(TUint16));
+    IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint16), ETrue);
+    MemoryCopyL(pageIndex, bufIndex, &(iReservedElement->iDataType), sizeof(TUint16));
+    IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint16), ETrue);
+    
+    iReservedElement->iValueSize = 0;
+    
+    iReservedElemCommitted = EFalse;
+    
+    return *iReservedElement;
+    }
+
+EXPORT_C void CMTPTypeObjectPropList::CommitPropElemL(CMTPTypeObjectPropListElement& aElem)
+    {
+    if (&aElem != iReservedElement || iReservedElemCommitted 
+            || iReservedElement->iValueSize == 0)
+        {
+        __ASSERT_DEBUG(EFalse, User::Invariant());
+        }
+    TUint elemSize = iReservedElement->Size();
+    // Update iRevDataEnd, reallocate new buffer page if need
+    IncreaseIndexL(iRevPageEnd, iRevDataEnd, elemSize, ETrue);
+    ++(iNumberOfElements);
+    memcpy(&(iIOPages[0][KReservedTransportHeaderSize]), &iNumberOfElements, sizeof(TUint32));
+    
+    iReservedElemCommitted = ETrue;
+    }
+
+
+EXPORT_C CMTPTypeObjectPropListElement& CMTPTypeObjectPropList::GetNextElementL() const
+    {
+    // Update the page index and buffer index of element
+    if (NULL == iCurrentElement)
+        {
+        ResetCursor();
+        }
+    
+    if (iResetCursor)
+        {
+        iResetCursor = EFalse;
+        }
+    else
+        {
+        TUint elemSize = iCurrentElement->Size();
+        IncreaseIndexL(iCurrentElement->iPageIndex, iCurrentElement->iBufIndex, elemSize, EFalse);
+        }
+
+    iCurrentElement->iArrayBuffered = EFalse;
+    
+    // Copy value of handle/propcode/datatype from buffer to element
+    TUint pageIndex = iCurrentElement->iPageIndex;
+    TUint bufIndex = iCurrentElement->iBufIndex;
+    MemoryCopyL(&(iCurrentElement->iObjectHandle), pageIndex, bufIndex, sizeof(TUint32));
+    IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint32), EFalse);
+    MemoryCopyL(&(iCurrentElement->iPropertyCode), pageIndex, bufIndex, sizeof(TUint16));
+    IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint16), EFalse);
+    MemoryCopyL(&(iCurrentElement->iDataType), pageIndex, bufIndex, sizeof(TUint16));
+    IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint16), EFalse);
+
+    // Calculate value length
+    switch(iCurrentElement->iDataType)
+        {
+        case EMTPTypeUINT8:
+            iCurrentElement->iValueSize = sizeof(TUint8);
+            break;
+        case EMTPTypeUINT16:
+            iCurrentElement->iValueSize = sizeof(TUint16);
+            break;
+        case EMTPTypeUINT32:
+            iCurrentElement->iValueSize = sizeof(TUint32);
+            break;
+        case EMTPTypeUINT64:
+            iCurrentElement->iValueSize = sizeof(TUint64);
+            break;
+        case EMTPTypeUINT128:
+            iCurrentElement->iValueSize = 2 * sizeof(TUint64);
+            break;
+        case EMTPTypeString:
+            {
+            TUint8 arrayLen = 0;
+            MemoryCopyL(&arrayLen, pageIndex, bufIndex, sizeof(TUint8));
+            iCurrentElement->iValueSize = arrayLen * sizeof(TUint16) + sizeof(TUint8);
+            break;
+            }
+        case EMTPTypeAUINT16:
+        case EMTPTypeAUINT8:
+        case EMTPTypeAUINT32:
+        case EMTPTypeAUINT64:
+        case EMTPTypeAUINT128:
+            {
+            TUint32 arrayLen = 0;
+            TUint32 arrayWidth = ArrayElemWidth(iCurrentElement->iDataType);
+            MemoryCopyL(&arrayLen, pageIndex, bufIndex, sizeof(TUint32));
+            iCurrentElement->iValueSize = arrayLen * arrayWidth + sizeof(TUint32);
+            break;
+            }
+        default:
+            break;
+        }
+    
+    return *iCurrentElement;
+    }
+
+TBool CMTPTypeObjectPropList::ValueBufferConsistent(TUint /* aPageIdx */, TUint aBufferIdx, TUint aValueSize) const
+    {
+    if (aBufferIdx + aValueSize >= KMTPPropListBufferPageSize)
+        {
+        return EFalse;
+        }
+    
+    return ETrue;
+    }
+
+TBool CMTPTypeObjectPropList::ValueAddressAligned(TUint aPageIdx, TUint aBufferIdx) const
+    {
+    const TUint8* bufPtr = &(iIOPages[aPageIdx][aBufferIdx]);
+    if (reinterpret_cast<TUint32>(bufPtr) & 1)
+        {
+        return EFalse;
+        }
+    
+    return ETrue;
+    }
+
+EXPORT_C TUint64 CMTPTypeObjectPropList::Size() const
+{
+    TInt pageCount = iIOPages.Count();
+    TUint64 totalSize = 0;
+    totalSize = KMTPPropListBufferPageSize - KReservedTransportHeaderSize  
+                + KMTPPropListBufferPageSize * (iRevPageEnd - 1) + iRevDataEnd;
+
+    return totalSize;
+}
+
+
+EXPORT_C TUint32 CMTPTypeObjectPropList::NumberOfElements() const
+	{
+    return iNumberOfElements;
+	}
+
+EXPORT_C void CMTPTypeObjectPropList::ResetCursor() const
+    {
+    if (NULL == iCurrentElement)
+        {
+        CMTPTypeObjectPropList* propList = const_cast<CMTPTypeObjectPropList*>(this);
+        iCurrentElement = CMTPTypeObjectPropListElement::NewL(propList);
+        }
+    iCurrentElement->iPageIndex = 0;
+    iCurrentElement->iBufIndex = KReservedTransportHeaderSize + sizeof(TUint32);
+    iResetCursor = ETrue;
+    }
+
+EXPORT_C void CMTPTypeObjectPropList::AppendObjectPropListL(const CMTPTypeObjectPropList& aSource)
+    {
+    TInt chunkStatus = 0;
+    TBool copyFirstChunk = ETrue;
+    TUint srcElemNum = aSource.NumberOfElements();
+    
+    while (chunkStatus != KMTPChunkSequenceCompletion)
+        {
+        TPtrC8 tmpPtrRawData;
+        if (copyFirstChunk)
+            {
+            chunkStatus = aSource.FirstReadChunk(tmpPtrRawData);
+            tmpPtrRawData.Set(tmpPtrRawData.Ptr() + sizeof(TUint32), tmpPtrRawData.Length() - sizeof(TUint32));
+            copyFirstChunk = EFalse;
+            }
+        else
+            {
+            chunkStatus = aSource.NextReadChunk(tmpPtrRawData);
+            }
+        
+        const TUint8* srcPtr = tmpPtrRawData.Ptr();
+        MemoryCopyL(iRevPageEnd, iRevDataEnd, srcPtr, tmpPtrRawData.Length());
+        IncreaseIndexL(iRevPageEnd, iRevDataEnd, tmpPtrRawData.Length(), ETrue);
+        }
+    
+    iNumberOfElements += srcElemNum;
+    memcpy(&(iIOPages[0][KReservedTransportHeaderSize]), &iNumberOfElements, sizeof(TUint32));
+    }
+
+EXPORT_C TInt CMTPTypeObjectPropList::FirstReadChunk(TPtrC8& aChunk) const
+    {
+    TInt ret = KMTPDataTypeInvalid;
+    iChunkIndex = 0;
+    if (iRevPageEnd == 0)
+        {
+        aChunk.Set(&(iIOPages[0][iTransportHeaderIndex]), iRevDataEnd - iTransportHeaderIndex);
+        ret = KMTPChunkSequenceCompletion;
+        }
+    else
+        {
+        aChunk.Set(&(iIOPages[0][iTransportHeaderIndex]), KMTPPropListBufferPageSize - iTransportHeaderIndex);
+        ret = KErrNone;
+        }
+    return ret;
+    }
+
+EXPORT_C TInt CMTPTypeObjectPropList::NextReadChunk(TPtrC8& aChunk) const
+	{
+	TInt ret = KMTPDataTypeInvalid;
+	++iChunkIndex;
+	if (iChunkIndex < iRevPageEnd)
+	    {
+        aChunk.Set(&(iIOPages[iChunkIndex][0]), KMTPPropListBufferPageSize);
+        ret = KErrNone;
+	    }
+	else if (iChunkIndex == iRevPageEnd)
+	    {
+        aChunk.Set(&(iIOPages[iChunkIndex][0]), iRevDataEnd);
+        ret = KMTPChunkSequenceCompletion;
+	    }
+	
+	
+	return ret;
+	}
+
+EXPORT_C TInt CMTPTypeObjectPropList::FirstWriteChunk(TPtr8& aChunk)
+	{
+    aChunk.Set(&(iIOPages[0][iTransportHeaderIndex]), 0, KMTPPropListBufferPageSize - iTransportHeaderIndex);
+    return KErrNone;
+	}
+
+EXPORT_C TInt CMTPTypeObjectPropList::NextWriteChunk(TPtr8& aChunk)
+	{
+	ReserveNewPage();
+	aChunk.Set(&(iIOPages[iIOPages.Count()-1][0]), 0, KMTPPropListBufferPageSize);
+    return KErrNone;
+	}
+
+EXPORT_C TInt CMTPTypeObjectPropList::FirstWriteChunk(TPtr8& aChunk, TUint aDataLength)
+    {
+    TInt ret = KMTPDataTypeInvalid;
+    if (aDataLength <= KMTPPropListBufferPageSize - iTransportHeaderIndex)
+        {
+        aChunk.Set(&(iIOPages[0][iTransportHeaderIndex]), 0, aDataLength);
+        ret = KMTPChunkSequenceCompletion;
+        }
+    else
+        {
+        aChunk.Set(&(iIOPages[0][iTransportHeaderIndex]), 0, KMTPPropListBufferPageSize - iTransportHeaderIndex);
+        ret = KErrNone;
+        }
+    
+    return ret;
+    }
+
+EXPORT_C TInt CMTPTypeObjectPropList::NextWriteChunk(TPtr8& aChunk, TUint aDataLength)
+    {
+    TInt ret = KMTPDataTypeInvalid;
+    ReserveNewPage();
+    if (aDataLength <= KMTPPropListBufferPageSize)
+        {
+        aChunk.Set(&(iIOPages[iIOPages.Count()-1][0]), 0, aDataLength);
+        ret = KMTPChunkSequenceCompletion;
+        }
+    else
+        {
+        aChunk.Set(&(iIOPages[iIOPages.Count()-1][0]), 0, KMTPPropListBufferPageSize);
+        ret = KErrNone;
+        }
+    
+    return ret;    
+    }
+
+EXPORT_C TUint CMTPTypeObjectPropList::Type() const
+	{
+    return EMTPTypeObjectPropListDataset;
+	}
+
+EXPORT_C TBool CMTPTypeObjectPropList::CommitRequired() const
+	{
+	return ETrue;
+	}
+
+EXPORT_C MMTPType* CMTPTypeObjectPropList::CommitChunkL(TPtr8& aChunk)
+	{
+	iRevPageEnd = iIOPages.Count() - 1;
+	if (iRevPageEnd == 0)
+	    {
+	    iRevDataEnd = aChunk.Length() + KReservedTransportHeaderSize;
+	    
+	    if (aChunk.Length() >= sizeof(TUint32))
+	        {
+	        memcpy(&iNumberOfElements, &(iIOPages[0][KReservedTransportHeaderSize]), sizeof(TUint32));
+	        }	    
+	    }
+	else
+	    {
+	    iRevDataEnd = aChunk.Length();
+	    }
+
+	return NULL;
+	}
+
+EXPORT_C TBool CMTPTypeObjectPropList::ReserveTransportHeader(TUint aHeaderLength, TPtr8& aHeader)
+	{
+    if (aHeaderLength > KReservedTransportHeaderSize)
+        {
+        return EFalse;
+        }
+    
+    iTransportHeaderIndex = KReservedTransportHeaderSize - aHeaderLength;
+    
+    aHeader.Set(&(iIOPages[0][iTransportHeaderIndex]), aHeaderLength, aHeaderLength);
+    return ETrue;
+	}
+
+EXPORT_C TInt CMTPTypeObjectPropList::Validate() const
+    {
+    TInt relValue(KErrNone);
+	TUint32 num = NumberOfElements();
+	ResetCursor();
+	for(TUint32 i = 0; i< num;i++)
+		{
+		TRAPD(err, GetNextElementL())
+		if(KErrNone != err)
+			{
+			relValue = KMTPDataTypeInvalid;
+			break;
+			}
+		}	
+	
+	ResetCursor();
+	return relValue;
+	}
+
+TUint CMTPTypeObjectPropList::ArrayElemWidth(TUint16& aDataType) const
+	{
+	TUint width(0);
+	switch(aDataType)
+		{
+		case EMTPTypeAUINT8:
+			width = 1;
+			break;
+	    case EMTPTypeAUINT16:
+			width = 2;
+			break;			
+	    case EMTPTypeAUINT32:
+			width = 4;
+			break;			
+	    case EMTPTypeAUINT64:
+			width = 8;
+			break;			
+	    case EMTPTypeAUINT128:
+			width = 16;
+			break;			
+		default:
+			break;
+		}
+	return width;
+	}
+
+void CMTPTypeObjectPropList::IncreaseIndexL(TUint& aPageIndex, TUint& aBufIndex, TUint aLength, TBool aReserveNewPage) const
+    {
+    aBufIndex += aLength;
+    while (aBufIndex >= KMTPPropListBufferPageSize)
+        {
+        aBufIndex -= KMTPPropListBufferPageSize;
+        ++aPageIndex;
+        if (aPageIndex >= iIOPages.Count())
+            {
+            if (aReserveNewPage)
+                {
+                const_cast<CMTPTypeObjectPropList*>(this)->ReserveNewPage();
+                }
+            else
+                {
+                User::Leave(KErrOverflow);
+                }
+            }
+        }
+    }
+
+void CMTPTypeObjectPropList::ReserveNewPage()
+    {
+    RBuf8 tmpBuffer;
+    iIOPages.AppendL(tmpBuffer);
+    iIOPages[iIOPages.Count() - 1].CreateMaxL(KMTPPropListBufferPageSize);
+    }
+
+void CMTPTypeObjectPropList::MemoryCopyL(TAny* aTrg, TUint aSrcPageIndex, TUint aSrcBufIndex, TUint aLength) const
+    {
+    TUint bytesLeft = aLength;
+    TUint curPageIdx = aSrcPageIndex;
+    TUint curSrcBufIdx = aSrcBufIndex;
+    TUint8* copyTo = reinterpret_cast<TUint8*>(aTrg);
+    while (bytesLeft > 0)
+        {
+        const TUint8* srcBuf = &(iIOPages[curPageIdx][curSrcBufIdx]);
+        TUint copySize = bytesLeft;
+        if (curSrcBufIdx + bytesLeft > KMTPPropListBufferPageSize)
+            {
+            copySize = KMTPPropListBufferPageSize - curSrcBufIdx;
+            ++curPageIdx;
+            curSrcBufIdx = 0;
+            }
+        
+        if (curPageIdx >= iIOPages.Count())
+            {
+            User::Leave(KErrOverflow);
+            }
+        else if ((curPageIdx == iIOPages.Count() - 1) && curSrcBufIdx + bytesLeft - copySize > iRevDataEnd)
+            {
+            User::Leave(KErrOverflow);
+            }
+        
+        memcpy(copyTo, srcBuf, copySize);
+        bytesLeft -= copySize;
+        copyTo += copySize;
+        }
+    }
+
+void CMTPTypeObjectPropList::MemoryCopyL(TUint aTrgPageIndex, TUint aTrgBufIndex, const TAny* aSrc, TUint aLength)
+    {
+    TUint bytesLeft = aLength;
+    TUint curPageIdx = aTrgPageIndex;
+    TUint curSrcBufIdx = aTrgBufIndex;
+    const TUint8* copyFrom = reinterpret_cast<const TUint8*>(aSrc);
+    while (bytesLeft > 0)
+        {
+        if (curPageIdx == iIOPages.Count())
+            {
+            ReserveNewPage();
+            }        
+        TUint8* trgBuf = &(iIOPages[curPageIdx][curSrcBufIdx]);
+        TUint copySize = bytesLeft;
+        if (curSrcBufIdx + bytesLeft > KMTPPropListBufferPageSize)
+            {
+            copySize = KMTPPropListBufferPageSize - curSrcBufIdx;
+            ++curPageIdx;
+            curSrcBufIdx = 0;
+            }
+        memcpy(trgBuf, copyFrom, copySize);
+        bytesLeft -= copySize;
+        copyFrom += copySize;
+        }
+    }
+
+CMTPTypeObjectPropListElement* CMTPTypeObjectPropListElement::NewL(CMTPTypeObjectPropList* propList)
+	{
+	CMTPTypeObjectPropListElement* self = NewLC(propList);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CMTPTypeObjectPropListElement* CMTPTypeObjectPropListElement::NewLC(CMTPTypeObjectPropList* propList)
+    {
+    CMTPTypeObjectPropListElement* self = new(ELeave) CMTPTypeObjectPropListElement();
+    CleanupStack::PushL(self);
+    self->ConstructL(propList);
+    return self;
+    }
+
+CMTPTypeObjectPropListElement::CMTPTypeObjectPropListElement()
+	{
+
+	}
+
+EXPORT_C CMTPTypeObjectPropListElement::~CMTPTypeObjectPropListElement()
+	{
+	iStringHolder.Close();
+	}
+
+void CMTPTypeObjectPropListElement::ConstructL(CMTPTypeObjectPropList* propList)
+	{
+	iArrayBuffered = EFalse;
+    iPropList = propList;
+	iStringHolder.CreateL(KMaxStringSize);
+	}
+
+EXPORT_C TUint8 CMTPTypeObjectPropListElement::Uint8L(TInt aElementId) const
+	{
+	if(EValue != aElementId || EMTPTypeUINT8 != iDataType)
+	    User::Leave(KErrArgument);
+	TUint8 retValue = 0;
+	GetValueL(&retValue, sizeof(TUint8));
+
+	return retValue;
+	}
+
+EXPORT_C TUint16 CMTPTypeObjectPropListElement::Uint16L(TInt aElementId) const
+	{
+	switch(aElementId)
+		{
+		case EPropertyCode:
+			return iPropertyCode;
+		case EDatatype:
+			return iDataType;
+		case EValue:
+            if(EMTPTypeUINT16 != iDataType)
+                {
+                  User::Leave(KErrArgument);
+                }
+            TUint16 retValue;
+            GetValueL(&retValue, sizeof(TUint16));
+			return retValue;
+		default:
+			User::Leave(KErrArgument);
+		}	
+	return 0;
+	}
+
+EXPORT_C TUint32 CMTPTypeObjectPropListElement::Uint32L(TInt aElementId) const
+	{
+	switch(aElementId)
+		{
+		case EObjectHandle:
+			return iObjectHandle;
+		case EValue:
+		    if(EMTPTypeUINT32 != iDataType)
+		        {
+		          User::Leave(KErrArgument);
+		        }
+		    TUint32 retValue;
+		    GetValueL(&retValue, sizeof(TUint32));
+		    return retValue;
+		default:
+			User::Leave(KErrArgument);	
+		}
+	return 0;
+	}
+
+EXPORT_C TUint64 CMTPTypeObjectPropListElement::Uint64L(TInt aElementId) const
+	{
+	if(EValue != aElementId || EMTPTypeUINT64 != iDataType)
+	    {
+	    User::Leave(KErrArgument);
+	    }
+	
+	TUint64 retValue;
+	GetValueL(&retValue, sizeof(TUint64));	
+	return retValue;
+	}
+
+EXPORT_C void CMTPTypeObjectPropListElement::Uint128L(TInt aElementId,TUint64& high, TUint64& low) const
+	{
+	if(EValue != aElementId || EMTPTypeUINT128 != iDataType)
+	    {
+	    User::Leave(KErrArgument);
+	    }
+    TUint pageIndex = iPageIndex;
+    TUint bufIndex = iBufIndex;
+    iPropList->IncreaseIndexL(pageIndex, bufIndex, KPropElemHeaderSize, EFalse);
+    iPropList->MemoryCopyL(&low, pageIndex, bufIndex, sizeof(TUint64));
+    iPropList->IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint64), EFalse);
+    iPropList->MemoryCopyL(&high, pageIndex, bufIndex, sizeof(TUint64));
+	}
+
+EXPORT_C const TDesC& CMTPTypeObjectPropListElement::StringL(TInt aElementId) const
+	{
+	if(EValue != aElementId || EMTPTypeString != iDataType)
+	    {
+	    User::Leave(KErrArgument);
+	    }
+	
+	if (!iArrayBuffered)
+	    {
+        TUint arrayLen = 0;
+        TUint pageIndex = iPageIndex;
+        TUint bufIndex = iBufIndex;
+        iPropList->IncreaseIndexL(pageIndex, bufIndex, KPropElemHeaderSize, EFalse);
+        iPropList->MemoryCopyL(&arrayLen, pageIndex, bufIndex, sizeof(TUint8));
+        iPropList->IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint8), EFalse);
+        
+        if (arrayLen == 0)
+            {
+            // Empty string
+            iStringValue.Set(iStringHolder.Ptr(), 0);
+            }
+        else if (iPropList->ValueBufferConsistent(pageIndex, bufIndex, (arrayLen - 1) * sizeof(TUint16))
+                && iPropList->ValueAddressAligned(pageIndex, bufIndex))
+            {
+            //No need to copy data
+            const TUint8* srcPtr = &(iPropList->iIOPages[pageIndex][bufIndex]);            
+            iStringValue.Set(reinterpret_cast<const TUint16*>(srcPtr), arrayLen - 1);
+            }
+        else
+            {
+            // The address of srcPtr is not aligned, can't pass the address to TPtr16::Set() 
+            // Copy the string data in buffer to iStringHolder
+            TUint16* dstPtr = const_cast<TUint16*>(iStringHolder.Ptr());
+            iPropList->MemoryCopyL(dstPtr, pageIndex, bufIndex, (arrayLen - 1) * sizeof(TUint16));
+            iStringValue.Set(dstPtr, arrayLen - 1);
+            }
+        
+	    iArrayBuffered = ETrue;
+	    }
+
+	return iStringValue;
+	}
+
+EXPORT_C const TDesC8& CMTPTypeObjectPropListElement::ArrayL(TInt aElementId) const
+	{
+	if(EValue != aElementId || iDataType < EMTPTypeFirstSimpleArrayType 
+	        || iDataType > EMTPTypeLastSimpleArrayType)
+	    {
+	    User::Leave(KErrArgument);
+	    }
+	
+   if (!iArrayBuffered)
+        {
+        TUint32 arrayLen = 0;
+        TUint32 arrayWidth = iPropList->ArrayElemWidth(iDataType);
+        
+        TUint pageIndex = iPageIndex;
+        TUint bufIndex = iBufIndex;
+        iPropList->IncreaseIndexL(pageIndex, bufIndex, KPropElemHeaderSize, EFalse);
+        iPropList->MemoryCopyL(&arrayLen, pageIndex, bufIndex, sizeof(TUint32));
+        iPropList->IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint32), EFalse);
+        
+        if (arrayLen == 0)
+            {
+            // Empty array
+            iArrayValue.Set(reinterpret_cast<const TUint8*>(iStringHolder.Ptr()), 0);
+            }
+        // if iDataType == EMTPTypeAINT16 or iDataType == EMTPTypeAUINT16, the array maybe be converted to TDes16 by the user, the address should be aligned
+        else if (iPropList->ValueBufferConsistent(pageIndex, bufIndex, arrayLen * arrayWidth)
+                && ((iDataType != EMTPTypeAINT16 && iDataType != EMTPTypeAUINT16) || iPropList->ValueAddressAligned(pageIndex, bufIndex)))
+            {
+            //No need to copy data
+            const TUint8* srcPtr = &(iPropList->iIOPages[pageIndex][bufIndex]);
+            iArrayValue.Set(srcPtr, arrayLen * arrayWidth);
+            }
+        else
+            {
+            // The address of srcPtr is not aligned, can't pass the address to TPtr16::Set() 
+            // Copy the array data in buffer to iStringHolder
+            if (iStringHolder.MaxLength() * sizeof(TUint16) < arrayLen * arrayWidth)
+                {
+                iStringHolder.Zero();
+                iStringHolder.ReAllocL((arrayLen * arrayWidth + 1) / sizeof(TUint16));
+                }
+            TUint16* dstPtr = const_cast<TUint16*>(iStringHolder.Ptr());
+            iPropList->MemoryCopyL(dstPtr, pageIndex, bufIndex, arrayLen * arrayWidth);
+            iArrayValue.Set(reinterpret_cast<const TUint8*>(dstPtr), arrayLen * arrayWidth);
+            }
+        iArrayBuffered = ETrue;
+        }
+   
+	return iArrayValue;
+	}
+
+
+EXPORT_C void CMTPTypeObjectPropListElement::SetUint8L(TInt aElementId, TUint8 aData)
+    {
+    if(EValue != aElementId)
+        {
+        User::Leave(KErrArgument);
+        }
+    
+    SetDataType(EMTPTypeUINT8);
+    SetValueL(&aData, sizeof(TUint8));
+    }
+
+EXPORT_C void CMTPTypeObjectPropListElement::SetUint16L(TInt aElementId, TUint16 aData)
+    {
+    switch(aElementId)
+        {
+        case EPropertyCode:
+            {
+            iPropertyCode = aData;
+            // Copy PropertyCode to page buffer
+            TUint pageIndex = iPageIndex;
+            TUint bufIndex = iBufIndex;
+            iPropList->IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint32), ETrue);
+            iPropList->MemoryCopyL(pageIndex, bufIndex, &aData, sizeof(TUint16));
+            }
+            break;
+        case EDatatype:
+            SetDataType(aData);
+            break;
+        case EValue:
+            SetDataType(EMTPTypeUINT16);
+            SetValueL(&aData, sizeof(TUint16));
+            break;
+        default:
+            User::Leave(KErrArgument);
+        }   
+    }
+
+EXPORT_C void CMTPTypeObjectPropListElement::SetUint32L(TInt aElementId, TUint32 aData)
+    {
+    switch(aElementId)
+        {
+        case EObjectHandle:
+            iObjectHandle = aData;
+            iPropList->MemoryCopyL(iPageIndex, iBufIndex, &aData, sizeof(TUint32));
+            break;
+        case EValue:
+            SetDataType(EMTPTypeUINT32);
+            SetValueL(&aData, sizeof(TUint32));
+            break;
+        default:
+            User::Leave(KErrArgument);
+        }
+    }
+
+EXPORT_C void CMTPTypeObjectPropListElement::SetUint64L(TInt aElementId, TUint64 aData)
+    {
+    if(EValue != aElementId)
+        User::Leave(KErrArgument);
+    
+    SetDataType(EMTPTypeUINT64);
+    SetValueL(&aData, sizeof(TUint64));
+    }
+
+EXPORT_C void CMTPTypeObjectPropListElement::SetUint128L(TInt aElementId, TUint64 high, TUint64 low)
+    {
+    if(EValue != aElementId)
+        {
+        User::Leave(KErrArgument);
+        }
+    
+    SetDataType(EMTPTypeUINT128);
+    TUint pageIndex = iPageIndex;
+    TUint bufIndex = iBufIndex;
+    iPropList->IncreaseIndexL(pageIndex, bufIndex, KPropElemHeaderSize, ETrue);
+    iPropList->MemoryCopyL(pageIndex, bufIndex, &low, sizeof(TUint64));
+    iPropList->IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint64), ETrue);
+    iPropList->MemoryCopyL(pageIndex, bufIndex, &high, sizeof(TUint64));
+    iValueSize = sizeof(TUint64) * 2;
+    }
+
+EXPORT_C void CMTPTypeObjectPropListElement::SetStringL(TInt aElementId, const TDesC& aString)
+    {
+    if(EValue != aElementId || aString.Length() > KMaxStringSize)
+        {
+        User::Leave(KErrArgument);
+        }
+    
+    TUint8 len = aString.Length() + 1;
+
+    // For string which length is 255, truncate the last character to handle the file name of 255
+    if (aString.Length() == KMaxStringSize)
+        {
+        len = KMaxStringSize;
+        }
+    
+    SetDataType(EMTPTypeString);
+
+
+    iValueSize = 1 + len * sizeof(TUint16);
+    TUint pageIndex = iPageIndex;
+    TUint bufIndex = iBufIndex;
+    // Copy string length
+    iPropList->IncreaseIndexL(pageIndex, bufIndex, KPropElemHeaderSize, ETrue);
+    iPropList->MemoryCopyL(pageIndex, bufIndex, &len, sizeof(TUint8));
+    // Copy string data
+    iPropList->IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint8), ETrue);
+    iPropList->MemoryCopyL(pageIndex, bufIndex, aString.Ptr(), (len - 1) * sizeof(TUint16));
+    // Append terminator
+    iPropList->IncreaseIndexL(pageIndex, bufIndex, (len - 1) * sizeof(TUint16), ETrue);
+    iPropList->MemoryCopyL(pageIndex, bufIndex, KMtpStringTerminator().Ptr(), 2);
+        
+    iArrayBuffered = EFalse;
+    }
+
+EXPORT_C void CMTPTypeObjectPropListElement::SetArrayL(TInt aElementId, const CMTPTypeArray& aArray)
+    {
+    if(EValue != aElementId)
+        {
+        User::Leave(KErrArgument);
+        }
+    
+    SetDataType(aArray.Type());
+    TUint32 num = aArray.NumElements();
+    
+    
+    TUint pageIndex = iPageIndex;
+    TUint bufIndex = iBufIndex;
+    
+    // Set number of array elements
+    iPropList->IncreaseIndexL(pageIndex, bufIndex, KPropElemHeaderSize, ETrue);
+    iPropList->MemoryCopyL(pageIndex, bufIndex, &num, sizeof(TUint32));
+
+    TPtrC8 srcPtr;
+    aArray.FirstReadChunk(srcPtr);
+    srcPtr.Set(srcPtr.Ptr() + sizeof(TUint32), srcPtr.Length() - sizeof(TUint32));
+    
+    iPropList->IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint32), ETrue);
+    TUint arrayWidth = iPropList->ArrayElemWidth(iDataType);
+    iValueSize = sizeof(TUint32) + num * arrayWidth;
+    iPropList->MemoryCopyL(pageIndex, bufIndex, srcPtr.Ptr(), num * arrayWidth);
+    iArrayBuffered = EFalse;
+    }
+
+EXPORT_C void CMTPTypeObjectPropListElement::SetArrayL(TInt aElementId, const TDesC& aString)
+    {
+    if(EValue != aElementId)
+        {
+        User::Leave(KErrArgument);
+        }
+    
+    TUint32 len = aString.Length() + 1;
+    
+    SetDataType(EMTPTypeAUINT16);
+
+    iValueSize = sizeof(TUint32) + len * sizeof(TUint16);
+    
+    TUint pageIndex = iPageIndex;
+    TUint bufIndex = iBufIndex;
+    // Copy string length
+    iPropList->IncreaseIndexL(pageIndex, bufIndex, KPropElemHeaderSize, ETrue);
+    iPropList->MemoryCopyL(pageIndex, bufIndex, &len, sizeof(TUint32));
+    // Copy string data
+    iPropList->IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint32), ETrue);
+    iPropList->MemoryCopyL(pageIndex, bufIndex, aString.Ptr(), (len - 1) * sizeof(TUint16));
+    // Append terminator
+    iPropList->IncreaseIndexL(pageIndex, bufIndex, (len - 1) * sizeof(TUint16), ETrue);
+    iPropList->MemoryCopyL(pageIndex, bufIndex, KMtpStringTerminator().Ptr(), 2);
+        
+    iArrayBuffered = EFalse;
+     }
+
+EXPORT_C TUint32 CMTPTypeObjectPropListElement::CMTPTypeObjectPropListElement::Size() const
+    {
+    return iValueSize + KPropElemHeaderSize;
+    }
+
+void CMTPTypeObjectPropListElement::SetDataType(TUint16 aDataType)
+    {
+    iDataType = aDataType;
+    TUint pageIndex = iPageIndex;
+    TUint bufIndex = iBufIndex;    
+    iPropList->IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint32) + sizeof(TUint16), ETrue);
+    iPropList->MemoryCopyL(pageIndex, bufIndex, &iDataType, sizeof(TUint16));
+    }
+
+void CMTPTypeObjectPropListElement::GetValueL(TAny* aTrg, TUint aLength) const
+    {
+    TUint pageIndex = iPageIndex;
+    TUint bufIndex = iBufIndex;
+    iPropList->IncreaseIndexL(pageIndex, bufIndex, KPropElemHeaderSize, EFalse);
+    iPropList->MemoryCopyL(aTrg, pageIndex, bufIndex, aLength);
+    }
+
+void CMTPTypeObjectPropListElement::SetValueL(const TAny* aSrc, TUint aLength)
+    {
+    TUint pageIndex = iPageIndex;
+    TUint bufIndex = iBufIndex;
+    iPropList->IncreaseIndexL(pageIndex, bufIndex, KPropElemHeaderSize, ETrue);
+    iPropList->MemoryCopyL(pageIndex, bufIndex, aSrc, aLength);
+    iValueSize = aLength;
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypeopaquedata.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,180 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/cmtptypeopaquedata.h>
+
+
+const TInt KMaxSizeOfWriteBuffer = 0x00010000; // 64KB
+
+EXPORT_C CMTPTypeOpaqueData* CMTPTypeOpaqueData::NewL()
+    {
+    CMTPTypeOpaqueData* self = NewLC();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+EXPORT_C CMTPTypeOpaqueData* CMTPTypeOpaqueData::NewLC()
+    {
+    CMTPTypeOpaqueData* self = new(ELeave) CMTPTypeOpaqueData();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+EXPORT_C CMTPTypeOpaqueData* CMTPTypeOpaqueData::NewL(const TDesC8 &aDes)
+    {
+    CMTPTypeOpaqueData* self = NewLC(aDes);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+EXPORT_C CMTPTypeOpaqueData* CMTPTypeOpaqueData::NewLC(const TDesC8 &aDes)
+    {
+    CMTPTypeOpaqueData* self = new(ELeave) CMTPTypeOpaqueData();
+    CleanupStack::PushL(self);
+    self->ConstructL(aDes);
+    return self;
+    }
+
+void CMTPTypeOpaqueData::ConstructL()
+    {
+    
+    }
+
+CMTPTypeOpaqueData::CMTPTypeOpaqueData():
+    iPtrBuffer(NULL, 0)
+    {
+    
+    }
+
+EXPORT_C CMTPTypeOpaqueData::~CMTPTypeOpaqueData()
+    {
+    iBuffer.Close();
+    }
+
+void CMTPTypeOpaqueData::ConstructL(const TDesC8 &aDes)
+    {
+    iPtrBuffer.Set(const_cast<TUint8*>(aDes.Ptr()), aDes.Length(), aDes.Size());
+    }
+
+EXPORT_C TInt CMTPTypeOpaqueData::FirstReadChunk(TPtrC8& aChunk) const
+    {
+    aChunk.Set(iPtrBuffer);
+
+    return KMTPChunkSequenceCompletion;
+    }
+    
+EXPORT_C TInt CMTPTypeOpaqueData::NextReadChunk(TPtrC8& aChunk) const
+    {
+    aChunk.Set(NULL, 0);
+    return KErrNotReady;
+    }
+
+TInt CMTPTypeOpaqueData::CreateBuffer( const TInt aMaxSize )
+    {
+    TInt err = iBuffer.Create( aMaxSize );
+    if( KErrNone != err)
+        return err;
+      
+    iPtrBuffer.Set(const_cast<TUint8*>(iBuffer.Ptr()), 0, aMaxSize);
+    
+    return KErrNone;
+    }
+
+EXPORT_C TInt CMTPTypeOpaqueData::FirstWriteChunk(TPtr8& aChunk)
+    {
+    if(iPtrBuffer.MaxSize() == 0)
+        {
+        TInt err =  CreateBuffer( KMaxSizeOfWriteBuffer );
+        if( KErrNone != err)
+            return err;
+        }
+    
+    aChunk.Set( const_cast<TUint8*>(iPtrBuffer.Ptr()), 0, iPtrBuffer.MaxSize());
+    
+    return KMTPChunkSequenceCompletion;
+    }
+
+EXPORT_C TInt CMTPTypeOpaqueData::FirstWriteChunk(TPtr8& aChunk, TUint aDataLength )
+    {
+    if(KMaxSizeOfWriteBuffer < aDataLength )
+        return KErrOverflow;
+    
+    TInt size = aDataLength;
+    if( aDataLength <= 0 )
+        {
+        size = KMaxSizeOfWriteBuffer;
+        }
+    
+    TInt err =  CreateBuffer( size );
+    if( KErrNone != err)
+        return err;
+
+    
+    return FirstWriteChunk(aChunk);
+    }
+
+EXPORT_C TInt CMTPTypeOpaqueData::NextWriteChunk(TPtr8& aChunk)
+    {
+    aChunk.Set(NULL, 0, 0);
+    return KErrNotReady;
+    }
+
+EXPORT_C TBool CMTPTypeOpaqueData::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* CMTPTypeOpaqueData::CommitChunkL(TPtr8& aChunk)
+    {
+    iPtrBuffer.Set(aChunk);
+    return NULL;
+    }
+
+EXPORT_C TUint64 CMTPTypeOpaqueData::Size() const
+    {
+    return iPtrBuffer.Size();
+    }
+
+EXPORT_C TUint CMTPTypeOpaqueData::Type() const
+    {
+    return EMTPTypeOpaqueData;        
+    }
+
+EXPORT_C TInt CMTPTypeOpaqueData::Read(TPtrC8 &aDes) const
+    {
+    aDes.Set( iPtrBuffer );
+    return KErrNone;
+    }
+
+EXPORT_C TInt CMTPTypeOpaqueData::Write( const TPtrC8 &aDes)
+    {
+    if(iBuffer.MaxSize() != 0)
+        {
+        iBuffer.Close();
+        }
+    
+    iPtrBuffer.Set(const_cast<TUint8*>(aDes.Ptr()), aDes.Length(), aDes.Size());
+    return KErrNone;
+    }
+
+   
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypeservicecapabilitylist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,232 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@publishedPartner
+*/
+#include <mtp/tmtptypeflatbase.h>
+#include <mtp/cmtptypeobjectpropdesc.h>
+#include <mtp/cmtptypeinterdependentpropdesc.h>
+#include <mtp/cmtptypeservicecapabilitylist.h>
+
+
+#include "mtpdatatypespanic.h"
+
+// Dataset constants
+const TUint KMTPChunk0Size = 2;
+
+// Dataset element metadata.
+const CMTPTypeCompoundBase::TElementInfo CMTPTypeFormatCapability::iElementMetaData[CMTPTypeFormatCapability::ENumElements] = 
+    {
+        {EIdFlatChunk,                          EMTPTypeFlat,                          {EMTPTypeUINT16,    0,                  KMTPTypeUINT16Size}},   // EFormatCode
+   };
+
+
+EXPORT_C CMTPTypeServiceCapabilityList* CMTPTypeServiceCapabilityList::NewL()
+    {
+    CMTPTypeServiceCapabilityList* self = CMTPTypeServiceCapabilityList::NewLC(); 
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+EXPORT_C CMTPTypeServiceCapabilityList* CMTPTypeServiceCapabilityList::NewLC()
+    {
+    CMTPTypeServiceCapabilityList* self = new(ELeave) CMTPTypeServiceCapabilityList();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+EXPORT_C CMTPTypeServiceCapabilityList::~CMTPTypeServiceCapabilityList()
+    {
+
+    }
+
+EXPORT_C void CMTPTypeServiceCapabilityList::AppendL(CMTPTypeFormatCapability* aElement)
+    {
+    CMTPTypeList::AppendL(aElement);
+    }
+
+EXPORT_C CMTPTypeFormatCapability& CMTPTypeServiceCapabilityList::ElementL(TUint aIndex) const
+	{
+	return static_cast<CMTPTypeFormatCapability&>( CMTPTypeList::ElementL(aIndex) );
+	}
+
+CMTPTypeServiceCapabilityList::CMTPTypeServiceCapabilityList():
+	CMTPTypeList(EMTPTypeServiceCapabilityListDataset,EMTPTypeFormatCapabilityDataset)
+    {
+
+    }
+
+void CMTPTypeServiceCapabilityList::ConstructL()
+    {
+    InitListL();
+    }
+    
+
+EXPORT_C CMTPTypeFormatCapability* CMTPTypeFormatCapability::NewL()
+    {
+    CMTPTypeFormatCapability* self = CMTPTypeFormatCapability::NewLC(); 
+    CleanupStack::Pop(self);
+    return self; 
+    }
+
+EXPORT_C CMTPTypeFormatCapability* CMTPTypeFormatCapability::NewLC()
+    {
+    CMTPTypeFormatCapability* self = new (ELeave) CMTPTypeFormatCapability( NULL ); 
+    CleanupStack::PushL(self); 
+    self->ConstructL();
+    return self;    
+    }
+
+EXPORT_C CMTPTypeFormatCapability* CMTPTypeFormatCapability::NewL(const TUint16 aFormatCode, CMTPTypeInterdependentPropDesc* aInterDependentPropDesc )
+    {
+    CMTPTypeFormatCapability* self = CMTPTypeFormatCapability::NewLC( aFormatCode, aInterDependentPropDesc ); 
+    CleanupStack::Pop(self);
+    return self; 
+    }
+
+EXPORT_C CMTPTypeFormatCapability* CMTPTypeFormatCapability::NewLC(const TUint16 aFormatCode, CMTPTypeInterdependentPropDesc* aInterDependentPropDesc )
+    {
+    CMTPTypeFormatCapability* self = new (ELeave) CMTPTypeFormatCapability( aInterDependentPropDesc ); 
+    CleanupStack::PushL(self); 
+    self->ConstructL( aFormatCode );
+    return self;    
+    }
+
+EXPORT_C CMTPTypeFormatCapability::~CMTPTypeFormatCapability()
+    {    
+    iChunkFlat.Close();
+    delete iObjectPropDescList;
+    delete iInterdependentPropDesc;
+    }
+
+EXPORT_C void CMTPTypeFormatCapability::AppendL(CMTPTypeObjectPropDesc* aElement)
+    {
+    __ASSERT_DEBUG(aElement, User::Invariant());
+    
+    iObjectPropDescList->AppendL( static_cast<MMTPType*>(aElement));
+    }
+
+EXPORT_C TUint32 CMTPTypeFormatCapability::NumberOfPropDescs() const
+    {
+    return iObjectPropDescList->NumberOfElements();
+    }
+
+EXPORT_C CMTPTypeObjectPropDesc& CMTPTypeFormatCapability::ObjectPropDescL(TUint aIndex) const
+    {
+     return static_cast<CMTPTypeObjectPropDesc&>(iObjectPropDescList->ElementL( aIndex ));
+    }
+
+EXPORT_C CMTPTypeInterdependentPropDesc& CMTPTypeFormatCapability::InterdependentPropDesc() const
+    {
+    return *iInterdependentPropDesc;
+    }
+
+EXPORT_C TUint CMTPTypeFormatCapability::Type() const
+    {
+    return EMTPTypeFormatCapabilityDataset;
+    }
+
+EXPORT_C TBool CMTPTypeFormatCapability::ReadableElementL(TInt aElementId) const
+    {
+    if( aElementId == EFormatCode)
+        {
+        return ETrue;
+        }
+    else
+        {
+        return EFalse;
+        }
+    }
+
+EXPORT_C TBool CMTPTypeFormatCapability::WriteableElementL(TInt aElementId ) const
+    {
+    if( aElementId == EFormatCode)
+           {
+           return ETrue;
+           }
+       else
+           {
+           return EFalse;
+           } 
+    }
+
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeFormatCapability::ElementInfo(TInt aElementId) const
+    {
+    return iElementInfo[aElementId];
+    }
+
+
+CMTPTypeFormatCapability::CMTPTypeFormatCapability( CMTPTypeInterdependentPropDesc* aInterDependentPropDesc) : 
+    CMTPTypeCompoundBase((!KJustInTimeConstruction), EIdNumChunks), 
+    iElementInfo(iElementMetaData, ENumElements),
+    iChunkFlat(KMTPChunk0Size, *this),
+    iInterdependentPropDesc(aInterDependentPropDesc)
+    {
+    
+    }
+
+void CMTPTypeFormatCapability::ConstructL()
+    {
+    for (TUint i(0); (i < ENumElements); i++)
+        {
+        const TElementInfo& info(iElementInfo[i]);
+        if (ChunkCount() <= info.iChunkId)
+            {
+            MMTPType* chunk(NULL);
+            
+            switch (info.iType)
+                {
+            case EMTPTypeFlat:
+                chunk = NewFlatChunkL();
+                break;  
+            default:
+                break;
+                }
+                
+            __ASSERT_DEBUG(chunk, User::Invariant());
+            ChunkAppendL(*chunk);
+            }
+        }
+    
+    iObjectPropDescList = CMTPTypeList::NewL(EMTPTypeFormatCapabilityDataset,EMTPTypeObjectPropDescDataset);
+    if( NULL == iInterdependentPropDesc )
+        {
+        iInterdependentPropDesc = CMTPTypeInterdependentPropDesc::NewL();
+        }
+    ChunkAppendL(*iObjectPropDescList);
+    ChunkAppendL(*iInterdependentPropDesc);
+    }
+
+MMTPType* CMTPTypeFormatCapability::NewFlatChunkL()
+    {
+    MMTPType* chunk(NULL);
+
+    iChunkFlat.OpenL();
+    chunk = &iChunkFlat;
+    
+    __ASSERT_DEBUG(chunk, User::Invariant());
+    return chunk;
+    }
+
+void CMTPTypeFormatCapability::ConstructL(const TUint16 aFormatCode)
+    {
+    ConstructL();
+
+    // Set mandatory construction values.
+    SetUint16L(EFormatCode, aFormatCode);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypeserviceevent.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,186 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@publishedPartner
+*/
+
+#include <mtp/tmtptypeflatbase.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/cmtptypeserviceevent.h>
+
+#include "mtpdatatypespanic.h"
+
+// Dataset constants
+const TUint KMTPChunk0Size = 18;
+
+
+const CMTPTypeCompoundBase::TElementInfo CMTPTypeServiceEventElement::iElementMetaData[CMTPTypeServiceEventElement::ENumElements] = 
+    {
+        {EIdFlatChunk,                      EMTPTypeFlat,   {EMTPTypeUINT16,    0,                  KMTPTypeUINT16Size}},   // EMTPServiceEventCode
+        {EIdFlatChunk,                      EMTPTypeFlat,   {EMTPTypeUINT128,   2,                  KMTPTypeUINT128Size}},  // EMTPServiceEventGUID
+        {EIdServiceEventNameChunk,          EMTPTypeString, {EMTPTypeString,    KMTPNotApplicable,  KMTPNotApplicable}},    // EMTPServiceEventName
+   };
+
+EXPORT_C CMTPTypeServiceEventList* CMTPTypeServiceEventList::NewL()
+    {
+    CMTPTypeServiceEventList* self = CMTPTypeServiceEventList::NewLC(); 
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+EXPORT_C CMTPTypeServiceEventList* CMTPTypeServiceEventList::NewLC()
+    {
+    CMTPTypeServiceEventList* self = new(ELeave) CMTPTypeServiceEventList();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+EXPORT_C CMTPTypeServiceEventList::~CMTPTypeServiceEventList()
+    {
+    }
+
+EXPORT_C void CMTPTypeServiceEventList::AppendL(CMTPTypeServiceEventElement* aElement)
+    {
+    CMTPTypeList::AppendL(aElement);
+    }
+EXPORT_C CMTPTypeServiceEventElement& CMTPTypeServiceEventList::ElementL(TUint aIndex) const
+    {
+    return static_cast<CMTPTypeServiceEventElement&>( CMTPTypeList::ElementL(aIndex) );
+    }
+
+CMTPTypeServiceEventList::CMTPTypeServiceEventList() :
+CMTPTypeList(EMTPTypeServiceEventListDataset,EMTPTypeServiceEventElementDataset)
+    {
+    }
+
+void CMTPTypeServiceEventList::ConstructL()
+    {
+    InitListL();
+    }
+    
+
+
+EXPORT_C CMTPTypeServiceEventElement* CMTPTypeServiceEventElement::NewL()
+    {
+    CMTPTypeServiceEventElement* self = NewLC( );
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+EXPORT_C CMTPTypeServiceEventElement* CMTPTypeServiceEventElement::NewLC()
+    {
+    CMTPTypeServiceEventElement* self = new(ELeave) CMTPTypeServiceEventElement();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+EXPORT_C CMTPTypeServiceEventElement* CMTPTypeServiceEventElement::NewL(const TUint16 aEventCode,const TMTPTypeGuid& aEventGUID,const TDesC& aEventName)
+    {
+    CMTPTypeServiceEventElement* self = NewLC( aEventCode, aEventGUID, aEventName);
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+EXPORT_C CMTPTypeServiceEventElement* CMTPTypeServiceEventElement::NewLC(const TUint16 aEventCode,const TMTPTypeGuid& aEventGUID,const TDesC& aEventName)
+    {
+    CMTPTypeServiceEventElement* self = new (ELeave) CMTPTypeServiceEventElement(); 
+	CleanupStack::PushL(self); 
+    self->ConstructL(aEventCode, aEventGUID, aEventName);
+	return self;    
+    }
+
+/**
+Destructor.
+*/    
+EXPORT_C CMTPTypeServiceEventElement::~CMTPTypeServiceEventElement()
+    {    
+    iChunkFlat.Close();
+    delete iChunkString;
+    }
+
+
+EXPORT_C TUint CMTPTypeServiceEventElement::Type() const
+    {
+    return EMTPTypeServiceEventElementDataset;
+    }
+
+
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeServiceEventElement::ElementInfo(TInt aElementId) const
+    {
+    return iElementInfo[aElementId];
+    }
+
+CMTPTypeServiceEventElement::CMTPTypeServiceEventElement() : 
+    CMTPTypeCompoundBase((!KJustInTimeConstruction), EIdNumChunks), 
+    iElementInfo(iElementMetaData, ENumElements),
+    iChunkFlat(KMTPChunk0Size, *this)
+    {
+    
+    }
+
+void CMTPTypeServiceEventElement::ConstructL()
+    {
+    for (TUint i(0); (i < ENumElements); i++)
+        {
+        const TElementInfo& info(iElementInfo[i]);
+        if (ChunkCount() <= info.iChunkId)
+            {
+            MMTPType* chunk(NULL);
+            
+            switch (info.iType)
+                {
+            case EMTPTypeFlat:
+            	chunk = NewFlatChunkL();
+            	break;  
+            case EMTPTypeString:
+            	iChunkString = CMTPTypeString::NewL();
+            	chunk = iChunkString ;
+                break;
+            default:
+                break;
+                }
+                
+            __ASSERT_DEBUG(chunk, User::Invariant());
+            ChunkAppendL(*chunk);
+            }
+        }
+    }
+
+
+MMTPType* CMTPTypeServiceEventElement::NewFlatChunkL()
+    {
+    MMTPType* chunk(NULL);
+
+    iChunkFlat.OpenL();
+    chunk = &iChunkFlat;
+        
+    __ASSERT_DEBUG(chunk, User::Invariant());
+    return chunk;
+    }
+
+void CMTPTypeServiceEventElement::ConstructL(const TUint16 aEventCode,const TMTPTypeGuid& aEventGUID,const TDesC& aEventName)
+    {
+
+    ConstructL();
+
+    // Set mandatory construction values.
+    SetUint16L(EEventCode, aEventCode);
+    SetL(EEventGUID, aEventGUID);
+    SetStringL(EEventName,aEventName);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypeserviceformat.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,222 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@publishedPartner
+*/
+
+#include <mtp/tmtptypeflatbase.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/cmtptypeserviceformat.h>
+
+#include "mtpdatatypespanic.h"
+
+// Dataset constants
+
+const TUint CMTPTypeServiceFormatElement::KFlat1ChunkSize(18);
+const TUint CMTPTypeServiceFormatElement::KFlat2ChunkSize(2);
+
+
+const CMTPTypeCompoundBase::TElementInfo CMTPTypeServiceFormatElement::iElementMetaData[CMTPTypeServiceFormatElement::ENumElements] = 
+    {
+        {EIdFlat1Chunk,                      EMTPTypeFlat,   {EMTPTypeUINT16,    0,                  KMTPTypeUINT16Size}},   // EMTPServiceFormatCode
+        {EIdFlat1Chunk,                      EMTPTypeFlat,   {EMTPTypeUINT128,   2,                  KMTPTypeUINT128Size}},  // EMTPServiceFormatGUID
+        {EIdFormatNameChunk,				EMTPTypeString,	{EMTPTypeString,	KMTPNotApplicable,	KMTPNotApplicable}},	// EMTPServiceFormatName        
+        {EIdFlat2Chunk,						EMTPTypeFlat,	{EMTPTypeUINT16,	0,					KMTPTypeUINT16Size}},	// EMTPServiceFormatBase
+        {EIdFormatMIMETypeChunk,   	        EMTPTypeString, {EMTPTypeString,    KMTPNotApplicable,  KMTPNotApplicable}},    // EMTPServiceFormatMIMTType
+   };
+
+EXPORT_C CMTPTypeServiceFormatList* CMTPTypeServiceFormatList::NewL()
+    {
+    CMTPTypeServiceFormatList* self = CMTPTypeServiceFormatList::NewLC(); 
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+EXPORT_C CMTPTypeServiceFormatList* CMTPTypeServiceFormatList::NewLC()
+    {
+    CMTPTypeServiceFormatList* self = new(ELeave) CMTPTypeServiceFormatList();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+EXPORT_C CMTPTypeServiceFormatList::~CMTPTypeServiceFormatList()
+    {
+
+    }
+
+EXPORT_C void CMTPTypeServiceFormatList::AppendL(CMTPTypeServiceFormatElement* aElement)
+    {
+    CMTPTypeList::AppendL(aElement);
+    }
+
+CMTPTypeServiceFormatList::CMTPTypeServiceFormatList() :
+CMTPTypeList(EMTPTypeServiceFormatListDataset,EMTPTypeServiceFormatElementDataset)
+    {
+    }
+
+void CMTPTypeServiceFormatList::ConstructL()
+    {
+    InitListL();
+    }
+    
+EXPORT_C CMTPTypeServiceFormatElement& CMTPTypeServiceFormatList::ElementL(TUint aIndex) const
+    {
+    return static_cast<CMTPTypeServiceFormatElement&>( CMTPTypeList::ElementL(aIndex) );
+    }
+
+EXPORT_C CMTPTypeServiceFormatElement* CMTPTypeServiceFormatElement::NewL()
+    {
+    CMTPTypeServiceFormatElement* self = NewLC();
+    CleanupStack::Pop(self);
+    return self; 
+    }
+
+EXPORT_C CMTPTypeServiceFormatElement* CMTPTypeServiceFormatElement::NewLC()
+    {
+    CMTPTypeServiceFormatElement* self = new(ELeave) CMTPTypeServiceFormatElement();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+EXPORT_C CMTPTypeServiceFormatElement* CMTPTypeServiceFormatElement::NewL(const TUint16 aFormatCode,const TMTPTypeGuid& aFormatGUID,const TDesC& aFormatName,const TUint16 aFormatBase,const TDesC& aMIMEType)
+    {
+    CMTPTypeServiceFormatElement* self = NewLC( aFormatCode, aFormatGUID, aFormatName, aFormatBase, aMIMEType);
+    CleanupStack::Pop(self);
+    return self; 
+    }
+
+EXPORT_C CMTPTypeServiceFormatElement* CMTPTypeServiceFormatElement::NewLC(const TUint16 aFormatCode,const TMTPTypeGuid& aFormatGUID,const TDesC& aFormatName,const TUint16 aFormatBase,const TDesC& aMIMEType)
+    {
+    CMTPTypeServiceFormatElement* self = new (ELeave) CMTPTypeServiceFormatElement(); 
+	CleanupStack::PushL(self); 
+    self->ConstructL(aFormatCode, aFormatGUID, aFormatName, aFormatBase, aMIMEType);
+	return self;    
+    }
+
+/**
+Destructor.
+*/    
+EXPORT_C CMTPTypeServiceFormatElement::~CMTPTypeServiceFormatElement()
+    {    
+    iChunkFlat1.Close();
+    iChunkFlat2.Close();
+    delete iChunkFormatNameString;
+    delete iChunkMIMETypeString;
+    }
+
+
+
+EXPORT_C TUint CMTPTypeServiceFormatElement::Type() const
+    {
+    return EMTPTypeServiceFormatElementDataset;
+    }
+
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeServiceFormatElement::ElementInfo(TInt aElementId) const
+    {
+    return iElementInfo[aElementId];
+    }
+
+CMTPTypeServiceFormatElement::CMTPTypeServiceFormatElement() : 
+    CMTPTypeCompoundBase((!KJustInTimeConstruction), EIdNumChunks), 
+    iElementInfo(iElementMetaData, ENumElements),
+    iChunkFlat1(KFlat1ChunkSize, *this),
+    iChunkFlat2(KFlat2ChunkSize, *this)
+    {
+    
+    }
+
+void CMTPTypeServiceFormatElement::ConstructL()
+    {
+    for (TUint i(0); (i < ENumElements); i++)
+        {
+        const TElementInfo& info(iElementInfo[i]);
+        if (ChunkCount() <= info.iChunkId)
+            {
+            MMTPType* chunk(NULL);
+            
+            switch (info.iType)
+                {
+            case EMTPTypeFlat:
+            	chunk = NewFlatChunkL(info);
+            	break;  
+            case EMTPTypeString:
+            	chunk = NewStringChunkL(info);
+                break;
+            default:
+                break;
+                }
+                
+            __ASSERT_DEBUG(chunk, User::Invariant());
+            ChunkAppendL(*chunk);
+            }
+        }
+    }
+
+MMTPType* CMTPTypeServiceFormatElement::NewFlatChunkL(const TElementInfo& aElementInfo)
+    {
+    MMTPType* chunk(NULL);
+    if (aElementInfo.iChunkId == EIdFlat1Chunk)
+        {
+        iChunkFlat1.OpenL();
+        chunk = &iChunkFlat1;
+        }
+    else if ( aElementInfo.iChunkId == EIdFlat2Chunk )
+    	{
+    	iChunkFlat2.OpenL();
+    	chunk = &iChunkFlat2;
+    	}
+    else
+    	{}
+    __ASSERT_DEBUG(chunk, User::Invariant());
+    return chunk;
+    }
+
+MMTPType* CMTPTypeServiceFormatElement::NewStringChunkL(const TElementInfo& aElementInfo)
+	{
+    MMTPType* chunk(NULL);
+    if (aElementInfo.iChunkId == EIdFormatNameChunk)
+        {
+        iChunkFormatNameString = CMTPTypeString::NewL();
+        chunk = iChunkFormatNameString ;
+        }
+    else if ( aElementInfo.iChunkId == EIdFormatMIMETypeChunk )
+    	{
+    	iChunkMIMETypeString = CMTPTypeString::NewL();
+    	chunk = iChunkMIMETypeString ;
+    	}
+    else
+    	{}
+    __ASSERT_DEBUG(chunk, User::Invariant());
+    return chunk;
+	}
+
+void CMTPTypeServiceFormatElement::ConstructL(const TUint16 aFormatCode,const TMTPTypeGuid& aFormatGUID,const TDesC& aFormatName,const TUint16 aFormatBase,const TDesC& aMIMEType)
+    {
+
+    ConstructL();
+
+    // Set mandatory construction values.
+    SetUint16L(EFormatCode, aFormatCode);
+    SetL(EFormatGUID, aFormatGUID);
+    SetStringL(EFormatName,aFormatName);
+    SetUint16L(EFormatBase,aFormatBase);
+    
+    SetStringL(EFormatMIMEType,aMIMEType);
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypeserviceinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,227 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@publishedPartner
+*/
+#include <mtp/tmtptypeflatbase.h>
+//#include <mtp/cmtptypeservicesection.h>
+#include <mtp/cmtptypeserviceinfo.h>
+#include <mtp/cmtptypeserviceprop.h>
+#include <mtp/cmtptypeserviceformat.h>
+#include <mtp/cmtptypeservicemethod.h>
+#include <mtp/cmtptypeserviceevent.h>
+#include <mtp/cmtptypestring.h>
+
+#include "mtpdatatypespanic.h"
+
+const TUint CMTPTypeServiceInfo::KFlat1ChunkSize(44);
+const TUint CMTPTypeServiceInfo::KFlat2ChunkSize(8);
+
+const CMTPTypeCompoundBase::TElementInfo CMTPTypeServiceInfo::iElementMetaData[CMTPTypeServiceInfo::ENumElements] = 
+    {
+        {EIdFlat1Chunk,                       EMTPTypeFlat,      {EMTPTypeUINT32,    0,                  KMTPTypeUINT32Size}},   // EMTPServiceID
+        {EIdFlat1Chunk,                       EMTPTypeFlat,      {EMTPTypeUINT32,    4,                  KMTPTypeUINT32Size}},   // EMTPServiceStorageID
+        {EIdFlat1Chunk,                       EMTPTypeFlat,      {EMTPTypeUINT128,   8,                  KMTPTypeUINT128Size}},  // EMTPServicePGUID
+        {EIdFlat1Chunk,                       EMTPTypeFlat,      {EMTPTypeUINT32,    24,                 KMTPTypeUINT32Size}},   // EMTPServiceVersion
+        {EIdFlat1Chunk,                       EMTPTypeFlat,      {EMTPTypeUINT128,   28,                 KMTPTypeUINT128Size}},  // EMTPServiceGUID
+        {EIdServiceNameChunk,                 EMTPTypeString,    {EMTPTypeString,    KMTPNotApplicable,  KMTPNotApplicable}},    // EMTPServiceName        
+        {EIdFlat2Chunk,                       EMTPTypeFlat,      {EMTPTypeUINT32,    0,                  KMTPTypeUINT32Size}},   // EMTPServiceType
+        {EIdFlat2Chunk,                       EMTPTypeFlat,      {EMTPTypeUINT32,    4,                  KMTPTypeUINT32Size}},   // EMTPBaseServiceID
+   };
+
+EXPORT_C CMTPTypeServiceInfo* CMTPTypeServiceInfo::NewL()
+    {
+    CMTPTypeServiceInfo* self = CMTPTypeServiceInfo::NewLC(); 
+    CleanupStack::Pop(self);
+    return self; 
+    }
+
+EXPORT_C CMTPTypeServiceInfo* CMTPTypeServiceInfo::NewLC()
+    {
+    CMTPTypeServiceInfo* self = new (ELeave) CMTPTypeServiceInfo(); 
+    CleanupStack::PushL(self); 
+    self->ConstructL();
+    return self;    
+    }
+
+EXPORT_C CMTPTypeServiceInfo::~CMTPTypeServiceInfo()
+    {   
+    iChunkFlat1.Close();
+    iChunkFlat2.Close();
+    delete iChunkString;
+    
+    delete iChunkUsedServices;
+    delete iChunkServiceDataBlock;
+    
+    delete iServicePropList;
+    delete iServiceFormatList;
+    delete iServiceMethodList;
+    delete iServiceEventList;
+    }
+
+EXPORT_C TUint32 CMTPTypeServiceInfo::NumberOfUsedServices() const
+    {
+    return iChunkUsedServices->NumElements();
+    }
+
+EXPORT_C void CMTPTypeServiceInfo::UsedServiceL( const TUint aIndex, TMTPTypeGuid& aUsedServiceGUID ) const
+    {
+    iChunkUsedServices->ElementL(aIndex, aUsedServiceGUID);
+    }
+
+EXPORT_C void CMTPTypeServiceInfo::AppendUsedServiceL( const TMTPTypeGuid& aElement )
+    {
+    iChunkUsedServices->AppendL( aElement );
+    }
+
+EXPORT_C TUint32 CMTPTypeServiceInfo::NumberOfServiceDataBlock() const
+    {
+    return iChunkServiceDataBlock->NumElements();
+    }
+
+EXPORT_C void CMTPTypeServiceInfo::SerivceDataBlockL( const TUint aIndex, TMTPTypeGuid& aGUID ) const
+    {
+    iChunkServiceDataBlock->ElementL(aIndex, aGUID);
+    }
+
+EXPORT_C void CMTPTypeServiceInfo::AppendServiceDataBlockL( const TMTPTypeGuid& aElement )
+    {
+    iChunkServiceDataBlock->AppendL( aElement );
+    }
+
+EXPORT_C TUint CMTPTypeServiceInfo::Type() const
+    {
+    return EMTPTypeServiceInfoDataset;
+    }
+
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeServiceInfo::ElementInfo(TInt aElementId) const
+    {
+    return iElementInfo[aElementId];
+    }
+
+TBool CMTPTypeServiceInfo::WriteableElementL(TInt aElementId) const
+    {
+    TBool ret(EFalse);
+    if(aElementId <= EBaseServiceID )
+        ret = ETrue;
+    
+    return ret;
+    }
+
+TBool CMTPTypeServiceInfo::ReadableElementL(TInt aElementId) const
+    {
+    TBool ret(EFalse);
+        if(aElementId <= EBaseServiceID )
+            ret = ETrue;
+        
+        return ret;
+    }
+
+CMTPTypeServiceInfo::CMTPTypeServiceInfo() : 
+    CMTPTypeCompoundBase((!KJustInTimeConstruction), EIdNumChunks), 
+    iElementInfo(iElementMetaData, ENumElements),
+    iChunkFlat1(KFlat1ChunkSize, *this),
+    iChunkFlat2(KFlat2ChunkSize, *this)
+    {
+    
+    }
+
+void CMTPTypeServiceInfo::ConstructL()
+    {
+    for (TUint i(0); (i < ENumElements); i++)
+        {
+        const TElementInfo& info(iElementInfo[i]);
+        if (ChunkCount() <= info.iChunkId)
+            {
+            MMTPType* chunk(NULL);
+            
+            switch (info.iType)
+                {
+            case EMTPTypeFlat:
+                chunk = NewFlatChunkL(info);
+                break;  
+            case EMTPTypeString:
+                iChunkString = CMTPTypeString::NewL();
+                chunk = iChunkString ;
+                break;
+            default:
+                break;
+                }
+                
+            __ASSERT_DEBUG(chunk, User::Invariant());
+            ChunkAppendL(*chunk);
+            }
+        }
+    
+    iChunkUsedServices = CMTPTypeArray::NewL(EMTPTypeAUINT128, EMTPTypeUINT128,  KMTPTypeUINT128Size );
+    ChunkAppendL( *iChunkUsedServices );
+    
+    iServicePropList = CMTPTypeServicePropertyList::NewL();
+    iServiceFormatList = CMTPTypeServiceFormatList::NewL();
+    iServiceMethodList = CMTPTypeServiceMethodList::NewL();
+    iServiceEventList = CMTPTypeServiceEventList::NewL();
+    
+    ChunkAppendL(*iServicePropList);
+    ChunkAppendL(*iServiceFormatList);
+    ChunkAppendL(*iServiceMethodList);
+    ChunkAppendL(*iServiceEventList);
+    
+    iChunkServiceDataBlock = CMTPTypeArray::NewL(EMTPTypeAUINT128, EMTPTypeUINT128,  KMTPTypeUINT128Size );
+    ChunkAppendL( *iChunkServiceDataBlock );
+    
+    }
+
+
+MMTPType* CMTPTypeServiceInfo::NewFlatChunkL(const TElementInfo& aElementInfo)
+    {
+    MMTPType* chunk(NULL);
+    if (aElementInfo.iChunkId == EIdFlat1Chunk)
+        {
+        iChunkFlat1.OpenL();
+        chunk = &iChunkFlat1;
+        }
+    else if ( aElementInfo.iChunkId == EIdFlat2Chunk )
+        {
+        iChunkFlat2.OpenL();
+        chunk = &iChunkFlat2;
+        }
+    else
+        {}
+    __ASSERT_DEBUG(chunk, User::Invariant());
+    return chunk;
+    }
+
+EXPORT_C CMTPTypeServicePropertyList& CMTPTypeServiceInfo::ServicePropList()
+    {
+    return *iServicePropList;
+    }
+
+EXPORT_C CMTPTypeServiceFormatList& CMTPTypeServiceInfo::ServiceFormatList()
+    {
+    return *iServiceFormatList;
+    }
+
+EXPORT_C CMTPTypeServiceMethodList& CMTPTypeServiceInfo::ServiceMethodList()
+    {
+    return *iServiceMethodList;
+    }
+
+EXPORT_C CMTPTypeServiceEventList& CMTPTypeServiceInfo::ServiceEventList()
+    {
+    return *iServiceEventList;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypeservicemethod.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,200 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@publishedPartner
+*/
+
+#include <mtp/tmtptypeflatbase.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/cmtptypeservicemethod.h>
+
+#include "mtpdatatypespanic.h"
+
+// Dataset constants
+
+
+const TUint CMTPTypeServiceMethodElement::KFlat1ChunkSize(18);
+const TUint CMTPTypeServiceMethodElement::KFlat2ChunkSize(2);
+
+
+const CMTPTypeCompoundBase::TElementInfo CMTPTypeServiceMethodElement::iElementMetaData[CMTPTypeServiceMethodElement::ENumElements] = 
+    {
+        {EIdFlat1Chunk,                      EMTPTypeFlat,   {EMTPTypeUINT16,    0,                  KMTPTypeUINT16Size}},   // EMTPServiceMethodCode
+        {EIdFlat1Chunk,                      EMTPTypeFlat,   {EMTPTypeUINT128,   2,                  KMTPTypeUINT128Size}},  // EMTPServiceMethodGUID
+        {EIdServiceMethodNameChunk,         EMTPTypeString, {EMTPTypeString,    KMTPNotApplicable,  KMTPNotApplicable}},    // EMTPServiceMethodName
+        {EIdFlat2Chunk,						EMTPTypeFlat,	{EMTPTypeUINT16,	0,					KMTPTypeUINT16Size}},	// EMTPServiceMethodAssocFormat        
+   };
+
+EXPORT_C CMTPTypeServiceMethodList* CMTPTypeServiceMethodList::NewL()
+    {
+    CMTPTypeServiceMethodList* self = CMTPTypeServiceMethodList::NewLC(); 
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+EXPORT_C CMTPTypeServiceMethodList* CMTPTypeServiceMethodList::NewLC()
+    {
+    CMTPTypeServiceMethodList* self = new(ELeave) CMTPTypeServiceMethodList();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+EXPORT_C CMTPTypeServiceMethodList::~CMTPTypeServiceMethodList()
+    {
+
+    }
+
+EXPORT_C void CMTPTypeServiceMethodList::AppendL(CMTPTypeServiceMethodElement* aElement)
+    {
+    CMTPTypeList::AppendL(aElement);
+    }
+
+
+
+CMTPTypeServiceMethodList::CMTPTypeServiceMethodList() :
+CMTPTypeList(EMTPTypeServiceMethodListDataset,EMTPTypeServiceMethodElementDataset)
+    {
+    }
+
+void CMTPTypeServiceMethodList::ConstructL()
+    {
+    InitListL();
+    }
+
+EXPORT_C CMTPTypeServiceMethodElement& CMTPTypeServiceMethodList::ElementL(TUint aIndex) const
+    {
+    return static_cast<CMTPTypeServiceMethodElement&>( CMTPTypeList::ElementL(aIndex) );
+    }    
+
+EXPORT_C CMTPTypeServiceMethodElement* CMTPTypeServiceMethodElement::NewL()
+    {
+    CMTPTypeServiceMethodElement* self = NewLC();
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+EXPORT_C CMTPTypeServiceMethodElement* CMTPTypeServiceMethodElement::NewLC()
+    {
+    CMTPTypeServiceMethodElement* self = new(ELeave) CMTPTypeServiceMethodElement();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+EXPORT_C CMTPTypeServiceMethodElement* CMTPTypeServiceMethodElement::NewL(const TUint16 aMethodCode,const TMTPTypeGuid& aMethodGUID,const TDesC& aMethodName,const TUint16 aMethodAssociateFormate)
+    {
+    CMTPTypeServiceMethodElement* self = NewLC( aMethodCode, aMethodGUID, aMethodName, aMethodAssociateFormate);
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+EXPORT_C CMTPTypeServiceMethodElement* CMTPTypeServiceMethodElement::NewLC(const TUint16 aMethodCode,const TMTPTypeGuid& aMethodGUID,const TDesC& aMethodName,const TUint16 aMethodAssociateFormate)
+    {
+    CMTPTypeServiceMethodElement* self = new (ELeave) CMTPTypeServiceMethodElement(); 
+	CleanupStack::PushL(self); 
+    self->ConstructL(aMethodCode, aMethodGUID, aMethodName, aMethodAssociateFormate);
+	return self;    
+    }
+
+/**
+Destructor.
+*/    
+EXPORT_C CMTPTypeServiceMethodElement::~CMTPTypeServiceMethodElement()
+    {    
+    iChunkFlat1.Close();
+    iChunkFlat2.Close();
+    delete iChunkString;
+    }
+
+EXPORT_C TUint CMTPTypeServiceMethodElement::Type() const
+    {
+    return EMTPTypeServiceMethodElementDataset;
+    }
+
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeServiceMethodElement::ElementInfo(TInt aElementId) const
+    {
+    return iElementInfo[aElementId];
+    }
+
+CMTPTypeServiceMethodElement::CMTPTypeServiceMethodElement() : 
+    CMTPTypeCompoundBase((!KJustInTimeConstruction), EIdNumChunks), 
+    iElementInfo(iElementMetaData, ENumElements),
+    iChunkFlat1(KFlat1ChunkSize, *this),
+    iChunkFlat2(KFlat2ChunkSize, *this)
+    {
+    
+    }
+
+void CMTPTypeServiceMethodElement::ConstructL()
+    {
+    for (TUint i(0); (i < ENumElements); i++)
+        {
+        const TElementInfo& info(iElementInfo[i]);
+        if (ChunkCount() <= info.iChunkId)
+            {
+            MMTPType* chunk(NULL);
+            
+            switch (info.iType)
+                {
+            case EMTPTypeFlat:
+            	chunk = NewFlatChunkL(info);
+            	break;  
+            case EMTPTypeString:
+            	iChunkString = CMTPTypeString::NewL();
+            	chunk = iChunkString ;
+                break;
+            default:
+                break;
+                }
+                
+            __ASSERT_DEBUG(chunk, User::Invariant());
+            ChunkAppendL(*chunk);
+            }
+        }
+    }
+
+MMTPType* CMTPTypeServiceMethodElement::NewFlatChunkL(const TElementInfo& aElementInfo)
+    {
+    MMTPType* chunk(NULL);
+    if (aElementInfo.iChunkId == EIdFlat1Chunk)
+        {
+        iChunkFlat1.OpenL();
+        chunk = &iChunkFlat1;
+        }
+    else if ( aElementInfo.iChunkId == EIdFlat2Chunk )
+    	{
+    	iChunkFlat2.OpenL();
+    	chunk = &iChunkFlat2;
+    	}
+    else
+    	{}
+    __ASSERT_DEBUG(chunk, User::Invariant());
+    return chunk;
+    }
+
+void CMTPTypeServiceMethodElement::ConstructL(const TUint16 aMethodCode,const TMTPTypeGuid& aMethodGUID,const TDesC& aMethodName,const TUint16 aMethodAssociateFormate)
+    {
+
+    ConstructL();
+
+    // Set mandatory construction values.
+    SetUint16L(EMethodCode, aMethodCode);
+    SetL(EMethodGUID, aMethodGUID);
+    SetStringL(EMethodName,aMethodName);
+    SetUint16L(EMethodAssociateFormate,aMethodAssociateFormate);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypeservicemethodparamextnform.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,358 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// 
+
+/**
+@file
+@internalComponent
+*/
+
+#include <mtp/cmtptypeservicemethodparamextnform.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/cmtptypestring.h>
+
+#include "mtpdatatypespanic.h"
+
+// Dataset constants
+const TUint CMTPTypeServiceMethodParamExtnForm::KFlat1ChunkSize(20);
+const TUint CMTPTypeServiceMethodParamExtnForm::KFlat2ChunkSize(3);
+const TUint CMTPTypeServiceMethodParamExtnForm::KNumChunksWithoutForm(EIdFlat2Chunk + 1);
+const TUint CMTPTypeServiceMethodParamExtnForm::KNumChunksWithForm(EIdFormChunk + 1);
+
+//Dataset element metadata    
+const CMTPTypeCompoundBase::TElementInfo CMTPTypeServiceMethodParamExtnForm::iElementMetaData[CMTPTypeServiceMethodParamExtnForm::ENumElements] = 
+    {
+        {EIdFlat1Chunk,       EMTPTypeFlat,       {EMTPTypeUINT128,    0,                 KMTPTypeUINT128Size}},   // EPKNamespace
+        {EIdFlat1Chunk,       EMTPTypeFlat,       {EMTPTypeUINT32,    16,                 KMTPTypeUINT32Size}},    // EPKeyID
+        {EIdNameChunk,        EMTPTypeString,     {EMTPTypeString,  KMTPNotApplicable,    KMTPNotApplicable}},     // EPropertyName
+        {EIdFlat2Chunk,       EMTPTypeFlat,       {EMTPTypeUINT8,     0,                  KMTPTypeUINT8Size}},     // EParameterType
+        {EIdFlat2Chunk,       EMTPTypeFlat,       {EMTPTypeUINT8,     1,                  KMTPTypeUINT8Size}},     // EParameterNumber
+        {EIdFlat2Chunk,       EMTPTypeFlat,       {EMTPTypeUINT8,     2,                  KMTPTypeUINT8Size}},     // EFormFlag
+        {EIdFormChunk,        EMTPTypeReference,  {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}},     // EForm
+    };
+
+
+/**
+MTP Service Method Parameter Extension FORM dataset factory method. This method is used to 
+create an empty MTP Service Method Parameter Extension FORM  of the specified Datatype. 
+@param aDataType The data type identifier datacode of the object property.
+@return A pointer to the form type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C  CMTPTypeServiceMethodParamExtnForm* CMTPTypeServiceMethodParamExtnForm::NewL( const TUint aDataType )
+    {
+    CMTPTypeServiceMethodParamExtnForm* self = CMTPTypeServiceMethodParamExtnForm::NewLC( aDataType );
+    CleanupStack::Pop(self); 
+    return self;
+    }
+/**
+MTP DevicePropDesc  Service Method Parameter Extension FORM  factory method. This method is used to 
+create an empty MTP Service Method Parameter Extension FORM  of the specified Datatype. 
+@param aDataType The data type identifier datacode of the the object property.
+@return A pointer to the form type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/
+EXPORT_C  CMTPTypeServiceMethodParamExtnForm* CMTPTypeServiceMethodParamExtnForm::NewLC( const TUint aDataType )
+    {
+    CMTPTypeServiceMethodParamExtnForm* self = new(ELeave) CMTPTypeServiceMethodParamExtnForm( aDataType );
+    CleanupStack::PushL(self);
+    
+    TMTPTypeGuid KUndefinedNamespace(0,0);
+    TUint KPKeyID(0);
+    TUint KParamNum(0);
+    TBuf<1> KName;
+    self->ConstructL( KUndefinedNamespace, KPKeyID, KName, EResserved, KParamNum, CMTPTypeObjectPropDesc::ENone, NULL );
+    return self;
+    }
+
+   
+EXPORT_C  CMTPTypeServiceMethodParamExtnForm* CMTPTypeServiceMethodParamExtnForm::NewL( const TUint aDataType, const TMTPTypeGuid  aPKNamespace, const TUint aPKID, const TDesC& aName, const TUint8 aParamType, const TUint8 aParamNum, const TUint8 aFormFlag, const MMTPType* aForm)
+    {
+    CMTPTypeServiceMethodParamExtnForm* self = CMTPTypeServiceMethodParamExtnForm::NewLC( aDataType, aPKNamespace, aPKID, aName, aParamType, aParamNum, aFormFlag, aForm );
+    CleanupStack::Pop(self); 
+    return self;
+    }
+   
+  
+EXPORT_C  CMTPTypeServiceMethodParamExtnForm* CMTPTypeServiceMethodParamExtnForm::NewLC( const TUint aDataType, const TMTPTypeGuid  aPKNamespace, const TUint aPKID, const TDesC& aName, const TUint8 aParamType, const TUint8 aParamNum, const TUint8 aFormFlag, const MMTPType* aForm)
+    {
+    CMTPTypeServiceMethodParamExtnForm* self = new(ELeave) CMTPTypeServiceMethodParamExtnForm(aDataType);
+    CleanupStack::PushL(self);
+    self->ConstructL( aPKNamespace, aPKID, aName, aParamType, aParamNum, aFormFlag, aForm );
+    return self;
+    }
+
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPTypeServiceMethodParamExtnForm::~CMTPTypeServiceMethodParamExtnForm()
+    {
+    iChunkFlat1.Close();
+    delete iChunkName;
+    iChunkFlat2.Close();
+    iChunkForm.Close();
+    }
+
+CMTPTypeServiceMethodParamExtnForm::CMTPTypeServiceMethodParamExtnForm(const TUint aDataType) : 
+    CMTPTypeCompoundBase((KJustInTimeConstruction), KNumChunksWithoutForm),
+    iElementInfo(iElementMetaData, ENumElements),
+    iChunkFlat1(KFlat1ChunkSize, *this),
+    iChunkFlat2(KFlat2ChunkSize, *this),
+    iDataType(aDataType),
+    iInitialised(EFalse)
+    {
+
+    }
+
+EXPORT_C TUint CMTPTypeServiceMethodParamExtnForm::Type() const
+    {
+    return EMTPTypeServiceObjPropExtnFormDataset;
+    } 
+
+EXPORT_C TInt CMTPTypeServiceMethodParamExtnForm::FirstWriteChunk(TPtr8& aChunk)
+    {
+    /* 
+    Reset the type in preparation for the data stream, by deleting all
+    except the first chunk.
+    */
+    for (TUint i(ChunkCount() - 1); i > EIdFlat1Chunk ; i--)
+      {
+      ChunkRemove(i);
+      }
+      
+    // Setup the write chunk pointer.
+    TInt err(UpdateWriteSequenceErr(CMTPTypeCompoundBase::FirstWriteChunk(aChunk)));
+    switch (err)
+      {
+    case KMTPChunkSequenceCompletion:
+      err = KErrNone;
+      // Don't break, fall through to set the write sequence state.
+      
+    case KErrNone:
+      // Set the write sequence state.
+      iWriteSequenceState = EFlat1Chunk; 
+      
+      /* 
+      Set the write sequence completion state. Initially assume that the 
+      extension form has a FORM field. If no FORM field is subsequently
+      detected in the write data stream then the completion state is 
+      adjusted accordingly.
+      */
+      iWriteSequenceCompletionState = EFormChunk;
+      break;
+      
+    default:
+      break;
+      }
+      
+    return  err;
+    }
+
+EXPORT_C TInt CMTPTypeServiceMethodParamExtnForm::NextWriteChunk(TPtr8& aChunk)
+    {
+    TInt err(KMTPChunkSequenceCompletion);
+     
+     if (iWriteSequenceState != EIdle)
+         {
+         err = UpdateWriteSequenceErr(CMTPTypeCompoundBase::NextWriteChunk(aChunk));
+         if ((iWriteSequenceErr == KMTPChunkSequenceCompletion) && (iWriteSequenceState != EIdle))
+             {
+             err = KErrNone;
+             }   
+         }    
+     return err;
+    }
+
+EXPORT_C TBool CMTPTypeServiceMethodParamExtnForm::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* CMTPTypeServiceMethodParamExtnForm::CommitChunkL(TPtr8& aChunk)
+    {
+    if (iWriteSequenceErr == KMTPChunkSequenceCompletion)
+        {
+        switch (iWriteSequenceState)
+            {
+        case EFlat1Chunk:     
+            iChunkName = CMTPTypeString::NewL();
+            ChunkAppendL(*iChunkName);
+            break;
+            
+        case ENameChunk:
+            ChunkAppendL(iChunkFlat2);
+            break;
+            
+        case EFlat2Chunk: 
+            {
+            iChunkForm.Close();
+            TUint8 flag(Uint8L(EFormFlag));
+            iChunkForm.SetMeta(flag, iDataType);
+            if (HasFormField(flag))
+                {
+                iChunkForm.OpenL(iElementInfo[EForm].iType);
+                ChunkAppendL(iChunkForm);
+                SetExpectedChunkCount(KNumChunksWithForm);
+                }
+            else
+                {
+                // Adjust the write sequence completion state.            
+                iWriteSequenceCompletionState = EFlat2Chunk;
+                }   
+            }
+            break;
+            
+        case EFormChunk:
+        case EIdle:
+        default:
+            break;
+            }
+        
+    if ( (iWriteSequenceState != EIdle ) && (iWriteSequenceState < iWriteSequenceCompletionState) )
+        {
+        iWriteSequenceState++;
+        }
+    else
+        {
+        iWriteSequenceState = EIdle;
+        }
+    }
+        
+    if (CMTPTypeCompoundBase::CommitRequired())
+        {
+        CMTPTypeCompoundBase::CommitChunkL(aChunk);
+        }
+    return NULL;
+    }
+
+TBool CMTPTypeServiceMethodParamExtnForm::HasFormField(TUint8 aFormFlag) const
+    {
+    return ((aFormFlag != CMTPTypeObjectPropDesc::EDateTimeForm) && (aFormFlag != CMTPTypeObjectPropDesc::ENone) && (aFormFlag != CMTPTypeObjectPropDesc::EObjectIDForm) );
+    }
+
+TInt CMTPTypeServiceMethodParamExtnForm::UpdateWriteSequenceErr(TInt aErr)
+    {
+    iWriteSequenceErr = aErr;
+    return iWriteSequenceErr;        
+    }
+
+TBool CMTPTypeServiceMethodParamExtnForm::ReadableElementL(TInt aElementId) const
+    {
+    __ASSERT_ALWAYS((aElementId < ENumElements), Panic(EMTPTypeBoundsError));
+    
+    TBool ret(ETrue);
+    if (aElementId == EForm)
+        {
+        ret = HasFormField(Uint8L(EFormFlag));
+        }
+    return ret;
+    }
+    
+TBool CMTPTypeServiceMethodParamExtnForm::WriteableElementL( TInt aElementId ) const
+    {   
+    __ASSERT_ALWAYS((aElementId < ENumElements), Panic(EMTPTypeBoundsError));
+    
+    if (!iInitialised)
+        {
+        return ETrue;    
+        }
+    
+    if (aElementId == EForm)
+        return EFalse;
+    
+    return ETrue;
+    }
+
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeServiceMethodParamExtnForm::ElementInfo(TInt aElementId) const
+    {
+    __ASSERT_ALWAYS((aElementId < ENumElements), Panic(EMTPTypeBoundsError));
+    
+    return iElementInfo[aElementId];  
+    }
+
+        
+void CMTPTypeServiceMethodParamExtnForm::ConstructL( const TMTPTypeGuid  aPKNamespace, const TUint aPKID, const TDesC& aName, const TUint8 aParamType, const TUint8 aParamNum, const TUint8 aFormFlag, const MMTPType* aForm )
+    {  
+    for (TUint i(0); (i < ENumElements); i++)
+       {
+       const TElementInfo& element(iElementInfo[i]);
+       if (ChunkCount() <= element.iChunkId)
+           {
+           MMTPType* chunk(NULL);
+           switch (element.iChunkId)
+               {
+           case EIdFlat1Chunk:
+               iChunkFlat1.OpenL();
+               chunk = &iChunkFlat1;
+               break;
+               
+           case EIdNameChunk:
+               iChunkName = CMTPTypeString::NewL();
+               chunk = iChunkName;
+               break;
+               
+           case EIdFlat2Chunk:
+               iChunkFlat2.OpenL();
+               chunk = &iChunkFlat2;
+               break;
+               
+           case EIdFormChunk:
+               iChunkForm.SetMeta(aFormFlag, iDataType);
+               if (HasFormField(aFormFlag))
+                   {
+                   iChunkForm.OpenL(element.iType);
+                   chunk = &iChunkForm;
+                   SetExpectedChunkCount(KNumChunksWithForm);
+                   }
+               break;
+               
+           default:
+               Panic(EMTPTypeBoundsError);
+               break;
+               }
+                   
+           // Some chunks (i.e. FORM) are optional.
+           if (chunk)
+               {
+               ChunkAppendL(*chunk);   
+               }
+           }
+       }
+       
+    // Set the construction values.
+    SetL( EPKeyNamespace, aPKNamespace );
+    SetUint32L( EPKeyID, aPKID );
+    SetStringL( EPropertyName, aName );
+    SetUint8L(EParameterType, aParamType);
+    SetUint8L(EParameterNumber, aParamNum);
+    SetUint8L(EFormFlag, aFormFlag);
+    
+    if (aForm)
+        {
+        if (!HasFormField(aFormFlag))
+            { 
+            User::Leave(KMTPDataTypeInvalid);
+            } 
+        else
+            {
+            SetL(EForm, *aForm); 
+            }
+        }
+    
+    iInitialised = ETrue;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypeserviceobjpropextnform.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,353 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// 
+
+/**
+@file
+@internalComponent
+*/
+
+#include <mtp/cmtptypeserviceobjpropextnform.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/cmtptypestring.h>
+
+#include "mtpdatatypespanic.h"
+
+// Dataset constants
+const TUint CMTPTypeServiceObjPropExtnForm::KFlat1ChunkSize(20);
+const TUint CMTPTypeServiceObjPropExtnForm::KFlat2ChunkSize(1);
+const TUint CMTPTypeServiceObjPropExtnForm::KNumChunksWithoutForm(EIdFlat2Chunk + 1);
+const TUint CMTPTypeServiceObjPropExtnForm::KNumChunksWithForm(EIdFormChunk + 1);
+
+//Dataset element metadata    
+const CMTPTypeCompoundBase::TElementInfo CMTPTypeServiceObjPropExtnForm::iElementMetaData[CMTPTypeServiceObjPropExtnForm::ENumElements] = 
+    {
+        {EIdFlat1Chunk,       EMTPTypeFlat,       {EMTPTypeUINT128,    0,                 KMTPTypeUINT128Size}},   // EPKNamespace
+        {EIdFlat1Chunk,       EMTPTypeFlat,       {EMTPTypeUINT32,    16,                 KMTPTypeUINT32Size}},    // EPKeyID
+        {EIdNameChunk,        EMTPTypeString,     {EMTPTypeString, KMTPNotApplicable,     KMTPNotApplicable}},     // EPropertyName
+        {EIdFlat2Chunk,       EMTPTypeFlat,       {EMTPTypeUINT8,     0,                  KMTPTypeUINT8Size}},     // EFormFlag
+        {EIdFormChunk,        EMTPTypeReference,  {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}},     // EForm
+    };
+
+
+/**
+MTP Service Object Property Extension FORM dataset factory method. This method is used to 
+create an empty MTP Service Object Property Extension FORM  of the specified Datatype. 
+@param aDataType The data type identifier datacode of the object property.
+@return A pointer to the form type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C  CMTPTypeServiceObjPropExtnForm* CMTPTypeServiceObjPropExtnForm::NewL( const TUint aDataType )
+    {
+    CMTPTypeServiceObjPropExtnForm* self = CMTPTypeServiceObjPropExtnForm::NewLC( aDataType );
+    CleanupStack::Pop(self); 
+    return self;
+    }
+/**
+MTP DevicePropDesc  Service Object Property Extension FORM  factory method. This method is used to 
+create an empty MTP Service Object Property Extension FORM  of the specified Datatype. 
+@param aDataType The data type identifier datacode of the the object property.
+@return A pointer to the form type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/
+EXPORT_C  CMTPTypeServiceObjPropExtnForm* CMTPTypeServiceObjPropExtnForm::NewLC( const TUint aDataType )
+    {
+    CMTPTypeServiceObjPropExtnForm* self = new(ELeave) CMTPTypeServiceObjPropExtnForm( aDataType );
+    CleanupStack::PushL(self);
+    TMTPTypeGuid KUndefinedNamespace(0,0);
+    TUint KPKeyID(0);
+    TBuf<1> KName;
+    self->ConstructL( KUndefinedNamespace, KPKeyID, KName, CMTPTypeObjectPropDesc::ENone, NULL );
+    
+    return self;
+    }
+
+   
+EXPORT_C  CMTPTypeServiceObjPropExtnForm* CMTPTypeServiceObjPropExtnForm::NewL( const TUint aDataType, const TMTPTypeGuid  aPKNamespace, const TUint aPKID, const TDesC& aName, const TUint8 aFormFlag, const MMTPType* aForm)
+    {
+    CMTPTypeServiceObjPropExtnForm* self = CMTPTypeServiceObjPropExtnForm::NewLC( aDataType, aPKNamespace, aPKID, aName, aFormFlag, aForm );
+    CleanupStack::Pop(self); 
+    return self;
+    }
+   
+  
+EXPORT_C  CMTPTypeServiceObjPropExtnForm* CMTPTypeServiceObjPropExtnForm::NewLC( const TUint aDataType, const TMTPTypeGuid  aPKNamespace, const TUint aPKID, const TDesC& aName, const TUint8 aFormFlag, const MMTPType* aForm)
+    {
+    CMTPTypeServiceObjPropExtnForm* self = new(ELeave) CMTPTypeServiceObjPropExtnForm(aDataType);
+    CleanupStack::PushL(self);
+    self->ConstructL( aPKNamespace, aPKID, aName, aFormFlag, aForm );
+    return self;
+    }
+
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPTypeServiceObjPropExtnForm::~CMTPTypeServiceObjPropExtnForm()
+    {
+    iChunkFlat1.Close();
+    delete iChunkName;
+    iChunkFlat2.Close();
+    iChunkForm.Close();
+    }
+
+CMTPTypeServiceObjPropExtnForm::CMTPTypeServiceObjPropExtnForm(const TUint aDataType) : 
+    CMTPTypeCompoundBase((KJustInTimeConstruction), KNumChunksWithoutForm),
+    iElementInfo(iElementMetaData, ENumElements),
+    iChunkFlat1(KFlat1ChunkSize, *this),
+    iChunkFlat2(KFlat2ChunkSize, *this),
+    iDataType(aDataType),
+    iInitialised(EFalse)
+    {
+
+    }
+
+EXPORT_C TUint CMTPTypeServiceObjPropExtnForm::Type() const
+    {
+    return EMTPTypeServiceObjPropExtnFormDataset;
+    } 
+
+
+
+EXPORT_C TInt CMTPTypeServiceObjPropExtnForm::FirstWriteChunk(TPtr8& aChunk)
+    {
+    /* 
+    Reset the type in preparation for the data stream, by deleting all
+    except the first chunk.
+    */
+    for (TUint i(ChunkCount() - 1); i > EIdFlat1Chunk ; i--)
+      {
+      ChunkRemove(i);
+      }
+      
+    // Setup the write chunk pointer.
+    TInt err(UpdateWriteSequenceErr(CMTPTypeCompoundBase::FirstWriteChunk(aChunk)));
+    switch (err)
+      {
+    case KMTPChunkSequenceCompletion:
+      err = KErrNone;
+      // Don't break, fall through to set the write sequence state.
+      
+    case KErrNone:
+      // Set the write sequence state.
+      iWriteSequenceState = EFlat1Chunk; 
+      
+      /* 
+      Set the write sequence completion state. Initially assume that the 
+      extension form has a FORM field. If no FORM field is subsequently
+      detected in the write data stream then the completion state is 
+      adjusted accordingly.
+      */
+      iWriteSequenceCompletionState = EFormChunk;
+      break;
+      
+    default:
+      break;
+      }
+      
+    return  err;
+    }
+
+EXPORT_C TInt CMTPTypeServiceObjPropExtnForm::NextWriteChunk(TPtr8& aChunk)
+    {
+    TInt err(KMTPChunkSequenceCompletion);
+     
+     if (iWriteSequenceState != EIdle)
+         {
+         err = UpdateWriteSequenceErr(CMTPTypeCompoundBase::NextWriteChunk(aChunk));
+         if ((iWriteSequenceErr == KMTPChunkSequenceCompletion) && (iWriteSequenceState != EIdle))
+             {
+             err = KErrNone;
+             }   
+         }    
+     return err;
+    }
+
+EXPORT_C TBool CMTPTypeServiceObjPropExtnForm::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* CMTPTypeServiceObjPropExtnForm::CommitChunkL(TPtr8& aChunk)
+    {
+    if (iWriteSequenceErr == KMTPChunkSequenceCompletion)
+        {
+        switch (iWriteSequenceState)
+            {
+        case EFlat1Chunk:     
+            delete iChunkName;
+            iChunkName = CMTPTypeString::NewL();
+            ChunkAppendL(*iChunkName);
+            break;
+            
+        case ENameChunk:
+            ChunkAppendL(iChunkFlat2);
+            break;
+            
+        case EFlat2Chunk: 
+            {
+            iChunkForm.Close();
+            TUint8 flag(Uint8L(EFormFlag));
+            iChunkForm.SetMeta(flag, iDataType);
+            if (HasFormField(flag))
+                {
+                iChunkForm.OpenL(iElementInfo[EForm].iType);
+                ChunkAppendL(iChunkForm);
+                SetExpectedChunkCount(KNumChunksWithForm);
+                }
+            else
+                {
+                // Adjust the write sequence completion state.            
+                iWriteSequenceCompletionState = EFlat2Chunk;
+                }   
+            }
+            break;
+            
+        case EFormChunk:
+        case EIdle:
+        default:
+            break;
+            }
+        
+    if ( (iWriteSequenceState != EIdle ) && (iWriteSequenceState < iWriteSequenceCompletionState) )
+        {
+        iWriteSequenceState++;
+        }
+    else
+        {
+        iWriteSequenceState = EIdle;
+        }
+    }
+        
+    if (CMTPTypeCompoundBase::CommitRequired())
+        {
+        CMTPTypeCompoundBase::CommitChunkL(aChunk);
+        }
+    return NULL;
+    }
+
+TBool CMTPTypeServiceObjPropExtnForm::HasFormField(TUint8 aFormFlag) const
+    {
+    return ((aFormFlag != CMTPTypeObjectPropDesc::EDateTimeForm) && (aFormFlag != CMTPTypeObjectPropDesc::ENone) && (aFormFlag != CMTPTypeObjectPropDesc::EObjectIDForm) );
+    }
+
+TInt CMTPTypeServiceObjPropExtnForm::UpdateWriteSequenceErr(TInt aErr)
+    {
+    iWriteSequenceErr = aErr;
+    return iWriteSequenceErr;        
+    }
+
+TBool CMTPTypeServiceObjPropExtnForm::ReadableElementL(TInt aElementId) const
+    {
+    __ASSERT_ALWAYS((aElementId < ENumElements), Panic(EMTPTypeBoundsError));
+    
+    TBool ret(ETrue);
+    if (aElementId == EForm)
+        {
+        ret = HasFormField(Uint8L(EFormFlag));
+        }
+    return ret;
+    }
+    
+TBool CMTPTypeServiceObjPropExtnForm::WriteableElementL(TInt aElementId) const
+    {  
+    __ASSERT_ALWAYS((aElementId < ENumElements), Panic(EMTPTypeBoundsError));
+    
+    if (!iInitialised)
+        {
+        return ETrue;    
+        }
+    
+    if (aElementId == EForm)
+        return EFalse;
+    
+    return ETrue;
+    }
+
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeServiceObjPropExtnForm::ElementInfo(TInt aElementId) const
+    {
+    __ASSERT_ALWAYS((aElementId < ENumElements), Panic(EMTPTypeBoundsError));
+    
+    return iElementInfo[aElementId];  
+    }   
+
+void CMTPTypeServiceObjPropExtnForm::ConstructL( const TMTPTypeGuid  aPKNamespace, const TUint aPKID, const TDesC& aName, const TUint8 aFormFlag, const MMTPType* aForm )
+    {  
+    for (TUint i(0); (i < ENumElements); i++)
+       {
+       const TElementInfo& element(iElementInfo[i]);
+       if (ChunkCount() <= element.iChunkId)
+           {
+           MMTPType* chunk(NULL);
+           switch (element.iChunkId)
+               {
+           case EIdFlat1Chunk:
+               iChunkFlat1.OpenL();
+               chunk = &iChunkFlat1;
+               break;
+               
+           case EIdNameChunk:
+               iChunkName = CMTPTypeString::NewL();
+               chunk = iChunkName;
+               break;
+               
+           case EIdFlat2Chunk:
+               iChunkFlat2.OpenL();
+               chunk = &iChunkFlat2;
+               break;
+               
+           case EIdFormChunk:
+               iChunkForm.SetMeta(aFormFlag, iDataType);
+               if (HasFormField(aFormFlag))
+                   {
+                   iChunkForm.OpenL(element.iType);
+                   chunk = &iChunkForm;
+                   SetExpectedChunkCount(KNumChunksWithForm);
+                   }
+               break;
+               
+           default:
+               Panic(EMTPTypeBoundsError);
+               break;
+               }
+                   
+           if (chunk)
+               {
+               ChunkAppendL(*chunk);   
+               }
+           }
+       }      
+    // Set the construction values.
+    SetL( EPKeyNamespace, aPKNamespace );
+    SetUint32L( EPKeyID, aPKID );
+    SetStringL( EPropertyName, aName );
+    SetUint8L(EFormFlag, aFormFlag);
+    
+    if (aForm)
+        {
+        if (!HasFormField(aFormFlag))
+            { 
+            User::Leave(KMTPDataTypeInvalid);
+            } 
+        else
+            {
+            SetL(EForm, *aForm); 
+            }
+        }
+    
+    iInitialised = ETrue;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypeserviceprop.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,190 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// 
+
+/**
+@file
+@publishedPartner
+*/
+
+#include <mtp/tmtptypeflatbase.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/cmtptypeserviceprop.h>
+
+#include "mtpdatatypespanic.h"
+
+// Dataset constants
+
+
+const TUint KMTPChunk0Size = 22;
+
+
+const CMTPTypeCompoundBase::TElementInfo CMTPTypeServicePropertyElement::iElementMetaData[CMTPTypeServicePropertyElement::ENumElements] = 
+    {
+        {EIdFlatChunk,                      EMTPTypeFlat,   {EMTPTypeUINT16,    0,                  KMTPTypeUINT16Size}},   // EMTPServicePropCode
+        {EIdFlatChunk,                      EMTPTypeFlat,   {EMTPTypeUINT128,   2,                  KMTPTypeUINT128Size}},  // EMTPServicePropNamespace
+        {EIdFlatChunk,						EMTPTypeFlat,	{EMTPTypeUINT32,	18,					KMTPTypeUINT32Size}},	// EMTPServicePropPKID
+        {EIdServicePropNameChunk,         	EMTPTypeString, {EMTPTypeString,    KMTPNotApplicable,  KMTPNotApplicable}},    // EMTPServicePropName
+   };
+
+EXPORT_C CMTPTypeServicePropertyList* CMTPTypeServicePropertyList::NewL()
+    {
+    CMTPTypeServicePropertyList* self = CMTPTypeServicePropertyList::NewLC(); 
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+EXPORT_C CMTPTypeServicePropertyList* CMTPTypeServicePropertyList::NewLC()
+    {
+    CMTPTypeServicePropertyList* self = new(ELeave) CMTPTypeServicePropertyList();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+EXPORT_C CMTPTypeServicePropertyList::~CMTPTypeServicePropertyList()
+    {
+
+    }
+
+EXPORT_C void CMTPTypeServicePropertyList::AppendL(CMTPTypeServicePropertyElement* aElement)
+    {
+    CMTPTypeList::AppendL(aElement);
+    }
+
+CMTPTypeServicePropertyList::CMTPTypeServicePropertyList() :
+CMTPTypeList(EMTPTypeServicePropertyListDataset,EMTPTypeServicePropertyElementDataset)
+    {
+    }
+
+void CMTPTypeServicePropertyList::ConstructL()
+    {
+    InitListL();
+    }
+
+EXPORT_C CMTPTypeServicePropertyElement& CMTPTypeServicePropertyList::ElementL(TUint aIndex) const
+    {
+    return static_cast<CMTPTypeServicePropertyElement&>( CMTPTypeList::ElementL(aIndex) );
+    }   
+
+EXPORT_C CMTPTypeServicePropertyElement* CMTPTypeServicePropertyElement::NewL()
+    {
+    CMTPTypeServicePropertyElement* self = NewLC();
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+EXPORT_C CMTPTypeServicePropertyElement* CMTPTypeServicePropertyElement::NewLC()
+    {
+    CMTPTypeServicePropertyElement* self = new(ELeave) CMTPTypeServicePropertyElement();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+EXPORT_C CMTPTypeServicePropertyElement* CMTPTypeServicePropertyElement::NewL(const TUint16 aPropertyCode, const TMTPTypeGuid& aNameSpace,const TUint32 aPKeyID, const TDesC& aPropertyName)
+    {
+    CMTPTypeServicePropertyElement* self = NewLC(aPropertyCode, aNameSpace,aPKeyID, aPropertyName);
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+EXPORT_C CMTPTypeServicePropertyElement* CMTPTypeServicePropertyElement::NewLC(const TUint16 aPropertyCode, const TMTPTypeGuid& aNameSpace,const TUint32 aPKeyID, const TDesC& aPropertyName)
+    {
+    CMTPTypeServicePropertyElement* self = new (ELeave) CMTPTypeServicePropertyElement(); 
+	CleanupStack::PushL(self); 
+    self->ConstructL(aPropertyCode, aNameSpace,aPKeyID, aPropertyName);
+	return self;    
+    }
+
+/**
+Destructor.
+*/    
+EXPORT_C CMTPTypeServicePropertyElement::~CMTPTypeServicePropertyElement()
+    {    
+    iChunkFlat.Close();
+    delete iChunkString;
+    }
+
+EXPORT_C TUint CMTPTypeServicePropertyElement::Type() const
+    {
+    return EMTPTypeServicePropertyElementDataset;
+    }
+
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeServicePropertyElement::ElementInfo(TInt aElementId) const
+    {
+    return iElementInfo[aElementId];
+    }
+
+CMTPTypeServicePropertyElement::CMTPTypeServicePropertyElement() : 
+    CMTPTypeCompoundBase((KJustInTimeConstruction), EIdNumChunks), 
+    iElementInfo(iElementMetaData, ENumElements),
+    iChunkFlat(KMTPChunk0Size, *this)
+    {
+    
+    }
+
+void CMTPTypeServicePropertyElement::ConstructL()
+    {
+    for (TUint i(0); (i < ENumElements); i++)
+        {
+        const TElementInfo& info(iElementInfo[i]);
+        if (ChunkCount() <= info.iChunkId)
+            {
+            MMTPType* chunk(NULL);
+            
+            switch (info.iType)
+                {
+            	case EMTPTypeFlat:
+            		chunk = NewFlatChunkL();
+            	break;  
+            	case EMTPTypeString:
+            		 iChunkString = CMTPTypeString::NewL();
+            		 chunk = iChunkString ;
+                break;
+            	default:
+                break;
+                }    
+                __ASSERT_DEBUG(chunk, User::Invariant());
+                ChunkAppendL(*chunk);
+                
+            }
+        }
+    }
+
+
+MMTPType* CMTPTypeServicePropertyElement::NewFlatChunkL()
+    {
+    MMTPType* chunk(NULL);
+
+    iChunkFlat.OpenL();
+    chunk = &iChunkFlat;
+
+    __ASSERT_DEBUG(chunk, User::Invariant());
+    return chunk;
+    }
+
+void CMTPTypeServicePropertyElement::ConstructL(const TUint16 aPropertyCode, const TMTPTypeGuid& aNameSpace,const TUint32 aPKeyID, const TDesC& aPropertyName)
+    {
+
+    ConstructL();
+
+    // Set mandatory construction values.
+    SetUint16L(EPropertyCode, aPropertyCode);
+    SetL(ENameSpace, aNameSpace);
+
+    SetUint32L(EPkeyID,aPKeyID);
+    SetStringL(EPorpertyName,aPropertyName);
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypeservicepropdesclist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,324 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// 
+
+/**
+@file
+@internalComponent
+*/
+
+#include <mtp/cmtptypeservicepropdesclist.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mtpprotocolconstants.h>
+
+#include "mtpdatatypespanic.h"
+
+// Dataset constants
+
+const TUint CMTPTypeServicePropDesc::KFlat1ChunkSize(6);
+const TUint CMTPTypeServicePropDesc::KNumChunksWithoutForm(EIdFlat1Chunk + 1);
+const TUint CMTPTypeServicePropDesc::KNumChunksWithForm(EIdFormChunk + 1);
+
+//Dataset element metadata    
+const CMTPTypeCompoundBase::TElementInfo CMTPTypeServicePropDesc::iElementMetaData[CMTPTypeServicePropDesc::ENumElements] = 
+    {
+        {EIdFlat1Chunk,       EMTPTypeFlat,       {EMTPTypeUINT16,    0,                  KMTPTypeUINT16Size}},   // EServicePropertyCode
+        {EIdFlat1Chunk,       EMTPTypeFlat,       {EMTPTypeUINT16,    2,                  KMTPTypeUINT16Size}},   // EDataType1
+        {EIdFlat1Chunk,       EMTPTypeFlat,       {EMTPTypeUINT8,     4,                  KMTPTypeUINT8Size}},   // EGetSet1
+        {EIdFlat1Chunk,       EMTPTypeFlat,       {EMTPTypeUINT8,     5,                  KMTPTypeUINT8Size}},    // EFormFlag
+        {EIdFormChunk,        EMTPTypeReference,  {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}},    // EForm
+    };
+
+
+
+EXPORT_C CMTPTypeServicePropDescList* CMTPTypeServicePropDescList::NewL()
+    {
+    CMTPTypeServicePropDescList* self = CMTPTypeServicePropDescList::NewLC(); 
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+
+EXPORT_C CMTPTypeServicePropDescList* CMTPTypeServicePropDescList::NewLC()
+    {
+    CMTPTypeServicePropDescList* self = new(ELeave) CMTPTypeServicePropDescList();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPTypeServicePropDescList::~CMTPTypeServicePropDescList()
+    {
+    
+    }
+
+CMTPTypeServicePropDescList::CMTPTypeServicePropDescList() :
+CMTPTypeList(EMTPTypeServicePropDescList,EMTPTypeServicePropDesc)
+    {
+    }
+
+void CMTPTypeServicePropDescList::ConstructL()
+    {
+    InitListL();
+    }
+
+EXPORT_C void CMTPTypeServicePropDescList::AppendL(CMTPTypeServicePropDesc* aElement)
+    {
+    CMTPTypeList::AppendL(aElement);
+    }
+
+EXPORT_C CMTPTypeServicePropDesc& CMTPTypeServicePropDescList::ElementL(TUint aIndex) const
+    {
+    return static_cast<CMTPTypeServicePropDesc&>( CMTPTypeList::ElementL(aIndex) );
+    }
+
+/**
+MTP Service Object Property Extension FORM dataset factory method. This method is used to 
+create an empty MTP Service Object Property Extension FORM  of the specified Datatype. 
+@return A pointer to the form type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C  CMTPTypeServicePropDesc* CMTPTypeServicePropDesc::NewL()
+    {
+    CMTPTypeServicePropDesc* self = CMTPTypeServicePropDesc::NewLC();
+    CleanupStack::Pop(self); 
+    return self;
+    }
+/**
+MTP DevicePropDesc  Service Object Property Extension FORM  factory method. This method is used to 
+create an empty MTP Service Object Property Extension FORM  of the specified Datatype. 
+@return A pointer to the form type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/
+EXPORT_C  CMTPTypeServicePropDesc* CMTPTypeServicePropDesc::NewLC()
+    {
+    CMTPTypeServicePropDesc* self = new(ELeave) CMTPTypeServicePropDesc();
+    CleanupStack::PushL(self);
+    const TUint16 KUndefinedCode = 0; 
+    self->ConstructL( KUndefinedCode , EMTPTypeUndefined,CMTPTypeObjectPropDesc::EReadOnly , CMTPTypeObjectPropDesc::ENone, NULL );
+    return self;
+    }
+   
+EXPORT_C  CMTPTypeServicePropDesc* CMTPTypeServicePropDesc::NewL( const TUint16  aServicePropCode, const TUint16 aDataType, const TUint8 aGetSet, const TUint8 aFormFlag, const MMTPType* aForm )
+    {
+    CMTPTypeServicePropDesc* self = CMTPTypeServicePropDesc::NewLC( aServicePropCode, aDataType, aGetSet, aFormFlag, aForm );
+    CleanupStack::Pop(self); 
+    return self;
+    }
+   
+  
+EXPORT_C  CMTPTypeServicePropDesc* CMTPTypeServicePropDesc::NewLC( const TUint16  aServicePropCode, const TUint16 aDataType, const TUint8 aGetSet, const TUint8 aFormFlag, const MMTPType* aForm)
+    {
+    CMTPTypeServicePropDesc* self = new(ELeave) CMTPTypeServicePropDesc();
+    CleanupStack::PushL(self);
+    self->ConstructL( aServicePropCode, aDataType, aGetSet, aFormFlag, aForm );
+    return self;
+    }
+
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPTypeServicePropDesc::~CMTPTypeServicePropDesc()
+    {
+    iChunkFlat1.Close();
+    iChunkForm.Close();
+    }
+
+CMTPTypeServicePropDesc::CMTPTypeServicePropDesc() : 
+    CMTPTypeCompoundBase((KJustInTimeConstruction), KNumChunksWithoutForm),
+    iElementInfo(iElementMetaData, ENumElements),
+    iChunkFlat1(KFlat1ChunkSize, *this)
+    {
+
+    }
+
+EXPORT_C TUint CMTPTypeServicePropDesc::Type() const
+    {
+    return EMTPTypeServicePropDesc;
+    } 
+
+
+
+EXPORT_C TInt CMTPTypeServicePropDesc::FirstWriteChunk(TPtr8& aChunk)
+    {
+    /* 
+    Reset the type in preparation for the data stream, by deleting all
+    except the first chunk.
+    */
+    for (TUint i(ChunkCount() - 1); (i >= (EIdFlat1Chunk + 1)); i--)
+      {
+      ChunkRemove(i);
+      }
+      
+    // Setup the write chunk pointer.
+       TInt err(CMTPTypeCompoundBase::FirstWriteChunk(aChunk));
+       switch (err)
+           {
+       case KMTPChunkSequenceCompletion:
+           err = KErrNone;
+           // Don't break, fall through to set the write sequence state.
+           
+       case KErrNone:
+           // Set the write sequence state.
+           iWriteSequenceState = EFormChunk;
+           iWriteSequenceCompletionState = EFormChunk;
+           break;
+           
+       default:
+           break;
+           }
+      
+    return  err;
+    }
+
+EXPORT_C TInt CMTPTypeServicePropDesc::NextWriteChunk(TPtr8& /*aChunk*/)
+    {
+        return KMTPChunkSequenceCompletion;
+    }
+
+
+EXPORT_C TBool CMTPTypeServicePropDesc::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+
+EXPORT_C MMTPType* CMTPTypeServicePropDesc::CommitChunkL(TPtr8& aChunk)
+    {
+        switch (iWriteSequenceState)
+            {
+        case EFormChunk:
+            {
+            iChunkForm.Close();
+            TUint8 flag(Uint8L(EFormFlag));
+            TUint16 type(Uint16L(EDataType1));
+            iChunkForm.SetMeta(flag, type);
+            if (HasFormField(flag))
+                {
+                iChunkForm.OpenL(iElementInfo[EForm].iType);
+                ChunkAppendL(iChunkForm);
+                SetExpectedChunkCount(KNumChunksWithForm);
+                }
+            else
+                {
+                // Adjust the write sequence completion state.            
+                iWriteSequenceCompletionState = EFormChunk;
+                }   
+            }
+            break;
+            
+        case EIdle:
+            // Completing the last element in the write sequence.
+            break;
+            
+        default:
+            Panic(EMTPTypeBadStorage);
+            break;
+            }
+        
+    if ( (iWriteSequenceState != EIdle ) && (iWriteSequenceState < iWriteSequenceCompletionState) )
+        {
+        iWriteSequenceState++;
+        }
+    else
+        {
+        iWriteSequenceState = EIdle;
+        }
+
+        
+    if (CMTPTypeCompoundBase::CommitRequired())
+        {
+        CMTPTypeCompoundBase::CommitChunkL(aChunk);
+        }
+    return NULL;
+    }
+
+
+TBool CMTPTypeServicePropDesc::HasFormField(TUint8 aFormFlag) const
+    {
+    return ((aFormFlag != CMTPTypeObjectPropDesc::EDateTimeForm) && (aFormFlag != CMTPTypeObjectPropDesc::ENone)&&(aFormFlag != CMTPTypeObjectPropDesc::EObjectIDForm));
+    }
+
+
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeServicePropDesc::ElementInfo(TInt aElementId) const
+    {
+    __ASSERT_ALWAYS((aElementId < ENumElements), Panic(EMTPTypeBoundsError));
+    
+    return iElementInfo[aElementId];  
+    }
+
+void CMTPTypeServicePropDesc::ConstructL( const TUint16  aServicePropCode, const TUint16 aDataType, const TUint8 aGetSet, const TUint8 aFormFlag, const MMTPType* aForm )
+    {  
+    for (TUint i(0); (i < ENumElements); i++)
+       {
+       const TElementInfo& element(iElementInfo[i]);
+       if (ChunkCount() <= element.iChunkId)
+           {
+           MMTPType* chunk(NULL);
+           switch (element.iChunkId)
+               {
+           case EIdFlat1Chunk:
+               iChunkFlat1.OpenL();
+               chunk = &iChunkFlat1;
+               break;
+               
+           case EIdFormChunk:
+               iChunkForm.SetMeta(aFormFlag, aDataType);
+               if (HasFormField(aFormFlag))
+                   {
+                   iChunkForm.OpenL(element.iType);
+                   chunk = &iChunkForm;
+                   SetExpectedChunkCount(KNumChunksWithForm);
+                   }
+               break;
+               
+           default:
+               Panic(EMTPTypeBoundsError);
+               break;
+               }
+           if (chunk)
+               {
+               ChunkAppendL(*chunk);   
+               }
+           }
+       }
+    
+    // Set the construction values.
+    SetUint16L( EServicePropertyCode, aServicePropCode );
+    SetUint16L( EDataType1, aDataType );
+    SetUint8L( EGetSet1, aGetSet );
+    SetUint8L(EFormFlag, aFormFlag);
+    
+    if (aForm)
+        {
+        if (!HasFormField(aFormFlag))
+            { 
+            User::Leave(KMTPDataTypeInvalid);
+            } 
+        else
+            {
+            SetL(EForm, *aForm); 
+            }
+        }
+    }
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypeserviceproplist.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,668 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/cmtptypeobjectpropdesc.h>
+#include <mtp/cmtptypeserviceproplist.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mtpprotocolconstants.h>
+
+#include "mtpdatatypespanic.h"
+
+// Dataset constants
+const TUint CMTPTypeServicePropListElement::KFlatChunkSize(8);
+    
+const TUint CMTPTypeServicePropList::KNumberOfElementsChunk(0);
+const TUint CMTPTypeServicePropList::KElementChunks(1);
+
+// Dataset element metadata    
+const CMTPTypeCompoundBase::TElementInfo CMTPTypeServicePropListElement::iElementMetaData[CMTPTypeServicePropListElement::ENumElements] = 
+    {
+        {EIdFlatChunk,  EMTPTypeFlat,       {EMTPTypeUINT32,    0,                  KMTPTypeUINT32Size}},   // EObjectHandle
+        {EIdFlatChunk,  EMTPTypeFlat,       {EMTPTypeUINT16,    4,                  KMTPTypeUINT16Size}},   // EPropertyCode
+        {EIdFlatChunk,  EMTPTypeFlat,       {EMTPTypeUINT16,    6,                  KMTPTypeUINT16Size}},   // EDatatype
+        {EIdValueChunk, EMTPTypeReference,  {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}},    // EValue
+    };
+
+/**
+MTP ObjectPropList dataset factory method. This method is used to create an 
+empty MTP ObjectPropList dataset. 
+@return A pointer to the MTP ObjectPropList dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeServicePropList* CMTPTypeServicePropList::NewL()
+    {
+    CMTPTypeServicePropList* self = CMTPTypeServicePropList::NewLC(); 
+    CleanupStack::Pop(self);
+    return self;  
+    }
+
+/**
+MTP ObjectPropList dataset factory method. This method is used to create an 
+empty MTP ObjectPropList dataset. A pointer to the data type is placed on the
+cleanup stack.
+@return A pointer to the MTP ObjectPropList dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeServicePropList* CMTPTypeServicePropList::NewLC()
+    {
+    CMTPTypeServicePropList* self = new(ELeave) CMTPTypeServicePropList();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPTypeServicePropList::~CMTPTypeServicePropList()
+    {
+    iChunksElement.ResetAndDestroy();
+    }
+
+/**
+Appends the specified ObjectPropList value quadruple to the ObjectPropList. 
+Ownership of the specified ObjectPropList value quadruple is passed to the 
+ObjectPropList.
+@param aElement The ObjectPropList value quadruple to append. Ownership IS
+transferred.
+@leave KMTPDataTypeInvalid, If an MTP data object is attached to the 
+ObjectPropList dataset.
+@leave One of the system wide error codes, if unsuccessful.
+*/
+EXPORT_C void CMTPTypeServicePropList::AppendL(CMTPTypeServicePropListElement* aElement)
+    {
+    if (iChunkDataObject)
+        {
+        User::Leave(KMTPDataTypeInvalid);
+        }
+        
+    // Increment NumberOfElements.
+    const TUint index(iChunkNumberOfElements.Value());
+    iChunkNumberOfElements.Set(index + 1);
+    
+    // Append the element.
+    AppendElementChunkL(aElement);
+    }
+
+/**
+Appends the specified MTP data object to the ObjectPropList dataset.
+@leave KMTPDataTypeInvalid, If an MTP data object is already attached to the 
+ObjectPropList dataset.
+@leave One of the system wide error codes, if unsuccessful.
+*/
+EXPORT_C void CMTPTypeServicePropList::AppendDataObjectL(MMTPType& aDataObject)
+    {
+    if (iChunkDataObject)
+        {
+        User::Leave(KMTPDataTypeInvalid);
+        }
+    else
+        {
+        iChunkDataObject = &aDataObject;
+        ChunkAppendL(*iChunkDataObject);
+        }
+    }
+    
+/**
+Provides the NumberOfElements element value.
+*/
+EXPORT_C TUint32 CMTPTypeServicePropList::NumberOfElements() const
+    {
+    return iChunkNumberOfElements.Value();
+    }
+
+/**
+Provides a non-const reference to the ObjectPropList value quadruple element at
+the specified index.
+@param aIndex The index of the required element.
+@return A non-const reference to the requested element.
+@leave One of the system wide error codes, if unsuccessful.
+*/
+EXPORT_C CMTPTypeServicePropListElement& CMTPTypeServicePropList::Element(TUint aIndex) const
+    {
+    return *iChunksElement[aIndex];
+    }
+
+/**
+Provides a non-const reference to the optional MTP data object attached to the
+ObjectPropList dataset.
+@leave KErrNotFound, If there is no MTP data object attched to the 
+ObjectPropList dataset.
+@leave One of the system wide error codes, if unsuccessful.
+*/  
+EXPORT_C MMTPType& CMTPTypeServicePropList::DataObjectL() const
+    {
+    return *iChunkDataObject;
+    }
+
+EXPORT_C TInt CMTPTypeServicePropList::FirstWriteChunk(TPtr8& aChunk)
+    {  
+    /* 
+    Reset the type in preparation for the data stream, by deleting all
+    except the first chunk.
+    */
+    for (TUint i(ChunkCount() - 1); (i >= (KNumberOfElementsChunk + 1)); i--)
+        {
+        ChunkRemove(i);
+        }
+    iChunksElement.ResetAndDestroy();
+    
+    // Setup the write chunk pointer.
+    TInt err(UpdateWriteSequenceErr(CMTPTypeCompoundBase::FirstWriteChunk(aChunk)));
+    switch (err)
+        {
+    case KMTPChunkSequenceCompletion:
+        err = KErrNone;
+        // Don't break, fall through to set the write sequence state.
+        
+    case KErrNone:
+        // Set the write sequence state.
+        iWriteSequenceState = EElementChunks;
+        break;
+        
+    default:
+        break;
+        }
+        
+    return  err;
+    }
+    
+EXPORT_C TInt CMTPTypeServicePropList::NextWriteChunk(TPtr8& aChunk)
+    {
+    TInt err(KMTPChunkSequenceCompletion);
+    if (iWriteSequenceState != EIdle)
+        {
+        err = UpdateWriteSequenceErr(CMTPTypeCompoundBase::NextWriteChunk(aChunk));
+        if ((iWriteSequenceErr == KMTPChunkSequenceCompletion) && (iWriteSequenceState != EIdle))
+            {
+            err = KErrNone;
+            }   
+        }    
+    return err;
+    }
+
+EXPORT_C TUint CMTPTypeServicePropList::Type() const
+    {
+    return EMTPTypeObjectPropListDataset;
+    }
+
+EXPORT_C TBool CMTPTypeServicePropList::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* CMTPTypeServicePropList::CommitChunkL(TPtr8& aChunk)
+    {
+    if (iWriteSequenceErr == KMTPChunkSequenceCompletion)
+        {
+        switch (iWriteSequenceState)
+            {
+        case EElementChunks:
+            if ((iChunkNumberOfElements.Value()) && 
+                (iChunksElement.Count() < iChunkNumberOfElements.Value()))
+                {
+                // Allocate the next element chunk.
+                CMTPTypeServicePropListElement* element = CMTPTypeServicePropListElement::NewLC();
+                AppendElementChunkL(element);
+                CleanupStack::Pop(element); 
+                }
+            else if (iChunkDataObject)
+                {
+                iWriteSequenceState = EDataObjectChunk;
+                ChunkAppendL(*iChunkDataObject);
+                }
+            else
+                {
+                iWriteSequenceState = EIdle;
+                }
+            break;
+            
+        case EDataObjectChunk:
+        case EIdle:
+            // Completing the last chunk in the write sequence.
+            break;
+            
+        default:
+            Panic(EMTPTypeBadStorage);
+            break;
+            }
+        }
+        
+    if (CMTPTypeCompoundBase::CommitRequired())
+        {
+        CMTPTypeCompoundBase::CommitChunkL(aChunk);
+        }
+	return NULL;
+    }
+ 
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeServicePropList::ElementInfo(TInt aElementId) const
+    {
+    if (aElementId == KNumberOfElementsChunk)
+        {
+        return iInfoNumberOfElements;
+        }
+    else
+        {
+        __ASSERT_ALWAYS(((aElementId - KElementChunks) < iChunkNumberOfElements.Value()), Panic(EMTPTypeBoundsError));
+        iInfoElement.iChunkId = aElementId;
+        return iInfoElement; 
+        }
+    }
+
+TInt CMTPTypeServicePropList::ValidateChunkCount() const
+    {
+    TInt ret(KErrNone);
+    TUint expected(iChunkDataObject ? (NumberOfElements() + 1) : NumberOfElements());
+    if (expected != (ChunkCount() - 1))
+        {
+        ret = KMTPDataTypeInvalid;
+        }
+    return ret;
+    }
+
+CMTPTypeServicePropList::CMTPTypeServicePropList() :
+    CMTPTypeCompoundBase(KJustInTimeConstruction, KVariableChunkCount)
+    {
+    const CMTPTypeCompoundBase::TElementInfo KDefaultInfo = {0, EMTPTypeUndefined, {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}};
+    iInfoNumberOfElements       = KDefaultInfo; 
+    iInfoNumberOfElements.iType = EMTPTypeUINT32;
+    iInfoElement                = KDefaultInfo; 
+    iInfoElement.iType          = EMTPTypeObjectPropListElementDataset;
+    }
+
+void CMTPTypeServicePropList::ConstructL()
+    {
+    ChunkAppendL(iChunkNumberOfElements);
+    }
+    
+void CMTPTypeServicePropList::AppendElementChunkL(CMTPTypeServicePropListElement* aElement)
+    {
+    iChunksElement.AppendL(aElement);
+    ChunkAppendL(*aElement);
+    }
+    
+TInt CMTPTypeServicePropList::UpdateWriteSequenceErr(TInt aErr)
+    {
+    iWriteSequenceErr = aErr;
+    return iWriteSequenceErr;        
+    }
+
+/**
+MTP ObjectPropList element dataset factory method. This method is used to 
+create an MTP ObjectPropList element dataset type with the default 
+ElementDataType defined for the specified ElementPropertyCode, and the default 
+ElementObjectHandle and ElementValue values. 
+@param aPropertyCode The datacode identifying the ObjectPropDesc which 
+describes the property.
+@return A pointer to the ObjectPropList element dataset type. 
+Ownership IS transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeServicePropListElement* CMTPTypeServicePropListElement::NewL(TUint16 aPropertyCode)
+    {
+    CMTPTypeServicePropListElement* self = NewLC(aPropertyCode);
+    CleanupStack::Pop(self); 
+    return self;
+    }
+
+/**
+MTP ObjectPropList element dataset factory method. This method is used to 
+create an MTP ObjectPropList element dataset type with with the default 
+ElementDataType defined for the specified ElementPropertyCode, and the default 
+ElementObjectHandle and ElementValue values. A pointer to the data type is 
+placed on the cleanup stack.
+@param aPropertyCode The datacode identifying the ObjectPropDesc which 
+describes the property.
+@return A pointer to the ObjectPropList element dataset type. 
+Ownership IS transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeServicePropListElement* CMTPTypeServicePropListElement::NewLC(TUint16 aPropertyCode)
+    {
+    CMTPTypeObjectPropDesc::TPropertyInfo info;
+    CMTPTypeObjectPropDesc::PropertyInfoL(aPropertyCode, info);
+
+    CMTPTypeServicePropListElement* self = new(ELeave) CMTPTypeServicePropListElement();
+    CleanupStack::PushL(self); 
+    self->ConstructL(aPropertyCode, info.iDataType, NULL, NULL);
+    return self;
+    }
+
+/**
+MTP ObjectPropList element dataset factory method. This method is used to 
+create an MTP ObjectPropList element dataset type with with the default 
+ElementDataType defined for the specified ElementPropertyCode, and the 
+specified ElementObjectHandle and ElementValue values. 
+@param aObjectHandle The ObjectHandle of the object to which the property 
+applies.
+@param aPropertyCode The datacode identifying the ObjectPropDesc which 
+describes the property.
+@param aValue The value of the property.
+@return A pointer to the ObjectPropList element dataset type. 
+Ownership IS transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeServicePropListElement* CMTPTypeServicePropListElement::NewL(TUint32 aObjectHandle, TUint16 aPropertyCode, const MMTPType& aValue)
+    {
+    CMTPTypeServicePropListElement* self = NewLC(aObjectHandle, aPropertyCode, aValue);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+MTP ObjectPropList element dataset factory method. This method is used to 
+create an MTP ObjectPropList element dataset type with with the default 
+ElementDataType defined for the specified ElementPropertyCode, and the 
+specified ElementObjectHandle and ElementValue values. A pointer to the data 
+type is placed on the cleanup stack.
+@param aObjectHandle The ObjectHandle of the object to which the property 
+applies.
+@param aPropertyCode The datacode identifying the ObjectPropDesc which 
+describes the property.
+@param aValue The value of the property.
+@return A pointer to the ObjectPropList element dataset type. 
+Ownership IS transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeServicePropListElement* CMTPTypeServicePropListElement::NewLC(TUint32 aObjectHandle, TUint16 aPropertyCode, const MMTPType& aValue)
+    {
+    CMTPTypeObjectPropDesc::TPropertyInfo info;
+    CMTPTypeObjectPropDesc::PropertyInfoL(aPropertyCode, info);
+
+    CMTPTypeServicePropListElement* self = new(ELeave) CMTPTypeServicePropListElement();
+    CleanupStack::PushL(self); 
+    self->ConstructL(aPropertyCode, info.iDataType, &aObjectHandle, &aValue);
+    return self;
+    }
+
+/**
+MTP ObjectPropList element dataset factory method. This method is used to 
+create an MTP ObjectPropList element dataset type with the specified 
+ElementPropertyCode and ElementDataType values, and the default 
+ElementObjectHandle and ElementValue values. 
+@param aPropertyCode The datacode identifying the ObjectPropDesc which 
+describes the property.
+@param aDataType The datacode identifying the datatype of the property.
+@return A pointer to the ObjectPropList element dataset type. 
+Ownership IS transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeServicePropListElement* CMTPTypeServicePropListElement::NewL(TUint16 aPropertyCode, TUint16 aDataType)
+    {
+    CMTPTypeServicePropListElement* self = NewLC(aPropertyCode, aDataType);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+MTP ObjectPropList element dataset factory method. This method is used to 
+create an MTP ObjectPropList element dataset type with the specified 
+ElementPropertyCode and ElementDataType values, and the default 
+ElementObjectHandle and ElementValue values. A pointer to the data type is 
+placed on the cleanup stack.
+@param aPropertyCode The datacode identifying the ObjectPropDesc which 
+describes the property.
+@param aDataType The datacode identifying the datatype of the property.
+@return A pointer to the ObjectPropList element dataset type. 
+Ownership IS transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeServicePropListElement* CMTPTypeServicePropListElement::NewLC(TUint16 aPropertyCode, TUint16 aDataType)
+    {
+    CMTPTypeServicePropListElement* self = new(ELeave) CMTPTypeServicePropListElement();
+    CleanupStack::PushL(self); 
+    self->ConstructL(aPropertyCode, aDataType, NULL, NULL);
+    return self;
+    }
+
+/**
+MTP ObjectPropList element dataset factory method. This method is used to 
+create an MTP ObjectPropList element dataset type with the specified values. 
+@param aObjectHandle The ObjectHandle of the object to which the property 
+applies.
+@param aPropertyCode The datacode identifying the ObjectPropDesc which 
+describes the property.
+@param aDataType The datacode identifying the datatype of the property.
+@param aValue The value of the property.
+@return A pointer to the ObjectPropList element dataset type. 
+Ownership IS transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeServicePropListElement* CMTPTypeServicePropListElement::NewL(TUint32 aObjectHandle, TUint16 aPropertyCode, TUint16 aDataType, const MMTPType& aValue)
+    {
+    CMTPTypeServicePropListElement* self = NewLC(aObjectHandle, aPropertyCode, aDataType, aValue);
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+/**
+MTP ObjectPropList element dataset factory method. This method is used to 
+create an MTP ObjectPropList element dataset type with the specified values. A 
+pointer to the data type is placed on the cleanup stack.
+@param aObjectHandle The ObjectHandle of the object to which the property 
+applies.
+@param aPropertyCode The datacode identifying the ObjectPropDesc which 
+describes the property.
+@param aDataType The datacode identifying the datatype of the property.
+@param aValue The value of the property.
+@return A pointer to the ObjectPropList element dataset type. 
+Ownership IS transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPTypeServicePropListElement* CMTPTypeServicePropListElement::NewLC(TUint32 aObjectHandle, TUint16 aPropertyCode, TUint16 aDataType, const MMTPType& aValue)
+    {
+    CMTPTypeServicePropListElement* self = new(ELeave) CMTPTypeServicePropListElement();
+    CleanupStack::PushL(self); 
+    self->ConstructL(aPropertyCode, aDataType, &aObjectHandle, &aValue);
+    return self;    
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPTypeServicePropListElement::~CMTPTypeServicePropListElement()
+    {
+    iChunkFlat.Close();
+    iChunkValue.Close();
+    }
+
+EXPORT_C TInt CMTPTypeServicePropListElement::FirstWriteChunk(TPtr8& aChunk)
+    {
+    // Setup the write chunk pointer.
+    TInt err(CMTPTypeCompoundBase::FirstWriteChunk(aChunk));
+    switch (err)
+        {
+    case KMTPChunkSequenceCompletion:
+        err = KErrNone;
+        // Don't break, fall through to set the write sequence state.
+        
+    case KErrNone:
+        // Set the write sequence state.
+        iWriteSequenceState = EFlatChunk;
+        break;
+        
+    default:
+        break;
+        }        
+    return  err;
+    }
+
+EXPORT_C TUint CMTPTypeServicePropListElement::Type() const
+    {
+    return EMTPTypeObjectPropListElementDataset;
+    }
+
+EXPORT_C TBool CMTPTypeServicePropListElement::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* CMTPTypeServicePropListElement::CommitChunkL(TPtr8& aChunk)
+    {
+    switch (iWriteSequenceState)
+        {
+    case EFlatChunk:
+        /* 
+        ElementDatatype is available, (re)construct storage for the 
+        ElementValue.
+        */
+        iChunkValue.Close();
+        iChunkValue.OpenL(Uint16L(EDatatype));
+        
+        // Update the write sequence state.
+        iWriteSequenceState = EValueChunk;
+        break;
+        
+    case EValueChunk:
+        // Update the write sequence state.
+        iWriteSequenceState = EIdle;
+        break;
+        
+    default:
+        break;
+        }
+        
+    if (CMTPTypeCompoundBase::CommitRequired())
+        {
+        CMTPTypeCompoundBase::CommitChunkL(aChunk);
+        }
+	return NULL;
+    }
+    
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeServicePropListElement::ElementInfo(TInt aElementId) const
+    {
+    return iElementInfo[aElementId];
+    }
+
+TBool CMTPTypeServicePropListElement::WriteableElementL(TInt aElementId) const
+    {
+    TBool ret(EFalse);
+
+    if (!iInitialised)
+        {
+        ret = ETrue;    
+        }
+    else
+        {
+        switch (aElementId)
+            {
+        case EObjectHandle:
+        case EValue:
+            ret = ETrue;
+            break;
+
+        default:
+            break;
+            }   
+        }
+        
+    return ret;
+    }
+
+/*
+MTP ObjectPropList element dataset "pre-production" factory method for datasets
+which will be populated from an MTP write data stream. This method is used to 
+create a partially constructed MTP ObjectPropList element dataset type prior to
+the construction characteristics being known. Construction of the element 
+dataset is completed on-the-fly as it is written to from an MTP write data 
+stream. A pointer to the data type is placed on the cleanup stack.
+@return A pointer to the ObjectPropList element dataset type. 
+Ownership IS transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/
+CMTPTypeServicePropListElement* CMTPTypeServicePropListElement::NewLC()
+    {
+    CMTPTypeServicePropListElement* self = new(ELeave) CMTPTypeServicePropListElement();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+CMTPTypeServicePropListElement::CMTPTypeServicePropListElement() :
+    CMTPTypeCompoundBase(KJustInTimeConstruction, EIdNumChunks),
+    iElementInfo(iElementMetaData, ENumElements),
+    iChunkFlat(KFlatChunkSize, *this)
+    {
+
+    }
+
+void CMTPTypeServicePropListElement::ConstructL()
+    {
+    for (TUint i(0); (i < ENumElements); i++)
+        {
+        const TElementInfo& element(iElementInfo[i]);
+        if (ChunkCount() <= element.iChunkId)
+            {
+            MMTPType* chunk(NULL);
+            
+            switch (element.iChunkId)
+                {
+            case EIdFlatChunk:
+                iChunkFlat.OpenL();
+                chunk = &iChunkFlat;
+                break;
+                
+            case EIdValueChunk:
+                /* 
+                iChunkValue is always opened elsewhere. CommitChunkL in the  
+                just-in-time construction case, or other ConstructL overloads in
+                normal construction cases.
+                */
+                chunk = &iChunkValue;
+                break;
+                
+            default:
+                Panic(EMTPTypeBoundsError);
+                break;
+                }
+                
+            if (chunk)
+                {
+                ChunkAppendL(*chunk);
+                }
+            }
+        }
+    }
+
+void CMTPTypeServicePropListElement::ConstructL(TUint16 aPropertyCode, TUint16 aDataType, const TUint32* aObjectHandle, const MMTPType* aValue)
+    {
+    iChunkValue.OpenL(aDataType);
+    ConstructL();
+
+    // Set mandatory construction values.
+    SetUint16L(EPropertyCode, aPropertyCode);
+    SetUint16L(EDatatype, aDataType);
+
+    // Set optional construction values.
+    if (aObjectHandle)
+        {
+        SetUint32L(EObjectHandle, *aObjectHandle);
+        }
+
+    if (aValue)
+        {
+        SetL(EValue, *aValue);
+        }
+    
+    iInitialised = ETrue;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypestorageinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,147 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <mtp/tmtptypeflatbase.h>
+#include <mtp/cmtptypestorageinfo.h>
+#include <mtp/cmtptypestring.h>
+   
+// Dataset constants
+const TUint CMTPTypeStorageInfo::KFlatChunkSize(26);
+
+// Dataset element metadata.
+const CMTPTypeCompoundBase::TElementInfo CMTPTypeStorageInfo::iElementMetaData[CMTPTypeStorageInfo::ENumElements] = 
+    {
+        {EIdFlatChunk,                  EMTPTypeFlat,   {EMTPTypeUINT16,    0,                  KMTPTypeUINT16Size}},   // EStorageType
+        {EIdFlatChunk,                  EMTPTypeFlat,   {EMTPTypeUINT16,    2,                  KMTPTypeUINT16Size}},   // EFileSystemType
+        {EIdFlatChunk,                  EMTPTypeFlat,   {EMTPTypeUINT16,    4,                  KMTPTypeUINT16Size}},   // EAccessCapability
+        {EIdFlatChunk,                  EMTPTypeFlat,   {EMTPTypeUINT64,    6,                  KMTPTypeUINT64Size}},   // EMaxCapacity
+        {EIdFlatChunk,                  EMTPTypeFlat,   {EMTPTypeUINT64,    14,                 KMTPTypeUINT64Size}},   // EFreeSpaceInBytes
+        {EIdFlatChunk,                  EMTPTypeFlat,   {EMTPTypeUINT32,    22,                 KMTPTypeUINT32Size}},   // EFreeSpaceInObjects
+        {EIdStorageDescriptionChunk,    EMTPTypeString, {EMTPTypeString,    KMTPNotApplicable,  KMTPNotApplicable}},    // EStorageDescription
+        {EIdVolumeIdentifierChunk,      EMTPTypeString, {EMTPTypeString,    KMTPNotApplicable,  KMTPNotApplicable}},    // EVolumeIdentifier
+    };
+    
+/**
+MTP StorageInfo dataset factory method. This method is used to create an empty 
+MTP StorageInfo dataset type. A pointer to the MTP array data type is placed on 
+the cleanup stack.
+@return A pointer to an empty MTP StorageInfo dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/    
+EXPORT_C CMTPTypeStorageInfo* CMTPTypeStorageInfo::NewL()
+    {
+    CMTPTypeStorageInfo* self=CMTPTypeStorageInfo::NewLC(); 
+    CleanupStack::Pop(self);
+    return self; 
+    }
+    
+
+/**
+MTP StorageInfo dataset factory method. This method is used to create an empty 
+MTP StorageInfo dataset type.
+@return A pointer to an empty MTP StorageInfo dataset type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/   
+EXPORT_C CMTPTypeStorageInfo* CMTPTypeStorageInfo::NewLC()
+    {
+    CMTPTypeStorageInfo* self=new (ELeave) CMTPTypeStorageInfo(); 
+    CleanupStack::PushL(self); 
+    self->ConstructL();
+    return self;    
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPTypeStorageInfo::~CMTPTypeStorageInfo()
+    {
+    iChunkFlat.Close();
+    iStringChunks.ResetAndDestroy();
+    } 
+
+EXPORT_C TUint CMTPTypeStorageInfo::Type() const
+    {
+    return EMTPTypeStorageInfoDataset;
+    }
+
+const CMTPTypeCompoundBase::TElementInfo& CMTPTypeStorageInfo::ElementInfo(TInt aElementId) const
+    {
+    return iElementInfo[aElementId];
+    }
+    
+CMTPTypeStorageInfo::CMTPTypeStorageInfo() :
+    CMTPTypeCompoundBase((!KJustInTimeConstruction), EIdNumChunks),
+    iElementInfo(iElementMetaData, ENumElements), 
+    iChunkFlat(KFlatChunkSize, *this)
+    {
+    
+    }
+        
+void CMTPTypeStorageInfo::ConstructL()
+    {
+    for (TUint i(0); (i < ENumElements); i++)
+        {
+        const TElementInfo& info(iElementInfo[i]);
+        if (ChunkCount() <= info.iChunkId)
+            {
+            MMTPType* chunk(NULL);
+            
+            switch (info.iType)
+                {
+            case EMTPTypeFlat:
+                chunk = NewFlatChunkL(info);
+                break;
+                
+            case EMTPTypeString:
+                chunk = NewStringChunkL(info);
+                break;
+                                
+            default:
+                break;
+                }
+            __ASSERT_DEBUG(chunk, User::Invariant());
+            ChunkAppendL(*chunk);
+            }
+        }
+    }
+    
+MMTPType* CMTPTypeStorageInfo::NewFlatChunkL(const TElementInfo& aElementInfo)
+    {
+    MMTPType* chunk(NULL);
+    switch (aElementInfo.iChunkId)
+        {
+    case 0:
+        iChunkFlat.OpenL();
+        chunk = &iChunkFlat;
+        break;
+        
+    default:
+        break;
+        }        
+    __ASSERT_DEBUG(chunk, User::Invariant());
+    return chunk;
+    }
+
+MMTPType* CMTPTypeStorageInfo::NewStringChunkL(const TElementInfo& /*aElementInfo*/)
+    {
+    CMTPTypeString* chunk(CMTPTypeString::NewLC());
+    iStringChunks.AppendL(chunk);
+    CleanupStack::Pop(chunk);
+    return chunk;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypestring.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,295 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/cmtptypestring.h>
+#include <mtp/mtpdatatypeconstants.h>
+
+#include "mtpdatatypespanic.h"
+
+// String type constants
+const TUint KMTPAlignmentOffset(0);
+const TUint KMTPAlignmentSize(1);
+const TUint KMTPNumCharsOffset(KMTPAlignmentOffset + KMTPAlignmentSize);
+const TUint KMTPNumCharsSize(KMTPTypeUINT8Size);
+const TUint KMTPStringCharactersOffset(KMTPNumCharsOffset + KMTPNumCharsSize);
+
+/**
+MTP string data type factory method. This method is used to create a 
+zero-length MTP string.
+@return A pointer to a zero-length MTP string data type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/   
+EXPORT_C CMTPTypeString* CMTPTypeString::NewL()
+    {
+	CMTPTypeString* self = NewLC(); 
+	CleanupStack::Pop(self);
+	return self; 
+    }
+
+/**
+MTP string data type factory method. This method is used to create an 
+MTP string with the specified value.
+@param aString The initial string value.
+@return A pointer to the MTP string data type. Ownership IS transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/     
+EXPORT_C CMTPTypeString* CMTPTypeString::NewL(const TDesC& aString)
+    {
+	CMTPTypeString* self = NewLC(aString);
+	CleanupStack::Pop(self);
+	return self;
+    }
+
+/**
+MTP string data type factory method. This method is used to create a 
+zero-length MTP string. A pointer to the MTP string data type is placed on the
+cleanup stack.
+@return A pointer to a zero-length MTP string data type. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/   
+EXPORT_C CMTPTypeString* CMTPTypeString::NewLC()
+    {
+	CMTPTypeString* self = NewLC(KNullDesC);
+	return self;    
+    }
+
+/**
+MTP string data type factory method. This method is used to create an MTP 
+string with the specified value. A pointer to the MTP string data type is 
+placed on the cleanup stack.
+@param aString The initial string value.
+@return A pointer to the MTP string data type. Ownership IS transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/      
+EXPORT_C CMTPTypeString* CMTPTypeString::NewLC(const TDesC& aString)
+    {
+	CMTPTypeString* self = new(ELeave) CMTPTypeString;
+	CleanupStack::PushL(self);
+    self->ConstructL(aString);
+	return self;
+    }
+
+/**
+Destructor
+*/
+EXPORT_C CMTPTypeString::~CMTPTypeString()
+    {
+    iBuffer.Close();
+    }
+    
+/**
+Provides the number of unicode characters making up the MTP string.
+@return The number of unicode characters making up the MTP string.
+*/    
+EXPORT_C TUint8 CMTPTypeString::NumChars() const
+    {
+    return iBuffer[KMTPNumCharsOffset];
+    }
+
+/**
+Provides a non-modifiable reference to the MTP String Characters data. The data
+provided does not include the terminating null character.
+@return A non-modifiable MTP string data reference.
+*/  
+EXPORT_C const TDesC& CMTPTypeString::StringChars() const
+    {
+    return iStringChars;
+    }
+    
+/**
+Sets the MTP string data type to the specified value.
+@param aString The type's new value.
+@leave One of the system wide error codes, if a processing error occurs.
+*/     
+EXPORT_C void CMTPTypeString::SetL(const TDesC& aString)
+    {
+    ConstructL(aString);
+    }
+	
+EXPORT_C TInt CMTPTypeString::FirstReadChunk(TPtrC8& aChunk) const
+    {
+	aChunk.Set(&iBuffer[KMTPNumCharsOffset], (iBuffer.Length() - KMTPAlignmentSize));
+    return KMTPChunkSequenceCompletion;
+    }
+	
+EXPORT_C TInt CMTPTypeString::NextReadChunk(TPtrC8& aChunk) const
+    {
+    aChunk.Set(NULL, 0);
+    return KErrNotReady;
+    }
+	
+EXPORT_C TInt CMTPTypeString::FirstWriteChunk(TPtr8& aChunk)
+    {
+    TInt ret(KErrNone);
+    aChunk.Set(&iBuffer[KMTPNumCharsOffset], 0, KMTPNumCharsSize);
+    iWriteSequenceState = ENumChars;        
+    return ret;
+    }
+	
+EXPORT_C TInt CMTPTypeString::NextWriteChunk(TPtr8& aChunk)
+    {
+    TInt ret(KMTPChunkSequenceCompletion);
+    
+    if (iWriteSequenceState != ENumChars)
+        {
+        ret = KErrNotReady;
+        }
+    else
+        {
+        const TUint numChars(NumChars());
+        __ASSERT_ALWAYS((numChars <= KMTPMaxStringLength), Panic(EMTPTypeSizeMismatch));
+        if (numChars > 0)
+            {
+        	aChunk.Set(&iBuffer[KMTPStringCharactersOffset], 0, (iBuffer.MaxLength() - KMTPAlignmentSize - KMTPNumCharsSize));
+            }
+        else
+            {
+            aChunk.Set(NULL, 0, 0);
+            }
+            
+        iWriteSequenceState = EStringChars;
+        }
+        
+    return ret;
+    }
+    
+EXPORT_C TUint64 CMTPTypeString::Size() const
+    {
+	return (iBuffer.Size() - KMTPAlignmentSize);
+    }
+    
+EXPORT_C TUint CMTPTypeString::Type() const
+	{
+	return EMTPTypeString;
+	}
+
+EXPORT_C TBool CMTPTypeString::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* CMTPTypeString::CommitChunkL(TPtr8& aChunk)
+    {
+    switch (iWriteSequenceState)
+        {
+    case ENumChars:
+        /* 
+        The first chunk specifies the NumChars field, and is used to re-size 
+        the array buffer. 
+        */
+        ReAllocBufferL(NumChars());  
+        break;
+        
+    case EStringChars:
+        // Check that the correct number of characters has been received.
+        {
+        TUint len(aChunk.Length());
+        if ((len % KMTPCharSize) ||
+            ((len / KMTPCharSize) != NumChars()))
+            {
+            iValidationState = KMTPDataTypeInvalid;
+            User::Leave(iValidationState);
+            }
+        iWriteSequenceState = EIdle;
+        }
+        break;
+        
+    case EIdle:
+    default:
+        break;
+        }
+    return NULL;
+    }
+    
+EXPORT_C TInt CMTPTypeString::Validate() const
+    {
+    return iValidationState;
+    }
+
+CMTPTypeString::CMTPTypeString() :
+    iBuffer(),
+    iStringChars(NULL, 0)
+    {
+
+    }
+
+void CMTPTypeString::ConstructL(const TDesC& aString)
+    {
+    if (aString.Length() > KMTPMaxStringCharactersLength)
+        {
+        User::Leave(KErrArgument);            
+        }
+    
+    // Allocate string storage.
+    TUint numChars(aString.Length());
+    if (numChars)
+        {
+        numChars += KMTPNullCharLen;   
+        }
+    ReAllocBufferL(numChars);
+    
+    // Append the String Characters.
+    if (numChars > 0)
+        {
+        iStringChars.Copy(aString);
+        }
+    }
+
+void CMTPTypeString::ReAllocBufferL(TUint aNumNullTerminatedChars)
+    {
+    if (aNumNullTerminatedChars > KMTPMaxStringLength)
+        {
+        User::Leave(KErrOverflow);            
+        }
+        
+    // Delete the current buffer
+    iBuffer.Close();
+    iStringChars.Set(NULL, 0, 0);
+    
+    // Allocate a new buffer.
+    if (aNumNullTerminatedChars > 0)
+        {  
+        /*
+        Allocate storage for both the NumChars and String Characters fields. A single 
+        alignment byte is pre-pended to force String Characters to be 16-bit aligned.
+        */
+        iBuffer.CreateMaxL(KMTPAlignmentSize + KMTPNumCharsSize + (aNumNullTerminatedChars * KMTPCharSize));
+        
+        // Insert the terminating NULL character.
+        TUint numChars(aNumNullTerminatedChars - KMTPNullCharLen);
+        memcpy(&iBuffer[KMTPStringCharactersOffset + (numChars * KMTPCharSize)], &KMTPNullChar, KMTPCharSize);
+        
+        // Set the String Characters pointer.
+        iStringChars.Set(reinterpret_cast<TUint16*>(&iBuffer[KMTPStringCharactersOffset]), numChars, numChars);
+        }
+    else
+        {       
+        /*
+        Allocate storage for the NumChars field only. A single alignment byte 
+        is pre-pended to force String Characters to be 16-bit aligned.
+        */
+        iBuffer.CreateMaxL(KMTPNumCharsSize + KMTPAlignmentSize);
+        }
+        
+    // Insert the NumChars value
+    iBuffer[KMTPNumCharsOffset] = aNumNullTerminatedChars;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypetrivialdata.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,120 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/cmtptypetrivialdata.h>
+
+
+const TInt KMaxSizeOfWriteBuffer = 0x00004000; // 16KB
+
+EXPORT_C CMTPTypeTrivialData* CMTPTypeTrivialData::NewL()
+    {
+    CMTPTypeTrivialData* self = NewLC();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+EXPORT_C CMTPTypeTrivialData* CMTPTypeTrivialData::NewLC()
+    {
+    CMTPTypeTrivialData* self = new(ELeave) CMTPTypeTrivialData();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+void CMTPTypeTrivialData::ConstructL()
+    {
+    
+    }
+
+CMTPTypeTrivialData::CMTPTypeTrivialData()
+    {
+
+    }
+
+EXPORT_C CMTPTypeTrivialData::~CMTPTypeTrivialData()
+    {
+    iBuffer.Close();
+    }
+
+EXPORT_C TInt CMTPTypeTrivialData::FirstReadChunk(TPtrC8& /* aChunk */) const
+    {
+    __ASSERT_DEBUG(EFalse, User::Invariant());
+    return KMTPChunkSequenceCompletion;
+    }
+    
+EXPORT_C TInt CMTPTypeTrivialData::NextReadChunk(TPtrC8& /* aChunk */) const
+    {
+    __ASSERT_DEBUG(EFalse, User::Invariant());
+    return KErrNotReady;
+    }
+
+EXPORT_C TInt CMTPTypeTrivialData::FirstWriteChunk(TPtr8& aChunk)
+    {    
+    return NextWriteChunk(aChunk);
+    }
+
+EXPORT_C TInt CMTPTypeTrivialData::NextWriteChunk(TPtr8& aChunk)
+    {    
+    if (iBuffer.MaxSize() == 0)
+    {
+    iBuffer.Create(KMaxSizeOfWriteBuffer);
+    }
+    aChunk.Set( const_cast<TUint8*>(iBuffer.Ptr()), 0, KMaxSizeOfWriteBuffer);
+    return KErrNone;    
+    }
+
+EXPORT_C TInt CMTPTypeTrivialData::FirstWriteChunk(TPtr8& aChunk, TUint aDataLength )
+    {
+    return NextWriteChunk(aChunk, aDataLength);
+    }
+
+EXPORT_C TInt CMTPTypeTrivialData::NextWriteChunk(TPtr8& aChunk, TUint aDataLength )
+    {
+    TInt ret = KMTPChunkSequenceCompletion;
+    TUint len = aDataLength;
+    if(aDataLength > KMaxSizeOfWriteBuffer)
+        {
+        len = KMaxSizeOfWriteBuffer;
+        ret = KErrNone;
+        }
+    
+    if (iBuffer.MaxSize() == 0)
+    {
+    iBuffer.Create(len);
+    }
+    
+    aChunk.Set( const_cast<TUint8*>(iBuffer.Ptr()), 0, len);
+
+    return ret;
+    }
+
+EXPORT_C TUint64 CMTPTypeTrivialData::Size() const
+    {
+    return 0;
+    }
+
+EXPORT_C TUint CMTPTypeTrivialData::Type() const
+    {
+    return EMTPTypeTrivialData;        
+    }
+
+   
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/mmtptype.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,163 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/mmtptype.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <e32base.h> 
+
+EXPORT_C TBool MMTPType::CommitRequired() const
+    {
+    return EFalse;
+    }
+	
+EXPORT_C MMTPType* MMTPType::CommitChunkL(TPtr8& /*aChunk*/)
+    {
+    User::Leave(KErrNotSupported);
+    return NULL;
+    }
+    
+EXPORT_C TInt MMTPType::Validate() const
+    {
+    return KErrNone;
+    }
+    
+EXPORT_C void MMTPType::CopyL(const MMTPType& aFrom, MMTPType& aTo)
+    {
+    TBool commit(aTo.CommitRequired());
+    TBool complete(EFalse);
+    TPtr8 dest(NULL, 0);
+    TPtrC8 src;
+    TBool useAoWrite = EFalse;
+    if(EMTPTypeFile == aTo.Type()) //should change later use API to get the write type
+        {
+        useAoWrite = ETrue;
+        }
+    
+    TInt readErr(KErrNone);
+    TInt writeErr(KErrNone);
+    
+    // Obtain the initial read and write chunks.
+    User::LeaveIfError(readErr = aFrom.FirstReadChunk(src));
+    User::LeaveIfError(writeErr = aTo.FirstWriteChunk(dest));
+    
+    while (!complete)
+        {
+        TUint dataAvailable(src.Length());
+        TUint writeCapacity(dest.MaxLength() - dest.Length());
+        
+        complete = 
+            (((readErr == KMTPChunkSequenceCompletion) && !dataAvailable) || 
+            (writeErr == KMTPChunkSequenceCompletion));
+            
+        if (writeCapacity < dataAvailable)
+            {
+            if (writeCapacity)
+                {
+                /* 
+                Write chunk capacity is available, but not enough to accomodate
+                the available read chunk data. Fill the available write chunk 
+                capacity and adjust the read chunk pointer.
+                */
+                dest.Append(src.Left(writeCapacity));                    
+                src.Set(src.Right(dataAvailable - writeCapacity));
+                }
+                
+            if (commit)
+                {
+                /*
+                Always commit write chunks which require it, even if the write
+                chunk has no capacity.
+                */
+                aTo.CommitChunkL(dest);   
+                if(useAoWrite)
+                    {
+                    TInt err = KErrNone;
+                    while(CActiveScheduler::RunIfReady(err, CActive::EPriorityIdle))
+                        {
+                        //let the write ao run
+                        }
+                    User::LeaveIfError(err);
+                    }
+                }
+
+            if (writeErr != KMTPChunkSequenceCompletion)
+                {
+                // Obtain the next write chunk
+                User::LeaveIfError(writeErr = aTo.NextWriteChunk(dest));  
+                }
+            }
+        else if (dataAvailable)
+            {
+            /* 
+            Write chunk can accomodate the available read chunk data. Consume
+            the available read chunk data, adjust the read chunk pointer, 
+            and obtain the next write chunk.
+            */
+            dest.Append(src);
+            if (commit && (dest.Length() == dest.MaxLength() || KMTPChunkSequenceCompletion == readErr)) //doesn't commit a half chunk unless it is the last chunk
+                {
+                aTo.CommitChunkL(dest);
+                if(useAoWrite)
+                    {
+                    TInt err = KErrNone;
+                    while(CActiveScheduler::RunIfReady(err, CActive::EPriorityIdle))
+                        {
+                        //let the write ao run
+                        }
+                    User::LeaveIfError(err);
+                    }
+                }
+
+            if (readErr != KMTPChunkSequenceCompletion)
+                {
+                User::LeaveIfError(readErr = aFrom.NextReadChunk(src)); 
+                }
+            else
+                {
+                src.Set(KNullDesC8);   
+                }
+
+            /*
+            If the write chunk is full, and more write chunks are available, 
+            obtain the next write chunk.
+            */
+            if ((dest.Length() == dest.MaxLength()) && (writeErr != KMTPChunkSequenceCompletion))
+                {
+                User::LeaveIfError(writeErr = aTo.NextWriteChunk(dest));  
+                }
+            }
+        }        
+    }
+
+EXPORT_C TAny* MMTPType::GetExtendedInterface(TUid /*aInterfaceUid*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C TInt MMTPType::FirstWriteChunk(TPtr8& aChunk, TUint /*aDataLength*/ )
+    {
+    return FirstWriteChunk(aChunk);
+    }
+
+EXPORT_C TInt MMTPType::NextWriteChunk(TPtr8& aChunk, TUint /*aDataLength*/ )
+    {
+    return NextWriteChunk(aChunk);
+    }
+
+EXPORT_C TBool MMTPType::ReserveTransportHeader(TUint /* aHeaderLength */, TPtr8& /* aHeader */)
+    {
+    return EFalse;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/rmtptype.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,461 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mtptypescomplex.h>
+#include <mtp/mtptypessimple.h>
+#include <mtp/rmtptype.h>
+#include <mtp/tmtptypedatapair.h>
+#include <mtp/cmtptypeobjectpropdesc.h>
+#include <mtp/cmtptypeserviceprop.h>
+#include <mtp/cmtptypeserviceformat.h>
+#include <mtp/cmtptypeservicemethod.h>
+#include <mtp/cmtptypeserviceevent.h>
+#include <mtp/cmtptypeservicepropdesclist.h>
+#include <mtp/cmtptypeservicecapabilitylist.h>
+
+#include "mtpdatatypespanic.h"
+
+
+/**
+Constructor.
+*/
+EXPORT_C RMTPType::RMTPType() :
+    iData(NULL)
+    {
+
+    }
+
+/**
+Destructor
+*/
+EXPORT_C RMTPType::~RMTPType()
+    {
+    Close();
+    }
+    
+/**
+Pushes a cleanup item for the managed data type onto the cleanup stack. The effect 
+of which is to cause Close() to be called on the managed data type when 
+CleanupStack::PopAndDestroy() is called at some later time.
+
+@code
+...
+RMTPType x;
+...
+x.OpenL(EMTPTypeAUINT32);
+x.CleanupClosePushL();
+...
+CleanupStack::PopAndDestroy();
+...
+@endcode
+@see RMTPType::Close()
+*/
+EXPORT_C void RMTPType::CleanupClosePushL()
+    {
+    ::CleanupClosePushL(*this);
+    }
+
+/**
+Releases the storage assigned to the data type.
+@panic MTPDataTypes 5, if the type's data type identifier datacode is 
+not supported.
+*/
+EXPORT_C void RMTPType::Close()
+    {
+    if (iData)
+        {
+        switch (iData->Type())
+            {
+        case EMTPTypeINT8:
+            delete static_cast<TMTPTypeInt8*> (iData);
+            break;
+
+        case EMTPTypeUINT8:
+            delete static_cast<TMTPTypeUint8*> (iData);
+            break;
+            
+        case EMTPTypeINT16:
+            delete static_cast<TMTPTypeInt16*> (iData);
+            break;
+            
+        case EMTPTypeUINT16:
+            delete static_cast<TMTPTypeUint16*> (iData);
+            break;
+            
+        case EMTPTypeINT32:
+            delete static_cast<TMTPTypeInt32*> (iData);
+            break;
+            
+        case EMTPTypeUINT32:
+            delete static_cast<TMTPTypeUint32*> (iData);
+            break;
+            
+        case EMTPTypeINT64:
+            delete static_cast<TMTPTypeInt64*> (iData);
+            break;
+            
+        case EMTPTypeUINT64:
+            delete static_cast<TMTPTypeUint64*> (iData);
+            break;
+            
+        case EMTPTypeINT128:
+            delete static_cast<TMTPTypeInt128*> (iData);
+            break;
+            
+        case EMTPTypeUINT128:
+            delete static_cast<TMTPTypeUint128*> (iData);
+            break;
+            
+        case EMTPTypeAINT8:
+        case EMTPTypeAUINT8:
+        case EMTPTypeAINT16:
+        case EMTPTypeAUINT16:
+        case EMTPTypeAINT32:
+        case EMTPTypeAUINT32:
+        case EMTPTypeAINT64:
+        case EMTPTypeAUINT64:
+        case EMTPTypeAINT128:
+        case EMTPTypeAUINT128:
+            delete static_cast<CMTPTypeArray*> (iData);
+            break;
+            
+        case EMTPTypeString:
+            delete static_cast<CMTPTypeString*> (iData);
+            break;
+            
+        default: 
+            Destroy(iData);
+            break;
+            }
+            
+        iData = NULL;
+        }
+    }
+
+/**
+Allocates storage for the data type. By default all MTP simple (signed and 
+unsigned integer), array (signed and unsigned integer), and string types are 
+supported. Support for any other data types must be provided by a derived 
+subclass which implements suitable CreateL and Destroy methods. This method 
+will release any pre-existing allocated storage.
+@param aDataType The type's data type identifier datacode.
+@leave One of the system wide error codes, if a processing failure occurs.
+@panic MTPDataTypes 5, if the type's data type identifier datacode is 
+not supported.
+@see CreateL
+@see Destroy
+*/
+EXPORT_C void RMTPType::OpenL(TUint aDataType)
+    {
+    if (iData)
+        {
+        Close();
+        }
+        
+    iData = AllocL(aDataType);
+    if (!iData)
+        {
+        // Type is not supported. Pass to the derived class (if any).
+        iData = CreateL(aDataType);
+        }
+    }
+    
+EXPORT_C MMTPType& RMTPType::Data()
+    {
+    __ASSERT_ALWAYS(iData, Panic(EMTPTypeBadStorage));
+    return *iData;
+    }
+    
+EXPORT_C TInt RMTPType::FirstReadChunk(TPtrC8& aChunk) const
+    {
+    __ASSERT_ALWAYS(iData, Panic(EMTPTypeBadStorage));
+    return iData->FirstReadChunk(aChunk);
+    }
+
+EXPORT_C TInt RMTPType::NextReadChunk(TPtrC8& aChunk) const
+    {
+    __ASSERT_ALWAYS(iData, Panic(EMTPTypeBadStorage));
+    return iData->NextReadChunk(aChunk);
+    }
+
+EXPORT_C TInt RMTPType::FirstWriteChunk(TPtr8& aChunk)
+    {
+    __ASSERT_ALWAYS(iData, Panic(EMTPTypeBadStorage));
+    return iData->FirstWriteChunk(aChunk);
+    }
+    
+EXPORT_C TInt RMTPType::NextWriteChunk(TPtr8& aChunk)
+    {
+    __ASSERT_ALWAYS(iData, Panic(EMTPTypeBadStorage));
+    return iData->NextWriteChunk(aChunk);
+    }
+
+EXPORT_C TUint64 RMTPType::Size() const
+    {
+    __ASSERT_ALWAYS(iData, Panic(EMTPTypeBadStorage));
+    return iData->Size();
+    }
+
+EXPORT_C TUint RMTPType::Type() const
+    {
+    __ASSERT_ALWAYS(iData, Panic(EMTPTypeBadStorage));
+    return iData->Type();
+    }
+
+EXPORT_C TBool RMTPType::CommitRequired() const
+    {
+    __ASSERT_ALWAYS(iData, Panic(EMTPTypeBadStorage));
+    return iData->CommitRequired();
+    }
+
+EXPORT_C MMTPType* RMTPType::CommitChunkL(TPtr8& aChunk)
+    {
+    __ASSERT_ALWAYS(iData, Panic(EMTPTypeBadStorage));
+    return iData->CommitChunkL(aChunk);
+    }
+    
+EXPORT_C TInt RMTPType::Validate() const
+    {
+    TInt ret(KMTPDataTypeInvalid);
+    if (iData)
+        {
+        ret = iData->Validate();
+        }
+    return ret;
+    }
+    
+/**
+Allocates storage for non-default data types. Non-default data types can be 
+supported by a derived class which overides both this and the Destroy methods.
+@param aDataType The type's data type identifier datacode.
+@return A pointer to the allocated data type storage. Ownership IS transferred.
+@leave KMTPDataTypeInvalid, if the type's data type identifier datacode is 
+not supported.
+@leave One of the system wide error codes, if a processing failure occurs.
+@see Destroy
+*/
+EXPORT_C MMTPType* RMTPType::CreateL(TUint aDataType)
+    {
+    MMTPType* type(AllocL(aDataType));
+    if (!type)
+        {
+        User::Leave(KMTPDataTypeInvalid);   
+        }
+
+    return type;  
+    }
+
+/**
+Releases the storage assigned to the data type. Non-default data types can be 
+supported by a derived class which overides both this and the CreateL methods.
+@panic MTPDataTypes 5, if the type's data type identifier datacode is 
+not supported.
+@see CreateL
+*/
+EXPORT_C void RMTPType::Destroy(MMTPType* /*aType*/)
+    {
+    Panic(EMTPTypeNotSupported);
+    }
+    
+MMTPType* RMTPType::AllocL(const TUint aDataType)
+    {
+    MMTPType* type(0);
+    switch (aDataType)
+        {
+    case EMTPTypeINT8:
+        type = new(ELeave) TMTPTypeInt8();
+        break;
+        
+    case EMTPTypeUINT8:
+        type = new(ELeave) TMTPTypeUint8();
+        break;
+        
+    case EMTPTypeINT16:
+        type = new(ELeave) TMTPTypeInt16();
+        break;
+        
+    case EMTPTypeUINT16:
+        type = new(ELeave) TMTPTypeUint16();
+        break;
+        
+    case EMTPTypeINT32:
+        type = new(ELeave) TMTPTypeInt32();
+        break;
+        
+    case EMTPTypeUINT32:
+        type = new(ELeave) TMTPTypeUint32();
+        break;
+        
+    case EMTPTypeINT64:
+        type = new(ELeave) TMTPTypeInt64();
+        break;
+        
+    case EMTPTypeUINT64:
+        type = new(ELeave) TMTPTypeUint64();
+        break;
+        
+    case EMTPTypeINT128:
+        type = new(ELeave) TMTPTypeInt128();
+        break;
+        
+    case EMTPTypeUINT128:
+        type = new(ELeave) TMTPTypeUint128();
+        break;
+        
+    case EMTPTypeAINT8:
+    case EMTPTypeAUINT8:
+    case EMTPTypeAINT16:
+    case EMTPTypeAUINT16:
+    case EMTPTypeAINT32:
+    case EMTPTypeAUINT32:
+    case EMTPTypeAINT64:
+    case EMTPTypeAUINT64:
+    case EMTPTypeAINT128:
+    case EMTPTypeAUINT128:
+        type = CMTPTypeArray::NewL(aDataType);
+        break;
+        
+    case EMTPTypeString:
+        type = CMTPTypeString::NewL();
+        break;
+    case EMTPTypeDataPair:
+        {
+        type = new(ELeave) TMTPTypeDataPair();
+        }
+        break;
+    case EMTPTypeObjectPropDescDataset:
+    	type = CMTPTypeObjectPropDesc::NewL();
+    	break;
+    case EMTPTypeFormatCapabilityDataset:
+    	type = CMTPTypeFormatCapability::NewL();
+    	break;
+    case EMTPTypeServicePropDesc:
+    	type = CMTPTypeServicePropDesc::NewL();
+    	break;
+    case EMTPTypeServicePropertyElementDataset:
+    	type = CMTPTypeServicePropertyElement::NewL();
+    	break;
+    case EMTPTypeServiceFormatElementDataset:
+    	type = CMTPTypeServiceFormatElement::NewL();
+    	break;
+    case EMTPTypeServiceMethodElementDataset:
+    	type = CMTPTypeServiceMethodElement::NewL();
+    	break;
+    case EMTPTypeServiceEventElementDataset:
+    	type = CMTPTypeServiceEventElement::NewL();
+    	break; 
+    default: 
+        break;
+        }
+        
+    return type;
+    }
+
+void RMTPType::Destroy(const TUint aDataType, MMTPType* aData)
+    {
+    switch ( aDataType )
+        {
+    case EMTPTypeINT8:
+        delete static_cast<TMTPTypeInt8*> (aData);
+        break;
+
+    case EMTPTypeUINT8:
+        delete static_cast<TMTPTypeUint8*> (aData);
+        break;
+        
+    case EMTPTypeINT16:
+        delete static_cast<TMTPTypeInt16*> (aData);
+        break;
+        
+    case EMTPTypeUINT16:
+        delete static_cast<TMTPTypeUint16*> (aData);
+        break;
+        
+    case EMTPTypeINT32:
+        delete static_cast<TMTPTypeInt32*> (aData);
+        break;
+        
+    case EMTPTypeUINT32:
+        delete static_cast<TMTPTypeUint32*> (aData);
+        break;
+        
+    case EMTPTypeINT64:
+        delete static_cast<TMTPTypeInt64*> (aData);
+        break;
+        
+    case EMTPTypeUINT64:
+        delete static_cast<TMTPTypeUint64*> (aData);
+        break;
+        
+    case EMTPTypeINT128:
+        delete static_cast<TMTPTypeInt128*> (aData);
+        break;
+        
+    case EMTPTypeUINT128:
+        delete static_cast<TMTPTypeUint128*> (aData);
+        break;
+        
+    case EMTPTypeAINT8:
+    case EMTPTypeAUINT8:
+    case EMTPTypeAINT16:
+    case EMTPTypeAUINT16:
+    case EMTPTypeAINT32:
+    case EMTPTypeAUINT32:
+    case EMTPTypeAINT64:
+    case EMTPTypeAUINT64:
+    case EMTPTypeAINT128:
+    case EMTPTypeAUINT128:
+        delete static_cast<CMTPTypeArray*> (aData);
+        break;
+    case EMTPTypeString:
+        delete static_cast<CMTPTypeString*> (aData);
+        break;
+    case EMTPTypeDataPair:
+        delete static_cast<TMTPTypeDataPair*>(aData);
+        break;
+    case EMTPTypeObjectPropDescDataset:
+        delete static_cast<CMTPTypeObjectPropDesc*> (aData);
+        break;
+    case EMTPTypeFormatCapabilityDataset:
+        delete static_cast<CMTPTypeFormatCapability*> (aData);
+        break;
+    case EMTPTypeServicePropDesc:
+        delete static_cast<CMTPTypeServicePropDesc*> (aData);
+        break;
+    case EMTPTypeServicePropertyElementDataset:
+        delete static_cast<CMTPTypeServicePropertyElement*> (aData);
+        break;
+    case EMTPTypeServiceFormatElementDataset:
+        delete static_cast<CMTPTypeServiceFormatElement*> (aData);
+        break;
+    case EMTPTypeServiceMethodElementDataset:
+        delete static_cast<CMTPTypeServiceMethodElement*> (aData);
+        break;
+    case EMTPTypeServiceEventElementDataset:
+        delete static_cast<CMTPTypeServiceEventElement*> (aData);
+        break;     
+            
+    default: 
+        Panic(EMTPTypeNotSupported);
+        break;
+        }
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptypedatapair.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,66 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@publishedPartner
+*/ 
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypedatapair.h>
+
+// data pair element metadata.
+const TMTPTypeDataPair::TElementInfo TMTPTypeDataPair::iElementMetaData[ENumElements] = 
+    {
+        {EMTPTypeUINT32,    0,  KMTPTypeUINT32Size},    // EOwnerHandle
+        {EMTPTypeUINT16,    4,  KMTPTypeUINT16Size},    // EDataCode
+    };
+
+/**
+Constructor.
+*/
+EXPORT_C TMTPTypeDataPair::TMTPTypeDataPair() :
+    iElementInfo(iElementMetaData, ENumElements),
+    iBuffer(KSize)
+    {
+    SetBuffer(iBuffer);
+    }
+    
+EXPORT_C TMTPTypeDataPair::TMTPTypeDataPair( const TUint32 aHandle, const TUint16 aCode ):
+	iElementInfo(iElementMetaData, ENumElements),
+	iBuffer(KSize)
+	{
+    SetBuffer(iBuffer);
+	SetUint32( TMTPTypeDataPair::EOwnerHandle, aHandle );
+	SetUint16(TMTPTypeDataPair::EDataCode, aCode);
+	}
+
+EXPORT_C TMTPTypeDataPair::TMTPTypeDataPair(const TMTPTypeDataPair& aPair):
+    iElementInfo(iElementMetaData, ENumElements),
+    iBuffer(KSize)
+    {
+    iBuffer = aPair.iBuffer;
+    SetBuffer(iBuffer);
+    }
+
+EXPORT_C TUint TMTPTypeDataPair::Type() const
+    {
+    return EMTPTypeDataPair;
+    }
+    
+const TMTPTypeFlatBase::TElementInfo& TMTPTypeDataPair::ElementInfo(TInt aElementId) const
+    {
+    return iElementInfo[aElementId];
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptypeevent.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,62 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypeevent.h>
+
+// Dataset element metadata.
+const TMTPTypeEvent::TElementInfo TMTPTypeEvent::iElementMetaData[ENumElements] = 
+    {
+        {EMTPTypeUINT16, 0,  KMTPTypeUINT16Size},   // EEventCode
+        {EMTPTypeUINT32, 2,  KMTPTypeUINT32Size},   // ESessionID
+        {EMTPTypeUINT32, 6,  KMTPTypeUINT32Size},   // ETransactionID
+        {EMTPTypeUINT32, 10, KMTPTypeUINT32Size},   // EParameter1
+        {EMTPTypeUINT32, 14, KMTPTypeUINT32Size},   // EParameter2
+        {EMTPTypeUINT32, 18, KMTPTypeUINT32Size}    // EParameter3
+    };
+
+/**
+Constructor.
+*/
+EXPORT_C TMTPTypeEvent::TMTPTypeEvent() :
+    iElementInfo(iElementMetaData, ENumElements),
+    iBuffer(KSize)
+    {
+    SetBuffer(iBuffer);
+    }
+
+EXPORT_C TMTPTypeEvent::TMTPTypeEvent(const TMTPTypeEvent& aEvent):
+    iElementInfo(iElementMetaData, ENumElements),
+    iBuffer(KSize)
+    {
+    iBuffer = aEvent.iBuffer;
+    SetBuffer(iBuffer);
+    }
+    
+EXPORT_C TUint TMTPTypeEvent::Type() const
+    {
+    return EMTPTypeEventDataset;
+    }
+    
+EXPORT_C const TMTPTypeFlatBase::TElementInfo& TMTPTypeEvent::ElementInfo(TInt aElementId) const
+    {
+    return iElementInfo[aElementId];
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptypeflatbase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,439 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mtptypessimple.h>
+#include <mtp/tmtptypeflatbase.h>
+
+#include "mtpdatatypespanic.h"
+
+/**
+Default constructor.
+*/
+EXPORT_C TMTPTypeFlatBase::TMTPTypeFlatBase() :
+    iBuffer(NULL, 0, 0)
+    {
+    
+    }
+    
+/**
+Resets the dataset by zero filling it..
+*/
+EXPORT_C void TMTPTypeFlatBase::Reset()
+    {
+    iBuffer.FillZ();
+    } 
+    
+/**
+Provides a copy of the specified element.
+@param aElementId The identifier of the requested element.
+@param aElement The MMTPType target data buffer.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the target buffer type does not match the requested 
+element.
+*/
+EXPORT_C void TMTPTypeFlatBase::GetL(TInt aElementId, MMTPType& aElement) const
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == aElement.Type()), Panic(EMTPTypeIdMismatch));
+    
+    TBool commit(aElement.CommitRequired());
+    TBool complete(EFalse);
+    TPtr8 dest(NULL, 0);
+    TInt offset(info.iOffset);
+    
+    TInt err(aElement.FirstWriteChunk(dest));
+    while (((err == KMTPChunkSequenceCompletion) || (err == KErrNone)) && (!complete))
+        {
+        complete = (err == KMTPChunkSequenceCompletion);
+        
+        TPtrC8 src(&(iBuffer[offset]), (info.iSize - (offset - info.iOffset)));  
+        dest.Copy(src);
+        offset += dest.Length();
+        
+        if (commit)
+            {
+            aElement.CommitChunkL(dest);   
+            }
+        
+        if (!complete)
+            {
+            err = aElement.NextWriteChunk(dest);                
+            }  
+        }
+        
+    if (err != KMTPChunkSequenceCompletion)
+        {
+        User::Leave(err);            
+        }
+    }
+
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aElement The MMTPType source data buffer.
+@leave One of the system wide error code, if a processing error occurs. 
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+@panic MTPDataTypes 4, if the source buffer size does not match the requested 
+element.
+*/  
+EXPORT_C void TMTPTypeFlatBase::SetL(TInt aElementId, const MMTPType& aElement)
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == aElement.Type()), Panic(EMTPTypeIdMismatch));
+    __ASSERT_ALWAYS((info.iSize == aElement.Size()), Panic(EMTPTypeSizeMismatch));
+    
+    TBool complete(EFalse);
+    TInt offset(info.iOffset);
+    TPtrC8 src;
+    
+    TInt err(aElement.FirstReadChunk(src));
+    while (((err == KMTPChunkSequenceCompletion) || (err == KErrNone)) && (!complete))
+        {
+        __ASSERT_ALWAYS((((offset + src.Length()) - info.iOffset) <= info.iSize), Panic(EMTPTypeSizeMismatch));
+        complete = (err == KMTPChunkSequenceCompletion);
+        
+        iBuffer.Replace(offset, src.Length(), src);
+        offset += src.Length();
+        
+        if (!complete)
+            {
+            err = aElement.NextReadChunk(src);                
+            } 
+        }
+        
+    if (err != KMTPChunkSequenceCompletion)
+        {
+        User::Leave(err);            
+        }
+    }
+    
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aElement The source data.
+@panic MTPDataTypes 3, if the source data type does not match the requested 
+element.
+*/    
+EXPORT_C void TMTPTypeFlatBase::SetInt8(TInt aElementId, TInt8 aData)
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == EMTPTypeINT8), Panic(EMTPTypeIdMismatch));
+        
+    TPtrC8 data(reinterpret_cast<TUint8*>(&aData), sizeof(aData));
+    iBuffer.Replace(info.iOffset, data.Length(), data);
+    }
+    
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aElement The source data.
+@panic MTPDataTypes 3, if the source data type does not match the requested 
+element.
+*/    
+EXPORT_C void TMTPTypeFlatBase::SetInt16(TInt aElementId, TInt16 aData)
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == EMTPTypeINT16), Panic(EMTPTypeIdMismatch));
+        
+    TPtrC8 data(reinterpret_cast<TUint8*>(&aData), sizeof(aData));
+    iBuffer.Replace(info.iOffset, data.Length(), data);
+    }
+    
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aElement The source data.
+@panic MTPDataTypes 3, if the source data type does not match the requested 
+element.
+*/    
+EXPORT_C void TMTPTypeFlatBase::SetInt32(TInt aElementId, TInt32 aData)
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == EMTPTypeINT32), Panic(EMTPTypeIdMismatch));
+        
+    TPtrC8 data(reinterpret_cast<TUint8*>(&aData), sizeof(aData));
+    iBuffer.Replace(info.iOffset, data.Length(), data);
+    }
+    
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aElement The source data.
+@panic MTPDataTypes 3, if the source data type does not match the requested 
+element.
+*/    
+EXPORT_C void TMTPTypeFlatBase::SetInt64(TInt aElementId, TInt64 aData)
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == EMTPTypeINT64), Panic(EMTPTypeIdMismatch));
+        
+    TPtrC8 data(reinterpret_cast<TUint8*>(&aData), sizeof(aData));
+    iBuffer.Replace(info.iOffset, data.Length(), data);
+    }
+    
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aElement The source data.
+@panic MTPDataTypes 3, if the source data type does not match the requested 
+element.
+*/    
+EXPORT_C void TMTPTypeFlatBase::SetUint8(TInt aElementId, TUint8 aData)
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == EMTPTypeUINT8), Panic(EMTPTypeIdMismatch));
+        
+    TPtrC8 data(reinterpret_cast<TUint8*>(&aData), sizeof(aData));
+    iBuffer.Replace(info.iOffset, data.Length(), data);
+    }
+    
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aElement The source data.
+@panic MTPDataTypes 3, if the source data type does not match the requested 
+element.
+*/    
+EXPORT_C void TMTPTypeFlatBase::SetUint16(TInt aElementId, TUint16 aData)
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == EMTPTypeUINT16), Panic(EMTPTypeIdMismatch));
+        
+    TPtrC8 data(reinterpret_cast<TUint8*>(&aData), sizeof(aData));
+    iBuffer.Replace(info.iOffset, data.Length(), data);
+    }
+    
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aElement The source data.
+@panic MTPDataTypes 3, if the source data type does not match the requested 
+element.
+*/    
+EXPORT_C void TMTPTypeFlatBase::SetUint32(TInt aElementId, TUint32 aData)
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == EMTPTypeUINT32), Panic(EMTPTypeIdMismatch));
+        
+    TPtrC8 data(reinterpret_cast<TUint8*>(&aData), sizeof(aData));
+    iBuffer.Replace(info.iOffset, data.Length(), data);
+    }
+    
+/**
+Updates the specified element.
+@param aElementId The identifier of the element to update.
+@param aElement The source data.
+@panic MTPDataTypes 3, if the source data type does not match the requested 
+element.
+*/    
+EXPORT_C void TMTPTypeFlatBase::SetUint64(TInt aElementId, TUint64 aData)
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == EMTPTypeUINT64), Panic(EMTPTypeIdMismatch));
+        
+    TPtrC8 data(reinterpret_cast<TUint8*>(&aData), sizeof(aData));
+    iBuffer.Replace(info.iOffset, data.Length(), data);
+    }
+
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C TInt8 TMTPTypeFlatBase::Int8(TInt aElementId) const
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == EMTPTypeINT8), Panic(EMTPTypeIdMismatch));
+    return (static_cast<TInt8>(iBuffer[info.iOffset]));
+    }
+
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C TInt16 TMTPTypeFlatBase::Int16(TInt aElementId) const
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == EMTPTypeINT16), Panic(EMTPTypeIdMismatch));
+        
+    // memcpy the element data to avoid alignment errors.
+    TInt16 ret;
+    memcpy(&ret, &iBuffer[info.iOffset], sizeof(ret));
+    return ret;
+    }
+
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C TInt32 TMTPTypeFlatBase::Int32(TInt aElementId) const
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == EMTPTypeINT32), Panic(EMTPTypeIdMismatch));
+    
+    // memcpy the element data to avoid alignment errors.
+    TInt32 ret;
+    memcpy(&ret, &iBuffer[info.iOffset], sizeof(ret));
+    return ret;
+    }
+
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C TInt64 TMTPTypeFlatBase::Int64(TInt aElementId) const
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == EMTPTypeINT64), Panic(EMTPTypeIdMismatch));
+    
+    // memcpy the element data to avoid alignment errors.
+    TInt64 ret;
+    memcpy(&ret, &iBuffer[info.iOffset], sizeof(ret));
+    return ret;
+    }
+
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C TUint8 TMTPTypeFlatBase::Uint8(TInt aElementId) const
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == EMTPTypeUINT8), Panic(EMTPTypeIdMismatch));
+    return (static_cast<TUint8>(iBuffer[info.iOffset]));
+    }
+
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C TUint16 TMTPTypeFlatBase::Uint16(TInt aElementId) const
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == EMTPTypeUINT16), Panic(EMTPTypeIdMismatch));
+    
+    // memcpy the element data to avoid alignment errors.
+    TUint16 ret;
+    memcpy(&ret, &iBuffer[info.iOffset], sizeof(ret));
+    return ret;
+    }
+
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C TUint32 TMTPTypeFlatBase::Uint32(TInt aElementId) const
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == EMTPTypeUINT32), Panic(EMTPTypeIdMismatch));
+    
+    // memcpy the element data to avoid alignment errors.
+    TUint32 ret;
+    memcpy(&ret, &iBuffer[info.iOffset], sizeof(ret));
+    return ret;
+    }
+
+/**
+Provides the value of the specified element.
+@param aElementId The identifier of the requested element.
+@return The value of the element.
+@panic MTPDataTypes 3, if the source buffer type does not match the requested 
+element.
+*/
+EXPORT_C TUint64 TMTPTypeFlatBase::Uint64(TInt aElementId) const
+    {
+    const TElementInfo& info(ElementInfo(aElementId));
+    __ASSERT_ALWAYS((info.iType == EMTPTypeUINT64), Panic(EMTPTypeIdMismatch));
+    
+    // memcpy the element data to avoid alignment errors.
+    TUint64 ret;
+    memcpy(&ret, &iBuffer[info.iOffset], sizeof(ret));
+    return ret;
+    }
+    
+EXPORT_C TInt TMTPTypeFlatBase::FirstReadChunk(TPtrC8& aChunk) const
+    {
+    __ASSERT_ALWAYS(iBuffer.MaxLength() > 0, Panic(EMTPTypeBadStorage));
+    aChunk.Set(iBuffer);
+    return KMTPChunkSequenceCompletion;
+    }
+    
+EXPORT_C TInt TMTPTypeFlatBase::NextReadChunk(TPtrC8& aChunk) const
+    {
+    aChunk.Set(NULL, 0);
+    return KErrNotReady;
+    }
+    
+EXPORT_C TInt TMTPTypeFlatBase::FirstWriteChunk(TPtr8& aChunk)
+    {
+    __ASSERT_ALWAYS(iBuffer.MaxLength() > 0, Panic(EMTPTypeBadStorage));
+    aChunk.Set(&iBuffer[0], 0, iBuffer.MaxLength());
+    return KMTPChunkSequenceCompletion;
+    }
+    
+EXPORT_C TInt TMTPTypeFlatBase::NextWriteChunk(TPtr8& aChunk)
+    {
+    aChunk.Set(NULL, 0, 0);
+    return KErrNotReady;
+    }
+    
+EXPORT_C TUint64 TMTPTypeFlatBase::Size() const
+    {
+    return iBuffer.Size();
+    }
+
+EXPORT_C TUint TMTPTypeFlatBase::Type() const
+    {
+    return EMTPTypeFlat;        
+    }
+
+/**
+Sets the MTP dataset buffer to be managed.
+@param aBuffer The MTP dataset buffer to be managed.
+*/
+EXPORT_C void TMTPTypeFlatBase::SetBuffer(const TDes8& aBuffer)
+    {
+    iBuffer.Set(aBuffer.MidTPtr(0));
+    iBuffer.SetLength(iBuffer.MaxLength());
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptypeguid.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,185 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypeguid.h>
+
+/**
+Default constructor.
+*/
+EXPORT_C TMTPTypeGuid::TMTPTypeGuid()
+    {
+    iData.FillZ(iData.MaxLength());
+    }
+
+EXPORT_C TMTPTypeGuid::TMTPTypeGuid(const TPtrC8& aData) : 
+TMTPTypeUint128::TMTPTypeUint128(aData)
+    {
+    }
+
+  
+EXPORT_C TMTPTypeGuid::TMTPTypeGuid(const TUint64 aData1,const TUint64 aData2) 
+    {  
+    const TUint KBitsOfByte = 8;
+    const TUint KBitsOfWORD = 16;
+    TGUID guid;
+    
+    //int32
+    guid.iUint32 = I64HIGH(aData1);
+    
+    //int16[]
+    guid.iUint16[0] = ((TUint16)(I64LOW(aData1) >> KBitsOfWORD));
+    guid.iUint16[1] = ((TUint16)(I64LOW(aData1))) ;
+    //guid.iUint16[2] = ((TUint16)(I64HIGH(aData2)>> KBitsOfWORD));
+    
+    //byte[]
+    for(TInt i = 0; i< KMTPGUIDUint8Num; i++)
+        {
+        guid.iByte[KMTPGUIDUint8Num - 1 - i] = ((TUint8)(aData2 >> (KBitsOfByte * i))) ;
+        }
+    
+    iData.FillZ(iData.MaxLength());
+    memcpy(&iData[0], &guid, KMTPTypeUINT128Size);
+    }
+
+
+/**
+Sets the data type to the specified value.
+*/  
+EXPORT_C void TMTPTypeGuid::Set(const TUint64 aData1,const TUint64 aData2)
+	{   
+    const TUint KBitsOfByte = 8;
+    const TUint KBitsOfWORD = 16;
+    TGUID guid;
+    
+    //int32
+    guid.iUint32 = I64HIGH(aData1);
+    
+    //int16[]
+    guid.iUint16[0] = ((TUint16)(I64LOW(aData1) >> KBitsOfWORD));
+    guid.iUint16[1] = ((TUint16)(I64LOW(aData1))) ;
+    //guid.iUint16[2] = ((TUint16)(I64HIGH(aData2)>> KBitsOfWORD));
+    
+    //byte[]
+    for(TInt i = 0; i< KMTPGUIDUint8Num; i++)
+        {
+        guid.iByte[KMTPGUIDUint8Num - 1 - i] = ((TUint8)(aData2 >> (KBitsOfByte * i))) ;
+        }
+    
+    memcpy(&iData[0], &guid, KMTPTypeUINT128Size);
+	}
+
+EXPORT_C TInt TMTPTypeGuid::SetL(const TDesC& aData)
+	{
+	TInt ret = KErrNone;
+	TGUID guid;
+	
+	ret = IsGuidFormat(aData);
+	
+	if ( ret != KErrNone )
+		{
+		return ret;
+		}
+	
+	RBuf buf;
+	buf.CleanupClosePushL();
+	buf.Create(aData);		
+	TPtr8 guidPtr = buf.Collapse();			
+	TInt length = guidPtr.Length();
+	TInt offset = 0;
+	
+	TPtrC8 dataStr1(&guidPtr[offset], 8);
+	TLex8 t1(dataStr1);
+	offset += 9;
+	ret = t1.Val(guid.iUint32, EHex);
+	
+	TPtrC8 dataStr2(&guidPtr[offset], 4);
+	TLex8 t2(dataStr2);
+	offset += 5;
+	ret = t2.Val(guid.iUint16[0], EHex);
+	
+	TPtrC8 dataStr3(&guidPtr[offset], 4);
+	TLex8 t3(dataStr3);
+	offset += 5;
+	ret = t3.Val(guid.iUint16[1], EHex);
+	
+	TInt index = 0;
+	for (TInt i(offset); (i<23); i = i+2)
+		{
+		TPtrC8 dataStr4(&guidPtr[offset], 2);
+		TLex8 t4(dataStr4);
+		offset += 2;
+		ret = t4.Val(guid.iByte[index++], EHex);
+		}
+	offset++;
+	for (TInt i(offset); (i<length); i = i+2)
+		{
+		TPtrC8 dataStr5(&guidPtr[offset], 2);
+		TLex8 t5(dataStr5);
+		offset += 2;
+		ret = t5.Val(guid.iByte[index++], EHex);
+		}
+	
+	memcpy(&iData[0], &guid, KMTPTypeUINT128Size);
+	
+	CleanupStack::PopAndDestroy(&buf);
+	
+	return ret;
+	}
+ 
+TInt TMTPTypeGuid::IsGuidFormat(const TDesC& aData)
+	{
+	TInt ret = KErrNone;
+	
+	//verify GUID style data xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
+	RBuf buf;
+	buf.CleanupClosePushL();
+	buf.Create(aData);		
+	TPtr8 guidPtr = buf.Collapse();			
+	TInt length = guidPtr.Length();
+	
+	if ( length == 36 )
+		{
+		for ( TInt i=0;i<length;++i)
+			{
+			TChar c(guidPtr[i]);
+			if ( !c.IsHexDigit() )
+				{
+				if ( (guidPtr[i]=='-') && (i==8 || i==13 || i==18 || i==23) )
+					{}
+				else
+					{
+					ret = KErrArgument;
+					}
+				}
+			}
+		}
+	else
+		{
+		ret = KErrArgument;
+		}
+	CleanupStack::PopAndDestroy(&buf);
+	
+	return ret;
+	}
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptypeint128.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,107 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypeint128.h>
+
+/**
+Default constructor.
+*/
+EXPORT_C TMTPTypeInt128::TMTPTypeInt128()
+    {
+    iData.FillZ(iData.MaxLength());
+    }
+
+/**
+Conversion constructor.
+*/
+EXPORT_C TMTPTypeInt128::TMTPTypeInt128(const TPtrC8& aData) : 
+    iData(aData)
+    {
+    }
+    
+/**
+Sets the data type to the specified value.
+*/  
+EXPORT_C void TMTPTypeInt128::Set(TInt64 aUpperValue, TUint64 aLowerValue)
+	{
+    memcpy(&iData[KMTPTypeInt128OffsetMS], &aUpperValue, sizeof(aUpperValue));
+    memcpy(&iData[KMTPTypeInt128OffsetLS], &aLowerValue, sizeof(aLowerValue));
+	}
+
+/**
+Provides the least significant portion of the data type.
+@return The least significant 64 bits of the value.
+*/    
+EXPORT_C TUint64 TMTPTypeInt128::LowerValue() const
+    {    
+    // memcpy the data to avoid alignment errors.
+    TInt64 ret;
+    memcpy(&ret, &iData[KMTPTypeInt128OffsetLS], sizeof(ret));
+    return ret;
+    }
+
+/**
+Provides the most significant portion of type's value.
+@return The most significant 64 bits of the value.
+*/    
+EXPORT_C TInt64 TMTPTypeInt128::UpperValue() const
+    {
+    // memcpy the data to avoid alignment errors.
+    TInt64 ret;
+    memcpy(&ret, &iData[KMTPTypeInt128OffsetMS], sizeof(ret));
+    return ret;
+    }  
+	
+EXPORT_C TInt TMTPTypeInt128::FirstReadChunk(TPtrC8& aChunk) const
+    {
+	aChunk.Set(iData);
+    return KMTPChunkSequenceCompletion;
+    }
+	
+EXPORT_C TInt TMTPTypeInt128::NextReadChunk(TPtrC8& aChunk) const
+    {
+    aChunk.Set(NULL, 0);
+    return KErrNotReady;
+    }
+	
+EXPORT_C TInt TMTPTypeInt128::FirstWriteChunk(TPtr8& aChunk)
+    {
+	aChunk.Set(&iData[0], 0, iData.MaxLength());
+    return KMTPChunkSequenceCompletion;
+    }
+	
+EXPORT_C TInt TMTPTypeInt128::NextWriteChunk(TPtr8& aChunk)
+    {
+    aChunk.Set(NULL, 0, 0);
+    return KErrNotReady;
+    }
+
+EXPORT_C TUint64 TMTPTypeInt128::Size() const
+    {
+    return iData.MaxLength();
+    }
+    
+EXPORT_C TUint TMTPTypeInt128::Type() const
+    {
+    return EMTPTypeINT128;
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptypeint16.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,59 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypeint16.h>
+
+/**
+Default constructor.
+*/
+EXPORT_C TMTPTypeInt16::TMTPTypeInt16() :
+    TMTPTypeIntBase(0, KMTPTypeINT16Size, EMTPTypeINT16)
+    {
+    
+    }
+
+/**
+Conversion constructor.
+@param aData The initial data value.
+*/
+EXPORT_C TMTPTypeInt16::TMTPTypeInt16(TInt16 aData) : 
+    TMTPTypeIntBase(aData, KMTPTypeINT16Size, EMTPTypeINT16)
+    {
+    
+    }
+
+/**
+Sets the data type to the specified value.
+*/  
+EXPORT_C void TMTPTypeInt16::Set(TInt16 aValue)
+	{
+	iData = aValue;
+	}
+    
+/**
+Provides data types's value.
+@return The value of the data type
+*/   
+EXPORT_C TInt16 TMTPTypeInt16::Value() const
+	{
+	return static_cast<TInt16>(iData);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptypeint32.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,59 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypeint32.h>
+
+/**
+Default constructor.
+*/
+EXPORT_C TMTPTypeInt32::TMTPTypeInt32() :
+    TMTPTypeIntBase(0, KMTPTypeINT32Size, EMTPTypeINT32)
+    {
+    
+    }
+
+/**
+Conversion constructor.
+@param aData The initial data value.
+*/
+EXPORT_C TMTPTypeInt32::TMTPTypeInt32(TInt32 aData) : 
+    TMTPTypeIntBase(aData, KMTPTypeINT32Size, EMTPTypeINT32)
+    {
+    
+    }
+
+/**
+Sets the data type to the specified value.
+*/  
+EXPORT_C void TMTPTypeInt32::Set(TInt32 aValue)
+	{
+	iData = aValue;
+	}
+    
+/**
+Provides data types's value.
+@return The value of the data type
+*/   
+EXPORT_C TInt32 TMTPTypeInt32::Value() const
+	{
+	return static_cast<TInt32>(iData);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptypeint64.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,99 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypeint64.h>
+
+/**
+Default constructor.
+*/
+EXPORT_C TMTPTypeInt64::TMTPTypeInt64() :
+    iData(0)
+    {
+    
+    }
+
+/**
+Conversion constructor from native type.
+*/
+EXPORT_C TMTPTypeInt64::TMTPTypeInt64(TInt64 aData) : 
+    iData(aData)
+    {
+    
+    }
+
+/**
+Destructor
+*/
+EXPORT_C TMTPTypeInt64::~TMTPTypeInt64()
+    {
+
+    }
+    
+/**
+Sets the data type to the specified value.
+*/      
+EXPORT_C void TMTPTypeInt64::Set(TInt64 aValue)
+	{
+	iData = aValue;
+	} 
+    
+/**
+Provides data types's value.
+@return The value of the data type
+*/   
+EXPORT_C TInt64 TMTPTypeInt64::Value() const
+	{
+	return iData;
+	} 
+	
+EXPORT_C TInt TMTPTypeInt64::FirstReadChunk(TPtrC8& aChunk) const
+    {
+	aChunk.Set(reinterpret_cast<const TUint8*>(&iData), sizeof(iData));
+    return KMTPChunkSequenceCompletion;
+    }
+	
+EXPORT_C TInt TMTPTypeInt64::NextReadChunk(TPtrC8& aChunk) const
+    {
+    aChunk.Set(NULL, 0);
+    return KErrNotReady;
+    }
+	
+EXPORT_C TInt TMTPTypeInt64::FirstWriteChunk(TPtr8& aChunk)
+    {
+	aChunk.Set(reinterpret_cast<TUint8*>(&iData), 0, sizeof(iData));
+    return KMTPChunkSequenceCompletion;
+    }
+	
+EXPORT_C TInt TMTPTypeInt64::NextWriteChunk(TPtr8& aChunk)
+    {
+    aChunk.Set(NULL, 0, 0);
+    return KErrNotReady;
+    }
+	
+EXPORT_C TUint64 TMTPTypeInt64::Size() const
+	{
+	return sizeof(iData);
+	}
+	
+EXPORT_C TUint TMTPTypeInt64::Type() const
+	{
+	return EMTPTypeINT64;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptypeint8.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,59 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypeint8.h>
+
+/**
+Default constructor.
+*/
+EXPORT_C TMTPTypeInt8::TMTPTypeInt8() :
+    TMTPTypeIntBase(0, KMTPTypeINT8Size, EMTPTypeINT8)
+    {
+    
+    }
+
+/**
+Conversion constructor.
+@param aData The initial data value.
+*/
+EXPORT_C TMTPTypeInt8::TMTPTypeInt8(TInt8 aData) : 
+    TMTPTypeIntBase(aData, KMTPTypeINT8Size, EMTPTypeINT8)
+    {
+    
+    }
+
+/**
+Sets the data type to the specified value.
+*/  
+EXPORT_C void TMTPTypeInt8::Set(TInt8 aValue)
+	{
+	iData = aValue;
+	}
+    
+/**
+Provides data types's value.
+@return The value of the data type
+*/   
+EXPORT_C TInt8 TMTPTypeInt8::Value() const
+	{
+	return static_cast<TInt8>(iData);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptypeintbase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,72 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypeintbase.h>
+    
+EXPORT_C TInt TMTPTypeIntBase::FirstReadChunk(TPtrC8& aChunk) const
+    {
+	aChunk.Set(reinterpret_cast<const TUint8*>(&iData), iSize);
+    return KMTPChunkSequenceCompletion;
+    }
+	
+EXPORT_C TInt TMTPTypeIntBase::NextReadChunk(TPtrC8& aChunk) const
+    {
+    aChunk.Set(NULL, 0);
+    return KErrNotReady;
+    }
+	
+EXPORT_C TInt TMTPTypeIntBase::FirstWriteChunk(TPtr8& aChunk)
+    {
+	aChunk.Set(reinterpret_cast<TUint8*>(&iData), 0, iSize);
+    return KMTPChunkSequenceCompletion;
+    }
+	
+EXPORT_C TInt TMTPTypeIntBase::NextWriteChunk(TPtr8& aChunk)
+    {
+    aChunk.Set(NULL, 0, 0);
+    return KErrNotReady;
+    }
+	
+EXPORT_C TUint64 TMTPTypeIntBase::Size() const
+	{
+	return iSize;
+	}
+	
+EXPORT_C TUint TMTPTypeIntBase::Type() const
+	{
+	return iType;
+	}
+
+/**
+Constructor.
+@param aData The INT data with which the type is to be initialised.
+@param aSize The size of the INT data type.
+@param aType The INT data type code.
+*/
+EXPORT_C TMTPTypeIntBase::TMTPTypeIntBase(TInt aData, TUint aSize, TInt aType) : 
+    iData(aData),
+    iSize(aSize),
+    iType(aType)
+    {
+    
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptypenull.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,76 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypenull.h>
+
+#include "mtpdatatypespanic.h"
+
+/**
+Default constructor.
+*/
+EXPORT_C TMTPTypeNull::TMTPTypeNull() :
+	iNullBuffer(NULL, 0, 0)
+    {
+    }
+
+/**
+Sets the data sink buffer to be used in write data stream operations.
+@param aBuffer The data sink buffer.
+*/
+    
+EXPORT_C void TMTPTypeNull::SetBuffer(const TDes8& aBuffer)
+	{
+	iNullBuffer.Set(aBuffer.MidTPtr(0));
+	}
+    
+EXPORT_C TInt TMTPTypeNull::FirstReadChunk(TPtrC8& aChunk) const
+    {
+    aChunk.Set(KNullDesC8);
+    return KMTPChunkSequenceCompletion;
+    }
+    
+EXPORT_C TInt TMTPTypeNull::NextReadChunk(TPtrC8& aChunk) const
+    {
+    aChunk.Set(KNullDesC8);
+    return KErrNotReady;
+    }
+    
+EXPORT_C TInt TMTPTypeNull::FirstWriteChunk(TPtr8& aChunk)
+    {
+    aChunk.Set(&iNullBuffer[0], 0, iNullBuffer.MaxLength());
+    return KErrNone;
+    }
+    
+EXPORT_C TInt TMTPTypeNull::NextWriteChunk(TPtr8& aChunk)
+	{
+    aChunk.Set(&iNullBuffer[0], 0, iNullBuffer.MaxLength());
+    return KErrNone;
+    }
+    
+EXPORT_C TUint64 TMTPTypeNull::Size() const
+    {
+    return 0;
+    }
+
+EXPORT_C TUint TMTPTypeNull::Type() const
+    {
+    return EMTPTypeUndefined;        
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptyperequest.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,84 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptyperequest.h>
+
+// Dataset element metadata.
+const TMTPTypeRequest::TElementInfo TMTPTypeRequest::iElementMetaData[ENumElements] = 
+    {
+        {EMTPTypeUINT16, 0,  KMTPTypeUINT16Size},   // ERequestOperationCode
+        {EMTPTypeUINT32, 2,  KMTPTypeUINT32Size},   // ERequestSessionID
+        {EMTPTypeUINT32, 6,  KMTPTypeUINT32Size},   // ERequestTransactionID
+        {EMTPTypeUINT32, 10, KMTPTypeUINT32Size},   // ERequestParameter1  
+        {EMTPTypeUINT32, 14, KMTPTypeUINT32Size},   // ERequestParameter2
+        {EMTPTypeUINT32, 18, KMTPTypeUINT32Size},   // ERequestParameter3
+        {EMTPTypeUINT32, 22, KMTPTypeUINT32Size},   // ERequestParameter4
+        {EMTPTypeUINT32, 26, KMTPTypeUINT32Size},   // ERequestParameter5
+    };
+
+/**
+Constructor.
+*/
+EXPORT_C TMTPTypeRequest::TMTPTypeRequest() :
+    iElementInfo(iElementMetaData, ENumElements),
+    iBuffer(KSize)
+    {
+    SetBuffer(iBuffer);
+    }	
+    
+/**
+Equality operator.
+@param aRequest The request to compare against this TMTPTypeRequest.
+@return ETrue if the two TMTPTypeRequests are equal, otherwise EFalse. 
+*/	
+EXPORT_C TBool TMTPTypeRequest::operator==(const TMTPTypeRequest& aRequest) const
+	{
+	return iBuffer == aRequest.iBuffer;
+	}
+    
+/**
+Inequality operator.
+@param aRequest The request to compare against this TMTPTypeRequest.
+@return ETrue if the two TMTPTypeRequests are different, otherwise EFalse. 
+*/	
+EXPORT_C TBool TMTPTypeRequest::operator!=(const TMTPTypeRequest& aRequest) const
+	{
+	return !(*this == aRequest);
+	}
+
+EXPORT_C TMTPTypeRequest::TMTPTypeRequest(const TMTPTypeRequest& aRequest):
+    iElementInfo(iElementMetaData, ENumElements),
+    iBuffer(KSize)
+    {
+    iBuffer = aRequest.iBuffer;
+    SetBuffer(iBuffer);
+    }
+
+EXPORT_C TUint TMTPTypeRequest::Type() const
+    {
+    return EMTPTypeRequestDataset;
+    }
+    
+EXPORT_C const TMTPTypeFlatBase::TElementInfo& TMTPTypeRequest::ElementInfo(TInt aElementId) const
+    {
+    return iElementInfo[aElementId];
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptyperesponse.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,63 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptyperesponse.h>
+
+// Dataset element metadata.
+const TMTPTypeResponse::TElementInfo TMTPTypeResponse::iElementMetaData[ENumElements] = 
+    {
+        {EMTPTypeUINT16,    0,  KMTPTypeUINT16Size},    // EResponseCode
+        {EMTPTypeUINT32,    2,  KMTPTypeUINT32Size},    // EResponseSessionID
+        {EMTPTypeUINT32,    6,  KMTPTypeUINT32Size},    // EResponseTransactionID
+        {EMTPTypeUINT32,    10, KMTPTypeUINT32Size},    // EResponseParameter1
+        {EMTPTypeUINT32,    14, KMTPTypeUINT32Size},    // EResponseParameter2
+        {EMTPTypeUINT32,    18, KMTPTypeUINT32Size},    // EResponseParameter3
+        {EMTPTypeUINT32,    22, KMTPTypeUINT32Size},    // EResponseParameter4
+        {EMTPTypeUINT32,    26, KMTPTypeUINT32Size},    // EResponseParameter5
+    };
+
+/**
+Constructor.
+*/
+EXPORT_C TMTPTypeResponse::TMTPTypeResponse() :
+    iElementInfo(iElementMetaData, ENumElements),
+    iBuffer(KSize)
+    {
+    SetBuffer(iBuffer);
+    }
+
+EXPORT_C TMTPTypeResponse::TMTPTypeResponse(const TMTPTypeResponse& aResponse):
+    iElementInfo(iElementMetaData, ENumElements),
+    iBuffer(KSize)
+    {
+    iBuffer = aResponse.iBuffer;
+    SetBuffer(iBuffer);
+    }
+
+EXPORT_C TUint TMTPTypeResponse::Type() const
+    {
+    return EMTPTypeResponseDataset;
+    }
+    
+EXPORT_C const TMTPTypeFlatBase::TElementInfo& TMTPTypeResponse::ElementInfo(TInt aElementId) const
+    {
+    return iElementInfo[aElementId];
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptypeuint128.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,149 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypeuint128.h>
+
+/**
+Default constructor.
+*/
+EXPORT_C TMTPTypeUint128::TMTPTypeUint128()
+    {
+    iData.FillZ(iData.MaxLength());
+    }
+
+/**
+Conversion constructor.
+@param aData The initial data value.
+*/
+EXPORT_C TMTPTypeUint128::TMTPTypeUint128(const TPtrC8& aData) : 
+    iData(aData)
+    {
+    }
+    
+/**
+Conversion constructor.
+@param aUpperGUID the most significant 64 bits: TUint32 and TUint16[2]
+@param aLowerGUID the lowest  64 bits : TUint8[8]
+*/
+EXPORT_C TMTPTypeUint128::TMTPTypeUint128(const TUint64 aUpperValue, const TUint64 aLowerValue) 
+    {  
+    iData.FillZ(iData.MaxLength());
+    memcpy(&iData[KMTPTypeUint128OffsetMS], &aUpperValue, sizeof(aUpperValue));
+    memcpy(&iData[KMTPTypeUint128OffsetLS], &aLowerValue, sizeof(aLowerValue));
+    }
+
+
+/**
+Sets the data type to the specified value.
+*/  
+EXPORT_C void TMTPTypeUint128::Set(TUint64 aUpperValue, TUint64 aLowerValue)
+	{   
+    memcpy(&iData[KMTPTypeUint128OffsetMS], &aUpperValue, sizeof(aUpperValue));
+    memcpy(&iData[KMTPTypeUint128OffsetLS], &aLowerValue, sizeof(aLowerValue));
+	}
+
+/**
+Provides the least significant portion of the data type.
+@return The least significant 64 bits of the value.
+*/    
+EXPORT_C TUint64 TMTPTypeUint128::LowerValue() const
+    {    
+    // memcpy the data to avoid alignment errors.
+    TUint64 ret;
+    memcpy(&ret, &iData[KMTPTypeUint128OffsetLS], sizeof(ret));
+    return ret;
+    }
+
+/**
+Provides the most significant portion of type's value.
+@return The most significant 64 bits of the value.
+*/    
+EXPORT_C TUint64 TMTPTypeUint128::UpperValue() const
+    {
+    // memcpy the data to avoid alignment errors.
+    TUint64 ret;
+    memcpy(&ret, &iData[KMTPTypeUint128OffsetMS], sizeof(ret));
+    return ret;
+    }
+
+	
+EXPORT_C TInt TMTPTypeUint128::FirstReadChunk(TPtrC8& aChunk) const
+    {
+	aChunk.Set(iData);
+    return KMTPChunkSequenceCompletion;
+    }
+	
+EXPORT_C TInt TMTPTypeUint128::NextReadChunk(TPtrC8& aChunk) const
+    {
+    aChunk.Set(NULL, 0);
+    return KErrNotReady;
+    }
+	
+EXPORT_C TInt TMTPTypeUint128::FirstWriteChunk(TPtr8& aChunk)
+    {
+	aChunk.Set(&iData[0], 0, iData.MaxLength());
+    return KMTPChunkSequenceCompletion;
+    }
+	
+EXPORT_C TInt TMTPTypeUint128::NextWriteChunk(TPtr8& aChunk)
+    {
+    aChunk.Set(NULL, 0, 0);
+    return KErrNotReady;
+    }
+
+EXPORT_C TUint64 TMTPTypeUint128::Size() const
+    {
+    return iData.MaxLength();
+    }
+    
+EXPORT_C TUint TMTPTypeUint128::Type() const
+    {
+    return EMTPTypeUINT128;
+    }
+
+EXPORT_C TBool TMTPTypeUint128::Equal(const TMTPTypeUint128& aR) const
+    {
+    return ( (this->UpperValue() == aR.UpperValue()) && (this->LowerValue() == aR.LowerValue()) );
+    }
+
+EXPORT_C TInt TMTPTypeUint128::Compare(const TMTPTypeUint128& aR) const
+    {  
+    return this->Compare(aR.UpperValue(),aR.LowerValue());
+    }
+
+EXPORT_C TInt TMTPTypeUint128::Compare(const TUint64 aRUpper, const TUint64 aRLower) const
+    {
+    TUint64 tmp = this->UpperValue();
+    if( tmp != aRUpper)
+        {
+        return ( tmp > aRUpper ) ? 1 : -1;
+        }
+    
+    tmp = this->LowerValue();
+    if ( tmp != aRLower )
+        {
+        return ( tmp > aRLower ) ? 1 : -1;
+        }
+ 
+    return 0;
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptypeuint16.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,59 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypeuint16.h>
+
+/**
+Default constructor.
+*/
+EXPORT_C TMTPTypeUint16::TMTPTypeUint16() :
+    TMTPTypeUintBase(0, KMTPTypeUINT16Size, EMTPTypeUINT16)
+    {
+    
+    }
+
+/**
+Conversion constructor.
+@param aData The initial data value.
+*/
+EXPORT_C TMTPTypeUint16::TMTPTypeUint16(TUint16 aData) : 
+    TMTPTypeUintBase(aData, KMTPTypeUINT16Size, EMTPTypeUINT16)
+    {
+    
+    }
+
+/**
+Sets the data type to the specified value.
+*/  
+EXPORT_C void TMTPTypeUint16::Set(TUint16 aValue)
+	{
+	iData = aValue;
+	}
+    
+/**
+Provides data types's value.
+@return The value of the data type
+*/   
+EXPORT_C TUint16 TMTPTypeUint16::Value() const
+	{
+	return static_cast<TUint16>(iData);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptypeuint32.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,59 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypeuint32.h>
+
+/**
+Default constructor.
+*/
+EXPORT_C TMTPTypeUint32::TMTPTypeUint32() :
+    TMTPTypeUintBase(0, KMTPTypeUINT32Size, EMTPTypeUINT32)
+    {
+    
+    }
+
+/**
+Conversion constructor.
+@param aData The initial data value.
+*/
+EXPORT_C TMTPTypeUint32::TMTPTypeUint32(TUint32 aData) : 
+    TMTPTypeUintBase(aData, KMTPTypeUINT32Size, EMTPTypeUINT32)
+    {
+    
+    }
+
+/**
+Sets the data type to the specified value.
+*/  
+EXPORT_C void TMTPTypeUint32::Set(TUint32 aValue)
+	{
+	iData = aValue;
+	}
+    
+/**
+Provides data types's value.
+@return The value of the data type
+*/   
+EXPORT_C TUint32 TMTPTypeUint32::Value() const
+	{
+	return static_cast<TUint32>(iData);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptypeuint64.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,91 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypeuint64.h>
+
+/**
+Default constructor.
+*/
+EXPORT_C TMTPTypeUint64::TMTPTypeUint64() :
+    iData(0)
+    {
+    
+    }
+
+/**
+Conversion constructor from native type.
+*/
+EXPORT_C TMTPTypeUint64::TMTPTypeUint64(TUint64 aData) : 
+    iData(aData)
+    {
+    
+    }
+    
+/**
+Sets the data type to the specified value.
+*/  
+EXPORT_C void TMTPTypeUint64::Set(TUint64 aValue)
+	{
+	iData = aValue;
+	}
+    
+/**
+Provides data types's value.
+@return The value of the data type
+*/   
+EXPORT_C TUint64 TMTPTypeUint64::Value() const
+	{
+	return iData;
+	}
+	
+EXPORT_C TInt TMTPTypeUint64::FirstReadChunk(TPtrC8& aChunk) const
+    {
+	aChunk.Set(reinterpret_cast<const TUint8*>(&iData), sizeof(iData));
+    return KMTPChunkSequenceCompletion;
+    }
+	
+EXPORT_C TInt TMTPTypeUint64::NextReadChunk(TPtrC8& aChunk) const
+    {
+    aChunk.Set(NULL, 0);
+    return KErrNotReady;
+    }
+	
+EXPORT_C TInt TMTPTypeUint64::FirstWriteChunk(TPtr8& aChunk)
+    {
+	aChunk.Set(reinterpret_cast<TUint8*>(&iData), 0, sizeof(iData));
+    return KMTPChunkSequenceCompletion;
+    }
+	
+EXPORT_C TInt TMTPTypeUint64::NextWriteChunk(TPtr8& aChunk)
+    {
+    aChunk.Set(NULL, 0, 0);
+    return KErrNotReady;
+    }
+	
+EXPORT_C TUint64 TMTPTypeUint64::Size() const
+	{
+	return sizeof(iData);
+	}
+	
+EXPORT_C TUint TMTPTypeUint64::Type() const
+	{
+	return EMTPTypeUINT64;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptypeuint8.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,59 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypeuint8.h>
+
+/**
+Default constructor.
+*/
+EXPORT_C TMTPTypeUint8::TMTPTypeUint8() :
+    TMTPTypeUintBase(0, KMTPTypeUINT8Size, EMTPTypeUINT8)
+    {
+    
+    }
+
+/**
+Conversion constructor.
+@param aData The initial data value.
+*/
+EXPORT_C TMTPTypeUint8::TMTPTypeUint8(TUint8 aData) : 
+    TMTPTypeUintBase(aData, KMTPTypeUINT8Size, EMTPTypeUINT8)
+    {
+    
+    }
+
+/**
+Sets the data type to the specified value.
+*/  
+EXPORT_C void TMTPTypeUint8::Set(TUint8 aValue)
+	{
+	iData = aValue;
+	}
+    
+/**
+Provides data types's value.
+@return The value of the data type
+*/   
+EXPORT_C TUint8 TMTPTypeUint8::Value() const
+	{
+	return static_cast<TUint8>(iData);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/datatypes/src/tmtptypeuintbase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,71 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/tmtptypeuintbase.h>
+    
+EXPORT_C TInt TMTPTypeUintBase::FirstReadChunk(TPtrC8& aChunk) const
+    {
+	aChunk.Set(reinterpret_cast<const TUint8*>(&iData), iSize);
+    return KMTPChunkSequenceCompletion;
+    }
+	
+EXPORT_C TInt TMTPTypeUintBase::NextReadChunk(TPtrC8& aChunk) const
+    {
+    aChunk.Set(NULL, 0);
+    return KErrNotReady;
+    }
+	
+EXPORT_C TInt TMTPTypeUintBase::FirstWriteChunk(TPtr8& aChunk)
+    {
+	aChunk.Set(reinterpret_cast<TUint8*>(&iData), 0, iSize);
+    return KMTPChunkSequenceCompletion;
+    }
+	
+EXPORT_C TInt TMTPTypeUintBase::NextWriteChunk(TPtr8& aChunk)
+    {
+    aChunk.Set(NULL, 0, 0);
+    return KErrNotReady;
+    }
+	
+EXPORT_C TUint64 TMTPTypeUintBase::Size() const
+	{
+	return iSize;
+	}
+	
+EXPORT_C TUint TMTPTypeUintBase::Type() const
+	{
+	return iType;
+	}
+
+/**
+Constructor.
+@param aData The UINT data with which the type is to be initialised.
+@param aSize The size of the UINT data type.
+@param aType The UINT data type code.
+*/
+EXPORT_C TMTPTypeUintBase::TMTPTypeUintBase(TUint aData, TUint aSize, TInt aType) : 
+    iData(aData),
+    iSize(aSize),
+    iType(aType)
+    {
+    
+    }
+
Binary file mtpfws/mtpfw/group/10282FCC_ARMV5.cre has changed
Binary file mtpfws/mtpfw/group/10282FCC_ARMV5.txt has changed
Binary file mtpfws/mtpfw/group/10282FCC_WINSCW.cre has changed
Binary file mtpfws/mtpfw/group/10282FCC_WINSCW.txt has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/group/backup_registration.xml	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,9 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration> 
+	<proxy_data_manager sid = "0x10202BE9"/>
+  	<passive_backup>
+		<include_directory name = "\">
+			<exclude name = "\nobackup\" />
+		</include_directory>
+	</passive_backup>
+</backup_registration> 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,44 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// MTP framework.
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include            "../daemon/group/bld.inf"
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES 
+mtpframework.mmp
+
+PRJ_EXPORTS
+// repositories exported for TechView and testing
+10282FCC_ARMV5.cre  /epoc32/data/z/private/10202be9/10282fcc.cre
+10282FCC_WINSCW.cre /epoc32/release/winscw/udeb/z/private/10202be9/10282fcc.cre
+10282FCC_WINSCW.cre /epoc32/release/winscw/urel/z/private/10202be9/10282fcc.cre
+backup_registration.xml  /epoc32/data/z/private/102827a2/backup_registration.xml
+backup_registration.xml /epoc32/release/winscw/udeb/z/private/102827a2/backup_registration.xml
+backup_registration.xml /epoc32/release/winscw/urel/z/private/102827a2/backup_registration.xml
+
+// ConfML Files
+../conf/mtpframework.confml                 MW_LAYER_EXPORTS_CONFML(mtpframework.confml)
+../conf/mtpframework_10282fcc.crml	        MW_LAYER_EXPORTS_CRML(mtpframework_10282fcc.crml)
+
+mtp_framework.iby   /epoc32/rom/include/mtp_framework.iby
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/group/centrep_compile.cmd	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,78 @@
+@ECHO OFF
+rem Copyright (c) 2006-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 Script to convert a central repository text file to a binary format. The 
+rem source file should be located in the current default directory, and should 
+rem be named as follows:
+rem <UID>_<platform>.txt (e.g 10282FCC_ARMV5.txt).
+rem The binary format target file is created in the current default directory.
+rem 
+rem
+
+SET RETURNCODE=0
+
+SET _UID=%1
+SET _PLATFORM=%2
+
+IF "%_UID%"=="" GOTO HELP
+IF "%_PLATFORM%"=="" SET _PLATFORM=BOTH
+
+IF /I "%_PLATFORM%"=="ARMV5" GOTO ARMV5
+IF /I "%_PLATFORM%"=="WINSCW" GOTO WINSCW
+IF /I "%_PLATFORM%"=="BOTH" GOTO WINSCW
+GOTO DONE
+
+:WINSCW
+SET _SOURCE=%_UID%_winscw.txt
+SET _TARGET=%_UID%_winscw.cre
+IF EXIST %_SOURCE% GOTO WINSCW_COMPILE
+ECHO %_SOURCE% not found
+GOTO WINSCW_DONE
+
+:WINSCW_COMPILE
+ECHO Compiling %_SOURCE% as %_TARGET%
+COPY %_SOURCE% %EPOCROOT%epoc32\winscw\c\%_UID%.txt
+CALL %EPOCROOT%epoc32\release\winscw\udeb\CentRepConv -nowait -o C:\%_UID%.cre C:\%_UID%.txt
+COPY %EPOCROOT%epoc32\winscw\c\%_UID%.cre %_TARGET% 
+ERASE %EPOCROOT%epoc32\winscw\c\%_UID%.cre
+ERASE %EPOCROOT%epoc32\winscw\c\%_UID%.txt
+
+:WINSCW_DONE
+IF /I NOT "%_PLATFORM%"=="BOTH" GOTO DONE
+
+:ARMV5
+SET _SOURCE=%_UID%_armv5.txt
+SET _TARGET=%_UID%_armv5.cre
+IF EXIST %_SOURCE% GOTO ARMV5_COMPILE
+ECHO %_SOURCE% not found
+GOTO ARMV5_DONE
+
+:ARMV5_COMPILE
+ECHO Compiling %_SOURCE% as %_TARGET%
+COPY %_SOURCE% %EPOCROOT%epoc32\winscw\c\%_UID%.txt
+CALL %EPOCROOT%epoc32\release\winscw\udeb\CentRepConv -nowait -o C:\%_UID%.cre C:\%_UID%.txt
+COPY %EPOCROOT%epoc32\winscw\c\%_UID%.cre %_TARGET% 
+ERASE %EPOCROOT%epoc32\winscw\c\%_UID%.cre
+ERASE %EPOCROOT%epoc32\winscw\c\%_UID%.txt
+
+:ARMV5_DONE
+GOTO DONE
+
+:HELP
+SET _SYNTAX="%0% <UID> [WINSCW|ARMV5]"
+ECHO Syntax: %_SYNTAX%
+GOTO DONE
+
+:DONE
+EXIT /B %RETURNCODE%
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/group/mtp_framework.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,69 @@
+// 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 MTP_FRAMEWORK_IBY
+#define MTP_FRAMEWORK_IBY
+
+
+#include <mtp_devicedp.iby>
+
+
+#if !defined(SYMBIAN_EXCLUDE_MTP)
+
+ 
+// MTP Data Types Library
+file=ABI_DIR\BUILD_DIR\mtpdatatypes.dll    system\libs\mtpdatatypes.dll
+
+// MTP Framework Library
+file=ABI_DIR\BUILD_DIR\mtpframework.dll    			system\libs\mtpframework.dll
+
+// MTP SERVER
+file=ABI_DIR\BUILD_DIR\mtpserver.exe    system\libs\mtpserver.exe
+
+// MTP Client
+file=ABI_DIR\BUILD_DIR\mtpclient.dll    system\libs\mtpclient.dll
+
+// MTP Generic Transport API
+file=ABI_DIR\DEBUG_DIR\mtptransportapi.dll  system\libs\mtptransportapi.dll
+
+// MTP Data Provider API
+file=ABI_DIR\BUILD_DIR\mtpdataproviderapi.dll    system\libs\mtpdataproviderapi.dll
+
+// MTP Device Data Provider Extension API
+file=ABI_DIR\BUILD_DIR\mtpdevdpextnapi.dll    system\libs\mtpdevdpextnapi.dll
+
+// MTP Data Provider Utility
+file=ABI_DIR\BUILD_DIR\mtpdataproviderutility.dll    system\libs\mtpdataproviderutility.dll
+
+
+// MTP Proxy Data Provider
+ECOM_PLUGIN(mtpproxydp.dll, mtpproxydp.rsc)
+
+// MTP plugin registration resource file
+data=EPOCROOT##epoc32\data\Z\resource\mtp\102827B1.rsc  resource\mtp\102827B1.rsc 
+
+// MTP dummydp resource file
+data=EPOCROOT##epoc32\data\Z\resource\mtp\dummydp.rsc  resource\mtp\dummydp.rsc 
+
+// MTP Service Config resource file
+data=EPOCROOT##epoc32\data\Z\resource\mtp\services.rsc  resource\mtp\services.rsc 
+
+// MTP Backup registration file
+data=EPOCROOT##epoc32\data\Z\private\102827a2\backup_registration.xml  private\102827a2\backup_registration.xml
+
+//MTP device icon property file 
+data=EPOCROOT##epoc32\data\Z\private\102827a2\mtpdevice.ico  private\102827a2\mtpdevice.ico
+
+#endif // SYMBIAN_EXCLUDE_MTP
+
+#endif // MTP_FRAMEWORK_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/group/mtp_framework.mrp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,35 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	mtp_framework
+source \sf\mw\remoteconn\mtpfws\mtpfw\common
+source \sf\mw\remoteconn\mtpfws\mtpfw\daemon
+source \sf\mw\remoteconn\mtpfws\mtpfw\dataproviders\dataproviderapi
+source \sf\mw\remoteconn\mtpfws\mtpfw\dataproviders\devdp
+source \sf\mw\remoteconn\mtpfws\mtpfw\dataproviders\dputility
+source \sf\mw\remoteconn\mtpfws\mtpfw\dataproviders\group
+source \sf\mw\remoteconn\mtpfws\mtpfw\dataproviders\proxydp
+source \sf\mw\remoteconn\mtpfws\mtpfw\datatypes
+source \sf\mw\remoteconn\mtpfws\mtpfw
+source \sf\mw\remoteconn\mtpfws\mtpfw\transports\transportapi
+
+binary	\sf\mw\remoteconn\mtpfws\mtpfw\group all
+exports	\sf\mw\remoteconn\mtpfws\mtpfw\group
+
+notes_source	\component_defs\release.src
+
+ipr E 
+ipr T  \sf\mw\remoteconn\mtpfws\mtpfw\dataproviders\devdp\devdpextn
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/group/mtpframework.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,107 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// MTP framework.
+// 
+//
+
+/**
+ @file
+*/
+
+#include <comms-infras/commsdebugutility.mmh>
+#include "../common/inc/mtpbuildoptions.hrh"
+
+TARGET              mtpframework.dll
+TARGETTYPE          DLL
+UID                 0x1000008D 0x102827A1 
+VENDORID 			0x70000001
+
+CAPABILITY          CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+USERINCLUDE         ../inc/ 
+USERINCLUDE         ../common/inc 
+USERINCLUDE         ../transports/transportapi/inc
+
+SOURCEPATH          ../src/ 
+SOURCE              cmtpconnection.cpp
+SOURCE              cmtpconnectionmgr.cpp
+SOURCE              cmtpdataprovider.cpp
+SOURCE              cmtpdataproviderconfig.cpp
+SOURCE              cmtpdataprovidercontroller.cpp
+SOURCE              cmtpframeworkconfig.cpp
+SOURCE              cmtphandleallocator.cpp
+SOURCE              cmtpobjectmgr.cpp
+SOURCE              cmtpobjectstore.cpp
+SOURCE              cmtpparserrouter.cpp
+//SOURCE              cmtppuidmgr.cpp
+SOURCE              cmtpreferencemgr.cpp
+SOURCE              cmtpsession.cpp
+SOURCE              cmtpstoragemgr.cpp
+//SOURCE              cmtpsuidmap.cpp
+SOURCE              dbutility.cpp
+SOURCE              rmtpframework.cpp
+SOURCE              tmtptypeobjecthandle.cpp
+SOURCE		        cdummydp.cpp
+SOURCE              cmtpdeltadatamgr.cpp
+SOURCE              cmtpdpidstore.cpp
+SOURCE              cmtppkgidstore.cpp
+SOURCE              cmtpserviceconfig.cpp
+SOURCE              cmtpservicemgr.cpp 
+SOURCE              cmtpdatacodegenerator.cpp 
+SOURCE              cmtpserviceinfo.cpp
+
+//SOURCE		ruidmapper.cpp
+
+
+// Data provider configuration resource file. 
+// The target filename corresponds to the implementation UID.
+START RESOURCE      dummydp_config.rss   
+TARGETPATH          /resource/mtp
+TARGET              dummydp.rsc
+END
+
+/*START RESOURCE      framework_config.rss
+HEADER
+TARGETPATH          /resource/mtp
+TARGET              framework.rsc
+END*/
+
+START RESOURCE      services_config.rss   
+TARGETPATH          /resource/mtp
+TARGET              services.rsc
+END
+
+LIBRARY             bafl.lib
+LIBRARY             centralrepository.lib
+LIBRARY             ecom.lib 
+LIBRARY             edbms.lib 
+LIBRARY             efsrv.lib
+LIBRARY             estor.lib
+LIBRARY             euser.lib
+
+LIBRARY             mtpdatatypes.lib
+LIBRARY             mtpdataproviderapi.lib
+LIBRARY             mtptransportapi.lib
+LIBRARY				sisregistryclient.lib
+LIBRARY 			sishelper.lib
+
+#ifdef MTP_CAPTURE_TEST_DATA
+LIBRARY             mtprequestlogger.lib
+#endif
+
+
+SMPSAFE
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cdummydp.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,56 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CDUMMYDP_H
+#define CDUMMYDP_H
+
+#include <mtp/cmtpdataproviderplugin.h>
+
+/** 
+Defines the MTP data provider component test plug-in.
+
+@internalTechnology
+*/
+
+const TUid KFrameworkUid = {0x05E00F14};
+
+class CDummyDp : public CMTPDataProviderPlugin
+    {
+public:    
+	static TAny* NewL(TAny* aParams);
+    ~CDummyDp();  
+    
+private: // From CMTPDataProviderPlugin
+
+    void Cancel();
+    void ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection);
+    void ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams);
+    void ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    void StartObjectEnumerationL(TUint32 aStorageId, TBool aPersistentFullEnumeration);
+    void StartStorageEnumerationL();
+    void Supported(TMTPSupportCategory aCategory, RArray<TUint>& aArray) const;
+
+private:
+    CDummyDp(TAny* aParams);
+    void ConstructL();
+    
+    };
+    
+#endif // CDUMMYDP_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpconnection.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,204 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPCONNECTION_H
+#define CMTPCONNECTION_H
+
+#include <e32property.h>
+#include <e32base.h>
+#include <mtp/mmtpconnection.h>
+#include <mtp/mtpdataproviderapitypes.h>
+#include <mtp/tmtptypeevent.h>
+#include <mtp/tmtptyperesponse.h>
+#include <mtp/rmtpclient.h>
+
+#include "mmtpconnectionprotocol.h"
+#include "rmtpframework.h"
+#include "mtpdebug.h"
+#include "mtpbuildoptions.hrh"
+#include "mtpdebug.h"
+
+class CMTPSession;
+class MMTPTransportConnection;
+class TRequestStatus;
+class TMTPTypeRequest;
+class TMTPTypeFlatBase;
+
+#ifdef MTP_CAPTURE_TEST_DATA
+class CMTPRequestLogger;
+#endif
+
+/** 
+Implements the connection level portion of the MTP communication model and 
+associated transport layer protocol binding. This class Implements the API 
+portion (@see MMTPConnectionProtocol) of the transport layer API/SPI interface 
+pair by which MTP framework and transport protocol connections 
+(@see MMTPTransportConnection) interact. A unique @see CMTPConnection instance 
+is created and bound to each @see MMTPTransportConnection instance that is 
+loaded. 
+
+It also implements the data provider layer MTP connection interface 
+(@see MMTPConnection) which represents the virtual circuit between data provider 
+and the transport layer.
+@internalComponent
+ 
+*/
+class CMTPConnection : 
+    public CBase,
+    public MMTPConnection, 
+    public MMTPConnectionProtocol
+    {
+private:
+
+	class CMTPEventLink :
+		public CBase
+		{
+	public:
+		CMTPEventLink(const TMTPTypeEvent& aEvent);
+		
+	public:
+		TSglQueLink		iLink;
+		TMTPTypeEvent	iEvent;		
+		};
+    
+public:
+
+    static CMTPConnection* NewLC(TUint aConnectionId, MMTPTransportConnection& aTransportConnection);
+    ~CMTPConnection();
+
+    void ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, TRequestStatus& aStatus);
+    void SendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, TRequestStatus& aStatus);
+    void SendEventL(const TMTPTypeEvent& aEvent);
+    void SendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, TRequestStatus& aStatus);
+    IMPORT_C void SessionClosedL(TUint32 aSessionMTPId);
+    IMPORT_C void SessionOpenedL(TUint32 aSessionMTPId);
+    IMPORT_C TInt GetDataReceiveResult() const;
+    void ConnectionSuspended();
+    void ConnectionResumedL(MMTPTransportConnection& aTransportConnection);
+    void TransactionCompleteL(const TMTPTypeRequest& aRequest);
+    
+public: // From MMTPConnection & MMTPConnectionProtocol
+
+    TUint ConnectionId() const;
+    
+public: // From MMTPConnection
+
+    TUint SessionCount() const;
+    TBool SessionWithMTPIdExists(TUint32 aMTPId) const;
+    MMTPSession& SessionWithMTPIdL(TUint32 aMTPId) const;
+    TBool SessionWithUniqueIdExists(TUint32 aUniqueId) const;
+    MMTPSession& SessionWithUniqueIdL(TUint32 aUniqueId) const;
+    TMTPTransactionPhase TransactionPhaseL(TUint32 aMTPSessionId) const;
+	void DisconnectionNotifyL();
+
+private: // From MMTPConnectionProtocol
+
+    void ReceivedEventL(const TMTPTypeEvent& aEvent);
+    void ReceivedRequestL(const TMTPTypeRequest& aRequest);
+    void ReceiveDataCompleteL(TInt aErr, const MMTPType& aData, const TMTPTypeRequest& aRequest);
+    void SendDataCompleteL(TInt aErr, const MMTPType& aData, const TMTPTypeRequest& aRequest);
+    void SendEventCompleteL(TInt aErr, const TMTPTypeEvent& aEvent);
+    void SendResponseCompleteL(TInt aErr, const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest);
+	void Unbind(MMTPTransportConnection& aConnection);
+
+private:
+
+    CMTPConnection(TUint aConnectionId, MMTPTransportConnection& aTransportConnection);
+    void ConstructL();
+  
+    void InitiateMTPErrorRecoveryL(const TMTPTypeRequest& aRequest, TUint16 aResponseCode);
+    void MTPErrorRecoveryComplete();
+    void UnrecoverableMTPError();
+    
+    void InitiateTransactionCancelL(TInt aSessionIdx);
+    
+    TUint ActiveSessions() const;
+    void CloseAllSessions();
+    void CloseSession(TUint aIdx);
+    CMTPSession& SessionL(const TMTPTypeFlatBase& aDataset, TInt aSessionIdElementNo) const;
+    
+    static TInt SessionOrder(const TUint32* aL, const CMTPSession& aR);
+    static TInt SessionOrder(const CMTPSession& aL, const CMTPSession& aR);
+    
+    void SetState(TUint aState);
+    TUint State() const;
+    
+    TBool ValidFrameworkRequest(CMTPSession* aSession, TUint aValidStates, TRequestStatus* aStatus);
+    
+    void RemoveEventsForSession(TUint32 aMTPId);
+    
+    void EnqueueEvent(CMTPEventLink* aLink);
+    void DequeueEvent(CMTPEventLink* aLink);
+
+/**
+  * This method define and attach the property for publishing connection state 
+  *  events.
+  */
+    void DefineConnStatePropertyL(); 
+
+/**
+  * This method is to publish various connection state.
+  */
+    void PublishConnState(TMTPConnStateType aConnState);	
+
+    void ValidateAndPublishConnState(CMTPSession& aSession, TInt aState);
+	
+    
+private: // Owned
+  
+    enum TStates
+        {
+        EStateUnknown,
+        EStateOpen,
+        EStateErrorRecovery,
+        EStateErrorShutdown,
+        EStateShutdown
+        };
+
+    TUint                       iConnectionId;
+    RPointerArray<CMTPSession>  iSessions;
+    TUint                       iState;
+    RMTPFramework               iSingletons;
+    TAny*                       iExtendedInterface;
+    TMTPTypeResponse 			iResponse;
+    TSglQue<CMTPEventLink>		iEventQ;
+    TInt 						iPendingEventCount;   
+    TInt 						iDataReceiveResult;
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+private: // Not owned
+
+    MMTPTransportConnection*    iTransportConnection;
+
+    //For publishing the connection state.
+    RProperty iProperty; 
+	
+    /**
+    Special build, capture request, data phase and responses to disk.
+    */
+#ifdef MTP_CAPTURE_TEST_DATA 
+    CMTPRequestLogger*          iRequestLogger;
+#endif
+    };
+    
+#endif // CMTPCONNECTION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpconnectionmgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,111 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+
+#ifndef CMTPCONNECTIONMGR_H
+#define CMTPCONNECTIONMGR_H
+
+#include <e32base.h>
+#include "mmtpconnectionmgr.h"
+#include "mtpdebug.h"
+
+class CMTPConnection;
+class CMTPTransportPlugin;
+class MMTPTransportConnection;
+
+/**
+Implements the connection manager singleton. The connection manager is a 
+container class responsible for loading, storing, and managing 
+@see CMTPTransportPlugin instances. The connection manager uses the ECOM 
+framework to load and unload transport plug-ins on demand. 
+
+The connection manager is not responsible for controlling or scheduling 
+transport connections, but is notified by the loaded transport plug-ins as 
+@see MMTPTransportConnection instances are created. At which time it will 
+create and bind a new @see CMTPConnection instance to the 
+@see MMTPTransportConnection instance being registered.
+*/
+class CMTPConnectionMgr : 
+    public CBase,
+    public MMTPConnectionMgr
+    {
+public:
+
+    static CMTPConnectionMgr* NewL();
+    ~CMTPConnectionMgr();
+    
+    IMPORT_C CMTPConnection& ConnectionL(TUint aConnectionId) const;
+    TUint ConnectionCount() const;
+    CMTPConnection& operator[](TInt aIndex) const;
+    IMPORT_C void StartTransportL(TUid aTransport);
+    IMPORT_C void StartTransportL(TUid aTransport, const TAny* aParameter);  
+    IMPORT_C void QueueTransportL( TUid aTransport, const TAny* aParameter );
+    IMPORT_C void SetClientSId(TUid aSecureId);  
+    IMPORT_C void StopTransport(TUid aTransport);
+    IMPORT_C void StopTransport( TUid aTransport, TBool aByBearer );
+    IMPORT_C void StopTransports();
+    IMPORT_C TInt TransportCount() const;
+    IMPORT_C TUid TransportUid();
+	
+	    
+private: // From MMTPConnectionMgr
+
+    void ConnectionClosed(MMTPTransportConnection& aTransportConnection);
+    void ConnectionOpenedL(MMTPTransportConnection& aTransportConnection);
+    TBool DeleteConnection(TUint aConnectionId);
+    TUid ClientSId();
+    
+private:
+
+    CMTPConnectionMgr();
+    
+    TInt ConnectionFind(TUint aConnectionId) const;
+    static TInt ConnectionOrderCompare(const CMTPConnection& aFirst, const CMTPConnection& aSecond);
+
+    void SuspendTransportL( TUid aTransport );
+    void UnsuspendTransport( TUid aTransport );
+    void ResumeSuspendedTransport();
+    static TInt DoResumeSuspendedTransport( TAny* aSelf );
+private:
+
+    RPointerArray<CMTPConnection>   iConnections;
+    TLinearOrder<CMTPConnection>    iConnectionOrder;
+    TInt                            iShutdownConnectionIdx;
+    CMTPTransportPlugin*            iTransport;
+    TUid                            iTransportUid;
+    TUint							iTransportCount;
+    TUid 							iSecureId;
+    
+    /**
+     * Array storing the UIDs of the suspended transport plugins
+     */
+    RArray< TUid >                  iSuspendedTransports;
+    
+    /**
+     * Active object which starts suspended transport asynchronously
+     */
+    CAsyncCallBack*                 iTransportTrigger;
+    
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    };
+#endif // CMTPCONNECTIONMGR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpdatacodegenerator.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,84 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//  
+
+/**
+@file
+@internalComponent
+*/ 
+
+#ifndef CMTPDATACODEGENERATOR_H_
+#define CMTPDATACODEGENERATOR_H_
+
+#include <e32base.h>
+#include <mtp/mmtpdatacodegenerator.h>
+
+
+
+#include "mtpdebug.h"
+
+class RMTPFramework;
+
+
+class CMTPDataCodeGenerator :
+    public CBase,
+    public MMTPDataCodeGenerator
+    {
+public:
+    static CMTPDataCodeGenerator* NewL();
+    ~CMTPDataCodeGenerator();
+
+public: // From MMTPDataCodeGenerator
+    TInt AllocateServiceID(const TMTPTypeGuid& aPGUID, const TUint aServiceType, TUint& aServiceID );
+    TInt AllocateServicePropertyCode(const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, TUint16& aServicePropertyCode );
+    TInt AllocateServiceFormatCode(const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, TUint16& aServiceFormatCode);
+    TInt AllocateServiceMethodFormatCode(const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, TUint16& aMethodFormatCode );
+
+
+private:
+    CMTPDataCodeGenerator();
+    void ConstructL();
+    TInt IncServiceIDResource( const TUint aServiceType, TUint& aServiceID );
+    void DecServiceIDResource();
+    TBool IsValidServiceType( const TUint aServiceType ) const;
+    
+private:
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+    /**
+    The framework singletons.
+    */
+    RMTPFramework                   iSingletons;
+
+    /*
+     * Undefined Section.1 : 0x0000 --- 0x0FFF
+     */
+    TUint16 iUndefinedNextCode;
+    
+    /*
+     * Vendor Extension Object Format Code : 0xB000 --- 0xB7FF
+     *    (EMTPFormatCodeVendorExtStart -- EMTPFormatCodeVendorExtEnd)
+     */
+    TUint16 iVendorExtFormatCode;
+
+    };
+
+#endif /* CMTPDATACODEGENERATOR_H_ */
+
+    
+    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpdataprovider.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,263 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef CMTPDATAPROVIDER_H
+#define CMTPDATAPROVIDER_H
+
+/**
+@file
+@internalComponent
+*/
+
+#include "rmtpframework.h"
+
+#include <e32base.h>
+
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mtpdataproviderapitypes.h>
+#include <mtp/tmtptypeevent.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/tmtptyperesponse.h>
+
+#include "mtpdebug.h"
+
+class CMTPConnection;
+class CMTPDataProviderPlugin;
+class CMTPDataProviderConfig;
+class MMTPDataProvider;
+class MMTPDataProviderConfig;
+class MTPFrameworkConfig;
+class MMTPObjectMgr;
+class MMTPTransactionProxy;
+class MMTPDataCodeGenerator;
+
+/**
+Implements the API portion of the API/SPI interface pair by which MTP framework 
+and data provider plug-ins interact. A unique CMTPDataProvider instance is 
+created and bound to each CMTPDataProviderPlugin instance that is loaded, and 
+functions on its behalf to:
+    a)	Process MTP operational and media object data to and from the MTP 
+        framework, and;
+    b)	Manage MTP transaction protocol state transitions to ensure that the 
+        MTP transaction state remains valid under both normal and error 
+        recovery processing conditions.
+@internalTechnology
+ 
+*/
+class CMTPDataProvider : 
+    public CActive, 
+    public MMTPDataProviderFramework
+    {
+public:
+
+    /**
+    The enumeration state bit flags.
+    */
+    enum TEnumerationStates
+        {
+        EUnenumerated               = 0x00000000,
+        EObjectsEnumerationState    = 0x0000000F,
+        EObjectsEnumerating         = 0x00000003,
+        EObjectsEnumerated          = 0x00000001,
+        EStoragesEnumerationState   = 0x000000F0,
+        EStoragesEnumerating        = 0x00000030,
+        EStoragesEnumerated         = 0x00000010,
+        EEnumerated                 = (EStoragesEnumerated | EObjectsEnumerated)
+        };
+        
+public:
+
+	static CMTPDataProvider* NewL(TUint aId, TUid aImplementationUid, CMTPDataProviderConfig* aConfig);
+	static CMTPDataProvider* NewLC(TUint aId, TUid aImplementationUid, CMTPDataProviderConfig* aConfig);
+	~CMTPDataProvider();
+ 
+	void ExecuteEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection);
+	void ExecuteRequestL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+	IMPORT_C void ExecuteProxyRequestL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, MMTPTransactionProxy& aProxy);
+    
+    void EnumerateObjectsL(TUint32 aStorageId);
+    void EnumerateStoragesL();
+    IMPORT_C TUint EnumerationState() const;
+    IMPORT_C TUid ImplementationUid() const;
+	IMPORT_C CMTPDataProviderPlugin& Plugin() const;
+    IMPORT_C TBool Supported(TMTPSupportCategory aCategory, TUint aCode) const;
+    IMPORT_C const RArray<TUint>& SupportedCodes(TMTPSupportCategory aCategory) const;
+    
+    void SetDataProviderId(TUint aId);
+    
+    static TInt LinearOrderUid(const TUid* aUid, const CMTPDataProvider& aObject);
+    static TInt LinearOrderUid(const CMTPDataProvider& aL, const CMTPDataProvider& aR);
+	static TInt LinearOrderDPId(const TUint* aDPId, const CMTPDataProvider& aObject);
+    static TInt LinearOrderDPId(const CMTPDataProvider& aL, const CMTPDataProvider& aR);
+    static TInt LinearOrderEnumerationPhase(const CMTPDataProvider& aL, const CMTPDataProvider& aR);
+    
+public: // From MMTPDataProviderFramework
+
+    TUint DataProviderId() const;
+    TMTPOperationalMode Mode() const;
+    void ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    void SendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    void SendEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection);
+    void SendEventL(const TMTPTypeEvent& aEvent);
+    void SendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    void TransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    void RouteRequestRegisterL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    void RouteRequestUnregisterL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+    void ObjectEnumerationCompleteL(TUint32 aStorageId);
+    void StorageEnumerationCompleteL();
+    const MMTPDataProviderConfig& DataProviderConfig() const;
+    const MMTPFrameworkConfig& FrameworkConfig() const;
+	MMTPObjectMgr& ObjectMgr() const;
+    MMTPReferenceMgr& ReferenceMgr() const;
+    MMTPStorageMgr& StorageMgr() const;
+    RFs& Fs() const;
+    MMTPDataCodeGenerator& DataCodeGenerator() const;
+	
+private: // From CActive
+
+	void DoCancel();
+	void RunL();
+	TInt RunError(TInt aError);
+
+private:
+
+   	CMTPDataProvider(TUint aId, TUid aImplementationUid, CMTPDataProviderConfig* aConfig);
+    void ConstructL();
+    
+	void Schedule();
+  	void SendErrorResponseL(TInt aError);
+  	
+private:
+
+    /**
+    */
+    class CSupportedCodes : public CBase
+        {
+    public:
+    
+        static CSupportedCodes* NewLC(TMTPSupportCategory aCategory, MMTPDataProvider& aDp);
+        virtual ~CSupportedCodes();
+    
+        const RArray<TUint>& Codes() const;
+        TBool Supported(TUint aCode) const;
+        
+    private:
+    
+        CSupportedCodes();
+        void ConstructL(TMTPSupportCategory aCategory, MMTPDataProvider& aDp);
+        
+    private:
+    
+        RArray<TUint> iCodes;
+        };
+        
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    /**
+    The data provider configurability parameter data.
+    */
+	CMTPDataProviderConfig*         iConfig;
+    
+    /**
+    The construction completed flag. This is used to indicate that ownership 
+    of passed objects has been assumed.
+    */
+    TBool                           iConstructed;
+	
+	/**
+	The transaction phase of the currently active operation.
+	*/
+    TMTPTransactionPhase            iCurrentTransactionPhase;
+    
+    /**
+    The enumeration state.
+    */
+	TUint                           iEnumerationState;
+	
+	/**
+	The error recovery flag, indicating that an error occurred while processing
+	a request. 
+	*/
+	TInt                            iErrorRecovery;
+    
+    /** 
+    The data provider identifier.
+    */
+	TInt                            iId;
+	
+	/**
+	The data provider implementation plug-in.
+	*/
+	CMTPDataProviderPlugin*         iImplementation;
+	
+	/**
+	The data provider implementation UID.
+	*/
+	TUid                            iImplementationUid;
+	
+	/**
+	The transaction phase of the currently active transaction proxy.
+	*/
+    TMTPTransactionPhase            iProxyTransactionPhase;
+    
+    /**
+    The MTP response dataset buffer.
+    */
+	TMTPTypeResponse		        iResponse;
+    
+    /**
+    The framework singletons.
+    */
+	RMTPFramework                   iSingletons;
+    
+    /** 
+    The data provider's support categories table.
+    */
+    RPointerArray<CSupportedCodes>  iSupported;
+
+	
+    /** Indicates whether iTimer is active. */
+    TBool							iTimerActive;
+
+    /*****
+	 * Added timer to delay request handling until storage/object enumeration has finished
+	 */ 	
+	RTimer iTimer;
+        
+private: // Not owned
+	
+	/**
+	The MTP connection on which the currently active operation is being 
+	processed.
+	*/
+	CMTPConnection*                 iCurrentConnection;
+    
+    /**
+    The MTP request dataset buffer.
+    */
+	const TMTPTypeRequest*          iCurrentRequest;
+	
+	/**
+	The currently active transaction proxy.
+	*/
+	MMTPTransactionProxy*           iProxy;
+    };
+    
+#endif // CMTPDATAPROVIDER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpdataproviderconfig.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,76 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPDATAPROVIDERCONFIG_H
+#define CMTPDATAPROVIDERCONFIG_H
+
+#include <mtp/mmtpdataproviderconfig.h>
+#include <mtp/mtpdataproviderapitypes.h>
+
+#include <e32std.h>
+
+class TResourceReader;
+
+/**
+Implements the data provider configurability parameter data interface. Each 
+loaded data provider is required to supply a compiled resource file which 
+implements a number of configurability parameters. These parameters are read 
+accessible only.
+@internalTechnology
+ 
+*/
+class CMTPDataProviderConfig : 
+    public CBase, 
+    public MMTPDataProviderConfig
+    {
+public:
+
+    static CMTPDataProviderConfig* NewL(TResourceReader& aReader, const TDesC& aFileName);
+    virtual ~CMTPDataProviderConfig();
+    
+    TBool ModeSupported(TMTPOperationalMode aMode) const;
+
+public: // From MMTPDataProviderConfig
+
+    TUint UintValue(TParameter aParam) const;
+    TBool BoolValue(TParameter aParam) const;
+    const TDesC& DesCValue(TParameter aParam) const;
+    const TDesC8& DesC8Value(TParameter aParam) const;
+    void GetArrayValue(TParameter aParam, RArray<TUint>& aArray) const;
+        
+private:
+
+    CMTPDataProviderConfig();
+    void ConstructL(TResourceReader& aReader, const TDesC& aFileName);
+
+private:
+
+    TMTPDataProviderTypes   iType;
+    TInt                    iVersion;
+    TBool                   iObjectEnumerationPersistent;
+    TUint32                 iSupportedModes;
+    HBufC*                  iServerName;
+    HBufC*                  iServerImageName;
+    TUint32                 iOpaqueResource;
+    HBufC*                  iResourceFileName;
+    TUint8                  iEnumerationPhase;
+    };
+
+#endif // CMTPDATAPROVIDERCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpdataprovidercontroller.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,219 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPDATAPROVIDERCONTROLLER_H
+#define CMTPDATAPROVIDERCONTROLLER_H
+
+#include <e32base.h>
+#include <ecom/ecom.h>
+#include <mtp/mtpdataproviderapitypes.h>
+
+#include "rmtpframework.h"
+#include "mtpdebug.h"
+#include <swi/sisregistrysession.h> 
+#include <swi/sisregistryentry.h>
+#include <swi/sisregistrypackage.h>
+
+
+class CMTPDataProvider;
+class CMTPDataProviderConfig;
+
+/**
+Implements the MTP framework data provider controller singleton. This is a 
+container class responsible for loading, storing, and managing 
+@see CMTPDataProviderPlugin instances and their associated 
+@see CMTPDataProvider bindings. The ECOM framework is used to load data 
+@see CMTPDataProviderPlugin instances when instructed to do so by the MTP 
+framework, either on start-up or when a mode switch occurs. 
+@internalTechnology
+ 
+*/
+
+
+	
+class CMTPDataProviderController : public CActive
+    {
+public:
+	/**
+    The active data provider set enumeration states.
+    */
+    enum TEnumerationStates
+        {
+        EUnenumerated                       = 0,
+        EEnumerationStarting                = 1,
+        EEnumeratingFrameworkStorages       = 2,
+        EEnumeratingDataProviderStorages    = 3,
+        EEnumeratingFrameworkObjects        = 4,
+        EEnumeratingDataProviderObjects     = 5,
+        EEnumerated                         = 6,
+        };
+        
+public:
+
+    static CMTPDataProviderController* NewL();
+    ~CMTPDataProviderController();    
+    
+    IMPORT_C void LoadDataProvidersL();
+    IMPORT_C void UnloadDataProviders();
+    IMPORT_C void NotifyDataProvidersL(TMTPNotification aNotification, const TAny* aParams);
+    IMPORT_C void NotifyDataProvidersL(TUint aDPId, TMTPNotification aNotification, const TAny* aParams);
+    
+    IMPORT_C TUint Count();
+    IMPORT_C CMTPDataProvider& DataProviderL(TUint aId);
+    IMPORT_C CMTPDataProvider& DataProviderByIndexL(TUint aIndex);
+    IMPORT_C TBool IsDataProviderLoaded(TUint aId) const;
+    IMPORT_C TInt DeviceDpId();
+    IMPORT_C TInt DpId(TUint aUid);
+    IMPORT_C TInt ProxyDpId();
+    IMPORT_C TUint EnumerateState();
+    IMPORT_C TInt FileDpId();
+        
+    void EnumerationStateChangedL(const CMTPDataProvider& aDp);    
+	TMTPOperationalMode Mode();
+
+    IMPORT_C void WaitForEnumerationComplete();
+    TBool FreeEnumerationWaiter();
+private: // From CActive
+
+    void DoCancel();
+    void RunL();
+    TInt RunError(TInt aError);
+
+private:
+
+    CMTPDataProviderController();
+    void ConstructL();
+    
+    CMTPDataProviderConfig* CreateConfigLC(const TDesC& aResourceFilename);
+    void EnumerateDataProviderObjectsL(TUint aId);
+	TBool IsObjectsEnumerationNeededL(CMTPDataProvider& dp);
+    void  LoadInstalledDataProvidersL(const CImplementationInformation* aImplementations);
+    TBool LoadROMDataProvidersL(const TDesC& aResourceFilename, const RImplInfoPtrArray& aImplementations);
+    TBool LoadDataProviderL(const TDesC& aResourceFilename);
+    TInt  Uid(const TDesC& aResourceFilename, TUint& aUid);
+    void Schedule();
+    void CreateRegistrySessionAndEntryL();
+    void CloseRegistrySessionAndEntryL();
+    
+    static void ImplementationsCleanup(TAny* aData);
+    static TInt ImplementationsLinearOrderUid(const TUid* aUid, const CImplementationInformation& aObject);
+    static TInt ImplementationsLinearOrderUid(const CImplementationInformation& aL, const CImplementationInformation& aR);
+        
+private: // Owned
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+    /**
+    The active data provider set container, ordered bit implementation 
+    UID.
+    */
+    RPointerArray<CMTPDataProvider> iDataProviders;
+
+    /**
+    The active data provider identifier container, ordered by enumeration phase.
+    */
+    RArray<TUint>                   iDataProviderIds;
+    
+    /**
+    The device data provider identifier.
+    */
+    TUint                           iDpIdDeviceDp;
+    
+    /**
+    The proxy data provider identifier.
+    */
+    TUint                           iDpIdProxyDp;
+
+    /**
+    The file data provider identifier.
+    */
+    TUint                           iDpIdFileDp;
+    
+    /**
+    The actively enumerating data providers.
+    */
+    RArray<TUint>                   iEnumeratingDps;
+    
+    /**
+    The actively enumerating storage IDs.
+    */
+    RArray<TUint>                   iEnumeratingStorages;
+    
+    /**
+    The active data provider set enumeration states.
+    */
+    TEnumerationStates              iEnumerationState;
+
+    /**
+    The active data provider set enumeration phases.
+    */
+    TUint                           iEnumerationPhase;
+
+    /**
+    The index used for iterating through the iDataProviderIds array.
+    */
+    TUint                           iDpIdArrayIndex;
+    
+    /**
+    A general purpose index used for iterating through the active data provider
+    set.
+    */
+    TUint                           iNextDpId;
+    
+    /**
+    The framework singletons.
+    */
+    RMTPFramework                   iSingletons;
+    
+    /**
+    Current operation mode
+    */
+    TMTPOperationalMode 			iMode ;
+    
+    /**
+    Session for sisRegistry
+    */
+    Swi::RSisRegistrySession iSisSession;
+    
+    /**
+    Registry Entry 
+    */
+    Swi::RSisRegistryEntry iSisEntry;
+    
+    /**
+    Stub Found
+    */
+    TBool iStubFound;
+
+    /**
+    opensession waiter
+    */
+    CActiveSchedulerWait *iOpenSessionWaiter;
+    
+    /**
+    Flag for Create DBSnapshot
+    */
+    TUint8 iFlagDb;
+
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpdeltadatamgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,97 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cmtpdeltadatamgr.h
+// 
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+
+#ifndef CMTPDELTADATAMGR_H
+#define CMTPDELTADATAMGR_H
+
+#include "mtpdebug.h"
+
+#include <e32base.h>
+#include <d32dbms.h>
+#include "dbutility.h"
+#include "mtpframeworkconst.h"
+#include <mtp/cmtptypearray.h>
+#include <mtp/tmtptypeuint128.h>
+class RDbDatabase;
+class TMTPTypeUint32;
+
+class CMtpDeltaDataMgr : public CBase
+{
+private:
+    CMtpDeltaDataMgr (RDbDatabase& aDatabase);
+    void ConstructL();
+    
+
+public:    
+    static CMtpDeltaDataMgr* NewL(RDbDatabase& aDatabase);
+    ~CMtpDeltaDataMgr();
+    /**
+    The enumeration for operations on file .
+    */
+    enum TOpCode
+    {
+    EAdded=0,
+    EDeleted=1,
+    EModified=2,
+    }; 
+    
+    /**
+    updates the delta data table with the params , if the suid identifier param passesd is
+    a not found in the table a new entry will be created with opcode as EAdded.
+    */
+    void UpdateDeltaDataTableL(TInt64 aSuidId, TOpCode aOpCode);
+    
+    IMPORT_C void CreateDeltaDataTableL();
+    IMPORT_C void CreateAnchorIdTableL();
+    IMPORT_C void InsertAnchorIdL(TInt aAnchorId, TInt aIdentifier);
+    IMPORT_C void UpdateAnchorIdL(TInt aAnchorId, TInt aIdentifier);
+    IMPORT_C TInt GetAnchorIdL(TInt aIdentifier);
+    IMPORT_C void UpdatePersistentIndexL(TInt aCurindex, TInt aIdentifier);
+    IMPORT_C TInt GetPersistentIndexL(TInt aIdentifier);
+    
+    IMPORT_C TInt GetAddedPuidsL(TInt aMaxArraySize, TInt &aPosition, CMTPTypeArray& aAddedPuidIdArray);
+    IMPORT_C TInt GetDeletedPuidsL(TInt aMaxArraySize, TInt &aPosition, CMTPTypeArray& aDeletedPuidIdArray);
+    IMPORT_C TInt GetModifiedPuidsL(TInt aMaxArraySize, TInt &aPosition, CMTPTypeArray& aModifiedPuidIdArray);
+    IMPORT_C TInt GetChangedPuidsL(TInt aMaxArraySize, TInt &aPosition, CMTPTypeArray& aModifiedPuidIdArray, CMTPTypeArray& aDeletedPuidArray);    
+    
+    IMPORT_C void ResetMTPDeltaDataTableL();
+
+private: // Not owned
+
+    RDbDatabase& iDatabase; 
+    TBuf<KMTPMaxSqlStatementLen>    iSqlStatement;
+    RArray <TMTPTypeUint128> iSuidIdArray;
+   
+    RDbView iView;
+    TBool iNeedToSendMore;
+    TInt iTotalRows;    
+    RDbTable iDeltaTableBatched;
+    RDbTable iAnchorTableBatched;
+   /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+};
+
+#endif // CMTPDELTADATAMGR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpdpidstore.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,54 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef CMTPDPIDSTORE_H
+#define CMTPDPIDSTORE_H  
+/** 
+Implements the MTP object manager interface.
+@internalComponent
+ 
+*/
+#include <d32dbms.h>
+#include "mtpframeworkconst.h"
+
+class RDbDatabase;
+
+class CMTPDPIDStore :  public CBase        
+    {
+public:   
+ 
+    static CMTPDPIDStore* NewL(RDbDatabase& aDatabase);    
+    ~CMTPDPIDStore();
+
+public:     
+    void InsertDPIDObjectL(TUint aDpId, TUint aUid);    
+    TUint DPIDL(TUint32 aUid, TBool& aFlag) const;
+
+private: 
+	enum TDPIDStore
+        {
+        EDPIDStoreDataProviderId         = 1,
+        EDPIDStoreUid                    = 2        
+        };   
+	CMTPDPIDStore(RDbDatabase& aDatabase);
+    void CreateDPIDStoteTableL();
+    void ConstructL();   
+private:
+	RDbDatabase&                    iDatabase;	
+	mutable TBuf<KMTPMaxSqlStatementLen>    iSqlStatement;   
+	RArray<TInt64> iDPIDs;
+	RArray<TInt64> iDPUIDs;
+    };
+#endif // CMTPDPIDSTORE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpframeworkconfig.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,75 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPFRAMEWORKCONFIG_H
+#define CMTPFRAMEWORKCONFIG_H
+
+#include <e32base.h>
+#include <mtp/mmtpframeworkconfig.h>
+
+class CRepository;
+
+/**
+Implements the framework configurability parameter data interface. 
+
+The MTP framework implements a number of configurability parameters using a 
+central repository. The initial set of configurability parameters are loaded 
+from a compiled (binary) initialisation file. Read only access to the MTP 
+framework configurability parameter data is unrestricted. Write access is 
+restricted to the MTP framework. 
+@internalTechnology
+ 
+*/
+class CMTPFrameworkConfig : 
+    public CBase,
+    public MMTPFrameworkConfig
+    {
+public:
+
+    static CMTPFrameworkConfig* NewL();
+    ~CMTPFrameworkConfig();
+		
+public:
+
+    IMPORT_C void GetValueL(TParameter aParam, TDes& aValue) const;
+    IMPORT_C HBufC* ValueL(TParameter aParam) const;
+    IMPORT_C void GetValueL(TParameter aParam, TUint& aValue) const;
+    IMPORT_C void GetValueL(TParameter aParam, TBool& aValue) const;
+    IMPORT_C void GetValueL(TParameter aParam, RArray<TUint>& aArray) const;
+   
+private:
+
+	CMTPFrameworkConfig();
+	void ConstructL();
+
+private: // Owned
+
+	/**
+	The configurability parameter data repository.
+	*/
+	CRepository* iRepository;
+	
+	/**
+	 To save the value of EDownState 
+	 */
+	TInt         iAbnormalDownValue;
+    };
+    
+#endif // CMTPFRAMEWORKCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtphandleallocator.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,141 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+ 
+#ifndef CMTPHANDLEALLOCATOR_H
+#define CMTPHANDLEALLOCATOR_H
+
+#include <e32base.h>
+
+class CMTPObjectStore;
+/** 
+Defines the handle allocator which centralize the allocation of object handles
+
+@internalTechnology
+ 
+*/
+class CMTPHandleAllocator : public CBase
+	{
+public:
+	static CMTPHandleAllocator* NewL( CMTPObjectStore& aObjectStore );
+	~CMTPHandleAllocator();
+
+	TUint32 NextIdL(TUint aDataProviderId);
+	void SetIdL( TUint32 aHandleID, TInt64 aPOUID );
+	TInt64 NextPOUIDL();
+	
+   TBool AppendHandleBlockL( TUint aDataProviderId, TUint aNextID, TInt aSpace );
+	   
+private:
+	CMTPHandleAllocator( CMTPObjectStore& aObjectStore );	
+	void ConstructL();
+    void ExtendArrayL(TUint aDataProviderId);
+
+	TUint32 NextIDFromPoolL( TUint aDataProviderId );
+	
+    /*
+     * Defines the HandleID cache of one data provider. The HandleIDs have been allocated, but now
+     * they are available because the corresponding Object have been deleted or ... 
+     *  
+     * When the HandleID of one data provider is over flow, we have to search the DB to get the available
+     * HandleIDs that are not registed in DB.
+     * 
+     */
+    class CDPHandleCache : public CBase
+        {
+    public:
+        
+        class THandleBlock
+            {
+            public:
+                THandleBlock( TUint aNextID, TInt aSpace );
+            public:
+                TUint    iNextID;
+                TInt     iSpace;
+            };
+        
+    public:
+        static TInt HanldeCacheOrderFromAscending( const CDPHandleCache& aL, const CDPHandleCache& aR);
+        static TInt HanldeCacheOrderFromKeyAscending( const TUint* aL, const CDPHandleCache& aR);
+        
+    public:
+        static CDPHandleCache* NewLC( TUint aDataProviderId );
+        
+        ~CDPHandleCache();
+        
+        TUint32 NextHandleID();
+        void AppendL( const THandleBlock& aBlock );
+        
+        inline TUint DPID() const
+            {
+            return iDPID;
+            }
+        
+        inline TBool HasCache() const
+            {
+            return (iBlocks.Count() != 0);
+            }
+        
+        inline TInt  BlocksCount() const
+            {
+            return iBlocks.Count();
+            }
+        
+        static inline TInt MaxNumOfBlocks()
+            {
+            return iNumOfBlocks;
+            }
+        
+    private:
+        CDPHandleCache(TUint aDataProviderId);
+        void ConstructL();
+        
+    private:
+        /*
+         * The number of blocks 
+         */
+        static const TInt           iNumOfBlocks = 10;
+        
+        /*
+         * Data Provider ID
+         */
+        TUint                       iDPID;
+        
+        /*
+         * HandleID Blocks
+         */
+        RArray<THandleBlock>        iBlocks;
+        };
+    
+private:
+    CMTPObjectStore&                iObjectStore;
+    
+	RArray<TUint>					iNextIds;	
+
+	TInt64							iNextPOUID;
+	
+	//For ObjectID overflow
+	RPointerArray<CDPHandleCache>   iNextIDPool;
+	};
+#endif //CMTPHANDLEALLOCATOR_H	
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpobjectmgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,108 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPOBJECTMGR_H
+#define CMTPOBJECTMGR_H
+
+#include <e32base.h>
+#include <mtp/mmtpobjectmgr.h>
+
+#include "mtpdebug.h"
+
+#include "cmtpobjectstore.h"
+
+class CMTPObjectStore;
+class RFs;
+class TMTPTypeUint32;
+class CMTPPuidMgr;
+class CMTPReferenceMgr;
+
+/** 
+Implements the MTP object manager interface.
+@internalComponent
+ 
+*/
+class CMTPObjectMgr : 
+    public CBase, 
+    public MMTPObjectMgr
+    {
+public:   
+ 
+    static CMTPObjectMgr* NewL();
+    ~CMTPObjectMgr();
+
+public:
+
+    CMTPObjectStore& ObjectStore();
+    void RestorePersistentObjectsL(TUint aDataProviderId);
+    IMPORT_C void RemoveObjectsByStorageIdL(TUint32 aStorageId);
+    void RemoveNonPersistentObjectsL(TUint aDataProviderId);
+    void MarkNonPersistentObjectsL(TUint aDataProviderId ,TUint32 aStorageId);
+    void MarkDPLoadedL(TUint aDataProviderId, TBool aFalg);
+   
+    void InsertPkgIDObjectL(TUint aDpId, TUint aPkgId);
+       
+    
+public: // From MMTPObjectMgr
+
+    TUint CountL(const TMTPObjectMgrQueryParams& aParams) const;
+	void CommitReservedObjectHandleL(CMTPObjectMetaData& aObject);
+    void GetObjectHandlesL(const TMTPObjectMgrQueryParams& aParams, RMTPObjectMgrQueryContext& aContext, RArray<TUint>& aHandles) const;
+    void GetObjectSuidsL(const TMTPObjectMgrQueryParams& aParams, RMTPObjectMgrQueryContext& aContext, CDesCArray& aSuids) const;
+	TUint32 HandleL(const TDesC& aSuid) const;
+    void InsertObjectL(CMTPObjectMetaData& aObject);
+    void InsertDPIDObjectL(TUint aDpId, TUint aUid);
+    void InsertObjectsL(RPointerArray<CMTPObjectMetaData>& aObjects);
+    void ModifyObjectL(const CMTPObjectMetaData& aObject);
+    TBool ObjectL(const TMTPTypeUint32& aHandle, CMTPObjectMetaData& aObject) const;
+    TBool ObjectL(const TDesC& aSuid, CMTPObjectMetaData& aObject) const;
+    TUint ObjectOwnerId(const TMTPTypeUint32& aHandle) const;
+    TUint DPIDL(const TUint aUid, TBool& aFlag) const;    
+	TMTPTypeUint128 PuidL(TUint32 aHandle) const;
+	TMTPTypeUint128 PuidL(TInt64 aObjectUid) const;
+	TMTPTypeUint128 PuidL(const TDesC& aSuid) const;
+    void RemoveObjectL(const TMTPTypeUint32& aHandle);
+    void RemoveObjectL(const TDesC& aSuid);
+    void RemoveObjectsL(const CDesCArray& aSuids);
+    void RemoveObjectsL(TUint aDataProviderId);
+	void ReserveObjectHandleL(CMTPObjectMetaData& aObject, TUint64 aSpaceRequired);
+	void UnreserveObjectHandleL(const CMTPObjectMetaData& aObject);
+
+    TAny* MtpDeltaDataMgr();
+    
+private:
+    
+    CMTPObjectMgr();
+    void ConstructL();
+    
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+    /**
+    The object meta data store.
+    */
+    CMTPObjectStore*    iObjectStore;
+    };
+    
+#endif // CMTPOBJECTMGR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpobjectstore.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,349 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+ */
+
+#ifndef CMTPOBJECTSTORE_H
+#define CMTPOBJECTSTORE_H
+
+#include <badesca.h>
+#include <d32dbms.h>
+
+#include "mtpframeworkconst.h"
+#include "rmtpframework.h"
+#include "mtpdebug.h"
+
+class CFileStore;
+class CMTPHandleAllocator;
+class CMTPObjectMetaData;
+class CMTPPuidMgr;
+class CMTPReferenceMgr;
+class CMTPTypeArray;
+class RMTPObjectMgrQueryContext;
+class TMTPTypeUint32;
+class TMTPTypeUint128;
+class TMTPObjectMgrQueryParams;
+class CMtpDeltaDataMgr;
+class CMTPDPIDStore;
+class CMTPPkgIDStore;
+/** 
+ Implements the MTP object meta data store, which manages the storage/mapping of object handle and suid, and puid using DMBS.
+ Note, the CMTPObjectMgr acts as a shim class which forwards all the requests to the CMTPObjectStore. 
+ The reason is that later on, the class CMTPObjectStore will also implement the reference manager and puid manager
+ functionalities.  Having a single class implements all these will enable us to use a single database with multiple 
+ tables.
+
+ @internalComponent
+ 
+ */
+class CMTPObjectStore : public CBase
+	{
+	class CDbCompactor : public CBase
+		{
+	public:
+		inline static CDbCompactor* NewL(RDbNamedDatabase* aDatabase)
+			{
+			CDbCompactor* self = new (ELeave) CDbCompactor(aDatabase);
+			return self;
+			}
+		inline void Compact()
+			{
+			if (!((++iCompactCnt) % KCompactCnt))
+				{
+				RDbDatabase::TSize size = iDatabase->Size();
+				iDatabase->Compact();
+				}
+			}
+		inline ~CDbCompactor()
+			{
+			}
+	private:
+		inline CDbCompactor(RDbNamedDatabase* aDatabase) : iDatabase(aDatabase)
+			{
+			}
+
+	private:
+		RDbNamedDatabase* iDatabase;
+		TUint8 iCompactCnt;
+		static const TUint8 KCompactCnt = 32; //Use this value make the performance better haven't test other value
+		};
+
+	class MTraverseAction
+		{
+	public:
+		typedef enum {EOnlyLoadedDP, EAllDP} TActionTarget;
+		MTraverseAction(TActionTarget aTarget) : iActionTarget(aTarget)
+			{
+			}
+		TActionTarget Target()
+			{
+			return iActionTarget;
+			}
+		virtual void DoL(RDbTable& aTable) = 0;
+		
+	private:
+		TActionTarget iActionTarget;
+		};
+	class TCountAction : public MTraverseAction
+		{
+	public:
+		TCountAction(TUint& aCounter, TActionTarget aTarget = EOnlyLoadedDP) : MTraverseAction(aTarget), iCounter(aCounter)
+			{
+			}
+		void DoL(RDbTable& /*aTable*/)
+			{
+			++iCounter;
+			}
+	private:
+		TUint& iCounter;
+		};
+
+	class TGetHandlesAction : public MTraverseAction
+		{
+	public:
+		TGetHandlesAction(RArray<TUint>& aHandles, TActionTarget aTarget = EOnlyLoadedDP) : MTraverseAction(aTarget), iHandles(aHandles)
+			{
+			}
+		void DoL(RDbTable& aTable)
+			{
+			iHandles.AppendL(aTable.ColUint32(EObjectStoreHandleId));
+			}
+	private:
+		RArray<TUint>& iHandles;
+		};
+
+	class TGetSuidsAction : public MTraverseAction
+		{
+	public:
+		TGetSuidsAction(CDesCArray& aSuids, TActionTarget aTarget = EOnlyLoadedDP) : MTraverseAction(aTarget), iSuids(aSuids)
+			{
+			}
+		void DoL(RDbTable& aTable)
+			{
+			TFileName buf;
+			RDbColReadStream suid;
+			suid.OpenLC(aTable, EObjectStoreSUID);
+			suid.ReadL(buf, aTable.ColLength(EObjectStoreSUID));
+			suid.Close();
+			CleanupStack::PopAndDestroy();
+			iSuids.AppendL(buf);
+			}
+	private:
+		CDesCArray& iSuids;
+		};
+	
+	class TDelAction : public MTraverseAction
+		{
+	public:
+		TDelAction(CMTPObjectStore& aStore, TActionTarget aTarget = EOnlyLoadedDP) : MTraverseAction(aTarget), iStore(aStore)
+			{
+			}
+		void DoL(RDbTable& aTable)
+			{
+			aTable.DeleteL();
+			iStore.IncTranOpsNumL();
+			}
+	private:
+		CMTPObjectStore& iStore;
+		};
+	
+public:
+
+	static CMTPObjectStore* NewL();
+	~CMTPObjectStore();
+
+public:
+
+	RDbDatabase& Database();
+	CMTPDPIDStore& DPIDStore() const;
+	CMTPPkgIDStore& PkgIDStore() const;
+	CMTPReferenceMgr& ReferenceMgr() const;
+	CMtpDeltaDataMgr* MtpDeltaDataMgr() const;
+	void RestorePersistentObjectsL(TUint aDataProviderId);
+	void RemoveObjectsByStorageIdL(TUint32 aStorageId);
+	void RemoveNonPersistentObjectsL(TUint aDataProviderId);
+	void MarkNonPersistentObjectsL(TUint aDataProviderId, TUint32 aStorageId);
+	void EstablishDBSnapshotL(TUint32 aStorageId);
+	void CleanDBSnapshotL();
+	void MarkDPLoadedL(TUint aDataProviderId, TBool aFlag);
+
+public:
+
+	TUint CountL(const TMTPObjectMgrQueryParams& aParams) const;
+	void GetObjectHandlesL(const TMTPObjectMgrQueryParams& aParams, RMTPObjectMgrQueryContext& aContext, RArray<TUint>& aHandles) const;
+	void GetObjectSuidsL(const TMTPObjectMgrQueryParams& aParams, RMTPObjectMgrQueryContext& aContext, CDesCArray& aSuids) const;
+	void TraverseL(const TMTPObjectMgrQueryParams& aParams, MTraverseAction& action) const;
+	void CalcFreeHandlesL(TUint aDataProviderId);
+	void CommitReservedObjectHandleL(CMTPObjectMetaData& aObject);
+	TUint32 HandleL(const TDesC& aSuid) const;
+	TUint32 HandleL(TUint32 aSuidHash, const TDesC& aSuid) const;
+	void InsertObjectL(CMTPObjectMetaData& aObject);
+	void InsertObjectsL(RPointerArray<CMTPObjectMetaData>& aObjects);
+	void ModifyObjectL(const CMTPObjectMetaData& aObject);
+	TBool ObjectL(const TMTPTypeUint32& aHandle, CMTPObjectMetaData& aObject) const;
+	TBool ObjectL(const TDesC& aSuid, CMTPObjectMetaData& aObject) const;
+	TBool ObjectExistsL(const TUint32 aHandle);
+	TMTPTypeUint128 PuidL(const TUint32 aHandle);
+	TMTPTypeUint128 PuidL(const TDesC& aSuid);
+
+	const TPtrC ObjectSuidL(TUint32 aHandle) const;
+	void RemoveObjectL(const TMTPTypeUint32& aHandle);
+	void RemoveObjectL(const TDesC& aSuid);
+	void RemoveObjectsL(const CDesCArray& aSuids);
+	void RemoveObjectsL(TUint aDataProviderId);
+	void ReserveObjectHandleL(CMTPObjectMetaData& aObject, TUint64 aSpaceRequired);
+	void UnreserveObjectHandleL(const CMTPObjectMetaData& aObject);
+	void IncTranOpsNumL();
+	TBool IsMediaFormat(TUint32 aFormatCode);
+
+	void BeginTransactionL();
+	void CommitTransactionL();
+
+	void CleanL();
+	TUint ObjectOwnerId(const TMTPTypeUint32& aHandle) const;
+private:
+
+	/**
+	 Enumeration representing the column fields in the object store DBMS, this definition must exactly match the sequence
+	 defined in KSQLCreateHandleTableText
+	 //During insert a object, only the following items is provided in the CMTPObjectMetaData
+	 //DPId
+	 //Format
+	 //FormatSubcode
+	 //StorageID
+	 //Modes
+	 //ParentHandle
+	 //
+	 //Handle is allocated by MTP framework
+	 //NonConsumable is inserted only by FileDP, for objects manged by LicenseeDP, its values is meaningless
+	 */
+	enum TObjectStore
+		{
+		EObjectStoreHandleId = 1,
+		EObjectStoreSUIDHash = 2,
+		EObjectStoreSUID = 3,
+		EObjectStoreDataProviderId = 4,
+		EObjectStoreFormatCode = 5,
+		EObjectStoreFormatSubCode = 6,
+		EObjectStoreStorageId = 7,
+		EObjectStoreModes = 8,
+		EObjectStorePOUID = 9,
+		EObjectStoreParentHandle = 10,
+		EObjectStoreDPFlag = 11,
+		EObjectStoreNonConsumable = 12,
+		EObjectStoreName = 13
+		};
+
+	class CEnumertingCacheItem : public CBase
+		{
+	public:
+		static CEnumertingCacheItem* NewLC(TUint32 aSuidHash, TUint32 aHandle, TUint32 aFormat, TUint64 aId, TUint8 aDpID)
+			{
+			CEnumertingCacheItem* self = new (ELeave) CEnumertingCacheItem(aSuidHash, aHandle, aFormat, aId, aDpID);
+			CleanupStack::PushL(self);
+			return self;
+			}
+		static CEnumertingCacheItem* NewL(TUint32 aSuidHash, TUint32 aHandle, TUint32 aFormat, TUint64 aId, TUint8 aDpID)
+			{
+			CEnumertingCacheItem* self = CEnumertingCacheItem::NewLC(aSuidHash, aHandle, aFormat, aId, aDpID);
+			CleanupStack::Pop();
+			return self;
+			}
+		static TInt Compare(const CEnumertingCacheItem& aFirst, const CEnumertingCacheItem& aSecond);
+		CEnumertingCacheItem(TUint32 aSuidHash, TUint32 aHandle, TUint32 aFormat, TUint64 aId, TUint8 aDpID);
+		~CEnumertingCacheItem()
+			{
+			delete iSuid;
+			}
+		TUint32 iObjHandleId;
+		TUint32 iObjSuiIdHash;
+		TUint32 iFormatcode;
+		TUint64 iPOUID;
+		HBufC* iSuid;
+		TPtrC iSuidPtr;
+		TUint8 iDpID;
+		};
+
+	CMTPObjectStore();
+	void ConstructL();
+
+private:
+
+	TBool LocateByHandleL(const TUint aHandle, const TBool aReadTable = ETrue) const;
+	TBool LocateBySuidL(const TDesC& aSuid) const;
+
+	void BuildObjectMetaDataL(CMTPObjectMetaData& aBuf, const RDbTable& aTable) const;
+	void InitializeDbL();
+	void CreateDbL(const TDesC& aFileName);
+	TInt OpenDb(const TDesC& aFileName);
+	void CloseDb();
+
+	void CreateHandleTableL();
+	void CreateHandleIndexL();
+	void CreateStorageTableL();
+	void CreateStorageIndexL();
+
+	void GetFullPathName(const TDesC& aName, TFileName& aFileName) const;
+
+	TBool GetObjectL(TUint32 aHandle, CMTPObjectMetaData& aObject) const;
+
+	static void DBUpdateFailRecover(TAny* aTable);
+    TBool IsInvalidHandle( TUint32 aHandle ) const;
+    TBool FilterObject(const RDbTable& aCurrRow,const TUint32 aStorageID,const TUint32 aFormatCode,const TUint32 aDpID) const;
+    void DbColWriteStreamL(RDbTable& aTable, TDbColNo aCol, const TDesC16& aDes);
+    void DbColReadStreamL(const RDbTable& aTable, TDbColNo aCol, TDes16& aDes) const;    
+
+private:
+
+	static const TUint KQueryWindowForeSlots = 512;
+	static const TUint KQueryWindowRearSlots = 0;
+	
+	mutable RDbTable						iBatched;
+	mutable RDbTable						iBatched_SuidHashID;
+	mutable RDbNamedDatabase				iDatabase;
+	mutable TBuf<KMTPMaxSqlStatementLen>	iSqlStatement;
+	mutable TUint32							iCachedHandle;
+	mutable TUint32							iCachedSuidHash;
+	
+	RArray<TUint>							iNonPersistentDPList;
+	//The following object is used for enumerating cache, will be closed after the enumeration is completed.
+	RPointerArray<CEnumertingCacheItem>		iEnumeratingCacheObjList;
+	RMTPFramework							iSingletons;
+	
+	
+	TUint32									iTransactionOps;
+	TUint32									iMaxCommitLimit;
+	TUint32									iMaxCompactLimit;
+	TBool									iUpdateDeltaDataTable;
+	TBool									iCacheExist;
+	
+	CMTPReferenceMgr*						iReferenceMgr;
+	CMTPHandleAllocator*					iHandleAllocator;
+	CEnumertingCacheItem*					iSentinal;
+	CMTPDPIDStore*							iDPIDStore;
+	CMTPPkgIDStore*							iPkgIDStore;
+	CMtpDeltaDataMgr* 						iMtpDeltaDataMgr;
+	CDbCompactor*							iCompactor;
+	mutable TFileName                       iSuidBuf;
+	/**
+	 FLOGGER debug trace member variable.
+	 */
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+	};
+
+#endif // CMTPOBJECTSTORE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpparserrouter.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,678 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPPARSERROUTER_H
+#define CMTPPARSERROUTER_H
+
+#include <e32cmn.h>
+#include <mtp/tmtptyperequest.h>
+
+#include "cmtpdataprovidercontroller.h"
+#include "mtpdebug.h"
+#include "rmtpframework.h"
+
+class CMTPConnection;
+class CMTPDataProvider;
+class MMTPConnection;
+class TMTPTypeEvent;
+
+/**
+Implements the MTP framework parser/router singleton. 
+
+The MTP framework parser/router singleton is responsible for directing received
+MTP operation request (and event) datasets to the appropriate data provider(s) 
+for processing, and performs the following major functions: 
+    
+    1.  Parses received operation request and event datasets to extract and 
+        coarse grain validate routing data (@see ParseOperationRequestL).
+    2.  Executes one or more routing algorithms to select the set of data 
+        provider targets able to service the operation or event 
+        (@see RouteOperationRequestL).
+    3.  (Optionally) dispatches the request or event (@see ProcessRequestL).
+    
+There are two basic scenarios which the parser/router must handle, and a 
+different set of APIs is provided for each. These scenarios are:
+
+    1.  The initial routing of operations as they are first received. This 
+        routing is initiated by the MTP framework using the @see ProcessRequestL 
+        API. This API executes all three of the functions identified above.
+    2.  The secondary routing of those operations which cannot be dispatched 
+        directly. Either because they require the combined processing 
+        capabilities of multiple data providers to produce an aggregated 
+        response, or; because they cannot be routed using data available during
+        the operation request phase and can only be routed to their final 
+        target using data available during the operation data phase. This 
+        secondary routing is performed by the MTP framework's proxy data 
+        provider using the @see ParseOperationRequestL and 
+        @see RouteOperationRequestL APIs. These APIs respectively execute the 
+        first two functions identified above, which are separated in order to 
+        allow additional information to be added to the routing data by the 
+        proxy data provider. The third function identified above is not executed 
+        in this scenario, since a very different dispatching mechanism must be 
+        used by the proxy data provider. 
+
+The parser/router implements a number of different routing algorithm types, 
+some of which are further decomposed into sub-types to achieve a finer level of 
+routing granularity and control. In combination these algorithms support the 
+following general routing mechanisms:
+    
+    1.  Device - A subset of device oriented MTP operations are always 
+        dispatched to the device data provider.
+    2.  Proxy - A subset of MTP operations cannot be dispatched directly. 
+        Either they require the combined processing capabilities of multiple 
+        data providers to produce an aggregated response, or cannot be routed 
+        using data available from the operation dataset alone. These operations
+        are dispatched to the proxy data provider for additional processing. 
+    3.  Object Handle - MTP object handles generated by the MTP framework are 
+        encoded with a data provider identifier to efficiently route those MTP 
+        operations which supply an object handle as a parameter.
+    4.  StorageID - MTP storage identifiers generated by the MTP framework are 
+        encoded with a data provider identifier to efficiently route those MTP 
+        operations which supply a storage identifier as a parameter.
+    5.  Operation Parameter - On being loaded each data provider supplies a set 
+        of configuration data (MTP operation codes, event codes, object 
+        property codes, device property codes, and storage system types) which 
+        collectively define the set of MTP operation requests that it wishes to 
+        receive.
+    6.  Request Registration - Data providers may optionally register MTP 
+        operation request datasets with the framework which, when subsequently 
+        matched, will be routed to them. This mechanism is used to route those 
+        MTP operation types which are paired to complete over two transaction 
+        cycles (e.g. SendObjectInfo/SendObject). It may also be used to route 
+        vendor extension operation requests.
+
+The following routing algorithm types are implemeted:
+
+    1.  Operation Parameter Routing
+
+        Operation parameter routing is the primary routing mechanism and by 
+        default is enabled for both initial and secondary proxy routing 
+        scenarios. Operation parameter routing involves selecting one or more 
+        data provider targets using routing data obtained from or related to 
+        the supplied operation dataset parameters using one of the following 
+        sub-types:
+        
+        o   Parameter lookup routing sub-types, which match operation dataset 
+            parameter data with the set of supported capabilities registered 
+            by each data provider on being loaded, or;
+        o   Parameter decode routing sub-types, which extract data provider 
+            target identifiers encoded into the parameter data itself.
+
+        The parameter lookup routing sub-types are table driven and utilise 
+        binary search techniques to minimise processing overhead. The 
+        following parameter lookup routing sub-types (tables) are implemented,
+        each characterised by the combination of parameters they require to map
+        to a routing target:
+        
+        o   DevicePropCode
+        o   ObjectPropCode
+        o   OperationCode
+        o   StorageType
+        o   FormatCode + FormatSubcode
+        o   FormatCode + OperationCode
+        o   StorageType + OperationCode
+        o   FormatCode + FormatSubcode + StorageType
+
+        These routing tables may be further characterised by modifier flags 
+        which e.g. allow or disallow duplicate entries, or specify ascending 
+        or descending sort orders which in turn can manipulate the order in 
+        which proxy targets are processed.
+
+        The parameter decode routing sub-types extract routing target 
+        identifiers directly from the operation dataset parameter data itself. 
+        The following parameter decode routing sub-types are implemented:
+
+        o   Object Handle
+        o   StorageID
+        
+    2.  Framework Routing
+
+        By default, framework routing is enabled during initial operation 
+        routing only and not during secondary proxy routing. Framework routing 
+        directs a sub-set of MTP operations to one or other of the framework 
+        data providers. Using one of the following routing sub-types: 
+        
+        o   Device DP. A fixed sub-set of MTP operations are always dispatched 
+            to the device data provider.
+        o   Proxy DP. A fixed sub-set of MTP operations are always dispatched 
+            to the proxy data provider. In addition, any operations which yield
+            multiple routing targets will also be routed to the proxy data 
+            provider.
+            
+    3.  Request Registration Routing
+
+        By default, request registration routing is enabled during initial 
+        operation routing only and not during secondary proxy routing. Data 
+        providers may optionally register MTP operation request datasets with 
+        the framework which, when subsequently matched, will be routed to them.
+        This mechanism is used to process those MTP operation types which are 
+        paired to complete over two transaction cycles (e.g. 
+        SendObjectInfo/SendObject). It may also be used to route vendor 
+        extension operation requests.
+
+        Request registration routing does not implement any routing sub-types.
+
+@internalTechnology
+ 
+*/
+class CMTPParserRouter : public CBase
+    {
+public:
+        
+    /**
+    Defines the MTP operation routing parameter data, which is an output of the 
+    parser/routers @see ParseOperationRequestL API and an input to the 
+    @see RouteOperationRequestL API. 
+    */
+    class TRoutingParameters
+        {
+    public: 
+    
+        /**
+        The routing parameter type identifiers. Note that not all parameter
+        types may be defined, only those deemed necessary to route the 
+        associated operation dataset.
+        */
+        enum TParameterType
+            {
+            /**
+            The DevicePropCode parameter.
+            */
+            EParamDevicePropCode,
+            
+            /**
+            The object FormatCode parameter.
+            */
+            EParamFormatCode,
+            
+            /**
+            The object format sub-code parameter. This parameter is undefined 
+            unless @see EFormatCode contains a value of 
+            @see EMTPFormatCodeAssociation, in which case this parameter should
+            the specify the MTP association type code.
+            */
+            EParamFormatSubCode,
+            
+            /**
+            The ObjectHandle parameter.
+            */
+            EParamObjectHandle,
+            
+            /**
+            The ObjectPropCode parameter.
+            */
+            EParamObjectPropCode,
+            
+            /**
+            The StorageId parameter.
+            */
+            EParamStorageId,
+            
+            /**
+            The storage system type parameter.
+            */
+            EParamStorageSystemType,
+            
+            /**
+            The invalid dataset flag. When set, this flag indicates that an 
+            operation dataset validation check failed.
+            */
+            EFlagInvalid,
+            
+            /**
+            The routing type codes. This flag is intended for internal use 
+            only.
+            */
+            EFlagRoutingTypes,
+            
+            /**
+            The ServiceID parameter.
+            */
+            EParamServiceId,
+            
+            /**
+            */
+            ENumTypes
+            };
+        
+    public: 
+    
+        IMPORT_C TRoutingParameters(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+        TRoutingParameters(const TRoutingParameters& aParams);
+    
+        IMPORT_C MMTPConnection& Connection() const;
+        IMPORT_C TUint Param(TParameterType aId) const;
+        IMPORT_C void Reset();
+        IMPORT_C const TMTPTypeRequest& Request() const; 
+        IMPORT_C void SetParam(TParameterType aId, TUint aVal);
+        
+    private: // Not owned
+    
+        /**
+        The handle of the MTP connection on which the operation is being
+        processed.
+        */
+        MMTPConnection&        			iConnection;
+        
+        /**
+        The operation dataset.
+        */
+        const TMTPTypeRequest&			iRequest; 
+        
+    private: // Owned
+    
+        TUint                           iParameterData[ENumTypes];
+        TFixedArray<TUint, ENumTypes>	iParameters;
+        };
+
+public:
+
+    static CMTPParserRouter* NewL(); 
+    virtual ~CMTPParserRouter();
+    
+    IMPORT_C void ConfigureL();
+    IMPORT_C TBool OperationSupportedL(TUint16 aOperation) const;
+    IMPORT_C void ParseOperationRequestL(TRoutingParameters& aParams) const;
+    IMPORT_C void RouteOperationRequestL(const TRoutingParameters& aParams, RArray<TUint>& aTargets) const;
+    IMPORT_C TBool RouteRequestRegisteredL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const;
+    
+    void ProcessEventL(const TMTPTypeEvent& aEvent, CMTPConnection& aConnection) const;
+    void ProcessRequestL(const TMTPTypeRequest& aRequest, CMTPConnection& aConnection) const;
+    void RouteRequestRegisterL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TInt aId);
+    void RouteRequestUnregisterL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection);
+
+private: // Owned
+
+    /**
+    Defines the routing type codes. These codes are partitioned into 
+    two sub-fields as follows:
+    
+        1.  Bits  0-15 - routing type identifier.
+        2.	Bits 16-23 - unused.
+        3.  Bits 24-31 - routing type modifier flags.
+    */
+    enum TRoutingType
+        {
+        /**
+        The routing type modifier flags mask.
+        */
+        ETypeFlagMask            	= 0xFF000000,
+        
+        /**
+        The single target flag. When set this flag will result in at most one
+        eligible routing target being selected. If multiple eligible targets 
+        exists then the first eligible target will be selected.
+        */
+        ETypeFlagSingleTarget       = 0x01000000,
+        
+        /**
+        The routing type identifier mask.
+        */
+        ETypeMask                   = 0x0000FFFF,
+        
+        /**
+        The framework routing type identifier.
+        */
+        ETypeFramework              = 0x00000001,
+        
+        /**
+        The operation parameter routing type identifier.
+        */
+        ETypeOperationParameter		= 0x00000002,
+        
+        /**
+        The request registration routing type identifier.
+        */
+        ETypeRequestRegistration	= 0x00000004,
+        };
+    
+    /**
+    Defines the routing sub-type codes. These codes are partitioned into 
+    two sub-fields as follows:
+    
+        1.  Bits  0-15 - routing sub-type (map) index.
+        2.  Bits 16-23 - routing sub-type modifier flags.
+        3.  Bits 24-31 - routing sub-type parameter count type.
+    */
+    enum TRoutingSubType
+        {
+        /**
+        The routing sub-type identifier (table index) mask.
+        */
+        ESubTypeIndexMask                        	= 0x0000FFFF,
+        
+        /**
+        The routing sub-type modifier bit flags mask.
+        */
+        ESubTypeFlagMask                            = 0x00FF0000,
+        
+        /**
+        The null flag bits.
+        */
+        ESubTypeFlagNone                            = 0x00000000,
+        
+        /**
+        The duplicates enabled flag bits. When set this flag indicates that 
+        duplicate routing table entries are permitted.
+        */
+        ESubTypeFlagEnableDuplicates                = 0x00010000,
+        
+        /**
+        The order descending flag bits. When set this flag indicates that 
+        routing table entries are to be arranged in descending rather than 
+        ascending order.
+        */
+        ESubTypeFlagOrderDescending               	= 0x00020000,
+        
+        /**
+        The routing sub-type parameter count mask.
+        */
+        ESubTypeParamsMask                       	= 0xFF000000,
+        
+        /**
+        The zero parameter count code.
+        */
+        ESubTypeParams0                           	= 0x00000000,
+        
+        /**
+        The one parameter count code.
+        */
+        ESubTypeParams1                          	= 0x01000000,
+        
+        /**
+        The two parameter count code.
+        */
+        ESubTypeParams2                           	= 0x02000000,
+        
+        /**
+        The three parameter count code.
+        */
+        ESubTypeParams3                           	= 0x03000000,
+        
+        /**
+        The DevicePropCode operation parameter lookup routing sub-type.
+        */
+        ESubTypeDevicePropCode                  	= (0x00000000 | ESubTypeParams1 | ESubTypeFlagNone),
+        
+        /**
+        The ObjectPropCode operation parameter lookup routing sub-type.
+        */
+        ESubTypeObjectPropCode                   	= (0x00000001 | ESubTypeParams1 | ESubTypeFlagEnableDuplicates),
+        
+        /**
+        The OperationCode operation parameter lookup routing sub-type.
+        */
+        ESubTypeOperationCode                    	= (0x00000002 | ESubTypeParams1 | ESubTypeFlagEnableDuplicates),
+        
+        /**
+        The StorageType operation parameter lookup routing sub-type.
+        */
+        ESubTypeStorageType                     	= (0x00000003 | ESubTypeParams1 | ESubTypeFlagEnableDuplicates),
+        
+        /**
+        The FormatCode + FormatSubcode operation parameter lookup routing 
+        sub-type.
+        */
+        ESubTypeFormatCodeFormatSubcode          	= (0x00000004 | ESubTypeParams2 | (ESubTypeFlagEnableDuplicates | ESubTypeFlagOrderDescending)),
+        
+        /**
+        The FormatCode + OperationCode operation parameter lookup routing 
+        sub-type.
+        */
+        ESubTypeFormatCodeOperationCode          	= (0x00000005 | ESubTypeParams2 | ESubTypeFlagEnableDuplicates),
+        
+        /**
+        The StorageType + OperationCode operation parameter lookup routing 
+        sub-type.
+        */
+        ESubTypeStorageTypeOperationCode            = (0x00000006 | ESubTypeParams2 | ESubTypeFlagEnableDuplicates),
+        
+        /**
+        The FormatCode + FormatSubcode + StorageType operation parameter 
+        lookup routing sub-type.
+        */
+        ESubTypeFormatCodeFormatSubcodeStorageType	= (0x00000007 | ESubTypeParams3 | ESubTypeFlagNone),
+        
+        /**
+        The ServiceID operation parameter lookup routing sub-type.
+        */
+        ESubTypeServiceIDOperationCode              = (0x00000008 | ESubTypeParams1 | ESubTypeFlagNone),
+        
+        /**
+        The device DP framework routing sub-type.
+        */
+        ESubTypeDpDevice                            = (0x00000009 | ESubTypeParams0 | ESubTypeFlagNone),
+        
+        /**
+        The proxy DP framework routing sub-type.
+        */
+        ESubTypeDpProxy                         	= (0x0000000A | ESubTypeParams0 | ESubTypeFlagNone),
+        
+        /**
+        The object owner operation parameter decode routing sub-type.
+        */
+        ESubTypeOwnerObject                     	= (0x0000000B | ESubTypeParams0 | ESubTypeFlagNone),
+        
+        /**
+        The storage owner operation parameter decode routing sub-type.
+        */
+        ESubTypeOwnerStorage                        = (0x0000000C | ESubTypeParams0 | ESubTypeFlagNone),
+        
+        /**
+        The default request registration routing sub-type.
+        */
+        ESubTypeRequestRegistration             	= (0x0000000D | ESubTypeParams0 | ESubTypeFlagNone),
+        
+        };
+        
+    /**
+    Defines the routing parameter IDs.
+    */
+    enum TRoutingParams
+        {
+        /**
+        The first parameter.
+        */
+        EParam1 = 0,
+        
+        /**
+        The second parameter.
+        */
+        EParam2 = 1
+        
+        /**
+        The third parameter.
+        */,
+        EParam3 = 2,
+        };
+
+    /**
+    Implements a simple single parameter map table entry which associates a 
+    single routing parameter value and target data provider identifier pair. 
+    */
+    class TMap
+        {
+    public:
+    
+        TMap(TUint aFrom);
+        TMap(TUint aFrom, TUint aTo, TUint aSubType);
+    
+    public:
+    
+        /**
+        The routing parameter.
+        */
+        TUint   iFrom;
+        
+        /**
+        The routing table sub-type code.
+        */
+        TUint   iSubType;
+    
+        /**
+        The routing target data provider identifier.
+        */
+        TUint	iTo;
+        };
+
+    /**
+    Implements a generic, multi-parameter routing table data structure. This 
+    table implements owns EITHER:
+
+        1.  A container of @see TMap node objects if implementing a single 
+            parameter table or the final level (n) of a multi-parameter table,
+            OR;
+        2.  A container of @see CMap branch objects if implementing an 
+            intermediate level (1 .. n-1) of a multi-parameter table.
+    */
+    class CMap : public CBase
+        {            
+    public:
+    
+        static CMap* NewLC(TUint aSubType);
+        ~CMap();
+        
+        TUint From() const;
+        void InitParamsL(RArray<TUint>& aFrom) const;
+        void InsertL(const RArray<TUint>& aFrom, TUint aTo);
+        void GetToL(const RArray<TUint>& aFrom, RArray<TUint>& aTo) const;
+        TUint SubType() const;
+        
+#ifdef __FLOG_ACTIVE
+        void FLOGMapL(RArray<TUint>& aFrom) const;
+        void FLOGMapEntryL(const RArray<TUint>& aFrom, TUint aTo) const;
+#endif
+        
+    private:
+    
+        static CMap* NewLC(TUint aFrom, TUint aSubType);
+        CMap(TUint aFrom, TUint aSubType);
+        void ConstructL();
+        
+        TInt BranchFind(TUint aFrom) const;
+        TUint BranchInsertL(TUint aFrom);
+        TInt NodeFind(TUint aFrom) const;
+        TInt NodeFind(const TMap& aNode) const;
+        TUint NodeInsertL(const TMap& aMap);
+        TUint Param(const RArray<TUint>& aFrom) const;
+        TUint ParamIdx(const RArray<TUint>& aFrom) const;
+        void SelectTargetAllL(const RArray<TUint>& aFrom, RArray<TUint>& aTo) const;
+        void SelectTargetMatchingL(const RArray<TUint>& aFrom, RArray<TUint>& aTo) const;
+        void SelectTargetSingleL(const RArray<TUint>& aFrom, RArray<TUint>& aTo) const;
+        
+        static TInt BranchOrderFromAscending(const CMap& aL, const CMap& aR);
+        static TInt BranchOrderFromDescending(const CMap& aL, const CMap& aR);
+        static TInt BranchOrderFromKeyAscending(const TUint* aL, const CMap& aR);
+        static TInt BranchOrderFromKeyDescending(const TUint* aL, const CMap& aR);
+        static TInt NodeOrderFromAscending(const TMap& aL, const TMap& aR);
+        static TInt NodeOrderFromDescending(const TMap& aL, const TMap& aR);
+        static TInt NodeOrderFromKeyAscending(const TUint* aL, const TMap& aR);
+        static TInt NodeOrderFromKeyDescending(const TUint* aL, const TMap& aR);
+        static TInt NodeOrderFromToAscending(const TMap& aL, const TMap& aR);
+        static TInt NodeOrderFromToDescending(const TMap& aL, const TMap& aR);
+        
+    private:
+
+        /**
+        FLOGGER debug trace member variable.
+        */
+        __FLOG_DECLARATION_MEMBER_MUTABLE;
+ 
+        /**
+        The routing parameter.
+        */
+        TUint               iFrom;
+        
+        /**
+        The routing table sub-type code.
+        */
+        TUint               iSubType;
+        
+        /**
+        The @see CMap branch object container. This container is only populated
+        if implementing an intermediate level (1 .. n-1) of a multi-parameter 
+        table.
+        */
+        RPointerArray<CMap> iToBranches;
+        
+        /**
+        The @see TMap node object container. This container is only populated 
+        if implementing a single parameter table or the final level (n) of a 
+        multi-parameter table.
+        */
+        RArray<TMap>        iToNodes;
+        };
+    
+private:
+    
+    CMTPParserRouter();
+    void ConstructL();
+    
+    static void GetMapParameterIdsL(TUint aSubType, RArray<TUint>& aP1Codes, RArray<TUint>& aP2Codes, RArray<TUint>& aP3Codes);
+    static void SelectTargetL(TUint aTarget, RArray<TUint>& aTargets);
+    
+    void Configure1ParameterMapL(TUint aSubType, const RArray<TUint>& aP1Codes);
+    void Configure2ParameterMapL(TUint aSubType, const RArray<TUint>& aP1Codes, const RArray<TUint>& aP2Codes);
+    void Configure3ParameterMapL(TUint aSubType, const RArray<TUint>& aP1Codes, const RArray<TUint>& aP2Codes, const RArray<TUint>& aP3Codes);
+    void GetConfigParametersL(const CMTPDataProvider& aDp, const RArray<TUint>& aCodes, RArray<TUint>& aParams) const;
+    void GetRoutingSubTypesL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const;
+    void GetRoutingSubTypesDeleteRequestL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const;
+    void GetRoutingSubTypesCopyMoveRequestL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const;
+    void GetRoutingSubTypesGetObjectPropListRequestL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const;
+    void GetRoutingSubTypesSendObjectPropListRequestL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const;
+    void GetRoutingSubTypesDeleteObjectPropListL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const;
+    void GetRoutingSubTypesGetFormatCapabilitiesL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const;
+    void ParseOperationRequestParameterL(TMTPTypeRequest::TElements aParam, TRoutingParameters::TParameterType aType, TRoutingParameters& aParams) const;
+    void RouteOperationRequestNParametersL(TUint aRoutingSubType, const TRoutingParameters& aParams, RArray<TUint>& aTargets) const;
+    void RouteOperationRequest0ParametersL(TUint aRoutingSubType, const TRoutingParameters& aParams, RArray<TUint>& aTargets) const;
+    TUint RoutingTargetL(const TMTPTypeRequest& aRequest, CMTPConnection& aConnection) const;
+    void SelectSubTypeRoutingL(TRoutingSubType aSubType, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes, RArray<TRoutingParameters>& aParams) const; 
+    void SelectSubTypeValidationL(TRoutingSubType aSubType, RArray<TUint>& aValidationSubTypes) const;
+    void ValidateTargetsL(const TRoutingParameters& aParams, const RArray<TUint>& aValidationSubTypes, RArray<TUint>& aTargets) const;
+
+    static TUint Flags(TUint aSubType);
+    static TUint Index(TUint aSubType);
+    static TUint Params(TUint aSubType);
+    static TUint ParamsCount(TUint aSubType);
+    static TUint SubType(TUint aIndex, TUint aFlags, TUint aParamsCount);
+    
+#ifdef __FLOG_ACTIVE
+    void FLOGMapsL() const;
+#endif
+
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    /**
+    The operation parameter routing sub-type map tables.
+    */
+    RPointerArray<CMap> iMaps;
+    
+    /**
+    The framework singletons.
+    */
+    RMTPFramework       iSingletons;
+    };
+
+#endif // CMTPPARSERROUTER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtppkgidstore.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,60 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef CMTPPKGIDSTORE_H
+#define CMTPPKGIDSTORE_H  
+/** 
+Implements the MTP package ID store interface.
+@internalComponent
+ 
+*/
+//#include <e32base.h>
+#include <d32dbms.h>
+#include "mtpframeworkconst.h"
+
+class RDbDatabase;
+
+/**
+ * Mapping of Installed data provider <sis package id, dp id>
+ */
+class CMTPPkgIDStore :  public CBase        
+    {
+public:   
+    static CMTPPkgIDStore* NewL(RDbDatabase& aDatabase);    
+    ~CMTPPkgIDStore();
+
+public:     
+    void InsertPkgIdL(TUint aDpId, TUint aPkgId);
+    const RArray<TUint>& DPIDL() const;
+    TUint PKGIDL (TUint aIndex) const;
+    TInt  RemoveL(TUint aDpId);
+
+private: 
+    enum TPkgIDStore
+        {
+        EPkgIDStoreDataProviderId   = 1,
+        EPkgIDStorePKGID            = 2
+        };   
+    CMTPPkgIDStore(RDbDatabase& aDatabase);
+    void CreatePkgIDStoreTableL();
+    void ConstructL();   
+private:
+    RDbDatabase&  iDatabase;   
+    mutable TBuf<KMTPMaxSqlStatementLen> iSqlStatement;   
+    RArray<TUint> iDPIDs;
+    RArray<TUint> iPkgIDs;
+    };
+    
+#endif // CMTPPKGIDSTORE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpreferencemgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,83 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPREFERENCEMGR_H
+#define CMTPREFERENCEMGR_H
+
+#include <e32base.h>
+#include <mtp/mmtpreferencemgr.h>
+
+#include "mtpframeworkconst.h"
+#include "rmtpframework.h"
+
+class RDbDatabase;
+class CMTPObjectStore;
+
+/** 
+Implements the MTP reference manager interface.
+
+@internalTechnology
+ 
+*/
+class CMTPReferenceMgr : public CBase, public MMTPReferenceMgr
+    {
+public:    
+    static CMTPReferenceMgr* NewL(CMTPObjectStore& aObjectStore);
+    ~CMTPReferenceMgr();
+    
+    void RemoveReferencesL(TUint aHandle);
+    
+public: // From MMTPReferenceMgr
+
+    CMTPTypeArray* ReferencesLC(const TMTPTypeUint32& aFromHandle) const;
+    CDesCArray* ReferencesLC(const TDesC& aParentSuid) const;
+    void RemoveReferencesL(const TDesC& aSuid);
+    void SetReferenceL(const TDesC& aFromSuid, const TDesC& aToSuid);
+    void SetReferencesL(const TDesC& aParentSuid, const CDesCArray& aToSuids);
+    void SetReferencesL(const TMTPTypeUint32& aFromHandle, const CMTPTypeArray& aToHandles);
+    
+private:
+    CMTPReferenceMgr(CMTPObjectStore& aObjectStore);
+    void ConstructL();
+    
+private:    
+    //helpers
+    void CreateTableL();
+    void CreateIndexL();
+    
+    CMTPTypeArray* GetReferencesLC(TUint aHandle) const;
+    CDesCArray* GetReferencesInDesLC(TUint aHandle) const;
+    void GetReferencesL(TUint aHandle, RArray<TUint>& aToHandles) const;
+    void SetReferencesL(TUint aHandle, const RArray<TUint>& aToHandles);
+    void SetReferenceL(TUint aHandle, TUint aToHandles);
+    //void AdjustReferencesL(RArray<TUint32>& aHandles) const;
+	void IncTranOpsNumL();
+	
+private: // Owned
+  
+    TBuf<KMTPMaxSqlStatementLen>    iSqlStatement;
+    
+private: // Not owned
+
+    RDbDatabase*                    iDatabase; 
+    CMTPObjectStore&			    iObjectStore;
+    mutable RDbTable 				iBatched;
+    };
+#endif // CMTPREFERENCEMGR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpserviceconfig.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,107 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef CMTPSERVICECONFIG_H_
+#define CMTPSERVICECONFIG_H_
+
+#include <e32base.h>
+#include <e32des8.h> 
+#include <barsc.h>
+#include <barsread.h>
+#include <e32cmn.h>
+
+#include <mtp/tmtptypeuint128.h>
+#include <mtp/tmtptypeguid.h>
+#include "cmtpserviceinfo.h"
+
+#include "mtpdebug.h"
+
+class TResourceReader;
+
+
+class CMTPServiceConfig : public CBase
+	{
+private:
+
+    class TSupportedService
+        {
+        public:
+            TSupportedService( const TMTPTypeGuid& aGUID, const TUint aServiceType, const TUint aResID );
+        public:
+            TMTPTypeGuid iGUID;
+            TUint   iServiceType;
+            TUint   iResourceID;
+        };
+    
+public:   
+ 
+    static CMTPServiceConfig* NewL( RFs& aRFs );
+    ~CMTPServiceConfig();	
+    
+    static TInt SupportedServiceOrderFromAscending( const TSupportedService& aL, const TSupportedService& aR);
+    static TInt SupportedServiceOrderFromKeyAscending( const TMTPTypeGuid* aL, const TSupportedService& aR);
+
+public:
+    TBool IsSupportedService( const TMTPTypeGuid& aServiceGUID ) const;
+    void LoadServiceDataL( const TMTPTypeGuid& aServiceGUID );
+    CMTPServiceInfo* ServiceInfo(const TMTPTypeGuid& aServiceGUID ) const;
+    CMTPServiceInfo* ServiceInfo(const TUint aServiceID) const;
+    TInt ServiceTypeOfSupportedService( const TMTPTypeGuid& aServiceGUID ) const;
+    
+private:
+    
+	CMTPServiceConfig( RFs& aRFs );
+    void ConstructL( const TDesC& aResourceFilename );
+    void InitializeL( TResourceReader& aReader );
+    TUint ServiceResourceIDL( const TMTPTypeGuid& aServiceGUID ) const;
+    
+    void StartReadUseServicesL( RResourceFile& aResFile, const TUint aResID, CMTPServiceInfo& aServiceInfo );
+    void StartReadServicePropertyNamespacesL(  RResourceFile& aResFile, const TUint aResID, RArray<TMTPTypeGuid>& aNamespaces );
+    void StartReadServicePropertiesL(  RResourceFile& aResFile, const TUint aNamespaceResID, const TUint aPropertiesResID, CMTPServiceInfo& aServiceInfo );
+    void StartReadServiceFormatsL(  RResourceFile& aResFile, const TUint aResID, CMTPServiceInfo& aServiceInfo );
+    void StartReadServiceMethodsL(  RResourceFile& aResFile, const TUint aResID, CMTPServiceInfo& aServiceInfo );
+    void StartReadServiceEventsL(  RResourceFile& aResFile, const TUint aResID, CMTPServiceInfo& aServiceInfo );
+    void StartReadServiceDataBlockL(  RResourceFile& aResFile, const TUint aResID, CMTPServiceInfo& aServiceInfo );
+    
+    TMTPTypeGuid ReadGUID( TResourceReader& aReader );
+    
+private:
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    
+    RFs&                             iRFs;
+    
+    /**
+     * service info store after loaded.
+     */
+    RPointerArray<CMTPServiceInfo>	        iServiceInfos;
+
+	/*
+	 * supported services
+	 */
+	RArray<TSupportedService>  iSupportedServices;
+		
+	};
+
+#endif /*CMTPSERVICECONFIG_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpserviceinfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,231 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// 
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef CMTPSERVICEINFO_H_
+#define CMTPSERVICEINFO_H_
+
+
+#include <e32base.h>
+#include <e32des8.h> 
+#include <e32cmn.h>
+
+
+#include <mtp/tmtptypeuint128.h>
+#include <mtp/tmtptypeguid.h>
+
+#include "mtpdebug.h"
+
+
+/** 
+Implements the MTP service configure interface.
+@internalComponent
+ 
+*/
+
+
+class TPKeyPair
+    {
+public:
+    TPKeyPair( const TMTPTypeGuid& aNamespace, const TUint aID );
+public:
+    TMTPTypeGuid iNamespace;
+    TUint     iPKeyId;
+    };
+
+class CServiceElementBase : public CBase
+    {
+public:
+    virtual ~CServiceElementBase();
+    IMPORT_C virtual TBool IsUsed();
+    IMPORT_C virtual TUint Code() const;
+    IMPORT_C virtual const TDesC& Name() const;
+    IMPORT_C virtual const TMTPTypeGuid& GUID() const;
+    
+    virtual void SetCode( const TUint aCode );
+    virtual TInt Compare( const CServiceElementBase& aR ) const;
+    
+protected:
+    CServiceElementBase(const TMTPTypeGuid& aGUID, HBufC* aName);
+    
+protected:
+    TUint16          iCode;
+    TMTPTypeGuid  iGUID;
+    HBufC*           iName;
+    };
+
+class CServiceProperty : public CServiceElementBase
+    {
+public:
+    static CServiceProperty* NewLC(const TMTPTypeGuid& aGUID, const TUint aPkeyID, HBufC* aName, const TUint aDataType, const TUint aGetSet, const TUint aFormFlag);
+
+    IMPORT_C const TMTPTypeGuid& Namespace() const;
+    IMPORT_C TUint PKeyID() const;
+    IMPORT_C TUint DataType() const;
+    IMPORT_C TUint GetSet() const;
+    IMPORT_C TUint FormFlag() const;
+    
+    
+private:
+    CServiceProperty( const TMTPTypeGuid& aGUID, const TUint aPkeyID, HBufC* aName, const TUint aDataType, const TUint aGetSet, const TUint aFormFlag );
+    void ConstructL();
+    
+private:
+    TUint            iPKeyId;
+    TUint16          iDataType;
+    TUint8           iGetSet;
+    TUint8           iFormFlag;
+    };
+
+
+class CServiceFormat : public CServiceElementBase
+    {
+public:
+    static CServiceFormat* NewLC(const TMTPTypeGuid& aGUID, HBufC* aName, const TUint aBaseFormat, HBufC* aMime );
+    IMPORT_C TUint FormatBase() const;
+    IMPORT_C const TDesC& MIMEType1() const;
+    ~CServiceFormat();
+    
+private:
+    CServiceFormat( const TMTPTypeGuid& aGUID, HBufC* aName, const TUint aBaseFormat, HBufC* aMime );
+    void ConstructL();
+    
+private:
+    TUint16     iFormatBase;
+    HBufC*      iMIMEType1;
+    };
+
+
+class CServiceMethod: public CServiceElementBase
+    {
+public:
+    static CServiceMethod* NewLC(const TMTPTypeGuid& aGUID, HBufC* aName, const TUint aAssFormat);
+    IMPORT_C TUint ObjAssociateFormatCode() const;
+    
+private:
+    CServiceMethod(const TMTPTypeGuid& aGUID, HBufC* aName, const TUint aAssFormat);
+    void ConstructL();
+    
+private:
+    TUint16     iObjAssociateFormatCode;
+    };
+
+class CServiceEvent : public CServiceElementBase
+    {
+public:
+    static CServiceEvent* NewLC(const TUint aCode, const TMTPTypeGuid& aGUID, HBufC* aName);
+
+private:
+    CServiceEvent(const TUint aCode, const TMTPTypeGuid& aGUID, HBufC* aName);
+    void ConstructL();
+
+    };
+
+
+class CMTPServiceInfo :
+    public CBase
+    {
+public:
+    static CMTPServiceInfo* NewLC();
+    ~CMTPServiceInfo();
+    
+private:
+    CMTPServiceInfo();
+    void ConstructL();
+    
+public:
+    static TInt ServicePropertyOrderFromAscending( const CServiceProperty& aL, const CServiceProperty& aR);
+    static TInt ServicePropertyOrderFromKeyAscending( const TPKeyPair* aL, const CServiceProperty& aR);
+    
+    static TInt ServiceElementBaseOrderFromAscending( const CServiceElementBase& aL, const CServiceElementBase& aR);
+    static TInt ServiceElementBaseOrderFromKeyAscending( const TMTPTypeGuid* aL, const CServiceElementBase& aR );
+    
+    static TInt ServiceFormatOrderFromAscending( const CServiceFormat& aL, const CServiceFormat& aR);
+    static TInt ServiceFormatOrderFromKeyAscending( const TMTPTypeGuid* aL, const CServiceFormat& aR );
+
+    static TInt ServiceMethodOrderFromAscending( const CServiceMethod& aL, const CServiceMethod& aR );
+    static TInt ServiceMethodOrderFromKeyAscending( const TMTPTypeGuid* aL, const CServiceMethod& aR );
+
+    static TInt ServiceEventOrderFromAscending( const CServiceEvent& aL, const CServiceEvent& aR );
+
+    
+public:
+    void SetServiceID( TUint aServiceID );
+    void SetServiceStorageID( TUint aStorageID );
+    void SetPersistentGUIDL( const TMTPTypeGuid& aGUID );
+    void SetServiceVersion( TUint aVersion );
+    void SetServiceGUIDL( const TMTPTypeGuid& aGUID );
+    void SetServiceName( HBufC* aName );
+    void SetServiceType( TUint aServiceType );
+    void SetBaseServiceID( TUint aID );
+    void AppendUserServiceL( const TMTPTypeGuid& aServiceGUID );
+    void InsertPropertyL( const CServiceProperty* aProperty );
+    void InsertFormatL( const CServiceFormat* aFormat );
+    void InsertMethodL( const CServiceMethod* aMethod );
+    void InsertEventL( const CServiceEvent* aEvent );
+    void AppendDataGUIDL( const TMTPTypeGuid& aGUID );
+    
+    IMPORT_C TUint ServiceID() const;
+    IMPORT_C TUint ServiceStorageID() const;
+    IMPORT_C const TMTPTypeGuid& ServicePersistentGUID()const;
+    IMPORT_C TUint ServiceVersion() const;
+    IMPORT_C const TMTPTypeGuid& ServiceGUID() const;
+    IMPORT_C const TDesC& ServiceName() const;
+    IMPORT_C TUint ServiceType() const;
+    IMPORT_C TUint BaseServiceID() const;
+    
+    CServiceProperty* ServiceProperty( const TMTPTypeGuid& aPKNamespace, const TUint aPKID ) const;
+    CServiceFormat* ServiceFormat( const TMTPTypeGuid& aGUID ) const;
+    CServiceMethod* ServiceMethod( const TMTPTypeGuid& aGUID ) const;
+    
+    IMPORT_C const RArray<TMTPTypeGuid>& UsedServiceGUIDs() const;
+    IMPORT_C const RPointerArray<CServiceProperty>& ServiceProperties() const;
+    IMPORT_C const RPointerArray<CServiceFormat>& ServiceFormats() const;
+    IMPORT_C const RPointerArray<CServiceMethod>& ServiceMethods() const;
+    IMPORT_C const RPointerArray<CServiceEvent>& ServiceEvents() const;
+    IMPORT_C const RArray<TMTPTypeGuid>& DataBlockGUIDs() const;
+
+    
+private:
+        TUint     iServiceId;
+        TUint     iServiceStorageId;
+        TMTPTypeGuid iPersistentGUID;
+        TUint     iServiceVersion;
+        TMTPTypeGuid iServiceGUID;
+        HBufC*      iServiceName;
+        TUint     iServiceType;
+        TUint     iBaseServiceId;
+
+        RArray<TMTPTypeGuid>     iUsedServiceGUIDs;
+        RPointerArray<CServiceProperty>   iServiceProperties;
+        RPointerArray<CServiceFormat>      iServiceFormats;
+        RPointerArray<CServiceMethod>     iServiceMethods;
+        RPointerArray<CServiceEvent>		iServiceEvents;
+        RArray<TMTPTypeGuid>     iDataBlock;
+        /**
+        FLOGGER debug trace member variable.
+        */
+        __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+    };
+
+
+
+
+#endif /* CMTPSERVICEINFO_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpservicemgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,108 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//  
+
+/**
+@file
+@internalComponent
+*/
+
+
+#ifndef CMTPSERVICEMGR_H_
+#define CMTPSERVICEMGR_H_
+
+#include <e32base.h>
+#include <e32cmn.h>
+
+
+#include "cmtpserviceinfo.h"
+#include "rmtpframework.h"
+#include "mtpdebug.h"
+
+class CMTPServiceConfig;
+
+/** 
+Implements the MTP service manager interface.
+@internalComponent
+ 
+*/
+
+class CMTPServiceMgr : public CBase
+	{
+public:   
+ 
+    static CMTPServiceMgr* NewL();
+    ~CMTPServiceMgr();	
+    
+private:
+    
+    CMTPServiceMgr();
+    void ConstructL();
+
+public:    
+	TInt GetServiceId(const TMTPTypeGuid& aServiceGUID, TUint& aServiceID) const;
+	IMPORT_C const RArray<TUint>& GetServiceIDs() const;
+	
+	TInt InsertServiceId(const TUint aServiceId);
+	
+	TInt GetServicePropertyCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, TUint& aServicePropertyCode ) const;
+	TInt SetServicePropertyCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, const TUint aCurrPropertyCode );
+	
+	TInt GetServiceFormatCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, TUint& aServiceFormatCode ) const;
+	TInt SetServiceFormatCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, const TUint aCurrFormatCode );
+	
+	TInt GetServiceMethodCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, TUint& aServiceFormatCode ) const;
+    TInt SetServiceMethodCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, const TUint aCurrMethodCode );
+	
+    IMPORT_C TBool IsSupportedService( const TMTPTypeGuid& aPGUID ) const;
+    IMPORT_C TBool IsSupportedService( const TUint aServiceID ) const;
+    
+	TInt  EnableService(const TMTPTypeGuid& aPGUID, const TUint aServiceID );
+	TInt ServiceTypeOfSupportedService( const TMTPTypeGuid& aPGUID ) const;
+	
+	
+	IMPORT_C CMTPServiceInfo* ServiceInfo(const TMTPTypeGuid& aServiceGUID ) const;
+	IMPORT_C CMTPServiceInfo* ServiceInfo(const TUint aServiceID) const;
+    IMPORT_C TBool IsServiceFormatCode(const TUint32 aDatacode ) const;
+
+private:
+    void LoadServiceL(const TMTPTypeGuid& aPGUID);
+    TInt GetServiceProperty( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, CServiceProperty** aServicePropertye) const;
+    TInt GetServiceFormat( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, CServiceFormat** aServiceFormat ) const;
+    TInt GetServiceMethod( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, CServiceMethod** aServiceMethod ) const;
+private:
+
+    /**
+    The framework singletons.
+    */
+    RMTPFramework                   iSingletons;
+
+    /*
+     *  Service IDs store
+     */
+    RArray<TUint>     iServiceIDs;
+
+    /**
+     * Service Config
+     */
+	CMTPServiceConfig*	iServiceCfg;
+	
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER_MUTABLE;    
+    
+	};
+
+#endif /*CMTPSERVICEMGR_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpsession.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,100 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPSESSION_H
+#define CMTPSESSION_H
+
+#include <e32base.h>
+#include <mtp/mmtpsession.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/tmtptypeevent.h>
+
+#include "mtpdebug.h"
+
+/** 
+Implements the session level portion of the MTP communication model. It also 
+implements the data provider layer MTP session interface (@see MMTPSession).
+@internalComponent
+ 
+*/
+class CMTPSession : 
+    public CBase,
+    public MMTPSession
+    {
+public:
+
+    static CMTPSession* NewLC(TUint32 aMTPId, TUint aUniqueId);
+    ~CMTPSession();    
+    
+    TUint32 ExpectedTransactionId() const;
+    void IncrementExpectedTransactionId();
+    
+    void SetActiveRequestL(const TMTPTypeRequest& aRequest);
+    void SetTransactionPhase(TMTPTransactionPhase aPhase);
+    TMTPTransactionPhase TransactionPhase() const;
+    TInt RouteRequest(const TMTPTypeRequest& aRequest);
+    void RouteRequestRegisterL(const TMTPTypeRequest& aRequest, TInt aDpId);
+    TBool RouteRequestRegistered(TUint16 aOpCode) const;
+    void RouteRequestUnregister(const TMTPTypeRequest& aRequest);
+    TBool CheckPendingEvent(const TMTPTypeRequest& aRequest) const;
+    void StorePendingEventL(const TMTPTypeEvent& aEvent);
+    const TMTPTypeEvent& PendingEvent() const;
+    
+    void CompletePendingRequest(TInt aErr);
+    TBool RequestPending() const;
+    void SetRequestPending(TRequestStatus& aStatus);
+
+public: // From MMTPSession
+
+    const TMTPTypeRequest& ActiveRequestL() const;
+    TUint32 SessionMTPId() const;
+    TUint SessionUniqueId() const;
+    TAny* GetExtendedInterface(TUid aInterfaceUid);
+    
+private:
+
+    CMTPSession(TUint32 aMTPId, TUint aUniqueId);
+    void ConstructL();
+    
+    static TBool RouteRequestMatchOpCode(const TUint16* aOpCode, const TMTPTypeRequest& aRequest);
+    static TInt RouteRequestOrder(const TMTPTypeRequest& aLeft, const TMTPTypeRequest& aRight);
+    
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+    TUint32                 iExpectedTransactionId;
+    TUint32                 iIdMTP;
+    TUint                   iIdUnique;
+    TMTPTransactionPhase    iTransactionPhase;
+    RArray<TMTPTypeRequest> iRoutingRegistrations;
+    TAny*                   iExtendedInterface;
+    TMTPTypeEvent           iPendingEvent;
+    TMTPTypeRequest         iActiveRequest;
+    
+private: // Not owned
+
+    TRequestStatus*         iRequestStatus;
+    };
+
+#endif // CMTPSESSION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpstoragemgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,138 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPSTORAGEMGR_H
+#define CMTPSTORAGEMGR_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <mtp/mmtpstoragemgr.h>
+
+#include "mtpdebug.h"
+#include "rmtpframework.h"
+
+/** 
+Implements the MTP storage manager interface.
+@internalComponent
+ 
+*/
+class CMTPStorageMgr : 
+    public CBase, 
+    public MMTPStorageMgr
+    {
+public:
+
+    IMPORT_C static CMTPStorageMgr* NewL();
+    IMPORT_C ~CMTPStorageMgr();
+    
+    IMPORT_C static TUint LogicalStorageNumber(TUint32 aStorageId);
+    IMPORT_C static TUint LogicalStorageOwner(TUint32 aStorageId);
+    IMPORT_C static TUint PhysicalStorageNumber(TUint32 aStorageId);
+    IMPORT_C static TUint PhysicalStorageOwner(TUint32 aStorageId);
+    
+    IMPORT_C void SetDefaultStorageId(TUint32 aStorageId);
+    IMPORT_C void SetDriveMappingL(TDriveNumber aDriveNumber, TUint32 aStorageId);
+    IMPORT_C void SetFrameworkId(TUint aDataProviderId);
+    
+public: // From MMTPStorageMgr
+
+    IMPORT_C TUint32 AllocateLogicalStorageIdL(TUint aDataProviderId, TDriveNumber aDriveNumber, const CMTPStorageMetaData& aStorage);
+    IMPORT_C TUint32 AllocateLogicalStorageIdL(TUint aDataProviderId, TUint32 aPhysicalStorageId, const CMTPStorageMetaData& aStorage);
+    IMPORT_C TUint32 AllocatePhysicalStorageIdL(TUint aDataProviderId, const CMTPStorageMetaData& aStorage);
+    IMPORT_C TInt DeallocateLogicalStorageId(TUint aDataProviderId, TUint32 aLogicalStorageId);
+    IMPORT_C void DeallocateLogicalStorageIds(TUint aDataProviderId, TUint32 aPhysicalStorageId);
+    IMPORT_C TInt DeallocatePhysicalStorageId(TUint aDataProviderId, TUint32 aPhysicalStorageId);
+    IMPORT_C TUint32 DefaultStorageId() const;
+    IMPORT_C TInt DriveNumber(TUint32 aStorageId) const;
+    IMPORT_C TInt32 FrameworkStorageId(TDriveNumber aDriveNumber) const;
+    IMPORT_C void GetAvailableDrivesL(RArray<TDriveNumber>& aDrives) const;
+    IMPORT_C void GetLogicalStoragesL(const TMTPStorageMgrQueryParams& aParams, RPointerArray<const CMTPStorageMetaData>& aStorages) const;
+    IMPORT_C void GetPhysicalStoragesL(const TMTPStorageMgrQueryParams& aParams, RPointerArray<const CMTPStorageMetaData>& aStorages) const;
+    IMPORT_C TUint32 LogicalStorageId(TUint32 aStorageId) const;
+    IMPORT_C TInt32 LogicalStorageId(const TDesC& aStorageSuid) const;
+    IMPORT_C TInt32 PhysicalStorageId(TDriveNumber aDriveNumber) const;
+    IMPORT_C TUint32 PhysicalStorageId(TUint32 aStorageId) const;
+    IMPORT_C const CMTPStorageMetaData& StorageL(TUint32 aStorageId) const;
+    IMPORT_C TUint32 StorageId(TUint32 aPhysicalStorageId, TUint32 aLogicalStorageId) const;
+    IMPORT_C TBool ValidStorageId(TUint32 aStorageId) const;
+    IMPORT_C CMTPTypeString* VolumeIdL(TUint aDataProviderId, TUint32 aStorageId, const TDesC& aVolumeIdSuffix) const;
+            
+private:
+
+    CMTPStorageMgr();
+    void ConstructL();
+    
+    TInt32 AllocateLogicalStorageId(TUint aDataProviderId, TUint32 aPhysicalStorageId);
+    TInt32 AllocatePhysicalStorageId(TUint aDataProviderId);
+    TUint32 EncodeLogicalStorageId(TUint32 aPhysicalStorageId, TUint aDataProviderId, TUint aStorageNumber);
+    TUint32 EncodeLogicalStorageNumber(TUint aStorageNumber);
+    TUint32 EncodeLogicalStorageOwner(TUint aDataProviderId);
+    TUint32 EncodePhysicalStorageId(TUint aDataProviderId, TUint aStorageNumber);
+    TUint32 EncodePhysicalStorageNumber(TUint aStorageNumber);
+    TUint32 EncodePhysicalStorageOwner(TUint aDataProviderId);
+    void RemoveLogicalStorageL(TUint aIdx);
+    CMTPStorageMetaData& StorageMetaDataL(TUint32 aStorageId);
+    
+    static TBool StorageKeyMatchSuid(const TDesC* aSuid, const CMTPStorageMetaData& aStorage);
+    static TInt StorageOrder(const CMTPStorageMetaData& aL, const CMTPStorageMetaData& aR);
+    static TInt StorageOrder(const TUint32* aKey, const CMTPStorageMetaData& aStorage);
+    
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    /**
+    The default MTP storage ID.
+    */
+    TUint32                             iDefaultStorageId;
+    
+    /**
+    The framework storages (drives) owning data provider ID.
+    */
+    TInt                                iFrameworkId;
+
+    /**
+    The Symbian OS drive number to default MTP StorageID mapping table. This 
+    StorageID may either be the physical MTP StorageID or the default logical 
+    MTP StorageID.
+    */
+    TFixedArray<TInt, KMaxDrives>       iMapDriveToStorage;
+    
+    /**
+    The physical storage numbers allocation table. Indexed by physical storage 
+    owner data provider ID.
+    */
+    RArray<TUint>                       iPhysicalStorageNumbers;
+    
+    /**
+    The framework singletons.
+    */
+    RMTPFramework                       iSingletons;
+    
+    /**
+    The storages table.
+    */
+    RPointerArray<CMTPStorageMetaData>  iStorages;
+    };
+    
+#endif // CMTPSTORAGEMGR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/cmtpxmlparserlogger.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,47 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef CMTPXMLPARSERLOGGER_H
+#define CMTPXMLPARSERLOGGER_H
+
+#include <e32base.h>
+
+_LIT(KNodeTestCase, "TestCase");
+_LIT(KNodeConnect, "Connect");
+_LIT(KNodeTransaction, "Transaction");
+_LIT(KNodeOperationCode, "OperationCode");
+_LIT(KNodeSessionID, "SessionID");
+_LIT(KNodeTransactionID, "TransactionID");
+_LIT(KNodeParameter1, "Parameter1");
+_LIT(KNodeParameter2, "Parameter2");
+_LIT(KNodeParameter3, "Parameter3");
+_LIT(KNodeParameter4, "Parameter4");
+_LIT(KNodeParameter5, "Parameter5");
+_LIT(KNodeDataIn, "DataIn");
+_LIT(KNodeDataOut, "DataOut");
+_LIT(KNodeRequest, "Request");
+_LIT(KNodeResponse, "Response");
+_LIT(KNodeResponseCode, "ResponseCode");
+_LIT(KNodeEvent, "Event");
+_LIT(KNodeEventCode, "EventCode");
+_LIT(KNotValid, "NotValid");
+_LIT(KATTRTransactionName, "TransactionName");
+
+_LIT(KVersionTag, "?xml version=\"1.0\" encoding=\"UTF-8\"?");
+
+const static TInt KMaxAttributeLength = 50;
+const static TInt KMaxNodeNameLength = 50;
+
+#endif // CMTPXMLPARSERLOGGER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/dbutility.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,40 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+#ifndef DBUTILITY_H
+#define DBUTILITY_H
+
+#include <e32base.h>
+
+class RDbDatabase;
+
+/** 
+Uitlity class for database management.
+
+@internalComponent
+ 
+*/
+class DBUtility
+	{
+public:	
+    static TBool IsTableExistsL(RDbDatabase&, const TDesC& aTableName);
+    static TBool IsIndexExistsL(RDbDatabase&, const TDesC& aTableName, const TDesC& aIndexName);
+	};
+	
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/mmtptransactionproxy.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,108 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef MMTPTRANSACTIONPROXY_H
+#define MMTPTRANSACTIONPROXY_H
+
+#include <e32cmn.h>
+#include <e32def.h>
+
+class MMTPConnection;
+class MMTPObjectMgr;
+class MMTPPuidMgr;
+class MMTPReferenceMgr;
+class MMTPType;
+class TMTPTypeEvent;
+class TMTPTypeResponse;
+class TMTPTypeRequest;
+class RFs;
+
+/** 
+Defines the MTP framework transaction proxy handler application interface.
+This is an internal interface that allows a data provider to complete the 
+processing of a delegated (proxy) request.
+@internalComponent
+ 
+*/
+class MMTPTransactionProxy
+    {
+public:
+    
+    /**
+    Initiates a data object receive sequence in the MTP transaction proxy 
+    handler. This is an asynchronous method. This method should only be invoked
+    when processing the ERequestPhase of an MTP transaction. 
+    @param aData The MTP data object sink buffer.
+    @param aRequest The MTP request dataset of the active MTP transaction.
+    @param aConnection The handle of the MTP connection on which the transaction
+    is being processed. 
+    @param aStatus The status used to return asynchronous completion 
+    information regarding the request.
+    @leave KErrNotReady, if invoked when the current MTP transaction phase is 
+    not ERequestPhase.
+    */
+    virtual void ProxyReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus) = 0;
+    
+    /**
+    Initiates a data object send sequence in the MTP transaction proxy 
+    handler. This is an asynchronous method. This method should only be invoked
+    when processing the ERequestPhase of an MTP transaction. 
+    @param aData The MTP data object source buffer.
+    @param aRequest The MTP request dataset of the active MTP transaction.
+    @param aConnection The handle of the MTP connection on which the transaction
+    is being processed.
+    @param aStatus The status used to return asynchronous completion 
+    information regarding the request.
+    @leave KErrNotReady, if invoked when the current MTP transaction phase is 
+    not ERequestPhase.
+    */
+    virtual void ProxySendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus) = 0;
+    
+    /**
+    Initiates a data object an MTP response dataset send sequence in the MTP 
+    transaction proxy handler. This is an asynchronous method. This method 
+    should only be invoked when processing either the ERequestPhase or 
+    EResponsePhase of an MTP transaction.
+    @param aData The MTP aResponse dataset source buffer.
+    @param aConnection The handle of the MTP connection on which the transaction
+    is being processed.
+    @param aStatus The status used to return asynchronous completion 
+    information regarding the request.
+    @leave KErrNotReady, if invoked when the current MTP transaction phase is 
+    not ERequestPhase or EResponsePhase.
+    */
+    virtual void ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus) = 0;
+    
+    /**
+    Signals to the MTP transaction proxy handler that all processing related 
+    to the current transaction has been completed. This method should only be 
+    invoked when processing the ECompletingPhase of the MTP transaction 
+    @param aRequest The MTP request dataset that initiated the transaction.
+    @param aConnection The handle of the MTP connection on which the transaction
+    is being processed.
+    @param aStatus The status used to return asynchronous completion 
+    information regarding the request.
+    @leave KErrNotReady If invoked when the current MTP transaction phase is 
+    invalid.
+    */
+    virtual void ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) = 0;
+    };
+    
+#endif // MMTPTRANSACTIONPROXY_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/mtpframeworkconst.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,84 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef MTPFRAMEWORKCONST_H
+#define MTPFRAMEWORKCONST_H
+
+/**
+The device data provider implementation UID.
+@internalTechnology
+ 
+*/
+const TUint KMTPImplementationUidDeviceDp(0x102827AF);
+
+/**
+The file data provider implementation UID.
+@internalTechnology
+ 
+*/
+const TUint KMTPImplementationUidFileDp(0x102827B0);
+
+/**
+The proxy data provider implementation UID.
+@internalTechnology
+ 
+*/
+const TUint KMTPImplementationUidProxyDp(0x102827B1);
+
+/**
+The maximum number of concurrently enumerating data providers.
+@internalTechnology
+ 
+*/
+const TUint KMTPMaxEnumeratingDataProviders(4);
+
+/** 
+The maximum SQL statement length.
+@internalTechnology
+ 
+*/
+const TInt KMTPMaxSqlStatementLen = 384;
+
+/**
+The maximum SUID length.
+@internalTechnology
+ 
+*/
+const TInt KMTPMaxSuidLen = 255;
+
+/**
+The deivce data provider DPID.
+@internalTechnology
+*/
+const TUint KMTPDeviceDPID = 0;
+
+/**
+The file data provider DPID.
+@internalTechnology
+*/
+const TUint KMTPFileDPID = 1;
+
+/**
+The proxy data provider DPID.
+@internalTechnology
+*/
+const TUint KMTPProxyDPID = 2; 
+
+#endif // MTPFRAMEWORKCONST_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/mtpservicecommon.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,45 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/ 
+
+#ifndef MTPSERVICECOMMON_H_
+#define MTPSERVICECOMMON_H_
+
+
+#define KInvliadU16DataCode 0x0000
+
+#define KInvliadServiceID   0x00000000
+
+
+#define KNormalServiceTypeMask  0x00000000
+
+#define KAbstrackServiceTypeMask  0x10000000
+
+
+
+enum TMTPServiceType
+    {
+    EMTPServiceTypeNormal = 0,
+    EMTPServiceTypeAbstract = 1
+    };
+
+
+
+
+#endif /* MTPSERVICECOMMON_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/mtpserviceconfig.hrh	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,22 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef MTPSERVICECONFIG_HRH_
+#define MTPSERVICECONFIG_HRH_
+
+#define KNum4IntsOfGUID  4
+
+
+#endif /* MTPSERVICECONFIG_HRH_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/mtpserviceconfig.rh	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,98 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef MTPSERVICECONFIG_RH_
+
+#define MTPSERVICECONFIG_RH_
+
+#include "mtpserviceconfig.hrh"
+
+STRUCT SVC_PROPERTY
+    {
+    LONG    namespaceid;    
+    
+    LONG    pkid;
+    LTEXT   name;
+    
+    LONG    datatype;
+    BYTE    getset;
+    BYTE    formflag;
+    }
+
+STRUCT SVC_FORMAT
+    {
+    LONG    guid[KNum4IntsOfGUID];    
+    
+    LTEXT   name;
+    LTEXT   mimetype1;
+    WORD    baseformatcode1;
+    }
+
+STRUCT SVC_METHOD
+    {
+    LONG    guid[KNum4IntsOfGUID];   
+    
+    LTEXT   name;
+    WORD    obj_ass_formatcode1;
+    }
+
+STRUCT SVC_EVENT
+    {
+    WORD    datacode;
+    LONG    guid[KNum4IntsOfGUID];   
+    LTEXT   name;
+    }
+
+STRUCT SVC_GUID
+    {
+    LONG   guid[KNum4IntsOfGUID];   
+    }
+    
+STRUCT ELEMENTSARRAY
+    {
+    STRUCT  elements[];
+    }
+
+STRUCT MTP_SERVICE_INFO
+    {
+    LONG       pguid[KNum4IntsOfGUID]; 
+    
+    LONG       version;
+    
+    LONG       svcguid[KNum4IntsOfGUID]; 
+    
+    LTEXT      servicename;
+    LONG       servicetype;
+    LONG       base_serviceid;
+    
+    LLINK      use_service_guids;
+    
+    LLINK      svc_property_namespaces;
+    LLINK      svc_properties;
+    LLINK      svc_formats;
+    LLINK      svc_methods;
+    LLINK      svc_events;
+    LLINK      svc_datablock;
+    }
+
+STRUCT MTP_SUPPORTED_SERVICES
+    {
+    LONG    guid[KNum4IntsOfGUID]; 
+    LONG    svctype;
+    LLINK   r_serviceinfo;
+    }
+
+
+#endif /* MTPSERVICECONFIG_RH_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/rmtpframework.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,160 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+#ifndef RMTPFRAMEWORK_H
+#define RMTPFRAMEWORK_H
+
+#include <e32base.h>
+#include <f32file.h>
+
+#include "mtpdebug.h"
+
+class CMTPConnectionMgr;
+class CMTPDataProviderController;
+class CMTPFrameworkConfig;
+class CMTPObjectMgr;
+class CMTPParserRouter;
+class CMTPReferenceMgr;
+class CMTPStorageMgr;
+class RFs;
+class CMTPDataCodeGenerator;
+class CMTPServiceMgr;
+
+/** 
+Implements the MTP framework singletons manager.
+@internalComponent
+*/
+class RMTPFramework
+	{
+public:	
+
+    IMPORT_C RMTPFramework();
+
+    IMPORT_C void OpenL();
+    IMPORT_C void OpenLC();
+    IMPORT_C void Close();
+    
+	IMPORT_C CMTPConnectionMgr& ConnectionMgr() const;
+	IMPORT_C CMTPDataProviderController& DpController() const;
+	IMPORT_C CMTPFrameworkConfig& FrameworkConfig() const;
+	IMPORT_C RFs& Fs() const;
+	IMPORT_C CMTPObjectMgr& ObjectMgr() const;
+	IMPORT_C CMTPReferenceMgr& ReferenceMgr() const;
+	IMPORT_C CMTPParserRouter& Router() const;
+	IMPORT_C CMTPStorageMgr& StorageMgr() const;
+	IMPORT_C CMTPDataCodeGenerator& DataCodeGenerator() const;	
+	IMPORT_C CMTPServiceMgr& ServiceMgr() const;
+    
+private: // Owned
+	
+    class CSingletons : public CObject
+        {
+    public: 
+
+        static CSingletons& OpenL();
+        
+    public: // From CObject
+        
+        void Close();
+
+    private:
+
+        virtual ~CSingletons();
+        void ConstructL();
+
+    public: // Owned
+
+        /**
+        FLOGGER debug trace member variable.
+        */
+        __FLOG_DECLARATION_MEMBER_MUTABLE;
+        
+        /**
+        The construction in-progress flag, which is used to manage nested 
+        (recursive) opens.
+        */
+        TBool                       iConstructing;
+
+        /**
+        The connection manager singleton.
+        */
+        CMTPConnectionMgr*          iSingletonConnectionMgr;	
+
+        /**
+        The data provider controller singleton.
+        */
+        CMTPDataProviderController* iSingletonDpController;
+        
+        /**
+        The configurability parameter data singleton.
+        */
+        CMTPFrameworkConfig*        iSingletonFrameworkConfig;	
+
+        /**
+        The file server session singleton
+        */
+        RFs                         iSingletonFs;   
+
+        /**
+        The object manager singleton.
+        */
+        CMTPObjectMgr*              iSingletonObjectMgr;
+
+        /**
+        The request and event parser/router singleton.
+        */
+        CMTPParserRouter*           iSingletonRouter;
+        
+        /** 
+        The storage manager singleton.
+        */
+        CMTPStorageMgr*             iSingletonStorageMgr;
+        
+        /** 
+        The data code manager singleton.
+        */
+        CMTPDataCodeGenerator*      iSingleDataCodeGenerator;
+        
+        /** 
+        The device service manager singleton.
+        */
+        CMTPServiceMgr*           iSingleServiceMgr;
+        
+        };
+
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    /**
+    The nested flag which indicates if the singletons manager reference was 
+    recursively opened.
+    */
+    TBool           iNested;
+
+    /**
+    The singletons reference block.
+    */
+    CSingletons*    iSingletons;
+	};
+	
+#endif // RMTPFRAMEWORK_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/ruidmapper.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,55 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+#ifndef RUIDMAPPER_H
+#define RUIDMAPPER_H
+
+#include <e32base.h>
+
+
+
+/** 
+Uitlity class for Getting the transport id from the Resource file corresponding to the Data provider UID.
+
+@internalComponent
+ 
+*/
+struct MappingStruct
+	{
+	TUint dpUid;
+	RArray<TUint> iTransportUidList;
+	};
+
+class RUidMapping
+	{
+public:	
+	RUidMapping();
+	void Open();
+	void Close();
+	TBool GetSupportedTransport(const TUint& aDPUid,const TUint& aTransportUid);
+	void ReadFromResourceFileL();
+private:
+	void InsertToMappingStruct(MappingStruct& aRef);
+private:
+	
+	RArray<MappingStruct> iMappingStruct;
+	 	
+	};
+	
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/inc/tmtptypeobjecthandle.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,69 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef TMTPTYPEOBJECTHANDLE_H
+#define TMTPTYPEOBJECTHANDLE_H
+
+#include <e32base.h>
+#include <e32std.h>
+#include <mtp/tmtptypeuint32.h>
+    
+/**
+Defines the MTP object handle type. The MTP object handle encoding comprises
+the following fields.
+
+    1. MS 8 bits - The ID of the data provider responsible for the object.
+    2. LS 24 bits - A data provider unique object identifier.
+    
+@internalComponent
+ 
+*/
+class TMTPTypeObjectHandle : public TMTPTypeUint32
+    {
+public:
+
+    TMTPTypeObjectHandle(TUint32 aId, TUint8 aDp);
+    TMTPTypeObjectHandle(TMTPTypeUint32 aId, TUint8 aDp);
+    TMTPTypeObjectHandle(TMTPTypeUint32 aHandle);
+    
+    ~TMTPTypeObjectHandle();
+    
+    TUint8 DpId() const;
+	TUint32 DPObjectId() const;
+    void SetDPHandle(TUint8 aDp);
+    
+    inline static TUint ObjectID( TUint32 aHandleID )
+        {
+        return ( (~KDpMask) & aHandleID);
+        }
+
+    inline static TUint DataProviderID( TUint32 aHandleID )
+        {
+        return ((KDpMask & aHandleID) >> KObjectIdWidth);
+        }
+    
+public:
+
+    static const TUint32    KDpMask         = 0xFF000000;
+    static const TUint32    KObjectIdMax    = 0x00FFFFFF;
+    static const TUint      KObjectIdWidth  = 24;
+    };
+
+#endif // TMTPTYPEOBJECTHANDLE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cdummydp.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,84 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/mmtpconnection.h>
+#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h> 
+#include <mtp/mmtpreferencemgr.h> 
+#include <mtp/mtpprotocolconstants.h> 
+#include <mtp/mmtpsession.h> 
+
+#include "cdummydp.h"  
+
+
+CDummyDp::~CDummyDp()
+    {
+    
+    }
+    
+void CDummyDp::Cancel()
+    {
+    
+    }
+    
+void CDummyDp::ProcessEventL(const TMTPTypeEvent& /*aEvent*/, MMTPConnection& /*aConnection*/)
+    {
+
+    }
+    
+void CDummyDp::ProcessNotificationL(TMTPNotification /*aNotification*/, const TAny* /*aParams*/)
+    {
+
+    }
+        
+void CDummyDp::ProcessRequestPhaseL(TMTPTransactionPhase /*aPhase*/, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/)
+    {
+
+    }
+    
+void CDummyDp::StartObjectEnumerationL(TUint32 aStorageId, TBool /*aPersistentFullEnumeration*/)
+    {
+    Framework().ObjectEnumerationCompleteL(aStorageId);        
+    }
+    
+void CDummyDp::StartStorageEnumerationL()
+    {
+    Framework().StorageEnumerationCompleteL();
+    }
+    
+void CDummyDp::Supported(TMTPSupportCategory /*aCategory*/, RArray<TUint>& /*aArray*/) const
+    {
+
+    }
+    
+TAny* CDummyDp::NewL(TAny* aParams)
+    {
+    CDummyDp* self = new (ELeave) CDummyDp(aParams);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);    
+    return self;
+    }
+   
+CDummyDp::CDummyDp(TAny* aParams) :
+    CMTPDataProviderPlugin(aParams)
+    {
+
+    }
+    
+void CDummyDp::ConstructL()
+    {
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpconnection.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1158 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <mtp/cmtpdataproviderplugin.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptypeevent.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/tmtptypeuint32.h>
+
+#include "cmtpconnection.h"
+#include "cmtpconnectionmgr.h"
+#include "cmtpdataprovider.h"
+#include "cmtpparserrouter.h"
+#include "cmtpsession.h"
+#include "mmtptransportconnection.h"
+
+#ifdef MTP_CAPTURE_TEST_DATA
+#include "cmtprequestlogger.h"
+#endif
+
+#define UNUSED_VAR(a) (a) = (a)
+
+__FLOG_STMT(_LIT8(KComponent,"MTPConnection");)
+
+/**
+CMTPConnection panics
+*/
+_LIT(KMTPPanicCategory, "CMTPConnection");
+enum TMTPPanicReasons
+    {
+    EMTPPanicBusy = 0,
+    EMTPPanicInvalidSession = 1,
+    EMTPPanicInvalidState = 2,
+    EMTPPanicPublishEvent = 3,
+    };
+    
+LOCAL_C void Panic(TInt aReason)
+    {
+    User::Panic(KMTPPanicCategory, aReason);
+    }
+
+/**
+CMTPConnection factory method. A pointer to the new CMTPConnection instance is
+placed on the cleanup stack.
+@param aConnectionId The unique identifier assigned to this connection by the 
+MTP framework. 
+@param aTransportConnection The MTP transport layer connection interface to 
+which the CMTPConnection will bind.
+@return Pointer to the new CMTPConnection instance. Ownership IS transfered.
+@leave One of the system wide error codes if a processing failure occurs.
+*/
+CMTPConnection* CMTPConnection::NewLC(TUint aConnectionId, MMTPTransportConnection& aTransportConnection)
+    {
+    CMTPConnection* self = new(ELeave) CMTPConnection(aConnectionId, aTransportConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+/**
+Destructor.
+*/
+CMTPConnection::~CMTPConnection()
+    {
+    __FLOG(_L8("~CMTPConnection - Entry"));
+    CloseAllSessions();
+    
+    // Remove any events not associated 
+    // with a session
+    TSglQueIter<CMTPEventLink> iter(iEventQ);
+    iter.SetToFirst();
+    CMTPEventLink* link = NULL;
+    
+    while ((link = iter++) != NULL)
+    	{
+    	delete link;
+    	}
+    
+    if (iTransportConnection != NULL)
+	    {
+	    iTransportConnection->Unbind(*this);
+	    }
+    iSessions.ResetAndDestroy();
+    //close the property
+    iProperty.Close();
+    // delete the ‘name?property
+    RProcess process;
+    RProperty::Delete(process.SecureId(), EMTPConnStateKey);
+    __FLOG(_L8("~CMTPConnection - Exit"));
+	__FLOG_CLOSE;
+    }
+
+/**
+Unbinds the Transport Connection
+*/    
+void CMTPConnection::Unbind(MMTPTransportConnection& /*aConnection*/)
+	{
+	iTransportConnection = NULL;
+	}
+
+/**
+Initiates MTP transaction data phase processing for initiator-to-responder
+data flows. This method should only be invoked when the MTP transaction phase 
+state is ERequestPhase. This is an asynchronous method.
+@param aData The MTP data object sink.
+@param aRequest The MTP request dataset of the active MTP transaction.
+@param aStatus The status used to return asynchronous completion 
+information regarding the request.
+@leave KErrNotFound If the MTP request dataset specifies an invalid SessionID.
+@panic CMTPConnection 0 If an asynchronous request is already pending on the 
+connection.
+@panic CMTPConnection 2 If the MTP transaction phase is invalid.
+*/
+void CMTPConnection::ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, TRequestStatus& aStatus)
+    {   
+    __FLOG(_L8("ReceiveDataL - Entry"));
+    iDataReceiveResult = KErrNone;
+    const TUint KValidPhases(ERequestPhase);
+    CMTPSession& session(SessionL(aRequest, TMTPTypeRequest::ERequestSessionID));
+    
+    if (ValidFrameworkRequest(&session, KValidPhases, &aStatus))
+        {
+        session.SetTransactionPhase(EDataIToRPhase);
+        session.SetRequestPending(aStatus);
+        if(EMTPTypeFile == aData.Type())
+            {
+            ValidateAndPublishConnState(session, State());
+            }
+        
+        iTransportConnection->ReceiveDataL(aData, aRequest);      
+        }
+    __FLOG(_L8("ReceiveDataL - Exit"));
+    }
+
+/**
+Initiates MTP transaction data phase processing for responder-to-initiator
+data flows. This method should only be invoked when the MTP transaction phase
+state is ERequestPhase. This is an asynchronous method.
+@param aData The MTP data object source.
+@param aRequest The MTP request dataset of the active MTP transaction.
+@param aStatus The status used to return asynchronous completion 
+information regarding the request.
+@leave KErrNotFound If the MTP request dataset specifies an invalid SessionID.
+@panic CMTPConnection 0 If an asynchronous request is already pending on the 
+connection.
+@panic CMTPConnection 2 If the MTP transaction phase is invalid.
+*/
+void CMTPConnection::SendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, TRequestStatus& aStatus)
+    {
+    __FLOG(_L8("SendDataL - Entry"));
+#ifdef MTP_CAPTURE_TEST_DATA
+    iRequestLogger->WriteDataPhaseL(aData, EDataRToIPhase);
+#endif
+
+    const TUint KValidPhases(ERequestPhase);
+    CMTPSession& session(SessionL(aRequest, TMTPTypeRequest::ERequestSessionID));
+    
+    if (ValidFrameworkRequest(&session, KValidPhases, &aStatus))
+        {
+        session.SetTransactionPhase(EDataRToIPhase);
+        session.SetRequestPending(aStatus);
+        if(EMTPTypeFile == aData.Type())
+            {
+            //In this case we should validate the state based on transaction phase then
+            //publish the connection state info to the subscriber.
+            ValidateAndPublishConnState(session, State());
+            }
+        iTransportConnection->SendDataL(aData, aRequest);
+        }
+    __FLOG(_L8("SendDataL - Exit"));
+    }
+
+/**
+Sends an MTP event dataset.
+@param aEvent The MTP event dataset source.
+@leave KErrNotFound If the MTP event dataset specifies an invalid SessionID.
+*/
+void CMTPConnection::SendEventL(const TMTPTypeEvent& aEvent)
+    {
+    __FLOG(_L8("SendEventL - Entry"));
+    const TUint KValidPhases(EIdlePhase | ERequestPhase | EDataIToRPhase| EDataRToIPhase | EResponsePhase | ECompletingPhase);
+    if (ValidFrameworkRequest(NULL, KValidPhases, NULL))
+        {
+        // Validate the SessionID
+        TUint32 sessionId(aEvent.Uint32(TMTPTypeEvent::EEventSessionID));
+        if (sessionId != KMTPSessionAll)
+            {
+            User::LeaveIfError(iSessions.FindInOrder(sessionId, SessionOrder));
+            }
+            
+
+		EnqueueEvent(new (ELeave) CMTPEventLink(aEvent));
+		if (iPendingEventCount == 1)
+			{
+			// Forward the event to the transport connection layer.
+			iTransportConnection->SendEventL(iEventQ.First()->iEvent);			
+			}
+        }
+    __FLOG(_L8("SendEventL - Exit"));
+    }
+
+/**
+Initiates MTP transaction response phase processing. This method should only 
+be invoked when the MTP transaction phase state is either ERequestPhase, or 
+EResponsePhase. This is an asynchronous method.
+@param aResponse The MTP response dataset source.
+@param aRequest The MTP request dataset of the active MTP transaction.
+@param aStatus The status used to return asynchronous completion 
+information regarding the request.
+@leave KErrNotFound If the MTP response dataset specifies an invalid SessionID.
+@leave KErrArgument If the MTP response dataset does not match the specified 
+request dataset.
+@panic CMTPConnection 0 If an asynchronous request is already pending on the 
+connection.
+@panic CMTPConnection 2 If the MTP transaction phase is invalid.
+*/
+void CMTPConnection::SendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, TRequestStatus& aStatus)
+    {
+    __FLOG(_L8("SendResponseL - Entry"));
+#ifdef MTP_CAPTURE_TEST_DATA
+    // Running under debug capture mode save this request off to disk.
+    iRequestLogger->LogResponseL(aResponse);
+#endif
+    
+    const TUint KValidPhases(ERequestPhase | EResponsePhase );
+    CMTPSession& session(SessionL(aResponse, TMTPTypeResponse::EResponseSessionID));
+    
+    if (ValidFrameworkRequest(&session, KValidPhases, &aStatus))
+        {
+        if ((aResponse.Uint32(TMTPTypeResponse::EResponseSessionID) != aRequest.Uint32(TMTPTypeRequest::ERequestSessionID)) ||
+            (aResponse.Uint32(TMTPTypeResponse::EResponseTransactionID) != aRequest.Uint32(TMTPTypeRequest::ERequestTransactionID)))
+            {
+            /* 
+            Request/Response mismatch by the originating data provider plug-in. 
+            Fail the transport connection to avoid leaving the current 
+            transaction irrecoverably hanging.
+            */
+            UnrecoverableMTPError();
+            User::Leave(KErrArgument);                
+            }
+
+        if (session.TransactionPhase() == ERequestPhase)
+            {
+            // Transaction has no data phase.
+            session.SetTransactionPhase(EResponsePhase);
+            }
+            
+        session.SetRequestPending(aStatus);
+        
+        iTransportConnection->SendResponseL(aResponse, aRequest);
+        }
+    __FLOG(_L8("SendResponseL - Exit"));
+    }
+
+/**
+Deletes the session object assigned to the specified session and notifies all 
+loaded data providers.
+@param aMTPId The session identifier assigned by the MTP connection 
+initiator.
+@leave KErrNotFound, if a session with the specified SessionMTPId is not 
+found.
+@leave One of the system wide error codes, if a general processing failure 
+occurs.
+*/
+EXPORT_C void CMTPConnection::SessionClosedL(TUint32 aMTPId)
+    {
+    __FLOG(_L8("SessionClosedL - Entry"));
+    if(0x0FFFFFFF != aMTPId)
+    	{
+    	TInt idx(iSessions.FindInOrder(aMTPId, SessionOrder));
+	    __ASSERT_DEBUG((idx != KErrNotFound), Panic(EMTPPanicInvalidSession));
+	    CloseSession(idx);
+	    }
+    else
+	    {
+	    CMTPSession* session = NULL;
+	    for(TInt i =0;i<iSessions.Count();i++)
+		    {
+		    session = iSessions[i];
+		    TUint id(session->SessionMTPId());	
+	    	if(0 != id)
+		    	{
+		    	SessionClosedL(id);	
+		    	}
+		    session = NULL;
+		    }
+	    }
+    __FLOG(_L8("SessionClosedL - Exit"));
+    }
+
+/**
+Creates a new session object for the specified session and notifies all loaded
+data providers. The session is known by two identifiers:
+    1. SessionMTPId - Assigned by the MTP connection initiator and unique only 
+        to the MTP connection on which the session was opened. In a multiple-
+        connection configuration this identifier may not uniquely identify the 
+        session.
+    2. SessionUniqueId - Assigned by the MTP daemon and guaranteed to uniquely
+        identify the session in a multiple-connection configuration.
+Currently the MTP daemon does not support multiple-connection configuration 
+and both identifiers are assigned the same value.
+@param aMTPId The session identifier assigned by the MTP connection 
+initiator.
+@leave KErrAlreadyExists, if a session with the specified SessionMTPId is 
+already open.
+@leave One of the system wide error codes, if a general processing failure 
+occurs.
+*/
+EXPORT_C void CMTPConnection::SessionOpenedL(TUint32 aMTPId)
+    {
+    __FLOG(_L8("SessionOpenedL - Entry"));
+    // Validate the SessionID
+    if (SessionWithMTPIdExists(aMTPId))
+        {
+        User::Leave(KErrAlreadyExists);            
+        }
+    
+    // Create a new session object
+    CMTPSession* session = CMTPSession::NewLC(aMTPId, aMTPId);
+    session->SetTransactionPhase(EIdlePhase);
+    iSessions.InsertInOrder(session, CMTPConnection::SessionOrder);
+    CleanupStack::Pop(session); 
+    
+    if (aMTPId != KMTPSessionNone)
+        {
+        // Notify the data providers if other than the null session is closing.
+        TMTPNotificationParamsSessionChange params = {aMTPId, *this};
+        iSingletons.DpController().NotifyDataProvidersL(EMTPSessionOpened, &params);
+        }
+    __FLOG(_L8("SessionOpenedL - Exit"));
+    }
+
+/*
+ * Signals the connection is suspended, the connection state is set to EStateShutdown which 
+ * means that all the current transaction will not be able to send/receive any data via the
+ * connection
+ */
+void CMTPConnection::ConnectionSuspended()
+    {
+    __FLOG(_L8("ConnectionSuspended - Entry"));
+    
+    TUint currentState = State();
+    if (currentState!=EStateShutdown && currentState!=EStateErrorShutdown)
+        {
+        SetState(EStateShutdown);
+        
+        if (iTransportConnection != NULL)
+            {
+            iTransportConnection->Unbind(*this);
+            iTransportConnection = NULL;
+            }
+        PublishConnState(EDisconnectedFromHost);   
+    
+        if (ActiveSessions() == 0)
+            {
+            CloseAllSessions();
+            iSessions.Reset();
+            iSingletons.Close();
+            }
+        else 
+            {
+            //some session may be in data or response phase, complete them and set transaction phase to ECompletingPhase.
+            const TUint count(iSessions.Count());
+            for (TUint i(0); (i < count); i++)
+                {
+                if (iSessions[i]->TransactionPhase() & (EDataIToRPhase|EDataRToIPhase|EResponsePhase))
+                    {
+                    iSessions[i]->SetTransactionPhase(ECompletingPhase);
+                    iSessions[i]->CompletePendingRequest(KErrCancel);
+                    }
+                }
+            }
+        }
+    
+    __FLOG(_L8("ConnectionSuspended - Exit"));
+    }
+
+/*
+ * Signals that the connection is resumed to EStateOpen state which means that data providers
+ * can receive requests from host again.
+ * @aTransportConnection The new transport connection object
+ * @leave One of the system wide error codes, if a processing failure occurs.
+ */
+void CMTPConnection::ConnectionResumedL(MMTPTransportConnection& aTransportConnection)
+    {
+    __FLOG(_L8("ConnectionResumed - Entry"));
+    
+    TUint currentState = State();
+    if (currentState != EStateOpen && currentState != EStateErrorRecovery)
+        {
+        iSingletons.OpenL();
+        
+        /* 
+        Create the null session object which owns the transaction state for 
+        transaction occuring outside a session (i.e. with SessionID == 0x00000000)
+        */
+        SessionOpenedL(KMTPSessionNone);            
+        
+        iTransportConnection = &aTransportConnection;
+        iTransportConnection->BindL(*this); 
+        SetState(EStateOpen); 
+        PublishConnState(EConnectedToHost); 
+        }
+    
+    __FLOG(_L8("ConnectionResumed - Exit"));
+    }
+
+/**
+Signals the completion of the current transaction processing sequence. This
+method should only be invoked when the MTP transaction phase state is 
+ECompletingPhase.
+@param aRequest The MTP request dataset of the completed MTP transaction.
+@leave KErrNotFound If the MTP request dataset specifies an invalid SessionID.
+@panic CMTPConnection 2 If the MTP transaction phase is invalid.
+*/
+void CMTPConnection::TransactionCompleteL(const TMTPTypeRequest& aRequest)
+    {
+    __FLOG(_L8("TransactionCompleteL - Entry"));
+    const TUint KValidPhases(ECompletingPhase);
+    CMTPSession& session(SessionL(aRequest, TMTPTypeRequest::ERequestSessionID));    
+
+    if (ValidFrameworkRequest(&session, KValidPhases, NULL))
+        {
+        session.SetTransactionPhase(EIdlePhase);
+        if (State() == EStateShutdown)
+            {
+            if (ActiveSessions() == 0)
+                {        
+                CloseAllSessions();
+                iSessions.Reset();
+                iSingletons.Close();
+                
+                // Move the log here because ShutdownComplete will delete this object.
+                __FLOG(_L8("TransactionCompleteL - Exit"));
+                }
+            }
+        else
+            {
+            iTransportConnection->TransactionCompleteL(aRequest);
+            __FLOG(_L8("TransactionCompleteL - Exit"));
+            }
+        }
+    }
+    
+TUint CMTPConnection::ConnectionId() const
+    {
+    return iConnectionId;
+    }
+    
+TUint CMTPConnection::SessionCount() const
+    {
+    return iSessions.Count();
+    }
+
+TBool CMTPConnection::SessionWithMTPIdExists(TUint32 aMTPId) const
+    {
+    return (iSessions.FindInOrder(aMTPId, SessionOrder) != KErrNotFound);
+    }
+
+MMTPSession& CMTPConnection::SessionWithMTPIdL(TUint32 aMTPId) const
+    {
+    TInt idx(iSessions.FindInOrder(aMTPId, SessionOrder));
+    User::LeaveIfError(idx);
+    return *iSessions[idx];
+    }
+    
+TBool CMTPConnection::SessionWithUniqueIdExists(TUint32 aUniqueId) const
+    {
+    return SessionWithMTPIdExists(aUniqueId);
+    }
+
+MMTPSession& CMTPConnection::SessionWithUniqueIdL(TUint32 aUniqueId) const
+    {
+    return SessionWithMTPIdL(aUniqueId);
+    }
+    
+void CMTPConnection::ReceivedEventL(const TMTPTypeEvent& aEvent)
+    {  
+    __FLOG(_L8("ReceivedEventL - Entry"));
+    TInt idx(KErrNotFound);
+    
+    // Validate the SessionID.
+    TUint32 sessionId(aEvent.Uint32(TMTPTypeEvent::EEventSessionID));
+    if (sessionId != KMTPSessionAll)
+        {
+        idx = iSessions.FindInOrder(sessionId, SessionOrder);
+        User::LeaveIfError(idx);
+        }
+       
+    // Check that this event is valid.
+    CMTPSession& session(*iSessions[idx]);
+
+    TMTPTypeRequest request; 
+    TRAPD( err, MMTPType::CopyL(session.ActiveRequestL(), request) );
+
+
+    if( err == KErrNotFound  )
+    	{
+    	session.StorePendingEventL(aEvent);
+    	}
+    else
+    	{
+	   	if (request.Uint32(TMTPTypeRequest::ERequestTransactionID) > 
+	    	aEvent.Uint32(TMTPTypeEvent::EEventTransactionID) )
+	        {
+	        // Event to be queued for future use, we can only queue one event at a time
+	        session.StorePendingEventL(aEvent);
+	        }
+	        
+	    if (request.Uint32(TMTPTypeRequest::ERequestTransactionID) == 
+	         aEvent.Uint32(TMTPTypeEvent::EEventTransactionID) )
+	        {     
+	        // Event is valid	     
+	        // Perform transport layer processing.
+	        if (aEvent.Uint16(TMTPTypeEvent::EEventCode) == EMTPEventCodeCancelTransaction)
+	            {
+	            if (sessionId == KMTPSessionAll)
+	                {
+	                const TUint noSessions = iSessions.Count();
+	                for (TUint i(0); (i < noSessions); i++)
+	                    {
+	                    InitiateTransactionCancelL(i);
+	                    } 
+	                }
+	            else
+	                {
+	                InitiateTransactionCancelL(idx);
+	                }
+	            }
+	        
+	         // Forward the event to the DP framework layer.
+	        iSingletons.Router().ProcessEventL(aEvent, *this); 
+	        }
+    	}	
+    __FLOG(_L8("ReceivedEventL - Exit"));
+    }
+
+void CMTPConnection::ReceivedRequestL(const TMTPTypeRequest& aRequest)
+    {  
+    __FLOG(_L8("ReceivedRequestL - Entry"));
+#ifdef MTP_CAPTURE_TEST_DATA
+    // Running under debug capture mode save this request off to disk.
+    iRequestLogger->LogRequestL(aRequest);
+#endif
+
+    // Resolve the session    
+    TInt idx(iSessions.FindInOrder(aRequest.Uint32(TMTPTypeRequest::ERequestSessionID), SessionOrder));
+	
+    // Process the request.
+    if (idx == KErrNotFound)
+        {
+        // Invalid SessionID
+        InitiateMTPErrorRecoveryL(aRequest, EMTPRespCodeSessionNotOpen);
+        }
+    else
+        {           
+        CMTPSession& session(*iSessions[idx]);
+        
+        if (session.TransactionPhase() != EIdlePhase)
+            {
+            // Initiator violation of the MTP transaction protocol.
+            UnrecoverableMTPError();
+            }
+        else
+            {
+            // Set the session state
+            session.IncrementExpectedTransactionId();
+            session.SetTransactionPhase(ERequestPhase);
+            session.SetActiveRequestL(aRequest);
+
+            // Forward the request to the DP framework layer.
+            TRAPD(err,iSingletons.Router().ProcessRequestL(session.ActiveRequestL(), *this));   
+            if(err!=KErrNone)
+                {
+                session.SetTransactionPhase(EIdlePhase);
+                User::Leave(err);
+                }
+            }
+        }
+    __FLOG(_L8("ReceivedRequestL - Exit"));
+    }
+
+#ifdef MTP_CAPTURE_TEST_DATA
+void CMTPConnection::ReceiveDataCompleteL(TInt aErr, const MMTPType& aData, const TMTPTypeRequest& aRequest)
+#else
+void CMTPConnection::ReceiveDataCompleteL(TInt aErr, const MMTPType& aData, const TMTPTypeRequest& aRequest)
+#endif
+    {
+    __FLOG(_L8("ReceiveDataCompleteL - Entry"));    
+    CMTPSession& session(SessionL(aRequest, TMTPTypeRequest::ERequestSessionID)); 
+    __ASSERT_DEBUG((session.TransactionPhase() == EDataIToRPhase), Panic(EMTPPanicInvalidState));
+    
+	if(EMTPTypeFile == aData.Type())
+	{
+		//All data transfer is over now we can publish that
+		//state is connected to host or idle
+		PublishConnState(EConnectedToHost);
+	}
+#ifdef MTP_CAPTURE_TEST_DATA
+    iRequestLogger->WriteDataPhaseL(aData, EDataIToRPhase);
+#endif
+    
+	session.SetTransactionPhase(EResponsePhase);
+	iDataReceiveResult = aErr;
+	session.CompletePendingRequest(aErr);
+    
+    __FLOG(_L8("ReceiveDataCompleteL - Exit"));
+    }
+
+void CMTPConnection::SendDataCompleteL(TInt aErr, const MMTPType& aData, const TMTPTypeRequest& aRequest)
+    {
+    __FLOG(_L8("SendDataCompleteL - Entry"));  
+    CMTPSession& session(SessionL(aRequest, TMTPTypeRequest::ERequestSessionID)); 
+    __ASSERT_DEBUG((session.TransactionPhase() == EDataRToIPhase), Panic(EMTPPanicInvalidState));
+
+    session.SetTransactionPhase(EResponsePhase);
+   
+    if(EMTPTypeFile == aData.Type())
+        {
+        //All data transfer is over now we can publish that
+        //state is connected to host or idle
+        PublishConnState(EConnectedToHost);
+        }
+    
+    session.CompletePendingRequest(aErr);
+    
+    __FLOG(_L8("SendDataCompleteL - Exit"));
+    }
+
+void CMTPConnection::SendEventCompleteL(TInt aErr, const TMTPTypeEvent& aEvent)
+    {
+    __FLOG(_L8("SendEventCompleteL - Entry"));
+
+    
+    if (aErr != KErrNone)
+        {
+        UnrecoverableMTPError();            
+        }    
+    else if (aEvent.Uint16(TMTPTypeEvent::EEventCode) == EMTPEventCodeCancelTransaction)
+        {
+        TUint32 sessionId(aEvent.Uint32(TMTPTypeEvent::EEventSessionID));
+        TInt idx(KErrNotFound);
+        if (sessionId == KMTPSessionAll)
+            {
+            const TUint noSessions = iSessions.Count();
+            for (TUint i(0); (i < noSessions); i++)
+                {
+                InitiateTransactionCancelL(i);
+                }    
+            }
+        else
+            {
+            idx = iSessions.FindInOrder(sessionId, SessionOrder);
+            InitiateTransactionCancelL(idx);
+            }   
+        }
+    // Dequeue first since the code below might leave.
+    DequeueEvent(iEventQ.First());       
+   	if (iPendingEventCount > 0)
+   		{
+   		// Forward the event to the transport connection layer.
+   		__FLOG(_L8("Sending queued event"));
+ 	    iTransportConnection->SendEventL(iEventQ.First()->iEvent);
+   		}
+    
+    __FLOG(_L8("SendEventCompleteL - Exit"));
+    }
+
+void CMTPConnection::SendResponseCompleteL(TInt aErr, const TMTPTypeResponse& /*aResponse*/, const TMTPTypeRequest& aRequest)
+    {   
+    __FLOG(_L8("SendResponseCompleteL - Entry"));
+	if(iState == EStateErrorRecovery)
+		{
+		MTPErrorRecoveryComplete();	    
+		iTransportConnection->TransactionCompleteL(aRequest);
+		}
+	else{
+        CMTPSession& session(SessionL(aRequest, TMTPTypeRequest::ERequestSessionID)); 
+	    __ASSERT_DEBUG((session.TransactionPhase() == EResponsePhase), Panic(EMTPPanicInvalidState));
+    	session.SetTransactionPhase(ECompletingPhase);
+    	session.CompletePendingRequest(aErr);
+		}
+    __FLOG(_L8("SendResponseCompleteL - Exit"));
+    }
+
+   
+TMTPTransactionPhase CMTPConnection::TransactionPhaseL(TUint32 aMTPId) const
+    {
+    TInt idx(iSessions.FindInOrder(aMTPId, SessionOrder));
+    User::LeaveIfError(idx);
+    return iSessions[idx]->TransactionPhase();
+    }
+
+/**
+Constructor.
+*/
+CMTPConnection::CMTPConnection(TUint aConnectionId, MMTPTransportConnection& aTransportConnection) :
+    iConnectionId(aConnectionId),
+    iEventQ(_FOFF(CMTPEventLink, iLink)),
+    iTransportConnection(&aTransportConnection)
+    {
+    
+    }
+    
+/**
+Second phase constructor.
+@leave One of the system wide error code, if a processing failure occurs.
+*/
+void CMTPConnection::ConstructL()
+    {
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry"));
+    //define the property for publishing connection state.
+    DefineConnStatePropertyL();
+    PublishConnState(EDisconnectedFromHost);  
+#ifdef MTP_CAPTURE_TEST_DATA
+    // Running under debug capture mode save this request off to disk.
+    iRequestLogger = CMTPRequestLogger::NewL();
+#endif
+    __FLOG(_L8("ConstructL - Exit"));
+    }
+    
+/**
+Initiates an MTP connection level protocol error recovery sequence. This 
+sequence is invoked when a recoverable protocol error is detected that cannot 
+be processed above the connection layer, e.g. when a request is made on a 
+non-existant SessionID, or an out-of-sequence TransactionID is detected. An
+appropriate MTP response dataset is formed and sent to the MTP initiator. The
+error recovery sequence is concluded by MTPErrorRecoveryComplete when the 
+connection transport layer signals SendResponseComplete to the MTP connection 
+protocol layer.
+@param aRequest The MTP request dataset of the erroneous MTP transaction.
+@param aResponseCode The MTP response datacode to be returned to the MTP
+initiator.
+@leave One of the system wide error codes, if a processing failure occurs.
+@see MTPErrorRecoveryComplete
+*/
+void CMTPConnection::InitiateMTPErrorRecoveryL(const TMTPTypeRequest& aRequest, TUint16 aResponseCode)
+    {
+    __FLOG(_L8("InitiateMTPErrorRecoveryL - Entry"));
+    // Populate error response.
+    iResponse.Reset();
+    iResponse.SetUint16(TMTPTypeResponse::EResponseCode, aResponseCode);
+    iResponse.SetUint32(TMTPTypeResponse::EResponseSessionID, aRequest.Uint32(TMTPTypeRequest::ERequestSessionID));
+    iResponse.SetUint32(TMTPTypeResponse::EResponseTransactionID, aRequest.Uint32(TMTPTypeRequest::ERequestTransactionID));
+    
+    // Set the connection state pending completion, and send the response.
+    SetState(EStateErrorRecovery);
+    iTransportConnection->SendResponseL(iResponse, aRequest);
+    __FLOG(_L8("InitiateMTPErrorRecoveryL - Exit"));
+    }
+    
+/**
+Concludes an MTP connection level protocol error recovery sequence.
+@see InitiateMTPErrorRecoveryL
+*/
+void CMTPConnection::MTPErrorRecoveryComplete()
+    {
+    __FLOG(_L8("MTPErrorRecoveryComplete - Entry"));
+    SetState(EStateOpen);
+    PublishConnState(EConnectedToHost);	
+    __FLOG(_L8("MTPErrorRecoveryComplete - Exit"));
+    }
+    
+/**
+Forces the immediate shutdown of the MTP connection. This is invoked when a 
+protocol error is detected that cannot be recovered from, e.g. if an attempt
+is detected to initiate an MTP transaction before a previous transaction has 
+concluded.
+*/
+void CMTPConnection::UnrecoverableMTPError()
+    {
+    __FLOG(_L8("UnrecoverableMTPError - Entry"));
+    SetState(EStateErrorShutdown);
+    PublishConnState(EDisconnectedFromHost);		
+    iTransportConnection->CloseConnection();
+    __FLOG(_L8("UnrecoverableMTPError - Entry"));
+    }
+
+/**
+Signals the MTP connection transport to terminate any in-progress data phase 
+processing on the specified session.
+@param aidx The sessions table index of the required session.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPConnection::InitiateTransactionCancelL(TInt aIdx)
+    {    
+    __FLOG(_L8("InitiateTransactionCancelL - Entry"));
+    // Initiate transport connection level termination of the active data phase.
+    CMTPSession& session(*iSessions[aIdx]);
+    
+    switch (session.TransactionPhase())
+        {
+    case EIdlePhase:
+    case ECompletingPhase:
+    case ERequestPhase:
+        break;
+
+    case EDataIToRPhase:
+        iTransportConnection->ReceiveDataCancelL(session.ActiveRequestL());
+        break;
+        
+    case EResponsePhase:
+    case EDataRToIPhase:
+        iTransportConnection->SendDataCancelL(session.ActiveRequestL());
+        break;
+        }
+    __FLOG(_L8("InitiateTransactionCancelL - Exit"));
+    }
+
+/**
+Provides a count of the number of sessions with transactions in-progress.
+*/
+TUint CMTPConnection::ActiveSessions() const
+    {
+    __FLOG(_L8("ActiveSessions - Entry"));
+    TUint active(0);
+    const TUint count(iSessions.Count());
+    for (TUint i(0); (i < count); i++)
+        {
+        if (iSessions[i]->TransactionPhase() > EIdlePhase)
+            {
+            active++;
+            }
+        }
+    __FLOG_VA((_L8("Active sessions = %d"), active));
+    __FLOG(_L8("ActiveSessions - Exit"));
+    return active;
+    }
+
+/**
+Closes all sessions which have been opened on the connection.
+*/
+void CMTPConnection::CloseAllSessions()
+    {
+    __FLOG(_L8("CloseAllSessions - Entry"));
+	
+    TInt count = iSessions.Count();
+    __FLOG_VA((_L8("Sessions number to be closed = %d"), count));   
+	for (TInt i(count - 1); i>=0; i--)
+		{
+		CloseSession(i);
+		}
+	
+    __FLOG(_L8("CloseAllSessions - Exit"));
+    }
+
+/**
+Closes the sessions with the specified session index.
+@param aIdx The session index.
+*/
+void CMTPConnection::CloseSession(TUint aIdx)
+    {
+    __FLOG(_L8("CloseSession - Entry"));
+    
+    __FLOG_VA((_L8("Session index to be closed = %d"), aIdx));    
+    CMTPSession* session(iSessions[aIdx]);
+        
+    TUint id(session->SessionMTPId());
+    if (id != KMTPSessionNone)
+        {
+        // Notify the data providers if other than the null session is closing.
+        TMTPNotificationParamsSessionChange params = {id, *this};
+        TRAPD(err, iSingletons.DpController().NotifyDataProvidersL(EMTPSessionClosed, &params));
+        UNUSED_VAR(err);
+        }
+    
+    // Remove any queued events for session
+    RemoveEventsForSession(id);
+    
+    // Delete the session object.
+    iSessions.Remove(aIdx);
+    delete session;
+    
+    __FLOG(_L8("CloseSession - Exit"));
+    }
+    
+/**
+Provides a reference to the session with the MTP connection assigned identifier
+specified in the supplied MTP dataset. 
+@param aDataset The MTP dataset.
+@param aSessionIdElementNo The element number in the MTP dataset of the MTP 
+connection assigned identifier.
+@leave KErrNotFound If the specified session identifier is not currently
+active on the connection.
+@return The reference of the session with the specified MTP connection 
+assigned identifier.
+*/
+CMTPSession& CMTPConnection::SessionL(const TMTPTypeFlatBase& aDataset, TInt aSessionIdElementNo) const
+    {
+    return static_cast<CMTPSession&>(SessionWithMTPIdL(aDataset.Uint32(aSessionIdElementNo)));
+    }
+
+/**
+Implements an order relation for CMTPSession objects based on relative MTP
+connection assigned session IDs.
+@param aL The first MTP connection assigned session ID.
+@param aR The second object.
+@return Zero, if the two objects are equal; a negative value, if the aFirst 
+is less than aSecond, or; a positive value, if the aFirst is greater than 
+aSecond.
+*/
+TInt CMTPConnection::SessionOrder(const TUint32* aL, const CMTPSession& aR)
+    {
+    return *aL - aR.SessionMTPId();
+    }
+
+/**
+Implements a TLinearOrder relation for CMTPSession objects based on relative 
+MTP connection assigned session IDs.
+@param aL The first object.
+@param aR The second object.
+@return Zero, if the two objects are equal; a negative value, if the first 
+object is less than second, or; a positive value, if the first object is 
+greater than the second.
+*/
+TInt CMTPConnection::SessionOrder(const CMTPSession& aL, const CMTPSession& aR)
+    {
+    return aL.SessionMTPId() - aR.SessionMTPId();
+    }
+    
+/**
+Get the data receive result.
+@return the data recevice result.
+*/
+EXPORT_C TInt CMTPConnection::GetDataReceiveResult() const
+	{
+	__FLOG(_L8("GetDataReceiveResult - Entry"));
+    __FLOG_VA((_L8("Data receive result = %d"), iDataReceiveResult));
+    __FLOG(_L8("GetDataReceiveResult - Exit"));
+    return iDataReceiveResult;
+	}
+    
+/**
+Sets the MTP connection state variable.
+@param aState The new MTP connection state value.
+*/
+void CMTPConnection::SetState(TUint aState)
+    {
+    __FLOG(_L8("SetState - Entry"));
+    __FLOG_VA((_L8("Setting state = %d"), aState));
+    iState = aState;
+    __FLOG(_L8("SetState - Exit"));
+    }
+  
+    
+/**
+Provide the current MTP connection state.
+@return The current MTP connection state.
+*/
+TUint CMTPConnection::State() const
+    {
+    __FLOG(_L8("State - Entry"));
+    __FLOG_VA((_L8("State = %d"), iState));
+    __FLOG(_L8("State - Exit"));
+    return iState;        
+    }
+    
+/**
+Performs common validation processing for requests initiated from the data 
+provider framework layer. The following validation checks are performed.
+    1.  Attempt to initiate concurrent asynchronous requests to the same 
+        connection. This will result in a panic.
+    2.  Attempt to initiate a request that is invalid for the current
+        transaction phase. This will result in a panic.
+    3.  Attempt to initiate a request when the connection is in an 
+        unrecoverable error shutdown mode. This will result in the immediate
+        cancellation of the request.
+@return ETrue if the request is valid to proceed, otherwise EFalse.
+@panic CMTPConnection 0 If an asynchronous request is already pending on the 
+connection.
+@panic CMTPConnection 2 If the MTP transaction phase is invalid.
+*/
+TBool CMTPConnection::ValidFrameworkRequest(CMTPSession* aSession, TUint aValidPhases, TRequestStatus* aStatus)
+    {
+    __FLOG(_L8("ValidFrameworkRequest - Entry"));
+    __ASSERT_ALWAYS((!aSession || (aSession->TransactionPhase() & aValidPhases)), Panic(EMTPPanicInvalidState));
+    __ASSERT_ALWAYS((!aStatus || (!aSession->RequestPending())), Panic(EMTPPanicBusy));
+    
+    TBool ret(ETrue);
+    switch (State())
+        {
+    case EStateUnknown:
+    case EStateErrorRecovery:
+    default:
+        Panic(EMTPPanicInvalidState);
+        break;
+        
+    case EStateOpen:
+        break;
+
+    case EStateShutdown:    
+    case EStateErrorShutdown:
+        // Shutdown in progress.
+        if (aSession != NULL) //Transaction is still alive during shutdown
+            {
+            ret = (aSession->TransactionPhase() == ECompletingPhase);
+            aSession->SetTransactionPhase(ECompletingPhase);
+            PublishConnState(EDisconnectedFromHost);		
+            if (aStatus)
+                {
+                User::RequestComplete(aStatus, KErrCancel); 
+                }
+            }
+        else //SendEventL happens during shutdown
+            {
+            ret = EFalse;
+            }
+        break;
+        }
+        
+    __FLOG(_L8("ValidFrameworkRequest - Exit"));
+    return ret;
+    }
+
+void CMTPConnection::RemoveEventsForSession(TUint32 aMTPId)
+	{
+    __FLOG(_L8("RemoveEventsForSession - Entry"));
+    
+    TSglQueIter<CMTPEventLink> iter(iEventQ);
+    iter.SetToFirst();
+    CMTPEventLink* link = NULL;
+    
+    while ((link = iter++) != NULL)
+    	{
+		if (link->iEvent.Uint32(TMTPTypeEvent::EEventSessionID) == aMTPId)
+			{
+			DequeueEvent(link);
+			}
+		}
+    
+    __FLOG(_L8("RemoveEventsForSession - Exit"));
+	}
+
+void CMTPConnection::DequeueEvent(CMTPEventLink* aLink)
+	{
+	iEventQ.Remove(*aLink);
+	delete aLink;
+	--iPendingEventCount;	
+	}
+
+void CMTPConnection::EnqueueEvent(CMTPEventLink* aLink)
+	{
+   	iEventQ.AddLast(*aLink);
+   	++iPendingEventCount;	
+	}
+	
+CMTPConnection::CMTPEventLink::CMTPEventLink(const TMTPTypeEvent& aEvent) :
+	iEvent(aEvent)
+	{
+	}
+
+/**
+  * This method define and attach the property for publishing connection state 
+  *  events.
+  */
+void CMTPConnection::DefineConnStatePropertyL()
+	{
+	
+	 __FLOG(_L8("DefineConnStatePropertyL - Entry"));
+	 RProcess process;
+	 TUid tSid = process.SecureId();	
+	//Property can read by anyone who subscribe for it.
+	_LIT_SECURITY_POLICY_PASS(KAllowReadAll);
+	_LIT_SECURITY_POLICY_S0(KAllowWrite, (TSecureId )KMTPPublishConnStateCat);
+	
+	TInt error = RProperty::Define(tSid, EMTPConnStateKey, RProperty::EInt, KAllowReadAll, KAllowReadAll);	
+	if (KErrAlreadyExists != error)
+		{
+		User::LeaveIfError(error);
+		}
+	User::LeaveIfError(iProperty.Attach(tSid, EMTPConnStateKey, EOwnerThread));
+	__FLOG(_L8("DefineConnStatePropertyL - Exit"));
+	}
+
+/**
+  * This method is to publish various connection state. 
+  */
+void CMTPConnection::PublishConnState(TMTPConnStateType aConnState)	
+	{
+	__FLOG_VA((_L8("PublishConnState - Entry \n publishing state = %d"), (TInt)aConnState));
+	RProcess process;    
+	TInt error = iProperty.Set(process.SecureId(), EMTPConnStateKey, (TInt)aConnState);		
+	 __ASSERT_DEBUG((error == KErrNone), Panic(EMTPPanicPublishEvent));;
+	__FLOG(_L8("PublishConnState - Exit"));
+	}
+
+/**
+  * This method is used to publish the events based on the TransactionPhase.
+  * 
+  */
+void CMTPConnection::ValidateAndPublishConnState(CMTPSession& aSession, TInt aState)
+	{	
+    	__FLOG_VA((_L8("ValidateAndPublishConnState - Entry \n publishing state = %d"), aState));
+
+	TMTPConnStateType conState = EConnectedToHost;
+	switch((TStates)aState)
+		{
+		  case EStateOpen:
+		  	{
+		  	TMTPTransactionPhase tPhase = aSession.TransactionPhase();
+			switch(tPhase)
+				{
+				case EDataRToIPhase:
+					conState = ESendingDataToHost;
+				break;
+
+				case EDataIToRPhase:
+					conState = EReceiveDataFromHost;	
+				break;
+
+				case EIdlePhase:
+				case EUndefined:
+				case ERequestPhase:
+				case EResponsePhase:
+				case ECompletingPhase:
+				default:
+					conState = EConnectedToHost;
+				break;
+				}
+		  	}
+		   break;
+		  case EStateShutdown:    
+		  case EStateErrorShutdown:
+		  	conState = EDisconnectedFromHost;
+		  break;
+
+		  case EStateErrorRecovery:
+		  case EStateUnknown:
+		  default:
+		  	conState = EConnectedToHost;
+		  break;
+		}
+	PublishConnState(conState);
+	__FLOG(_L8("ValidateAndPublishConnStateL - Exit"));
+	}
+
+void CMTPConnection::DisconnectionNotifyL()
+	{
+	iSingletons.DpController().NotifyDataProvidersL(EMTPDisconnected,this);	
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpconnectionmgr.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,410 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "cmtpconnectionmgr.h"
+
+#include "cmtpconnection.h"
+#include "cmtptransportplugin.h"
+#include "mmtptransportconnection.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"ConnectionMgr");)
+
+/**
+CMTPConnectionMgr factory method.
+@leave If a failure occurs, one of the system wide error codes.
+*/
+CMTPConnectionMgr* CMTPConnectionMgr::NewL()
+    {
+    CMTPConnectionMgr* self = new(ELeave) CMTPConnectionMgr();
+    return self;
+    }
+
+/**
+Destructor.
+*/  
+CMTPConnectionMgr::~CMTPConnectionMgr()
+    {
+    StopTransport( iTransportUid, ETrue );
+    iConnections.ResetAndDestroy();
+    iSuspendedTransports.Reset();
+    iSuspendedTransports.Close();
+    delete iTransportTrigger;
+    __FLOG_CLOSE;
+    }
+
+/**
+Provides a reference to the connection with the specified connection identifier.
+@param aConnectionId The connection identifier.
+@return The connection reference.
+@leave KErrNotFound If a connection with the specified identifier does not 
+exist.
+*/
+EXPORT_C CMTPConnection& CMTPConnectionMgr::ConnectionL(TUint aConnectionId) const
+    {   
+    __FLOG(_L8("ConnectionL - Entry"));
+    
+    TInt idx(ConnectionFind(aConnectionId));
+    
+    __FLOG_VA((_L8("idx is %d "), idx));
+    __ASSERT_ALWAYS((idx != KErrNotFound), User::Invariant());
+    
+    __FLOG(_L8("ConnectionL - Exit"));
+    return *iConnections[idx];
+    }
+
+/**
+Provides a count of the number of currently open connections.
+@return The count of currently open connections.
+*/  
+TUint CMTPConnectionMgr::ConnectionCount() const
+    {
+    return iConnections.Count();
+    }
+
+/**
+Provide a non-const reference to the located at the specified position within 
+the connection table.
+@return A non-const reference to the required connection.
+*/
+CMTPConnection& CMTPConnectionMgr::operator[](TInt aIndex) const
+    {
+    return *iConnections[aIndex];
+    }
+    
+/**
+Returns the current transportID.
+@return The CMTPTransportPlugin interface implementation UID.
+*/
+EXPORT_C TUid CMTPConnectionMgr::TransportUid()
+    {
+    return iTransportUid;
+    }
+
+EXPORT_C void CMTPConnectionMgr::StartTransportL(TUid aTransport)
+    {
+    StartTransportL( aTransport, NULL );
+    }
+
+/**
+Loads and starts up the MTP transport plug-in with the specified 
+CMTPTransportPlugin interface implementation UID. Only one MTP transport 
+plug-in can be loaded at any given time.
+@param The CMTPTransportPlugin interface implementation UID.
+@leave KErrNotSupported If an attempt is made to load a second MTP transport
+plug-in.
+@leave One of the system wide error codes, if a processing failure occurs.
+@see StopTransport
+*/
+EXPORT_C void CMTPConnectionMgr::StartTransportL(TUid aTransport, const TAny* aParameter)
+    {
+	__FLOG(_L8("StartTransportL - Entry"));
+	
+    if (iTransport)
+        {
+        if (aTransport != iTransportUid)
+            {
+            // Multiple transports not currently supported.
+            User::Leave(KErrNotSupported);
+            }
+        }
+    else
+        {
+
+        iTransport = CMTPTransportPlugin::NewL(aTransport, aParameter);
+
+        TRAPD(err, iTransport->StartL(*this));
+		if (err != KErrNone)
+			{
+			__FLOG_VA( ( _L8("StartTransportL error, error code = %d"), err) );
+			delete iTransport;
+			iTransport = NULL;
+			User::Leave(err);
+			}
+        iTransportUid = aTransport;       
+		
+        iTransportCount++;
+        UnsuspendTransport( iTransportUid );
+        }
+		
+	__FLOG(_L8("StartTransportL - Exit"));
+    }
+
+/**
+Queue the transport to start when there is no running transport
+@param aTransport, The CMTPTransportPlugin interface implementation UID.
+@param aParameter, reserved
+@leave One of the system wide error codes, if the operation fails.
+*/
+EXPORT_C void CMTPConnectionMgr::QueueTransportL( TUid aTransport, const TAny* /*aParameter*/ )
+    {
+    __FLOG_VA( ( _L8("+QueueTransportL( 0x%08X )"), aTransport.iUid ) );
+    __ASSERT_DEBUG( ( KErrNotFound == iSuspendedTransports.Find( aTransport ) ), User::Invariant() );
+    iSuspendedTransports.InsertL( aTransport, 0 );
+    __FLOG( _L8("-QueueTransportL") );
+    }
+
+EXPORT_C void CMTPConnectionMgr::SetClientSId(TUid aSecureId)
+	{
+	iSecureId=aSecureId;
+	}
+
+/**
+Shuts down and unloads the MTP transport plug-in with the specified 
+CMTPTransportPlugin interface implementation UID.
+@param The CMTPTransportPlugin interface implementation UID.
+*/
+EXPORT_C void CMTPConnectionMgr::StopTransport(TUid aTransport)
+    {
+    StopTransport( aTransport, EFalse );
+    }
+
+/**
+Shuts down and unloads the MTP transport plug-in with the specified 
+CMTPTransportPlugin interface implementation UID.
+@param aTransport The CMTPTransportPlugin interface implementation UID.
+@param aByBearer If ETrue, it means the transport plugin is stopped because the bearer is turned off or not activated.
+*/
+EXPORT_C void CMTPConnectionMgr::StopTransport( TUid aTransport, TBool aByBearer )
+    {
+	__FLOG(_L8("StopTransport - Entry"));
+	
+    if ( ( iTransport ) && ( aTransport == iTransportUid ) )
+        {
+        if ( !aByBearer )
+            {
+            TRAP_IGNORE( SuspendTransportL( aTransport ) );
+            }
+        iTransport->Stop(*this);
+        delete iTransport;
+        iTransport = NULL;
+        iTransportUid = KNullUid;
+        iTransportCount--;
+
+
+        }
+    if ( aByBearer )
+        {
+        UnsuspendTransport( aTransport );
+        }
+		
+	__FLOG(_L8("StopTransport - Exit"));
+    }
+
+/**
+Shuts down and unloads all active MTP transport plug-ins.
+*/
+EXPORT_C void CMTPConnectionMgr::StopTransports()
+    {
+    if (iTransport)
+        {
+        iTransport->Stop(*this);
+        delete iTransport;
+        iTransport = NULL;
+        iTransportUid = KNullUid;
+        iTransportCount--;
+        }
+    }
+
+/**
+Returns the number of active Transports.
+@return Number of active transports
+*/
+EXPORT_C TInt CMTPConnectionMgr::TransportCount() const
+    {
+	return iTransportCount;
+    }
+
+void CMTPConnectionMgr::ConnectionClosed(MMTPTransportConnection& aTransportConnection)
+    {
+    __FLOG(_L8("ConnectionClosed - Entry"));
+    
+    TInt idx(ConnectionFind(aTransportConnection.BoundProtocolLayer().ConnectionId()));
+    __FLOG_VA((_L8("idx is %d "), idx));
+    __ASSERT_DEBUG((idx != KErrNotFound), User::Invariant());
+    
+    CMTPConnection* connection(iConnections[idx]);
+    connection->ConnectionSuspended();
+    
+    ResumeSuspendedTransport();
+    
+    __FLOG(_L8("ConnectionClosed - Exit"));
+    }
+    
+void CMTPConnectionMgr::ConnectionOpenedL(MMTPTransportConnection& aTransportConnection)
+    {   
+    __FLOG(_L8("ConnectionOpenedL - Entry"));
+    
+    TUint impUid = aTransportConnection.GetImplementationUid();
+    TInt idx = ConnectionFind(impUid);
+    CMTPConnection* connection = NULL;
+    
+    if (idx == KErrNotFound)
+        {
+        // take transport connection implementation UID as connection ID
+        connection = CMTPConnection::NewLC(impUid, aTransportConnection);
+        iConnections.InsertInOrder(connection, iConnectionOrder);
+        CleanupStack::Pop(connection); 
+        }
+    else
+        {
+        connection = iConnections[idx];
+        }
+    connection->ConnectionResumedL(aTransportConnection);
+    
+    __FLOG(_L8("ConnectionOpenedL - Exit"));
+    }
+
+TBool CMTPConnectionMgr::DeleteConnection(TUint aConnectionId)
+    {
+    __FLOG(_L8("DeleteConnection - Entry"));
+    
+    TBool ret = EFalse;    
+    TInt idx = ConnectionFind(aConnectionId);
+    
+    if (idx != KErrNotFound)
+        {
+        CMTPConnection* connection(iConnections[idx]);
+        iConnections.Remove(idx);
+        delete connection;
+        ret = ETrue;
+        }
+    
+    __FLOG(_L8("DeleteConnection - Entry"));
+    
+    return ret;
+    }
+
+EXPORT_C TUid CMTPConnectionMgr::ClientSId()
+	{
+	return iSecureId;
+	}
+/**
+Constructor.
+*/
+CMTPConnectionMgr::CMTPConnectionMgr() :
+    iConnectionOrder(ConnectionOrderCompare),
+    iShutdownConnectionIdx(KErrNotFound),
+	iTransportUid(KNullUid)
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);    
+    }
+
+/**
+Provides the connections table index of the connection with the specified 
+connection identifier.
+@param The identifier of the required connection.
+@return The connection table index of the required connection, or KErrNotFound
+if the connection identifier could not be found.
+*/ 
+TInt CMTPConnectionMgr::ConnectionFind(TUint aConnectionId) const
+    {
+    __FLOG_VA((_L8("ConnectionFind - Entry with connectionId %d "), aConnectionId));
+    TInt ret(KErrNotFound);
+    
+    const TUint noConnections = iConnections.Count();
+    for (TUint i(0); ((i < noConnections) && (ret == KErrNotFound)); i++)
+        {
+        TInt id(iConnections[i]->ConnectionId());
+        if (aConnectionId == id)
+            {
+            ret = i;
+            break;
+            }
+        }
+    __FLOG(_L8("ConnectionFind - Exit"));    
+    return ret;
+    }
+
+/**
+Determines the relative order of two CMTPConnection objects based on their 
+connection IDs.
+@return Zero, if the two objects are equal; a negative value, if the aFirst 
+is less than aSecond, or; a positive value, if the aFirst is greater than 
+aSecond.
+*/
+TInt CMTPConnectionMgr::ConnectionOrderCompare(const CMTPConnection& aFirst, const CMTPConnection& aSecond)
+    {
+    return aFirst.ConnectionId() - aSecond.ConnectionId();
+    }
+
+/**
+Append the transport to the suspended transport list
+@param aTransport, The implementation UID of the suspended transport plugin
+@leave One of the system wide error codes, if the operation fails.
+*/
+void CMTPConnectionMgr::SuspendTransportL( TUid aTransport )
+    {
+    __FLOG_1( _L8("+SuspendTransportL( 0x%08X )"), aTransport );
+    if ( KErrNotFound == iSuspendedTransports.Find( aTransport ) )
+        {
+        iSuspendedTransports.AppendL( aTransport );
+        }
+    __FLOG( _L8("-SuspendTransportL") );
+    }
+
+/**
+Remove transport from the suspended transports list
+@param aTransport, The CMTPTransportPlugin interface implementation UID 
+*/
+void CMTPConnectionMgr::UnsuspendTransport( TUid aTransport )
+    {
+    __FLOG_1( _L8("+UnsuspendTransport( 0x%08X )"), aTransport.iUid );
+    TInt idx = iSuspendedTransports.Find( aTransport );
+    if ( KErrNotFound != idx )
+        {
+        __FLOG_1( _L8("Remove the number %d suspended transport"), idx );
+        iSuspendedTransports.Remove( idx );
+        }
+    __FLOG( _L8("-UnsuspendTransport") );
+    }
+
+/**
+Prepare to resume suspended transport
+*/
+void CMTPConnectionMgr::ResumeSuspendedTransport()
+    {
+    __FLOG( _L8("+ResumeSuspendedTransport") );
+    const TInt count = iSuspendedTransports.Count();
+    if ( ( count > 0 )
+        // If the transport was just switched and suspended, it shouldn't be resumed.
+        && ( iTransportUid != iSuspendedTransports[count-1] ) )
+        {
+        __FLOG( _L8("Found suspended transport(s).") );
+        if ( !iTransportTrigger )
+            {
+            iTransportTrigger = new( ELeave ) CAsyncCallBack( CActive::EPriorityStandard );
+            }
+        __ASSERT_DEBUG( ( !iTransportTrigger->IsActive() ), User::Invariant() );
+        TCallBack callback( CMTPConnectionMgr::DoResumeSuspendedTransport, this );
+        iTransportTrigger->Set( callback );
+        iTransportTrigger->CallBack();
+        }
+    __FLOG( _L8("-ResumeSuspendedTransport") );
+    }
+
+/**
+Resume suspended transport
+@param aSelf, The memory address of the CMTPConnectionMgr instance
+@return KErrNone, but the value is ignored.
+*/
+TInt CMTPConnectionMgr::DoResumeSuspendedTransport( TAny* aSelf )
+    {
+    CMTPConnectionMgr* self = reinterpret_cast< CMTPConnectionMgr* >( aSelf );
+    __ASSERT_DEBUG( ( self->iSuspendedTransports.Count() > 0 ), User::Invariant() );
+    TRAP_IGNORE( self->StartTransportL( self->iSuspendedTransports[self->iSuspendedTransports.Count()-1] ) );
+    return KErrNone;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpdatacodegenerator.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,258 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+/**
+ @file
+ @internalComponent
+ */
+#include <e32err.h>
+#include <mtp/mtpprotocolconstants.h>
+
+#include "mtpservicecommon.h"
+#include "rmtpframework.h"
+#include "cmtpdatacodegenerator.h"
+#include "cmtpservicemgr.h"
+
+
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"DataCodeGenerator");)
+
+const TUint16 KUndenfinedStartCode = EMTPCodeUndefined1Start + 1;
+const TUint16 KUndenfinedEndCode = EMTPCodeUndefined1End;
+
+
+CMTPDataCodeGenerator* CMTPDataCodeGenerator::NewL()
+    {
+    CMTPDataCodeGenerator* self = new (ELeave) CMTPDataCodeGenerator();
+    CleanupStack::PushL ( self );
+    self->ConstructL ();
+    CleanupStack::Pop ( self );
+    return self;
+    }
+
+CMTPDataCodeGenerator::~CMTPDataCodeGenerator()
+    {
+    __FLOG(_L8("CMTPDataCodeGenerator::~CMTPDataCodeGenerator - Entry"));
+
+    iSingletons.Close();
+
+    __FLOG(_L8("CMTPDataCodeGenerator::~CMTPDataCodeGenerator - Exit"));
+    
+    __FLOG_CLOSE;
+    }
+
+void CMTPDataCodeGenerator::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("CMTPDataCodeGenerator::ConstructL - Entry"));
+
+    iSingletons.OpenL ();
+
+    __FLOG(_L8("CMTPDataCodeGenerator::ConstructL - Exit"));
+    }
+
+CMTPDataCodeGenerator::CMTPDataCodeGenerator() :
+    iUndefinedNextCode(KUndenfinedStartCode ),
+    iVendorExtFormatCode(EMTPFormatCodeVendorExtDynamicStart)
+    {
+
+    }
+
+TInt CMTPDataCodeGenerator::IncServiceIDResource( const TUint aServiceType, TUint& aServiceID )
+    {
+    __FLOG(_L8("CMTPDataCodeGenerator::IncServiceIDResource - Entry"));
+    if ( iUndefinedNextCode >= KUndenfinedEndCode )
+        return KErrOverflow;
+    
+    switch ( aServiceType )
+       {
+       case EMTPServiceTypeNormal:
+           {
+           aServiceID = ( ( ++iUndefinedNextCode ) | KNormalServiceTypeMask );
+           }
+           break;
+   
+       case EMTPServiceTypeAbstract:
+           {
+           aServiceID = ( (++iUndefinedNextCode) | KAbstrackServiceTypeMask );
+           }
+           break;
+       default:
+           {
+           __FLOG(_L8("CMTPDataCodeGenerator::IncServiceIDResource - Service Type not supported")); 
+           }
+       }
+    __FLOG(_L8("CMTPDataCodeGenerator::IncServiceIDResource - Exit"));
+    return KErrNone;
+    }
+
+void CMTPDataCodeGenerator::DecServiceIDResource()
+    {
+    __FLOG(_L8("CMTPDataCodeGenerator::DecServiceIDResource - Entry"));
+    iUndefinedNextCode--;
+    __FLOG(_L8("CMTPDataCodeGenerator::DecServiceIDResource - Exit"));
+    }
+
+TBool CMTPDataCodeGenerator::IsValidServiceType( const TUint aServiceType ) const
+    {
+    return ( (EMTPServiceTypeNormal == aServiceType) || (EMTPServiceTypeAbstract == aServiceType) );
+    }
+
+TInt CMTPDataCodeGenerator::AllocateServiceID(const TMTPTypeGuid& aPGUID, const TUint aServiceType, TUint& aServiceID )
+    {
+    __FLOG(_L8("CMTPDataCodeGenerator::AllocateServiceID - Entry"));
+    
+    if( !IsValidServiceType(aServiceType) )
+        return KErrArgument;
+        
+    TInt err(KErrNone);
+    TUint retID (KInvliadServiceID);
+    if( iSingletons.ServiceMgr().IsSupportedService(aPGUID) )
+        {
+        if( iSingletons.ServiceMgr().ServiceTypeOfSupportedService(aPGUID) != aServiceType )
+            return KErrArgument;
+            
+        err = iSingletons.ServiceMgr().GetServiceId(aPGUID , retID);
+        if( KErrNone != err )
+            {
+            if((err = IncServiceIDResource( aServiceType, retID )) != KErrNone)
+                return err;
+            
+            err = iSingletons.ServiceMgr().EnableService( aPGUID, retID );
+            if( KErrNone != err )
+                {
+                DecServiceIDResource();
+                return err;
+                }
+            }
+        
+        }
+    else
+        {
+        if((err = IncServiceIDResource( aServiceType, retID )) != KErrNone)
+            return err;
+        }
+    
+   aServiceID = retID;
+   iSingletons.ServiceMgr().InsertServiceId( retID );
+
+    __FLOG(_L8("CMTPDataCodeGenerator::AllocateServiceID - Exit"));
+    return KErrNone;
+    }
+
+TInt CMTPDataCodeGenerator::AllocateServicePropertyCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, TUint16& aServicePropertyCode )
+    {
+    __FLOG(_L8("CMTPDataCodeGenerator::AllocateServicePropertyCode - Entry"));
+
+    TUint retID = KInvliadU16DataCode;
+    if( iSingletons.ServiceMgr().IsSupportedService(aServicePGUID) )
+        {
+        TInt err = iSingletons.ServiceMgr().GetServicePropertyCode( aServicePGUID, aPKNamespace, aPKID, retID );
+        if( KErrNone != err )
+            return err;
+
+        if(retID == KInvliadU16DataCode)
+           {
+           if ( iUndefinedNextCode >= KUndenfinedEndCode )
+               return KErrOverflow;
+           
+           retID = ++iUndefinedNextCode;
+           iSingletons.ServiceMgr().SetServicePropertyCode( aServicePGUID, aPKNamespace, aPKID, retID);
+           }
+        }
+    else
+        {
+        if ( iUndefinedNextCode >= KUndenfinedEndCode )
+            return KErrOverflow;
+    
+        retID = ++iUndefinedNextCode;
+        }
+    
+    aServicePropertyCode = retID;
+    
+    __FLOG(_L8("CMTPDataCodeGenerator::AllocateServicePropertyCode - Exit"));
+    return KErrNone;
+    }
+
+TInt CMTPDataCodeGenerator::AllocateServiceFormatCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, TUint16& aServiceFormatCode )
+    {
+    __FLOG(_L8("CMTPServiceConfig::AllocateServiceFormatCode - Entry"));
+
+    TUint retID = KInvliadU16DataCode;
+    if( iSingletons.ServiceMgr().IsSupportedService(aServicePGUID) )
+        {
+        TInt err = iSingletons.ServiceMgr().GetServiceFormatCode( aServicePGUID, aGUID, retID );
+        if( KErrNone != err )
+            return err;
+
+        if(retID == KInvliadU16DataCode)
+           {
+           if ( iVendorExtFormatCode > EMTPFormatCodeVendorExtDynamicEnd )
+               return KErrOverflow;
+           
+           retID = ++iVendorExtFormatCode;
+           iSingletons.ServiceMgr().SetServiceFormatCode( aServicePGUID, aGUID, retID);
+           }
+        }
+    else
+        {
+        if ( iVendorExtFormatCode > EMTPFormatCodeVendorExtDynamicEnd )
+            return KErrOverflow;
+            
+        retID = ++iVendorExtFormatCode;
+        }
+    
+    aServiceFormatCode = retID;
+    
+    __FLOG(_L8("CMTPServiceConfig::AllocateServiceFormatCode - Exit"));
+    return KErrNone;
+    }
+
+TInt CMTPDataCodeGenerator::AllocateServiceMethodFormatCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, TUint16& aMethodFormatCode )
+    {
+    __FLOG(_L8("CMTPDataCodeGenerator::AllocateServiceMethodFormatCode - Entry"));
+    
+    TUint retID = KInvliadU16DataCode;
+    if( iSingletons.ServiceMgr().IsSupportedService(aServicePGUID) )
+        {
+        TInt err = iSingletons.ServiceMgr().GetServiceMethodCode( aServicePGUID, aGUID, retID );
+        if( KErrNone != err )
+            return err;
+    
+        if(retID == KInvliadU16DataCode)
+           {
+           if ( iUndefinedNextCode > KUndenfinedEndCode )
+               return KErrOverflow;
+           
+           retID = ++iUndefinedNextCode;
+           iSingletons.ServiceMgr().SetServiceMethodCode( aServicePGUID, aGUID, retID);
+           }
+        }
+    else
+        {
+        if ( iUndefinedNextCode > KUndenfinedEndCode )
+            return KErrOverflow;
+            
+        retID = ++iUndefinedNextCode;
+        }
+    
+    aMethodFormatCode = retID;
+    
+    __FLOG(_L8("CMTPDataCodeGenerator::AllocateServiceMethodFormatCode - Exit"));
+    return KErrNone;
+    }
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpdataprovider.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,811 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtpdataproviderplugin.h>
+#include <mtp/mtpdataproviderconfig.hrh>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptyperesponse.h> 
+
+#include "cmtpsession.h"
+#include "cmtpconnection.h"
+#include "cmtpconnectionmgr.h"
+#include "cmtpdataprovider.h"
+#include "cmtpdataproviderconfig.h"
+#include "cmtpframeworkconfig.h"
+#include "cmtpobjectmgr.h"
+#include "cmtpparserrouter.h"
+#include "cmtpreferencemgr.h"
+#include "cmtpstoragemgr.h"
+#include "mmtptransactionproxy.h"
+#include "rmtpframework.h"
+#include "cdummydp.h"
+#include "cmtpdatacodegenerator.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"DataProvider");)
+
+const TInt KWaitForEnumeration = 1000000 * 3;
+
+#define KMTPDummyDataProvider             0x0000
+
+/**
+CMTPDataProvider factory method. 
+@param aId The data provider identifier.
+@param aUid The data provider implementation UID.
+@param aConfig The data provider configurability parameter data. Ownership IS 
+transfered.
+@return A pointer to a new CMTPDataProvider instance. Ownership IS transfered.
+@leave One of the system wide error codes if a processing failure occurs.
+*/
+CMTPDataProvider* CMTPDataProvider::NewL(TUint aId, TUid aUid, CMTPDataProviderConfig* aConfig)
+    {
+    CMTPDataProvider* self = CMTPDataProvider::NewLC(aId, aUid, aConfig);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+CMTPDataProvider factory method. A pointer to the CMTPDataProvider instance is
+placed on the cleanup stack.
+@param aUid The data provider implementation UID.
+@param aConfig The data provider configurability parameter data. Ownership IS 
+transfered.
+@return A pointer to a new CMTPDataProvider instance. Ownership IS transfered.
+@leave One of the system wide error codes if a processing failure occurs.
+*/ 
+CMTPDataProvider* CMTPDataProvider::NewLC(TUint aId, TUid aUid, CMTPDataProviderConfig* aConfig)
+    {
+    CMTPDataProvider* self = new (ELeave) CMTPDataProvider(aId, aUid, aConfig);
+    CleanupStack::PushL(self);
+    self->ConstructL();    
+    return self;
+    }
+    
+/**
+Destructor.
+*/
+CMTPDataProvider::~CMTPDataProvider()
+    {
+    __FLOG_VA((_L8("~CMTPDataProvider - Entry, data provider %d "), iId));
+    Cancel();
+    iSupported.ResetAndDestroy();
+    delete iImplementation;
+    iSingletons.Close();
+
+    // Only delete passed objects when fully constructed.
+    if (iConstructed)
+        {
+        delete iConfig;
+        }
+	
+	iTimer.Close();  
+    __FLOG_VA((_L8("~CMTPDataProvider - Exit, data provider %d "), iId));
+    __FLOG_CLOSE;
+    }
+    
+void CMTPDataProvider::ExecuteEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection)
+    {   
+    __FLOG_VA((_L8("ExecuteEventL - Entry, data provider %d "), iId));
+    __ASSERT_DEBUG(iImplementation, User::Invariant());
+	
+    if (iTimerActive && aEvent.Uint16(TMTPTypeEvent::EEventCode) == EMTPEventCodeCancelTransaction)
+	    {
+	    Cancel();
+	    }
+    
+    // Pass this event notification directly to the plugin...
+    // In reality we will only ever see one event canceltransaction.
+    iImplementation->ProcessEventL(aEvent, aConnection);
+    __FLOG_VA((_L8("ExecuteEventL - Exit, data provider %d "), iId));
+    }
+        
+void CMTPDataProvider::ExecuteRequestL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {
+    __FLOG_VA((_L8("ExecuteRequestL - Entry, data provider %d "), iId));
+    __ASSERT_DEBUG(iImplementation, User::Invariant());
+               
+    iCurrentRequest = &aRequest;
+    iCurrentConnection = &iSingletons.ConnectionMgr().ConnectionL(aConnection.ConnectionId());
+    // Schedule data provider to process this request.  
+    Schedule(); 
+    
+    __FLOG_VA((_L8("ExecuteRequestL - Exit, data provider %d "), iId));
+    }
+    
+EXPORT_C void CMTPDataProvider::ExecuteProxyRequestL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, MMTPTransactionProxy& aProxy)
+    {
+    __FLOG_VA((_L8("ExecuteProxyRequestL - Entry, data provider %d "), iId));
+    iProxy = &aProxy;
+    iCurrentRequest    = &aRequest;
+    iCurrentConnection = static_cast<CMTPConnection*>(&aConnection);
+    Schedule();
+    __FLOG_VA((_L8("ExecuteProxyRequestL - Exit, data provider %d "), iId));
+    }
+    
+void CMTPDataProvider::EnumerateObjectsL(TUint32 aStorageId)
+    {
+    __FLOG_VA((_L8("EnumerateObjectsL - Entry, data provider %d "), iId));
+    iEnumerationState = ((iEnumerationState & ~EObjectsEnumerationState) | EObjectsEnumerating);
+    TBool abnormaldown = EFalse;
+    iSingletons.FrameworkConfig().GetValueL(CMTPFrameworkConfig::EAbnormalDown, abnormaldown);
+    iImplementation->StartObjectEnumerationL(aStorageId, abnormaldown);
+    __FLOG_VA((_L8("EnumerateObjectsL - Exit, data provider %d "), iId));
+    }
+
+void CMTPDataProvider::EnumerateStoragesL()
+    {
+    __FLOG_VA((_L8("EnumerateStoragesL - Entry, data provider %d "), iId));
+    iEnumerationState = ((iEnumerationState & ~EStoragesEnumerationState) | EStoragesEnumerating);
+    iImplementation->StartStorageEnumerationL();
+    __FLOG_VA((_L8("EnumerateStoragesL - Exit, data provider %d "), iId));
+    }
+
+/**
+Provides the data provider's enumeration state.
+@return The data provider's enumeration state.
+*/
+EXPORT_C TUint CMTPDataProvider::EnumerationState() const
+	{
+    return iEnumerationState;	
+	}
+    
+/**
+Provides the data provider's implementation UID
+@return The data provider's implementation UID.
+*/
+EXPORT_C TUid CMTPDataProvider::ImplementationUid() const 
+    {
+    return iImplementationUid;
+    }
+    
+/**
+Provides the handle of the bound data provider plug-in.
+@return The data provider plug-in.
+*/
+EXPORT_C CMTPDataProviderPlugin& CMTPDataProvider::Plugin() const
+    {
+    __ASSERT_DEBUG(iImplementation, User::Invariant());
+    return *iImplementation;
+    }
+    
+EXPORT_C TBool CMTPDataProvider::Supported(TMTPSupportCategory aCategory, TUint aCode) const
+    {
+    return iSupported[aCategory]->Supported(aCode);
+    }
+    
+EXPORT_C const RArray<TUint>& CMTPDataProvider::SupportedCodes(TMTPSupportCategory aCategory) const
+    {
+    return iSupported[aCategory]->Codes();
+    }
+
+/**
+Sets the 
+*/    
+void CMTPDataProvider::SetDataProviderId(TUint aId)
+    {
+    __FLOG_VA((_L8("~CMTPDataProvider - Entry, data provider %d "), iId));
+    iId = aId;
+    __FLOG_VA((_L8("~CMTPDataProvider - Entry, data provider %d "), iId));
+    }
+	
+/**
+Implements a linear order relation for @see CMTPDataProvider 
+objects based on relative @see CMTPDataProvider::ImplementationUid.
+@param aUid The implementation UID object to match.
+@param aObject The object instance to match.
+@return Zero, if the two objects are equal; A negative value, if the first 
+object is less than the second, or; A positive value, if the first object is 
+greater than the second.
+*/     
+TInt CMTPDataProvider::LinearOrderUid(const TUid* aUid, const CMTPDataProvider& aObject)
+    {
+    return (aUid->iUid - aObject.ImplementationUid().iUid);
+    }
+    
+/**
+Implements a @see TLinearOrder for @see CMTPDataProvider objects based on 
+relative @see CMTPDataProvider::ImplementationUid.
+@param aL The first object instance.
+@param aR The second object instance.
+@return Zero, if the two objects are equal; A negative value, if the first 
+object is less than the second, or; A positive value, if the first object is 
+greater than the second.
+*/   
+TInt CMTPDataProvider::LinearOrderUid(const CMTPDataProvider& aL, const CMTPDataProvider& aR)
+    {
+    return (aL.iImplementationUid.iUid - aR.iImplementationUid.iUid);
+    }
+
+/**
+Implements a @see TLinearOrder for @see CMTPDataProvider objects based on 
+relative @see CMTPDataProvider::DataProviderId.
+@param aDPId The Dataprovider ID to match.
+@param aR The second object instance.
+@return Zero, if the two objects are equal; A negative value, if the first 
+object is less than the second, or; A positive value, if the first object is 
+greater than the second.
+*/   
+TInt CMTPDataProvider::LinearOrderDPId(const TUint* aDPId, const CMTPDataProvider& aObject)
+    {
+    return (*aDPId - aObject.DataProviderId());
+    }
+
+/**
+Implements a @see TLinearOrder for @see CMTPDataProvider objects based on 
+relative @see CMTPDataProvider::DataProviderId.
+@param aL The first object instance.
+@param aR The second object instance.
+@return Zero, if the two objects are equal; A negative value, if the first 
+object is less than the second, or; A positive value, if the first object is 
+greater than the second.
+*/   
+TInt CMTPDataProvider::LinearOrderDPId(const CMTPDataProvider& aL, const CMTPDataProvider& aR)
+    {
+    return (aL.DataProviderId() - aR.DataProviderId());
+    }
+
+/**
+Implements a @see TLinearOrder for @see CMTPDataProvider objects based on 
+relative enumeration phase
+@param aL The first object instance.
+@param aR The second object instance.
+@return Zero, if the two objects are equal; A negative value, if the first 
+object is less than the second, or; A positive value, if the first object is 
+greater than the second.
+*/   
+TInt CMTPDataProvider::LinearOrderEnumerationPhase(const CMTPDataProvider& aL, const CMTPDataProvider& aR)
+    {    
+    return (aL.DataProviderConfig().UintValue(MMTPDataProviderConfig::EEnumerationPhase)
+    	      - aR.DataProviderConfig().UintValue(MMTPDataProviderConfig::EEnumerationPhase));
+    }
+
+    
+TUint CMTPDataProvider::DataProviderId() const
+    {
+    return iId;
+    }    
+    
+TMTPOperationalMode CMTPDataProvider::Mode() const
+    {
+    return (iSingletons.DpController().Mode());    
+    }
+    
+void CMTPDataProvider::ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {
+    __FLOG_VA((_L8("ReceiveDataL - Entry, data provider %d "), iId));
+    __ASSERT_DEBUG(iImplementation, User::Invariant());
+    __ASSERT_DEBUG(!IsActive(), User::Invariant());
+    
+    if (iProxy)
+        {
+        // Pass to proxy plugin for processing
+        iProxy->ProxyReceiveDataL(aData, aRequest, aConnection, iStatus);
+        SetActive();
+        
+        // Running under proxy mode so manually set the next transaction phase to be processed by the plugin
+        iProxyTransactionPhase = EResponsePhase;
+        }
+    else
+        {
+        // Inform the connection that we wish to receive data from the connection
+        CMTPConnection& connection(iSingletons.ConnectionMgr().ConnectionL(aConnection.ConnectionId()));
+        connection.ReceiveDataL(aData, aRequest, iStatus);
+        SetActive();
+        // Async call so wait for object to be activated...
+        }
+    __FLOG_VA((_L8("ReceiveDataL - Exit, data provider %d "), iId));
+    }
+
+void CMTPDataProvider::SendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {
+    __FLOG_VA((_L8("SendDataL - Entry, data provider %d "), iId));
+    __ASSERT_DEBUG(iImplementation, User::Invariant());
+    __ASSERT_DEBUG(!IsActive(), User::Invariant());
+    
+    if (iProxy)
+        {
+        // Pass to proxy plugin for processing
+        iProxy->ProxySendDataL(aData,aRequest, aConnection, iStatus);
+        SetActive();
+        
+        // Running under proxy mode so manually set the next transaction phase to be processed by the plugin
+        iProxyTransactionPhase = EResponsePhase;
+        }
+    else
+        {
+        // Pass request to connection...
+        CMTPConnection& connection(iSingletons.ConnectionMgr().ConnectionL(aConnection.ConnectionId()));
+        connection.SendDataL(aData, aRequest, iStatus);
+        SetActive();
+        // Async call so wait for object to be activated...
+        }
+    __FLOG_VA((_L8("SendDataL - Exit, data provider %d "), iId));
+    }
+
+void CMTPDataProvider::SendEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection)
+    {
+    __FLOG_VA((_L8("SendEventL - Entry, data provider %d "), iId));
+    __ASSERT_DEBUG(iImplementation, User::Invariant());
+    
+    CMTPConnection& connection(iSingletons.ConnectionMgr().ConnectionL(aConnection.ConnectionId()));
+    connection.SendEventL(aEvent);
+    __FLOG_VA((_L8("SendEventL - Exit, data provider %d "), iId));
+    }
+
+void CMTPDataProvider::SendEventL(const TMTPTypeEvent& aEvent)
+    {
+    __FLOG_VA((_L8("SendEventL - Entry, data provider %d "), iId));
+    if (aEvent.Uint32(TMTPTypeEvent::EEventSessionID) != KMTPSessionAll)
+        {
+        User::Leave(KErrArgument);            
+        }
+    
+    TUint numConnections(iSingletons.ConnectionMgr().ConnectionCount());
+    
+    for (TUint i(0); (i < numConnections); i++)
+        {
+        iSingletons.ConnectionMgr()[i].SendEventL(aEvent);       
+        }
+    __FLOG_VA((_L8("SendEventL - Exit, data provider %d "), iId));
+    }
+
+void CMTPDataProvider::SendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {
+    __FLOG_VA((_L8("SendResponseL - Entry, data provider %d "), iId));
+    __ASSERT_DEBUG(iImplementation, User::Invariant());
+    __ASSERT_DEBUG(!IsActive(), User::Invariant());
+    
+    if (iProxy)
+        {
+        // Pass to proxy plugin for processing
+        iProxy->ProxySendResponseL(aResponse, aRequest, aConnection, iStatus);
+        SetActive();
+        
+        // Running under proxy mode so manually set the next transaction phase to be processed by the plugin
+        iProxyTransactionPhase = ECompletingPhase;
+        }
+    else
+        {
+        CMTPConnection& connection(iSingletons.ConnectionMgr().ConnectionL(aConnection.ConnectionId()));
+        connection.SendResponseL(aResponse, aRequest, iStatus);
+        SetActive();
+        }
+    __FLOG_VA((_L8("SendResponseL - Exit, data provider %d "), iId));
+    }
+
+void CMTPDataProvider::TransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {
+    __FLOG_VA((_L8("TransactionCompleteL - Entry, data provider %d "), iId));
+    __ASSERT_DEBUG(iImplementation, User::Invariant());
+    
+    if (iProxy)
+        {
+        // Pass to proxy plugin for processing
+        iProxy->ProxyTransactionCompleteL(aRequest, aConnection);
+        // Running under proxy mode so manually set the next transaction phase to be processed by the plugin
+        iProxyTransactionPhase = ERequestPhase;
+        }
+    else
+        {
+        CMTPConnection& connection(iSingletons.ConnectionMgr().ConnectionL(aConnection.ConnectionId()));
+        connection.TransactionCompleteL(aRequest);            
+        }
+    
+    // Clear pointers
+    iProxy = NULL;
+    iCurrentRequest = NULL;
+    iCurrentConnection = NULL;
+    
+    __FLOG_VA((_L8("TransactionCompleteL - Exit, data provider %d "), iId));
+    } 
+    
+void CMTPDataProvider::RouteRequestRegisterL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {
+    __FLOG_VA((_L8("RouteRequestRegisterL - Entry, data provider %d "), iId));
+    iSingletons.Router().RouteRequestRegisterL(aRequest, aConnection, iId);
+    __FLOG_VA((_L8("RouteRequestRegisterL - Exit, data provider %d "), iId));
+    }
+
+void CMTPDataProvider::RouteRequestUnregisterL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {
+    __FLOG_VA((_L8("RouteRequestUnregister - Entry, data provider %d "), iId));
+    iSingletons.Router().RouteRequestUnregisterL(aRequest, aConnection);
+    __FLOG_VA((_L8("RouteRequestUnregister - Exit, data provider %d "), iId));
+    }
+
+#ifdef __FLOG_ACTIVE  	
+void CMTPDataProvider::ObjectEnumerationCompleteL(TUint32 aStorageId)
+#else
+void CMTPDataProvider::ObjectEnumerationCompleteL(TUint32 /*aStorageId*/)
+#endif // __FLOG_ACTIVE
+    {
+    __FLOG_VA((_L8("ObjectEnumerationCompleteL - Entry, data provider %d "), iId));
+    __FLOG_VA((_L8("StorageId = 0x%08X "), aStorageId));
+    iEnumerationState = ((iEnumerationState & ~EObjectsEnumerationState) | EObjectsEnumerated);
+    iSingletons.DpController().EnumerationStateChangedL(*this);
+    __FLOG_VA((_L8("ObjectEnumerationCompleteL - Exit, data provider %d "), iId));
+    }
+    
+void CMTPDataProvider::StorageEnumerationCompleteL()
+    {
+    __FLOG_VA((_L8("StorageEnumerationCompleteL - Entry, data provider %d "), iId));
+    iEnumerationState = ((iEnumerationState & ~EStoragesEnumerationState) | EStoragesEnumerated);
+    iSingletons.DpController().EnumerationStateChangedL(*this);
+    __FLOG_VA((_L8("StorageEnumerationCompleteL - Exit, data provider %d "), iId));
+    }
+
+const MMTPDataProviderConfig& CMTPDataProvider::DataProviderConfig() const
+	{
+	return *iConfig;
+	}
+	
+const MMTPFrameworkConfig& CMTPDataProvider::FrameworkConfig() const
+	{
+    return iSingletons.FrameworkConfig();
+	}
+
+MMTPObjectMgr& CMTPDataProvider::ObjectMgr() const
+    {    
+    return iSingletons.ObjectMgr();
+    }
+    
+MMTPReferenceMgr& CMTPDataProvider::ReferenceMgr() const
+    {
+    return iSingletons.ReferenceMgr();
+    }
+    
+MMTPStorageMgr& CMTPDataProvider::StorageMgr() const
+    {    
+    return iSingletons.StorageMgr();
+    } 
+    
+RFs& CMTPDataProvider::Fs() const
+    {
+    return iSingletons.Fs();
+    }
+
+MMTPDataCodeGenerator& CMTPDataProvider::DataCodeGenerator() const
+    {
+    return iSingletons.DataCodeGenerator();
+    }
+
+void CMTPDataProvider::DoCancel()
+    {
+    __FLOG_VA((_L8("DoCancel - Entry, data provider %d "), iId));
+    __FLOG_VA((_L8("DoCancel - Exit, data provider %d "), iId)); 
+	
+    if (iTimerActive)
+	    {
+	    iTimer.Cancel();
+	    iTimerActive = EFalse;
+	    }
+    else
+	    {
+    	TRequestStatus* status = &iStatus;
+	    User::RequestComplete(status, KErrCancel);
+	    }  
+    }
+    
+void CMTPDataProvider::RunL()
+    {  
+    __FLOG_VA((_L8("RunL - Entry, data provider %d "), iId));
+    __MTP_HEAP_FLOG
+    __ASSERT_DEBUG(iCurrentConnection, User::Invariant());
+     
+	
+    iTimerActive = EFalse; 
+
+	if (iProxy)
+        {
+        iCurrentTransactionPhase = iProxyTransactionPhase;
+        }
+    else
+        {
+        iCurrentTransactionPhase = iCurrentConnection->TransactionPhaseL(iCurrentRequest->Uint32(TMTPTypeRequest::ERequestSessionID));        
+        }
+    __FLOG_VA((_L8("Current transaction phase = 0x%08X"), iCurrentTransactionPhase));
+    
+    TInt status(iStatus.Int());
+    if ((status != KErrNone) &&
+    	(status != KErrAbort) &&
+    	(status != KErrCancel))
+	    {
+	    // Framework or transport error has occured, force error recovery.
+        iErrorRecovery = iStatus.Int();
+	    }
+    else if (status == KErrCancel)
+        {
+        iImplementation->Cancel();
+        }
+
+    
+    if (iErrorRecovery != KErrNone)
+        {
+        __FLOG(_L8("Error recovery in progress"));
+        switch (iCurrentTransactionPhase)
+            {
+        case ERequestPhase:
+        case EDataIToRPhase:
+        case EDataRToIPhase:
+        case EResponsePhase:
+            SendErrorResponseL(iErrorRecovery);
+            break;
+            
+        case ECompletingPhase:
+            TRAPD(err, iImplementation->ProcessRequestPhaseL(iCurrentTransactionPhase, *iCurrentRequest, *iCurrentConnection));
+            __FLOG_VA((_L8("iImplementation->ProcessRequestPhaseL error %d"), err));
+            if (err != KErrNone)
+                {
+                TransactionCompleteL(*iCurrentRequest, *iCurrentConnection);   
+                }
+            iErrorRecovery = KErrNone;
+            break;
+            
+        default:
+            break;                
+            }
+        }
+    
+		else if (iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumerated)
+    	{
+        __FLOG(_L8("DP Enumeration is not complete"));
+
+        TUint16 opCode = iCurrentRequest->Uint16(TMTPTypeRequest::ERequestOperationCode);
+
+        switch(opCode)
+        {
+        case EMTPOpCodeOpenSession:
+        case EMTPOpCodeCloseSession:
+        case EMTPOpCodeGetDeviceInfo:
+        case EMTPOpCodeGetDevicePropDesc:
+        case EMTPOpCodeGetObjectPropsSupported:
+        case EMTPOpCodeGetObjectPropDesc:
+        case EMTPOpCodeVendorExtextensionEnd:
+            iImplementation->ProcessRequestPhaseL(iCurrentTransactionPhase, *iCurrentRequest, *iCurrentConnection);
+    	break;
+
+        case EMTPOpCodeGetStorageIDs:
+        case EMTPOpCodeGetStorageInfo:
+        	if(iSingletons.DpController().EnumerateState() > CMTPDataProviderController::EEnumeratingDataProviderStorages)
+        	{
+        		iImplementation->ProcessRequestPhaseL(iCurrentTransactionPhase, *iCurrentRequest, *iCurrentConnection);
+        	}
+        	else
+        	{
+        	    //If storages are not enumerated wait for 3 secs and check it again.
+    			iTimer.After(iStatus, TTimeIntervalMicroSeconds32(KWaitForEnumeration));
+    			SetActive();
+    			iTimerActive = ETrue;
+        	}
+            break;
+        	    	
+        default:
+
+	    switch (iCurrentTransactionPhase)
+		    {
+		case ERequestPhase:
+		   	// Wait till the objects are enumerated. 
+		    // checks for every 3 secs till the objects are eumrated.
+		    // Won't send any device busy response.
+		    // Windows wont repond if it gets device busy response after it has send Openseesion.
+			iTimer.After(iStatus, TTimeIntervalMicroSeconds32(KWaitForEnumeration));
+			SetActive();
+			iTimerActive = ETrue;
+			break;		   
+	   	case ECompletingPhase:
+	   		TransactionCompleteL(*iCurrentRequest, *iCurrentConnection);   
+		   	break;
+	   	default:
+		   	break;
+		    }
+	    }
+		}
+    else
+        {
+        // Pass to the bound plugin for processing.
+        iImplementation->ProcessRequestPhaseL(iCurrentTransactionPhase, *iCurrentRequest, *iCurrentConnection);
+        
+        //Make ActiveRequest processor and CancelRequest processing to occur synchronously
+        if( iCurrentTransactionPhase == ERequestPhase )
+        	{
+        	CMTPSession& session(static_cast<CMTPSession&>(iCurrentConnection->SessionWithMTPIdL(iCurrentRequest->Uint32(TMTPTypeRequest::ERequestSessionID))));
+        	MMTPConnectionProtocol& connection(static_cast<MMTPConnectionProtocol&>(*iCurrentConnection)); 
+        	
+        	// Pass transaction to session to check against any pending events
+           	if ( session.CheckPendingEvent(*iCurrentRequest) )
+            	{
+                //Current request matches a pending event, pass event to connection layer event processing
+                connection.ReceivedEventL(session.PendingEvent());
+                }
+        	}
+        
+        }
+    
+    __MTP_HEAP_FLOG
+    __FLOG_VA((_L8("RunL - Exit, data provider %d "), iId));
+    }
+     
+TInt CMTPDataProvider::RunError(TInt aError)
+	{
+    __FLOG_VA((_L8("RunError - Entry, data provider %d "), iId));
+    __FLOG_VA((_L8("Error = %d"), aError));
+    
+    /* 
+    CMTPDataProvider or iImplementation error, save the error state and 
+    re-schedule.
+    */
+    iErrorRecovery = aError;
+    Schedule();
+    
+    __FLOG_VA((_L8("RunError - Exit, data provider %d "), iId));
+	return KErrNone;
+	}
+
+/**
+Constructor.
+@param aId The data provider identifier.
+@param aUid The data provider implementation UID.
+@param aConfig The data provider configurability parameter data. Ownership IS 
+transfered.
+*/
+CMTPDataProvider::CMTPDataProvider(TUint aId, TUid aUid, CMTPDataProviderConfig* aConfig) : 
+	CActive(EPriorityStandard),
+	iConfig(aConfig),
+	iId(aId),
+	iImplementationUid(aUid),
+	iProxyTransactionPhase(ERequestPhase)
+    {
+    CActiveScheduler::Add(this);
+    }
+        
+/**
+Second phase constructor.
+@leave One of the system wide error codes if a processing failure occurs.
+*/
+void CMTPDataProvider::ConstructL()
+	{
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG_VA((_L8("ConstructL - Entry, data provider %d "), iId));
+    
+    iSingletons.OpenL();
+    TUint tDPType = iConfig->UintValue(MMTPDataProviderConfig::EDataProviderType);   
+    const TUint KExcludeCategoryStart = EVendorExtensionSets;
+    const TUint KExcludeCategoryEnd = EFormatExtensionSets;
+    if( tDPType == KMTPDummyDataProvider)
+    	{
+		iImplementation = static_cast<CMTPDataProviderPlugin*>(CDummyDp::NewL(static_cast<MMTPDataProviderFramework*>(this)));
+		//create your dummy classCMTPDataProviderPlugin
+		for (TUint i(EAssociationTypes); (i < ENumCategories); i++)
+            {
+            CSupportedCodes* codes = CSupportedCodes::NewLC(static_cast<TMTPSupportCategory>(i), Plugin());
+            
+            if((i >= KExcludeCategoryStart) && (i <= KExcludeCategoryEnd) && (codes->Codes().Count() >0))
+            	{
+            	User::Leave(KErrNotSupported);
+            	}
+            
+            iSupported.AppendL(codes);
+            CleanupStack::Pop(codes);
+            }
+		iConstructed = ETrue;	
+		}
+	else   
+    	{
+    	iImplementation = CMTPDataProviderPlugin::NewL(iImplementationUid, static_cast<MMTPDataProviderFramework*>(this));
+	
+    	for (TUint i(EAssociationTypes); (i < ENumCategories); i++)
+        	{
+        	CSupportedCodes* codes = CSupportedCodes::NewLC(static_cast<TMTPSupportCategory>(i), Plugin());
+        	
+        	if((i >= KExcludeCategoryStart) && (i <= KExcludeCategoryEnd) && (codes->Codes().Count() >0))
+            	{
+            	User::Leave(KErrNotSupported);
+            	}
+        	iSupported.AppendL(codes);
+        	CleanupStack::Pop(codes);
+        	}
+				
+    	User::LeaveIfError(iTimer.CreateLocal());
+
+		// Only assume ownership of passed objects on successful construction.
+		iConstructed = ETrue;
+	
+		__FLOG_VA((_L8("Data provider %d iImplementationUid 0x08%X "), iId, iImplementationUid));
+    	__FLOG_VA((_L8("ConstructL - Exit, data provider %d "), iId));	
+    	}
+	 
+	}
+
+/**
+Schedules the next request phase or event.
+*/
+void CMTPDataProvider::Schedule()
+    {
+    __FLOG_VA((_L8("Schedule - Entry, data provider %d "), iId));
+    iStatus = KRequestPending;
+    TRequestStatus* status = &iStatus;
+    SetActive();
+    User::RequestComplete(status, KErrNone);
+    __FLOG_VA((_L8("Schedule - Exit, data provider %d "), iId));
+    }
+
+/**
+Formats and sends an MTP response dataset from the specified error code.
+@param aError The error code.
+@leave One of the system wide error codes, if a processing error occurs.
+*/
+void CMTPDataProvider::SendErrorResponseL(TInt aError)
+	{
+    __FLOG_VA((_L8("SendResponseL - Entry, data provider %d "), iId));
+	__ASSERT_DEBUG(iCurrentRequest != NULL, User::Invariant());
+	
+	TMTPResponseCode code;
+	switch (aError)
+	    {
+    case KErrOverflow:
+    case KMTPDataTypeInvalid:
+        code = EMTPRespCodeInvalidDataset;
+        break;
+        
+    default:
+        code = EMTPRespCodeGeneralError;
+        break;
+	    }
+	    
+    __FLOG_VA((_L8("Sending response code  0x%04X"), code));
+	iResponse.SetUint16(TMTPTypeResponse::EResponseCode, code);		    
+    iResponse.SetUint32(TMTPTypeResponse::EResponseSessionID, iCurrentRequest->Uint32(TMTPTypeResponse::EResponseSessionID));	
+	iResponse.SetUint32(TMTPTypeResponse::EResponseTransactionID, iCurrentRequest->Uint32(TMTPTypeResponse::EResponseTransactionID));
+	SendResponseL(iResponse, *iCurrentRequest, *iCurrentConnection);
+	
+    __FLOG_VA((_L8("SendResponseL - Exit, data provider %d "), iId));	
+	}
+    
+CMTPDataProvider::CSupportedCodes* CMTPDataProvider::CSupportedCodes::NewLC(TMTPSupportCategory aCategory, MMTPDataProvider& aDp)
+    {
+    CSupportedCodes* self = new(ELeave) CSupportedCodes();
+    CleanupStack::PushL(self);
+    self->ConstructL(aCategory, aDp);
+    return self;
+    }
+    
+CMTPDataProvider::CSupportedCodes::~CSupportedCodes()
+    {
+    iCodes.Close();
+    }
+    
+const RArray<TUint>& CMTPDataProvider::CSupportedCodes::Codes() const
+    {
+    return iCodes;
+    }
+    
+TBool CMTPDataProvider::CSupportedCodes::Supported(TUint aCode) const
+    {
+    return (iCodes.FindInOrder(aCode) != KErrNotFound);
+    }
+    
+CMTPDataProvider::CSupportedCodes::CSupportedCodes() :
+    iCodes()
+    {
+    
+    }
+    
+void CMTPDataProvider::CSupportedCodes::ConstructL(TMTPSupportCategory aCategory, MMTPDataProvider& aDp)
+    {
+    aDp.Supported(aCategory, iCodes);
+    iCodes.Sort();
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpdataproviderconfig.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,208 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <barsread.h>
+#include "cmtpdataproviderconfig.h"
+
+/**
+CMTPDataProviderConfig factory method.
+@param aReader The data provider configuration resource file reader.
+@param aFileName The data provider configuration resource file name.
+@return A pointer to a new CMTPDataProviderConfig instance. Ownership IS 
+transfered.
+@leave One of the system wide error codes if a processing failure occurs.
+*/
+CMTPDataProviderConfig* CMTPDataProviderConfig::NewL(TResourceReader& aReader, const TDesC& aFileName)
+    {
+    CMTPDataProviderConfig* self = new (ELeave) CMTPDataProviderConfig();
+    CleanupStack::PushL(self);
+    self->ConstructL(aReader, aFileName);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor.
+*/
+CMTPDataProviderConfig::~CMTPDataProviderConfig()
+    {
+    delete iServerName;
+    delete iServerImageName;
+    delete iResourceFileName;
+    }
+
+/**
+Indicates if the data provider supporte the specified operational mode.
+@param aMode The operational mode.
+@return ETrue if the mode is supported, otherwise EFalse.
+*/
+TBool CMTPDataProviderConfig::ModeSupported(TMTPOperationalMode aMode) const
+    {
+    return (iSupportedModes & aMode);
+    }
+    
+TUint CMTPDataProviderConfig::UintValue(MMTPDataProviderConfig::TParameter aParam) const
+    {
+    TUint value(0);
+    switch (aParam)
+        {
+    case EDataProviderType:
+        value = iType;
+        break;
+
+    case EMajorProtocolRevision:
+        value = iVersion;
+        break;
+
+    case EOpaqueResource:
+        value = iOpaqueResource;
+        break;
+
+    case EEnumerationPhase:
+        value = iEnumerationPhase;
+        break;
+
+    default:
+        User::Invariant();
+        break;
+        }
+    return value;
+    }
+    
+TBool CMTPDataProviderConfig::BoolValue(MMTPDataProviderConfig::TParameter aParam) const
+    {
+    TBool value(EFalse);
+    switch (aParam)
+        {
+    case EObjectEnumerationPersistent:
+        value = iObjectEnumerationPersistent;
+        break;
+
+    default:
+        User::Invariant();
+        }
+    return value;
+    }
+    
+const TDesC& CMTPDataProviderConfig::DesCValue(MMTPDataProviderConfig::TParameter aParam) const
+    {
+    const TDesC* value(&KNullDesC);
+    switch (aParam)
+        {
+    case EServerName:
+        value = iServerName;
+        break;
+
+    case EServerImageName:
+        value = iServerImageName;
+        break;
+
+    case EResourceFileName:
+        value = iResourceFileName;
+        break;
+
+    default:
+        User::Invariant();
+        break;
+        }
+    return *value;
+    }
+    
+const TDesC8& CMTPDataProviderConfig::DesC8Value(MMTPDataProviderConfig::TParameter /*aParam*/) const
+    {
+    User::Invariant();
+    return KNullDesC8;
+    }
+    
+void CMTPDataProviderConfig::GetArrayValue(MMTPDataProviderConfig::TParameter aParam, RArray<TUint>& aArray) const
+    {
+    switch (aParam)
+        {
+    case ESupportedModes:
+        {
+        if (iSupportedModes & EModePTP)
+            {
+            aArray.Append(EModePTP);
+            }
+        if (iSupportedModes & EModeMTP)
+            {
+            aArray.Append(EModeMTP);
+            }
+        if (iSupportedModes & EModePictBridge)
+            {
+            aArray.Append(EModePictBridge);
+            }
+
+        break;
+        }
+
+    default:
+        User::Invariant();
+        break;
+        }
+    }
+
+/**
+Constructor
+*/
+CMTPDataProviderConfig::CMTPDataProviderConfig()
+    {
+
+    }
+
+/**
+Second phase construction. Reads the data from the reader and configures the instance.
+See mtpdpinfo.rh for the definition of the MTP_DATA_PROVIDER resource structure.
+@param aReader    Resource reader opened on the corresponding RSC file.
+*/
+void CMTPDataProviderConfig::ConstructL(TResourceReader& aReader, const TDesC& aFileName)
+    {
+    iResourceFileName = aFileName.AllocL();
+    
+    // WORD type
+    iType = static_cast<TMTPDataProviderTypes>(aReader.ReadUint16());
+    if(KMTPDataProviderTypeECOM != iType)
+        {
+        User::Leave(KErrCorrupt);
+        }
+
+    // BYTE major_version
+    iVersion = aReader.ReadInt8();
+
+    // BYTE object_enumeration_persistent
+    iObjectEnumerationPersistent = (aReader.ReadInt8() != 0);
+
+    // WORD supported_modes
+    iSupportedModes = aReader.ReadUint16();
+
+    // LTEXT server_name
+    iServerName = aReader.ReadHBufCL();
+
+    // LTEXT server_image_name
+    iServerImageName = aReader.ReadHBufCL();
+
+    // LLINK opaque_resource
+    iOpaqueResource = aReader.ReadUint32();
+
+    // BYTE enumeration_phase
+    iEnumerationPhase = aReader.ReadUint8();
+    if (iEnumerationPhase == 0)
+      {
+      // The default value 0 is treated as 255
+      iEnumerationPhase = 255;
+      }
+    
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpdataprovidercontroller.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1150 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <barsc.h> 
+#include <barsread.h> 
+#include <e32property.h>
+#include <mtp/cmtpdataproviderplugin.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/rmtpclient.h>
+
+#include "cmtpdataprovider.h"
+#include "cmtpdataproviderconfig.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpobjectmgr.h"
+#include "mtpframeworkconst.h"
+#include "cmtpframeworkconfig.h"
+#include "cmtpstoragemgr.h"
+
+
+// Class constants.
+_LIT(KMTPDpResourceDirectory, "z:\\resource\\mtp\\");
+_LIT(KMTPDpDummyResourcefile, "z:\\resource\\mtp\\dummydp.rsc");
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"DataProviderController");)
+
+static const TUint KOpaqueDataLength(64);
+
+/**
+CMTPDataProviderController panics
+*/
+_LIT(KMTPPanicCategory, "CMTPDataProviderController");
+enum TMTPPanicReasons
+    {
+    EMTPPanicStorageEnumeration = 0,
+    EMTPPanicFrameworkEnumeration = 1,
+    EMTPPanicDataProviderStorageEnumeration = 2,
+    EMTPPanicDataProviderEnumeration = 3
+    };
+    
+LOCAL_C void Panic(TInt aReason)
+    {
+    User::Panic(KMTPPanicCategory, aReason);
+    }
+
+/**
+CMTPDataProviderController factory method. 
+@return A pointer to a new CMTPDataProviderController instance. Ownership IS 
+transfered.
+@leave One of the system wide error codes if a processing failure occurs.
+*/
+CMTPDataProviderController* CMTPDataProviderController::NewL()
+    {
+    CMTPDataProviderController* self = new (ELeave) CMTPDataProviderController();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor.
+*/
+CMTPDataProviderController::~CMTPDataProviderController()
+    {
+    __FLOG(_L8("~CMTPDataProviderController - Entry"));
+    Cancel();
+    UnloadDataProviders();
+    iDataProviderIds.Close();
+    iEnumeratingDps.Close();
+    iEnumeratingStorages.Close();
+    iSingletons.Close();
+    CloseRegistrySessionAndEntryL();
+    delete iOpenSessionWaiter;
+    __FLOG(_L8("~CMTPDataProviderController - Exit"));
+    __FLOG_CLOSE;
+    }
+    
+/**
+Loads the set of available data providers and initiates the data provider
+enumeration sequence.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C void CMTPDataProviderController::LoadDataProvidersL()
+    {
+    __FLOG(_L8("LoadDataProvidersL - Entry"));
+    // Retrieve the ECOM data provider implementations list
+    RImplInfoPtrArray   implementations;
+    TCleanupItem        cleanup(ImplementationsCleanup, reinterpret_cast<TAny*>(&implementations));
+    CleanupStack::PushL(cleanup);
+    REComSession::ListImplementationsL(KMTPDataProviderPluginInterfaceUid, implementations);
+    implementations.Sort(TLinearOrder<CImplementationInformation>(ImplementationsLinearOrderUid));
+    
+    // Retrieve the data provider registration resource file list.
+    CDir* registrations;
+    User::LeaveIfError(iSingletons.Fs().GetDir(KMTPDpResourceDirectory, KEntryAttNormal, ESortByName, registrations));
+    CleanupStack::PushL(registrations);
+
+    // Load the registered data providers. 
+    const TUint KCount(registrations->Count());
+    TInt index = 0; 
+    for (TInt i = 0; i < KCount; ++i)
+        {
+        TUint uid = 0;
+        if(Uid((*registrations)[i].iName, uid) != KErrNone)
+        	{
+        	__FLOG_1(_L8("LoadDataProvidersL - Fail to get UID = %s"),&((*registrations)[i].iName) );
+        	continue;
+        	}
+        index = implementations.FindInOrder(TUid::Uid(uid), ImplementationsLinearOrderUid);
+        if (KErrNotFound == index)
+        	{
+        	continue;
+        	}
+		if( uid != KMTPImplementationUidDeviceDp && uid != KMTPImplementationUidProxyDp && uid != KMTPImplementationUidFileDp )
+			{
+	        //get the dpid for the uid from dpidstore table
+	        TBool tFlag;
+		    iNextDpId = iSingletons.ObjectMgr().DPIDL(uid, tFlag);
+		    if(tFlag == EFalse)
+		    	{
+		    	iSingletons.ObjectMgr().InsertDPIDObjectL(iNextDpId,uid);
+		    	}	       	
+			}
+		else
+			{
+			switch (uid)
+				{
+				case KMTPImplementationUidDeviceDp : 
+					iNextDpId = KMTPDeviceDPID;
+					break;
+
+				case KMTPImplementationUidFileDp   : 
+					iNextDpId = KMTPFileDPID;
+					break;
+
+				case KMTPImplementationUidProxyDp  : 
+					iNextDpId = KMTPProxyDPID;
+					break;				
+				}
+			}
+		LoadROMDataProvidersL((*registrations)[i].iName, implementations);
+		delete implementations[index];
+		implementations.Remove(index);
+        }
+
+    //Load installed DPs on non-ROM drives.
+    for (index = 0; index < implementations.Count(); ++index)
+        {
+        TRAPD(err, LoadInstalledDataProvidersL(implementations[index]));
+        if (KErrNone != err)
+            {
+            __FLOG_VA((_L8("Load installed data provider[0x%x] failed."),implementations[index]->ImplementationUid().iUid));
+            }
+        }
+
+    CleanupStack::PopAndDestroy(registrations);
+    CleanupStack::PopAndDestroy(&implementations);    
+
+    // Verify that the framework data providers are loaded.
+    User::LeaveIfError(DpId(KMTPImplementationUidDeviceDp));
+    User::LeaveIfError(DpId(KMTPImplementationUidProxyDp));
+    User::LeaveIfError(DpId(KMTPImplementationUidFileDp));
+
+	// Sort the data provider set on enumeration phase order.
+	iDataProviders.Sort(TLinearOrder<CMTPDataProvider>(CMTPDataProvider::LinearOrderEnumerationPhase));
+	// Add the DP IDs into DP ID array, except for device DP, File DP and proxy DP
+	for (TUint index=0; index < iDataProviders.Count(); index++)
+	  {
+	  if ((iDataProviders[index]->DataProviderId() != iDpIdDeviceDp)
+	  	  && (iDataProviders[index]->DataProviderId() != iDpIdFileDp)
+	  	  && (iDataProviders[index]->DataProviderId() != iDpIdProxyDp))
+	    {
+	    iDataProviderIds.Append(iDataProviders[index]->DataProviderId());
+	    }
+	  }
+	
+    // Ensure that the data provider set is ordered on DataProvider Id.
+    iDataProviders.Sort(TLinearOrder<CMTPDataProvider>(CMTPDataProvider::LinearOrderDPId));
+    
+    // Start enumerating.
+    iEnumeratingStorages.AppendL(KMTPStorageAll);
+    iEnumerationState = EEnumerationStarting;
+    Schedule();
+    __FLOG(_L8("LoadDataProvidersL - Exit"));
+    }
+    
+/**
+Unloads all active data providers.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C void CMTPDataProviderController::UnloadDataProviders()
+    {
+    __FLOG(_L8("UnloadDataProviders - Entry"));
+    TRAP_IGNORE(iSingletons.ObjectMgr().ObjectStore().CleanL());
+    iDataProviders.ResetAndDestroy();
+    iDataProviderIds.Reset();
+    __FLOG(_L8("UnloadDataProviders - Exit"));
+    }
+    
+/**
+Issues the specified notification to all loaded data providers.
+@param aNotification The notification type identifier.
+@param aParams The notification type specific parameter block
+@leave One of the system wide error code if a processing failure occurs
+in the data provider.
+*/
+EXPORT_C void CMTPDataProviderController::NotifyDataProvidersL(TMTPNotification aNotification, const TAny* aParams)
+    {
+    NotifyDataProvidersL(KMTPDataProviderAll, aNotification, aParams);
+    }
+
+EXPORT_C void CMTPDataProviderController::NotifyDataProvidersL(TUint aDPId, TMTPNotification aNotification, const TAny* aParams)
+    {
+    __FLOG(_L8("NotifyDataProvidersL - Entry"));
+    // Schedule any long running operations.
+    switch (aNotification)
+        {
+    case EMTPStorageAdded:
+        {
+        // Queue a storage enumeration operation.
+        __ASSERT_DEBUG(aParams, User::Invariant());
+        const TMTPNotificationParamsStorageChange* params(static_cast<const TMTPNotificationParamsStorageChange*>(aParams));
+        iEnumeratingStorages.AppendL(params->iStorageId);
+        
+        // Only schedule the operation start if there is not one currently underway.
+        if (iEnumerationState == EEnumerated)
+            {
+            iNextDpId           = iDpIdDeviceDp;
+            iEnumerationState   = EEnumeratingFrameworkObjects;
+            Schedule();
+            }
+        }
+        break;
+	case EMTPStorageRemoved:
+		{
+		// Dequeue an unhandled storage enumeration operations if existed.
+        // If not existed, just ignore the remove event, since the logical storageId already removed from StorageMgr
+        // by the caller, i.e. CMTPStorageWatcher. 
+        __ASSERT_DEBUG(aParams, User::Invariant());
+        const TMTPNotificationParamsStorageChange* params(static_cast<const TMTPNotificationParamsStorageChange*>(aParams));
+        //Start checking from the second event, since iEnumeratingStorages[0] is the event being handled by DPs.
+        TUint32 storageId = params->iStorageId;
+        for(TInt i=1; i<iEnumeratingStorages.Count(); i++)
+            {
+            if(storageId==iEnumeratingStorages[i])
+                {
+                iEnumeratingStorages.Remove(i);
+                __FLOG_VA((_L8("Unhandle memory card add event removed, storageId: %d"), storageId));
+                }
+            }
+        }
+        break;
+    case EMTPObjectAdded:
+        break;
+    default:
+        break;        
+        }
+        
+    // Issue the notification.    
+    const TUint KLoadedDps(iDataProviders.Count());
+    if(aDPId == KMTPDataProviderAll)
+        {
+        for (TUint i(0); i < KLoadedDps; ++i)
+            {
+            CMTPDataProvider *dp = iDataProviders[i];
+            if ((dp->DataProviderId() != iDpIdDeviceDp) &&
+                (dp->DataProviderId() != iDpIdProxyDp))
+                {
+                dp->Plugin().ProcessNotificationL(aNotification, aParams);
+                }
+            }
+        }
+    else
+        {
+        for (TUint i(0); i < KLoadedDps; ++i)
+            {
+            CMTPDataProvider *dp = iDataProviders[i];
+            if ( dp->DataProviderId() == aDPId )
+                {
+                dp->Plugin().ProcessNotificationL(aNotification, aParams);
+                break;
+                }
+            }
+        }    
+    __FLOG(_L8("NotifyDataProvidersL - Exit"));
+    }
+
+/**
+Provides the number of active data providers.
+@return the number of active data providers.
+*/
+EXPORT_C TUint CMTPDataProviderController::Count()
+    {
+    return iDataProviders.Count();
+    }
+
+/**
+Provides a reference to the data provider with the specified identifier.
+@param aId The data provider identifier.
+@return The data provider reference.
+*/
+EXPORT_C CMTPDataProvider& CMTPDataProviderController::DataProviderL(TUint aId)
+    {
+    return DataProviderByIndexL(iDataProviders.FindInOrder(aId, CMTPDataProvider::LinearOrderDPId));
+    }  
+
+/**
+Provides a reference to the data provider with the specified index.
+@param aIndex The data provider index.
+@return The data provider reference.
+*/
+EXPORT_C CMTPDataProvider& CMTPDataProviderController::DataProviderByIndexL(TUint aIndex)
+    {
+    __ASSERT_DEBUG((aIndex < iDataProviders.Count()), User::Invariant());
+    return *(iDataProviders[aIndex]);
+    }  
+
+/**
+ * Determine whether a data provider with the specified data provider id has been loaded
+ * @param aId the id of the data provider to be checked
+ * @return true if the data provider has been loaded, otherwise false
+ */
+EXPORT_C TBool CMTPDataProviderController::IsDataProviderLoaded(TUint aId) const
+	{
+	TInt index = iDataProviders.FindInOrder(aId, CMTPDataProvider::LinearOrderDPId);
+	if (index >= 0 && index < iDataProviders.Count())
+		{
+		return ETrue;
+		}
+	else
+		{
+		return EFalse;
+		}
+	}
+
+/**
+Provides the identifier of the device data provider.
+@return TInt The device data provider identifier.
+*/
+EXPORT_C TInt CMTPDataProviderController::DeviceDpId()
+    {
+    return iDpIdDeviceDp;
+    }
+    
+/**
+Provides the identifier of the data provider with the specified implementation 
+UID.
+@param aUid The implementation UID.
+@return TInt The proxy data provider identifier.
+*/  
+EXPORT_C TInt CMTPDataProviderController::DpId(TUint aUid)
+    {
+    return iDataProviders.FindInOrder(TUid::Uid(aUid), CMTPDataProvider::LinearOrderUid);
+    }
+
+/**
+Provides the identifier of the proxy data provider.
+@return TInt The proxy data provider identifier.
+*/  
+EXPORT_C TInt CMTPDataProviderController::ProxyDpId()
+    {
+    return iDpIdProxyDp;
+    }
+
+EXPORT_C TInt CMTPDataProviderController::FileDpId()
+    {
+    return iDpIdFileDp;
+    }
+
+/**
+Wait for the enumeration complete.
+*/ 
+EXPORT_C void CMTPDataProviderController::WaitForEnumerationComplete()
+{
+	if(EnumerateState() != CMTPDataProviderController::EEnumerated)
+		{
+		iOpenSessionWaiter->Start();
+		}
+}
+TBool CMTPDataProviderController::FreeEnumerationWaiter()
+	{
+	if(iOpenSessionWaiter->IsStarted())
+		{
+		iOpenSessionWaiter->AsyncStop();
+		return ETrue;
+		}
+	return EFalse;
+	}
+/**
+Data provider enumeration state change notification callback.
+@param aDp The notifying data provider.
+*/    
+void CMTPDataProviderController::EnumerationStateChangedL(const CMTPDataProvider& aDp)
+    {
+    __FLOG(_L8("EnumerationStateChangedL - Entry"));
+    switch (iEnumerationState)
+        {        
+    case EEnumeratingFrameworkStorages:
+    	switch (aDp.ImplementationUid().iUid)
+            {
+        case KMTPImplementationUidDeviceDp:
+            iNextDpId = iDpIdProxyDp;
+            break;
+
+            
+        case KMTPImplementationUidProxyDp:
+            iNextDpId = iDpIdFileDp;
+            break;
+            
+        case KMTPImplementationUidFileDp:
+            iEnumerationState   = EEnumeratingDataProviderStorages;
+            iDpIdArrayIndex     = 0;
+            break;
+            }
+        Schedule();
+        break;    
+        
+    case EEnumeratingDataProviderStorages:
+        // Data provider storage enumerations execute sequentially.
+        if (++iDpIdArrayIndex >= iDataProviderIds.Count())
+            {
+            iNextDpId           = iDpIdDeviceDp;
+            iEnumerationState   = EEnumeratingFrameworkObjects;
+            }
+        Schedule();
+        break;
+          
+    case EEnumeratingFrameworkObjects:
+        switch (aDp.ImplementationUid().iUid)
+            {
+        case KMTPImplementationUidDeviceDp:
+            iSingletons.ObjectMgr().RemoveNonPersistentObjectsL(aDp.DataProviderId());
+            iNextDpId = iDpIdProxyDp;
+            Schedule();
+            break;
+            
+        case KMTPImplementationUidProxyDp:
+            //iNextDpId = iDpIdFileDp;
+            if ( iDataProviderIds.Count()>0 )
+                {
+                iEnumerationState   = EEnumeratingDataProviderObjects;
+                iEnumerationPhase   = DataProviderL(iDataProviderIds[0]).DataProviderConfig().UintValue(MMTPDataProviderConfig::EEnumerationPhase);
+                iDpIdArrayIndex     = 0;                
+                }
+            else
+                {
+                iNextDpId = iDpIdFileDp;
+                }
+            Schedule();
+            break;
+            
+        case KMTPImplementationUidFileDp:
+            iSingletons.ObjectMgr().RemoveNonPersistentObjectsL(aDp.DataProviderId());
+            // No other data providers
+            iNextDpId = 0;
+            iEnumeratingStorages.Remove(0);
+            if (iEnumeratingStorages.Count() == 0)
+                {
+                // No queued enumerations.
+                iSingletons.ObjectMgr().ObjectStore().CleanDBSnapshotL();
+                iEnumerationState   = EEnumerated;
+                Cancel();
+                if(iOpenSessionWaiter->IsStarted())
+                    {
+                    iOpenSessionWaiter->AsyncStop();
+                    }
+                }
+            else
+                {
+                // Queued enumerations.
+                iNextDpId           = iDpIdDeviceDp;
+                Schedule();
+                }
+            }
+        break;
+        
+    case EEnumeratingDataProviderObjects:
+        // Enumerate non-framework data providers concurrently.
+        iEnumeratingDps.Remove(iEnumeratingDps.FindInOrderL(aDp.DataProviderId()));
+        // Remove any non-persistent objects that are still marked.
+        iSingletons.ObjectMgr().RemoveNonPersistentObjectsL(aDp.DataProviderId());
+
+        if ((iEnumeratingDps.Count() == 0) && iDpIdArrayIndex >= iDataProviderIds.Count())
+            {
+            // Enumeration complete.
+            iNextDpId = 0;
+            iNextDpId           = iDpIdFileDp;
+            iEnumerationState   = EEnumeratingFrameworkObjects;
+            }
+        else
+            {
+            if ((iEnumeratingDps.Count() == 0) && (iEnumerationPhase != DataProviderL(iDataProviderIds[iDpIdArrayIndex]).DataProviderConfig().UintValue(MMTPDataProviderConfig::EEnumerationPhase)))
+                {
+                // Enter next enumeration phase
+                iEnumerationPhase = DataProviderL(iDataProviderIds[iDpIdArrayIndex]).DataProviderConfig().UintValue(MMTPDataProviderConfig::EEnumerationPhase);
+                }
+            }
+        Schedule();        
+        break;
+        
+    case EUnenumerated:
+    case EEnumerationStarting:
+    case EEnumerated:
+    default:
+        __DEBUG_ONLY(User::Invariant());
+        break;
+        }
+    __FLOG(_L8("EnumerationStateChangedL - Exit"));
+    }
+
+void CMTPDataProviderController::DoCancel()
+    {
+    __FLOG(_L8("DoCancel - Entry"));
+    __FLOG(_L8("DoCancel - Exit"));
+    }
+    
+void CMTPDataProviderController::RunL()
+    {
+    __FLOG(_L8("RunL - Entry"));
+    __FLOG_VA((_L8("iEnumerationState: 0x%x iNextDpId: %d"), iEnumerationState, iNextDpId));
+    switch (iEnumerationState)
+        {
+    case EEnumerationStarting:
+        iEnumerationState   = EEnumeratingFrameworkStorages;
+        iNextDpId           = iDpIdDeviceDp;
+        // Fall through to issue the StartStorageEnumerationL signal.
+        
+    case EEnumeratingFrameworkStorages:
+        // Enumerate storages sequentially.
+    	DataProviderL(iNextDpId).EnumerateStoragesL();
+        break;
+        
+    case EEnumeratingDataProviderStorages:
+        // Enumerate storages sequentially.
+            
+        // In case there was no DPs other than devdp and proxydp.
+        if (iDpIdArrayIndex < iDataProviderIds.Count())
+            {
+            DataProviderL(iDataProviderIds[iDpIdArrayIndex]).EnumerateStoragesL();
+            }
+        else
+            {
+            iNextDpId           = iDpIdDeviceDp;
+            iEnumerationState   = EEnumeratingFrameworkObjects;
+	
+            
+        
+            Schedule();
+            }
+        break;
+        
+    case EEnumeratingFrameworkObjects:
+        {
+        TUint32 storageId = iEnumeratingStorages[0];
+        if( ( KMTPStorageAll != storageId ) && (!iSingletons.StorageMgr().ValidStorageId(storageId)))
+            {
+            iNextDpId = 0;
+            //Specified storage not existed, not necessary to start enumeration on this stroage.
+            //Do this check will save enumeration time, i.e. avoid unnecessary enumeration, since memory card removed before enumeration starts.
+            iEnumeratingStorages.Remove(0);
+            if (iEnumeratingStorages.Count() == 0)
+                {
+                iEnumerationState = EEnumerated;
+                }
+            else
+                {
+                //deal next storage
+                iNextDpId = iDpIdDeviceDp;
+                Schedule();
+                }
+            }
+        else
+        	{
+            // Enumerate framework data providers sequentially.
+            if(iNextDpId == iDpIdDeviceDp)
+                {
+                if(KMTPStorageAll == storageId)
+                    {
+                    iSingletons.ObjectMgr().ObjectStore().EstablishDBSnapshotL(storageId);
+                    }
+                else
+                    {
+                    const CMTPStorageMetaData& storage(iSingletons.StorageMgr().StorageL(storageId));
+                    if(storage.Uint(CMTPStorageMetaData::EStorageSystemType) == CMTPStorageMetaData::ESystemTypeDefaultFileSystem)
+                        {
+                        const RArray<TUint>& logicalIds(storage.UintArray(CMTPStorageMetaData::EStorageLogicalIds));
+                        const TUint KCountLogicalIds(logicalIds.Count());
+                        for (TUint i(0); (i < KCountLogicalIds); i++)
+                            {
+                            __FLOG_VA((_L8("Establish snapshot for storage: 0x%x"), storageId));
+                            iSingletons.ObjectMgr().ObjectStore().EstablishDBSnapshotL(storageId);
+                            }
+                        }
+                    }
+                }
+            EnumerateDataProviderObjectsL(iNextDpId);          
+            }
+        	}
+        break;
+        
+    case EEnumeratingDataProviderObjects:
+        {
+        TUint currentDp = 0;
+        
+        // Enumerate non-framework data providers concurrently.
+        const TUint KLoadedDps(iDataProviderIds.Count());
+        while ((iEnumeratingDps.Count() < KMTPMaxEnumeratingDataProviders) && (iDpIdArrayIndex < KLoadedDps)
+               && (iEnumerationPhase == DataProviderL(iDataProviderIds[iDpIdArrayIndex]).DataProviderConfig().UintValue(MMTPDataProviderConfig::EEnumerationPhase)))
+            {
+            currentDp = iDataProviderIds[iDpIdArrayIndex++];
+            iEnumeratingDps.InsertInOrderL(currentDp);
+            EnumerateDataProviderObjectsL(currentDp);
+            }
+        }
+        break;
+        
+    case EUnenumerated:
+    case EEnumerated:
+    default:
+        __DEBUG_ONLY(User::Invariant());
+        break;
+        }
+    __FLOG(_L8("RunL - Exit"));
+    }
+
+#ifdef __FLOG_ACTIVE
+TInt CMTPDataProviderController::RunError(TInt aError)
+#else
+TInt CMTPDataProviderController::RunError(TInt /*aError*/)
+#endif
+    {
+    __FLOG(_L8("RunError - Entry"));
+    __FLOG_VA((_L8("Error = %d"), aError));
+    
+    // If a RunL error happens, there's no point in trying to continue.
+    switch (iEnumerationState)
+        {
+    case EEnumerationStarting:
+    case EEnumeratingFrameworkStorages:
+        Panic(EMTPPanicStorageEnumeration);
+        break;
+        
+    case EEnumeratingFrameworkObjects:
+        Panic(EMTPPanicFrameworkEnumeration);
+        break;
+        
+    case EEnumeratingDataProviderStorages:
+        Panic(EMTPPanicDataProviderStorageEnumeration);
+        break;
+        
+    case EEnumeratingDataProviderObjects:
+        Panic(EMTPPanicDataProviderEnumeration);
+        break;
+        
+    case EUnenumerated:
+    case EEnumerated:
+    default:
+        User::Invariant();
+        break;
+        }
+
+    // This code is never reached
+    __FLOG(_L8("RunError - Exit"));
+    return KErrNone;
+    }
+
+/**
+Constructor.
+*/
+CMTPDataProviderController::CMTPDataProviderController() :
+    CActive(EPriorityNormal)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+/**
+Second-phase constructor.
+@leave One of the system wide error codes if a processing failure occurs.
+*/
+void CMTPDataProviderController::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry"));
+    iSingletons.OpenL();
+	TInt tMTPMode;
+	TInt err = RProperty::Get(KUidSystemCategory, KUidMTPModeKeyValue, tMTPMode);
+	if(err != KErrNone)
+		{
+		tMTPMode = KMTPModeMTP;		
+		}
+	else
+		{
+		if(tMTPMode != KMTPModeMTP && tMTPMode != KMTPModePTP && tMTPMode != KMTPModePictBridge)
+		tMTPMode = KMTPModeMTP;
+		}
+	iMode = (TMTPOperationalMode)tMTPMode;
+	CreateRegistrySessionAndEntryL();
+    
+	iFlagDb = 0;
+	
+    iOpenSessionWaiter = new(ELeave) CActiveSchedulerWait();
+    __FLOG(_L8("ConstructL - Exit"));
+    }
+    
+/**
+Creates a data provider configurability parameter data instance on the cleanup 
+stack.
+@param aResourceFilename The data provider configuration data resource filename.
+@return A pointer to the data provider configurability parameter data instance, 
+which is also placed on the cleanup stack. Ownership is transferred.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/    
+CMTPDataProviderConfig* CMTPDataProviderController::CreateConfigLC(const TDesC& aResourceFilename)
+    {
+    __FLOG(_L8("CreateConfigLC - Entry"));
+    // Open the configuration data resource file
+    RResourceFile file;
+    CleanupClosePushL(file);
+    file.OpenL(iSingletons.Fs(), aResourceFilename);    
+    
+    // Create the resource reader.
+    const TInt KDefaultResourceId(1);
+    HBufC8* buffer(file.AllocReadLC(KDefaultResourceId));
+    TResourceReader reader;
+    reader.SetBuffer(buffer);
+    
+    // Load the data provider configurability parameter data.
+    CMTPDataProviderConfig* config(CMTPDataProviderConfig::NewL(reader, aResourceFilename));
+    CleanupStack::PopAndDestroy(buffer);
+    CleanupStack::PopAndDestroy(&file);
+    CleanupStack::PushL(config);
+    __FLOG(_L8("CreateConfigLC - Exit"));
+    return config;
+    }
+
+/**
+Check the  necessity of objects enumeration as given the data provider 
+@param dp CMTPDataProvider reference
+*/
+TBool CMTPDataProviderController::IsObjectsEnumerationNeededL(CMTPDataProvider& dp)
+{
+    __FLOG(_L8("CheckEnumerateDPObjectsL - Entry"));
+
+	CMTPStorageMgr& storages = iSingletons.StorageMgr();
+	TUint32 aStorageId = iEnumeratingStorages[0];
+	
+    TBool doEnumeration = true;
+	
+	if (aStorageId != KMTPStorageAll && storages.PhysicalStorageId(aStorageId))
+		{
+		TBool isFSBased(false);
+		RArray<TUint> storageTypes = dp.SupportedCodes( EStorageSystemTypes );
+                // check whether the storage type of the dp is file system based.
+		for (TInt i = 0; i < storageTypes.Count() && !isFSBased; i++)
+			{
+			   isFSBased= (storageTypes[i] == CMTPStorageMetaData::ESystemTypeDefaultFileSystem);
+			}
+		// As given physical storage id, only fs based dp need to do the enumeration.
+		if (!isFSBased)
+			{
+			  doEnumeration = false;
+			}
+	    }
+	__FLOG(_L8("CheckEnumerateDPObjectsL - Exit"));
+	return doEnumeration;
+}
+
+/**
+Requests that the given data provider enumerate its objects.
+@param aId data provider ID
+*/
+void CMTPDataProviderController::EnumerateDataProviderObjectsL(TUint aId)
+    {
+    __FLOG(_L8("EnumerateDataProviderObjectsL - Entry"));
+    CMTPDataProvider& dp(DataProviderL(aId));
+
+	if (IsObjectsEnumerationNeededL(dp))
+		{   
+		TBool abnormaldown = ETrue;
+		iSingletons.FrameworkConfig().GetValueL(CMTPFrameworkConfig::EAbnormalDown , abnormaldown);
+		if ( (!abnormaldown) && (dp.DataProviderConfig().BoolValue(MMTPDataProviderConfig::EObjectEnumerationPersistent)))
+			{       
+			// Initialize persistent objects store.
+            iSingletons.ObjectMgr().RestorePersistentObjectsL(aId);
+			}
+        else
+        	{
+			// Mark all non-persistent objects.    
+			iSingletons.ObjectMgr().MarkNonPersistentObjectsL(aId,iEnumeratingStorages[0]);
+		    }
+    
+        // Initiate the data provider enumeration sequence.
+        dp.EnumerateObjectsL(iEnumeratingStorages[0]);
+		}
+	else 
+		{
+		//The DP does not need enumeration this time, so just change the state to go on.
+		EnumerationStateChangedL(dp);
+		}
+
+    __FLOG(_L8("EnumerateDataProviderObjectsL - Exit"));
+    }
+    
+/**
+Loads the dataprovider on ROM drives depending upon the mode and activates the specified ECOM data provider.
+@param aResourceFilename The data provider registration and configuration data 
+resource filename.
+@param aImplementations The ECOM data provider implementations list (ordered by 
+implementation UID).
+@return ETrue if data provider is successfully loaded, EFalse otherwise.
+@leave One of the system wide error codes, if a processing failure occurs. 
+*/
+TBool CMTPDataProviderController::LoadROMDataProvidersL(const TDesC& aResourceFilename, const RImplInfoPtrArray& aImplementations)
+    {
+    __FLOG(_L8("LoadROMDataProvidersL - Entry"));
+    // Retrieve the implementation UID
+    TUint uid(0);
+    User::LeaveIfError(Uid(aResourceFilename, uid));
+    TBool success(EFalse);
+
+    // Check for a corresponding plug-in implementation.
+    TInt index = aImplementations.FindInOrder(TUid::Uid(uid), ImplementationsLinearOrderUid);
+    if (index >= 0)
+        {       	
+        // Construct the configuration data resource file full path name.
+        RBuf filename;
+        CleanupClosePushL(filename);  
+        filename.CreateL(KMTPDpResourceDirectory.BufferSize + aResourceFilename.Length());
+        filename.Append(KMTPDpResourceDirectory);
+        filename.Append(aResourceFilename); 
+        if(iStubFound)
+            {
+            RPointerArray<HBufC> files;
+            CleanupClosePushL(files);
+            iSisEntry.FilesL(files);
+            for (TInt i = 0; i< files.Count(); ++i)
+                {
+                TPtrC resourceFileName = files[i]->Des();
+                TPtrC fileName = resourceFileName.Mid(resourceFileName.LocateReverse('\\') + 1);
+                if(fileName.MatchF(aResourceFilename) != KErrNotFound)
+                    {
+                    TDriveName drive = aImplementations[index]->Drive().Name();
+                    //replace "z:" with "c:" or "d:" or ...
+                    filename.Replace(0,2,drive);
+                    break;
+                    }
+                }
+            CleanupStack::Pop(&files);
+            files.ResetAndDestroy();  	        	
+            }
+        success = LoadDataProviderL(filename);
+        CleanupStack::PopAndDestroy(&filename);
+        }    	
+    __FLOG(_L8("LoadROMDataProvidersL - Exit"));
+    return success;
+    }
+
+/**
+Load all data providers installed on non-ROM drives depending upon the mode and activates 
+the specified ECOM data provider.
+@param aImplementations The installed ECOM data provider implementations list (ordered by 
+implementation UID).
+@leave One of the system wide error codes, if a processing failure occurs. 
+*/
+void CMTPDataProviderController::LoadInstalledDataProvidersL(const CImplementationInformation* aImplementations)
+    {
+    __FLOG(_L8("LoadInstalledDataProvidersL - Entry"));
+    TUint uid = aImplementations->ImplementationUid().iUid;
+    TBool tFlag(EFalse);
+    iNextDpId = iSingletons.ObjectMgr().DPIDL(uid, tFlag);
+    if(!tFlag)
+        {
+        iSingletons.ObjectMgr().InsertDPIDObjectL(iNextDpId, uid);
+        }   
+
+    HBufC8 *OpaqData = HBufC8::NewLC(KOpaqueDataLength);
+    *OpaqData = aImplementations->OpaqueData();
+    TBuf16<KOpaqueDataLength> pkgIDstr;
+    pkgIDstr.Copy(*OpaqData);
+    CleanupStack::PopAndDestroy(OpaqData);
+    pkgIDstr.Trim();
+    _LIT(prefix, "0x");
+    TInt searchindex = pkgIDstr.FindC(prefix);
+    if(KErrNotFound != searchindex)
+        {
+        //Skip "0x".
+        pkgIDstr = pkgIDstr.Mid(searchindex + 2);
+        }
+    if (0 == pkgIDstr.Length())
+        {
+        User::Leave(KErrArgument);
+        }
+    
+    TUint aUid(0);
+    User::LeaveIfError(Uid(pkgIDstr, aUid));
+    
+    iSingletons.ObjectMgr().InsertPkgIDObjectL(iNextDpId, aUid);
+    TDriveName drive = aImplementations->Drive().Name();
+    RBuf resourcefilename;
+    CleanupClosePushL(resourcefilename);  
+    resourcefilename.CreateL(KMaxFileName);
+    resourcefilename.Copy(KMTPDpResourceDirectory);
+    //Replace "z:"(at 0 position) with "c:" or "d:" or ...
+    resourcefilename.Replace(0,2,drive);
+
+    RBuf rscfile;
+    CleanupClosePushL(rscfile);
+    rscfile.CreateL(KMaxFileName);
+    rscfile.NumUC(uid,EHex);
+    _LIT(postfix, ".rsc");
+    rscfile.Append(postfix);
+    resourcefilename.Append(rscfile);
+    CleanupStack::PopAndDestroy(&rscfile);
+   
+    LoadDataProviderL(resourcefilename);
+
+    CleanupStack::PopAndDestroy(&resourcefilename);
+    __FLOG(_L8("LoadInstalledDataProvidersL - Exit"));
+    }
+
+/**
+Load data providers
+@param aImplementations The installed ECOM data provider implementations list (ordered by 
+implementation UID).
+@return ETrue if data provider is successfully loaded, EFalse otherwise.
+@leave One of the system wide error codes, if a processing failure occurs. 
+*/
+TBool CMTPDataProviderController::LoadDataProviderL(const TDesC& aResourceFilename)
+    {
+    __FLOG(_L8("LoadDataProviderL - Entry"));
+    // Load the configurability parameter data.
+    CMTPDataProviderConfig* config(CreateConfigLC(aResourceFilename));
+    
+    
+    TBool success(EFalse);
+    TBool supported(ETrue);
+    TUint aUid(0);
+    if ( Uid(aResourceFilename,aUid) != KErrNone )
+       	{
+        return success;	
+       	}
+    TUint uid(aUid);
+    if ((uid != KMTPImplementationUidDeviceDp) && (uid != KMTPImplementationUidProxyDp) && (uid != KMTPImplementationUidFileDp))
+        {
+        supported = EFalse;
+        RArray<TUint> supportedModeArray;			
+        config->GetArrayValue(MMTPDataProviderConfig::ESupportedModes, supportedModeArray);
+        TInt i=0;
+        while (i < supportedModeArray.Count())
+            {
+            if(iMode == supportedModeArray[i])
+                {
+                supported = ETrue;
+                break;
+                }
+            i++;
+            }
+        supportedModeArray.Close();
+        if(!supported)
+            {
+            //Update the Database table last IsDploaded filed with Efalse;
+            /* create dummy  DP which is just new of Dervied DataPRoviderClass
+            update the DataBase  so that DPIP which this was get then set handle Store DB */
+            iSingletons.ObjectMgr().MarkDPLoadedL(iNextDpId,EFalse);
+            RBuf dummyfilename;
+            CleanupClosePushL(dummyfilename);
+            dummyfilename.CreateL(KMTPDpDummyResourcefile.BufferSize);        		
+            dummyfilename.Append(KMTPDpDummyResourcefile);							
+            CMTPDataProviderConfig* aDummyConfig(CreateConfigLC(dummyfilename));
+            CMTPDataProvider* dummyDp(NULL);		
+            dummyDp = CMTPDataProvider::NewLC(iNextDpId, TUid::Uid(uid), aDummyConfig);
+            iDataProviders.InsertInOrderL(dummyDp, TLinearOrder<CMTPDataProvider>(CMTPDataProvider::LinearOrderUid));			
+            CleanupStack::Pop(dummyDp);          						
+            CleanupStack::Pop(aDummyConfig);
+            CleanupStack::PopAndDestroy(&dummyfilename);			
+            }
+        }
+    CMTPDataProvider* dp(NULL);
+    if(supported)
+        {
+        // Load the data provider.        	
+        switch (config->UintValue(MMTPDataProviderConfig::EDataProviderType))
+            {
+        case EEcom:
+            {
+            // Configurability parameter data ownership is passed to the data provider.
+            iSingletons.ObjectMgr().MarkDPLoadedL(iNextDpId, ETrue);
+            dp = CMTPDataProvider::NewLC(iNextDpId, TUid::Uid(uid), config);
+            }
+            break;
+
+        default:
+            __DEBUG_ONLY(User::Invariant());
+            break;
+            }
+    	}
+    if (dp)
+        {
+        // Register the data provider.
+        switch (uid)
+            {
+            case KMTPImplementationUidDeviceDp:
+                iDpIdDeviceDp = iNextDpId;
+                break;
+
+            case KMTPImplementationUidFileDp:
+                iDpIdFileDp = iNextDpId;
+                break;
+
+            case KMTPImplementationUidProxyDp:
+                iDpIdProxyDp = iNextDpId;
+                break;
+
+            default:
+                break;
+            }
+        iDataProviders.InsertInOrderL(dp,  TLinearOrder<CMTPDataProvider>(CMTPDataProvider::LinearOrderUid));
+        CleanupStack::Pop(dp);
+        CleanupStack::Pop(config);
+        success = ETrue;
+        }
+    else
+        {
+        // No data provider was created.
+        CleanupStack::PopAndDestroy(config);
+        }
+    __FLOG(_L8("LoadDataProviderL - Exit"));
+    return success;
+    }
+
+/**
+Provides the implemetation UID associated with the specified data provider 
+configuration data resource filename.
+@param aResourceFilename The data provider configuration data resource
+filename.
+@param aUid On completion, the implemetation UID.
+*/
+TInt CMTPDataProviderController::Uid(const TDesC& aResourceFilename, TUint& aUid)
+    {
+    __FLOG(_L8("Uid - Entry"));
+    // Extract the implemetation UID from the filename.
+    TParsePtrC parser(aResourceFilename);
+    TLex lex(parser.Name());
+    TInt err = lex.Val(aUid, EHex);
+    __FLOG(_L8("Uid - Exit"));
+    return err;
+    }
+
+/**
+Schedules an enumeration iteration.
+*/
+void CMTPDataProviderController::Schedule()
+    {
+    __FLOG(_L8("Schedule - Entry"));
+    if (!IsActive())
+        {
+        TRequestStatus* status(&iStatus);
+        *status = KRequestPending;
+        SetActive();
+        User::RequestComplete(status, KErrNone);
+        }
+    __FLOG(_L8("Schedule - Exit"));
+    }
+/**
+Get the mtpkey mode.
+*/    
+TMTPOperationalMode CMTPDataProviderController::Mode()
+	{
+	return iMode;
+	}
+     
+void CMTPDataProviderController::ImplementationsCleanup(TAny* aData)
+    {
+    reinterpret_cast<RImplInfoPtrArray*>(aData)->ResetAndDestroy();
+    }
+    
+/**
+Implements a linear order relation for @see CImplementationInformation 
+objects based on relative @see CImplementationInformation::ImplementationUid.
+@param aUid The implementation UID object to match.
+@param aObject The object instance to match.
+@return Zero, if the two objects are equal; A negative value, if the first 
+object is less than the second, or; A positive value, if the first object is 
+greater than the second.
+*/     
+TInt CMTPDataProviderController::ImplementationsLinearOrderUid(const TUid* aUid, const CImplementationInformation& aObject)
+    {
+    return (aUid->iUid - aObject.ImplementationUid().iUid);
+    }
+    
+/**
+Implements a @see TLinearOrder for @see CImplementationInformation objects 
+based on relative @see CImplementationInformation::ImplementationUid.
+@param aL The first object instance.
+@param aR The second object instance.
+@return Zero, if the two objects are equal; A negative value, if the first 
+object is less than the second, or; A positive value, if the first object is 
+greater than the second.
+*/   
+TInt CMTPDataProviderController::ImplementationsLinearOrderUid(const CImplementationInformation& aL, const CImplementationInformation& aR)
+    {
+    return (aL.ImplementationUid().iUid - aR.ImplementationUid().iUid);
+    }
+
+/**
+Provides the enumeration state
+@return iEnumerationState
+*/
+EXPORT_C TUint CMTPDataProviderController::EnumerateState()
+    {
+    return iEnumerationState;
+    } 
+
+void CMTPDataProviderController::CreateRegistrySessionAndEntryL()
+	{
+	User::LeaveIfError(iSisSession.Connect());
+    CleanupClosePushL(iSisSession);
+    TInt err = KErrNone;
+    TUint stubuid;
+    iSingletons.FrameworkConfig().GetValueL(CMTPFrameworkConfig::EPackageStubUID , stubuid);
+ 	TRAP_IGNORE(err=iSisEntry.Open(iSisSession, TUid::Uid(stubuid) ));
+	if(err == KErrNone)
+		{
+		iStubFound = ETrue;	
+		}
+	CleanupStack::Pop();	
+	}
+	
+void  CMTPDataProviderController::CloseRegistrySessionAndEntryL()
+	{
+	if (&iSisEntry != NULL)
+		{
+		iSisEntry.Close();	
+		}
+	iSisSession.Close();
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpdeltadatamgr.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,559 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+*/
+
+
+#include "cmtpdeltadatamgr.h"
+//! Size of a PUID in bytes
+static const TInt KMTPPuidSize = 16;
+
+
+__FLOG_STMT(_LIT8(KComponent,"MTPDeltaDataMgr:");)
+
+_LIT(KMTPDeltaDataTable, "MTPDeltaDataTable");
+_LIT(KSQLPuidIndexName, "PuidIndex");
+_LIT(KSQLIdentifierIndexName, "IdentifierIndex");
+_LIT(KAnchorIdTable, "AnchorIdTable");
+_LIT (KDeleteDeltaTable, "DELETE FROM MTPDeltaDataTable");
+/**
+Standard c++ constructor
+*/	
+CMtpDeltaDataMgr::CMtpDeltaDataMgr(RDbDatabase& aDatabase)
+	:iDatabase(aDatabase)
+ 	{
+ 	}
+
+ 
+/**
+Second-phase construction
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+void CMtpDeltaDataMgr::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry"));
+	__FLOG(_L8("ConstructL - Exit"));
+	}
+
+
+/**
+Two-phase construction
+@param aDatabase	The reference to the database object
+@return	pointer to the created CMtpDeltaDataMgr instance
+*/
+CMtpDeltaDataMgr* CMtpDeltaDataMgr::NewL(RDbDatabase& aDatabase)
+	{
+	CMtpDeltaDataMgr* self = new (ELeave) CMtpDeltaDataMgr(aDatabase);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+
+/**
+Destructor
+*/	
+CMtpDeltaDataMgr::~CMtpDeltaDataMgr()
+	{
+	iDeltaTableBatched.Close();
+	iAnchorTableBatched.Close();
+	iView.Close();
+	iSuidIdArray.Close();
+	__FLOG_CLOSE;
+	}
+/**
+Create the MTP Delta Data Table
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C void CMtpDeltaDataMgr::CreateDeltaDataTableL()
+	{
+	__FLOG(_L8("CreateDeltaDataTableL - Entry"));
+	
+	iDeltaTableBatched.Close();
+	if(!DBUtility::IsTableExistsL(iDatabase, KMTPDeltaDataTable))
+		{
+		_LIT(KSQLCreateMTPDeltaDataTableText,"CREATE TABLE MTPDeltaDataTable (SuidId BIGINT , OpCode TINYINT )");		
+		User::LeaveIfError(iDatabase.Execute(KSQLCreateMTPDeltaDataTableText));
+		
+		if(!DBUtility::IsIndexExistsL(iDatabase, KMTPDeltaDataTable, KSQLPuidIndexName))
+			{
+			_LIT(KSQLCreateReferenceIndexText,"CREATE UNIQUE INDEX PuidIndex on MTPDeltaDataTable (SuidId)");
+			User::LeaveIfError(iDatabase.Execute(KSQLCreateReferenceIndexText));
+			}
+		}
+	iDeltaTableBatched.Open(iDatabase, KMTPDeltaDataTable, RDbRowSet::EUpdatable);
+		
+	__FLOG(_L8("CreateDeltaDataTableL - Exit"));
+	}
+
+/**
+Create the Anchor Id Table anchor Id will be stored here
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C void CMtpDeltaDataMgr::CreateAnchorIdTableL()
+	{
+	__FLOG(_L8("CreateAnchorIdTableL - Entry"));
+	iAnchorTableBatched.Close();
+	if(!DBUtility::IsTableExistsL(iDatabase, KAnchorIdTable))
+		{
+		_LIT(KSQLCreateAnchorIdTableText,"CREATE TABLE AnchorIdTable (anchorid INTEGER, curindex INTEGER, identifier INTEGER)");
+		User::LeaveIfError(iDatabase.Execute(KSQLCreateAnchorIdTableText));
+			
+		if(!DBUtility::IsIndexExistsL(iDatabase, KAnchorIdTable, KSQLIdentifierIndexName))
+			{
+			_LIT(KSQLCreateRefIndexText,"CREATE UNIQUE INDEX IdentifierIndex on AnchorIdTable (identifier)");
+			User::LeaveIfError(iDatabase.Execute(KSQLCreateRefIndexText));
+			}
+		}
+	iAnchorTableBatched.Open(iDatabase, KAnchorIdTable, RDbRowSet::EUpdatable);
+		
+	__FLOG(_L8("CreateAnchorIdTableL - Exit"));
+	}
+
+/**
+Add a new anchor ID to the AnchorIdTable
+@param aAnchorId The anchor ID
+@param aIdentifier The identifier of the anchor
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+EXPORT_C void CMtpDeltaDataMgr::InsertAnchorIdL(TInt aAnchorId, TInt aIdentifier)
+	{
+	__FLOG(_L8("InsertAnchorIdL - Entry"));	
+	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
+	if(!(iAnchorTableBatched.SeekL(aIdentifier)))
+		{
+		iAnchorTableBatched.InsertL();
+		iAnchorTableBatched.SetColL(1, aAnchorId);
+		iAnchorTableBatched.SetColL(2, 0);
+		iAnchorTableBatched.SetColL(3, aIdentifier);
+		iAnchorTableBatched.PutL();
+		}
+	__FLOG(_L8("InsertAnchorIdL - Exit"));
+	}
+
+/**
+Overwrite the anchor Id with new one
+@param aAnchorId The new anchor ID
+@param aIdentifier The identifier of the anchor
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+EXPORT_C void CMtpDeltaDataMgr::UpdateAnchorIdL(TInt aAnchorId, TInt aIdentifier)
+	{
+	__FLOG(_L8("UpdateAnchorIdL - Entry"));
+	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
+	if(iAnchorTableBatched.SeekL(aIdentifier))
+		{
+		iAnchorTableBatched.UpdateL();
+		iAnchorTableBatched.SetColL(1, aAnchorId);
+		iAnchorTableBatched.PutL();
+		}
+	__FLOG(_L8("UpdateAnchorIdL - Exit"));
+	}
+
+/**
+Get the anchor ID with specified identifier
+@param aIdentifier The identifier of the anchor
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+EXPORT_C TInt CMtpDeltaDataMgr::GetAnchorIdL(TInt aIdentifier)
+	{
+	__FLOG(_L8("GetAnchorIdL - Entry"));
+	TInt anchorId = 0;
+	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
+	if(iAnchorTableBatched.SeekL(aIdentifier))
+		{
+		iAnchorTableBatched.GetL();
+		anchorId = iAnchorTableBatched.ColInt32(1);
+		}
+	__FLOG(_L8("GetAnchorIdL - Exit"));
+	return anchorId;
+	}
+
+/**
+Overwrite the old index  with new one
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+EXPORT_C void CMtpDeltaDataMgr::UpdatePersistentIndexL(TInt aCurindex, TInt aIdentifier)
+	{	
+	__FLOG(_L8("UpdatePersistentIndexL - Entry"));
+	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
+	if(iAnchorTableBatched.SeekL(aIdentifier))
+		{
+		iAnchorTableBatched.UpdateL();
+		iAnchorTableBatched.SetColL(2, aCurindex);
+		iAnchorTableBatched.PutL();
+		}
+	__FLOG(_L8("UpdatePersistentIndexL - Exit"));
+	}
+	
+/**
+returns the stored index 
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C TInt CMtpDeltaDataMgr::GetPersistentIndexL(TInt aIdentifier)
+	{
+	__FLOG(_L8("GetPersistentIndexL - Entry"));
+
+	TInt currIndex = 0;
+	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
+	if(iAnchorTableBatched.SeekL(aIdentifier))
+		{
+		iAnchorTableBatched.GetL();
+		currIndex = iAnchorTableBatched.ColInt32(2);
+		}
+	__FLOG(_L8("GetPersistentIndexL - Exit"));		
+	return currIndex;
+	}
+
+/**
+Add the Opcode and SuidId to the MTPDeltaDataTable
+@param aSuidId The suid identifier of the object to be added
+@param aOpCode operation code 
+@leave  One of the system wide error codes, if a processing failure occurs.
+*/
+void CMtpDeltaDataMgr::UpdateDeltaDataTableL(TInt64 aSuidId, TOpCode aOpCode)
+	{
+	__FLOG(_L8("UpdateDeltaDataTableL - Entry"));
+	if(!DBUtility::IsTableExistsL(iDatabase, KMTPDeltaDataTable))
+		return;
+		
+	iDeltaTableBatched.SetIndex(KSQLPuidIndexName);
+	if(iDeltaTableBatched.SeekL(aSuidId))
+		{
+		iDeltaTableBatched.UpdateL();
+		iDeltaTableBatched.SetColL(2, aOpCode);
+		}
+	else
+		{
+		iDeltaTableBatched.InsertL();
+		iDeltaTableBatched.SetColL(1, aSuidId);
+		iDeltaTableBatched.SetColL(2, aOpCode);
+		}
+	iDeltaTableBatched.PutL();
+	__FLOG(_L8("UpdateDeltaDataTableL - Exit"));
+	}
+
+/**
+@param total number of items to be  filled into aModifiedPuidIdArray and aDeletedPuidArray
+@param the start position 
+@param reference to modifed and deleted mtp arrays 
+@return Number of remaining items to be retrieved from table
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C TInt CMtpDeltaDataMgr::GetChangedPuidsL(TInt aMaxArraySize, TInt& aPosition, CMTPTypeArray& aModifiedPuidIdArray, CMTPTypeArray& aDeletedPuidArray)
+	{
+	__FLOG(_L8("GetChangedPuidsL - Entry"));
+	
+	if(!iNeedToSendMore)
+		{
+		_LIT(KSQLGetAll, "SELECT * FROM MTPDeltaDataTable");
+		
+		User::LeaveIfError(iView.Prepare(iDatabase, TDbQuery(KSQLGetAll)));
+		User::LeaveIfError(iView.EvaluateAll());
+		iNeedToSendMore = ETrue;
+		iView.FirstL();
+		iTotalRows = iView.CountL();
+
+		if(aPosition !=0 && aPosition < iTotalRows)
+			{
+			for(TInt i=0; i<aPosition; i++)
+				{
+				iView.NextL();
+				}
+			}
+		}
+		
+	if(iTotalRows == 0 || aPosition >= iTotalRows)
+		{
+		iNeedToSendMore = EFalse;
+		iView.Close();
+		return 0;
+		}
+	
+	TInt64 suidId = 0;
+	TInt64 puidlow = 1;
+	TBuf8<KMTPPuidSize> puidBuffer;
+	
+	for(TInt count=0;count <aMaxArraySize;count++)
+		{
+		iView.GetL();
+		//Get the data from the current row
+		suidId = iView.ColInt64(1);
+		TInt8 opCode = iView.ColInt8(2);	
+		puidBuffer.Copy(TPtrC8((const TUint8*)&suidId, sizeof(TInt64)));
+		puidBuffer.Append(TPtrC8((const TUint8*)&puidlow, sizeof(TInt64)));
+		TMTPTypeUint128 puid(puidBuffer);
+
+		if(opCode  == EDeleted)
+			{
+			aDeletedPuidArray.AppendL(puid);
+			}
+		else
+			{
+			aModifiedPuidIdArray.AppendL(puid);
+			}
+		aPosition++;
+
+		if(aPosition == iTotalRows)
+			{
+			iNeedToSendMore = EFalse;
+			iView.Close();
+			break;	
+			}
+		else
+			{
+			//Move to the next row
+			iView.NextL();
+			}
+		}
+	
+	__FLOG(_L8("GetChangedPuidsL - Exit"));
+	return	(iTotalRows - aPosition);
+	}
+
+/**
+@param total number of items to be  filled into aAddedPuidIdArray
+@param reference to added mtp arrays 
+@return Number of remaining items to be retrieved from table
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C TInt CMtpDeltaDataMgr::GetAddedPuidsL(TInt aMaxArraySize, TInt &aPosition, CMTPTypeArray& aAddedPuidIdArray)
+	{
+	__FLOG(_L8("GetAddedPuidsL - Entry"));
+	
+	if(!iNeedToSendMore)
+		{
+		TInt opcode = EAdded;
+		_LIT(KSQLSelectAdded, "SELECT * FROM MTPDeltaDataTable WHERE OpCode = %d");
+		iSqlStatement.Format(KSQLSelectAdded, opcode);
+		
+		User::LeaveIfError(iView.Prepare(iDatabase, TDbQuery(iSqlStatement)));
+		User::LeaveIfError(iView.EvaluateAll());
+		iNeedToSendMore = ETrue;
+		iView.FirstL();
+		iTotalRows = iView.CountL();
+
+		if(aPosition !=0 && aPosition < iTotalRows)
+			{
+			for(TInt i=0; i<aPosition; i++)
+				{
+				iView.NextL();
+				}
+			}
+		}
+		
+	if(iTotalRows == 0 || aPosition >= iTotalRows)
+		{
+		iNeedToSendMore = EFalse;
+		iView.Close();
+		return 0;
+		}
+	
+	TInt64 suidId = 0;
+	TInt64 puidlow = 1;
+	TBuf8<KMTPPuidSize> puidBuffer;
+	
+	for(TInt count=0;count <aMaxArraySize;count++)
+		{
+
+		iView.GetL();
+		//Get the data from the current row
+		suidId = iView.ColInt64(1);
+		puidBuffer.Copy(TPtrC8((const TUint8*)&suidId, sizeof(TInt64)));
+		puidBuffer.Append(TPtrC8((const TUint8*)&puidlow, sizeof(TInt64)));
+		TMTPTypeUint128 puid(puidBuffer);
+
+		aAddedPuidIdArray.AppendL(puid);
+		aPosition++;
+
+		if(aPosition == iTotalRows)
+			{
+			iNeedToSendMore = EFalse;
+			iView.Close();
+			break;	
+			}
+		else
+			{
+			//Move to the next row
+			iView.NextL();		
+			}
+		}
+	
+	__FLOG(_L8("GetAddedPuidsL - Exit"));
+	return 	(iTotalRows - aPosition);
+	}
+
+/**
+@param total number of items to be  filled into aAddedPuidIdArray
+@param reference to deleted mtp arrays 
+@return Number of remaining items to be retrieved from table
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C TInt CMtpDeltaDataMgr::GetDeletedPuidsL(TInt aMaxArraySize, TInt &aPosition, CMTPTypeArray& aDeletedPuidIdArray)
+	{
+	__FLOG(_L8("GetDeletedPuidsL - Entry"));
+
+	if(!iNeedToSendMore)
+		{
+		TInt opcode = EDeleted;
+		_LIT(KSQLSelectDeleted, "SELECT * FROM MTPDeltaDataTable WHERE OpCode = %d");
+		iSqlStatement.Format(KSQLSelectDeleted, opcode);
+		
+		User::LeaveIfError(iView.Prepare(iDatabase, TDbQuery(iSqlStatement)));
+		User::LeaveIfError(iView.EvaluateAll());
+		iNeedToSendMore = ETrue;
+		iView.FirstL();
+		iTotalRows = iView.CountL();
+
+		if(aPosition !=0 && aPosition < iTotalRows)
+			{
+			for(TInt i=0; i<aPosition; i++)
+				{
+				iView.NextL();
+				}
+			}
+		}
+		
+	if(iTotalRows == 0 || aPosition >= iTotalRows)
+		{
+		iNeedToSendMore = EFalse;
+		iView.Close();
+		return 0;
+		}
+	
+	TInt64 suidId = 0;
+	TInt64 puidlow = 1;
+	TBuf8<KMTPPuidSize> puidBuffer;
+	
+	for(TInt count=0;count <aMaxArraySize;count++)
+		{
+
+		iView.GetL();
+		//Get the data from the current row
+		suidId = iView.ColInt64(1);
+		puidBuffer.Copy(TPtrC8((const TUint8*)&suidId, sizeof(TInt64)));
+		puidBuffer.Append(TPtrC8((const TUint8*)&puidlow, sizeof(TInt64)));
+		TMTPTypeUint128 puid(puidBuffer);
+
+		aDeletedPuidIdArray.AppendL(puid);
+		aPosition++;
+
+		if(aPosition == iTotalRows)
+			{
+			iNeedToSendMore = EFalse;
+			iView.Close();
+			break;	
+			}
+		else
+			{
+			//Move to the next row
+			iView.NextL();		
+			}
+		}
+		
+	__FLOG(_L8("GetDeletedPuidsL - Exit"));
+	return 	(iTotalRows - aPosition);
+	}
+
+/**
+@param total number of items to be  filled into aAddedPuidIdArray
+@param reference to Modified mtp arrays 
+@return Number of remaining items to be retrieved from table
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C TInt CMtpDeltaDataMgr::GetModifiedPuidsL(TInt aMaxArraySize, TInt &aPosition, CMTPTypeArray& aModifiedPuidIdArray)
+	{
+	__FLOG(_L8("GetDeletedPuidsL - Entry"));
+
+	if(!iNeedToSendMore)
+		{
+		TInt opcode = EModified;
+		_LIT(KSQLSelectModified, "SELECT * FROM MTPDeltaDataTable WHERE OpCode = %d");
+		iSqlStatement.Format(KSQLSelectModified, opcode);
+		
+		User::LeaveIfError(iView.Prepare(iDatabase, TDbQuery(iSqlStatement)));
+		User::LeaveIfError(iView.EvaluateAll());
+		iNeedToSendMore = ETrue;
+		iView.FirstL();
+		iTotalRows = iView.CountL();
+
+		if(aPosition !=0 && aPosition < iTotalRows)
+			{
+			for(TInt i=0; i<aPosition; i++)
+				{
+				iView.NextL();
+				}
+			}
+		}
+		
+	if(iTotalRows == 0 || aPosition >= iTotalRows)
+		{
+		iNeedToSendMore = EFalse;
+		iView.Close();
+		return 0;
+		}
+	
+	TInt64 suidId = 0;
+	TInt64 puidlow = 1;
+	TBuf8<KMTPPuidSize> puidBuffer;
+	
+	for(TInt count=0;count <aMaxArraySize;count++)
+		{
+		iView.GetL();
+		//Get the data from the current row
+		suidId = iView.ColInt64(1);		
+		
+		puidBuffer.Copy(TPtrC8((const TUint8*)&suidId, sizeof(TInt64)));
+		puidBuffer.Append(TPtrC8((const TUint8*)&puidlow, sizeof(TInt64)));
+		TMTPTypeUint128 puid(puidBuffer);
+
+		aModifiedPuidIdArray.AppendL(puid);
+		aPosition++;
+
+		if(aPosition == iTotalRows)
+			{
+			iNeedToSendMore = EFalse;
+			iView.Close();
+			break;	
+			}
+		else
+			{
+			//Move to the next row
+			iView.NextL();		
+			}
+		}
+		
+	__FLOG(_L8("GetDeletedPuidsL - Exit"));
+	return 	(iTotalRows - aPosition);
+	}
+
+/**
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C void CMtpDeltaDataMgr::ResetMTPDeltaDataTableL()
+	{
+	__FLOG(_L8("ResetMTPDeltaDataTableL - Entry"));
+
+	iView.Close();
+	iNeedToSendMore = EFalse;
+	User::LeaveIfError(iDatabase.Execute(KDeleteDeltaTable));
+	
+	__FLOG(_L8("ResetMTPDeltaDataTableL - Exit"));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpdpidstore.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,120 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+#include "cmtpdpidstore.h"
+#include "dbutility.h"
+
+
+_LIT(KSQLDPIDTableName, "DPIDStore");
+_LIT(KSQLInsertDPIDObjectText, "INSERT INTO DPIDStore (DataProviderId, Uid) VALUES (%u, %u)");
+_LIT(KSQLCreateDPIDTableText, "CREATE TABLE DPIDStore (DataProviderId UNSIGNED INTEGER, Uid UNSIGNED INTEGER )");
+_LIT(KSQLGetDPIDUID, "SELECT * FROM DPIDStore");
+
+/**
+Two-phase construction
+@param aDatabase	The reference to the database object
+@return	pointer to the created suid map instance
+*/
+CMTPDPIDStore* CMTPDPIDStore::NewL(RDbDatabase& aDatabase)
+	{
+	CMTPDPIDStore* self = new (ELeave) CMTPDPIDStore(aDatabase);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+
+/**
+Standard c++ constructor
+*/	
+CMTPDPIDStore::CMTPDPIDStore(RDbDatabase& aDatabase)
+	:iDatabase(aDatabase)
+	{
+	}
+
+/**
+Second phase constructor.
+*/    
+void CMTPDPIDStore::ConstructL()
+    {    
+    CreateDPIDStoteTableL();
+    }
+
+/**
+Create the table for storing the mapping from object handle to other properties 
+(data provider id, storage id, formatcode, etc.)
+*/    
+void CMTPDPIDStore::CreateDPIDStoteTableL()
+	{	
+	if (!DBUtility::IsTableExistsL(iDatabase, KSQLDPIDTableName))
+		{
+		User::LeaveIfError(iDatabase.Execute(KSQLCreateDPIDTableText));			
+		}
+	iSqlStatement.Format(KSQLGetDPIDUID);    
+    RDbView view;
+    CleanupClosePushL(view);
+    User::LeaveIfError(view.Prepare(iDatabase, TDbQuery(iSqlStatement)));
+    User::LeaveIfError(view.Evaluate());
+	while (view.NextL())
+        {
+        view.GetL();
+       	iDPIDs.AppendL(view.ColInt64(EDPIDStoreDataProviderId));
+		iDPUIDs.AppendL(view.ColInt64(EDPIDStoreUid));
+        }
+	CleanupStack::PopAndDestroy(&view);	
+	}
+	
+/**
+Destructor.
+*/    
+CMTPDPIDStore::~CMTPDPIDStore()
+    {  
+	iDPIDs.Close();
+	iDPUIDs.Close();
+    }
+
+
+void CMTPDPIDStore::InsertDPIDObjectL(TUint aDPId, TUint aUid)
+	{		
+	iSqlStatement.Format(KSQLInsertDPIDObjectText, aDPId, aUid);
+	TInt err(iDatabase.Execute(iSqlStatement));
+	iDatabase.Compact();
+	iDPIDs.AppendL(aDPId);
+	iDPUIDs.AppendL(aUid);
+	}	
+  
+TUint CMTPDPIDStore::DPIDL(TUint32 aUid, TBool& aFlag) const
+    {
+	TUint tempDPId = 3;
+	aFlag = ETrue;
+	TRAPD(err, tempDPId = iDPUIDs.FindL(aUid));
+	if(err == KErrNone)
+		{
+		tempDPId = iDPIDs[tempDPId];
+		}
+	else
+		{
+		if(iDPIDs.Count()>0)
+			{
+			tempDPId = iDPIDs[iDPIDs.Count() - 1];
+			tempDPId++;			
+			}
+		aFlag = EFalse;
+		}
+	return tempDPId;
+    } 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpframeworkconfig.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,186 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <centralrepository.h>
+
+#include "cmtpframeworkconfig.h"
+
+/**
+CMTPFrameworkConfig factory method. 
+@return A pointer to a new CMTPFrameworkConfig instance. Ownership IS transfered.
+@leave One of the system wide error codes if a processing failure occurs.
+*/
+CMTPFrameworkConfig* CMTPFrameworkConfig::NewL()
+    {
+    CMTPFrameworkConfig* self = new (ELeave) CMTPFrameworkConfig();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor.
+*/
+CMTPFrameworkConfig::~CMTPFrameworkConfig()
+    {
+    //Save the AbnormalDown state to EFalse
+    const TInt KNormalShutDownValue = 0;
+    iRepository->Set(EAbnormalDown, KNormalShutDownValue);
+    
+    delete iRepository;
+    }
+
+EXPORT_C void CMTPFrameworkConfig::GetValueL(TParameter aParam, TDes& aValue) const
+    {
+    TInt err(iRepository->Get(aParam, aValue));
+    if (KErrNotFound == err)
+        {
+        aValue = KNullDesC;
+        }
+    else if (KErrNone != err)
+        {
+        User::Leave(err);
+        }
+    }
+
+EXPORT_C HBufC* CMTPFrameworkConfig::ValueL(TParameter aParam) const
+    {
+    TInt length;
+    HBufC* buf = HBufC::NewLC(0);
+    TPtr ptr(buf->Des());
+    TInt err = iRepository->Get(aParam, ptr, length);    
+
+    // We want to get the length here so ignore the error if KErrOverflow
+    // Sometimes, the return value is KErrNone
+    if (KErrOverflow == err  || KErrNone == err)
+        {
+        // Now reallocate the buffer to length
+        if((length > 0)&&(length <255))
+            {
+        buf = buf->ReAllocL(length);
+        CleanupStack::Pop();
+        CleanupStack::PushL(buf);
+        
+        // Get the value
+        ptr.Set(buf->Des());
+        User::LeaveIfError(iRepository->Get(aParam, ptr));
+            }
+        }
+    else if (KErrNotFound != err)
+        {
+        User::Leave(err);
+        }
+    CleanupStack::Pop(buf);
+    return buf;
+    }
+
+EXPORT_C void CMTPFrameworkConfig::GetValueL(TParameter aParam, TUint& aValue) const
+    {    
+    // Use a temporary to avoid the compiler warning
+    TInt value(0);
+    TInt err(iRepository->Get(aParam, value));
+    if ((KErrNone != err ) &&
+        (KErrNotFound != err))
+        {
+        User::Leave(err);
+        }
+    aValue = static_cast<TUint>(value);
+    }
+
+EXPORT_C void CMTPFrameworkConfig::GetValueL(TParameter aParam, TBool& aValue) const
+    {
+    TInt value(0);
+    if(EAbnormalDown == aParam)
+    	{
+    	value = iAbnormalDownValue;
+    	}
+    else
+    	{
+        TInt err(iRepository->Get(aParam, value));
+        if ((KErrNone != err ) &&
+            (KErrNotFound != err))
+            {
+            User::Leave(err);
+            };
+    	}
+    aValue = (value != 0);
+    }
+   
+EXPORT_C void CMTPFrameworkConfig::GetValueL(TParameter aParam, RArray<TUint>& aArray) const
+    {
+    aArray.Reset();
+    if (CMTPFrameworkConfig::EExcludedStorageDrives != aParam)
+        {
+        User::Leave(KErrArgument);
+        }
+        
+    // Array settings key mask. All array settings keys must be unique that are
+    // unique in the most significant 2 bytes of the mask
+    static const TUint32 KMTPRepositoryArrayMask = 0xFFFF0000;
+    RArray<TUint32> keys;
+    CleanupClosePushL(keys);
+    
+    aArray.Reset();            
+    // Retrieve the keys for all array elements
+    TInt err(iRepository->FindL(aParam, KMTPRepositoryArrayMask, keys));
+    if (KErrNone == err)
+        {
+        // Iterate the keys, retrieve the values and append them to the destination array
+        TInt count = keys.Count();
+        for (TInt index = 0; index < count; index++)
+            {        
+            TInt value;
+            User::LeaveIfError(iRepository->Get(keys[index], value));    
+            aArray.AppendL(static_cast<TUint>(value));
+            }                 
+        }
+    else if (KErrNotFound != err)
+        {
+        User::Leave(err);    
+        }
+    
+    CleanupStack::PopAndDestroy(&keys);    
+    }
+    
+/**
+Constructor
+*/
+CMTPFrameworkConfig::CMTPFrameworkConfig()
+    {
+    }
+
+/**
+Second phase constructor.
+*/
+void CMTPFrameworkConfig::ConstructL()
+    {
+    const TUint32 KUidMTPRepositoryValue(0x10282FCC);
+    const TUid KUidMTPRepository = {KUidMTPRepositoryValue};
+    iRepository = CRepository::NewL(KUidMTPRepository);
+    
+    const TInt KStartupInitValue = 1;
+    iAbnormalDownValue = 0;
+    TInt err(iRepository->Get(EAbnormalDown, iAbnormalDownValue));
+    if ((KErrNone != err ) && (KErrNotFound != err))
+		{
+		User::Leave(err);
+		}
+    
+    //Save the AbnormalDown state to ETrue
+    User::LeaveIfError(iRepository->Set(EAbnormalDown, KStartupInitValue ));
+
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtphandleallocator.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,267 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <mtp/mtpprotocolconstants.h>
+#include "cmtphandleallocator.h"
+#include "tmtptypeobjecthandle.h"
+#include "dbutility.h"
+#include "cmtpobjectstore.h"
+    
+static const TUint KMTPMinimumId = 0x00000000;
+static const TUint KMTPMaximumId = 0x00FFFFFE;
+static const TInt64 KMTPPOUIDStart = -1;
+static const TInt  KMTPMaxDataProviderGranularity = 8;
+#if defined(_DEBUG)
+static const TInt  KMTPMaxDataProviderId = 0x00000100;
+#endif
+
+
+/**
+Two-phase object construction
+*/
+CMTPHandleAllocator* CMTPHandleAllocator::NewL( CMTPObjectStore& aObjectStore )
+	{
+	CMTPHandleAllocator* self = new (ELeave) CMTPHandleAllocator(aObjectStore);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+/**
+destructor
+*/	
+CMTPHandleAllocator::~CMTPHandleAllocator()
+	{
+	iNextIds.Close();
+	
+    iNextIDPool.ResetAndDestroy();
+	}
+
+/**
+Get the next object identifier (Handle) for the specified data provider.
+@param aDataProviderId	The Id of the data provider 
+@return the next object identifier (Handle)
+@leave KErrOverFlow	if the object identifier has been exhausted for the data provider
+*/	
+TUint32 CMTPHandleAllocator::NextIdL(TUint aDataProviderId)
+	{
+	__ASSERT_DEBUG(aDataProviderId < KMTPMaxDataProviderId, User::Invariant());
+	if (aDataProviderId >= iNextIds.Count())
+	    {
+	    ExtendArrayL(aDataProviderId);
+	    }
+	
+	TUint result = ++iNextIds[aDataProviderId];
+	if(result > KMTPMaximumId)
+		{
+		--iNextIds[aDataProviderId];
+        result = NextIDFromPoolL(aDataProviderId);
+		}
+	
+	TMTPTypeObjectHandle handle(result,  aDataProviderId);
+	return handle.Value(); 
+	}
+
+TInt64 CMTPHandleAllocator::NextPOUIDL()
+{
+	return ++iNextPOUID;
+}
+/**
+Initialize the allocator for this DP.  This must be called if and only if the
+DP uses persistent objects, and some persistent objects exist in the object
+store, so that later allocations do not duplicate earlier object IDs.
+If it is called, it must therefore be called before any new objects are
+allocated for this DP.
+@param aDataProviderId	Id of the data provider 
+@param aObjectId Object Id of the largest object already allocated,
+or KMTPHandleNone if no objects have been allocated
+*/
+
+void CMTPHandleAllocator::SetIdL( TUint32 aHandleID, TInt64 aPOUID )
+	{
+	TUint dpID = TMTPTypeObjectHandle::DataProviderID(aHandleID);
+	TUint objID = TMTPTypeObjectHandle::ObjectID(aHandleID);
+
+	__ASSERT_DEBUG(dpID < KMTPMaxDataProviderId, User::Invariant());
+	
+	if ( dpID >= iNextIds.Count())
+	    {
+	    ExtendArrayL(dpID);
+	    }
+	
+	if( objID > iNextIds[dpID] )
+	    {
+	    iNextIds[dpID] = objID ;
+	    }
+	if( aPOUID > iNextPOUID )
+	    {
+	    iNextPOUID = aPOUID;
+	    }
+	}
+
+/**
+Standard C++ constructor
+*/	
+CMTPHandleAllocator::CMTPHandleAllocator( CMTPObjectStore& aObjectStore):
+	iObjectStore(aObjectStore),
+	iNextIds(KMTPMaxDataProviderGranularity),
+	iNextPOUID(KMTPPOUIDStart)
+	{
+	}
+
+/**
+Extends the array to handle more data providers. DP IDs are allocated
+sequentially, so this way the array never needs to be much larger
+than necessary.  This must only be called if the array size needs to be increased.
+@param aDataProviderId the array must be sized to fit this data provider ID
+*/	
+void CMTPHandleAllocator::ExtendArrayL(TUint aDataProviderId)
+	{
+	__ASSERT_DEBUG(aDataProviderId >= iNextIds.Count(), User::Invariant());
+	TInt increase = aDataProviderId - iNextIds.Count() + KMTPMaxDataProviderGranularity;
+	while (increase--)
+		{
+		User::LeaveIfError(iNextIds.Append(KMTPMinimumId));
+		}
+	}
+	
+/**
+Second-phase construction
+*/	
+void CMTPHandleAllocator::ConstructL()
+	{
+	ExtendArrayL(0);
+	}
+
+TBool CMTPHandleAllocator::AppendHandleBlockL( TUint aDataProviderId, TUint aNextID, TInt aSpace )
+    {
+    TInt index = iNextIDPool.FindInOrder( aDataProviderId, CDPHandleCache::HanldeCacheOrderFromKeyAscending );
+    if( index == KErrNotFound )
+        {
+        CDPHandleCache* cache = CDPHandleCache::NewLC(aDataProviderId);
+        iNextIDPool.InsertInOrderL(cache , TLinearOrder<CDPHandleCache>(CDPHandleCache::HanldeCacheOrderFromAscending));
+        CleanupStack::Pop(cache);
+        
+        index = iNextIDPool.FindInOrder( aDataProviderId, CDPHandleCache::HanldeCacheOrderFromKeyAscending );
+        }
+    
+    iNextIDPool[index]->AppendL( CDPHandleCache::THandleBlock( TMTPTypeObjectHandle::ObjectID(aNextID), aSpace) );
+    
+    
+    if(iNextIDPool[index]->BlocksCount() < CDPHandleCache::MaxNumOfBlocks() )
+        {
+        return ETrue;
+        }
+    else
+        {
+        return EFalse;
+        }
+    }
+
+TUint32 CMTPHandleAllocator::NextIDFromPoolL( TUint aDataProviderId )
+    {
+    TInt index = iNextIDPool.FindInOrder( aDataProviderId, CDPHandleCache::HanldeCacheOrderFromKeyAscending );
+    if( index == KErrNotFound )
+        {
+        iObjectStore.CalcFreeHandlesL(aDataProviderId);
+        
+        index = iNextIDPool.FindInOrder( aDataProviderId, CDPHandleCache::HanldeCacheOrderFromKeyAscending );
+        if( index == KErrNotFound )
+            {
+            User::Leave(KErrOverflow);
+            }
+        }
+    
+    TUint32 ret = iNextIDPool[index]->NextHandleID();
+    if( !iNextIDPool[index]->HasCache() )
+        {
+        iNextIDPool.Remove(index);
+        }
+    
+    if(ret > KMTPMaximumId )
+        {
+        User::Leave(KErrOverflow);
+        }
+    
+    return ret;
+    }
+
+CMTPHandleAllocator::CDPHandleCache::THandleBlock::THandleBlock(TUint aNextID, TInt aSpace):
+    iNextID(aNextID),
+    iSpace(aSpace)
+    {
+    }
+
+TInt CMTPHandleAllocator::CDPHandleCache::HanldeCacheOrderFromAscending( const CDPHandleCache& aL, const CDPHandleCache& aR)
+    {
+    return aL.DPID() - aR.DPID();
+    }
+
+TInt CMTPHandleAllocator::CDPHandleCache::HanldeCacheOrderFromKeyAscending( const TUint* aL, const CDPHandleCache& aR)
+    {
+    return (*aL) - aR.DPID();
+    }
+
+CMTPHandleAllocator::CDPHandleCache::CDPHandleCache(TUint aDataProviderId ):
+    iDPID(aDataProviderId)
+    {
+    }
+
+CMTPHandleAllocator::CDPHandleCache::~CDPHandleCache()
+    {
+    iBlocks.Close();
+    }
+
+void CMTPHandleAllocator::CDPHandleCache::ConstructL()
+    {
+    }
+
+CMTPHandleAllocator::CDPHandleCache* CMTPHandleAllocator::CDPHandleCache::NewLC( TUint aDataProviderId )
+    {
+    CDPHandleCache* self = new (ELeave) CDPHandleCache(aDataProviderId);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+TUint32 CMTPHandleAllocator::CDPHandleCache::NextHandleID()
+    {
+    TUint32 ret = KMTPMaximumId + 1;
+    if(iBlocks.Count() == 0)
+        {
+        return ret;
+        }
+    
+    ret = iBlocks[0].iNextID;
+    --iBlocks[0].iSpace;
+    
+    if( 0 == iBlocks[0].iSpace )
+        {
+        iBlocks.Remove(0);
+        }
+    else
+        {
+        iBlocks[0].iNextID++;
+        }
+    
+    return ret;
+    }
+
+void CMTPHandleAllocator::CDPHandleCache::AppendL( const THandleBlock& aBlock )
+    {
+    iBlocks.AppendL( aBlock );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpobjectmgr.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,223 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "cmtpobjectmgr.h"
+#include "cmtpdpidstore.h"
+#include "cmtpobjectstore.h"
+#include "tmtptypeobjecthandle.h"
+#include "cmtppkgidstore.h"
+/**
+MTP object manager information record factory method. This method creates an 
+empty object information record.
+@return A pointer to a new CMTPObjectMetaData instance, ownership IS transferred.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+CMTPObjectMgr* CMTPObjectMgr::NewL()
+    {
+    CMTPObjectMgr* self = new (ELeave) CMTPObjectMgr();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/    
+CMTPObjectMgr::~CMTPObjectMgr()
+    {
+    delete iObjectStore;
+    }
+
+/**
+Provides a reference to the object meta data store.
+@return The object information store.
+*/
+CMTPObjectStore& CMTPObjectMgr::ObjectStore()
+    {
+    return *iObjectStore;
+    }
+
+void CMTPObjectMgr::RestorePersistentObjectsL(TUint aDataProviderId)
+    {
+    iObjectStore->RestorePersistentObjectsL(aDataProviderId);
+    }
+
+EXPORT_C void CMTPObjectMgr::RemoveObjectsByStorageIdL(TUint32 aStorageId)
+	{
+    iObjectStore->RemoveObjectsByStorageIdL(aStorageId);
+	}
+
+void CMTPObjectMgr::RemoveNonPersistentObjectsL(TUint aDataProviderId)
+	{
+	iObjectStore->RemoveNonPersistentObjectsL(aDataProviderId);
+	}
+
+void CMTPObjectMgr::MarkNonPersistentObjectsL(TUint aDataProviderId, TUint32 aStorageId)
+	{
+	iObjectStore->MarkNonPersistentObjectsL(aDataProviderId, aStorageId);
+	}
+      
+void CMTPObjectMgr::MarkDPLoadedL(TUint aDataProviderId, TBool aFlag)
+	{
+	iObjectStore->MarkDPLoadedL(aDataProviderId, aFlag);
+	}
+TUint CMTPObjectMgr::CountL(const TMTPObjectMgrQueryParams& aParams) const
+    {
+    return iObjectStore->CountL(aParams);
+    }
+    
+void CMTPObjectMgr::CommitReservedObjectHandleL(CMTPObjectMetaData& aObjectInfo)
+    {
+    iObjectStore->CommitReservedObjectHandleL(aObjectInfo);
+    }
+    
+void CMTPObjectMgr::GetObjectHandlesL(const TMTPObjectMgrQueryParams& aParams, RMTPObjectMgrQueryContext& aContext, RArray<TUint>& aHandles) const
+    {
+    iObjectStore->GetObjectHandlesL(aParams, aContext, aHandles);
+    }
+    
+void CMTPObjectMgr::GetObjectSuidsL(const TMTPObjectMgrQueryParams& aParams, RMTPObjectMgrQueryContext& aContext, CDesCArray& aSuids) const
+    {
+    iObjectStore->GetObjectSuidsL(aParams, aContext, aSuids);
+    }
+    
+TUint32 CMTPObjectMgr::HandleL(const TDesC& aSuid) const
+    {
+    return iObjectStore->HandleL(aSuid);
+    }
+    
+void CMTPObjectMgr::InsertObjectL(CMTPObjectMetaData& aObject)
+    {
+    iObjectStore->InsertObjectL(aObject);
+    }
+    
+void CMTPObjectMgr::InsertObjectsL(RPointerArray<CMTPObjectMetaData>& aObjects)
+    {
+    iObjectStore->InsertObjectsL(aObjects);
+    }
+void CMTPObjectMgr::InsertDPIDObjectL(TUint aDpId, TUint aUid)
+    {
+    iObjectStore->DPIDStore().InsertDPIDObjectL(aDpId,aUid);
+    }  
+
+void CMTPObjectMgr::InsertPkgIDObjectL(TUint aDpId, TUint aPkgId)
+    {
+    iObjectStore->PkgIDStore().InsertPkgIdL(aDpId,aPkgId);
+    }
+    
+void CMTPObjectMgr::ModifyObjectL(const CMTPObjectMetaData& aObject)
+    {
+    iObjectStore->ModifyObjectL(aObject);
+    }
+    
+TBool CMTPObjectMgr::ObjectL(const TMTPTypeUint32& aHandle, CMTPObjectMetaData& aBuf) const
+    {
+    return iObjectStore->ObjectL(aHandle, aBuf);
+    }
+    
+TBool CMTPObjectMgr::ObjectL(const TDesC& aSuid, CMTPObjectMetaData& aBuf) const            
+    {
+    return iObjectStore->ObjectL(aSuid, aBuf);
+    }
+    
+TUint CMTPObjectMgr::ObjectOwnerId(const TMTPTypeUint32& aHandle) const
+    {
+    return iObjectStore->ObjectOwnerId(aHandle);
+    }
+
+TUint CMTPObjectMgr::DPIDL(const TUint aUid, TBool& aFlag) const
+    {
+    return iObjectStore->DPIDStore().DPIDL(aUid, aFlag);
+    }    
+
+TMTPTypeUint128 CMTPObjectMgr::PuidL(TUint32 aHandle) const
+    {
+    return iObjectStore->PuidL(aHandle);
+    }
+    
+    
+TMTPTypeUint128 CMTPObjectMgr::PuidL(TInt64 /*aObjectUid*/) const
+    {
+    User::Leave(KErrNotSupported);
+    return TMTPTypeUint128(0);
+    }
+    
+TMTPTypeUint128 CMTPObjectMgr::PuidL(const TDesC& aSuid) const
+    {
+    return iObjectStore->PuidL(aSuid);
+    }
+    
+void CMTPObjectMgr::RemoveObjectL(const TMTPTypeUint32& aHandle)
+    {
+    iObjectStore->RemoveObjectL(aHandle);
+    }
+    
+void CMTPObjectMgr::RemoveObjectL(const TDesC& aSuid)
+    {
+    iObjectStore->RemoveObjectL(aSuid);
+    }
+    
+void CMTPObjectMgr::RemoveObjectsL(const CDesCArray& aSuids)
+    {
+    iObjectStore->RemoveObjectsL(aSuids);
+    }
+    
+void CMTPObjectMgr::RemoveObjectsL(TUint aDataProviderId)
+    {
+    iObjectStore->RemoveObjectsL(aDataProviderId);
+    }
+    
+void CMTPObjectMgr::ReserveObjectHandleL(CMTPObjectMetaData& aObjectInfo, TUint64 aSpaceRequired)
+    {
+    iObjectStore->ReserveObjectHandleL(aObjectInfo, aSpaceRequired);
+    }
+    
+void CMTPObjectMgr::UnreserveObjectHandleL(const CMTPObjectMetaData& aObjectInfo)
+    {
+    iObjectStore->UnreserveObjectHandleL(aObjectInfo);
+    }
+
+/**
+Standard C++ constructor
+*/    	
+CMTPObjectMgr::CMTPObjectMgr()
+    {
+    }
+
+/**
+second phase construction
+*/    
+void CMTPObjectMgr::ConstructL()
+    {
+    iObjectStore = CMTPObjectStore::NewL();
+    }
+
+/**
+return MtpDeltaDataMgr
+*/    
+TAny* CMTPObjectMgr::MtpDeltaDataMgr()
+    {
+    return 	iObjectStore->MtpDeltaDataMgr();
+    }
+
+
+    
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpobjectstore.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1302 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+#include <bautils.h>
+#include <f32file.h>
+#include <s32file.h>
+#include "tmtptypeobjecthandle.h"
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/cmtptypearray.h>
+#include <mtp/mmtpobjectmgr.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mtpobjectmgrquerytypes.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptypeuint32.h>
+#include "cmtphandleallocator.h"
+#include "cmtpobjectstore.h"
+#include "cmtpreferencemgr.h"
+#include "dbutility.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpdataprovider.h"
+#include "cmtpdpidstore.h"
+#include "cmtppkgidstore.h"
+#include "cmtpdeltadatamgr.h"
+#include <e32hashtab.h>
+#include "cmtpstoragemgr.h"
+
+_LIT(KMTPDbDriveLocation, "c:");
+_LIT(KMTPBackSlash, "\\");
+_LIT(KMTPHandleObjectDbName, "MTPObjectStore.db");
+_LIT(KMTPNoBackupFolderName, "nobackup");
+_LIT(KSQLHandleTableName, "HandleStore");
+_LIT(KSQLCreateHandleTableText, "CREATE TABLE HandleStore (HandleId UNSIGNED INTEGER, SuidHash UNSIGNED INTEGER, Suid LONG VARCHAR, DataProviderId UNSIGNED TINYINT, FormatCode UNSIGNED SMALLINT, FormatSubCode UNSIGNED SMALLINT, StorageId UNSIGNED INTEGER, Modes UNSIGNED TINYINT, POUID BIGINT, ParentHandle UNSIGNED INTEGER, DPFlag UNSIGNED TINYINT, NonConsumable UNSIGNED TINYINT, Name VARCHAR(255))");
+_LIT(KSQLHandleId, "HandleIndex");
+_LIT(KSQLCreateHandleIndexText,"CREATE UNIQUE INDEX HandleIndex on HandleStore (HandleId)");
+_LIT(KSQLSuidHash, "SuidIndex");
+_LIT(KSQLCreateSuidIndexText,"CREATE INDEX SuidIndex on HandleStore (SuidHash)");
+_LIT(KSQLParentHandle, "ParentHandleIndex");
+_LIT(KSQLCreateParentHandleText,"CREATE INDEX ParentHandleIndex on HandleStore (ParentHandle)");
+_LIT(KMTPFormat, "MTP");
+__FLOG_STMT(_LIT8(KComponent,"MTPObjectStore");)
+const TInt KMaxLimitCommitInEnumeration = 1024;
+const TInt KMaxLimitCommitAfterEnumeration = 256;
+const TInt KMaxLimitCompactInEnumeration = 2048;
+const TInt KMaxLimitCompactAfterEnumeration = 1024;
+/**
+ MTP object meta data store factory method. 
+ @return A pointer to a new CMTPObjectStore instance, ownership IS transferred.
+ @leave One of the system wide error codes, if a processing failure occurs.
+ */
+CMTPObjectStore* CMTPObjectStore::NewL()
+	{
+	CMTPObjectStore* self = new (ELeave) CMTPObjectStore();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+ Destructor.
+ */
+CMTPObjectStore::~CMTPObjectStore()
+	{
+	delete iCompactor;
+	delete iReferenceMgr;
+	delete iHandleAllocator;
+	delete iMtpDeltaDataMgr;
+	delete iDPIDStore;
+	delete iPkgIDStore;
+	delete iSentinal;
+	TRAP_IGNORE(CommitTransactionL());
+	iDatabase.Compact();
+	iBatched.Close();
+	iBatched_SuidHashID.Close();
+	CloseDb();
+	iSingletons.Close();
+	iNonPersistentDPList.Close();
+	iEnumeratingCacheObjList.ResetAndDestroy();
+	__FLOG_CLOSE;
+	}
+
+/**
+ Provides a reference to the object meta data store database.
+ @return The object information store database.
+ */
+RDbDatabase& CMTPObjectStore::Database()
+	{
+	return iDatabase;
+	}
+
+/**
+ Provides a reference to the DPID store object.
+ @return The DPID store.
+ */
+CMTPDPIDStore& CMTPObjectStore::DPIDStore() const
+	{
+	return *iDPIDStore;
+	}
+
+CMTPPkgIDStore& CMTPObjectStore::PkgIDStore() const
+	{
+	return *iPkgIDStore;
+	}
+
+/**
+ Provides a reference to the reference manager object.
+ @return The reference manager.
+ */
+CMTPReferenceMgr& CMTPObjectStore::ReferenceMgr() const
+	{
+	return *iReferenceMgr;
+	}
+
+/**
+Provides a reference to the MTP delta Data manager object.
+@return The MTP delta data manager.
+*/ 
+CMtpDeltaDataMgr* CMTPObjectStore:: MtpDeltaDataMgr() const
+	{
+	return iMtpDeltaDataMgr;
+	}
+
+void CMTPObjectStore::RemoveNonPersistentObjectsL(TUint /*aDataProviderId*/)
+	{
+	}
+
+void CMTPObjectStore::MarkNonPersistentObjectsL(TUint aDataProviderId, TUint32)
+	{
+	TInt result = iNonPersistentDPList.InsertInOrder(aDataProviderId);
+	if(result != KErrAlreadyExists)
+		{
+		User::LeaveIfError(result);
+		}
+	}
+
+void CMTPObjectStore::MarkDPLoadedL(TUint aDataProviderId, TBool aFlag)
+	{
+	__FLOG(_L8("MarkDPFlafFalseL - Entry"));
+	if (!aFlag)
+		{
+		_LIT(KSQLMarkfalgDPFalse, "UPDATE HandleStore SET DPFlag = %u WHERE DataProviderId = %u");
+		iSqlStatement.Format(KSQLMarkfalgDPFalse, aFlag, aDataProviderId);
+		User::LeaveIfError(iDatabase.Execute(iSqlStatement));
+		}
+	__FLOG(_L8("MarkNonPersistentObjectsL - Exit"));
+	}
+
+TBool CMTPObjectStore::FilterObject(const RDbTable& aCurrRow,const TUint32 aStorageID,const TUint32 aFormatCode,const TUint32 aDpID) const
+    {
+    return  ( ((KMTPStorageAll==aStorageID) ||(aCurrRow.ColUint32(EObjectStoreStorageId)== aStorageID)) 
+            
+            &&((0 == aFormatCode)||(aCurrRow.ColUint16(EObjectStoreFormatCode) == aFormatCode)) 
+            
+            &&((aDpID==KMTPDataProviderAll)||(aCurrRow.ColUint8(EObjectStoreDataProviderId) == aDpID ))
+            );
+    }
+
+
+void CMTPObjectStore::TraverseL(const TMTPObjectMgrQueryParams& aParams, MTraverseAction& action) const
+	{
+	RDbTable temp;
+	CleanupClosePushL(temp);
+	temp.Open(iDatabase, KSQLHandleTableName, RDbRowSet::EUpdatable);
+
+	TUint32 tmpStorageID = 0;
+	TBool bStorageAvailable = ETrue;
+	
+	if (aParams.iParentHandle == 0)
+		{//ParentHandle is not used to filter the objects. Need to iterate throught all objects in the storage to filter based on format/dpid/storatgeid.
+		//Do not using index to iterate through the whole storage is faster than index iteration.
+		temp.FirstL();
+		while (!temp.AtEnd())
+			{
+			temp.GetL();
+			if ((MTraverseAction::EAllDP == action.Target()) || (temp.ColUint8(EObjectStoreDPFlag) == 1))//If the DP is loaded or ation for all dps.
+				{
+
+				if((aParams.iStorageId == KMTPStorageAll) &&(aParams.iFormatCode == 0)&&(iSingletons.DpController().DataProviderL(temp.ColUint8(EObjectStoreDataProviderId)).SupportedCodes( EServiceIDs ).Count() != 0))
+				    {
+				    temp.NextL();
+				    continue;
+				    }
+				
+				//check StorageID ,DPID and Formatcode
+				if ( !FilterObject(temp,aParams.iStorageId,aParams.iFormatCode,aParams.iDpId) )
+				    {
+						temp.NextL();
+						continue;
+				    }
+				    
+				//verify the whether the storageID is validated.   
+				if(tmpStorageID != temp.ColUint32(EObjectStoreStorageId))
+					{
+					tmpStorageID = temp.ColUint32(EObjectStoreStorageId);
+					bStorageAvailable = iSingletons.StorageMgr().ValidStorageId( tmpStorageID );
+					}
+				if(!bStorageAvailable)
+					{
+					temp.NextL();
+					continue;
+					}
+								
+				action.DoL(temp); 
+				}
+			temp.NextL();
+			}
+		}
+	else
+		{//Fetch the root directory
+		temp.SetIndex(KSQLParentHandle);
+		if (temp.SeekL((TUint) aParams.iParentHandle))
+			{//every storageID has the same root directory handles.KMTPHandleNoParent, therefore, need to filter the storageID
+			//if it is not KMTPStorageAll
+			while (!temp.AtEnd())
+				{
+				temp.GetL();
+				if (temp.ColUint32(EObjectStoreParentHandle) == aParams.iParentHandle)
+					{
+					if ((MTraverseAction::EAllDP == action.Target()) || (temp.ColUint8(EObjectStoreDPFlag) == 1))//If the DP is loaded or ation for all dps.
+						{
+						
+            if((aParams.iStorageId == KMTPStorageAll) &&(aParams.iFormatCode == 0)&&(iSingletons.DpController().DataProviderL(temp.ColUint8(EObjectStoreDataProviderId)).SupportedCodes( EServiceIDs ).Count() != 0))
+                {
+                temp.NextL();
+                continue;
+                }
+		                
+						//check StorageID ,DPID and Formatcode
+						if ( !FilterObject(temp,aParams.iStorageId,aParams.iFormatCode,aParams.iDpId) )
+						    {
+								temp.NextL();
+								continue;
+						    }
+						    
+						//verify the whether the storageID is validated.   
+						if(tmpStorageID != temp.ColUint32(EObjectStoreStorageId))
+							{
+							tmpStorageID = temp.ColUint32(EObjectStoreStorageId);
+							bStorageAvailable = iSingletons.StorageMgr().ValidStorageId( tmpStorageID );
+							}
+						if(!bStorageAvailable)
+							{
+							temp.NextL();
+							continue;
+							}
+		                
+						action.DoL(temp);
+						}
+					temp.NextL();
+					}
+				else
+					{
+					break;//has jumped over the range of handles with the same parent handle
+					}
+				}
+			}
+		}
+	CleanupStack::PopAndDestroy(&temp);
+	//Since we fetch all handles as requested, therefore, we do not open aContext to indicate the query is completed.
+	}
+
+TUint CMTPObjectStore::CountL(const TMTPObjectMgrQueryParams& aParams) const
+	{
+	TUint i = 0;
+	TCountAction action(i);
+	TraverseL(aParams, action);
+	return i;
+	}
+
+void CMTPObjectStore::CommitReservedObjectHandleL(CMTPObjectMetaData& aObject)
+	{
+	//After the PutL called the cursor's position is not well defined.
+	iCachedHandle = 0;
+	iCachedSuidHash = 0;
+	TInt64 id = iHandleAllocator->NextPOUIDL();
+	aObject.SetUint(CMTPObjectMetaData::EIdentifier, id);
+
+	TFileName suid;
+	suid.CopyLC(aObject.DesC(CMTPObjectMetaData::ESuid));
+	TUint32 suidHash = DefaultHash::Des16(suid);
+
+	TUint32 handle = aObject.Uint(CMTPObjectMetaData::EHandle);
+	CleanupStack::PushL(TCleanupItem(CMTPObjectStore::DBUpdateFailRecover, &iBatched));
+	iBatched.InsertL();
+	iBatched.SetColL(EObjectStoreHandleId, handle);
+	iBatched.SetColL(EObjectStoreSUIDHash, suidHash);
+	DbColWriteStreamL(iBatched, EObjectStoreSUID, aObject.DesC(CMTPObjectMetaData::ESuid));	
+	iBatched.SetColL(EObjectStoreDataProviderId, aObject.Uint(CMTPObjectMetaData::EDataProviderId));
+	iBatched.SetColL(EObjectStoreFormatCode, aObject.Uint(CMTPObjectMetaData::EFormatCode));
+	iBatched.SetColL(EObjectStoreFormatSubCode, aObject.Uint(CMTPObjectMetaData::EFormatSubCode));
+	iBatched.SetColL(EObjectStoreStorageId, aObject.Uint(CMTPObjectMetaData::EStorageId));
+	iBatched.SetColL(EObjectStoreModes,aObject.Uint(CMTPObjectMetaData::EModes));
+	iBatched.SetColL(EObjectStorePOUID, id);
+	iBatched.SetColL(EObjectStoreParentHandle, aObject.Uint(CMTPObjectMetaData::EParentHandle));
+	iBatched.SetColL(EObjectStoreDPFlag, 1);
+	iBatched.SetColL(EObjectStoreNonConsumable, aObject.Uint(CMTPObjectMetaData::ENonConsumable));
+	iBatched.SetColL(EObjectStoreName, aObject.DesC(CMTPObjectMetaData::EName));
+	
+	iBatched.PutL();
+	CleanupStack::Pop(&iBatched);
+	IncTranOpsNumL();
+
+	}
+
+/*
+ This API is designed intended for coping with the MTP operation GetObjectHandles which has 3 parameters.
+ 1. StorageID
+ 2. FormatCode
+ 3. ParentHandle.
+
+ The first parameter contains the StorageID of the storage for which the list of Object Handles is desired. 
+ A value of 0xFFFFFFFF may be used to indicate that a list of Object Handles of all objects on all storages 
+ should be returned. If a storage is specified and the storage is unavailable, this operation should return Store_Not_Available.
+
+ The second parameter is optional, and contains an Object Format datacode. Object Formats are described
+ in section 4, "Object Formats". If the second parameter contains a non-0x00000000 value, it specifies that 
+ a list of object handles referencing objects of a certain object format is desired. If the parameter is not used, 
+ it should contain a value of 0x00000000 and objects should be included in the response dataset regardless 
+ of their object format. If this parameter is not supported, the responder should return a response code of 
+ Specification_By_Format_Unsupported.
+
+ The third parameter may be used to restrict the list of objects that are returned by this operation to objects 
+ directly contained in a particular folder (Association). If this parameter contains a non-0x00000000 value, 
+ the responder should return a list of objects which have as their ParentObject the folder (Association) 
+ that is identified by this parameter. If the number of objects that are contained in the root of a storage is desired, 
+ a value of 0xFFFFFFFF may be passed in this operation, which indicates that only those objects with no ParentObject
+ should be returned. If the first parameter indicates that all storages are included in this query, then a value of 0xFFFFFFFF
+ should return a list of all objects at the root level of all storages. If this parameter is unused, it should contain a value of 0x00000000. 
+
+ If the third parameter is unsupported and a non-0x00000000 value is sent in this operation, a response of 
+ Parameter_Unsupported should be returned. If the use of the third parameter is supported, but the value 
+ contained does not reference an actual object on the device, a response of Invalid_ObjectHandle should be returned. 
+ If the use of the third parameter is supported and it contains a valid Object Handle, but the object referenced 
+ is not of type Association, then a response of Invalid_ParentObject should be returned.
+
+
+ */
+void CMTPObjectStore::GetObjectHandlesL(const TMTPObjectMgrQueryParams& aParams, RMTPObjectMgrQueryContext& /*aContext*/, RArray<TUint>& aHandles) const
+	{
+	TGetHandlesAction action(aHandles);
+	TraverseL(aParams, action);
+	}
+
+void CMTPObjectStore::GetObjectSuidsL(const TMTPObjectMgrQueryParams& aParams, RMTPObjectMgrQueryContext& /*aContext*/, CDesCArray& aSuids) const
+	{
+	//take the similar approach for GetObjectHandlesL, but need to pay attention for the memory usage, since every SUID might take
+	//maximum 255 bytes, if there are totally 10K objects, the maximum memory usage will be 2.5M, consider to get it in multiple calls instead of one.
+	TGetSuidsAction action(aSuids);
+	TraverseL(aParams, action);
+	}
+
+TUint32 CMTPObjectStore::HandleL(const TDesC& aSuid) const
+	{
+	TUint32 handle = KMTPHandleNone;
+	if (LocateBySuidL(aSuid))
+		{
+		handle = iBatched_SuidHashID.ColUint32(EObjectStoreHandleId);
+		}
+	return handle;
+	}
+
+void CMTPObjectStore::DBUpdateFailRecover(TAny* aTable)
+	{
+	reinterpret_cast<RDbTable*> (aTable)->Cancel();
+	}
+
+void CMTPObjectStore::InsertObjectL(CMTPObjectMetaData& aObject)
+	{
+	//_LIT(KInsert, "CMTPObjectStore::InsertObjectL");
+	//volatile TTimer t(KInsert);
+	__FLOG(_L8("InsertObjectL - Entry"));
+	iCachedHandle = 0;
+	iCachedSuidHash = 0;
+	TBool needToInsert = EFalse;
+	TBool needUpdateOwner = EFalse;
+	TUint dpId(aObject.Uint(CMTPObjectMetaData::EDataProviderId));
+	TFileName suid;
+	suid.CopyLC(aObject.DesC(CMTPObjectMetaData::ESuid));
+	TUint32 suidHash = DefaultHash::Des16(suid);
+	TUint32 parentHandle = aObject.Uint(CMTPObjectMetaData::EParentHandle);
+	TUint32 handle = KMTPHandleNone, handleInDB = KMTPHandleAll;
+	TInt64 id = 0;
+	// Check if the dp is enumerating
+	if (iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumerated && iCacheExist)
+		{
+		//it is in the object enumeration phase. 
+		// if it's see if we have an object with the same SUID
+		//When the MTP server startup the object enumeration, it will fetch all of the object's (SUIDHash and Handles) into in-memory ordered array.
+		//this function is to try to match the handleID for the incoming suidHash/SUID/DPID, if matched in memory, it will return the handleID
+		//considering the possible conflicting of the SUID for different file name, it need to consult the SUID in the table for eactly match.
+		//Therefore, for each object matching, it need one table lookup and file name cope and match operation.
+		//If it matched, do nothing for the table, but remove it from the in-memory ordered array.
+		//if there is no match, it is a new object, insert it into table.
+		iSentinal->iObjSuiIdHash = suidHash;
+		iSentinal->iSuidPtr.Set(aObject.DesC(CMTPObjectMetaData::ESuid));
+		TInt found = iEnumeratingCacheObjList.FindInOrder(iSentinal, TLinearOrder<CEnumertingCacheItem>(CEnumertingCacheItem::Compare));
+		if (KErrNotFound != found)
+			{//There is a match
+			if(NULL == iEnumeratingCacheObjList[found]->iSuid)
+				{//need extra check for hash collision
+				handleInDB = HandleL(aObject.DesC(CMTPObjectMetaData::ESuid));
+				}
+			handle = iEnumeratingCacheObjList[found]->iObjHandleId;
+			if((handleInDB != KMTPHandleAll) && (handleInDB != handle)) //hash collision
+				{
+				needToInsert = ETrue;
+				}
+			else
+				{
+				aObject.SetUint(CMTPObjectMetaData::EHandle, handle);
+				id = iEnumeratingCacheObjList[found]->iPOUID;
+				aObject.SetUint(CMTPObjectMetaData::EIdentifier, id);
+				if(iEnumeratingCacheObjList[found]->iFormatcode != aObject.Uint(CMTPObjectMetaData::EFormatCode))
+					{//have different owner
+					needUpdateOwner = ETrue;
+					}
+				delete iEnumeratingCacheObjList[found];
+				iEnumeratingCacheObjList.Remove(found);
+				}
+			}
+		else
+			{//This is a totally new object. insert it after check the db to prevent user wrong operation
+			handle = HandleL(aObject.DesC(CMTPObjectMetaData::ESuid));
+			if (handle == KMTPHandleNone)
+				{
+				needToInsert = ETrue;
+				}
+			else
+				{
+				User::Leave(KErrAlreadyExists);
+				}
+			}
+		}
+	else
+		{
+		handle = HandleL(aObject.DesC(CMTPObjectMetaData::ESuid));
+		if (handle != KMTPHandleNone)
+			{
+				//Leaves if id already exists in suid map table 
+			User::Leave(KErrAlreadyExists);
+			}
+		// dp is not enumerating, do a plain insert
+		needToInsert = ETrue;
+		}
+	if (needToInsert)//needToInsert and needUpdateOwner can't be true at same time
+		{
+		TUint32 parentHandle(aObject.Uint(CMTPObjectMetaData::EParentHandle));
+		handle = iHandleAllocator->NextIdL(dpId);
+		id = iHandleAllocator->NextPOUIDL();
+		aObject.SetUint(CMTPObjectMetaData::EHandle, handle);
+		aObject.SetUint(CMTPObjectMetaData::EIdentifier, id);
+		CleanupStack::PushL(TCleanupItem(CMTPObjectStore::DBUpdateFailRecover, &iBatched));
+		iBatched.InsertL();
+		iBatched.SetColL(EObjectStoreHandleId, handle);
+		iBatched.SetColL(EObjectStoreSUIDHash, suidHash);
+		DbColWriteStreamL(iBatched, EObjectStoreSUID, aObject.DesC(CMTPObjectMetaData::ESuid));
+		iBatched.SetColL(EObjectStoreDataProviderId, aObject.Uint(CMTPObjectMetaData::EDataProviderId));
+		iBatched.SetColL(EObjectStoreFormatCode, aObject.Uint(CMTPObjectMetaData::EFormatCode));
+		iBatched.SetColL(EObjectStoreFormatSubCode, aObject.Uint(CMTPObjectMetaData::EFormatSubCode));
+		iBatched.SetColL(EObjectStoreStorageId, aObject.Uint(CMTPObjectMetaData::EStorageId));
+		iBatched.SetColL(EObjectStoreModes, aObject.Uint(CMTPObjectMetaData::EModes));
+		iBatched.SetColL(EObjectStorePOUID, id);
+		iBatched.SetColL(EObjectStoreParentHandle, parentHandle);
+		iBatched.SetColL(EObjectStoreDPFlag, 1);
+		iBatched.SetColL(EObjectStoreNonConsumable, aObject.Uint(CMTPObjectMetaData::ENonConsumable));
+		iBatched.SetColL(EObjectStoreName, aObject.DesC(CMTPObjectMetaData::EName));
+		iBatched.PutL();
+		CleanupStack::Pop(&iBatched);
+		IncTranOpsNumL();
+		}
+	else if(needUpdateOwner)
+		{
+		if(iBatched.SeekL(static_cast<TUint>(handle)))
+			{
+			CleanupStack::PushL(TCleanupItem(CMTPObjectStore::DBUpdateFailRecover, &iBatched));
+			iBatched.UpdateL();
+			iBatched.SetColL(EObjectStoreDataProviderId, aObject.Uint(CMTPObjectMetaData::EDataProviderId));
+			iBatched.SetColL(EObjectStoreFormatCode, aObject.Uint(CMTPObjectMetaData::EFormatCode));
+			iBatched.SetColL(EObjectStoreFormatSubCode, aObject.Uint(CMTPObjectMetaData::EFormatSubCode));
+			iBatched.SetColL(EObjectStoreStorageId, aObject.Uint(CMTPObjectMetaData::EStorageId));
+			iBatched.SetColL(EObjectStoreModes, aObject.Uint(CMTPObjectMetaData::EModes));
+			iBatched.SetColL(EObjectStoreNonConsumable, aObject.Uint(CMTPObjectMetaData::ENonConsumable));
+			iBatched.SetColL(EObjectStoreName, aObject.DesC(CMTPObjectMetaData::EName));
+			iBatched.PutL();
+			CleanupStack::Pop(&iBatched);
+			IncTranOpsNumL();	
+			}
+		}
+	if ((needToInsert || needUpdateOwner) && IsMediaFormat(aObject.Uint(CMTPObjectMetaData::EFormatCode)))
+		{
+		if (iUpdateDeltaDataTable)
+			{
+			iMtpDeltaDataMgr->UpdateDeltaDataTableL(id, CMtpDeltaDataMgr::EAdded);
+			}
+		}
+
+	__FLOG(_L8("InsertObjectL - Exit"));
+	}
+
+void CMTPObjectStore::IncTranOpsNumL()
+	{
+	iTransactionOps++;
+	if (iTransactionOps % iMaxCommitLimit == 0)
+		{
+		CommitTransactionL();
+		if (iTransactionOps % iMaxCompactLimit == 0)
+			{
+			User::LeaveIfError(iDatabase.Compact());
+			}
+		BeginTransactionL();
+		}
+	}
+
+void CMTPObjectStore::BeginTransactionL()
+	{
+	if (!iDatabase.InTransaction())
+		{
+		User::LeaveIfError(iDatabase.Begin());
+		}
+	}
+
+void CMTPObjectStore::CommitTransactionL()
+	{
+	if (iDatabase.InTransaction())
+		{
+		User::LeaveIfError(iDatabase.Commit());
+		}
+	}
+
+void CMTPObjectStore::InsertObjectsL(RPointerArray<CMTPObjectMetaData>& aObjects)
+	{
+	TInt count = aObjects.Count();
+	for (TInt i = 0; i < count; i++)
+		{
+		InsertObjectL(*aObjects[i]);
+		}
+	}
+
+void CMTPObjectStore::ModifyObjectL(const CMTPObjectMetaData& aObject)
+	{
+	TUint32 handle = aObject.Uint(CMTPObjectMetaData::EHandle);
+	TFileName suid;
+	suid.CopyLC(aObject.DesC(CMTPObjectMetaData::ESuid));
+	TUint32 suidHash = DefaultHash::Des16(suid);
+
+	if (LocateByHandleL(handle))
+		{
+		//After the PutL called the cursor's position is not well defined.
+		iCachedHandle = 0;
+		iCachedSuidHash = 0;
+		TInt64 id = iBatched.ColInt64(EObjectStorePOUID);
+		TUint32 suidHashOld = iBatched.ColUint32(EObjectStoreSUIDHash);
+		TUint32 parentOld = iBatched.ColUint32(EObjectStoreParentHandle);
+		CleanupStack::PushL(TCleanupItem(CMTPObjectStore::DBUpdateFailRecover, &iBatched));
+		iBatched.UpdateL();
+		if(suidHashOld != suidHash)
+			{//change on index column will impact the performace
+			iBatched.SetColL(EObjectStoreSUIDHash, suidHash);
+			}
+		if(parentOld != aObject.Uint(CMTPObjectMetaData::EParentHandle))
+			{//change on index column will impact the performace
+			iBatched.SetColL(EObjectStoreParentHandle, aObject.Uint(CMTPObjectMetaData::EParentHandle));
+			}
+
+		DbColWriteStreamL(iBatched, EObjectStoreSUID, aObject.DesC(CMTPObjectMetaData::ESuid));		
+		iBatched.SetColL(EObjectStoreDataProviderId, aObject.Uint(CMTPObjectMetaData::EDataProviderId));
+		iBatched.SetColL(EObjectStoreFormatCode, aObject.Uint(CMTPObjectMetaData::EFormatCode));
+		iBatched.SetColL(EObjectStoreFormatSubCode, aObject.Uint(CMTPObjectMetaData::EFormatSubCode));
+		iBatched.SetColL(EObjectStoreStorageId, aObject.Uint(CMTPObjectMetaData::EStorageId));
+		iBatched.SetColL(EObjectStoreModes, aObject.Uint(CMTPObjectMetaData::EModes));
+		iBatched.SetColL(EObjectStoreDPFlag, 1);
+		iBatched.SetColL(EObjectStoreNonConsumable, aObject.Uint(CMTPObjectMetaData::ENonConsumable));
+		iBatched.SetColL(EObjectStoreName, aObject.DesC(CMTPObjectMetaData::EName));
+		iBatched.PutL();
+		CleanupStack::Pop(&iBatched);
+		IncTranOpsNumL();
+		if (aObject.Uint(CMTPObjectMetaData::EObjectMetaDataUpdate) && IsMediaFormat(aObject.Uint(CMTPObjectMetaData::EFormatCode)))
+			{
+			if (iUpdateDeltaDataTable)
+				{
+				iMtpDeltaDataMgr->UpdateDeltaDataTableL(id, CMtpDeltaDataMgr::EModified);
+				}
+			}
+		}
+	else
+		{
+		User::Leave(KErrNotFound);
+		}
+	}
+
+TBool CMTPObjectStore::ObjectL(const TMTPTypeUint32& aHandle, CMTPObjectMetaData& aBuf) const
+	{
+	TUint32 handleId = aHandle.Value();
+	aBuf.SetUint(CMTPObjectMetaData::EHandle, handleId);
+	return GetObjectL(handleId, aBuf);
+	}
+
+TBool CMTPObjectStore::ObjectExistsL(const TUint32 aHandle)
+	{
+	return LocateByHandleL(aHandle, EFalse);
+	}
+
+
+void CMTPObjectStore::BuildObjectMetaDataL(CMTPObjectMetaData& aBuf, const RDbTable& aTable) const
+	{
+	aBuf.SetUint(CMTPObjectMetaData::EHandle, aTable.ColUint32(EObjectStoreHandleId));
+
+	TFileName suid;
+    DbColReadStreamL(aTable, EObjectStoreSUID, suid);
+    aBuf.SetDesCL(CMTPObjectMetaData::ESuid, suid);
+
+	aBuf.SetUint(CMTPObjectMetaData::EFormatCode, aTable.ColUint16(EObjectStoreFormatCode));
+	aBuf.SetUint(CMTPObjectMetaData::EFormatSubCode, aTable.ColUint16(EObjectStoreFormatSubCode));
+	aBuf.SetUint(CMTPObjectMetaData::EDataProviderId, aTable.ColUint8(EObjectStoreDataProviderId));
+	aBuf.SetUint(CMTPObjectMetaData::EParentHandle, aTable.ColUint32(EObjectStoreParentHandle));
+	aBuf.SetUint(CMTPObjectMetaData::EStorageId, aTable.ColUint32(EObjectStoreStorageId));
+	aBuf.SetUint(CMTPObjectMetaData::EModes, aTable.ColUint8(EObjectStoreModes));
+	aBuf.SetUint(CMTPObjectMetaData::EIdentifier, aTable.ColInt64(EObjectStorePOUID));
+	aBuf.SetUint(CMTPObjectMetaData::ENonConsumable, aTable.ColUint8(EObjectStoreNonConsumable));
+	aBuf.SetDesCL(CMTPObjectMetaData::EName, aTable.ColDes(EObjectStoreName));
+	}
+
+TBool CMTPObjectStore::ObjectL(const TDesC& aSuid, CMTPObjectMetaData& aBuf) const
+	{
+	if (LocateBySuidL(aSuid))
+		{
+		BuildObjectMetaDataL(aBuf, iBatched_SuidHashID);
+		return ETrue;
+		}
+	return EFalse;
+	}
+
+const TPtrC CMTPObjectStore::ObjectSuidL(TUint32 aHandle) const
+	{
+	//iBatched owns the memory of Suid ?
+	if (!LocateByHandleL(aHandle))
+		{
+		User::Leave(KErrNotFound);
+		}
+    DbColReadStreamL(iBatched, EObjectStoreSUID, iSuidBuf);
+	return iSuidBuf;
+	}
+
+TMTPTypeUint128 CMTPObjectStore::PuidL(TUint32 aHandle)
+	{
+	if (!LocateByHandleL(aHandle))
+		{
+		User::Leave(KErrNotFound);
+		}
+	TUint64 highHalfPOUID = static_cast<TUint64> (iBatched.ColInt64(EObjectStorePOUID));
+	// We actually use the first 64 bits to represent the PUID. this will represent 2^64=16 G xG objects, it is reasonable 
+	//to assume the Phone, as a resource-constrained device, never will reach that number, therefore, we choose
+	//only 64 bit to represent the POUID Of the objects on phone.
+	TMTPTypeUint128 result;
+	result.Set(1, highHalfPOUID);	//for the ONB
+	return result;
+	}
+
+TMTPTypeUint128 CMTPObjectStore::PuidL(const TDesC& aSuid)
+	{
+	if (!LocateBySuidL(aSuid))
+		{
+		User::Leave(KErrNotFound);
+		}
+	TUint64 highHalfPOUID = static_cast<TUint64> (iBatched_SuidHashID.ColInt64(EObjectStorePOUID));
+	// We actually use the first 64 bits to represent the PUID. this will represent 2^64=16 G xG objects, it is reasonable 
+	//to assume the Phone, as a resource-constrained device, never will reach that number, therefore, we choose
+	//only 64 bit to represent the POUID Of the objects on phone.
+	TMTPTypeUint128 result;
+	result.Set(1, highHalfPOUID);	//for the ONB
+	return result;
+	}
+
+void CMTPObjectStore::RemoveObjectL(const TMTPTypeUint32& aHandle)
+	{
+	if (LocateByHandleL(aHandle.Value()))
+		{
+		if (iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumerated &&
+			IsMediaFormat(iBatched.ColUint16(EObjectStoreFormatCode)))
+			{
+			iMtpDeltaDataMgr->UpdateDeltaDataTableL(iBatched.ColInt64(EObjectStorePOUID), CMtpDeltaDataMgr::EDeleted);
+			}
+		iCachedSuidHash = 0;
+		iCachedHandle = 0;
+		iBatched.DeleteL();
+		IncTranOpsNumL();
+		}
+	}
+
+void CMTPObjectStore::RemoveObjectL(const TDesC& aSuid)
+	{
+	if(LocateBySuidL(aSuid))
+		{
+		if (iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumerated &&
+			IsMediaFormat(iBatched_SuidHashID.ColUint16(EObjectStoreFormatCode)))
+			{
+			iMtpDeltaDataMgr->UpdateDeltaDataTableL(iBatched_SuidHashID.ColInt64(EObjectStorePOUID), CMtpDeltaDataMgr::EDeleted);
+			}
+		iCachedSuidHash = 0;
+		iCachedHandle = 0;
+		iBatched_SuidHashID.DeleteL();
+		IncTranOpsNumL();
+		}
+	}
+
+void CMTPObjectStore::RemoveObjectsL(const CDesCArray& aSuids)
+	{
+	TUint i(aSuids.Count());
+	while (i--)
+		{
+		RemoveObjectL(aSuids[i]);
+		}
+	}
+
+void CMTPObjectStore::RemoveObjectsL(TUint aDataProviderId)
+	{
+	iCachedSuidHash = 0;
+	iCachedHandle = 0;
+	TMTPObjectMgrQueryParams params(KMTPStorageAll, 0, 0, aDataProviderId);
+	TDelAction action(*this, MTraverseAction::EAllDP);
+	TraverseL(params, action);
+	}
+
+void CMTPObjectStore::RemoveObjectsByStorageIdL(TUint32 aStorageId)
+	{
+	iCachedSuidHash = 0;
+	iCachedHandle = 0;
+	TMTPObjectMgrQueryParams params(aStorageId, 0, 0);
+	TDelAction action(*this);
+	TraverseL(params, action);
+	}
+
+void CMTPObjectStore::ReserveObjectHandleL(CMTPObjectMetaData& aObject, TUint64 /*aSpaceRequired*/)
+	{
+	const TUint dp(aObject.Uint(CMTPObjectMetaData::EDataProviderId));
+	const TUint32 id(iHandleAllocator->NextIdL(dp));
+	aObject.SetUint(CMTPObjectMetaData::EHandle, id);
+	}
+
+void CMTPObjectStore::UnreserveObjectHandleL(const CMTPObjectMetaData& /*aObjectInfo*/)
+	{
+
+	}
+
+/**
+ Clean unloaded data provider contents from object store
+ */
+void CMTPObjectStore::CleanL()
+	{
+	__FLOG(_L8("CleanL - Entry"));
+	Swi::RSisRegistrySession sisSession;
+	User::LeaveIfError(sisSession.Connect());
+	CleanupClosePushL(sisSession);
+
+	const RArray<TUint>& loadedDPIDs = iPkgIDStore->DPIDL();
+	RArray<TUint> unInstalledDpIDs;
+	CleanupClosePushL(unInstalledDpIDs);
+	for (TUint idx(0); (idx < loadedDPIDs.Count()); ++idx)
+		{
+		TUid pkgUid = TUid::Uid(iPkgIDStore->PKGIDL(idx));
+		if (!sisSession.IsInstalledL(pkgUid))
+			{
+			//DP is uninstalled, remove DP related data from database.
+			TUint thisID = loadedDPIDs[idx];
+			__FLOG_1(_L("Data provider[%d] is removed from device!"),thisID);
+			unInstalledDpIDs.AppendL(thisID);
+			}
+		}
+	for (TUint index = 0; index < unInstalledDpIDs.Count(); ++index)
+		{
+		RemoveObjectsL(unInstalledDpIDs[index]);
+		iPkgIDStore->RemoveL(unInstalledDpIDs[index]);
+		}
+	CleanupStack::PopAndDestroy(&unInstalledDpIDs);
+	CleanupStack::PopAndDestroy(&sisSession);
+	__FLOG(_L8("CleanL - Exit"));
+	}
+
+TUint CMTPObjectStore::ObjectOwnerId(const TMTPTypeUint32& aHandle) const
+    {
+    if (!LocateByHandleL(aHandle.Value()))
+        {
+        return 0xff;
+        }
+    return iBatched.ColUint32(EObjectStoreDataProviderId);
+    }
+/**
+ Standard c++ constructor
+ */
+CMTPObjectStore::CMTPObjectStore()
+	{
+	}
+
+/**
+ Second phase constructor.
+ */
+void CMTPObjectStore::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	iMaxCommitLimit = KMaxLimitCommitInEnumeration;
+	iMaxCompactLimit = KMaxLimitCompactInEnumeration;
+	iSingletons.OpenL();
+	InitializeDbL();
+	iCompactor = CDbCompactor::NewL(&iDatabase);
+	iMtpDeltaDataMgr = CMtpDeltaDataMgr::NewL(iDatabase);
+	iReferenceMgr = CMTPReferenceMgr::NewL(*this);
+	iDPIDStore = CMTPDPIDStore::NewL(iDatabase);
+	iPkgIDStore = CMTPPkgIDStore::NewL(iDatabase);
+	iBatched.Open(iDatabase, KSQLHandleTableName, RDbRowSet::EUpdatable);
+	iBatched.SetIndex(KSQLHandleId);
+	iBatched_SuidHashID.Open(iDatabase, KSQLHandleTableName, RDbRowSet::EUpdatable);
+	iBatched_SuidHashID.SetIndex(KSQLSuidHash);
+	iHandleAllocator = CMTPHandleAllocator::NewL(*this);
+	iSentinal = CEnumertingCacheItem::NewL(0, 0, 0, 0, 0);
+	BeginTransactionL();
+	}
+
+/**
+ Initialises the database, it creates the table and index if the database does not exist, otherwise,
+ it open the existing table and index
+ */
+void CMTPObjectStore::InitializeDbL()
+	{
+	TFileName fullName;
+	GetFullPathName(KMTPNoBackupFolderName, fullName);
+	BaflUtils::EnsurePathExistsL(iSingletons.Fs(), fullName);
+	fullName.Append(KMTPBackSlash);
+	fullName.Append(KMTPHandleObjectDbName);
+	TInt err = KErrNone;
+	if (!BaflUtils::FileExists(iSingletons.Fs(), fullName))
+		{
+		CreateDbL(fullName);
+		}
+	else
+		{
+		err = OpenDb(fullName);
+		if (iDatabase.IsDamaged())
+			{
+			err = iDatabase.Recover();
+			}
+		}
+	
+	if (err != KErrNone)
+		{
+		CloseDb();
+		CreateDbL(fullName);
+		}
+	}
+
+/**
+ Create the database with the specified database name
+ @param aFileName    The name of the database to create
+ */
+void CMTPObjectStore::CreateDbL(const TDesC& aFileName)
+	{
+	BaflUtils::EnsurePathExistsL(iSingletons.Fs(), aFileName);
+
+	User::LeaveIfError(iDatabase.Replace(iSingletons.Fs(), aFileName, KMTPFormat));
+	// Create table and index
+	CreateHandleTableL();
+	CreateHandleIndexL();
+	//This is the very very 1st time of MTP server running, therefore, all of the objects in the HandleStore should be added items
+	//roundtrip table will fetch the added items directly from the handlestore, do not popluate the added items to round-trip table
+	//until the enumeration is finished.
+	iUpdateDeltaDataTable = EFalse;
+	}
+
+/**
+ Open the database with the specified database name
+ @param aFileName    The name of the database to open
+ */
+TInt CMTPObjectStore::OpenDb(const TDesC& aFileName)
+	{
+	TInt err = iDatabase.Open(iSingletons.Fs(), aFileName, KMTPFormat);
+	if(KErrNone == err)
+		{
+		TRAP(err,
+			CreateHandleTableL();
+			CreateHandleIndexL();
+			)
+		}
+	iUpdateDeltaDataTable = ETrue;
+	return err;
+	}
+
+/**
+ Close the current opened database
+ */
+void CMTPObjectStore::CloseDb()
+	{
+	iDatabase.Close();
+	}
+
+/**
+ Create the table for storing the mapping from object handle to other properties (data provider id, storage id, formatcode, etc.)
+ */
+void CMTPObjectStore::CreateHandleTableL()
+	{
+	if (!DBUtility::IsTableExistsL(iDatabase, KSQLHandleTableName))
+		{
+		User::LeaveIfError(iDatabase.Execute(KSQLCreateHandleTableText));
+		}
+	}
+
+/**
+ Create three index on the table: 1. Handle, 2. SuidHash, 3. ParentHandle
+ */
+void CMTPObjectStore::CreateHandleIndexL()
+	{
+	if (DBUtility::IsTableExistsL(iDatabase, KSQLHandleTableName))
+		{
+		if (!DBUtility::IsIndexExistsL(iDatabase, KSQLHandleTableName, KSQLHandleId))
+			{
+			User::LeaveIfError(iDatabase.Execute(KSQLCreateHandleIndexText));
+			}
+
+		if (!DBUtility::IsIndexExistsL(iDatabase, KSQLHandleTableName, KSQLSuidHash))
+			{
+			User::LeaveIfError(iDatabase.Execute(KSQLCreateSuidIndexText));
+			}
+
+		if (!DBUtility::IsIndexExistsL(iDatabase, KSQLHandleTableName, KSQLParentHandle))
+			{
+			User::LeaveIfError(iDatabase.Execute(KSQLCreateParentHandleText));
+			}
+		}
+	else
+		{
+		User::Leave(KErrNotFound);
+		}
+	}
+
+/**
+ Get the full path of the database 
+ @param aFileName    The file name of the database to be retrieved
+ */
+void CMTPObjectStore::GetFullPathName(const TDesC& aName, TFileName& aFileName) const
+	{
+	iSingletons.Fs().PrivatePath(aFileName);
+	aFileName.Insert(0, KMTPDbDriveLocation);
+	aFileName.Append(aName);
+	}
+
+/**
+ Initialize the handle allocator for this DP with the minimum object ID to use.
+ This must not be called while an initiator has an open session or it could cause
+ an object ID to be reused.
+ @param aDataProviderId Data provider ID whose handle allocator must be initialized
+ */
+void CMTPObjectStore::RestorePersistentObjectsL(TUint)
+	{
+
+	}
+
+TBool CMTPObjectStore::LocateByHandleL(const TUint aHandle, const TBool aReadTable /*default = ETrue*/) const
+	{
+	TBool result = EFalse;
+	if(IsInvalidHandle(aHandle))
+		{
+		return result;
+		}
+	
+	if (iCachedHandle == aHandle)
+		{
+		result = ETrue;
+		}
+	else
+		{
+		if (iBatched.SeekL(aHandle))
+			{
+			iCachedHandle = aHandle;
+			result = ETrue;
+			}
+		else
+			{
+			iCachedHandle = 0;
+			}
+		}
+	if (result && aReadTable)
+		{
+		iBatched.GetL();
+		}
+	return result;
+	}
+
+TBool CMTPObjectStore::LocateBySuidL(const TDesC& aSuid) const
+	{
+	TBool result = EFalse;
+	TFileName suid;
+	suid.CopyLC(aSuid);
+	TUint32 suidHash = DefaultHash::Des16(suid);
+	if (iCachedSuidHash == suidHash && iCachedSuidHash != 0) //the hash may generate 0 and we use 0 as a sentinel
+		{
+		iBatched_SuidHashID.GetL();
+	    DbColReadStreamL(iBatched_SuidHashID, EObjectStoreSUID, suid);	    
+		if (suid.CompareF(aSuid) == 0 )
+			{
+			result = ETrue;
+			}
+		}
+	if (!result)
+		{
+		if (iBatched_SuidHashID.SeekL(static_cast<TUint> (suidHash)))
+			{//found, but there might be multiple entries since SUIDhash might possible conflict.
+			while (!iBatched_SuidHashID.AtEnd())
+				{
+				iBatched_SuidHashID.GetL();
+		        DbColReadStreamL(iBatched_SuidHashID, EObjectStoreSUID, suid);				
+				if (suid.CompareF(aSuid) == 0)
+					{
+					result = ETrue;
+					iCachedSuidHash = suidHash;
+					break;
+					}
+				else if (iBatched_SuidHashID.ColUint32(EObjectStoreSUIDHash) == suidHash)
+					{
+					iBatched_SuidHashID.NextL();
+					}
+				else
+					{
+					iCachedSuidHash = 0;
+					break;//Not found
+					}
+				}
+			}
+		else
+			{
+			iCachedSuidHash = 0;
+			}
+		}
+	return result;
+	}
+
+/**
+ Get an object for the current query
+ @param aBuf if found, contains the pointer to the created object info,
+ @return ETrue if the object is found, otherwise, EFalse
+ */
+
+TBool CMTPObjectStore::GetObjectL(TUint32 aHandle, CMTPObjectMetaData& aObject) const
+	{
+	if (LocateByHandleL(aHandle))
+		{
+		BuildObjectMetaDataL(aObject, iBatched);
+		return ETrue;
+		}
+	return EFalse;
+	}
+
+/**
+ Determine if the object is of WMP supported media format
+ @param aObject the object meta data
+ @return ETrue if it is of WMP supported media format. EFalse otherwise.
+ */
+TBool CMTPObjectStore::IsMediaFormat(TUint32 aFormatCode)
+	{
+	switch (aFormatCode)
+		{
+		//case EMTPFormatCodeUndefined:
+		//case EMTPFormatCodeAssociation:
+		case EMTPFormatCodeAIFF:
+		case EMTPFormatCodeWAV:
+		case EMTPFormatCodeMP3:
+		case EMTPFormatCodeAVI:
+		case EMTPFormatCodeMPEG:
+		case EMTPFormatCodeASF:
+		case EMTPFormatCodeEXIFJPEG:
+		case EMTPFormatCodeTIFFEP:
+		case EMTPFormatCodeFlashPix:
+		case EMTPFormatCodeBMP:
+		case EMTPFormatCodeCIFF:
+		case EMTPFormatCodeGIF:
+		case EMTPFormatCodeJFIF:
+		case EMTPFormatCodeCD:
+		case EMTPFormatCodePICT:
+		case EMTPFormatCodePNG:
+		case EMTPFormatCodeTIFF:
+		case EMTPFormatCodeTIFFIT:
+		case EMTPFormatCodeJP2:
+		case EMTPFormatCodeJPX:
+		case EMTPFormatCodeUndefinedFirmware:
+		case EMTPFormatCodeWindowsImageFormat:
+		case EMTPFormatCodeUndefinedAudio:
+		case EMTPFormatCodeWMA:
+		case EMTPFormatCodeOGG:
+		case EMTPFormatCodeAAC:
+		case EMTPFormatCodeAudible:
+		case EMTPFormatCodeWMV:
+		case EMTPFormatCodeMP4Container:
+		case EMTPFormatCodeMP2:
+		case EMTPFormatCode3GPContainer:
+		case EMTPFormatCodeAbstractMultimediaAlbum:
+		case EMTPFormatCodeAbstractImageAlbum:
+		case EMTPFormatCodeAbstractAudioAlbum:
+		case EMTPFormatCodeAbstractVideoAlbum:
+		case EMTPFormatCodeAbstractAudioVideoPlaylist:
+		case EMTPFormatCodeAbstractAudioPlaylist:
+		case EMTPFormatCodeAbstractVideoPlaylist:
+		case EMTPFormatCodeWPLPlaylist:
+		case EMTPFormatCodeM3UPlaylist:
+		case EMTPFormatCodeMPLPlaylist:
+		case EMTPFormatCodeASXPlaylist:
+		case EMTPFormatCodePLSPlaylist:
+			return ETrue;
+
+		default:
+			return EFalse;
+		}
+	}
+
+void CMTPObjectStore::CalcFreeHandlesL(TUint aDataProviderId)
+	{
+	TMTPTypeObjectHandle handleType(0, aDataProviderId);
+	TUint32 minHandleForDP = handleType.Value();
+	iCachedSuidHash = 0;
+	iCachedHandle = 0;
+	TUint32 preHandle = minHandleForDP, curHandle = 0;
+	if (iBatched.SeekL((TUint) minHandleForDP, RDbTable::ELessThan))
+		{
+		iBatched.NextL();
+		while (!iBatched.AtEnd())
+			{
+			iBatched.GetL();
+			curHandle = iBatched.ColUint32(EObjectStoreHandleId);
+			TMTPTypeObjectHandle handleType(curHandle);
+			if (handleType.DpId() == aDataProviderId)
+				{
+				if(++ preHandle < curHandle)//base on the handle is allocated continuously
+					{
+					if(!iHandleAllocator->AppendHandleBlockL(aDataProviderId, preHandle, curHandle - preHandle))
+						{
+						break;
+						}
+					preHandle = curHandle;
+					}
+				iBatched.NextL();
+				}
+			else
+				{
+				//Has gone over the current DPid, break;
+				break;
+				}
+			}
+		}
+	}
+
+void CMTPObjectStore::EstablishDBSnapshotL(TUint32 aStorageId)
+	{
+	//Currently, i only do this for File DP since it is non-persistent, later, if we take the proposal that 
+	//1. FileDP is the last DP to be enumerated.
+	//2. FileDP will san the whole file system, and will try to enumerate all of the objects(might on behalf of another DP) if the objects is still not
+	// in the object store after all other DP finish its enumeration.
+	//3. Then notify the related DP about the newly added objects by notification API;
+	//_LIT(KInsert, "CMTPObjectStore::EstablishDBSnapshotL");
+	//volatile TTimer t(KInsert);
+	RDbTable temp;
+	CleanupClosePushL(temp);
+	temp.Open(iDatabase, KSQLHandleTableName, RDbRowSet::EUpdatable);
+    if(!iCacheExist)
+        {
+	TInt32 count = temp.CountL(RDbRowSet::EQuick);
+        iEnumeratingCacheObjList.ReserveL(count);
+        }
+	temp.FirstL();
+	while (!temp.AtEnd())
+		{
+		temp.GetL();
+        if (temp.ColUint8(EObjectStoreDPFlag) == 1 && (KMTPStorageAll == aStorageId || temp.ColUint32(EObjectStoreStorageId) == aStorageId))
+			{
+			TUint32 handleID = temp.ColUint32(EObjectStoreHandleId);
+			TInt64 pUID = temp.ColInt64(EObjectStorePOUID);
+			iHandleAllocator->SetIdL(handleID, pUID);
+			CEnumertingCacheItem* item = CEnumertingCacheItem::NewLC(
+					temp.ColUint32(EObjectStoreSUIDHash), handleID,
+					temp.ColUint16(EObjectStoreFormatCode), pUID, temp.ColUint8(EObjectStoreDataProviderId));
+			TInt result = iEnumeratingCacheObjList.InsertInOrder(item, TLinearOrder<CEnumertingCacheItem>(CEnumertingCacheItem::Compare));
+			if (KErrAlreadyExists == result) //hash collision
+				{
+				TInt found = iEnumeratingCacheObjList.FindInOrder(item, TLinearOrder<CEnumertingCacheItem>(CEnumertingCacheItem::Compare));
+				CEnumertingCacheItem* colliItem = iEnumeratingCacheObjList[found];
+                TFileName suid;
+				if (colliItem->iSuid == NULL)
+					{
+					if (!LocateByHandleL(colliItem->iObjHandleId))
+					    {
+					    DbColReadStreamL(iBatched, EObjectStoreSUID, suid);
+					    
+					    colliItem->iSuid = suid.AllocL();
+					    
+					    colliItem->iSuidPtr.Set(*colliItem->iSuid);
+					    }
+					}
+                DbColReadStreamL(temp, EObjectStoreSUID, suid);
+				
+                item->iSuid = suid.AllocL();
+                
+				item->iSuidPtr.Set(*item->iSuid);
+                result = iEnumeratingCacheObjList.InsertInOrder(item, TLinearOrder<CEnumertingCacheItem>(CEnumertingCacheItem::Compare));
+				}
+            if(result != KErrAlreadyExists)
+				{
+				User::LeaveIfError(result);
+				}
+			CleanupStack::Pop(item);
+			}
+		temp.NextL();
+		}
+	CleanupStack::PopAndDestroy(&temp);
+	iCacheExist = ETrue;
+	}
+
+void CMTPObjectStore::CleanDBSnapshotL()
+	{
+	//For those items left in the iEnumeratingCacheObjList, remove the object entry if the DPID of the handle is not persistent. and populate the 
+	//roundtrip table if needed.
+	//and then close the iEnumeratingCacheObjList to release the memory.
+	//_LIT(KInsert, "CMTPObjectStore::CleanDBSnapshot");
+	//volatile TTimer t(KInsert);
+	if(iCacheExist)
+	    {
+	        iCacheExist = EFalse;
+	    }
+	else 
+	    return;
+
+	for (TInt i = iEnumeratingCacheObjList.Count() - 1; i >= 0; i--)
+		{
+		TInt rc = iNonPersistentDPList.FindInOrder(iEnumeratingCacheObjList[i]->iDpID);
+		if (rc != KErrNotFound)
+			{//This is a non persistent DP.
+			RemoveObjectL(iEnumeratingCacheObjList[i]->iObjHandleId);
+			}
+		}
+	iNonPersistentDPList.Close();
+	iEnumeratingCacheObjList.ResetAndDestroy();
+	iUpdateDeltaDataTable = ETrue;
+	iMaxCommitLimit = KMaxLimitCommitAfterEnumeration;
+	iMaxCompactLimit = KMaxLimitCompactAfterEnumeration;
+    CommitTransactionL();
+    User::LeaveIfError(iDatabase.Compact());
+    BeginTransactionL();
+	}
+
+CMTPObjectStore::CEnumertingCacheItem::CEnumertingCacheItem(TUint32 aSuidHash, TUint32 aHandle, TUint32 aFormat, TUint64 aId, TUint8 aDpID)
+	{
+	iObjSuiIdHash = aSuidHash;
+	iObjHandleId = aHandle;
+	iFormatcode = aFormat;
+	iPOUID = aId;
+	iDpID = aDpID;
+	}
+
+TInt CMTPObjectStore::CEnumertingCacheItem::Compare(const CEnumertingCacheItem& aFirst, const CEnumertingCacheItem& aSecond)
+	{
+	if (aFirst.iObjSuiIdHash > aSecond.iObjSuiIdHash)
+		{
+		return 1;
+		}
+	else if (aFirst.iObjSuiIdHash < aSecond.iObjSuiIdHash)
+		{
+		return -1;
+		}
+	if ((aFirst.iSuidPtr.Length() != 0) && (aSecond.iSuidPtr.Length() != 0))
+		{
+		return aFirst.iSuidPtr.CompareF(aSecond.iSuidPtr);
+		}
+	return 0;
+	}
+
+TBool CMTPObjectStore::IsInvalidHandle( TUint32 aHandle ) const
+	{
+	return ( (KMTPHandleAll == aHandle) || (KMTPHandleNone == aHandle) );
+	}
+
+void CMTPObjectStore::DbColWriteStreamL(RDbTable& aTable, TDbColNo aCol, const TDesC16& aDes)
+    {
+    RDbColWriteStream suid;
+    suid.OpenLC(aTable, aCol);
+    suid.WriteL(aDes);
+    suid.Close();
+    CleanupStack::PopAndDestroy(); // suid
+    }
+
+void CMTPObjectStore::DbColReadStreamL(const RDbTable& aTable, TDbColNo aCol, TDes16& aDes) const
+    {
+    RDbColReadStream suid;
+    suid.OpenLC(aTable, aCol);
+    suid.ReadL(aDes, aTable.ColLength(aCol));
+    suid.Close();
+    CleanupStack::PopAndDestroy(); // suid
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpparserrouter.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,2377 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtpobjectmetadata.h>
+#include <mtp/mtpprotocolconstants.h>
+
+#include "cmtpconnection.h"
+#include "cmtpdataprovider.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpframeworkconfig.h"
+#include "cmtpobjectmgr.h"
+#include "cmtpparserrouter.h"
+#include "cmtpsession.h"
+#include "cmtpstoragemgr.h"
+#include "tmtptypeobjecthandle.h"
+#include "cmtpservicemgr.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"ParserRouter");)
+
+/**
+Provides the byte size of the specified array.
+*/
+#define _ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+
+/**
+CMTPParserRouter panic codes.
+*/
+_LIT(KMTPPanicCategory, "CMTPParserRouter");
+enum TMTPPanicReasons
+    {
+    EMTPPanicRoutingConflict = 0
+    };
+    
+/**
+Produces a "CMTPParserRouter" category panic.
+@param aReason The panic code.
+*/
+LOCAL_C void Panic(TInt aReason)
+    {
+    User::Panic(KMTPPanicCategory, aReason);
+    }
+    
+/**
+Constructor.
+*/
+EXPORT_C CMTPParserRouter::TRoutingParameters::TRoutingParameters(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) :
+    iConnection(aConnection),
+    iRequest(aRequest),
+    iParameters(iParameterData, ENumTypes)
+    {
+    Reset();
+    }
+        
+    
+/**
+Copy constructor.
+*/
+CMTPParserRouter::TRoutingParameters::TRoutingParameters(const TRoutingParameters& aParams) :
+    iConnection(aParams.iConnection),
+    iRequest(aParams.iRequest),
+    iParameters(iParameterData, ENumTypes)
+    {
+    iParameters.Copy(aParams.iParameters.Begin(), aParams.iParameters.Count());
+    }
+
+/**
+Provides the handle of the MTP connection on associated with the operation.
+@return The MTP connection handle.
+*/    
+EXPORT_C MMTPConnection& CMTPParserRouter::TRoutingParameters::Connection() const
+    {
+    return iConnection;
+    }
+    
+/**
+Provides the value of the specified parameter.
+@param aId The parameter identifier.
+@return The parameter value.
+*/
+EXPORT_C TUint CMTPParserRouter::TRoutingParameters::Param(CMTPParserRouter::TRoutingParameters::TParameterType aId) const
+    {
+    return iParameters[aId];
+    }
+    
+/**
+Resets all parameter values to zero.
+*/
+EXPORT_C void CMTPParserRouter::TRoutingParameters::Reset()
+    {
+    iParameters.Reset();
+    }
+    
+/**
+Provides the operation dataset associated with the operation.
+@return The operation dataset.
+*/
+EXPORT_C const TMTPTypeRequest& CMTPParserRouter::TRoutingParameters::Request() const
+    {
+    return iRequest;
+    }
+    
+/**
+Sets the value of the specified parameter.
+@param aId The parameter identifier.
+@param aVal The new parameter value.
+*/
+EXPORT_C void CMTPParserRouter::TRoutingParameters::SetParam(CMTPParserRouter::TRoutingParameters::TParameterType aId, TUint aVal)
+    {
+    iParameters[aId] = aVal;
+    }
+
+/**
+CMTPParserRouter factory method.
+@return A pointer to a new CMTPDataProvider instance. Ownership IS transfered.
+@leave One of the system wide error codes if a processing failure occurs.
+ */
+CMTPParserRouter* CMTPParserRouter::NewL()
+    {
+    CMTPParserRouter* self = new (ELeave) CMTPParserRouter();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor
+*/
+CMTPParserRouter::~CMTPParserRouter()
+    {
+    __FLOG(_L8("~CMTPParserRouter, Entry"));
+    iMaps.ResetAndDestroy();
+    iSingletons.Close();
+    __FLOG(_L8("~CMTPParserRouter, Exit"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Configures the parser/router. This processing primarily involves retrieving 
+each data provider's set of supported category codes and using them to build
+up the operation parameter lookup routing sub-type tables.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C void CMTPParserRouter::ConfigureL()
+    {
+    __FLOG(_L8("ConfigureL, Entry"));    
+    const TUint KMapIds[] = 
+        {
+        ESubTypeDevicePropCode,
+        ESubTypeObjectPropCode,
+        ESubTypeOperationCode,
+        ESubTypeStorageType,
+        ESubTypeFormatCodeFormatSubcode,
+        ESubTypeFormatCodeOperationCode,
+        ESubTypeStorageTypeOperationCode,
+        ESubTypeFormatCodeFormatSubcodeStorageType,
+        ESubTypeServiceIDOperationCode
+        };
+        
+    iMaps.ResetAndDestroy();
+    for (TUint i(0); (i < _ARRAY_SIZE(KMapIds)); i++)
+        {
+        const TUint KSubType(KMapIds[i]);
+        CMap* map(CMap::NewLC(KSubType));
+        iMaps.AppendL(map);
+        CleanupStack::Pop(map);
+        
+        RArray<TUint> p1Codes;
+        RArray<TUint> p2Codes;
+        RArray<TUint> p3Codes;
+        CleanupClosePushL(p1Codes);
+        CleanupClosePushL(p2Codes);
+        CleanupClosePushL(p3Codes);
+        
+        GetMapParameterIdsL(KSubType, p1Codes, p2Codes, p3Codes);
+        
+        const TUint KParams(KSubType & ESubTypeParamsMask);
+        switch (KParams)
+            {
+        case ESubTypeParams1:
+            Configure1ParameterMapL(KSubType, p1Codes);
+            break;
+            
+        case ESubTypeParams2:
+            Configure2ParameterMapL(KSubType, p1Codes, p2Codes);
+            break;
+            
+        case ESubTypeParams3:
+            Configure3ParameterMapL(KSubType, p1Codes, p2Codes, p3Codes);
+            break;
+
+        default:
+            __DEBUG_ONLY(User::Invariant());
+            break;
+            }
+            
+        CleanupStack::PopAndDestroy(&p3Codes);
+        CleanupStack::PopAndDestroy(&p2Codes);
+        CleanupStack::PopAndDestroy(&p1Codes);
+        }
+        
+    __FLOG_STMT(FLOGMapsL());
+    __FLOG(_L8("ConfigureL, Exit"));
+    }
+    
+/**
+Indicates if the specified MTP operation code is supported by any of the set 
+of loaded data providers.
+@param aOperation The MTP operation code.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/    
+EXPORT_C TBool CMTPParserRouter::OperationSupportedL(TUint16 aOperation) const
+    {
+    __FLOG(_L8("OperationSupported, Entry"));
+    RArray<TUint> from;
+    RArray<TUint> to;
+    CleanupClosePushL(from);
+    CleanupClosePushL(to);
+    
+    from.AppendL(aOperation);
+    iMaps[Index(ESubTypeOperationCode)]->GetToL(from, to);
+    TBool ret(to.Count() > 0);
+
+    CleanupStack::PopAndDestroy(&to);
+    CleanupStack::PopAndDestroy(&from);
+    __FLOG(_L8("OperationSupported, Exit"));
+    return (ret);
+    }
+
+/**
+Parses the operation dataset supplied in the specified routing parameters 
+object which encapsulates all information required to route the operation. 
+The parsing process involves:
+
+    1.  Extracting all relevant routing information from the received operation 
+        dataset. Note that not all parameter data is extracted, only that which 
+        is required to route the operation.
+    2.  Coarse grain validating the parsed data. Specifically this involves 
+        validating that any MTP StorageID or Object Handle parameter data refers 
+        to valid entities that exist on the device.
+    3.    Extracting additional meta-data related to specific data objects and/or 
+        storages referred to in the operation dataset and which is required to 
+        route the operation.
+        
+@param aParams The routing parameters object. On entry this contains the 
+operation dataset to be parsed and the handle of the MTP connection on which it
+was received. On exit this contains all information required to route the 
+operation. 
+@leave One of the system wide error codes if a processing failure occurs,
+*/
+EXPORT_C void CMTPParserRouter::ParseOperationRequestL(TRoutingParameters& aParams) const
+    {
+    __FLOG(_L8("ParseOperationRequestL, Entry"));
+    const TUint16 KOpCode(aParams.Request().Uint16(TMTPTypeRequest::ERequestOperationCode));
+    __FLOG_VA((_L8("Operation Code = 0x%04X"), KOpCode));
+    switch (KOpCode)
+        {
+    case EMTPOpCodeGetStorageInfo:
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamStorageId, aParams);
+        break;
+      
+    case EMTPOpCodeGetObjectInfo:
+    case EMTPOpCodeGetObject:
+    case EMTPOpCodeGetThumb:
+    case EMTPOpCodeSetObjectProtection:
+    case EMTPOpCodeMoveObject:
+    case EMTPOpCodeCopyObject:        
+    case EMTPOpCodeGetPartialObject:
+    case EMTPOpCodeGetObjectReferences:
+    case EMTPOpCodeSetObjectReferences:
+    case EMTPOpCodeUpdateObjectPropList :
+    case EMTPOpCodeDeleteObjectPropList :
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamObjectHandle, aParams);
+        break; 
+        
+    case EMTPOpCodeGetObjectPropValue:
+    case EMTPOpCodeSetObjectPropValue:
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamObjectHandle, aParams);
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter2, TRoutingParameters::EParamObjectPropCode, aParams);
+        break; 
+
+    case EMTPOpCodeDeleteObject:              
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamObjectHandle, aParams);
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter2, TRoutingParameters::EParamFormatCode, aParams); 
+        break;
+        
+    case EMTPOpCodeSendObjectInfo:
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamStorageId, aParams);
+        break;
+
+    case EMTPOpCodeInitiateCapture: 
+    case EMTPOpCodeInitiateOpenCapture:
+        {   
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamStorageId, aParams);
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter2, TRoutingParameters::EParamFormatCode, aParams); 
+        TUint format(aParams.Request().Uint32(TMTPTypeRequest::ERequestParameter2));
+        if (format == KMTPNotSpecified32)
+            {
+            iSingletons.FrameworkConfig().GetValueL(MMTPFrameworkConfig::EDefaultObjectFormatCode, format);
+            if (format == KMTPNotSpecified32)
+                {
+                format = EMTPFormatCodeUndefined;
+                }
+            aParams.SetParam(TRoutingParameters::EParamFormatCode, format);
+            }
+        }
+        break; 
+ 
+    case EMTPOpCodeSendObjectPropList:
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamStorageId, aParams);
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter3, TRoutingParameters::EParamFormatCode, aParams); 
+        break;  
+        
+    case EMTPOpCodeGetDevicePropDesc:
+    case EMTPOpCodeGetDevicePropValue:
+    case EMTPOpCodeSetDevicePropValue:
+    case EMTPOpCodeResetDevicePropValue:
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamDevicePropCode, aParams);
+        break;
+        
+    case EMTPOpCodeGetObjectPropsSupported:
+    case EMTPOpCodeGetInterdependentPropDesc:
+    case EMTPOpCodeGetFormatCapabilities:
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamFormatCode, aParams); 
+        break;
+
+    case EMTPOpCodeGetObjectPropDesc:
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamObjectPropCode, aParams); 
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter2, TRoutingParameters::EParamFormatCode, aParams);
+        break;
+
+    case EMTPOpCodeGetObjectPropList:              
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter2, TRoutingParameters::EParamFormatCode, aParams);
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamObjectHandle, aParams);
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter3, TRoutingParameters::EParamObjectPropCode, aParams);
+        break;
+        
+    case EMTPOpCodeGetServiceInfo :
+    case EMTPOpCodeGetServiceCapabilities :
+    case EMTPOpCodeGetServicePropDesc :
+    case EMTPOpCodeGetServicePropList :
+    case EMTPOpCodeSetServicePropList:
+    case EMTPOpCodeDeleteServicePropList :
+        {
+        ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamServiceId, aParams);
+        }
+        break;
+                
+    case EMTPOpCodeGetDeviceInfo:
+    case EMTPOpCodeOpenSession:
+    case EMTPOpCodeCloseSession:
+    case EMTPOpCodeGetStorageIDs:
+    case EMTPOpCodeGetNumObjects:
+    case EMTPOpCodeGetObjectHandles:
+    case EMTPOpCodeSendObject:
+    case EMTPOpCodeFormatStore:
+    case EMTPOpCodeResetDevice:
+    case EMTPOpCodeSelfTest:
+    case EMTPOpCodePowerDown:
+    case EMTPOpCodeSetObjectPropList:
+    case EMTPOpCodeSkip:
+    case EMTPOpCodeGetServiceIDs:
+        default:
+        break;
+        }
+    __FLOG(_L8("ParseOperationRequestL, Exit"));
+    }
+
+/**
+Routes an MTP operation using the specified routing parameters. By default 
+only operation parameter routing is performed.
+@param aParams The routing parameters.
+@param aTargets One exit, the set of data provider targets to which the 
+operation should be dispatched.
+@leave One of the system wide error codes if a processing failure occurs,
+*/
+EXPORT_C void CMTPParserRouter::RouteOperationRequestL(const TRoutingParameters& aParams, RArray<TUint>& aTargets) const
+    {
+    __FLOG(_L8("RouteOperationRequestL, Entry"));
+    aTargets.Reset();
+    
+    // By default ETypeOperationParameter routing is always enabled.
+    if (!(aParams.Param(TRoutingParameters::EFlagRoutingTypes) & ETypeOperationParameter))
+        {
+        const_cast<TRoutingParameters&>(aParams).SetParam(TRoutingParameters::EFlagRoutingTypes, ETypeOperationParameter);
+        }
+    
+    // Get the routing and validation sub-types.
+    RArray<TUint> routing;
+    CleanupClosePushL(routing);
+    RArray<TUint> validation;
+    CleanupClosePushL(validation);
+    RArray<TRoutingParameters> params;
+    CleanupClosePushL(params);
+    params.AppendL(TRoutingParameters(aParams));
+    TRoutingParameters& param1(params[0]);
+    GetRoutingSubTypesL(params, routing, validation);
+    
+    // Execute the routing sub-types.
+    const TUint KCountParams(params.Count());
+    for (TUint p(0); ((p < KCountParams) && (aTargets.Count() == 0)); p++)
+        {
+        const TRoutingParameters& KParam(params[p]);
+        const TUint KCountRouting(routing.Count());
+        for (TUint r(0); (r < KCountRouting); r++)
+            {
+            const TUint KRouting(routing[r]);
+            if ((KRouting & ESubTypeParamsMask) == ESubTypeParams0)
+                {
+                RouteOperationRequest0ParametersL(KRouting, KParam, aTargets);
+                }
+            else
+                {
+                RouteOperationRequestNParametersL(KRouting, KParam, aTargets);
+                }
+            }
+        }
+     
+    // Execute the validation sub-types.
+    ValidateTargetsL(param1, validation, aTargets);
+    const TUint KCountTargets(aTargets.Count());
+    if ((KCountTargets == 0) && (param1.Param(TRoutingParameters::EFlagRoutingTypes) & ETypeFramework))
+        {
+        SelectTargetL(iSingletons.DpController().DeviceDpId(), aTargets);
+        }
+    else if (KCountTargets > 1)
+        {
+        if (param1.Param(TRoutingParameters::EFlagRoutingTypes) & ETypeFlagSingleTarget)
+            {
+            TUint target(KCountTargets);
+            while (target-- > 1)
+                {
+                aTargets.Remove(target);
+                }
+            }
+        else if (param1.Param(TRoutingParameters::EFlagRoutingTypes) & ETypeFramework)
+            {
+            aTargets.Reset();
+            SelectTargetL(iSingletons.DpController().ProxyDpId(), aTargets);
+            }
+        }    
+    CleanupStack::PopAndDestroy(&params);
+    CleanupStack::PopAndDestroy(&validation);
+    CleanupStack::PopAndDestroy(&routing);
+    __FLOG(_L8("RouteOperationRequestL, Exit"));
+    }
+
+/**
+Indicates if a routing request with the specified MTP operation code is 
+registered on the specified session.
+@param aRequest The MTP operation requesty dataset specifying MTP operation 
+code and session.
+@param aConnection The handle of the MTP connection on which the operation
+request is expected to be received.
+@return ETrue if a routing request with the specified MTP operation code is 
+registered on the session, otherwise EFalse.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C TBool CMTPParserRouter::RouteRequestRegisteredL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const
+    {
+    __FLOG(_L8("RouteRequestRegistered, Entry"));
+    TBool ret(EFalse);
+    const TUint32 KSessionId(aRequest.Uint32(TMTPTypeRequest::ERequestSessionID));
+    if ((KSessionId != KMTPSessionAll) && (aConnection.SessionWithMTPIdExists(KSessionId)))
+        {
+        CMTPSession& session(static_cast<CMTPSession&>(aConnection.SessionWithMTPIdL(KSessionId)));
+        ret = session.RouteRequestRegistered(aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode));
+        }
+    __FLOG(_L8("RouteRequestRegistered, Exit"));
+    return ret;
+    }
+   
+/**
+Routes and dispatches the specified MTP event dataset. The only valid event 
+that is accepted is CancelTransaction, all other event types are discarded. 
+Events are routed to the same target to which the currently active operation 
+was dispatched. If there is no active transaction in progress then the event 
+will be discarded.
+@param aEvent The MTP event dataset.
+@param aConnection The MTP connection on which the event was received.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPParserRouter::ProcessEventL(const TMTPTypeEvent& aEvent, CMTPConnection& aConnection) const
+    {
+    __FLOG(_L8("ProcessEventL, Entry"));
+    if ((aEvent.Uint16(TMTPTypeEvent::EEventCode) == EMTPEventCodeCancelTransaction) &&
+        (aConnection.SessionWithMTPIdExists(aEvent.Uint32(TMTPTypeEvent::EEventSessionID))))
+        {
+        CMTPSession& session(static_cast<CMTPSession&>(aConnection.SessionWithMTPIdL(aEvent.Uint32(TMTPTypeEvent::EEventSessionID))));
+        if (session.TransactionPhase() != EIdlePhase)
+            {    
+            iSingletons.DpController().DataProviderL(RoutingTargetL(session.ActiveRequestL(), aConnection)).ExecuteEventL(aEvent, aConnection);
+            }
+        }
+    __FLOG(_L8("ProcessEventL, Exit"));
+    }
+   
+/**
+Routes and dispatches the specified MTP operation (request) dataset.
+@param aRequest The MTP operation (request) dataset.
+@param aConnection The MTP connection on which the event was received.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPParserRouter::ProcessRequestL(const TMTPTypeRequest& aRequest, CMTPConnection& aConnection) const
+    {
+    __FLOG(_L8("ProcessRequestL, Entry")); 
+    iSingletons.DpController().DataProviderL(RoutingTargetL(aRequest, aConnection)).ExecuteRequestL(aRequest, aConnection);
+    __FLOG(_L8("ProcessRequestL, Exit"));
+    }
+
+/**
+Registers the calling data provider to receive one or more occurrences of 
+the specified request dataset that are received on the specified connection.
+@param aRequest The operation request dataset being registered.
+@param aConnection The handle of the MTP connection on which the operation
+request is expected to be received.
+@param aId The data provider identifier.
+@leave One of the system wide error codes, if a processing failure occurs.
+@see MMTPDataProviderFramework::RouteRequestRegisterL
+*/
+void CMTPParserRouter::RouteRequestRegisterL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TInt aId)
+    {
+    __FLOG(_L8("RouteRequestRegisterL, Entry"));
+    const TUint32 KSessionId(aRequest.Uint32(TMTPTypeRequest::ERequestSessionID));
+    if (KSessionId == KMTPSessionAll)
+        {
+        // Register the request on all sessions.
+        const TUint KNumSessions(aConnection.SessionCount());
+        TUint count(0);
+        TUint sessionId(1);
+        while (count < KNumSessions)
+            {
+            // Insert the correct session id into a copy of the request and register this copy with the session
+            if (aConnection.SessionWithMTPIdExists(sessionId))
+                {
+                // Session exists
+                count++;
+                TMTPTypeRequest req(aRequest);
+                req.SetUint32(TMTPTypeRequest::ERequestSessionID, sessionId);
+                CMTPSession& session(static_cast<CMTPSession&>(aConnection.SessionWithMTPIdL(sessionId)));
+                session.RouteRequestRegisterL(req, aId);
+                }
+            sessionId++;
+            }
+        }
+    else
+        {
+        CMTPSession& session(static_cast<CMTPSession&>(aConnection.SessionWithMTPIdL(KSessionId)));
+        session.RouteRequestRegisterL(aRequest, aId);
+        }
+    __FLOG(_L8("RouteRequestRegisterL, Exit"));
+    }
+
+/**
+Cancels a pending RouteRequestRegisterL registration.
+@param aRequest The registered operation request dataset.
+@param aConnection The handle of the MTP connection for which the operation
+request was registered.
+@leave One of the system wide error codes, if a general processing error
+occurs.
+@see MMTPDataProviderFramework::RouteRequestUnregisterL
+*/
+void CMTPParserRouter::RouteRequestUnregisterL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
+    {
+    __FLOG(_L8("RouteRequestUnregisterL, Entry"));
+    CMTPSession& session(static_cast<CMTPSession&>(aConnection.SessionWithMTPIdL(aRequest.Uint32(TMTPTypeRequest::ERequestSessionID))));
+    session.RouteRequestUnregister(aRequest);
+    __FLOG(_L8("RouteRequestUnregisterL, Exit"));
+    }
+
+/**
+Constructor.
+@param aFrom The map source parameter.
+*/
+CMTPParserRouter::TMap::TMap(TUint aFrom) :
+    iFrom(aFrom),
+    iSubType(0),
+    iTo(0)
+    {
+
+    }
+
+/**
+Constructor.
+@param aFrom The map source parameter.
+@param aTo The map target.
+@param aSubType The map routing sub-type code (@see CMTPParserRouter::TRoutingSubType).
+*/
+CMTPParserRouter::TMap::TMap(TUint aFrom, TUint aTo, TUint aSubType) :
+    iFrom(aFrom),
+    iSubType(aSubType),
+    iTo(aTo)
+    {
+
+    }
+
+/**
+CMTPParserRouter::CMap factory method.
+@param aSubType The map routing sub-type code (@see CMTPParserRouter::TRoutingSubType).
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+CMTPParserRouter::CMap* CMTPParserRouter::CMap::NewLC(TUint aSubType)
+    {
+    return NewLC(0, aSubType);
+    }
+
+/**
+Destructor.
+*/
+CMTPParserRouter::CMap::~CMap()
+    {
+    if (Params(iSubType) == ESubTypeParams1)
+        {
+        iToNodes.Reset();
+        }
+    else
+        {
+        iToBranches.ResetAndDestroy();
+        }
+    __FLOG_CLOSE;
+    }
+    
+/**
+Provides the map source parameter.
+@return The map source parameter.
+*/
+TUint CMTPParserRouter::CMap::From() const
+    {
+    return iFrom;
+    }
+    
+/**
+Initialises a map source parameter set array.
+@param aFrom On exit, the initialised map source parameter set array.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+
+*/
+void CMTPParserRouter::CMap::InitParamsL(RArray<TUint>& aFrom) const
+    {
+    aFrom.Reset();
+    TUint KCount(ParamsCount(iSubType));
+    for (TUint i(0); (i < KCount); i++)
+        {
+        aFrom.AppendL(0);
+        }
+    }
+
+/**
+Inserts an entry into the map table with the specified source and target 
+parameters.
+@param aFrom The map source parameter set array.
+@param aFrom The map target parameter.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::CMap::InsertL(const RArray<TUint>& aFrom, TUint aTo)
+    {
+    const TUint KFrom(Param(aFrom));
+    if (Params(iSubType) == ESubTypeParams1)
+        {
+        // Node.
+        __FLOG_STMT(FLOGMapEntryL(aFrom, aTo));
+        const TUint KSubType(CMTPParserRouter::SubType(Index(iSubType), Flags(iSubType), (ParamsCount(iSubType) - 1)));
+        const TMap KNode(KFrom, aTo, KSubType);
+        NodeInsertL(KNode);
+        }
+    else
+        {
+        // Branch.
+        TInt idx(BranchFind(KFrom));
+        if (idx == KErrNotFound)
+            {
+            idx = BranchInsertL(KFrom);
+            __ASSERT_DEBUG((idx != KErrNotFound), User::Invariant());
+            }
+        iToBranches[idx]->InsertL(aFrom, aTo);
+        }
+    }
+
+/**
+Provides the set of targets which map from the specified source parameters.
+@param aFrom The map source parameters.
+@param aTo The map target parameter set.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::CMap::GetToL(const RArray<TUint>& aFrom, RArray<TUint>& aTo) const
+    {
+    __FLOG(_L8("CMap::GetToL - entry"));
+    const TUint KFrom(Param(aFrom));
+    if (KFrom == KMTPNotSpecified32)
+        {
+        // Null (zero) parameter acts as a wildcard.
+        SelectTargetAllL(aFrom, aTo);
+        }
+    else if (Flags(iSubType) & ESubTypeFlagEnableDuplicates)
+        {
+        // Select 0 .. n matching targets.
+        SelectTargetMatchingL(aFrom, aTo);
+        }
+    else
+        {
+        // Select 0 .. 1 matching targets.
+        SelectTargetSingleL(aFrom, aTo);
+        }
+	__FLOG(_L8("CMap::GetToL - Exit"));        
+    }
+    
+/**
+Provides the map subtype code.
+@return The map subtype code.
+*/
+TUint CMTPParserRouter::CMap::SubType() const
+    {
+    return iSubType;
+    }
+
+#ifdef __FLOG_ACTIVE
+/**
+Logs the map table entries (source and target) which match the specified source 
+parameters.
+@param aFrom The map source parameters.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/  
+void CMTPParserRouter::CMap::FLOGMapL(RArray<TUint>& aFrom) const
+    {
+    if (Params(iSubType) == ESubTypeParams1)
+        {
+        // Node.
+        const TUint KCount(iToNodes.Count());
+        for (TUint i(0); (i < KCount); i++)
+            {
+            aFrom[ParamIdx(aFrom)] = iToNodes[i].iFrom;
+            FLOGMapEntryL(aFrom, iToNodes[i].iTo);
+            }
+        }
+    else 
+        {
+        // Branch.
+        const TUint KCount(iToBranches.Count());
+        for (TUint i(0); (i < KCount); i++)
+            {
+            const CMap& KBranch(*iToBranches[i]);
+            aFrom[ParamIdx(aFrom)] = KBranch.iFrom;
+            KBranch.FLOGMapL(aFrom);
+            }
+        }
+    }
+    
+/**
+Logs the specified source and target map table entry parameters.
+@param aFrom The map source parameters.
+@param aTo The map target parameter.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::CMap::FLOGMapEntryL(const RArray<TUint>& aFrom, TUint aTo) const
+    {
+    __ASSERT_DEBUG((aFrom.Count() >= ParamsCount(iSubType)), User::Invariant());
+    RBuf log;
+    log.CleanupClosePushL();
+    const TUint KParamsCount(aFrom.Count());
+    const TUint KWidthFrom(8);
+    const TUint KWidthTo(2);
+    const TUint KLength((KParamsCount * 11) + 7);
+    log.CreateL(KLength);
+    for (TUint i(0); (i < KParamsCount); i++)
+        {
+        log.Append(_L("0x"));
+        log.AppendNumFixedWidthUC(aFrom[i], EHex, KWidthFrom);
+        log.Append(_L(" "));
+        }
+    log.Append(_L("-> 0x"));
+    log.AppendNumFixedWidthUC(aTo, EHex, KWidthTo);
+    __FLOG(log);
+    CleanupStack::PopAndDestroy(&log);
+    }
+#endif
+
+/**
+CMTPParserRouter::CMap factory method.
+@param aFrom The map source parameter.
+@param aTo The map target parameter.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+CMTPParserRouter::CMap* CMTPParserRouter::CMap::NewLC(TUint aFrom, TUint aSubType)
+    {
+    CMap* self(new(ELeave) CMap(aFrom, aSubType));
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+    
+/**
+Constructor.
+@param aFrom The map source parameter.
+@param aTo The map target parameter.
+*/
+CMTPParserRouter::CMap::CMap(TUint aFrom, TUint aSubType) :
+    iFrom(aFrom),
+    iSubType(aSubType)
+    {
+
+    }
+    
+/**
+Second-phase constructor.
+*/
+void CMTPParserRouter::CMap::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    }
+    
+/**
+Locates the map branch table index of the first map table entry matching the 
+specified source parameter, using a binary search algorithm.
+@param aFrom The map source parameter,
+@return The map node table index of the first matching entry, or KErrNotFound 
+if no matching entry is found.
+*/
+TInt CMTPParserRouter::CMap::BranchFind(TUint aFrom) const
+    {
+    return (iToBranches.FindInOrder(aFrom, ((Flags(iSubType) & ESubTypeFlagOrderDescending) ? BranchOrderFromKeyDescending : BranchOrderFromKeyAscending)));
+    }
+    
+/**
+Inserts a new map branch table with the specified source parameter.
+@param aFrom The map source paramete.
+@return The map branch table index of the new entry.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+TUint CMTPParserRouter::CMap::BranchInsertL(TUint aFrom)
+    {
+    CMap* branch(CMap::NewLC(aFrom, CMTPParserRouter::SubType(Index(iSubType), Flags(iSubType), (ParamsCount(iSubType) - 1))));
+    TLinearOrder<CMap> KOrder((iSubType & ESubTypeFlagOrderDescending) ? BranchOrderFromDescending : BranchOrderFromAscending);
+    iToBranches.InsertInOrderL(branch, KOrder);
+    CleanupStack::Pop(branch);
+    return iToBranches.FindInOrder(branch, KOrder);
+    }
+    
+/**
+Locates the map node table index of the first map table entry matching the 
+specified source parameter, using a binary search algorithm.
+@param aFrom The source parameter,
+@return The map node table index of the first matching entry, or KErrNotFound 
+if no matching entry is found.
+*/
+TInt CMTPParserRouter::CMap::NodeFind(TUint aFrom) const
+    {
+    return (iToNodes.FindInOrder(aFrom, ((Flags(iSubType) & ESubTypeFlagOrderDescending) ? NodeOrderFromKeyDescending : NodeOrderFromKeyAscending)));
+    }
+    
+/**
+Locates the map node table index of the  map table entry matching the specified
+node, using a binary search algorithm.
+@param aFrom The map node table entry.
+@return The map node table index, or KErrNotFound if no matching entry is 
+found.
+*/
+TInt CMTPParserRouter::CMap::NodeFind(const TMap& aNode) const
+    {
+    return iToNodes.FindInOrder(aNode, ((Flags(iSubType) & ESubTypeFlagOrderDescending) ? NodeOrderFromToDescending : NodeOrderFromToAscending));
+    }
+    
+/**
+Inserts the specified map node into the map node table.
+@param aFrom The map node table entry.
+@return The map node table index of the new entry.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+TUint CMTPParserRouter::CMap::NodeInsertL(const TMap& aMap)
+    {   
+    TLinearOrder<TMap> KOrder((iSubType & ESubTypeFlagOrderDescending) ? NodeOrderFromToDescending : NodeOrderFromToAscending);
+    if (Flags(iSubType) & ESubTypeFlagEnableDuplicates)
+        {
+        // Duplicates allowed, but discard completely duplicated routes.
+        if (NodeFind(aMap) == KErrNotFound) 
+            {
+            iToNodes.InsertInOrderL(aMap, KOrder);
+            }
+        }
+    else
+        {
+        TInt err(iToNodes.InsertInOrder(aMap, KOrder));
+        if (err == KErrAlreadyExists)
+            {
+            Panic(EMTPPanicRoutingConflict);
+            }
+        else
+            {
+            User::LeaveIfError(err);
+            }
+        }
+    const TInt KIdx(NodeFind(aMap));
+    __ASSERT_DEBUG((KIdx != KErrNotFound), User::Invariant());
+    return KIdx;
+    }
+    
+/**
+Provides the source parameter value from the specified source parameter set 
+appropriate to the parameter level of the map.
+@param aFrom The map source parameter set.
+@return The parameter value.
+*/
+TUint CMTPParserRouter::CMap::Param(const RArray<TUint>& aFrom) const
+    {
+    return (aFrom[ParamIdx(aFrom)]);
+    }
+    
+/**
+Provides the source parameter set index of the source parameter corresponding to the 
+parameter level of the map.
+@param aFrom The map source parameter set.
+@return The parameter set index.
+*/
+TUint CMTPParserRouter::CMap::ParamIdx(const RArray<TUint>& aFrom) const
+    {
+    return (aFrom.Count() - ParamsCount(iSubType));
+    }
+
+/**
+Selects all map targets at the parameter level of the map.
+@param aFrom The map source parameter set.
+@param aTo The matching target parameters.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::CMap::SelectTargetAllL(const RArray<TUint>& aFrom, RArray<TUint>& aTo) const
+    {
+    if (Params(iSubType) == ESubTypeParams1)
+        {
+        // Node.
+        const TUint KCount(iToNodes.Count());
+        for (TUint idx(0); (idx < KCount); idx++)
+            {
+            SelectTargetL(iToNodes[idx].iTo, aTo);
+            }
+        }
+    else
+        {
+        // Branch.
+        const TUint KCount(iToBranches.Count());
+        for (TUint idx(0); (idx < KCount); idx++)
+            {
+            iToBranches[idx]->GetToL(aFrom, aTo);
+            }
+        }
+    }
+
+/**
+Selects all map targets which match the specified source parameters.
+@param aFrom The map source parameter set.
+@param aTo The matching target parameters.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::CMap::SelectTargetMatchingL(const RArray<TUint>& aFrom, RArray<TUint>& aTo) const
+    {
+    __FLOG(_L8("CMap::SelectTargetMatchingL - entry"));
+    const TUint KFrom(Param(aFrom));
+    TInt idx(KErrNotFound);
+    if (Params(iSubType) == ESubTypeParams1)
+        {
+        idx = iToNodes.SpecificFindInOrder(TMap(KFrom), ((iSubType & ESubTypeFlagOrderDescending) ? NodeOrderFromDescending : NodeOrderFromAscending), EArrayFindMode_First);                
+        if (idx != KErrNotFound)
+            {
+            const TUint KCount(iToNodes.Count());
+            while ((idx < KCount) && (iToNodes[idx].iFrom == KFrom))
+                {
+                SelectTargetL(iToNodes[idx++].iTo, aTo);
+                }
+            }
+        }
+    else
+        {
+        CMap* from(CMap::NewLC(KFrom, iSubType));
+        idx = iToBranches.SpecificFindInOrder(from, ((iSubType & ESubTypeFlagOrderDescending) ? BranchOrderFromDescending : BranchOrderFromAscending), EArrayFindMode_First);
+        CleanupStack::PopAndDestroy(from);
+        const TUint KCount(iToBranches.Count());
+        while ((idx < KCount) && (iToBranches[idx]->From() == KFrom))
+            {
+            iToBranches[idx++]->GetToL(aFrom, aTo);
+            }
+        }
+	__FLOG(_L8("CMap::SelectTargetMatchingL - exit"));        
+    }
+
+/**
+Selects the first map target which matches the specified source parameters.
+@param aFrom The map source parameter set.
+@param aTo The matching target parameters.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::CMap::SelectTargetSingleL(const RArray<TUint>& aFrom, RArray<TUint>& aTo) const
+    {
+    const TUint KFrom(Param(aFrom));
+    TInt idx(KErrNotFound);
+    if (Params(iSubType) == ESubTypeParams1)
+        {
+        idx = NodeFind(KFrom);
+        if (idx != KErrNotFound)
+            {
+            SelectTargetL(iToNodes[idx].iTo, aTo);
+            }
+        }
+    else
+        {
+        idx = BranchFind(KFrom);
+        if (idx != KErrNotFound)
+            {
+            iToBranches[idx]->GetToL(aFrom, aTo);
+            }
+        }
+    }
+    
+/**
+Implements an @see TLinearOrder relation for @see CMTPParserRouter::CMap 
+branch map objects based on ascending map source parameter order.
+@param aL The first object instance.
+@param aR The second object instance.
+@return Zero, if the two objects are equal; A negative value, if the first 
+object is less than the second, or; A positive value, if the first object is 
+greater than the second.
+*/
+TInt CMTPParserRouter::CMap::BranchOrderFromAscending(const CMap& aL, const CMap& aR)
+    {
+    return (aL.iFrom - aR.iFrom);
+    }
+    
+/**
+Implements an @see TLinearOrder relation for @see CMTPParserRouter::CMap 
+branch map objects based on descending map source parameter order.
+@param aL The first object instance.
+@param aR The second object instance.
+@return Zero, if the two objects are equal; A positive value, if the first 
+object is less than the second, or; A negative value, if the first object is 
+greater than the second.
+*/
+TInt CMTPParserRouter::CMap::BranchOrderFromDescending(const CMap& aL, const CMap& aR)
+    {
+    return (aR.iFrom - aL.iFrom);
+    }
+    
+/**
+Implements a map source parameter key identity relation for 
+@see CMTPParserRouter::CMap branch map objects based on ascending key order.
+@param aL The first object instance.
+@param aR The second object instance.
+@return Zero, if the two objects are equal; A negative value, if the first 
+object is less than the second, or; A positive value, if the first object is 
+greater than the second.
+*/
+TInt CMTPParserRouter::CMap::BranchOrderFromKeyAscending(const TUint* aL, const CMap& aR)
+    {
+    return (*aL - aR.iFrom);
+    }
+    
+/**
+Implements a map source parameter key identity relation for 
+@see CMTPParserRouter::CMap branch map objects based on descending key order.
+@param aL The first object instance.
+@param aR The second object instance.
+@return Zero, if the two objects are equal; A positive value, if the first 
+object is less than the second, or; A negative value, if the first object is 
+greater than the second.
+*/
+TInt CMTPParserRouter::CMap::BranchOrderFromKeyDescending(const TUint* aL, const CMap& aR)
+    {
+    return (aR.iFrom - *aL);
+    }
+    
+/**
+Implements an @see TLinearOrder relation for @see CMTPParserRouter::TMap 
+node map objects based on ascending map source parameter order.
+@param aL The first object instance.
+@param aR The second object instance.
+@return Zero, if the two objects are equal; A negative value, if the first 
+object is less than the second, or; A positive value, if the first object is 
+greater than the second.
+*/
+TInt CMTPParserRouter::CMap::NodeOrderFromAscending(const TMap& aL, const TMap& aR)
+    {
+    return (aL.iFrom - aR.iFrom);
+    }
+    
+/**
+Implements an @see TLinearOrder relation for @see CMTPParserRouter::TMap 
+node map objects based on descending map source parameter order.
+@param aL The first object instance.
+@param aR The second object instance.
+@return Zero, if the two objects are equal; A positive value, if the first 
+object is less than the second, or; A negative value, if the first object is 
+greater than the second.
+*/
+TInt CMTPParserRouter::CMap::NodeOrderFromDescending(const TMap& aL, const TMap& aR)
+    {
+    return (aR.iFrom - aL.iFrom);
+    }
+    
+/**
+Implements a map source parameter key identity relation for 
+@see CMTPParserRouter::TMap node map objects based on ascending key order.
+@param aL The first object instance.
+@param aR The second object instance.
+@return Zero, if the two objects are equal; A negative value, if the first 
+object is less than the second, or; A positive value, if the first object is 
+greater than the second.
+*/
+TInt CMTPParserRouter::CMap::NodeOrderFromKeyAscending(const TUint* aL, const TMap& aR)
+    {
+    return (*aL - aR.iFrom);
+    }
+    
+/**
+Implements a map source parameter key identity relation for 
+@see CMTPParserRouter::TMap node map objects based on descending key order.
+@param aL The first object instance.
+@param aR The second object instance.
+@return Zero, if the two objects are equal; A positive value, if the first 
+object is less than the second, or; A negative value, if the first object is 
+greater than the second.
+*/
+TInt CMTPParserRouter::CMap::NodeOrderFromKeyDescending(const TUint* aL, const TMap& aR)
+    {
+    return (aR.iFrom - *aL);
+    }
+    
+/**
+Implements an @see TLinearOrder relation for @see CMTPParserRouter::CMap 
+branch map objects based on ascending map source and target parameter order.
+@param aL The first object instance.
+@param aR The second object instance.
+@return Zero, if the two objects are equal; A negative value, if the first 
+object is less than the second, or; A positive value, if the first object is 
+greater than the second.
+*/
+TInt CMTPParserRouter::CMap::NodeOrderFromToAscending(const TMap& aL, const TMap& aR)
+    {
+    TInt ret(0);
+    if (aL.iFrom != aR.iFrom)
+        {
+        ret = (aL.iFrom - aR.iFrom);
+        }
+    else
+        {
+        ret = (aL.iTo - aR.iTo);
+        }
+    return ret;
+    }
+    
+/**
+Implements an @see TLinearOrder relation for @see CMTPParserRouter::CMap 
+branch map objects based on descending map source and target parameter order.
+@param aL The first object instance.
+@param aR The second object instance.
+@return Zero, if the two objects are equal; A positive value, if the first 
+object is less than the second, or; A negative value, if the first object is 
+greater than the second.
+*/
+TInt CMTPParserRouter::CMap::NodeOrderFromToDescending(const TMap& aL, const TMap& aR)
+    {
+    TInt ret(0);
+    if (aL.iFrom != aR.iFrom)
+        {
+        ret = aR.iFrom - aL.iFrom;
+        }
+    else
+        {
+        ret = aR.iTo - aL.iTo;
+        }
+    return ret;
+    }
+
+/**
+Constructor.
+*/
+CMTPParserRouter::CMTPParserRouter()
+    {
+    
+    }
+    
+/**
+Second-phase constructor.
+*/
+void CMTPParserRouter::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL, Entry"));
+    iSingletons.OpenL();
+    __FLOG(_L8("ConstructL, Exit"));
+    }
+    
+/**
+Provides the set of @see TMTPSupportCategory codes which comprise each of the 
+lookup parameters for the specified routing sub-type (routing map).
+@param aSubType The routing sub-type identifier.
+@param aP1Codes On exit, the set of @see TMTPSupportCategory codes which 
+comprise the first lookup parameter. This set will be empty if the routing
+sub-type implements fewer than one parameter.
+@param aP2Codes On exit, the set of @see TMTPSupportCategory codes which 
+comprise the second lookup parameter. This set will be empty if the routing
+sub-type implements fewer than two parameters.
+@param aP2Codes On exit, the set of @see TMTPSupportCategory codes which 
+comprise the third lookup parameter. This set will be empty if the routing
+sub-type implements fewer than three parameters.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::GetMapParameterIdsL(TUint aSubType, RArray<TUint>& aP1Codes, RArray<TUint>& aP2Codes, RArray<TUint>& aP3Codes)
+    {
+    aP1Codes.Reset();
+    aP2Codes.Reset();
+    aP3Codes.Reset();
+    
+    switch (aSubType)
+        {
+    case ESubTypeDevicePropCode:
+        aP1Codes.AppendL(EDeviceProperties);
+        break;
+        
+    case ESubTypeObjectPropCode:
+        aP1Codes.AppendL(EObjectProperties);
+        break;
+        
+    case ESubTypeOperationCode:
+        aP1Codes.AppendL(EOperations);
+        break;
+        
+    case ESubTypeStorageType:
+        aP1Codes.AppendL(EStorageSystemTypes);
+        break;
+        
+    case ESubTypeFormatCodeFormatSubcode:
+        aP1Codes.AppendL(EObjectCaptureFormats);
+        aP1Codes.AppendL(EObjectPlaybackFormats);
+        aP2Codes.AppendL(EAssociationTypes);
+        break;
+        
+    case ESubTypeFormatCodeOperationCode:
+        aP1Codes.AppendL(EObjectCaptureFormats);
+        aP1Codes.AppendL(EObjectPlaybackFormats);
+        aP2Codes.AppendL(EOperations);
+        break;
+        
+    case ESubTypeStorageTypeOperationCode:
+        aP1Codes.AppendL(EStorageSystemTypes);
+        aP2Codes.AppendL(EOperations);
+        break;
+        
+    case ESubTypeFormatCodeFormatSubcodeStorageType:
+        aP1Codes.AppendL(EObjectCaptureFormats);
+        aP1Codes.AppendL(EObjectPlaybackFormats);
+        aP2Codes.AppendL(EAssociationTypes);
+        aP3Codes.AppendL(EStorageSystemTypes);
+        break;
+        
+    case ESubTypeServiceIDOperationCode:
+        aP1Codes.AppendL(EServiceIDs);
+        break;   
+        
+    default:
+        __DEBUG_ONLY(User::Invariant());
+        break;
+        }
+    }
+
+/**
+Selects the specified data provider target identifier by appending it to the 
+set of selected targets. Each target identifier may only appear once in the 
+set of selected targets. A selected target which is already a member of the 
+selected set will be replaced to ensure that targets are dispatched in order
+of most recent selection.
+@param aTarget The data provider target identifier.
+@param aTargets The set of selected targets.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+
+*/    
+void CMTPParserRouter::SelectTargetL(TUint aTarget, RArray<TUint>& aTargets)
+    {
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("SelectTargetL, Entry"));
+    TInt idx(aTargets.Find(aTarget));
+    if (idx != KErrNotFound)
+        {
+        aTargets.Remove(idx);
+        }
+    aTargets.AppendL(aTarget);
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("SelectTargetL, Exit"));
+    }
+
+/**
+Configures (loads) the specified one lookup parameter routing sub-type map. The
+map is constructed by interrogating each data provider in turn and building a 
+set of map table entries which resolve each supported @see TMTPSupportCategory 
+code to its data provider (target) identifier.
+@param aSubType The routing sub-type identifier.
+@param aP1Codes The set of @see TMTPSupportCategory codes which comprise the 
+first lookup parameter.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::Configure1ParameterMapL(TUint aSubType, const RArray<TUint>& aP1Codes)
+    {
+    CMap& map(*iMaps[aSubType & ESubTypeIndexMask]);
+    RArray<TUint> from;
+    CleanupClosePushL(from);
+    map.InitParamsL(from);
+    
+    const TUint KCount(iSingletons.DpController().Count());
+    for (TUint d(0); (d < KCount); d++)
+        {
+        CMTPDataProvider& dp(iSingletons.DpController().DataProviderByIndexL(d));
+        __FLOG(_L8(""));
+        __FLOG_VA((_L8("Creating DP %02d Table 0x%08X Entries"), dp.DataProviderId(), aSubType));
+        __FLOG(_L8("---------------------------------------")); 
+        
+        RArray<TUint> p1s;
+        CleanupClosePushL(p1s);
+        GetConfigParametersL(dp, aP1Codes, p1s);
+        const TUint KCountP1s(p1s.Count());
+        for (TUint p1(0); (p1 < KCountP1s); p1++)
+            {
+            const TUint KP1(p1s[p1]);
+            from[EParam1] = KP1;
+            map.InsertL(from, dp.DataProviderId());
+            }
+        CleanupStack::PopAndDestroy(&p1s);
+        __FLOG(_L8(""));
+        }
+    CleanupStack::PopAndDestroy(&from);
+    }
+
+/**
+Configures (loads) the specified two lookup parameter routing sub-type map. The
+map is constructed by interrogating each data provider in turn and building a 
+set of map table entries which resolve each combination of supported 
+@see TMTPSupportCategory codes to its data provider (target) identifier.
+@param aSubType The routing sub-type identifier.
+@param aP1Codes The set of @see TMTPSupportCategory codes which comprise the 
+first lookup parameter.
+@param aP2Codes The set of @see TMTPSupportCategory codes which comprise the 
+second lookup parameter.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::Configure2ParameterMapL(TUint aSubType, const RArray<TUint>& aP1Codes, const RArray<TUint>& aP2Codes)
+    {
+    CMap& map(*iMaps[aSubType & ESubTypeIndexMask]);
+    RArray<TUint> from;
+    CleanupClosePushL(from);
+    map.InitParamsL(from);
+    
+    const TUint KCountDps(iSingletons.DpController().Count());
+    for (TUint d(0); (d < KCountDps); d++)
+        {
+        CMTPDataProvider& dp(iSingletons.DpController().DataProviderByIndexL(d));
+        __FLOG(_L8(""));
+        __FLOG_VA((_L8("Creating DP %02d Table 0x%08X Entries"), dp.DataProviderId(), aSubType));
+        __FLOG(_L8("---------------------------------------"));
+        
+        RArray<TUint> p1s;
+        CleanupClosePushL(p1s);
+        GetConfigParametersL(dp, aP1Codes, p1s);
+        const TUint KCountP1s(p1s.Count());
+        for (TUint p1(0); (p1 < KCountP1s); p1++)
+            {
+            const TUint KP1(p1s[p1]);
+            from[EParam1] = KP1;
+            if ((aSubType == ESubTypeFormatCodeFormatSubcode) && 
+                (KP1 != EMTPFormatCodeAssociation))
+                {
+                from[EParam2] = EMTPAssociationTypeUndefined;
+                map.InsertL(from, dp.DataProviderId());
+                }
+            else
+                {
+                RArray<TUint> p2s;
+                CleanupClosePushL(p2s);
+                GetConfigParametersL(dp, aP2Codes, p2s);
+                const TUint KCountP2s(p2s.Count());
+                for (TUint p2(0); (p2 < KCountP2s); p2++)
+                    {
+                    const TUint KP2(p2s[p2]);
+                    from[EParam2] = KP2;
+                    map.InsertL(from, dp.DataProviderId());
+                    }
+                CleanupStack::PopAndDestroy(&p2s);
+                }
+            }
+        CleanupStack::PopAndDestroy(&p1s);
+        __FLOG(_L8(""));
+        } 
+    CleanupStack::PopAndDestroy(&from);
+    }
+
+/**
+Configures (loads) the specified three lookup parameter routing sub-type map. 
+The map is constructed by interrogating each data provider in turn and building
+a set of map table entries which resolve each combination of supported 
+@see TMTPSupportCategory codes to its data provider (target) identifier.
+@param aSubType The routing sub-type identifier.
+@param aP1Codes The set of @see TMTPSupportCategory codes which comprise the 
+first lookup parameter.
+@param aP2Codes The set of @see TMTPSupportCategory codes which comprise the 
+second lookup parameter.
+@param aP3Codes The set of @see TMTPSupportCategory codes which comprise the 
+third lookup parameter.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::Configure3ParameterMapL(TUint aSubType, const RArray<TUint>& aP1Codes, const RArray<TUint>& aP2Codes, const RArray<TUint>& aP3Codes)
+    {
+    CMap& map(*iMaps[aSubType & ESubTypeIndexMask]);
+    RArray<TUint> from;
+    CleanupClosePushL(from);
+    map.InitParamsL(from);
+    
+    const TUint KCount(iSingletons.DpController().Count());
+    for (TUint d(0); (d < KCount); d++)
+        {
+        CMTPDataProvider& dp(iSingletons.DpController().DataProviderByIndexL(d));
+        __FLOG(_L8(""));
+        __FLOG_VA((_L8("Creating DP %02d Table 0x%08X Entries"), dp.DataProviderId(), aSubType));
+        __FLOG(_L8("---------------------------------------"));
+        
+        RArray<TUint> p1s;
+        CleanupClosePushL(p1s);
+        GetConfigParametersL(dp, aP1Codes, p1s);
+        const TUint KCountP1s(p1s.Count());
+        for (TUint p1(0); (p1 < KCountP1s); p1++)
+            {
+            RArray<TUint> p3s;
+            CleanupClosePushL(p3s);
+            const TUint KP1(p1s[p1]);
+            from[EParam1] = KP1;
+            if ((aSubType == ESubTypeFormatCodeFormatSubcodeStorageType) && 
+                (KP1 != EMTPFormatCodeAssociation))
+                {
+                from[EParam2] = EMTPAssociationTypeUndefined;
+                GetConfigParametersL(dp, aP3Codes, p3s);
+                const TUint KCountP3s(p3s.Count());
+                for (TUint p3(0); (p3 < KCountP3s); p3++)
+                    {
+                    const TUint KP3(p3s[p3]);
+                    from[EParam3] = KP3;
+                    map.InsertL(from, dp.DataProviderId());
+                    }
+                }
+            else
+                {
+                RArray<TUint> p2s;
+                CleanupClosePushL(p2s);
+                GetConfigParametersL(dp, aP2Codes, p2s);
+                const TUint KCountP2s(p2s.Count());
+                for (TUint p2(0); (p2 < KCountP2s); p2++)
+                    {
+                    const TUint KP2(p2s[p2]);
+                    from[EParam2] = KP2;
+                    GetConfigParametersL(dp, aP3Codes, p3s);
+                    const TUint KCountP3s(p3s.Count());
+                    for (TUint p3(0); (p3 < KCountP3s); p3++)
+                        {
+                        const TUint KP3(p3s[p3]);
+                        from[EParam3] = KP3;
+                        map.InsertL(from, dp.DataProviderId());
+                        }
+                    }
+                CleanupStack::PopAndDestroy(&p2s);
+                }
+            CleanupStack::PopAndDestroy(&p3s);
+            }
+        CleanupStack::PopAndDestroy(&p1s);
+        __FLOG(_L8(""));
+        }
+    CleanupStack::PopAndDestroy(&from);
+    }
+
+/**
+Obtains the set of supported @see TMTPSupportCategory code parameter values 
+supported by the specified data provider.
+@param aDp The data provider.
+@param aCodes The set of @see TMTPSupportCategory codes which comprise the 
+parameter.
+@param aParams On exit, the set of supported parameter values.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::GetConfigParametersL(const CMTPDataProvider& aDp, const RArray<TUint>& aCodes, RArray<TUint>& aParams) const
+    {
+    aParams.Reset();
+    const TUint KCountCodes(aCodes.Count());
+    for (TUint c(0); (c < KCountCodes); c++)
+        {
+        const RArray<TUint>& KParams(aDp.SupportedCodes(static_cast<TMTPSupportCategory>(aCodes[c])));
+        const TUint KCountParams(KParams.Count());
+        for (TUint p(0); (p < KCountParams); p++)
+            {
+            if(( EServiceIDs == aCodes[c] )&&( iSingletons.ServiceMgr().IsSupportedService( KParams[p] )) )
+                {
+                __FLOG_1(_L8("GetConfigParametersL, abstract service id = %d"), KParams[p]);
+                continue;
+                }
+            TInt err(aParams.InsertInOrder(KParams[p]));
+            if ((err != KErrNone) && (err != KErrAlreadyExists))
+                {
+                User::Leave(err);
+                }
+            }
+        }
+    }
+
+/**
+Provides the set of operation parameter routing and validation sub-types to be 
+executed against each of the specified operation routing parameter data.
+@param aParams The set of operation routing parameter data.
+@param aRoutingSubTypes On exit, the set of routing sub-types to be executed.
+@param aValidationSubTypes On exit, the set of validation sub-types to be executed. 
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::GetRoutingSubTypesL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const
+    {
+    __FLOG(_L8("GetRoutingSubTypesL, Entry"));
+    __ASSERT_DEBUG((aParams.Count() > 0), User::Invariant());
+    aRoutingSubTypes.Reset();
+    aValidationSubTypes.Reset();
+    
+    TRoutingParameters& params1(aParams[0]);
+    if (params1.Param(TRoutingParameters::EFlagInvalid))
+        {
+        SelectSubTypeRoutingL(ESubTypeDpDevice, aRoutingSubTypes, aValidationSubTypes, aParams);
+        }
+    else
+        {
+        const TUint KOpCode(params1.Request().Uint16(TMTPTypeRequest::ERequestOperationCode));
+        const TUint KRoutingTypes(params1.Param(TRoutingParameters::EFlagRoutingTypes));
+        switch (KOpCode)
+            {
+        case EMTPOpCodeGetDeviceInfo:
+        case EMTPOpCodeOpenSession:
+        case EMTPOpCodeCloseSession:
+        case EMTPOpCodeGetStorageIDs:
+        case EMTPOpCodeGetNumObjects:
+        case EMTPOpCodeGetObjectHandles:
+        case EMTPOpCodeFormatStore:
+        case EMTPOpCodeResetDevice:
+        case EMTPOpCodeSelfTest:
+        case EMTPOpCodePowerDown:
+            if (KRoutingTypes & ETypeFramework)
+                {
+                SelectSubTypeRoutingL(ESubTypeDpDevice, aRoutingSubTypes, aValidationSubTypes, aParams);
+                }
+            break;
+            
+        case EMTPOpCodeDeleteObject:
+            GetRoutingSubTypesDeleteRequestL(aParams, aRoutingSubTypes, aValidationSubTypes);
+            break;
+            
+        case EMTPOpCodeGetObjectPropList:
+            GetRoutingSubTypesGetObjectPropListRequestL(aParams, aRoutingSubTypes, aValidationSubTypes);
+            break;
+
+        case EMTPOpCodeSetObjectPropList:
+            if (KRoutingTypes & ETypeFramework)
+                {
+                SelectSubTypeRoutingL(ESubTypeDpProxy, aRoutingSubTypes, aValidationSubTypes, aParams);
+                }
+            else if (KRoutingTypes & ETypeOperationParameter)
+                {
+                SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams);
+                SelectSubTypeValidationL(ESubTypeObjectPropCode, aValidationSubTypes);
+                }
+            break;
+            
+        case EMTPOpCodeSendObjectInfo:
+            if (KRoutingTypes & ETypeFramework)
+                {
+                SelectSubTypeRoutingL(ESubTypeDpProxy, aRoutingSubTypes, aValidationSubTypes, aParams);
+                }
+            else if (KRoutingTypes & ETypeOperationParameter)
+                {
+                SelectSubTypeRoutingL(ESubTypeFormatCodeFormatSubcodeStorageType, aRoutingSubTypes, aValidationSubTypes, aParams); 
+                }
+            break;
+            
+        case EMTPOpCodeGetDevicePropDesc:
+        case EMTPOpCodeGetDevicePropValue:
+        case EMTPOpCodeSetDevicePropValue:
+        case EMTPOpCodeResetDevicePropValue:
+            if (KRoutingTypes & ETypeOperationParameter)
+                {
+                SelectSubTypeRoutingL(ESubTypeDevicePropCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+                }
+            break;
+
+        case EMTPOpCodeGetObjectPropsSupported:
+            if (KRoutingTypes & ETypeOperationParameter)
+                {
+                SelectSubTypeRoutingL(ESubTypeFormatCodeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+                }
+            break;
+
+        case EMTPOpCodeSkip:
+            if (KRoutingTypes & ETypeOperationParameter)
+                {
+                SelectSubTypeRoutingL(ESubTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+                params1.SetParam(TRoutingParameters::EFlagRoutingTypes, (KRoutingTypes | ETypeFlagSingleTarget));
+                }
+            break;
+
+        case EMTPOpCodeGetObjectPropDesc:
+            if (KRoutingTypes & ETypeOperationParameter)
+                {
+                SelectSubTypeRoutingL(ESubTypeFormatCodeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+                SelectSubTypeValidationL(ESubTypeObjectPropCode, aValidationSubTypes);
+                params1.SetParam(TRoutingParameters::EFlagRoutingTypes, (KRoutingTypes | ETypeFlagSingleTarget));
+                }
+            break;
+
+        case EMTPOpCodeGetInterdependentPropDesc:
+            if (KRoutingTypes & ETypeOperationParameter)
+                {
+                SelectSubTypeRoutingL(ESubTypeFormatCodeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+                }
+            break;
+            
+        case EMTPOpCodeInitiateCapture:
+        case EMTPOpCodeInitiateOpenCapture:
+            if (KRoutingTypes & ETypeOperationParameter)
+                {
+                SelectSubTypeRoutingL(ESubTypeFormatCodeFormatSubcodeStorageType, aRoutingSubTypes, aValidationSubTypes, aParams);
+                }
+            break;
+            
+        case EMTPOpCodeSendObjectPropList:
+            GetRoutingSubTypesSendObjectPropListRequestL(aParams, aRoutingSubTypes, aValidationSubTypes);
+            break;
+            
+        case EMTPOpCodeMoveObject:    
+        case EMTPOpCodeCopyObject:
+        	GetRoutingSubTypesCopyMoveRequestL(aParams, aRoutingSubTypes, aValidationSubTypes);
+        	break;
+        case EMTPOpCodeGetObjectInfo:
+        case EMTPOpCodeGetObject:
+        case EMTPOpCodeGetThumb:
+        case EMTPOpCodeGetPartialObject:
+        case EMTPOpCodeGetObjectReferences:
+        case EMTPOpCodeSetObjectReferences:
+        case EMTPOpCodeUpdateObjectPropList :
+            if (KRoutingTypes & ETypeOperationParameter)
+                {
+                SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams);
+                }
+            break;
+            
+        case EMTPOpCodeGetObjectPropValue:
+        case EMTPOpCodeSetObjectPropValue:
+            if (KRoutingTypes & ETypeOperationParameter)
+                {
+                SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams);
+                SelectSubTypeValidationL(ESubTypeObjectPropCode, aValidationSubTypes);
+                }
+            break;
+            
+        case EMTPOpCodeGetStorageInfo:
+            if (KRoutingTypes & ETypeOperationParameter)
+                {
+                SelectSubTypeRoutingL(ESubTypeOwnerStorage, aRoutingSubTypes, aValidationSubTypes, aParams);
+                }
+            break;
+
+        case EMTPOpCodeSendObject:
+        case EMTPOpCodeTerminateOpenCapture:
+            if (KRoutingTypes & ETypeRequestRegistration)
+                {
+                SelectSubTypeRoutingL(ESubTypeRequestRegistration, aRoutingSubTypes, aValidationSubTypes, aParams);
+                }
+            break;
+
+        case EMTPOpCodeGetServiceInfo:     
+        case EMTPOpCodeGetServiceCapabilities:
+        case EMTPOpCodeGetServicePropDesc:
+        case EMTPOpCodeGetServicePropList:
+        case EMTPOpCodeSetServicePropList:
+        case EMTPOpCodeDeleteServicePropList:
+            {
+            if ( iSingletons.ServiceMgr().IsSupportedService( params1.Param(TRoutingParameters::EParamServiceId) ) )
+                {
+                SelectSubTypeRoutingL(ESubTypeDpDevice, aRoutingSubTypes, aValidationSubTypes, aParams);
+                }
+            else
+                {
+                SelectSubTypeRoutingL(ESubTypeServiceIDOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+                }
+            }
+            break;
+        case EMTPOpCodeDeleteObjectPropList :
+            {
+            GetRoutingSubTypesDeleteObjectPropListL( aParams, aRoutingSubTypes, aValidationSubTypes );
+            }
+            break;
+        case EMTPOpCodeGetFormatCapabilities:
+            {
+            GetRoutingSubTypesGetFormatCapabilitiesL(aParams, aRoutingSubTypes, aValidationSubTypes);
+            }
+            break;
+        case EMTPOpCodeSetObjectProtection:
+            SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams);
+            break;
+        default:
+            if (KRoutingTypes & ETypeRequestRegistration)
+                {
+                SelectSubTypeRoutingL(ESubTypeRequestRegistration, aRoutingSubTypes, aValidationSubTypes, aParams);
+                }
+            if (KRoutingTypes & ETypeFramework)
+                {
+                SelectSubTypeRoutingL(ESubTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+                params1.SetParam(TRoutingParameters::EFlagRoutingTypes, (KRoutingTypes | ETypeFlagSingleTarget));
+                }
+            break;
+            }
+        }
+    __FLOG(_L8("GetRoutingSubTypesL, Exit"));
+    }
+
+/**
+Provides the set of operation parameter routing and validation sub-types to be 
+executed against each of the specified MTP DeleteObject operation routing 
+parameter data.
+@param aParams The set of operation routing parameter data.
+@param aRoutingSubTypes On exit, the set of routing sub-types to be executed.
+@param aValidationSubTypes On exit, the set of validation sub-types to be executed. 
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::GetRoutingSubTypesDeleteRequestL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const
+    {
+    __FLOG(_L8("GetRoutingSubTypesDeleteRequestL, Entry"));
+    TRoutingParameters& params1(aParams[0]);
+    __ASSERT_DEBUG((params1.Request().Uint16(TMTPTypeRequest::ERequestOperationCode) == EMTPOpCodeDeleteObject), User::Invariant());
+    
+    const TUint KObjectHandle(params1.Param(TRoutingParameters::EParamObjectHandle));
+    const TUint KObjectFormatCode(params1.Param(TRoutingParameters::EParamFormatCode));
+    if (KObjectHandle == KMTPHandleAll)
+        {
+        if (KObjectFormatCode == KMTPFormatsAll || KObjectFormatCode == EMTPFormatCodeAssociation)
+            {
+            /* 
+            Deleting all objects of all formats. Force the format to 
+            Association to ensure that objects are deleted in the correct
+            order.
+            */
+            if (KObjectFormatCode == KMTPFormatsAll)
+            	{
+            	params1.SetParam(TRoutingParameters::EParamFormatCode, EMTPFormatCodeAssociation);
+            	}
+                SelectSubTypeRoutingL(ESubTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+            }
+        else if ( KObjectFormatCode == EMTPFormatCodeUndefined )
+            {
+            SelectSubTypeRoutingL(ESubTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+            }
+        SelectSubTypeRoutingL(ESubTypeFormatCodeFormatSubcode, aRoutingSubTypes, aValidationSubTypes, aParams);
+        }
+    else if (KObjectHandle != KMTPHandleNone)
+        {
+        if (KObjectFormatCode == EMTPFormatCodeAssociation)
+            {
+            SelectSubTypeRoutingL(ESubTypeStorageTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+            }
+        SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams);
+        }
+    __FLOG(_L8("GetRoutingSubTypesDeleteRequestL, Exit"));
+    }
+
+/**
+Provides the set of operation parameter routing and validation sub-types to be 
+executed against each of the specified MTP CopyObject and MoveObject operation routing 
+parameter data.
+@param aParams The set of operation routing parameter data.
+@param aRoutingSubTypes On exit, the set of routing sub-types to be executed.
+@param aValidationSubTypes On exit, the set of validation sub-types to be executed. 
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::GetRoutingSubTypesCopyMoveRequestL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const
+	{
+	__FLOG(_L8("GetRoutingSubTypesCopyMoveRequestL, Entry"));
+	const TUint KObjectFormatCode(aParams[0].Param(TRoutingParameters::EParamFormatCode));
+	if (KObjectFormatCode == EMTPFormatCodeAssociation)
+        {
+        SelectSubTypeRoutingL(ESubTypeStorageTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+        }
+    else
+    	{
+    	SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams);    
+    	}
+	__FLOG(_L8("GetRoutingSubTypesCopyMoveRequestL, Exit"));    
+	}
+/**
+Provides the set of operation parameter routing and validation sub-types to be 
+executed against each of the specified MTP GetObjectPropList operation routing 
+parameter data.
+@param aParams The set of operation routing parameter data.
+@param aRoutingSubTypes On exit, the set of routing sub-types to be executed.
+@param aValidationSubTypes On exit, the set of validation sub-types to be executed. 
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::GetRoutingSubTypesGetObjectPropListRequestL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const
+    {
+    __FLOG(_L8("GetRoutingSubTypesGetObjectPropListRequestL, Entry"));
+    TRoutingParameters& params1(aParams[0]);
+    __ASSERT_DEBUG((params1.Request().Uint16(TMTPTypeRequest::ERequestOperationCode) == EMTPOpCodeGetObjectPropList), User::Invariant());
+    if (params1.Param(TRoutingParameters::EFlagRoutingTypes) & ETypeOperationParameter)
+        {
+        const TUint KObjectHandle(params1.Param(TRoutingParameters::EParamObjectHandle));
+        const TUint KObjectFormatCode(params1.Param(TRoutingParameters::EParamFormatCode));
+        const TUint KObjectFormatSubCode(params1.Param(TRoutingParameters::EParamFormatSubCode));
+        const TUint KObjectPropCode(params1.Param(TRoutingParameters::EParamObjectPropCode));
+        if ((KObjectHandle == KMTPHandleAll) || 
+            (KObjectHandle == KMTPHandleAllRootLevel))
+            {
+            // All objects or all root level objects.
+            if (KObjectFormatCode == KMTPFormatsAll)
+                {
+                SelectSubTypeRoutingL(ESubTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+                }
+            else
+                {
+                SelectSubTypeRoutingL(ESubTypeFormatCodeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+                }
+            }
+        else if (KObjectHandle != KMTPHandleNone)
+            {
+             if( (KObjectFormatCode == EMTPFormatCodeAssociation) && (KObjectFormatSubCode == EMTPAssociationTypeGenericFolder) )
+                 {
+					 if ( params1.Param(TRoutingParameters::EFlagRoutingTypes) & ETypeFramework )
+					 {
+					 SelectSubTypeRoutingL(ESubTypeDpProxy, aRoutingSubTypes, aValidationSubTypes, aParams);
+					 }
+					 else
+					 {
+					 SelectSubTypeRoutingL(ESubTypeStorageTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+					 SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams);
+					 }
+                 }
+             else
+            	 {
+                 SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams);
+            	 }
+             } 
+        
+
+        if (KObjectPropCode != KMTPObjectPropCodeAll)
+            {
+            SelectSubTypeValidationL(ESubTypeObjectPropCode, aValidationSubTypes);
+            }
+        }
+    __FLOG(_L8("GetRoutingSubTypesGetObjectPropListRequestL, Exit"));
+    }
+
+/**
+Provides the set of operation parameter routing and validation sub-types to be 
+executed against each of the specified MTP SendObjectPropList operation routing 
+parameter data.
+@param aParams The set of operation routing parameter data.
+@param aRoutingSubTypes On exit, the set of routing sub-types to be executed.
+@param aValidationSubTypes On exit, the set of validation sub-types to be executed. 
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::GetRoutingSubTypesSendObjectPropListRequestL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const
+    {
+    __FLOG(_L8("GetRoutingSubTypesSendObjectPropListRequestL, Entry"));
+    TRoutingParameters& params1(aParams[0]);
+    __ASSERT_DEBUG((params1.Request().Uint16(TMTPTypeRequest::ERequestOperationCode) == EMTPOpCodeSendObjectPropList), User::Invariant());
+    const TUint KRoutingTypes(params1.Param(TRoutingParameters::EFlagRoutingTypes));
+    if ((KRoutingTypes & ETypeFramework) &&
+        (params1.Param(TRoutingParameters::EParamFormatCode) == EMTPFormatCodeAssociation))
+        {
+        SelectSubTypeRoutingL(ESubTypeDpProxy, aRoutingSubTypes, aValidationSubTypes, aParams);
+        }
+    else if (KRoutingTypes & ETypeOperationParameter)
+        {
+        SelectSubTypeRoutingL(ESubTypeFormatCodeFormatSubcodeStorageType, aRoutingSubTypes, aValidationSubTypes, aParams);
+        }
+    __FLOG(_L8("GetRoutingSubTypesSendObjectPropListRequestL, Exit"));
+    }
+
+void CMTPParserRouter::GetRoutingSubTypesDeleteObjectPropListL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const
+    {
+    __FLOG(_L8("GetRoutingSubTypesDeleteObjectPropListL, Entry"));
+    TRoutingParameters& params1(aParams[0]);
+    
+    __ASSERT_DEBUG((params1.Request().Uint16(TMTPTypeRequest::ERequestOperationCode) == EMTPOpCodeDeleteObjectPropList), User::Invariant());
+    
+    const TUint KObjectHandle(params1.Param(TRoutingParameters::EParamObjectHandle));
+    if ((KObjectHandle == KMTPHandleAll) || (KObjectHandle == KMTPHandleNone))
+        {
+        SelectSubTypeRoutingL(ESubTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+        }
+    else 
+        {
+        SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams);
+        }
+
+    __FLOG(_L8("GetRoutingSubTypesDeleteObjectPropListL, Exit"));
+    }
+
+void CMTPParserRouter::GetRoutingSubTypesGetFormatCapabilitiesL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const
+    {
+    __FLOG(_L8("GetRoutingSubTypesGetFormatCapabilities, Entry"));
+    TRoutingParameters& params1(aParams[0]);
+    
+    __ASSERT_DEBUG((params1.Request().Uint16(TMTPTypeRequest::ERequestOperationCode) == EMTPOpCodeGetFormatCapabilities), User::Invariant());
+    
+    if( params1.Param(TRoutingParameters::EParamFormatCode) == KMTPFormatsAll)
+        {
+        SelectSubTypeRoutingL(ESubTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+        }
+    else if ( params1.Param(TRoutingParameters::EFlagRoutingTypes) & ETypeOperationParameter)
+        {
+        SelectSubTypeRoutingL(ESubTypeFormatCodeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+        }
+    
+    __FLOG(_L8("GetRoutingSubTypesGetFormatCapabilities, Exit"));
+    }
+
+/**
+Parses the specified MTP operation request dataset to extract the specified 
+parameter value together with any applicable meta-data. The parameter value 
+will be extracted only if not null (0x00000000).  
+@param aParam The operation request dataset parameter identifier.
+@param aType The operation request dataset parameter type.
+@param aParams The operation routing parameter data, updated on exit with the 
+parameter value together with any associated meta-data.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/    
+void CMTPParserRouter::ParseOperationRequestParameterL(TMTPTypeRequest::TElements aParam, TRoutingParameters::TParameterType aType, TRoutingParameters& aParams) const
+    {
+    __FLOG(_L8("ParseOperationRequestParameterL, Entry"));
+    const TUint32 KParam(aParams.Request().Uint32(aParam));    
+    __FLOG_VA((_L8("Parameter %d = 0x%08X"), (aParam - TMTPTypeRequest::ERequestParameter1 + 1), KParam));
+    
+    // Parse out the parameter value if a non-null value is present.
+    if (KParam != KMTPNotSpecified32)
+        {
+        aParams.SetParam(aType, KParam);
+        }
+    
+    // Extract any applicable meta-data.
+    switch (aType)
+        {
+    case TRoutingParameters::EParamStorageId:
+        {
+        CMTPStorageMgr& storages(iSingletons.StorageMgr());
+        if (KParam == KMTPStorageDefault) 
+            {
+            aParams.SetParam(TRoutingParameters::EParamStorageSystemType, storages.StorageL(storages.DefaultStorageId()).Uint(CMTPStorageMetaData::EStorageSystemType));
+            }
+        else if (storages.ValidStorageId(KParam))
+            {
+            aParams.SetParam(TRoutingParameters::EParamStorageSystemType, storages.StorageL(KParam).Uint(CMTPStorageMetaData::EStorageSystemType));
+            }
+        else
+            {
+            aParams.SetParam(TRoutingParameters::EFlagInvalid, ETrue);
+            }
+        }
+        break;
+        
+    case TRoutingParameters::EParamObjectHandle:
+        if ((KParam != KMTPHandleAll) && (KParam != KMTPHandleAllRootLevel))
+            {
+            CMTPObjectMetaData* obj(CMTPObjectMetaData::NewLC());
+            if (!iSingletons.ObjectMgr().ObjectL(aParams.Param(CMTPParserRouter::TRoutingParameters::EParamObjectHandle), *obj))
+                {
+                // Object does not exist.
+                aParams.SetParam(TRoutingParameters::EFlagInvalid, ETrue);
+                }
+            else
+                {
+                aParams.SetParam(CMTPParserRouter::TRoutingParameters::EParamFormatCode, obj->Uint(CMTPObjectMetaData::EFormatCode));
+                aParams.SetParam(CMTPParserRouter::TRoutingParameters::EParamFormatSubCode, obj->Uint(CMTPObjectMetaData::EFormatSubCode));
+                aParams.SetParam(CMTPParserRouter::TRoutingParameters::EParamStorageSystemType, iSingletons.StorageMgr().StorageL(obj->Uint(CMTPObjectMetaData::EStorageId)).Uint(CMTPStorageMetaData::EStorageSystemType));            
+                }
+            CleanupStack::PopAndDestroy(obj);
+            }
+        break;
+        
+    default:
+        break;
+        }    
+    __FLOG(_L8("ParseOperationRequestParameterL, Exit"));
+    }
+
+/**
+Resolves set of zero or more routing targets using the specified lookup 
+parameter based routing sub-type.
+@param aRoutingSubType The routing sub-type.
+@param aParams The operation routing parameter data.
+@param aTargets On exit, the seto of resolved routing targets.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::RouteOperationRequestNParametersL(TUint aRoutingSubType, const TRoutingParameters& aParams, RArray<TUint>& aTargets) const
+    {
+    __FLOG(_L8("RouteOperationRequestNParametersL, Entry"));
+    __FLOG_VA((_L8("Routing Sub-type = 0x%08X"), aRoutingSubType));
+    
+    // Build the set of map source parameter values.
+    RArray<TUint> from;
+    CleanupClosePushL(from);
+    switch (aRoutingSubType)
+        {
+    case ESubTypeDevicePropCode:
+        from.AppendL(aParams.Param(TRoutingParameters::EParamDevicePropCode));
+        break;
+        
+    case ESubTypeObjectPropCode:
+        from.AppendL(aParams.Param(TRoutingParameters::EParamObjectPropCode));
+        break;
+        
+    case ESubTypeOperationCode:
+        from.AppendL(aParams.Request().Uint16(TMTPTypeRequest::ERequestOperationCode));
+        break;
+        
+    case ESubTypeStorageType:
+        from.AppendL(aParams.Param(TRoutingParameters::EParamStorageSystemType));
+        break;
+        
+    case ESubTypeFormatCodeFormatSubcode:
+        from.AppendL(aParams.Param(TRoutingParameters::EParamFormatCode));
+        from.AppendL(aParams.Param(TRoutingParameters::EParamFormatSubCode));
+        break;
+        
+    case ESubTypeFormatCodeOperationCode:
+        from.AppendL(aParams.Param(TRoutingParameters::EParamFormatCode));
+        from.AppendL(aParams.Request().Uint16(TMTPTypeRequest::ERequestOperationCode));
+        break;
+        
+    case ESubTypeStorageTypeOperationCode:
+        from.AppendL(aParams.Param(TRoutingParameters::EParamStorageSystemType));
+        from.AppendL(aParams.Request().Uint16(TMTPTypeRequest::ERequestOperationCode));
+        break;
+        
+    case ESubTypeFormatCodeFormatSubcodeStorageType:
+        from.AppendL(aParams.Param(TRoutingParameters::EParamFormatCode));
+        from.AppendL(aParams.Param(TRoutingParameters::EParamFormatSubCode));
+        from.AppendL(aParams.Param(TRoutingParameters::EParamStorageSystemType));
+        break;
+    case ESubTypeServiceIDOperationCode :
+        {
+        from.AppendL(aParams.Param(TRoutingParameters::EParamServiceId));
+        }
+        break;   
+        
+    default:
+        __DEBUG_ONLY(User::Invariant());
+        break;
+        }
+    
+    // Resolve the map target parameter set.
+    iMaps[Index(aRoutingSubType)]->GetToL(from, aTargets);
+    CleanupStack::PopAndDestroy(&from);
+    __FLOG(_L8("RouteOperationRequestNParametersL, Exit"));
+    }
+
+/**
+Resolves set of zero or more routing targets using the specified parameterless 
+routing sub-type.
+@param aRoutingSubType The routing sub-type.
+@param aParams The operation routing parameter data.
+@param aTargets On exit, the seto of resolved routing targets.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::RouteOperationRequest0ParametersL(TUint aRoutingSubType, const TRoutingParameters& aParams, RArray<TUint>& aTargets) const
+    {
+    __FLOG(_L8("RouteOperationRequest0ParametersL, Entry"));
+    __FLOG_VA((_L8("Routing Sub-type = 0x%08X"), aRoutingSubType));
+    TInt id(KErrNotFound);
+    switch (aRoutingSubType)
+        {
+    case ESubTypeDpDevice:
+        id = iSingletons.DpController().DeviceDpId();
+        break;
+        
+    case ESubTypeDpProxy:
+        id = iSingletons.DpController().ProxyDpId();
+        break;
+        
+    case ESubTypeOwnerObject:
+        id = iSingletons.ObjectMgr().ObjectOwnerId(aParams.Param(TRoutingParameters::EParamObjectHandle));
+        if ( EMTPOpCodeSetObjectProtection == aParams.Request().Uint16(TMTPTypeRequest::ERequestOperationCode))
+            {
+            if ( (EMTPFormatCodeScript!=aParams.Param(TRoutingParameters::EParamFormatCode)) && (EMTPFormatCodeEXIFJPEG!=aParams.Param(TRoutingParameters::EParamFormatCode)) )
+                {
+                id = iSingletons.DpController().FileDpId();
+                }
+            }
+        break;
+        
+    case ESubTypeOwnerStorage:
+        {
+        CMTPStorageMgr& storages(iSingletons.StorageMgr());
+        const TUint KStorageId(aParams.Param(TRoutingParameters::EParamStorageId));
+        if (storages.LogicalStorageId(KStorageId))
+            {
+            id = storages.LogicalStorageOwner(KStorageId);
+            }
+        else
+            {
+            id = storages.PhysicalStorageOwner(KStorageId);
+            }
+        }
+        break;
+        
+    case ESubTypeRequestRegistration:
+        {
+        CMTPSession& session(static_cast<CMTPSession&>(aParams.Connection().SessionWithMTPIdL(aParams.Request().Uint32(TMTPTypeRequest::ERequestSessionID))));
+        id = session.RouteRequest(aParams.Request());
+        }
+        break;
+
+    default:
+        __DEBUG_ONLY(User::Invariant());
+        break;
+        }
+        
+    if (id != KErrNotFound && iSingletons.DpController().IsDataProviderLoaded(id))
+        {
+        SelectTargetL(id, aTargets);
+        }
+    __FLOG(_L8("RouteOperationRequest0ParametersL, Exit"));
+    }
+
+/**
+Provides a single suitable routing target for the specified request. A target 
+is selected such that:
+
+    1.	Any request that resolves to multiple targets will always be directed 
+     	to the proxy data provider.
+    2.	Any request that cannot be resolved to at least one target will always 
+        be directed to the device data provider.
+
+@param aRequest The operation request dataset of the MTP operation to be 
+routed.
+@param aConnection The MTP connection on which the operation request is being 
+processed.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+TUint CMTPParserRouter::RoutingTargetL(const TMTPTypeRequest& aRequest, CMTPConnection& aConnection) const
+    {
+    __FLOG(_L8("RoutingTargetL, Entry"));    
+    // Parse the operation request dataset.
+    TRoutingParameters params(aRequest, static_cast<MMTPConnection&>(aConnection));
+    ParseOperationRequestL(params);
+      
+    // Route the operation request.
+    RArray<TUint> targets;
+    CleanupClosePushL(targets);
+    params.SetParam(TRoutingParameters::EFlagRoutingTypes, (ETypeFramework | ETypeOperationParameter | ETypeRequestRegistration));
+    RouteOperationRequestL(params, targets);
+    
+    // Dispatch the operation request.
+    TUint target(0);
+    if (targets.Count() > 1)
+        {
+        target = iSingletons.DpController().ProxyDpId();
+        }
+    else
+        {
+        target = targets[0];
+        }
+    CleanupStack::PopAndDestroy(&targets);
+    __FLOG(_L8("RoutingTargetL, Exit"));
+    return target;
+    }
+    
+/**
+Selects the specified routing sub-type together with any applicable validation 
+sub-types.
+@param aSubType The selected routing sub-type.
+@param aRoutingSubTypes The set of selected routing sub-types, updated on exit.
+@param aValidationSubTypes The set of selected validation sub-types, 
+potentially updated on exit.
+@param aParams The set of operation routing parameter data.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::SelectSubTypeRoutingL(TRoutingSubType aSubType, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes, RArray<TRoutingParameters>& aParams) const
+    {
+    __FLOG(_L8("SelectSubTypeRoutingL, Entry"));
+    __ASSERT_DEBUG((aRoutingSubTypes.Find(aSubType) == KErrNotFound), User::Invariant());
+    aRoutingSubTypes.AppendL(aSubType);    
+    switch (aSubType)
+        {
+    case ESubTypeDevicePropCode:
+    case ESubTypeObjectPropCode:
+    case ESubTypeStorageType:
+    case ESubTypeOwnerObject:
+    case ESubTypeOwnerStorage:
+        SelectSubTypeValidationL(ESubTypeOperationCode, aValidationSubTypes);
+        break;
+        
+    case ESubTypeFormatCodeFormatSubcode:
+    case ESubTypeFormatCodeOperationCode:
+    case ESubTypeFormatCodeFormatSubcodeStorageType:
+        {
+        TRoutingParameters params2(aParams[0]);
+        params2.SetParam(TRoutingParameters::EParamFormatCode, EMTPFormatCodeUndefined);
+        aParams.AppendL(params2);
+        SelectSubTypeValidationL(ESubTypeOperationCode, aValidationSubTypes);
+        }
+        break;
+        
+    case ESubTypeRequestRegistration:
+    default:
+        break;
+        }
+    __FLOG(_L8("SelectSubTypeRoutingL, Exit"));
+    }
+    
+/**
+Selects the specified validation sub-type.
+@param aSubType The selected validation sub-type.
+@param aValidationSubTypes The set of selected validation sub-types, updated 
+on exit.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/
+void CMTPParserRouter::SelectSubTypeValidationL(TRoutingSubType aSubType, RArray<TUint>& aValidationSubTypes) const
+    {
+    __FLOG(_L8("SelectSubTypeValidationL, Entry"));
+    TInt err(aValidationSubTypes.InsertInOrder(aSubType));
+    if ((err != KErrNone) &&
+        (err != KErrAlreadyExists))
+        {
+        User::Leave(err);
+        }
+    __FLOG(_L8("SelectSubTypeValidationL, Exit"));
+    }
+
+/**
+Validates the specified set of routing targets.
+@param aParams The operation routing parameter data.
+@param aValidationSubTypes The set of validation sub-types. 
+@param aTargets The set of data provider targets to be validated. Invalid 
+targets are removed from this set.
+*/    
+void CMTPParserRouter::ValidateTargetsL(const TRoutingParameters& aParams, const RArray<TUint>& aValidationSubTypes, RArray<TUint>& aTargets) const
+    {
+    __FLOG(_L8("ValidateTargetsL, Entry"));
+    const TUint KValidationsCount(aValidationSubTypes.Count());
+    for (TUint v(0); (v < KValidationsCount); v++)
+        {
+        RArray<TUint> valid;
+        CleanupClosePushL(valid);
+        RouteOperationRequestNParametersL(aValidationSubTypes[v], aParams, valid);
+        valid.Sort();
+        TUint target(aTargets.Count());
+        while (target--)
+            {
+            if (valid.FindInOrder(aTargets[target]) == KErrNotFound)
+                {
+                aTargets.Remove(target);
+                }
+            }
+        CleanupStack::PopAndDestroy(&valid);
+        }
+    __FLOG(_L8("ValidateTargetsL, Exit"));
+    }
+    
+/**
+Provides the routing sub-type modifier flags of the specified routing sub-type.
+@param aSubType The routing sub-type identifier.
+@return The routing sub-type modifier flags.
+*/
+TUint CMTPParserRouter::Flags(TUint aSubType)
+    {
+    return (aSubType & ESubTypeFlagMask);
+    }
+    
+/**
+Provides the routing sub-type (map) index of the specified routing sub-type.
+@param aSubType The routing sub-type identifier.
+@return The routing sub-type (map) index.
+*/
+TUint CMTPParserRouter::Index(TUint aSubType)
+    {
+    return (aSubType & ESubTypeIndexMask);
+    }
+    
+/**
+Provides the routing sub-type parameter count type of the specified routing 
+sub-type.
+@param aSubType The routing sub-type identifier.
+@return The routing sub-type parameter count type.
+*/
+TUint CMTPParserRouter::Params(TUint aSubType)
+    {
+    return (aSubType & ESubTypeParamsMask);
+    }
+    
+/**
+Provides the routing sub-type parameter count of the specified routing 
+sub-type.
+@param aSubType The routing sub-type identifier.
+@return The routing sub-type parameter count.
+*/
+TUint CMTPParserRouter::ParamsCount(TUint aSubType)
+    {
+    return (Params(aSubType) >> 24);
+    }
+
+/**
+Encodes a routing sub-type identifier using the specified sub-field values.
+@param aIndex The routing sub-type (map) index.
+@param aFlags The routing sub-type modifier flags.
+@param aParamsCount The routing sub-type parameter count.
+*/
+TUint CMTPParserRouter::SubType(TUint aIndex, TUint aFlags, TUint aParamsCount)
+    {
+    return ((aParamsCount << 24) | aFlags | aIndex);
+    }
+  
+#ifdef __FLOG_ACTIVE
+/**
+Logs the map table entries of all map tables.
+@leave One of the system wide error codes, if a general processing error 
+occurs.
+*/  
+void CMTPParserRouter::FLOGMapsL() const
+    {
+    __FLOG(_L8("FLOGMapsL, Entry"));
+    const TUint KCount(iMaps.Count());
+    for (TUint i(0); (i < KCount); i++)
+        {
+        const CMap& KMap (*iMaps[i]);
+        __FLOG(_L8(""));
+        __FLOG_VA((_L8("Table 0x%08X"), KMap.SubType()));
+        __FLOG(_L8("----------------"));
+        RArray<TUint> from;
+        CleanupClosePushL(from);
+        KMap.InitParamsL(from);
+        KMap.FLOGMapL(from);
+        CleanupStack::PopAndDestroy(&from);
+        __FLOG(_L8(""));
+        }
+    __FLOG(_L8("FLOGMapsL, Exit"));
+    }
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtppkgidstore.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,136 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "cmtppkgidstore.h"
+#include "dbutility.h"
+
+/**
+Two-phase construction
+@param aDatabase    The reference to the database object
+@return pointer to the created <pkgid, dpid> map instance
+*/
+CMTPPkgIDStore* CMTPPkgIDStore::NewL(RDbDatabase& aDatabase)
+    {
+    CMTPPkgIDStore* self = new (ELeave) CMTPPkgIDStore(aDatabase);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+
+/**
+Standard c++ constructor
+*/  
+CMTPPkgIDStore::CMTPPkgIDStore(RDbDatabase& aDatabase)
+    :iDatabase(aDatabase)
+    {
+    }
+
+/**
+Second phase constructor.
+*/    
+void CMTPPkgIDStore::ConstructL()
+    {
+    CreatePkgIDStoreTableL();
+    }
+
+/**
+Create table to store the mapping from object handle to other properties 
+(data provider id, storage id, formatcode, etc.)
+*/    
+void CMTPPkgIDStore::CreatePkgIDStoreTableL()
+    {   
+    _LIT(KSQLPkgIDTableName, "PkgIDStore");
+    if (!DBUtility::IsTableExistsL(iDatabase, KSQLPkgIDTableName))
+        {
+        _LIT(KSQLCreatePkgIDTableText,
+            "CREATE TABLE PkgIDStore (DataProviderId UNSIGNED INTEGER, PkgId UNSIGNED INTEGER)");
+        User::LeaveIfError(iDatabase.Execute(KSQLCreatePkgIDTableText));            
+        }
+    _LIT(KSQLGetPKGID, "SELECT * FROM PkgIDStore");
+    iSqlStatement.Format(KSQLGetPKGID);    
+    RDbView view;
+    CleanupClosePushL(view);
+    User::LeaveIfError(view.Prepare(iDatabase, TDbQuery(iSqlStatement)));
+    User::LeaveIfError(view.Evaluate());
+    while (view.NextL())
+        {
+        view.GetL();
+        iDPIDs.AppendL(view.ColInt64(EPkgIDStoreDataProviderId));
+        iPkgIDs.AppendL(view.ColInt64(EPkgIDStorePKGID));
+        }
+    CleanupStack::PopAndDestroy(&view); 
+    }
+    
+/**
+Destructor.
+*/    
+CMTPPkgIDStore::~CMTPPkgIDStore()
+    {
+    iDPIDs.Close();
+    iPkgIDs.Close();
+    }
+
+
+void CMTPPkgIDStore::InsertPkgIdL(TUint aDPId, TUint aPkgId)
+    {       
+    TInt index = 0;
+    TRAPD(err, index = iDPIDs.FindL(aDPId));
+    if(KErrNotFound == err)
+        {
+        _LIT(KSQLInsertPkgIDObjectText, "INSERT INTO PkgIDStore (DataProviderId, PkgId) VALUES (%u, %u)");
+        iSqlStatement.Format(KSQLInsertPkgIDObjectText, aDPId, aPkgId);
+        User::LeaveIfError(iDatabase.Execute(iSqlStatement));
+        iDPIDs.AppendL(aDPId);
+        iPkgIDs.AppendL(aPkgId);
+        }
+    else
+        {
+        if(aPkgId != iPkgIDs[index])
+            {
+            _LIT(KSQLSetPkgIDObjectText, "UPDATE PkgIDStore SET PkgId = %u WHERE DataProviderId = %u");
+            iSqlStatement.Format(KSQLSetPkgIDObjectText, aPkgId,aDPId);
+            User::LeaveIfError(iDatabase.Execute(iSqlStatement));
+            iPkgIDs[index] = aPkgId;
+            }
+        }
+    }
+
+const RArray<TUint>& CMTPPkgIDStore::DPIDL() const
+    {
+    __ASSERT_DEBUG((iPkgIDs.Count() == iDPIDs.Count()), User::Invariant());
+    return iDPIDs;
+    }
+
+TUint CMTPPkgIDStore::PKGIDL (TUint aIndex) const
+    {
+    __ASSERT_DEBUG((aIndex < iPkgIDs.Count()), User::Invariant());
+    return iPkgIDs[aIndex];
+    }
+
+TInt CMTPPkgIDStore::RemoveL(TUint aDpId)
+    {
+    TInt index = iDPIDs.Find(aDpId);
+    if(KErrNotFound != index)
+        {
+        iDPIDs.Remove(index);
+        iPkgIDs.Remove(index);
+        _LIT(KSQLDeleteObjectText, "DELETE FROM PkgIDStore WHERE DataProviderId = %u");
+        iSqlStatement.Format(KSQLDeleteObjectText, aDpId);
+        User::LeaveIfError(iDatabase.Execute(iSqlStatement));
+        }
+    return index;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpreferencemgr.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,407 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/cmtptypearray.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/mtptypessimple.h>
+
+#include "cmtpobjectstore.h"
+#include "cmtpreferencemgr.h"
+#include "dbutility.h"
+
+
+_LIT(KSQLReferenceTableName, "ReferenceStore");
+_LIT(KSQLReferenceIndexName, "ReferenceIndex");
+_LIT(KSQLCreateReferenceTableText,"CREATE TABLE ReferenceStore (HandleId UNSIGNED INTEGER, References LONG VARBINARY)");
+_LIT(KSQLCreateReferenceIndexText,"CREATE UNIQUE INDEX ReferenceIndex on ReferenceStore (HandleId)");	
+
+
+static const TInt KMTPReferenceGranularity = 5;
+// Maximum value to use for granularity 
+// This will result in 4KB of memory used (1024 * 4bytes) for reference SUID array
+static const TInt KMTPMaxGranularity = 1024;
+
+/**
+Two phase construction
+@param aObjectMgr	Reference to the object manager
+@return a pointer to the reference manager instance
+*/
+CMTPReferenceMgr* CMTPReferenceMgr::NewL(CMTPObjectStore& aObjectStore)
+	{
+	CMTPReferenceMgr* self = new (ELeave) CMTPReferenceMgr(aObjectStore);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+Destructor
+*/	
+CMTPReferenceMgr::~CMTPReferenceMgr()
+	{
+	iBatched.Close();
+	}
+
+/**
+Provides an MTP array of the target object handles which are referenced 
+by the specified source object handle. A pointer to the MTP array is 
+placed on the cleanup stack.
+@param aFromHandle The MTP object handle of the source object from which 
+the references originate.
+@return The MTP reference target object handle array. Ownership IS transferred.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+CMTPTypeArray* CMTPReferenceMgr::ReferencesLC(const TMTPTypeUint32& aFromHandle) const
+	{
+	return GetReferencesLC(aFromHandle.Value());
+	}
+
+/**
+Provides an SUID array of the target object SUIDs which are referenced by 
+the specified source object SUID. A pointer to the SUID array is 
+placed on the cleanup stack.
+@param aFromSuid The SUID of the source object from which the references 
+originate.
+@return The reference target object SUID array. Ownership IS transferred.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+CDesCArray* CMTPReferenceMgr::ReferencesLC(const TDesC& aParentSuid) const
+	{
+	TUint32 handle =  iObjectStore.HandleL(aParentSuid);
+	return GetReferencesInDesLC(handle);
+	}
+
+/**
+Removes all object reference links in which the specified SUID represents 
+either the source or target reference object.
+@param aSuid The object SUID.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+void CMTPReferenceMgr::RemoveReferencesL(const TDesC& aSuid)
+	{
+	TUint32 handle =  iObjectStore.HandleL(aSuid);
+	RemoveReferencesL(handle);
+	}
+
+/**
+Creates an abstract reference linkage between the specified source and 
+target object SUIDs.
+@param aFromSuid The SUID of the source object from which the reference 
+originates.
+param aToSuid The SUID of the target object to which the reference is 
+made.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+void CMTPReferenceMgr::SetReferenceL(const TDesC& aFromSuid, const TDesC& aToSuid)
+	{
+	TUint32 fromHandle =  iObjectStore.HandleL(aFromSuid);
+	TUint32 toHandle =  iObjectStore.HandleL(aToSuid);
+	SetReferenceL(fromHandle, toHandle);
+	}
+
+/**
+Replaces the abstract reference links originating from the specified 
+source object handle with the specified set of target object SUIDs.
+@param aFromHandle The SUID of the source object from which the references 
+originate.
+@param aToSuids The reference target MTP object SUID array.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+void CMTPReferenceMgr::SetReferencesL(const TDesC& aParentSuid, const CDesCArray& aToSuids)
+	{
+	TInt count = aToSuids.Count();
+	
+	if (count > 0)
+		{
+		TUint32 fromHandle =  iObjectStore.HandleL(aParentSuid);
+	
+		// Limit granularity to something less or equal to KMTPMaxGranularity items
+		RArray<TUint> toHandles(Min(count, KMTPMaxGranularity));
+		CleanupClosePushL(toHandles);
+		
+		for(TInt i = 0; i < count; i++)
+			{
+			TUint32 toHandle =  iObjectStore.HandleL(aToSuids[i]);
+			toHandles.Append(toHandle);
+			}	
+		
+		SetReferencesL(fromHandle, toHandles);	
+		CleanupStack::PopAndDestroy(&toHandles);
+		}
+	}
+
+
+/**
+Constructor/.
+*/    
+CMTPReferenceMgr::CMTPReferenceMgr(CMTPObjectStore& aObjectStore):
+	iObjectStore(aObjectStore)
+	{
+	
+	}
+
+/**
+second-phase construction
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+void CMTPReferenceMgr::ConstructL()
+	{
+    iDatabase   = &iObjectStore.Database();
+
+	if(!DBUtility::IsTableExistsL(*iDatabase, KSQLReferenceTableName))
+		{
+		CreateTableL();
+		}
+	if(!DBUtility::IsIndexExistsL(*iDatabase, KSQLReferenceTableName, KSQLReferenceIndexName))
+		{
+		CreateIndexL();
+		}
+	iBatched.Open(*iDatabase, KSQLReferenceTableName, RDbRowSet::EUpdatable);
+	iBatched.SetIndex( KSQLReferenceIndexName ); 
+	}
+
+/**
+Create the reference table in the database
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+void CMTPReferenceMgr::CreateTableL()
+	{
+	User::LeaveIfError(iDatabase->Execute(KSQLCreateReferenceTableText));	
+	}
+
+/**
+Create the index in the reference table
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+void CMTPReferenceMgr::CreateIndexL()
+	{
+	User::LeaveIfError(iDatabase->Execute(KSQLCreateReferenceIndexText));	
+	}
+
+/**
+Get reference on the object identified by aIdentifier
+@param aIdentifier	The 64bit internal object identifier
+@return The array containing the handles of the references
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+CMTPTypeArray* CMTPReferenceMgr::GetReferencesLC(TUint aHandle) const
+	{
+	RArray<TUint> toHandles;
+	CleanupClosePushL(toHandles);
+	GetReferencesL(aHandle, toHandles);
+	
+	CMTPTypeArray* mtpReferenceArray = CMTPTypeArray::NewLC(EMTPTypeAUINT32);	
+	mtpReferenceArray->AppendL(toHandles);
+	CleanupStack::Pop(mtpReferenceArray);
+	CleanupStack::PopAndDestroy(&toHandles);
+	CleanupStack::PushL(mtpReferenceArray);
+	return mtpReferenceArray;
+	}
+
+/**
+Get reference on the object identified by aIdentifier
+@param aIdentifier	The 64bit internal object identifier
+@return The array containing the suids of the references
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+CDesCArray*	 CMTPReferenceMgr::GetReferencesInDesLC(TUint aHandle) const
+	{
+	RArray<TUint> toHandles(KMTPReferenceGranularity);
+	CleanupClosePushL(toHandles);
+	GetReferencesL(aHandle, toHandles);	
+	const TInt count = toHandles.Count();
+	CDesCArray* mtpReferenceArray = new (ELeave) CDesCArrayFlat((count==0) ? 1 : count);
+	CleanupStack::PushL(mtpReferenceArray);
+	
+	for(TInt i = 0; i < count; i++)
+		{
+		const TDesC& suid = iObjectStore.ObjectSuidL(toHandles[i]);
+		if(suid.Length())
+			{
+			mtpReferenceArray->AppendL(suid);
+			}
+		}
+	CleanupStack::Pop(mtpReferenceArray);
+	CleanupStack::PopAndDestroy(&toHandles);
+	CleanupStack::PushL(mtpReferenceArray);
+	return mtpReferenceArray;		
+	
+	}
+
+/**
+Get references on the object identified by aIdentifier
+@param aIdentifier	The 64bit internal object identifier
+@param aReferences	The reference array, on return, containing the 64bit internal identifiers of the references
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+void CMTPReferenceMgr::GetReferencesL(TUint aHandle, RArray<TUint>& aToHandles) const
+	{
+	TUint32 temp = 0;
+	TBool   needToUpdate = EFalse;
+	aToHandles.Reset();
+	if(iBatched.SeekL(aHandle))
+		{
+		iBatched.GetL();
+	    RDbColReadStream readStream;     
+        readStream.OpenLC(iBatched,2);
+        TInt count = readStream.ReadInt32L();
+        while(count--)
+        	{
+        	temp = readStream.ReadUint32L();
+			if(iObjectStore.ObjectExistsL(temp))
+	        	aToHandles.AppendL(temp);
+			else
+				needToUpdate = ETrue;
+        	}
+        CleanupStack::PopAndDestroy(&readStream);
+
+		
+		if(needToUpdate)
+			{//Something has been deleted. Write it back to Reference list
+			iBatched.UpdateL();
+			RDbColWriteStream writeStream;	   
+			writeStream.OpenLC(iBatched,2);
+			
+			count = aToHandles.Count();
+			writeStream.WriteInt32L(count);
+			for(TInt i = 0; i < count; i++)
+				{
+				writeStream.WriteUint32L(aToHandles[i]);
+				}
+			writeStream.CommitL(); 
+			CleanupStack::PopAndDestroy(&writeStream);
+			iBatched.PutL();			
+			}
+		
+		}	
+	return;
+
+	}
+
+
+/**
+Remove reference on the object identified by aIdentifier
+@param aIdentifier	The 64bit internal object identifier
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+void CMTPReferenceMgr::RemoveReferencesL(TUint aHandle)
+	{
+	if(iBatched.SeekL(aHandle))
+		{
+		iBatched.DeleteL();
+		IncTranOpsNumL();
+		}
+	}
+/**
+Set reference on the object identified by aFromIdentifier
+@param aFromIdentifier	The 64bit internal object identifier of the source object
+@param aToIdentifier	The 64bit internal object identifier of the referenced object
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+void CMTPReferenceMgr::SetReferenceL(TUint aFromHandle, TUint aToHandle)
+	{
+	RArray<TUint> aToHandleArray(1);
+	CleanupClosePushL(aToHandleArray);
+	aToHandleArray.AppendL(aToHandle);
+	SetReferencesL(aFromHandle, aToHandleArray);
+	CleanupStack::PopAndDestroy(&aToHandleArray);
+	}
+
+/**
+Replaces the abstract reference links originating from the specified 
+source object handle with the specified set of target object handles.
+@param aFromHandle The handle of the source object from which the references 
+originate.
+@param aToHandles The reference target object handle array.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/	
+void CMTPReferenceMgr::SetReferencesL(const TMTPTypeUint32& aFromHandle, const CMTPTypeArray& aToHandles)
+{
+	RArray<TUint> tempArray;
+	CleanupClosePushL(tempArray);
+	TInt count = aToHandles.NumElements();
+	for(TInt i = 0; i < count; i++)
+		{
+		tempArray.Append(aToHandles.ElementUint(i));
+		}	
+	SetReferencesL(aFromHandle.Value(), tempArray);
+	CleanupStack::PopAndDestroy(&tempArray);
+}
+
+
+
+/**
+Set references on the object identified by aFromIdentifier
+@param aFromIdentifier	The 64bit internal object identifier of the source object
+@param aToIdentifiers	The 64bit internal object identifiers of the referenced objects
+@leave One of the system wide error codes, if a processing failure occurs.
+*/   	
+void CMTPReferenceMgr::SetReferencesL(TUint aHandle, const RArray<TUint>& aToHandles)
+	{
+	if(iBatched.SeekL(aHandle))
+		{
+		iBatched.UpdateL();		
+		}
+	else
+		{
+		iBatched.InsertL();		
+		}
+	
+	iBatched.SetColL(1, aHandle);
+	
+	RDbColWriteStream writeStream;     
+    writeStream.OpenLC(iBatched,2);
+    
+    const TInt count = aToHandles.Count();
+    writeStream.WriteInt32L(count);
+    for(TInt i = 0; i < count; i++)
+        {
+        writeStream.WriteUint32L(aToHandles[i]);
+        }
+    writeStream.CommitL(); 
+    CleanupStack::PopAndDestroy(&writeStream);
+	iBatched.PutL();			
+	IncTranOpsNumL();
+	}
+
+
+void CMTPReferenceMgr::IncTranOpsNumL()
+	{
+	iObjectStore.IncTranOpsNumL();
+	}
+
+
+/**
+Verify if every reference is pointing to a valid object. If the referenced object does not exist,
+delete the object from the reference array.
+@param aReference	The 64bit internal object identifiers of the referenced objects
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+/*
+void CMTPReferenceMgr::AdjustReferencesL(RArray<TUint32>&aHandles) const
+	{
+	TInt count = aHandles.Count();
+	while(count--)
+		{
+		if(!iObjectStore.ObjectExistsL(aHandles[count]))
+			{
+			aHandles.Remove(count);
+			}
+		}
+	}
+	*/
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpserviceconfig.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,463 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/ 
+
+#include "mtpservicecommon.h"
+#include "cmtpserviceconfig.h"
+
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"ServiceConfigMgr");)
+_LIT(KMTPServiceCofigfile, "z:\\resource\\mtp\\services.rsc");
+
+
+
+CMTPServiceConfig::TSupportedService::TSupportedService( const TMTPTypeGuid& aGUID, const TUint aServiceType, const TUint aResID ):
+    iGUID(aGUID),
+    iServiceType(aServiceType),
+    iResourceID(aResID)
+    {
+    
+    }
+
+/**
+
+*/
+CMTPServiceConfig* CMTPServiceConfig::NewL( RFs& aRFs)  
+    {
+    CMTPServiceConfig* self = new (ELeave) CMTPServiceConfig( aRFs );
+    CleanupStack::PushL(self);
+    self->ConstructL( KMTPServiceCofigfile ); 
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+
+/**
+Destructor
+*/    
+CMTPServiceConfig::~CMTPServiceConfig()
+    {
+    __FLOG(_L8("CMTPServiceConfig::~CMTPServiceConfig() - Entry"));
+        
+    iSupportedServices.Close();
+    iServiceInfos.ResetAndDestroy();
+    __FLOG(_L8("CMTPServiceConfig::~CMTPServiceConfig() - Exit"));
+    __FLOG_CLOSE;
+    }
+
+TInt CMTPServiceConfig::SupportedServiceOrderFromAscending( const TSupportedService& aL, const TSupportedService& aR)
+    {
+    return aL.iGUID.Compare( aR.iGUID );
+    }
+
+TInt CMTPServiceConfig::SupportedServiceOrderFromKeyAscending( const TMTPTypeGuid* aL, const TSupportedService& aR)
+    {
+    return aL->Compare( aR.iGUID );
+    }
+
+CMTPServiceConfig::CMTPServiceConfig( RFs& aRFs ):
+    iRFs(aRFs)
+    {
+    
+    }
+
+void CMTPServiceConfig::ConstructL( const TDesC& aResourceFilename )
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("CMTPServiceConfig::ConstructL - Entry"));
+    
+
+    
+    RResourceFile file;
+    file.OpenL( iRFs, aResourceFilename );
+    CleanupClosePushL(file);
+       
+    
+    // Create the resource reader.
+    const TInt KDefaultResourceId(1);
+    HBufC8* buffer(file.AllocReadLC(KDefaultResourceId));
+    TResourceReader reader;
+    reader.SetBuffer(buffer);
+    
+    InitializeL( reader );
+    
+    CleanupStack::PopAndDestroy(buffer);
+    CleanupStack::PopAndDestroy(&file);
+    
+    __FLOG(_L8("CMTPServiceConfig::ConstructL - Exit"));
+    }
+
+
+void CMTPServiceConfig::InitializeL( TResourceReader& aReader )
+    {
+    __FLOG(_L8("CMTPServiceConfig::InitializeL - Entry"));
+    
+    //read the supported services
+    TUint serviceCount = aReader.ReadInt16();
+
+    TUint resID(0);
+    TUint type(EMTPServiceTypeAbstract);
+    while( serviceCount-- )
+        {
+        TMTPTypeGuid svcGUID = ReadGUID( aReader );
+        type = aReader.ReadUint32();
+        resID = aReader.ReadUint32();
+        iSupportedServices.InsertInOrderL( TSupportedService( svcGUID, type, resID ), TLinearOrder<TSupportedService>(SupportedServiceOrderFromAscending) );      
+        }
+    
+    
+    __FLOG(_L8("CMTPServiceConfig::InitializeL - Exit"));
+    }
+
+TBool CMTPServiceConfig::IsSupportedService( const TMTPTypeGuid& aServiceGUID ) const
+    {   
+    return !( KErrNotFound == iSupportedServices.FindInOrder( aServiceGUID, SupportedServiceOrderFromKeyAscending  ) );
+    }
+
+void CMTPServiceConfig::LoadServiceDataL( const TMTPTypeGuid& aServiceGUID )
+    {
+    __FLOG(_L8("CMTPServiceConfig::LoadServiceDataL - Entry"));
+    
+    RResourceFile file;
+    file.OpenL( iRFs, KMTPServiceCofigfile );
+    CleanupClosePushL(file);
+   
+
+    // Create the resource reader.
+    HBufC8* buffer(file.AllocReadLC( ServiceResourceIDL( aServiceGUID ) ));
+    TResourceReader reader;
+    reader.SetBuffer(buffer);
+    
+    CMTPServiceInfo* serviceInfo = CMTPServiceInfo::NewLC();
+    const TUint KStorageID = 0;
+    serviceInfo->SetServiceStorageID( KStorageID );
+    
+    //read pguid
+    TMTPTypeGuid KPGUID( ReadGUID( reader ) );
+    serviceInfo->SetPersistentGUIDL( KPGUID );
+    
+    //read version
+    serviceInfo->SetServiceVersion( reader.ReadUint32() );
+    
+    //read service guid
+    TMTPTypeGuid KSvcGUID( ReadGUID( reader ) );
+    serviceInfo->SetServiceGUIDL( KSvcGUID );
+    
+    HBufC* name = reader.ReadHBufCL();
+    //read service name
+    serviceInfo->SetServiceName( name );
+
+    //read service type
+    serviceInfo->SetServiceType( reader.ReadUint32() );
+    
+    //read service base service id
+    serviceInfo->SetBaseServiceID( reader.ReadUint32() );
+    
+    //read use service guids
+    TUint resID = reader.ReadUint32();
+    StartReadUseServicesL( file, resID, *serviceInfo );
+    
+    //read service properties
+    TUint resNamespace = reader.ReadUint32();
+    resID = reader.ReadUint32();
+    StartReadServicePropertiesL( file,resNamespace, resID, *serviceInfo );
+    
+    //read service formats
+    resID = reader.ReadUint32();
+    StartReadServiceFormatsL( file, resID, *serviceInfo );
+    
+    //read service methods
+    resID = reader.ReadUint32();
+    StartReadServiceMethodsL( file, resID, *serviceInfo );
+
+    //read service events
+    resID = reader.ReadUint32();
+    StartReadServiceEventsL( file, resID, *serviceInfo );
+    
+    //read service data block.
+    resID = reader.ReadUint32();
+    StartReadServiceDataBlockL( file, resID, *serviceInfo );
+    
+    iServiceInfos.AppendL(serviceInfo);
+    CleanupStack::Pop(serviceInfo);
+    CleanupStack::PopAndDestroy(buffer);
+    CleanupStack::PopAndDestroy(&file);
+    
+    __FLOG(_L8("CMTPServiceConfig::LoadServiceDataL - Exit"));
+    }
+
+void CMTPServiceConfig::StartReadUseServicesL(  RResourceFile& aResFile, const TUint aResID, CMTPServiceInfo& aServiceInfo )
+    {
+    __FLOG(_L8("CMTPServiceConfig::StartReadUseServices - Entry"));
+    
+    // Create the resource reader.
+    HBufC8* buffer(aResFile.AllocReadLC( aResID ));
+    TResourceReader reader;
+    reader.SetBuffer(buffer);
+    
+    TUint num  = reader.ReadInt16();
+    while( num-- )
+        {
+        TMTPTypeGuid KGUID(ReadGUID(reader));
+        aServiceInfo.AppendUserServiceL( KGUID );
+        }
+    
+    CleanupStack::PopAndDestroy(buffer);
+    
+    __FLOG(_L8("CMTPServiceConfig::StartReadUseServices - Exit"));
+    }
+
+void CMTPServiceConfig::StartReadServicePropertyNamespacesL(  RResourceFile& aResFile, const TUint aResID, RArray<TMTPTypeGuid>& aNamespaces )
+    {
+    __FLOG(_L8("CMTPServiceConfig::StartReadServicePropertyNamespacesL - Entry"));
+        
+    // Create the resource reader.
+    HBufC8* buffer(aResFile.AllocReadLC( aResID ));
+    TResourceReader reader;
+    reader.SetBuffer(buffer);
+    
+    //read namespaces
+    TUint num = reader.ReadInt16();
+    while( num-- )
+        {
+        aNamespaces.Append( ReadGUID(reader) );
+        }
+    
+    CleanupStack::PopAndDestroy(buffer);
+    __FLOG(_L8("CMTPServiceConfig::StartReadServicePropertyNamespacesL - Exit"));
+    }
+
+void CMTPServiceConfig::StartReadServicePropertiesL(  RResourceFile& aResFile, const TUint aNamespaceResID, const TUint aPropertiesResID, CMTPServiceInfo& aServiceInfo )
+    {
+    __FLOG(_L8("CMTPServiceConfig::StartReadServicePropertyL - Entry"));
+    
+    //read namespaces
+    RArray<TMTPTypeGuid> namespaces;
+    CleanupClosePushL(namespaces);
+    StartReadServicePropertyNamespacesL(aResFile, aNamespaceResID, namespaces);
+    
+    // Create the resource reader.
+    HBufC8* buffer(aResFile.AllocReadLC( aPropertiesResID ));
+    TResourceReader reader;
+    reader.SetBuffer(buffer);
+    
+    //read properties  
+    TUint num = reader.ReadInt16();
+    TUint namespaceid = 0 ;
+    TUint pkeyid = 0;
+    HBufC* name( NULL );
+    TUint16 datatype = 0;
+    TUint8  getset = 0;
+    TUint8  formflag = 0;
+    CServiceProperty* newElement = NULL;
+    while( num-- )
+        {
+        namespaceid = reader.ReadUint32();
+        pkeyid = reader.ReadUint32();
+        name = reader.ReadHBufCL();
+        datatype = reader.ReadUint32();
+        getset = reader.ReadUint8();
+        formflag = reader.ReadUint8();
+        
+        newElement = CServiceProperty::NewLC(namespaces[namespaceid], pkeyid, name, datatype, getset, formflag);
+        aServiceInfo.InsertPropertyL( newElement );
+        CleanupStack::Pop(newElement);
+        }
+    
+    CleanupStack::PopAndDestroy(buffer);
+    CleanupStack::PopAndDestroy(&namespaces);
+    
+    __FLOG(_L8("CMTPServiceConfig::StartReadServicePropertyL - Exit"));
+    }
+
+void CMTPServiceConfig::StartReadServiceFormatsL(  RResourceFile& aResFile, const TUint aResID, CMTPServiceInfo& aServiceInfo )
+    {
+    __FLOG(_L8("CMTPServiceConfig::StartReadServiceFormatL - Entry"));
+    
+    // Create the resource reader.
+    HBufC8* buffer(aResFile.AllocReadLC( aResID ));
+    TResourceReader reader;
+    reader.SetBuffer(buffer);
+    
+    TUint num = reader.ReadInt16();
+    HBufC* name( NULL );
+    HBufC* mimetype1( NULL );
+    CServiceFormat* newElement = NULL;
+    while( num-- )
+        {
+        TMTPTypeGuid guid = ReadGUID( reader );
+        name = reader.ReadHBufCL();   
+		CleanupStack::PushL(name);
+
+        mimetype1 = reader.ReadHBufCL();
+        if( NULL == mimetype1 )
+            {
+			//If mimetype is not configed in the config file, then alloc a zero length buffer for it. The mimetype is treated as an empty string for this situation.
+            mimetype1 = HBufC16::NewLC(0);
+            }
+        else
+            {
+            CleanupStack::PushL(mimetype1);
+            }
+        CleanupStack::Pop(2);
+        newElement = CServiceFormat::NewLC( guid, name, reader.ReadUint16() ,mimetype1 );
+		
+        aServiceInfo.InsertFormatL( newElement );
+        CleanupStack::Pop(newElement);
+        }
+    
+    CleanupStack::PopAndDestroy(buffer);
+    
+    __FLOG(_L8("CMTPServiceConfig::StartReadServiceFormatL - Exit"));
+    }
+
+
+void CMTPServiceConfig::StartReadServiceMethodsL(  RResourceFile& aResFile, const TUint aResID,  CMTPServiceInfo& aServiceInfo )
+    {
+    __FLOG(_L8("CMTPServiceConfig::StartReadServiceMethodL - Entry"));
+    
+    // Create the resource reader.
+    HBufC8* buffer(aResFile.AllocReadLC( aResID ));
+    TResourceReader reader;
+    reader.SetBuffer(buffer);
+    
+    TUint num = reader.ReadInt16();
+    HBufC* name( NULL );
+    CServiceMethod* newElement = NULL;
+    while( num-- )
+        {
+        TMTPTypeGuid guid = ReadGUID( reader );
+        name = reader.ReadHBufCL();       
+        
+        newElement = CServiceMethod::NewLC(guid, name, reader.ReadUint16());
+        aServiceInfo.InsertMethodL( newElement );
+        CleanupStack::Pop(newElement);
+        }
+    
+    CleanupStack::PopAndDestroy(buffer);
+    
+    __FLOG(_L8("CMTPServiceConfig::StartReadServiceMethodL - Exit"));
+    }
+
+void CMTPServiceConfig::StartReadServiceEventsL(  RResourceFile& aResFile, const TUint aResID, CMTPServiceInfo& aServiceInfo )
+    {
+    __FLOG(_L8("CMTPServiceConfig::StartReadServiceEventsL - Entry"));
+      
+    // Create the resource reader.
+    HBufC8* buffer(aResFile.AllocReadLC( aResID ));
+    TResourceReader reader;
+    reader.SetBuffer(buffer);
+    
+    TUint num = reader.ReadInt16();
+    TUint16 datacode(0); 
+    CServiceEvent* newElement = NULL;
+    while( num-- )
+        {
+        datacode = reader.ReadUint16();
+        TMTPTypeGuid guid = ReadGUID( reader );     
+        
+        newElement = CServiceEvent::NewLC(datacode, guid, reader.ReadHBufCL() );
+        aServiceInfo.InsertEventL( newElement );
+        CleanupStack::Pop(newElement);
+        }
+      
+    CleanupStack::PopAndDestroy(buffer);
+    
+      __FLOG(_L8("CMTPServiceConfig::StartReadServiceEventsL - Exit"));
+    }
+
+void CMTPServiceConfig::StartReadServiceDataBlockL(  RResourceFile& aResFile, const TUint aResID, CMTPServiceInfo& aServiceInfo )
+    {
+    __FLOG(_L8("CMTPServiceConfig::StartReadServiceDataBlockL - Entry"));
+    
+    // Create the resource reader.
+    HBufC8* buffer(aResFile.AllocReadLC( aResID ));
+    TResourceReader reader;
+    reader.SetBuffer(buffer);
+    
+    TUint num = reader.ReadInt16();
+    while( num-- )
+        {
+        TMTPTypeGuid guid = ReadGUID( reader );
+              
+        aServiceInfo.AppendDataGUIDL( guid );
+        }
+    
+    CleanupStack::PopAndDestroy(buffer);
+    __FLOG(_L8("CMTPServiceConfig::StartReadServiceDataBlockL - Exit"));
+    }
+
+CMTPServiceInfo* CMTPServiceConfig::ServiceInfo(const TMTPTypeGuid& aServiceGUID ) const
+    {
+    TInt count = iServiceInfos.Count();
+    for(TInt i(0); i < count; i++ )
+        {
+        if(iServiceInfos[i]->ServicePersistentGUID().Equal(aServiceGUID))
+            return iServiceInfos[i] ;
+        }
+    
+    return NULL;
+    }
+
+CMTPServiceInfo* CMTPServiceConfig::ServiceInfo(const TUint aServiceID) const
+	{
+	__FLOG(_L8("CMTPServiceConfig::ServiceInfo - Entry"));
+	
+	TInt count = iServiceInfos.Count();
+    for(TInt i(0); i < count; i++ )
+        {
+        if(iServiceInfos[i]->ServiceID() == aServiceID)
+            return iServiceInfos[i] ;
+        }
+    
+    __FLOG(_L8("CMTPServiceConfig::ServiceInfo - Exit"));
+    return NULL;
+	
+	}
+
+TInt CMTPServiceConfig::ServiceTypeOfSupportedService( const TMTPTypeGuid& aServiceGUID ) const
+    {
+    TInt index = iSupportedServices.FindInOrder( aServiceGUID, SupportedServiceOrderFromKeyAscending ) ;
+       if( KErrNotFound == index)
+           return KErrNotFound;
+       
+       return iSupportedServices[index].iServiceType;
+    }
+
+TUint CMTPServiceConfig::ServiceResourceIDL( const TMTPTypeGuid& aServiceGUID ) const
+    {
+    TInt index = iSupportedServices.FindInOrder( aServiceGUID, SupportedServiceOrderFromKeyAscending ) ;
+    if( KErrNotFound == index)
+        User::Leave( KErrNotFound );
+    
+    return iSupportedServices[index].iResourceID;
+    }
+
+TMTPTypeGuid CMTPServiceConfig::ReadGUID( TResourceReader& aReader )
+    {
+    TUint upper2 = aReader.ReadUint32();
+    TUint upper1 = aReader.ReadUint32();
+    TUint lower2 = aReader.ReadUint32();
+    TUint lower1 = aReader.ReadUint32();
+    
+    return TMTPTypeGuid( MAKE_TUINT64( upper2, upper1 ), MAKE_TUINT64( lower2, lower1 ) );
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpserviceinfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,489 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/ 
+
+#include "mtpservicecommon.h"
+#include "cmtpserviceinfo.h"
+
+
+// Class constants.
+
+__FLOG_STMT(_LIT8(KComponent,"ServiceInfo");)
+
+
+TPKeyPair::TPKeyPair( const TMTPTypeGuid& aNamespace, const TUint aID ):
+    iNamespace( aNamespace ),
+    iPKeyId(aID)
+    {
+    }
+
+
+CServiceElementBase::CServiceElementBase(const TMTPTypeGuid& aGUID, HBufC* aName):
+    iCode( KInvliadU16DataCode ),
+    iGUID( aGUID ),
+    iName( aName )
+    {
+    }
+
+CServiceElementBase::~CServiceElementBase()
+    {
+    delete iName;
+    }
+
+EXPORT_C TBool CServiceElementBase::IsUsed()
+    {
+    return ( KInvliadU16DataCode != iCode );
+    }
+
+EXPORT_C TUint CServiceElementBase::Code() const
+    {
+    return iCode;
+    }
+EXPORT_C const TDesC& CServiceElementBase::Name() const
+    {
+    return *iName;
+    }
+EXPORT_C const TMTPTypeGuid& CServiceElementBase::GUID() const
+    {
+    return iGUID;
+    }
+
+EXPORT_C void CServiceElementBase::SetCode( const TUint aCode )
+    {
+    iCode = aCode;
+    }
+
+TInt CServiceElementBase::Compare( const CServiceElementBase& aR ) const
+    {
+    return iGUID.Compare( aR.GUID() );
+    }
+
+CServiceProperty::CServiceProperty( const TMTPTypeGuid& aGUID, const TUint aPkeyID, HBufC* aName, const TUint aDataType, const TUint aGetSet, const TUint aFormFlag):
+    CServiceElementBase( aGUID, aName ),
+    iPKeyId( aPkeyID ),
+    iDataType( aDataType ),
+    iGetSet( aGetSet ),
+    iFormFlag( aFormFlag )
+    {
+    }
+
+CServiceProperty* CServiceProperty::NewLC(const TMTPTypeGuid& aGUID, const TUint aPkeyID, HBufC* aName, const TUint aDataType, const TUint aGetSet, const TUint aFormFlag)
+    {
+    CServiceProperty* self = new (ELeave) CServiceProperty(aGUID, aPkeyID, aName, aDataType, aGetSet, aFormFlag);
+    CleanupStack::PushL(self);
+    self->ConstructL(); 
+    return self;
+    }
+
+void CServiceProperty::ConstructL()
+    {
+    }
+
+EXPORT_C const TMTPTypeGuid& CServiceProperty::Namespace() const
+    {
+    return GUID();
+    }
+EXPORT_C TUint CServiceProperty::PKeyID() const
+    {
+    return iPKeyId;
+    }
+
+EXPORT_C TUint CServiceProperty::DataType() const
+    {
+    return iDataType;
+    }
+EXPORT_C TUint CServiceProperty::GetSet() const
+    {
+    return iGetSet;
+    }
+EXPORT_C TUint CServiceProperty::FormFlag() const
+    {
+    return iFormFlag;
+    }
+    
+
+
+CServiceFormat::CServiceFormat(const TMTPTypeGuid& aGUID, HBufC* aName, const TUint aBaseFormat, HBufC* aMime ):
+    CServiceElementBase( aGUID, aName ),
+    iFormatBase(aBaseFormat),
+    iMIMEType1(aMime)
+    {
+    }
+
+CServiceFormat* CServiceFormat::NewLC(const TMTPTypeGuid& aGUID, HBufC* aName, const TUint aBaseFormat, HBufC* aMime )
+    {
+    CServiceFormat* self = new (ELeave) CServiceFormat( aGUID, aName, aBaseFormat, aMime );
+    CleanupStack::PushL(self);
+    self->ConstructL(); 
+    return self;
+    }
+
+void CServiceFormat::ConstructL()
+    {
+    }
+
+CServiceFormat::~CServiceFormat()
+	{
+	delete iMIMEType1;
+	}
+
+EXPORT_C TUint CServiceFormat::FormatBase() const
+    {
+    return iFormatBase;
+    }
+EXPORT_C const TDesC& CServiceFormat::MIMEType1() const
+    {
+    return *iMIMEType1;
+    }
+
+CServiceMethod::CServiceMethod(const TMTPTypeGuid& aGUID, HBufC* aName, const TUint aAssFormat):
+    CServiceElementBase( aGUID, aName ),
+    iObjAssociateFormatCode(aAssFormat)
+    {
+    }
+
+CServiceMethod* CServiceMethod::NewLC(const TMTPTypeGuid& aGUID, HBufC* aName, const TUint aAssFormat)
+    {
+    CServiceMethod* self = new (ELeave) CServiceMethod( aGUID,  aName, aAssFormat );
+    CleanupStack::PushL(self);
+    self->ConstructL(); 
+    return self;
+    }
+
+void CServiceMethod::ConstructL()
+    {
+    }
+
+EXPORT_C TUint CServiceMethod::ObjAssociateFormatCode() const
+    {
+    return iObjAssociateFormatCode;
+    }
+
+
+CServiceEvent::CServiceEvent( const TUint aCode, const TMTPTypeGuid& aGUID, HBufC* aName):
+    CServiceElementBase( aGUID, aName )
+    {
+    SetCode(aCode);
+    }
+CServiceEvent* CServiceEvent:: NewLC(const TUint aCode, const TMTPTypeGuid& aGUID, HBufC* aName)
+    {
+    CServiceEvent* self = new (ELeave) CServiceEvent( aCode, aGUID, aName );
+    CleanupStack::PushL(self);
+    self->ConstructL(); 
+    return self;
+    }
+
+void CServiceEvent::ConstructL()
+    {
+    }
+
+
+CMTPServiceInfo* CMTPServiceInfo::NewLC()
+    {
+    CMTPServiceInfo* self = new (ELeave) CMTPServiceInfo();
+    CleanupStack::PushL(self);
+    self->ConstructL(); 
+    return self;
+    }
+
+CMTPServiceInfo::~CMTPServiceInfo()
+    {
+    __FLOG(_L8("CServiceInfo::~CserviceInfo() - Entry"));
+    
+    delete iServiceName;
+    
+    iUsedServiceGUIDs.Close();
+    iServiceProperties.ResetAndDestroy();
+    iServiceFormats.ResetAndDestroy();
+    iServiceMethods.ResetAndDestroy();
+    iServiceEvents.ResetAndDestroy();
+    iDataBlock.Close();
+    
+    __FLOG(_L8("CServiceInfo::~CserviceInfo() - Exit"));
+    __FLOG_CLOSE;
+    }
+    
+
+CMTPServiceInfo::CMTPServiceInfo()
+    {
+    }
+void CMTPServiceInfo::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("CServiceInfo::ConstructL() - Entry"));
+   
+    
+    
+    __FLOG(_L8("CServiceInfo::ConstructL() - Exit"));
+    }
+
+
+TInt CMTPServiceInfo::ServicePropertyOrderFromAscending( const CServiceProperty& aL, const CServiceProperty& aR)
+    {
+    TInt ret = aL.Compare( aR );
+    if( 0 == ret )
+        {
+        return aL.PKeyID() - aR.PKeyID();
+        }
+    else
+        {
+        return ret;
+        }
+    }
+
+TInt CMTPServiceInfo::ServicePropertyOrderFromKeyAscending( const TPKeyPair* aL, const CServiceProperty& aR)
+    {
+    TInt ret = aL->iNamespace.Compare( aR.Namespace() );
+        if( 0 == ret )
+            {
+            return aL->iPKeyId - aR.PKeyID();
+            }
+        else
+            {
+            return ret;
+            }
+    }
+
+TInt CMTPServiceInfo::ServiceElementBaseOrderFromAscending( const CServiceElementBase& aL, const CServiceElementBase& aR)
+    {
+    return aL.Compare( aR );
+    }
+
+TInt CMTPServiceInfo::ServiceElementBaseOrderFromKeyAscending( const TMTPTypeGuid* aL, const CServiceElementBase& aR )
+    {
+    return aL->Compare( aR.GUID() );
+    }
+
+TInt CMTPServiceInfo::ServiceFormatOrderFromAscending( const CServiceFormat& aL, const CServiceFormat& aR)
+    {
+    return ServiceElementBaseOrderFromAscending(aL, aR);
+    }
+
+TInt CMTPServiceInfo::ServiceFormatOrderFromKeyAscending( const TMTPTypeGuid* aL, const CServiceFormat& aR )
+    {
+    return ServiceElementBaseOrderFromKeyAscending(aL, aR);
+    }
+
+TInt CMTPServiceInfo::ServiceMethodOrderFromAscending( const CServiceMethod& aL, const CServiceMethod& aR )
+    {
+    return ServiceElementBaseOrderFromAscending(aL, aR);
+    }
+
+TInt CMTPServiceInfo::ServiceMethodOrderFromKeyAscending( const TMTPTypeGuid* aL, const CServiceMethod& aR )
+    {
+    return ServiceElementBaseOrderFromKeyAscending(aL, aR);
+    }
+
+TInt CMTPServiceInfo::ServiceEventOrderFromAscending( const CServiceEvent& aL, const CServiceEvent& aR )
+    {
+    return ServiceElementBaseOrderFromAscending(aL, aR);
+    }
+
+
+void CMTPServiceInfo::SetServiceID( TUint aServiceID)
+    {
+    iServiceId = aServiceID;
+    }
+
+void CMTPServiceInfo::SetServiceStorageID( TUint aStorageID )
+    {
+    iServiceStorageId = aStorageID;
+    }
+
+void CMTPServiceInfo::SetPersistentGUIDL( const TMTPTypeGuid& aGUID )
+    {
+    MMTPType::CopyL( aGUID, iPersistentGUID);
+    }
+
+void CMTPServiceInfo::SetServiceVersion( TUint aVersion )
+    {
+    iServiceVersion = aVersion;
+    }
+
+void CMTPServiceInfo::SetServiceGUIDL( const TMTPTypeGuid& aGUID )
+    {
+    MMTPType::CopyL( aGUID, iServiceGUID);
+    }
+
+void CMTPServiceInfo::SetServiceName( HBufC* aName )
+    {
+    delete iServiceName;
+    iServiceName = aName;
+    }
+
+void CMTPServiceInfo::SetServiceType( TUint aServiceType )
+    {
+    iServiceType = aServiceType;
+    }
+
+void CMTPServiceInfo::SetBaseServiceID( TUint aID )
+    {
+    iBaseServiceId = aID;
+    }
+
+void CMTPServiceInfo::AppendUserServiceL( const TMTPTypeGuid& aServiceGUID )
+    {
+    __FLOG(_L8("CServiceInfo::AppendUserServiceL - Entry"));
+    
+    iUsedServiceGUIDs.AppendL( aServiceGUID );
+    
+    __FLOG(_L8("CServiceInfo::AppendUserServiceL - Exit"));
+    }
+
+void CMTPServiceInfo::InsertPropertyL( const CServiceProperty* aProperty )
+    {
+    __FLOG(_L8("CServiceInfo::InsertPropertyL - Entry"));
+    
+    iServiceProperties.InsertInOrderL( aProperty, TLinearOrder<CServiceProperty>(ServicePropertyOrderFromAscending) );
+    
+    __FLOG(_L8("CServiceInfo::InsertPropertyL - Exit"));
+    }
+
+void CMTPServiceInfo::InsertFormatL( const CServiceFormat* aFormat )
+    {
+    __FLOG(_L8("CServiceInfo::InsertFormatL - Entry"));
+    
+    iServiceFormats.InsertInOrderL( aFormat, TLinearOrder<CServiceFormat>(ServiceFormatOrderFromAscending) );
+    
+    __FLOG(_L8("CServiceInfo::InsertFormatL - Exit"));
+    }
+
+void CMTPServiceInfo::InsertMethodL( const CServiceMethod* aMethod )
+    {
+    __FLOG(_L8("CServiceInfo::InsertMethodL - Entry"));
+    
+    iServiceMethods.InsertInOrderL( aMethod , TLinearOrder<CServiceMethod>(ServiceMethodOrderFromAscending) );
+    
+    __FLOG(_L8("CServiceInfo::InsertMethodL - Exit"));
+    }
+
+void CMTPServiceInfo::InsertEventL( const CServiceEvent* aEvent )
+    {
+    __FLOG(_L8("CServiceInfo::InsertMethodL - Entry"));
+    
+    iServiceEvents.InsertInOrderL( aEvent , TLinearOrder<CServiceEvent>(ServiceEventOrderFromAscending) );
+    
+    __FLOG(_L8("CServiceInfo::InsertMethodL - Exit"));
+    }
+  
+void CMTPServiceInfo::AppendDataGUIDL( const TMTPTypeGuid& aGUID )
+    {
+    __FLOG(_L8("CServiceInfo::AppendDataGUIDL - Entry"));
+    
+    iDataBlock.AppendL( aGUID );
+    
+    __FLOG(_L8("CServiceInfo::AppendDataGUIDL - Exit"));
+    }
+    
+EXPORT_C TUint CMTPServiceInfo::ServiceID() const
+    {
+    return iServiceId;
+    }
+
+EXPORT_C TUint CMTPServiceInfo::ServiceStorageID() const
+    {
+    return iServiceStorageId;
+    }
+
+EXPORT_C const TMTPTypeGuid& CMTPServiceInfo::ServicePersistentGUID() const
+    {
+    return iPersistentGUID;
+    }
+EXPORT_C TUint CMTPServiceInfo::ServiceVersion() const
+    {
+    return iServiceVersion;
+    }
+
+EXPORT_C const TMTPTypeGuid& CMTPServiceInfo::ServiceGUID() const
+    {
+    return iServiceGUID;
+    }
+
+EXPORT_C const TDesC& CMTPServiceInfo::ServiceName() const
+    {
+    return *iServiceName;
+    }
+
+EXPORT_C TUint CMTPServiceInfo::ServiceType() const
+    {
+    return iServiceType;
+    }
+
+EXPORT_C TUint CMTPServiceInfo::BaseServiceID() const
+    {
+    return iBaseServiceId;
+    }
+
+CServiceProperty* CMTPServiceInfo::ServiceProperty( const TMTPTypeGuid& aPKNamespace, const TUint aPKID ) const
+    {
+    TInt index = iServiceProperties.FindInOrder( TPKeyPair(aPKNamespace, aPKID), ServicePropertyOrderFromKeyAscending );
+    if( index != KErrNotFound )
+        return iServiceProperties[index];
+    
+    return NULL;
+    }
+
+CServiceFormat* CMTPServiceInfo::ServiceFormat( const TMTPTypeGuid& aGUID ) const
+    {
+    TInt index = iServiceFormats.FindInOrder( aGUID, ServiceFormatOrderFromKeyAscending );
+    if( index != KErrNotFound )
+        return iServiceFormats[index];
+    
+    return NULL;
+    }
+
+CServiceMethod* CMTPServiceInfo::ServiceMethod( const TMTPTypeGuid& aGUID ) const
+    {
+    TInt index = iServiceMethods.FindInOrder( aGUID , ServiceMethodOrderFromKeyAscending );
+    if( index != KErrNotFound )
+        return iServiceMethods[index];
+    
+    return NULL;
+    }
+
+EXPORT_C const RArray<TMTPTypeGuid>& CMTPServiceInfo::UsedServiceGUIDs() const
+	{
+	return iUsedServiceGUIDs;
+	}
+
+EXPORT_C const RPointerArray<CServiceProperty>& CMTPServiceInfo::ServiceProperties() const
+	{
+	return iServiceProperties;
+	}
+
+EXPORT_C const RPointerArray<CServiceFormat>& CMTPServiceInfo::ServiceFormats() const
+	{
+	return iServiceFormats;
+	}
+
+EXPORT_C const RPointerArray<CServiceMethod>& CMTPServiceInfo::ServiceMethods() const
+	{
+	return iServiceMethods;
+	}
+
+EXPORT_C const RPointerArray<CServiceEvent>& CMTPServiceInfo::ServiceEvents() const
+	{
+	return iServiceEvents;
+	}
+
+EXPORT_C const RArray<TMTPTypeGuid>& CMTPServiceInfo::DataBlockGUIDs() const
+    {
+    return iDataBlock;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpservicemgr.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,310 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// 
+
+/**
+@file
+@internalComponent
+*/ 
+#include <e32cmn.h>
+
+#include "mtpservicecommon.h"
+#include "cmtpserviceconfig.h"
+#include "cmtpservicemgr.h"
+#include <mtp/mtpprotocolconstants.h>
+
+__FLOG_STMT(_LIT8(KComponent,"ServiceMgr");)
+
+
+/**
+
+*/
+CMTPServiceMgr* CMTPServiceMgr::NewL()
+    {
+    CMTPServiceMgr* self = new (ELeave) CMTPServiceMgr();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CMTPServiceMgr::CMTPServiceMgr()
+    {
+    
+    }
+
+void CMTPServiceMgr::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry"));
+	
+    iSingletons.OpenL();
+	iServiceCfg = CMTPServiceConfig::NewL( iSingletons.Fs() );
+	   
+	__FLOG(_L8("ConstructL - Exit"));
+	}
+/**
+Destructor
+*/    
+CMTPServiceMgr::~CMTPServiceMgr()
+    {
+    __FLOG(_L8("~CMTPServiceMgr - Entry"));
+    
+    delete iServiceCfg;
+    
+    iSingletons.Close();
+    
+    iServiceIDs.Close();
+    
+    __FLOG(_L8("~CMTPServiceMgr - Exit"));
+    __FLOG_CLOSE;
+    }
+
+EXPORT_C TBool CMTPServiceMgr::IsSupportedService( const TUint aServiceID ) const
+    {
+    return ( ServiceInfo( aServiceID ) != NULL );
+    }
+
+EXPORT_C TBool CMTPServiceMgr::IsSupportedService( const TMTPTypeGuid& aPGUID ) const
+    {
+    return iServiceCfg->IsSupportedService( aPGUID );
+    }
+
+TInt CMTPServiceMgr::EnableService(const TMTPTypeGuid& aPGUID, const TUint aServiceID )
+    {
+    __FLOG(_L8("CMTPServiceMgr::EnableService : "));
+    
+    if( NULL == iServiceCfg->ServiceInfo(aPGUID)  )
+        {
+        TRAPD(err,LoadServiceL( aPGUID ));
+        if( KErrNone == err)
+            {
+            iServiceCfg->ServiceInfo(aPGUID)->SetServiceID( aServiceID );
+            }
+        
+        __FLOG_1(_L8("CMTPServiceMgr::EnableService - Fail to Load service! error = %d "), err );
+        return err;
+        }
+    
+    __FLOG(_L8("CMTPServiceMgr::EnableService - Has been loaded!"));
+    
+    return KErrNone;
+    }
+
+TInt CMTPServiceMgr::ServiceTypeOfSupportedService( const TMTPTypeGuid& aPGUID ) const
+    {
+    return iServiceCfg->ServiceTypeOfSupportedService( aPGUID );
+    }
+
+EXPORT_C CMTPServiceInfo* CMTPServiceMgr::ServiceInfo(const TMTPTypeGuid& aServiceGUID )const
+    {
+    return iServiceCfg->ServiceInfo( aServiceGUID );
+    }
+
+EXPORT_C CMTPServiceInfo* CMTPServiceMgr::ServiceInfo(const TUint aServiceID) const
+    {
+    return iServiceCfg->ServiceInfo( aServiceID );
+    }
+
+EXPORT_C TBool CMTPServiceMgr::IsServiceFormatCode(const TUint32 aDatacode ) const
+    {
+    return ( (EMTPFormatCodeVendorExtDynamicStart <= aDatacode) && ( aDatacode <= EMTPFormatCodeVendorExtDynamicEnd ) );
+    }
+
+EXPORT_C const RArray<TUint>& CMTPServiceMgr::GetServiceIDs() const
+	{
+	return iServiceIDs;
+	}
+
+TInt CMTPServiceMgr::InsertServiceId(const TUint aServiceId)
+    {
+    return iServiceIDs.InsertInOrder( aServiceId );
+    }
+
+void CMTPServiceMgr::LoadServiceL( const TMTPTypeGuid& aPGUID )
+	{
+	__FLOG(_L8("CMTPServiceMgr::LoadServiceL - Entry"));
+
+	iServiceCfg->LoadServiceDataL(aPGUID);
+	
+    __FLOG(_L8("CMTPServiceMgr::LoadServiceL - Exit"));
+	}
+
+TInt CMTPServiceMgr::GetServiceProperty( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, CServiceProperty** aServicePropertye) const
+    {
+    __FLOG(_L8("CMTPServiceMgr::GetServiceProperty :"));
+        
+    CMTPServiceInfo* svcinfo = iServiceCfg->ServiceInfo( aServicePGUID );
+    if( NULL == svcinfo )
+       return KErrNotSupported;
+    
+    CServiceProperty* prop = svcinfo->ServiceProperty( aPKNamespace, aPKID );
+    if( NULL == prop)
+       return KErrNotSupported;
+    
+    *aServicePropertye = prop;
+    
+    __FLOG(_L8("CMTPServiceMgr::GetServiceProperty Exit"));
+    return KErrNone;
+    }
+
+TInt CMTPServiceMgr::GetServiceFormat( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, CServiceFormat** aServiceFormat ) const
+   {
+    __FLOG(_L8("CMTPServiceMgr::GetServiceFormat :"));
+    
+    CMTPServiceInfo* svcinfo = iServiceCfg->ServiceInfo( aServicePGUID );
+    if( NULL == svcinfo )
+       return KErrNotSupported;
+    
+    CServiceFormat* format = svcinfo->ServiceFormat( aGUID );
+    if( NULL == format)
+       return KErrNotSupported;
+    
+    *aServiceFormat = format;
+   
+    __FLOG(_L8("CMTPServiceMgr::GetServiceFormat Exit"));
+    return KErrNone;
+   }
+
+TInt CMTPServiceMgr::GetServiceMethod( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, CServiceMethod** aServiceMethod ) const
+   {
+    __FLOG(_L8("CMTPServiceMgr::GetServiceMethod :"));
+    
+    CMTPServiceInfo* svcinfo = iServiceCfg->ServiceInfo( aServicePGUID );
+    if( NULL == svcinfo )
+       return KErrNotSupported;
+    
+    CServiceMethod* method = svcinfo->ServiceMethod( aGUID );
+    if( NULL == method)
+       return KErrNotSupported;
+    
+    *aServiceMethod = method ;
+    
+    __FLOG(_L8("CMTPServiceMgr::GetServiceMethod - Exit"));
+    return KErrNone;
+   }
+
+TInt CMTPServiceMgr::GetServiceId( const TMTPTypeGuid& aServiceGUID, TUint& aServiceID) const
+	{
+	__FLOG(_L8("CMTPServiceMgr::FindServiceId :"));
+	
+	CMTPServiceInfo* svcinfo = ServiceInfo( aServiceGUID );
+	
+	if( NULL ==  svcinfo )
+	    {
+	    __FLOG(_L8("CMTPServiceMgr::GetServiceId - Invalid serviceID"));
+	    
+	    return KErrNotFound;
+	    }
+	else
+	    {
+	    aServiceID = svcinfo->ServiceID();
+	    
+	    __FLOG_1(_L8("CMTPServiceMgr::GetServiceId = %d"),aServiceID );
+	    
+	    return KErrNone;
+	    }
+	}
+
+TInt CMTPServiceMgr::GetServicePropertyCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, TUint& aServicePropertyCode ) const
+    {
+    __FLOG(_L8("CMTPServiceMgr::GetServicePropertyCode :"));
+    
+    CServiceProperty* prop = NULL;
+    TInt err =  GetServiceProperty( aServicePGUID, aPKNamespace, aPKID, &prop );
+    if( KErrNone != err)
+        return err;
+    
+    aServicePropertyCode = prop->Code();
+ 
+    __FLOG(_L8("CMTPServiceMgr::GetServicePropertyCode - Exit"));
+    return KErrNone;
+    }
+
+TInt CMTPServiceMgr::SetServicePropertyCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, const TUint aCurrPropertyCode )
+    {
+    __FLOG(_L8("CMTPServiceMgr::SetServicePropertyCode :"));
+    
+    CServiceProperty* prop = NULL;
+    TInt err =  GetServiceProperty( aServicePGUID, aPKNamespace, aPKID, &prop );
+    if( KErrNone != err)
+        return err;
+    
+    prop->SetCode( aCurrPropertyCode );
+    
+    __FLOG(_L8("CMTPServiceMgr::SetServicePropertyCode - Exit"));
+    return KErrNone;
+    }
+
+TInt CMTPServiceMgr::GetServiceFormatCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, TUint& aServiceFormatCode ) const
+    {
+    __FLOG(_L8("CMTPServiceMgr::GetServiceFormatCode :"));
+    
+    CServiceFormat* format = NULL;
+    TInt err = GetServiceFormat( aServicePGUID, aGUID, &format );
+    if( KErrNone != err )
+        return err;
+    
+    aServiceFormatCode = format->Code();
+    
+    __FLOG(_L8("CMTPServiceMgr::GetServiceFormatCode - Exit"));
+    return KErrNone;
+    }
+
+TInt CMTPServiceMgr::SetServiceFormatCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, const TUint aCurrFormatCode )
+    {
+    __FLOG(_L8("CMTPServiceMgr::SetServiceFormatCode :"));
+    
+    CServiceFormat* format = NULL;
+    TInt err = GetServiceFormat( aServicePGUID, aGUID, &format );
+    if( KErrNone != err )
+       return err;
+    
+    format->SetCode( aCurrFormatCode );
+    
+    __FLOG(_L8("CMTPServiceMgr::SetServiceFormatCode - Exit"));
+    return KErrNone;
+    }
+
+TInt CMTPServiceMgr::GetServiceMethodCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, TUint& aServiceMethodCode ) const
+    {
+    __FLOG(_L8("CMTPServiceMgr::GetServiceMethodCode :"));
+    
+    CServiceMethod* method = NULL;
+    TInt err = GetServiceMethod( aServicePGUID, aGUID, &method );
+    if ( KErrNone != err )
+        return err;
+    
+    aServiceMethodCode = method->Code();
+    
+    __FLOG(_L8("CMTPServiceMgr::GetServiceMethodCode - Exit"));
+    return KErrNone;
+    }
+
+TInt CMTPServiceMgr::SetServiceMethodCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, const TUint aCurrMethodCode )
+    {
+    __FLOG(_L8("CMTPServiceMgr::SetServiceMethodCode :"));
+    
+    CServiceMethod* method = NULL;
+    TInt err = GetServiceMethod( aServicePGUID, aGUID, &method );
+    if ( KErrNone != err )
+        return err;
+    
+    method->SetCode( aCurrMethodCode );
+    
+    __FLOG(_L8("CMTPServiceMgr::SetServiceMethodCode - Exit"));
+    return KErrNone;
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpsession.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,361 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <mtp/mtpprotocolconstants.h>
+
+#include "cmtpsession.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"Session");)
+
+#ifdef _DEBUG
+
+/**
+CMTPSession panics
+*/
+_LIT(KMTPPanicCategory, "CMTPSession");
+enum TMTPPanicReasons
+    {
+    EMTPPanicBusy = 0,
+    EMTPPanicStraySignal = 1,
+    };
+    
+LOCAL_C void Panic(TInt aReason)
+    {
+    User::Panic(KMTPPanicCategory, aReason);
+    }
+
+#endif //_DEBUG
+
+/**
+CMTPSession factory method. A pointer to the new CMTPSession instance is placed
+on the cleanup stack.
+@param aMTPId The session identifier assigned by the MTP connection on which 
+the session resides. 
+@param aUniqueId The session identifier assigned by the MTP data provider framework that 
+is unique across all active connections.
+@return Pointer to the new CMTPSession instance. Ownership IS transfered.
+@leave One of the system wide error codes.
+*/
+CMTPSession* CMTPSession::NewLC(TUint32 aMTPId, TUint aUniqueId)
+    {
+    CMTPSession* self = new(ELeave) CMTPSession(aMTPId, aUniqueId);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+/**
+Destructor.
+*/ 
+CMTPSession::~CMTPSession()
+    {
+    __FLOG(_L8("~CMTPSession - Entry"));
+    iRoutingRegistrations.Close();
+    __FLOG(_L8("~CMTPSession - Exit"));
+    __FLOG_CLOSE;
+    }
+    
+/**
+Provides the next expected TransactionID. Transaction IDs are assigned 
+in incremental sequence by the MTP initiator in the range 0x00000001 to
+0xFFFFFFFE.
+@return The next TransactionID expected on the session.
+*/
+TUint32 CMTPSession::ExpectedTransactionId() const
+    {
+    __FLOG(_L8("ExpectedTransactionId - Entry"));
+    __FLOG_VA((_L8("iExpectedTransactionId = 0x%08X"), iExpectedTransactionId));
+    __FLOG(_L8("ExpectedTransactionId - Exit")); 
+    return iExpectedTransactionId; 
+    }
+
+/**
+Increments the next expected TransactionID to the next value in the sequence.
+TransactionIDs are assigned by the MTP initiator starting from 0x00000001. 
+When the TransactionID increments to 0xFFFFFFFF it wraps back to 0x00000001.
+*/
+void CMTPSession::IncrementExpectedTransactionId()
+    {
+    __FLOG(_L8("IncrementExpectedTransactionId - Entry"));
+    if (++iExpectedTransactionId == KMTPTransactionIdLast)
+        {
+        iExpectedTransactionId = KMTPTransactionIdFirst;
+        }
+    __FLOG_VA((_L8("iExpectedTransactionId = 0x%08X"), iExpectedTransactionId));
+    __FLOG(_L8("IncrementExpectedTransactionId - Exit"));
+    }
+
+/**
+Sets or resets the session's active transaction request dataset. The active 
+transaction request dataset should only be set at the start of the transaction 
+(ERequestPhase), and reset and the end of the transaction (ECompletingPhase).
+@param aRequest The active transaction request dataset.
+*/
+void CMTPSession::SetActiveRequestL(const TMTPTypeRequest& aRequest)
+    {
+    __FLOG(_L8("SetActiveRequestL - Entry"));
+    MMTPType::CopyL(aRequest, iActiveRequest);    
+    __FLOG(_L8("SetActiveRequestL - Exit"));
+    }
+
+/**
+Sets the session's transaction phase state variable.
+@param aPhase The new transaction phase state value.
+*/
+void CMTPSession::SetTransactionPhase(TMTPTransactionPhase aPhase)
+    {
+    __FLOG(_L8("SetTransactionPhase - Entry"));
+    iTransactionPhase = aPhase;
+    __FLOG_VA((_L8("iTransactionPhase = 0x%08X"), iTransactionPhase));
+    __FLOG(_L8("SetTransactionPhase - Exit"));
+    }
+
+    
+/**
+Provides the current MTP transaction state for the session.
+@return The MTP transaction state for the session.
+*/
+TMTPTransactionPhase CMTPSession::TransactionPhase() const
+    {
+    __FLOG(_L8("TransactionPhase - Entry"));
+    __FLOG_VA((_L8("iTransactionPhase = 0x%08X"), iTransactionPhase));
+    __FLOG(_L8("TransactionPhase - Exit"));
+	return  iTransactionPhase;
+    }
+    
+TInt CMTPSession::RouteRequest(const TMTPTypeRequest& aRequest)
+    {
+    __FLOG(_L8("RouteRequest - Entry"));
+    TInt ret(KErrNotFound);
+    
+    // Attempt to match the request to existing registrations.
+    TInt idx(iRoutingRegistrations.FindInOrder(aRequest, CMTPSession::RouteRequestOrder));
+    if (idx != KErrNotFound)
+        {
+        // Retrieve the request registration.
+        const TMTPTypeRequest& registration(iRoutingRegistrations[idx]);
+            
+        /*
+        Extract the registered DP ID. For convenience the DP ID is saved in 
+        the registered request, in the TransactionID element (which is unused 
+        for routing).
+        */  
+        ret = registration.Uint32(TMTPTypeRequest::ERequestTransactionID);
+        
+        /* 
+        Recognised follow-on request types match one request occurence 
+        and are then deleted.
+        */
+        TUint16 op(aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode));
+        if ((op == EMTPOpCodeSendObject) ||
+            (op == EMTPOpCodeTerminateOpenCapture))
+            {
+            __FLOG_VA((_L8("Unregistering follow-on request 0x%08X"), op));
+            iRoutingRegistrations.Remove(idx);
+            }
+        }
+        
+    __FLOG_VA((_L8("DP ID = %d"), ret));
+    __FLOG(_L8("RouteRequest - Exit"));
+    return ret;
+    }
+  
+void CMTPSession::RouteRequestRegisterL(const TMTPTypeRequest& aRequest, TInt aDpId)
+    {
+    __FLOG(_L8("RouteRequestRegisterL - Entry"));
+    // Locate any pre-existing registration (which if found, will be overwritten).
+    TInt idx(iRoutingRegistrations.FindInOrder(aRequest, CMTPSession::RouteRequestOrder));
+    if (idx == KErrNotFound)
+        {
+        iRoutingRegistrations.InsertInOrderL(aRequest, CMTPSession::RouteRequestOrder);
+        User::LeaveIfError(idx = iRoutingRegistrations.FindInOrder(aRequest, CMTPSession::RouteRequestOrder));
+        }
+    
+    /*
+    For convenience the DP ID is saved in the registered request, in the 
+    TransactionID element (which is unused for routing).
+    */
+    iRoutingRegistrations[idx].SetUint32(TMTPTypeRequest::ERequestTransactionID, aDpId);
+    __FLOG(_L8("RouteRequestRegisterL - Exit"));
+    }
+
+/**
+Indicates if a routing request is registered on the session with the 
+specified MTP operation code.
+@param aOpCode The MTP operation code.
+@return ETrue if a routing request with the specified MTP operation code is 
+registered on the session, otherwise EFalse.
+*/
+TBool CMTPSession::RouteRequestRegistered(TUint16 aOpCode) const
+    {
+    __FLOG(_L8("RouteRequestPending - Entry"));
+    __FLOG(_L8("RouteRequestPending - Entry"));
+    return (iRoutingRegistrations.Find(aOpCode, CMTPSession::RouteRequestMatchOpCode) != KErrNotFound);
+    }
+
+void CMTPSession::RouteRequestUnregister(const TMTPTypeRequest& aRequest)
+    {
+    __FLOG(_L8("RouteRequestUnregister - Entry"));
+    TInt idx(iRoutingRegistrations.FindInOrder(aRequest, CMTPSession::RouteRequestOrder));
+    if (idx != KErrNotFound)
+        {
+        iRoutingRegistrations.Remove(idx);
+        }
+    __FLOG(_L8("RouteRequestUnregister - Exit"));
+    }
+    
+void CMTPSession::StorePendingEventL(const TMTPTypeEvent& aEvent)
+    {
+    MMTPType::CopyL(aEvent, iPendingEvent);
+    }
+    
+TBool CMTPSession::CheckPendingEvent(const TMTPTypeRequest& aRequest) const
+    {
+    TBool ret = EFalse;
+    
+    // Compare transaction ID in the request and any pending event
+    if ( aRequest.Uint32(TMTPTypeRequest::ERequestTransactionID)  
+         == iPendingEvent.Uint32(TMTPTypeEvent::EEventTransactionID) )
+        {
+        ret = ETrue;
+        }
+    
+    return ret;
+    }
+    
+const TMTPTypeEvent& CMTPSession::PendingEvent() const
+    {
+    return iPendingEvent;
+    }
+    
+/**
+Completes the currently pending asynchronous request status with the specified
+completion code.
+@param aErr The asynchronous request completion request.
+*/
+void CMTPSession::CompletePendingRequest(TInt aErr)
+    {
+    __FLOG(_L8("CompletePendingRequest - Entry"));
+    
+    if (iRequestStatus != NULL)
+        {
+        __ASSERT_DEBUG(*iRequestStatus == KRequestPending, Panic(EMTPPanicStraySignal));
+        User::RequestComplete(iRequestStatus, aErr);
+        }
+    
+    __FLOG(_L8("CompletePendingRequest - Exit"));
+    }
+    
+
+/**
+Indicates if an asynchronous request is currently pending.
+@return ETrue if an asynchronous request is currently pending, otherwise 
+EFalse.
+*/
+TBool CMTPSession::RequestPending() const
+    {
+    return (iRequestStatus != NULL);        
+    }
+
+/**
+Set the status to complete for the currently pending asynchronous request.
+@param aStatus The asynchronous request status to complete.
+*/
+void CMTPSession::SetRequestPending(TRequestStatus& aStatus)
+    {
+    __FLOG(_L8("SetRequestPending - Entry"));
+    __ASSERT_DEBUG(!iRequestStatus, Panic(EMTPPanicBusy));
+    iRequestStatus = &aStatus;
+    *iRequestStatus = KRequestPending;
+    __FLOG(_L8("SetRequestPending - Exit"));
+    }
+
+const TMTPTypeRequest& CMTPSession::ActiveRequestL() const
+    {
+    __FLOG(_L8("ActiveRequestL - Entry"));
+    
+    if (iTransactionPhase == EIdlePhase)
+        {
+        User::Leave(KErrNotFound);            
+        }
+    
+    __FLOG(_L8("ActiveRequestL - Exit"));
+    return iActiveRequest;  
+    }
+
+TUint32 CMTPSession::SessionMTPId() const
+    {
+    __FLOG(_L8("SessionMTPId - Entry"));
+    __FLOG_VA( (_L8("Session MTP ID = %d"), iIdMTP) );
+    __FLOG(_L8("SessionMTPId - Exit"));
+    return iIdMTP;        
+    }
+
+TUint CMTPSession::SessionUniqueId() const
+    {
+    __FLOG(_L8("SessionUniqueId - Entry"));
+    __FLOG(_L8("SessionUniqueId - Exit"));
+    return iIdUnique;        
+    }
+    
+TAny* CMTPSession::GetExtendedInterface(TUid /*aInterfaceUid*/)
+    {
+    __FLOG(_L8("GetExtendedInterface - Entry"));
+    __FLOG(_L8("GetExtendedInterface - Exit"));
+    return NULL;        
+    }
+    
+/**
+Constructor.
+*/
+CMTPSession::CMTPSession(TUint32 aMTPId, TUint aUniqueId) :
+    iExpectedTransactionId(KMTPTransactionIdFirst),
+    iIdMTP(aMTPId),
+    iIdUnique(aUniqueId),
+    iRequestStatus(NULL)
+    {
+    
+    }
+
+void CMTPSession::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry"));
+    __FLOG(_L8("ConstructL - Exit"));
+    }
+    
+TBool CMTPSession::RouteRequestMatchOpCode(const TUint16* aOpCode, const TMTPTypeRequest& aRequest)
+    {
+    return (aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode) == *aOpCode);
+    }
+
+TInt CMTPSession::RouteRequestOrder(const TMTPTypeRequest& aLeft, const TMTPTypeRequest& aRight)
+    {
+    TInt unequal(aLeft.Uint16(TMTPTypeRequest::ERequestOperationCode) - aRight.Uint16(TMTPTypeRequest::ERequestOperationCode));
+    if (!unequal)
+        {
+        for (TUint i(TMTPTypeRequest::ERequestParameter1); ((i <= TMTPTypeRequest::ERequestParameter5) && (!unequal)); i++)
+            {
+            unequal = aLeft.Uint32(i) - aRight.Uint32(i);
+            }
+        }
+    return unequal;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/cmtpstoragemgr.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,811 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <bautils.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mtpprotocolconstants.h>
+
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpstoragemgr.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"StorageMgr");)
+
+// StorageID bit manipulation patterns.
+static const TUint32    KLogicalIdMask(0x0000FFFF);
+static const TUint32    KPhysicalIdMask(0xFFFF0000);
+
+static const TUint      KLogicalNumberMask(0x000000FF);
+static const TUint      KLogicalOwnerShift(8);
+static const TUint      KPhysicalNumberShift(16);
+static const TUint      KPhysicalOwnerShift(24);
+static const TUint8     KMaxOwnedStorages(0xFF);
+
+/**
+MTP data provider framework storage manager factory method.
+@return A pointer to an MTP data provider framework storage manager. Ownership 
+IS transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+EXPORT_C CMTPStorageMgr* CMTPStorageMgr::NewL()
+    {
+    CMTPStorageMgr* self = new(ELeave) CMTPStorageMgr();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPStorageMgr::~CMTPStorageMgr()
+    {
+    __FLOG(_L8("~CMTPStorageMgr - Entry"));
+    iPhysicalStorageNumbers.Reset();
+    iStorages.ResetAndDestroy();
+    iSingletons.Close();
+    __FLOG(_L8("~CMTPStorageMgr - Exit"));
+    __FLOG_CLOSE;
+    }
+
+/**
+Extracts the storage number of the logical storage ID encoded in the specified
+StorageID.
+@param aStorageId The storage ID.
+@return The storage number.
+*/
+EXPORT_C TUint CMTPStorageMgr::LogicalStorageNumber(TUint32 aStorageId) 
+    {
+    return (aStorageId & KLogicalNumberMask);
+    }
+
+/**
+Extracts the ID of the data provider responsible for the logical storage ID 
+encoded in the specified StorageID.
+@param aStorageId The storage ID.
+@return The data provider owner ID.
+*/    
+EXPORT_C TUint CMTPStorageMgr::LogicalStorageOwner(TUint32 aStorageId) 
+    {
+    return ((aStorageId & KLogicalIdMask) >> KLogicalOwnerShift);
+    }
+
+/**
+Extracts the storage number of the physical storage ID encoded in the specified
+StorageID.
+@param aStorageId The storage ID.
+@return The storage number.
+*/
+EXPORT_C TUint CMTPStorageMgr::PhysicalStorageNumber(TUint32 aStorageId) 
+    {
+    return ((aStorageId & KPhysicalIdMask) >> KPhysicalNumberShift);
+    }
+    
+/**
+Extracts the ID of the data provider responsible for the physical storage ID 
+encoded in the specified StorageID.
+@param aStorageId The storage ID.
+@return The data provider owner ID.
+*/
+EXPORT_C TUint CMTPStorageMgr::PhysicalStorageOwner(TUint32 aStorageId) 
+    {
+    return ((aStorageId & KPhysicalIdMask) >> KPhysicalOwnerShift);
+    }
+
+/**
+Sets the default MTP StorageID. This should be set once at start up and not 
+subsequently changed.
+@param aStorageId The system default MTP StorageID.
+@panic USER 0, in debug builds only, if the default StorageID is set more than
+once.
+*/    
+EXPORT_C void CMTPStorageMgr::SetDefaultStorageId(TUint32 aStorageId)
+    {
+    __FLOG(_L8("SetDefaultStorageId - Entry"));
+    iDefaultStorageId = aStorageId;
+    __FLOG_VA((_L8("Default StorageId = 0x%08X"), aStorageId));
+    __FLOG(_L8("SetDefaultStorageId - Exit"));
+    }
+
+/**
+Creates a mapping between the specified Symbian OS drive number and MTP 
+StorageID.
+@param aDriveNumber The Symbian OS drive number.
+@param aStorageId The MTP StorageID.
+@leave One of the sysem wide error codes, if a processing failure occurs.
+*/
+EXPORT_C void CMTPStorageMgr::SetDriveMappingL(TDriveNumber aDriveNumber, TUint32 aStorageId)
+    {
+    __FLOG(_L8("DefineDriveNumberMapping - Entry"));
+    iMapDriveToStorage[aDriveNumber] = aStorageId;
+    __FLOG_VA((_L8("Drive number %d = StorageID 0x%08X"), aDriveNumber, aStorageId));
+    __FLOG(_L8("DefineDriveNumberMapping - Exit"));
+    }
+
+/**
+Sets the framework storages owner identifier. This should be set once at start 
+up and not subsequently changed.
+@param aDataProviderId The framework storages owner identifier.
+@panic USER 0, in debug builds only, if the framework storages owner identifier
+is set more than once.
+*/    
+EXPORT_C void CMTPStorageMgr::SetFrameworkId(TUint aDataProviderId)
+    {
+    __FLOG(_L8("SetFrameworkStoragesOwner - Entry"));
+    __ASSERT_DEBUG((iFrameworkId == KErrNotFound), User::Invariant());
+    iFrameworkId = aDataProviderId;
+    __FLOG_VA((_L8("System storages owner DP Id = %d"), aDataProviderId));
+    __FLOG(_L8("SetFrameworkStoragesOwner - Exit"));
+    }    
+    
+EXPORT_C TUint32 CMTPStorageMgr::AllocateLogicalStorageIdL(TUint aDataProviderId, TDriveNumber aDriveNumber, const CMTPStorageMetaData& aStorage)
+    {
+    __FLOG(_L8("AllocateLogicalStorageIdL - Entry"));
+    TUint id(AllocateLogicalStorageIdL(aDataProviderId, PhysicalStorageId(aDriveNumber), aStorage));
+    __FLOG(_L8("AllocateLogicalStorageIdL - Exit"));
+    return id;
+    }
+
+EXPORT_C TUint32 CMTPStorageMgr::AllocateLogicalStorageIdL(TUint aDataProviderId, TUint32 aPhysicalStorageId, const CMTPStorageMetaData& aStorage)
+    {
+    __FLOG(_L8("AllocateLogicalStorageIdL - Entry"));
+    //if support uninstall DP, comment the below assert.
+    //__ASSERT_DEBUG((aDataProviderId < iSingletons.DpController().Count()), User::Invariant());
+    
+    // Resolve the physical storage.
+    CMTPStorageMetaData& physical(StorageMetaDataL(aPhysicalStorageId));
+    // Validate the SUID and storage type.
+    if (iStorages.Find(aStorage.DesC(CMTPStorageMetaData::EStorageSuid), StorageKeyMatchSuid) != KErrNotFound)
+        {
+        // SUID is not unique.
+        User::Leave(KErrAlreadyExists);
+        }
+    else if (aStorage.Uint(CMTPStorageMetaData::EStorageSystemType) != physical.Uint(CMTPStorageMetaData::EStorageSystemType))
+        {
+        // Physical/logical storage type mis-match.
+        User::Leave(KErrArgument);
+        }
+    else if (aStorage.Uint(CMTPStorageMetaData::EStorageSystemType) == CMTPStorageMetaData::ESystemTypeDefaultFileSystem)
+        {   
+        // Validate that the SUID path exists.
+        if (!BaflUtils::PathExists(iSingletons.Fs(), aStorage.DesC(CMTPStorageMetaData::EStorageSuid)))
+            {
+            User::Leave(KErrPathNotFound);
+            }
+     
+        // Validate that the SUID path corresponds to the physical storage drive.
+        TInt storageDrive(DriveNumber(aPhysicalStorageId));
+        TParse p;
+        User::LeaveIfError(p.Set(aStorage.DesC(CMTPStorageMetaData::EStorageSuid), NULL, NULL));
+        TInt suidDrive(0);
+        User::LeaveIfError(iSingletons.Fs().CharToDrive(TChar(p.Drive()[0]), suidDrive));
+        if (suidDrive != storageDrive)
+            {
+            // SUID path/physical storage drive mis-match.
+            User::Leave(KErrArgument);
+            }
+        }
+    
+    // Allocate a logical StorageId.
+    TInt32 id(AllocateLogicalStorageId(aDataProviderId, aPhysicalStorageId));
+    User::LeaveIfError(id);
+    
+    // Create the logical storage meta-data.
+    CMTPStorageMetaData* logical(CMTPStorageMetaData::NewLC(aStorage));
+    logical->SetUint(CMTPStorageMetaData::EStorageId, id);
+    
+    // Store the logical storage meta-data.
+    iStorages.InsertInOrderL(logical, StorageOrder);
+    CleanupStack::Pop(logical);
+    
+    // Associate the logical and physical storages.
+    RArray<TUint> logicals;
+    CleanupClosePushL(logicals);
+    physical.GetUintArrayL(CMTPStorageMetaData::EStorageLogicalIds, logicals);
+    logicals.InsertInOrderL(id);
+    physical.SetUintArrayL(CMTPStorageMetaData::EStorageLogicalIds, logicals);
+    CleanupStack::PopAndDestroy(&logicals);
+    
+#ifdef __FLOG_ACTIVE
+    HBufC8* buf(HBufC8::NewLC(aStorage.DesC(CMTPStorageMetaData::EStorageSuid).Length()));
+    buf->Des().Copy(aStorage.DesC(CMTPStorageMetaData::EStorageSuid));
+    __FLOG_VA((_L8("Allocated logical StorageID 0x%08X for storage SUID %S"), id, buf));
+    CleanupStack::PopAndDestroy(buf);
+#endif // __FLOG_ACTIVE    
+    __FLOG(_L8("AllocateLogicalStorageIdL - Exit"));
+    return id;
+    }
+
+EXPORT_C TUint32 CMTPStorageMgr::AllocatePhysicalStorageIdL(TUint aDataProviderId, const CMTPStorageMetaData& aStorage)
+    {
+    __FLOG(_L8("AllocatePhysicalStorageIdL - Entry"));
+    
+    // Validate the SUID.
+    if (iStorages.Find(aStorage.DesC(CMTPStorageMetaData::EStorageSuid), StorageKeyMatchSuid) != KErrNotFound)
+        {
+        // SUID is not unique.
+        User::Leave(KErrAlreadyExists);
+        }
+    
+    // Allocate a physical StorageId.
+    TInt32 id(AllocatePhysicalStorageId(aDataProviderId));
+    User::LeaveIfError(id);
+    
+    // Create the physical storage meta-data.
+    CMTPStorageMetaData* physical(CMTPStorageMetaData::NewLC(aStorage));
+    const RArray<TUint> noStorages;
+    physical->SetUint(CMTPStorageMetaData::EStorageId, id);
+    physical->SetUintArrayL(CMTPStorageMetaData::EStorageLogicalIds, noStorages);
+    
+    // Store the physical storage meta-data.
+    iStorages.InsertInOrderL(physical, StorageOrder);
+    CleanupStack::Pop(physical);
+    
+    __FLOG_VA((_L8("Allocated physical StorageID 0x%08X"), id));
+    __FLOG(_L8("AllocatePhysicalStorageIdL - Exit"));
+    return id;
+    }
+
+EXPORT_C TInt CMTPStorageMgr::DeallocateLogicalStorageId(TUint aDataProviderId, TUint32 aLogicalStorageId)
+    {
+    __FLOG(_L8("DeallocateLogicalStorageId - Entry"));
+    TInt ret(KErrArgument);
+    
+    // Validate the StorageID.
+    if (LogicalStorageId(aLogicalStorageId))
+        {
+        ret = iStorages.FindInOrder(aLogicalStorageId, StorageOrder);
+        if (ret != KErrNotFound)
+            {
+            // Validate the storage owner.
+            if (LogicalStorageOwner(iStorages[ret]->Uint(CMTPStorageMetaData::EStorageId)) != aDataProviderId)
+                {
+                ret = KErrAccessDenied;
+                }
+            else
+                {
+                TRAPD(err, RemoveLogicalStorageL(ret));
+                ret = err;
+                }
+            }
+        }
+    __FLOG(_L8("DeallocateLogicalStorageId - Exit"));
+    return ret;
+    }
+
+EXPORT_C void CMTPStorageMgr::DeallocateLogicalStorageIds(TUint aDataProviderId, TUint32 aPhysicalStorageId)
+    {
+    __FLOG(_L8("DeallocateLogicalStorageIds - Entry"));
+    TInt ret(iStorages.FindInOrder(aPhysicalStorageId, StorageOrder));
+    if (ret != KErrNotFound)
+        {
+        const RArray<TUint>& logicals(iStorages[ret]->UintArray(CMTPStorageMetaData::EStorageLogicalIds));
+        TUint count(logicals.Count());
+        while (count)
+            {
+            const TUint KIdx(count - 1);
+            if (LogicalStorageOwner(logicals[KIdx]) == aDataProviderId)
+                {
+                DeallocateLogicalStorageId(aDataProviderId, logicals[KIdx]);
+                }
+            count--;
+            }
+        }
+    __FLOG(_L8("DeallocateLogicalStorageIds - Exit"));
+    }
+
+EXPORT_C TInt CMTPStorageMgr::DeallocatePhysicalStorageId(TUint aDataProviderId, TUint32 aPhysicalStorageId)
+    {
+    __FLOG(_L8("DeallocatePhysicalStorageId - Entry"));
+    TInt ret(KErrArgument);
+    
+    // Validate the StorageID.
+    if (!LogicalStorageId(aPhysicalStorageId))
+        {
+        ret = iStorages.FindInOrder(aPhysicalStorageId, StorageOrder);
+        if (ret != KErrNotFound)
+            {
+            // Validate the storage owner.
+            if (PhysicalStorageOwner(iStorages[ret]->Uint(CMTPStorageMetaData::EStorageId)) != aDataProviderId)
+                {
+                ret = KErrAccessDenied;
+                }
+            else
+                {
+                // Deallocate all associated logical storages.
+                const RArray<TUint>& logicals(iStorages[ret]->UintArray(CMTPStorageMetaData::EStorageLogicalIds));
+                TUint count(logicals.Count());
+                while (count)
+                    {
+                    const TUint KIdx(--count);
+                    DeallocateLogicalStorageId(aDataProviderId, logicals[KIdx]);
+                    }
+                
+                // Delete the storage.
+                delete iStorages[ret];
+                iStorages.Remove(ret);
+                }
+            }
+        }
+    __FLOG(_L8("DeallocatePhysicalStorageId - Exit"));
+    return ret;
+    }
+
+EXPORT_C TUint32 CMTPStorageMgr::DefaultStorageId() const
+    {
+    __FLOG(_L8("DefaultStorageId - Entry"));
+    __FLOG(_L8("DefaultStorageId - Exit"));
+    return iDefaultStorageId;
+    }
+
+EXPORT_C TInt CMTPStorageMgr::DriveNumber(TUint32 aStorageId) const
+    {
+    __FLOG(_L8("DriveNumber - Entry"));
+    TInt drive(KErrNotFound);
+    if (PhysicalStorageOwner(aStorageId) == iFrameworkId)
+        {
+        const TUint32 KPhysicalId(PhysicalStorageId(aStorageId));
+        const TUint KCount(iMapDriveToStorage.Count());
+        for (TUint i(0); ((i < KCount) && (drive == KErrNotFound)); i++)
+            {
+            if (PhysicalStorageId(iMapDriveToStorage[i]) == KPhysicalId)
+                {
+                drive = i;
+                }
+            }
+        }
+    __FLOG(_L8("DriveNumber - Exit"));
+    return drive;
+    }
+
+EXPORT_C TInt32 CMTPStorageMgr::FrameworkStorageId(TDriveNumber aDriveNumber) const
+    {
+    __FLOG(_L8("FrameworkStorageId - Entry"));
+    TInt32 ret(KErrNotFound);
+    TInt32 id(iMapDriveToStorage[aDriveNumber]);
+    if ((id != KErrNotFound) && (LogicalStorageId(id)))
+        {
+        ret = id;
+        }
+    __FLOG(_L8("FrameworkStorageId - Exit"));
+    return ret;
+    }
+
+EXPORT_C void CMTPStorageMgr::GetAvailableDrivesL(RArray<TDriveNumber>& aDrives) const
+    {
+    __FLOG(_L8("GetAvailableDrivesL - Entry"));
+    aDrives.Reset();
+    for (TUint i(0); (i < iMapDriveToStorage.Count()); i++)
+        {
+        if (iMapDriveToStorage[i] != KErrNotFound)
+            {
+            aDrives.AppendL(static_cast<TDriveNumber>(i));
+            }
+        }
+    __FLOG(_L8("GetAvailableDrivesL - Exit"));
+    }
+
+EXPORT_C void CMTPStorageMgr::GetLogicalStoragesL(const TMTPStorageMgrQueryParams& aParams, RPointerArray<const CMTPStorageMetaData>& aStorages) const
+    {
+    __FLOG(_L8("GetLogicalStoragesL - Entry"));
+    aStorages.Reset();
+    const TBool KAllStorages(aParams.StorageSuid() == KNullDesC);
+    const TBool KAllStorageSystemTypes(aParams.StorageSystemType() == CMTPStorageMetaData::ESystemTypeUndefined);
+    const TUint KCount(iStorages.Count());
+    for (TUint i(0); (i < KCount); i++)
+        {
+        const CMTPStorageMetaData& storage(*iStorages[i]);
+        if (((KAllStorages) || (storage.DesC(CMTPStorageMetaData::EStorageSuid) == aParams.StorageSuid())) &&
+            ((KAllStorageSystemTypes) || (storage.Uint(CMTPStorageMetaData::EStorageSystemType) == aParams.StorageSystemType())) &&
+            (LogicalStorageId(storage.Uint(CMTPStorageMetaData::EStorageId))))
+            {
+            aStorages.AppendL(iStorages[i]);
+            }
+        }
+    __FLOG(_L8("GetLogicalStoragesL - Exit"));
+    }
+
+EXPORT_C void CMTPStorageMgr::GetPhysicalStoragesL(const TMTPStorageMgrQueryParams& aParams, RPointerArray<const CMTPStorageMetaData>& aStorages) const
+    {
+    __FLOG(_L8("GetPhysicalStoragesL - Entry"));
+    aStorages.Reset();
+    const TBool KAllStorages(aParams.StorageSuid() == KNullDesC);
+    const TBool KAllStorageSystemTypes(aParams.StorageSystemType() == CMTPStorageMetaData::ESystemTypeUndefined);
+    const TUint KCount(iStorages.Count());
+    for (TUint i(0); (i < KCount); i++)
+        {
+        const CMTPStorageMetaData& storage(*iStorages[i]);
+        if (((KAllStorages) || (storage.DesC(CMTPStorageMetaData::EStorageSuid) == aParams.StorageSuid())) &&
+            ((KAllStorageSystemTypes) || (storage.Uint(CMTPStorageMetaData::EStorageSystemType) == aParams.StorageSystemType())) &&
+            (!LogicalStorageId(storage.Uint(CMTPStorageMetaData::EStorageId))))
+            {
+            aStorages.AppendL(iStorages[i]);
+            }
+        }
+    __FLOG(_L8("GetPhysicalStoragesL - Exit"));
+    }
+
+EXPORT_C TUint32 CMTPStorageMgr::LogicalStorageId(TUint32 aStorageId) const
+    {
+    __FLOG(_L8("LogicalStorageId - Entry"));
+    __FLOG(_L8("LogicalStorageId - Exit"));
+    return (aStorageId & KLogicalIdMask);
+    }
+
+EXPORT_C TInt32 CMTPStorageMgr::LogicalStorageId(const TDesC& aStorageSuid) const
+    {
+    __FLOG(_L8("LogicalStorageId - Entry"));
+    TInt32 id(KErrNotFound);
+    TInt idx(iStorages.Find(aStorageSuid, StorageKeyMatchSuid));
+    if (idx != KErrNotFound)
+        {
+        id = iStorages[idx]->Uint(CMTPStorageMetaData::EStorageId);
+        if (!LogicalStorageId(id))
+            {
+            id = KErrNotFound;
+            }
+        }
+    __FLOG(_L8("LogicalStorageId - Exit"));
+    return id;
+    }
+
+EXPORT_C TInt32 CMTPStorageMgr::PhysicalStorageId(TDriveNumber aDriveNumber) const
+    {
+    __FLOG(_L8("PhysicalStorageId - Entry"));
+    TInt32 storageId(iMapDriveToStorage[aDriveNumber]);
+    if (storageId != KErrNotFound)
+        {
+        storageId = PhysicalStorageId(storageId);
+        }
+    __FLOG(_L8("PhysicalStorageId - Exit"));
+    return storageId;
+    }
+
+EXPORT_C TUint32 CMTPStorageMgr::PhysicalStorageId(TUint32 aStorageId) const
+    {
+    __FLOG(_L8("PhysicalStorageId - Entry"));
+    __FLOG(_L8("PhysicalStorageId - Exit"));
+    return (aStorageId & KPhysicalIdMask);
+    }
+
+EXPORT_C const CMTPStorageMetaData& CMTPStorageMgr::StorageL(TUint32 aStorageId) const
+    {
+    __FLOG(_L8("StorageL - Entry"));
+    TInt idx(iStorages.FindInOrder(aStorageId, StorageOrder));
+    User::LeaveIfError(idx);
+    __FLOG(_L8("StorageL - Exit"));
+    return *iStorages[idx];
+    }
+
+EXPORT_C TUint32 CMTPStorageMgr::StorageId(TUint32 aPhysicalStorageId, TUint32 aLogicalStorageId) const
+    {
+    __FLOG(_L8("StorageId - Entry"));
+    __FLOG(_L8("StorageId - Exit"));
+    return (aPhysicalStorageId | aLogicalStorageId);
+    }
+
+EXPORT_C TBool CMTPStorageMgr::ValidStorageId(TUint32 aStorageId) const
+    {
+    __FLOG(_L8("ValidStorageId - Entry"));
+    TInt idx(iStorages.FindInOrder(aStorageId, StorageOrder));
+    if(KErrNotFound == idx)
+    	{
+    	__FLOG(_L8("ValidStorageId - False Exit"));
+    	return EFalse;
+    	}
+    
+    _LIT(KSeperator,"\\");
+	TBool ret = ETrue;
+	if(iStorages[idx]->Uint(CMTPStorageMetaData::EStorageSystemType) == CMTPStorageMetaData::ESystemTypeDefaultFileSystem)
+		{
+		const TDesC& KSuid(iStorages[idx]->DesC(CMTPStorageMetaData::EStorageSuid));
+		if(LogicalStorageId(aStorageId) || (KSuid.Right(1) == KSeperator))
+			{
+			ret = BaflUtils::PathExists(iSingletons.Fs(), KSuid);
+			}
+		else if(KSuid.Length() >= KMaxFileName)
+			{
+			ret = EFalse;
+			}
+		else
+			{
+			TFileName buf;
+			buf.Append(KSuid);
+            buf.Append(KSeperator);
+            
+            ret = BaflUtils::PathExists(iSingletons.Fs(), buf);
+			}
+		}
+  
+    __FLOG(_L8("ValidStorageId - Exit"));
+    
+    return ret;
+    }
+    
+EXPORT_C CMTPTypeString* CMTPStorageMgr::VolumeIdL(TUint aDataProviderId, TUint32 aStorageId, const TDesC& aVolumeIdSuffix) const
+    {
+    __FLOG(_L8("VolumeIdL - Entry"));
+
+    // Validate the StorageId.
+    TUint owner(LogicalStorageId(aStorageId) ? LogicalStorageOwner(aStorageId) : PhysicalStorageOwner(aStorageId));
+    if (!ValidStorageId(aStorageId))
+        {
+        User::Leave(KErrNotFound);
+        }
+    else if (aDataProviderId != owner)
+        {
+        User::Leave(KErrAccessDenied);
+        }
+    
+    // Generate a unique volume ID.
+    RBuf16 buffer;
+    buffer.CreateL(KMTPMaxStringCharactersLength);
+    CleanupClosePushL(buffer);
+    buffer.Format(_L("%08X"), aStorageId); 
+           
+    if (aVolumeIdSuffix.Length() != 0)
+        {
+        // Append the separator and suffix, truncating if necessary.
+        buffer.Append(_L("-"));
+        buffer.Append(aVolumeIdSuffix.Left(KMTPMaxStringCharactersLength - buffer.Length()));
+        }
+
+    CMTPTypeString* volumeId = CMTPTypeString::NewL(buffer);
+	CleanupStack::PopAndDestroy(&buffer);  
+    __FLOG(_L8("VolumeIdL - Exit"));
+    return volumeId;
+    }   
+    
+/**
+Constructor.
+*/
+CMTPStorageMgr::CMTPStorageMgr() :
+    iFrameworkId(KErrNotFound)
+    {
+
+    }
+    
+/**
+Second phase constructor.
+@leave One of the system wide error code, if a processing failure occurs.
+*/
+void CMTPStorageMgr::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry"));
+    iSingletons.OpenL();
+    for (TUint i(0); (i < KMaxDrives); i++)
+        {
+        iMapDriveToStorage[i] = KErrNotFound;
+        }
+    __FLOG(_L8("ConstructL - Exit"));
+    }
+    
+/**
+Allocates a new 32-bit logical StorageId for the storage owner as a partition 
+of the specified physical MTP StorageID.
+@param aDataProviderId The storage owner data provider identifier.
+@param aPhysicalStorageId The physical MTP StorageID.
+@return The new logical StorageId.
+@return KErrNotFound, if the specified physical MTP StorageID does not exist
+@return KErrOverflow, if the maximum number of storages would be exceeded.
+*/
+TInt32 CMTPStorageMgr::AllocateLogicalStorageId(TUint aDataProviderId, TUint32 aPhysicalStorageId)
+    {
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("AllocateLogicalStorageId - Entry"));
+    TInt ret(iStorages.FindInOrder(aPhysicalStorageId, StorageOrder));
+    if (ret != KErrNotFound)
+        {
+        // Scan for the first available storage number.
+        const RArray<TUint>& logicalIds(iStorages[ret]->UintArray(CMTPStorageMetaData::EStorageLogicalIds));
+        TUint num(1);
+        do
+            {
+            ret = EncodeLogicalStorageId(aPhysicalStorageId, aDataProviderId, num);
+            }
+        while ((logicalIds.FindInOrder(ret) != KErrNotFound) &&
+                (++num <= KMaxOwnedStorages));
+                
+        if (num >= KMaxOwnedStorages)
+            {
+            ret = KErrOverflow;
+            }
+        }
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("AllocateLogicalStorageId - Exit"));
+    return ret;
+    }
+    
+/**
+Allocates a new 32-bit physical StorageId for the storage owner.
+@param aDataProviderId The storage owner data provider identifier.
+@return The new physical StorageId.
+@return KErrOverflow, if the maximum number of storages would be exceeded.
+@return One of the system wide error code, if a processing failure occurs.
+*/
+TInt32 CMTPStorageMgr::AllocatePhysicalStorageId(TUint aDataProviderId)
+    {
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("AllocatePhysicalStorageId - Entry"));
+    TInt32 ret(KErrNone);
+    while ((iPhysicalStorageNumbers.Count() < (aDataProviderId + 1)) && (ret == KErrNone))
+        {
+        ret = iPhysicalStorageNumbers.Append(0);
+        }
+        
+    if (ret == KErrNone)
+        {
+        if (iPhysicalStorageNumbers[aDataProviderId] < KMaxOwnedStorages)
+            {
+            ret = EncodePhysicalStorageId(aDataProviderId, ++iPhysicalStorageNumbers[aDataProviderId]);
+            }
+        else
+            {
+            ret = KErrOverflow;
+            }
+        }
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("AllocatePhysicalStorageId - Exit"));
+    return ret;
+    }
+	
+/**
+Encodes the specified physical MTP StorageID, data provider identifier, and 
+storage number as a fully formed MTP StorageID.
+@param aPhysicalStorageId The physical MTP StorageID.
+@param aDataProviderId The data provider identifier.
+@param aStorageNumber The storage number.
+@return The fully formed MTP StorageID.
+*/	
+TUint32 CMTPStorageMgr::EncodeLogicalStorageId(TUint32 aPhysicalStorageId, TUint aDataProviderId, TUint aStorageNumber)
+    {
+    return (StorageId(aPhysicalStorageId, (EncodeLogicalStorageOwner(aDataProviderId) | EncodeLogicalStorageNumber(aStorageNumber))));
+    }
+
+/**
+Encodes the storage identifier as the logical storage number in a fully formed 
+MTP StorageID.
+@param aStorageNumber The storage number.
+@return The encoded logical storage number.
+*/	
+TUint32 CMTPStorageMgr::EncodeLogicalStorageNumber(TUint aStorageNumber)
+	{
+	return (aStorageNumber);
+	}
+
+/**
+Encodes the specified data provider identifier as the logical storage owner 
+in a fully formed MTP StorageID.
+@param aDataProviderId The data provider identifier.
+@return The encoded logical storage owner.
+*/
+TUint32 CMTPStorageMgr::EncodeLogicalStorageOwner(TUint aDataProviderId)
+	{
+	return (aDataProviderId << KLogicalOwnerShift);
+	}
+	
+/**
+Encodes the specified data provider identifier and storage number as an  
+physical MTP StorageID.
+@param aDataProviderId The data provider identifier.
+@param aStorageNumber The storage number.
+@return The encoded physical MTP StorageID.
+*/	
+TUint32 CMTPStorageMgr::EncodePhysicalStorageId(TUint aDataProviderId, TUint aStorageNumber)
+    {
+    return (EncodePhysicalStorageOwner(aDataProviderId) | EncodePhysicalStorageNumber(aStorageNumber));
+    }
+
+/**
+Encodes the storage identifier as the physical storage number in a fully formed 
+MTP StorageID.
+@param aStorageNumber The storage number.
+@return The encoded physical storage number.
+*/	
+TUint32 CMTPStorageMgr::EncodePhysicalStorageNumber(TUint aStorageNumber)
+	{
+	return (aStorageNumber << KPhysicalNumberShift);
+	}
+
+/**
+Encodes the specified data provider identifier as the physical storage owner 
+in a fully formed MTP StorageID.
+@param aDataProviderId The data provider identifier.
+@return The encoded physical storage owner.
+*/
+TUint32 CMTPStorageMgr::EncodePhysicalStorageOwner(TUint aDataProviderId)
+	{
+	return (aDataProviderId << KPhysicalOwnerShift);
+	}
+	
+/**
+Removes the logical storages table entry at the specified index.
+@param aIdx The storages table index.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPStorageMgr::RemoveLogicalStorageL(TUint aIdx)
+    {
+    __FLOG(_L8("RemoveLogicalStorageL - Entry"));
+    TUint32 id(iStorages[aIdx]->Uint(CMTPStorageMetaData::EStorageId));
+    
+    // Disassociate the logical and physical storages.
+    CMTPStorageMetaData& physical(StorageMetaDataL(PhysicalStorageId(id)));
+    RArray<TUint> logicals;
+    CleanupClosePushL(logicals);
+    physical.GetUintArrayL(CMTPStorageMetaData::EStorageLogicalIds, logicals);
+    logicals.Remove(logicals.FindInOrderL(id));
+    physical.SetUintArrayL(CMTPStorageMetaData::EStorageLogicalIds, logicals);
+    CleanupStack::PopAndDestroy(&logicals);
+    
+    // Delete the storage.
+    delete iStorages[aIdx];
+    iStorages.Remove(aIdx);
+    __FLOG(_L8("RemoveLogicalStorageL - Entry"));
+    }
+    
+/**
+Provides a non-const reference to the storage meta-data for the specified 
+logical MTP StorageID.
+@param aStorageId The physical or fully formed logical MTP StorageID.
+@leave KErrNotFound if the specified StorageID does not exist.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+CMTPStorageMetaData& CMTPStorageMgr::StorageMetaDataL(TUint32 aStorageId)
+    {
+    __FLOG(_L8("StorageMetaDataL - Entry"));
+    TInt idx(iStorages.FindInOrder(aStorageId, StorageOrder));
+    User::LeaveIfError(idx);
+    __FLOG(_L8("StorageMetaDataL - Exit"));
+    return *iStorages[idx];
+    }
+   
+/**
+Implements a storage key match identity relation using 
+@see CMTPStorageMetaData::EStorageSuid.
+@param aSuid The storage SUID key value.
+@param aStorage The storage meta-data.
+@return ETrue if the storage matches the key relation, otherwise EFalse.
+*/ 
+TBool CMTPStorageMgr::StorageKeyMatchSuid(const TDesC* aSuid, const CMTPStorageMetaData& aStorage)
+    {
+    return (*aSuid == aStorage.DesC(CMTPStorageMetaData::EStorageSuid));
+    }
+	
+/**
+Implements an @see TLinearOrder function for @see CMTPStorageMetaData objects 
+based on relative @see CMTPStorageMetaData::EStorageId.
+@param aL The first object instance.
+@param aR The second object instance.
+@return Zero, if the two objects are equal; A negative value, if the first 
+object is less than the second, or; A positive value, if the first object is 
+greater than the second.
+*/
+TInt CMTPStorageMgr::StorageOrder(const CMTPStorageMetaData& aL, const CMTPStorageMetaData& aR)
+    {
+    return (aL.Uint(CMTPStorageMetaData::EStorageId) - aR.Uint(CMTPStorageMetaData::EStorageId));
+    }
+	
+/**
+Implements an @see CMTPStorageMetaData::EStorageId key order function.
+@param aKey The key value.
+@param aR The storage meta-data.
+@return Zero, if the two objects are equal; A negative value, if the first 
+object is less than the second, or; A positive value, if the first object is 
+greater than the second.
+*/
+TInt CMTPStorageMgr::StorageOrder(const TUint32* aKey, const CMTPStorageMetaData& aStorage)
+    {
+    return (*aKey - aStorage.Uint(CMTPStorageMetaData::EStorageId));
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/dbutility.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,73 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include "dbutility.h"
+#include "d32dbms.h"
+    
+/**
+Check if the table exists in the database.
+@param aDatabase  the database to use
+@param aTableName the table name to check
+@return ETrue if exists, otherwise, EFalse
+*/
+TBool DBUtility::IsTableExistsL(RDbDatabase& aDatabase, const TDesC& aTableName)
+	{
+	TBool result = EFalse;
+	CDbTableNames* tableNames = aDatabase.TableNamesL();
+	CleanupStack::PushL(tableNames);
+	if(tableNames)
+		{
+		const TInt count = tableNames->Count();
+		for(TInt i = 0; i < count; i++)
+			{
+			if((*tableNames)[i] == aTableName)
+				{
+				result = ETrue;
+				break;
+				}
+			}
+		}
+	CleanupStack::PopAndDestroy(tableNames);
+	return result;	
+	}
+
+/**
+Check if the specified index exists in the table.
+@param aDatabase  the database to use
+@param aTableName the table name to use
+@param aIndexName the index name to check
+@return ETrue if the index exists, otherwise, EFalse
+*/
+TBool DBUtility::IsIndexExistsL(RDbDatabase& aDatabase, const TDesC& aTableName, const TDesC& aIndexName)
+	{
+	TBool result = EFalse;
+	CDbIndexNames* indexNames = aDatabase.IndexNamesL(aTableName);
+	CleanupStack::PushL(indexNames);
+	if(indexNames)
+		{
+		const TInt count = indexNames->Count();
+		for(TInt i = 0; i < count; i++)
+			{
+			if((*indexNames)[i] == aIndexName)
+				{
+				result = ETrue;
+				break;
+				}
+			}
+		}
+	CleanupStack::PopAndDestroy(indexNames);
+	return result;	
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/dummydp_config.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,28 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/mtpdataproviderconfig.rh>
+
+RESOURCE MTP_DATA_PROVIDER dpConfig
+    {
+    type = 0;
+    major_version = 1;
+    object_enumeration_persistent = 1;
+    supported_modes = KMTPModeMTP;  
+    server_name = "";
+    server_image_name = "";
+    opaque_resource = 0;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/framework_config.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,46 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+//#include <mtp/mtpdataproviderconfig.rh>
+
+
+STRUCT ELEMENTSARRAY
+	{
+	STRUCT	elements[];
+	}
+
+
+STRUCT DP_LOADING_CONFIG
+	{
+	LONG	syncdp_uid;	   //  SyncDP UID
+	LONG	transport_uid[];   //  array of Transport UIDs
+	}
+
+RESOURCE ELEMENTSARRAY r_elements_info
+	{
+        elements=
+		{
+		DP_LOADING_CONFIG
+		{
+		syncdp_uid = 0x2001B137;
+		transport_uid = {				
+				0x102827AC,
+				0xA0004A61
+ 		 		}; 
+		}
+		//ADD New Data Provider Uid's with the supported Transport ID's		
+		};
+	
+        }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/rmtpframework.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,241 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "cmtpconnectionmgr.h"
+#include "cmtpdataprovidercontroller.h"
+#include "cmtpframeworkconfig.h"
+#include "cmtpobjectmgr.h"
+#include "cmtpobjectstore.h"
+#include "cmtpparserrouter.h"
+#include "cmtpstoragemgr.h"
+#include "rmtpframework.h"
+#include "cmtpdatacodegenerator.h"
+#include "cmtpservicemgr.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"Framework");)
+
+/**
+Constructor.
+*/
+EXPORT_C RMTPFramework::RMTPFramework() :
+    iSingletons(NULL)
+    {
+    
+    }
+
+/**
+Opens the singletons reference.
+*/
+EXPORT_C void RMTPFramework::OpenL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("OpenL - Entry"));
+    iSingletons = &CSingletons::OpenL();
+    iNested     = iSingletons->iConstructing;
+    __FLOG(_L8("OpenL - Exit"));
+    }
+
+/**
+Opens the singletons reference. The singletons reference is pushed onto the
+cleanup stack.
+*/
+EXPORT_C void RMTPFramework::OpenLC()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("OpenLC - Entry"));
+    ::CleanupClosePushL(*this);
+    OpenL();
+    __FLOG(_L8("OpenLC - Exit"));
+    }
+    
+/**
+Closes the singletons reference.
+*/
+EXPORT_C void RMTPFramework::Close()
+    {
+    __FLOG(_L8("Close - Entry"));
+    if ((iSingletons) && (!iNested))
+        {
+        iSingletons->Close();
+        iSingletons = NULL;
+        }
+    __FLOG(_L8("Close - Exit"));
+    __FLOG_CLOSE;
+    }
+
+EXPORT_C CMTPConnectionMgr& RMTPFramework::ConnectionMgr() const
+    {
+    __FLOG(_L8("ConnectionMgr - Entry"));
+    __ASSERT_DEBUG(iSingletons, User::Invariant());
+    __ASSERT_DEBUG(iSingletons->iSingletonConnectionMgr, User::Invariant());
+    __FLOG(_L8("ConnectionMgr - Exit"));
+    return *(iSingletons->iSingletonConnectionMgr);
+    }
+    
+EXPORT_C CMTPDataProviderController& RMTPFramework::DpController() const
+    {
+    __FLOG(_L8("DpController - Entry"));
+    __ASSERT_DEBUG(iSingletons, User::Invariant());
+    __ASSERT_DEBUG(iSingletons->iSingletonDpController, User::Invariant());
+    __FLOG(_L8("DpController - Exit"));
+    return *(iSingletons->iSingletonDpController);
+    }
+   
+EXPORT_C CMTPFrameworkConfig& RMTPFramework::FrameworkConfig() const
+    {
+    __FLOG(_L8("FrameworkConfig - Entry"));
+    __ASSERT_DEBUG(iSingletons, User::Invariant());
+    __ASSERT_DEBUG(iSingletons->iSingletonFrameworkConfig, User::Invariant());
+    __FLOG(_L8("FrameworkConfig - Exit"));
+    return *(iSingletons->iSingletonFrameworkConfig);
+    }
+
+EXPORT_C RFs& RMTPFramework::Fs() const
+    {
+    __FLOG(_L8("Fs - Entry"));
+    __ASSERT_DEBUG(iSingletons, User::Invariant());
+    __FLOG(_L8("Fs - Exit"));
+    return iSingletons->iSingletonFs;
+    }
+
+EXPORT_C CMTPObjectMgr& RMTPFramework::ObjectMgr() const
+    {
+    __FLOG(_L8("ObjectMgr - Entry"));
+    __ASSERT_DEBUG(iSingletons, User::Invariant());
+    __ASSERT_DEBUG(iSingletons->iSingletonObjectMgr, User::Invariant());
+    __FLOG(_L8("ObjectMgr - Exit"));
+    return *(iSingletons->iSingletonObjectMgr);
+    }
+
+EXPORT_C CMTPReferenceMgr& RMTPFramework::ReferenceMgr() const
+    {
+    __FLOG(_L8("ReferenceMgr - Entry"));
+    __ASSERT_DEBUG(iSingletons, User::Invariant());
+    __ASSERT_DEBUG(iSingletons->iSingletonRouter, User::Invariant());
+    __FLOG(_L8("ReferenceMgr - Exit"));
+    return (iSingletons->iSingletonObjectMgr->ObjectStore().ReferenceMgr());
+    }
+
+EXPORT_C CMTPParserRouter& RMTPFramework::Router() const
+    {
+    __FLOG(_L8("Router - Entry"));
+    __ASSERT_DEBUG(iSingletons, User::Invariant());
+    __ASSERT_DEBUG(iSingletons->iSingletonRouter, User::Invariant());
+    __FLOG(_L8("Router - Exit"));
+    return *(iSingletons->iSingletonRouter);
+    }
+
+EXPORT_C CMTPStorageMgr& RMTPFramework::StorageMgr() const
+    {
+    __FLOG(_L8("StorageMgr - Entry"));
+    __ASSERT_DEBUG(iSingletons, User::Invariant());
+    __ASSERT_DEBUG(iSingletons->iSingletonStorageMgr, User::Invariant());
+    __FLOG(_L8("StorageMgr - Exit"));
+    return *(iSingletons->iSingletonStorageMgr);
+    }
+
+EXPORT_C CMTPDataCodeGenerator& RMTPFramework::DataCodeGenerator() const
+    {
+    __FLOG(_L8("DataCodeGenerator - Entry"));
+    __ASSERT_DEBUG(iSingletons, User::Invariant());
+    __ASSERT_DEBUG(iSingletons->iSingleDataCodeGenerator, User::Invariant());
+    __FLOG(_L8("DataCodeGenerator - Exit"));
+    return *(iSingletons->iSingleDataCodeGenerator);
+    }
+
+EXPORT_C CMTPServiceMgr& RMTPFramework::ServiceMgr() const
+    {
+    __FLOG(_L8("ServiceMgr - Entry"));
+   __ASSERT_DEBUG(iSingletons, User::Invariant());
+   __ASSERT_DEBUG(iSingletons->iSingleServiceMgr, User::Invariant());
+   __FLOG(_L8("ServiceMgr - Exit"));
+   return *(iSingletons->iSingleServiceMgr);
+    }
+
+RMTPFramework::CSingletons& RMTPFramework::CSingletons::OpenL()
+    {
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("CSingletons::OpenL - Entry"));
+    CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
+    if (!self)
+        {
+        self = new(ELeave) CSingletons();
+        Dll::SetTls(reinterpret_cast<TAny*>(self));
+        self->ConstructL();
+        }
+    else if (!self->iConstructing)
+        {        
+        self->Inc();
+        }
+    __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("CSingletons::OpenL - Exit"));
+    return *self;
+    }
+    
+void RMTPFramework::CSingletons::Close()
+    {
+    CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
+    if (self)
+        {
+        __FLOG(_L8("CSingletons::Close - Entry"));
+        self->Dec();
+        if (self->AccessCount() == 0)
+            {
+            __FLOG(_L8("CSingletons::Close - Exit"));
+            delete self;
+            Dll::SetTls(NULL);
+            }
+        else
+            {
+            __FLOG(_L8("CSingletons::Close - Exit"));
+            }
+        }
+    }
+    
+RMTPFramework::CSingletons::~CSingletons()
+    {
+    __FLOG(_L8("CSingletons::~CSingletons - Entry"));
+    delete iSingletonStorageMgr;
+    delete iSingletonRouter;
+    delete iSingletonDpController;
+    delete iSingletonObjectMgr;
+    delete iSingletonFrameworkConfig;
+    delete iSingletonConnectionMgr;
+    delete iSingleDataCodeGenerator;
+    delete iSingleServiceMgr;
+    
+    iSingletonFs.Close();
+    __FLOG(_L8("CSingletons::~CSingletons - Exit"));
+    __FLOG_CLOSE;
+    }
+    
+void RMTPFramework::CSingletons::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("CSingletons::ConstructL - Entry"));
+    iConstructing = ETrue;
+    
+	User::LeaveIfError(iSingletonFs.Connect());
+    iSingletonFrameworkConfig   = CMTPFrameworkConfig::NewL();
+    iSingletonConnectionMgr     = CMTPConnectionMgr::NewL();
+    iSingletonObjectMgr         = CMTPObjectMgr::NewL();
+    iSingletonDpController      = CMTPDataProviderController::NewL();
+    iSingletonRouter            = CMTPParserRouter::NewL();
+    iSingletonStorageMgr        = CMTPStorageMgr::NewL();
+    iSingleDataCodeGenerator    = CMTPDataCodeGenerator::NewL();
+    iSingleServiceMgr           = CMTPServiceMgr::NewL();
+    
+    iConstructing = EFalse;
+    __FLOG(_L8("CSingletons::ConstructL - Exit"));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/ruidmapper.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,100 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <barsc.h> 
+#include <barsread.h>
+#include "ruidmapper.h"
+#include <framework.rsg>
+_LIT(KFrameworkFilename, "\\resource\\mtp\\framework.rsc");
+
+void RUidMapping::ReadFromResourceFileL()
+	{
+	RFs 	Fs;
+	User::LeaveIfError(Fs.Connect());
+	CleanupClosePushL(Fs); 
+	const TDriveName driveName(TDriveUnit(EDriveZ).Name());
+	HBufC* filename = HBufC::NewLC(KMaxDriveName + 
+									KFrameworkFilename().Length() );
+	
+	TPtr pFileName = filename->Des();	
+	pFileName.Append(driveName);
+	pFileName.Append(KFrameworkFilename);	
+	
+	// Reading from resource file  
+	RResourceFile resourceFile;
+	resourceFile.OpenL(Fs, *filename);
+	
+	CleanupClosePushL(resourceFile);  
+	TResourceReader resourceReader;
+	MappingStruct st;
+	HBufC8* buffer = resourceFile.AllocReadLC(R_ELEMENTS_INFO); 
+	resourceReader.SetBuffer(buffer);
+	const TInt numberOfEntries=resourceReader.ReadInt16();
+	for(TInt count =0;count<numberOfEntries ; count++)
+		{
+		st.dpUid=resourceReader.ReadInt32();
+			
+		TInt entries = resourceReader.ReadInt16();
+		for (TInt n = 0 ; n < entries; ++n)
+			{
+			TUint transportId(resourceReader.ReadInt32());
+			st.iTransportUidList.Append(transportId);
+			}
+		InsertToMappingStruct(st);	
+		}
+	
+	CleanupStack::PopAndDestroy(4, &Fs);
+	}
+	
+
+RUidMapping::RUidMapping() 
+	{
+	
+	}
+
+void RUidMapping::Close()
+	{
+	iMappingStruct.Close();
+	}
+
+void RUidMapping::Open()
+	{
+	iMappingStruct.Reset();
+	}
+
+void RUidMapping::InsertToMappingStruct(MappingStruct& aRef)
+	{
+	iMappingStruct.Append(aRef);
+	}
+	
+TBool RUidMapping::GetSupportedTransport(const TUint& aDPUid,const TUint& aTransportUid)
+	{
+	TBool found = ETrue;
+	TInt count = iMappingStruct.Count();
+	for(TInt i=0 ; i<count ; i++)
+		{
+		if(iMappingStruct[i].dpUid == aDPUid)
+			{
+			if(iMappingStruct[i].iTransportUidList.Find(aTransportUid)<0)
+				{
+				found = EFalse;
+				return found;
+				}
+			
+			}
+		}
+	return found;
+	}
+	
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/services_config.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,517 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "mtpserviceconfig.rh"
+
+
+//main resource header
+//MTP_SUPPORTED_SERVICES.guid must not be duplicate
+RESOURCE ELEMENTSARRAY mtp_supported_services
+    {
+        elements=
+        {
+        // Full Enumeration Sync Service
+        MTP_SUPPORTED_SERVICES
+            {
+            guid  = { 0x102827A1 , 0x00000001 , 0x00000000, 0x00000000 };
+            svctype = 1;
+            r_serviceinfo = r_elements_fullsync;
+            },
+                
+        //Anchor Sync Service
+        MTP_SUPPORTED_SERVICES
+            {
+            guid = { 0x102827A1 , 0x00000002 , 0x00000000, 0x00000000 };
+            svctype = 1;
+            r_serviceinfo = r_elements_anchorsync;
+            }
+                    
+        };
+    }
+
+
+//---------------Begin ----------Full Sync Service--------------------------------------------------------------------------------------------------    
+
+RESOURCE MTP_SERVICE_INFO r_elements_fullsync
+    {
+    pguid = { 0x102827A1 , 0x00000001 , 0x00000000, 0x00000000 };
+    
+    version = 100;
+    
+    svcguid =  { 0x28d3aac9, 0xc07544be,  0x888165f3, 0x8d305909 };
+    
+    
+    servicename = "FullEnumSync";
+    servicetype = 1;
+    base_serviceid = 0;
+    
+    use_service_guids = r_elements_fullsync_usedguids;
+    
+    svc_property_namespaces = r_elements_fullsync_property_namespaces;
+    svc_properties = r_elements_fullsync_properties;
+    svc_formats = r_elements_fullsync_formats;
+    svc_methods = r_elements_fullsync_methods;
+    svc_events = r_elements_fullsync_events;
+    svc_datablock = r_elements_fullsync_datablock;
+    }
+
+//SVC_GUID must not be duplicate
+RESOURCE ELEMENTSARRAY r_elements_fullsync_usedguids
+    {
+    elements =
+        {      
+//        SVC_GUID
+//            {
+//            }
+            
+        };
+    }
+
+//SVC_GUID must not be duplicate
+RESOURCE ELEMENTSARRAY r_elements_fullsync_property_namespaces
+    {
+    elements =
+        {      
+        SVC_GUID
+            {
+            guid = { 0x63b10e6c, 0x4f3a456d, 0x95cb9894, 0xedec9fa5 };
+            },
+        SVC_GUID
+            {
+            guid = { 0x703d392c, 0x532c4607, 0x91589cea, 0x742f3a16 };
+            }    
+        };
+    }
+
+//(SVC_PROPERTY.namespaceid + SVC_PROPERTY.pkid) must not be duplicate
+RESOURCE ELEMENTSARRAY r_elements_fullsync_properties
+    {
+    elements =
+        {
+
+        SVC_PROPERTY
+            {
+            namespaceid = 0;
+            pkid  = 3;
+            name = "FullEnumVersionProps";
+            datatype = 0x00004002;
+            getset = 0x00;
+            formflag = 0x00;
+            },
+                        
+        SVC_PROPERTY
+            {
+            namespaceid = 0;
+            pkid  = 4;
+            name  = "FullEnumReplicaID";
+            datatype = 0x0000000A;
+            getset = 0x01;
+            formflag = 0x00;
+            },
+            
+        SVC_PROPERTY
+            {
+            namespaceid = 0;
+            pkid  = 7;
+            name  = "FullEnumKnowledgeObjectID";
+            datatype = 0x00000006;
+            getset = 0x00;
+            formflag = 0x00;
+            }, 
+            
+        SVC_PROPERTY
+            {
+            namespaceid = 0;
+            pkid  = 8;
+            name  = "FullEnumLastSyncProxyID";
+            datatype = 0x0000000A;
+            getset = 0x01;
+            formflag = 0x00;
+            },
+            
+        SVC_PROPERTY
+            {
+            namespaceid = 0;
+            pkid  = 9;
+            name  = "FullEnumProviderVersion";
+            datatype = 0x00000004;
+            getset = 0x00;
+            formflag = 0x00;
+            },
+            
+        SVC_PROPERTY
+            {
+            namespaceid = 1;
+            pkid  = 2;
+            name  = "SyncFormat";
+            datatype = 0x0000000A;
+            getset = 0x00;
+            formflag = 0x00;
+            },
+            
+        SVC_PROPERTY
+            {
+            namespaceid = 1;
+            pkid  = 3;
+            name  = "LocalOnlyDelete";
+            datatype = 0x00000002;
+            getset = 0x01;
+            formflag = 0x02;
+            }, 
+            
+        SVC_PROPERTY
+            {
+            namespaceid = 1;
+            pkid  = 4;
+            name  = "FilterType";
+            datatype = 0x00000002;
+            getset = 0x01;
+            formflag = 0x00;
+            },      
+
+        SVC_PROPERTY
+            {
+            namespaceid = 1;
+            pkid  = 5;
+            name  = "SyncObjectReferences";
+            datatype = 0x00000002;
+            getset = 0x00;
+            formflag = 0x02;
+            }
+        };
+    }
+
+//SVC_FORMAT.guid must not be duplicate    
+RESOURCE ELEMENTSARRAY r_elements_fullsync_formats
+    {
+    elements =
+        {
+        
+        SVC_FORMAT
+            {
+            guid = { 0x221bce32, 0x221b4f45, 0xb48b80de, 0x9a93a44a };
+            name = "FullEnumSyncKnowledge";
+            mimetype1 = "";
+            baseformatcode1 = 0;
+            }
+        
+        };
+    }
+
+//SVC_METHOD.guid must not be duplicate    
+RESOURCE ELEMENTSARRAY r_elements_fullsync_methods
+    {
+    elements =
+        {
+        SVC_METHOD
+            {
+            guid = { 0x63803e07, 0xc71345d3, 0x81193479, 0xb31d3592 };
+            name = "BeginSync";
+            obj_ass_formatcode1 = 0;
+            },
+            
+        SVC_METHOD
+            {
+            guid = { 0x40f3f0f7, 0xa539422e, 0x98ddfd8d, 0x385c8849 };
+            name = "EndSync";
+            obj_ass_formatcode1 = 0;
+            }
+        };
+    }   
+
+//SVC_EVENT.guid must not be duplicate  
+RESOURCE ELEMENTSARRAY r_elements_fullsync_events
+    {
+    elements =
+        {
+//        SVC_EVENT
+//            {
+//            datacode = 0xC303 ;
+//            guid = { 0x00000000, 0x00000000, 0x00000000, 0x00000000 };
+//            name = "ServicePropChanged";
+//            },
+//            
+//        SVC_EVENT
+//            {
+//            datacode = 0xC304;
+//            guid = { 0x00000000, 0x00000000, 0x00000000, 0x00000000 };
+//            name = "MethodComplete";
+//            }
+        };
+    }
+
+//SVC_GUID must not be duplicate  
+RESOURCE ELEMENTSARRAY r_elements_fullsync_datablock
+    {
+    elements =
+        {      
+//        SVC_GUID
+//            {
+//            }
+            
+        };
+    }
+
+//---------------End ----------Full Sync Service--------------------------------------------------------------------------------------------------  
+
+
+
+//---------------Begin ----------Anchor Sync Service--------------------------------------------------------------------------------------------------    
+
+RESOURCE MTP_SERVICE_INFO r_elements_anchorsync
+    {
+    pguid = { 0x102827A1 , 0x00000002 , 0x00000000, 0x00000000 };
+    
+    version = 100;
+    
+    svcguid = { 0x056d8b9e, 0xad7a44fc, 0x946f1d63, 0xa25cda9a } ;
+    
+    
+    servicename = "AnchorSync";
+    servicetype = 1;
+    base_serviceid = 0;
+    
+    use_service_guids = r_elements_anchorsync_usedguids;
+    
+    svc_property_namespaces = r_elements_anchorsync_property_namespaces;
+    svc_properties = r_elements_anchorsync_properties;
+    svc_formats = r_elements_anchorsync_formats;
+    svc_methods = r_elements_anchorsync_methods;
+    svc_events = r_elements_anchorsync_events;
+    svc_datablock = r_elements_anchorsync_datablock;
+    }
+
+//SVC_GUID  must not be duplicate
+RESOURCE ELEMENTSARRAY r_elements_anchorsync_usedguids
+    {
+    elements =
+        {      
+//        SVC_GUID
+//            {            
+//            };
+        };
+    }
+
+//SVC_GUID  must not be duplicate
+RESOURCE ELEMENTSARRAY r_elements_anchorsync_property_namespaces
+    {
+    elements =
+        {      
+        SVC_GUID
+            {
+            guid ={0xe65b8fb7,0x8fc74278,0xb9a3ba14,0xc2db40fa};
+            },
+        SVC_GUID
+            {
+            guid ={0x703d392c,0x532c4607,0x91589cea,0x742f3a16};
+            }    
+        };
+    }
+
+//(SVC_PROPERTY.namespaceid + SVC_PROPERTY.pkid) must not be duplicate  
+RESOURCE ELEMENTSARRAY r_elements_anchorsync_properties
+    {
+    elements =
+        {
+
+        SVC_PROPERTY
+            {
+            namespaceid = 0;
+            pkid  = 2;
+            name = "AnchorVersionProps";
+            datatype = 0x00004002;
+            getset = 0x00;
+            formflag = 0x00;
+            },
+                        
+        SVC_PROPERTY
+            {
+            namespaceid = 0;
+            pkid  = 3;
+            name  = "AnchorReplicaID";
+            datatype = 0x0000000A;
+            getset = 0x01;
+            formflag = 0x00;
+            },
+            
+        SVC_PROPERTY
+            {
+            namespaceid = 0;
+            pkid  = 4;
+            name  = "AnchorKnowledgeObjectID";
+            datatype = 0x00000006;
+            getset = 0x00;
+            formflag = 0x00;
+            }, 
+            
+        SVC_PROPERTY
+            {
+            namespaceid = 0;
+            pkid  = 5;
+            name  = "AnchorLastSyncProxyID";
+            datatype = 0x0000000A;
+            getset = 0x01;
+            formflag = 0x00;
+            },
+            
+        SVC_PROPERTY
+            {
+            namespaceid = 0;
+            pkid  = 6;
+            name  = "AnchorCurrentAnchor";
+            datatype = 0x0000400A;
+            getset = 0x01;
+            formflag = 0x00;
+            },
+        SVC_PROPERTY
+            {
+            namespaceid = 0;
+            pkid  = 7;
+            name  = "AnchorProviderVersion";
+            datatype = 0x00000006;
+            getset = 0x00;
+            formflag = 0x00;
+            },
+            
+        SVC_PROPERTY
+            {
+            namespaceid = 1;
+            pkid  = 2;
+            name  = "SyncFormat";
+            datatype = 0x0000000A;
+            getset = 0x00;
+            formflag = 0x00;
+            },
+            
+        SVC_PROPERTY
+            {
+            namespaceid = 1;
+            pkid  = 3;
+            name  = "LocalOnlyDelete";
+            datatype = 0x00000002;
+            getset = 0x01;
+            formflag = 0x02;
+            }, 
+            
+        SVC_PROPERTY
+            {
+            namespaceid = 1;
+            pkid  = 4;
+            name  = "FilterType";
+            datatype = 0x00000002;
+            getset = 0x01;
+            formflag = 0x00;
+            },
+            
+        SVC_PROPERTY
+            {
+            namespaceid = 1;
+            pkid  = 5;
+            name  = "SyncObjectReferences";
+            datatype = 0x00000002;
+            getset = 0x01;
+            formflag = 0x02;
+            }
+            
+        };
+    }
+
+//SVC_FORMAT.guid must not be duplicate     
+RESOURCE ELEMENTSARRAY r_elements_anchorsync_formats
+    {
+    elements =
+        {
+        SVC_FORMAT
+            {
+            guid = { 0x37c550bc, 0xf2314727, 0xbbbc4cb3, 0x3a3f3ecd };
+            name = "AnchorKnowledge";
+            mimetype1 = "";
+            baseformatcode1 = 0;
+            },
+            
+        SVC_FORMAT
+            {
+            guid = { 0xf35527c1, 0xce4a487a, 0x9d299383, 0x3569321e };
+            name = "AnchorResults";
+            mimetype1 = "";
+            baseformatcode1 = 0;
+            }
+        };
+    }
+    
+//SVC_METHOD.guid must not be duplicate 
+RESOURCE ELEMENTSARRAY r_elements_anchorsync_methods
+    {
+    elements =
+        {
+        SVC_METHOD
+            {
+            guid = { 0x37c550bc, 0xf2314727, 0xbbbc4cb3, 0x3a3f3ecd };
+            name = "GetChangesSinceAnchor";
+            obj_ass_formatcode1 = 0;
+            },
+                
+        SVC_METHOD
+            {
+            guid = { 0x63803e07, 0xc71345d3, 0x81193479, 0xb31d3592 };
+            name = "BeginSync";
+            obj_ass_formatcode1 = 0;
+            },
+            
+        SVC_METHOD
+            {
+            guid = { 0x40f3f0f7, 0xa539422e, 0x98ddfd8d, 0x385c8849 };
+            name = "EndSync";
+            obj_ass_formatcode1 = 0;
+            }
+        };
+    }   
+
+//SVC_EVENT.guid must not be duplicate  
+RESOURCE ELEMENTSARRAY r_elements_anchorsync_events
+    {
+    elements =
+        {
+//        SVC_EVENT
+//            {
+//            datacode = 0xC303 ;
+//            guid = { 0, 0, 0, 0 };
+//            name = "ServicePropChanged";
+//            },
+//            
+//        SVC_EVENT
+//            {
+//            datacode = 0xC304;
+//            guid = { 0, 0, 0, 1 };
+//            name = "MethodComplete";
+//            }
+        };
+    }
+
+//SVC_GUID must not be duplicate  
+RESOURCE ELEMENTSARRAY r_elements_anchorsync_datablock
+    {
+    elements =
+        {      
+//        SVC_GUID
+//            {
+//            }
+            
+        };
+    }
+    
+//---------------End ----------Full Sync Service--------------------------------------------------------------------------------------------------  
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/src/tmtptypeobjecthandle.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,85 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include "tmtptypeobjecthandle.h"
+#include <mtp/tmtptypeuint32.h>
+
+/**
+Constructor.
+@param aId The data provider unique object identifier.
+@param aDp The ID of the data provider responsible for the object.
+*/
+TMTPTypeObjectHandle::TMTPTypeObjectHandle(TUint32 aId, TUint8 aDp) : 
+    TMTPTypeUint32(aId)
+    {
+    __ASSERT_DEBUG((aId <= KObjectIdMax), User::Invariant());
+    SetDPHandle(aDp);
+    }
+    
+/**
+Destructor.
+*/
+TMTPTypeObjectHandle::~TMTPTypeObjectHandle()
+    {
+    }
+
+/**
+Constructor.
+@param aId The data provider unique object identifier.
+@param aDp The ID of the data provider responsible for the object.
+*/
+TMTPTypeObjectHandle::TMTPTypeObjectHandle(TMTPTypeUint32 aId, TUint8 aDp) : TMTPTypeUint32(aId)
+    {
+    __ASSERT_DEBUG((aId.Value() <= KObjectIdMax), User::Invariant());
+    SetDPHandle(aDp);
+    }
+
+/**
+Constructor.
+@param aHandle A valid encoded 32-bit MTP object handle.
+*/
+TMTPTypeObjectHandle::TMTPTypeObjectHandle(TMTPTypeUint32 aHandle) : 
+    TMTPTypeUint32(aHandle)
+    {   
+    }
+    
+/**
+Provides the ID of the data provider responsible for the object.
+@return The ID of the data provider responsible for the object.
+*/
+TUint8 TMTPTypeObjectHandle::DpId() const
+    {
+    return (Value() & KDpMask) >> KObjectIdWidth;
+    }
+
+/**
+Provides the DP's unique object ID for the object.
+@return The object's unique DP ID.
+*/
+TUint32 TMTPTypeObjectHandle::DPObjectId() const
+    {
+    return Value() & ~KDpMask;
+    }
+
+/**
+Encodes the given data provider ID into the top eight bits of this data type
+
+@param aDp The ID of the data provider responsible for the object.
+*/
+void TMTPTypeObjectHandle::SetDPHandle(TUint8 aDp)
+    {
+    Set(Value() | (aDp << KObjectIdWidth));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/transports/transportapi/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,29 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// bld.inf for mtptransportapi
+// Media Transfer Protocol Framework Generic Transport API
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES 
+mtptransportapi.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/transports/transportapi/group/mtptransportapi.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,34 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+TARGET              mtptransportapi.dll
+TARGETTYPE          DLL
+UID                 0x1000008D 0x102827A8
+VENDORID 			0x70000001
+
+CAPABILITY          All -Tcb
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+USERINCLUDE         ../inc/ 
+
+SOURCEPATH          ../src/ 
+SOURCE              cmtptransportplugin.cpp
+
+LIBRARY             euser.lib
+LIBRARY             ecom.lib
+
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/transports/transportapi/inc/cmtptransportplugin.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,124 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPTRANSPORTPLUGIN_H
+#define CMTPTRANSPORTPLUGIN_H
+
+#include <e32base.h>
+#include <mtp/mtpdataproviderapitypes.h>
+
+class MMTPConnectionMgr;
+
+/** 
+CMTPDataProviderPlugin interface UID.
+*/
+const TUid KMTPTransportPluginInterfaceUid = {0x102827AE};
+
+/** 
+Defines the MTP transport layer plug-in interface.
+@internalComponent 
+*/
+class CMTPTransportPlugin : public CBase
+    {
+public:
+
+    /**
+    MTP transport layer plug-in factory method.
+    @param aImplementationUid A UID specifying the required interface 
+    implementation.
+    @return Pointer to the plug-in instance. Ownership IS transfered.
+    @leave KErrNoMemory If the plug-in instance could not be allocated.
+    @leave KErrArgument If an invalid aImplementationUid was specified.
+    */
+    IMPORT_C static CMTPTransportPlugin* NewL(TUid aImplementationUid);
+    
+    /**
+    MTP transport layer plug-in factory method.
+    @param aImplementationUid A UID specifying the required interface 
+    implementation.
+    @param aParameter is the Parameter needed by MTPBT transport plugin. Since MTPBT support to initiate connection, it require listensee application to provide address and psm for remote host.
+    @return Pointer to the plug-in instance. Ownership IS transfered.
+    @leave KErrNoMemory If the plug-in instance could not be allocated.
+    @leave KErrArgument If an invalid aImplementationUid was specified.
+    */
+	IMPORT_C static CMTPTransportPlugin* NewL(TUid aImplementationUid,const TAny * aParameter);
+    
+    /**
+    Destructor.
+    */
+    IMPORT_C virtual ~CMTPTransportPlugin();
+
+public: // MTP Transport plug-in API methods. Not Exported.
+
+    /**
+    Notifies the transport layer plug-in of a change in the operational mode
+    of the MTP protocol layer.
+    @param aMode The new operational mode of the MTP protocol layer.
+    */
+    virtual void ModeChanged(TMTPOperationalMode aMode) = 0;
+
+    /**
+    Initiates the startup of the MTP transport layer. The transport layer should
+    use the supplied MTP connection manager interface to signal the 
+    availability and unavailability of transport layer connections.
+    @param aConnectionMgr The MTP connection manager interface.
+    @see MMTPConnectionMgr::ConnectionClosedL
+    @see MMTPConnectionMgr::ConnectionOpenedL
+    @leave One of the system wide error codes.
+    */
+    virtual void StartL(MMTPConnectionMgr& aConnectionMgr) = 0;
+   
+    /**
+    Initiates the shutdown of the MTP transport layer. The transport layer should
+    use the supplied connection manager interface to signal the availability
+    and unavailability of transport layer connections.
+    @param aConnectionMgr The connection manager interface.
+    @see MMTPConnectionMgr::ConnectionClosedL.
+    @see MMTPConnectionMgr::ConnectionOpenedL.
+    */
+    virtual void Stop(MMTPConnectionMgr& aConnectionMgr) = 0;
+    
+    /**
+    Provides an MTP transport plug-in extension interface implementation 
+    for the specified interface Uid. 
+    @param aInterfaceUid Unique identifier for the extension interface being 
+    requested.
+    @return Pointer to an interface instance or 0 if the interface is not 
+    supported. Ownership is NOT transfered.
+    */
+    virtual TAny* GetExtendedInterface(TUid aInterfaceUid) = 0;
+
+protected:
+
+    /**
+    Constructor.
+    */
+    IMPORT_C CMTPTransportPlugin();
+    
+
+
+private: // Owned
+
+    /**
+    MTP transport layer ECOM plug-in identifier.
+    */
+    TUid iDtorIdKey;
+    };
+#endif // CMTPTRANSPORTPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/transports/transportapi/inc/mmtpconnectionmgr.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,59 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef MMTPCONNECTIONMGR_H
+#define MMTPCONNECTIONMGR_H
+
+#include <e32cmn.h>
+
+class MMTPTransportConnection;
+
+/** 
+Defines the MTP connection manager interface
+@internalTechnology
+  
+*/
+
+class MMTPConnectionMgr
+    {
+public:
+
+    /**
+    Signals that an MTP transport layer connection has become unavailable.
+    @param aTransportConnection Interface handle of the MTP transport layer 
+    connection instance.
+    */
+    virtual void ConnectionClosed(MMTPTransportConnection& aTransportConnection) = 0;
+    
+    /**
+    Signals that an MTP transport layer connection has become available.
+    @param aTransportConnection Interface handle of the MTP transport layer 
+    connection instance.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void ConnectionOpenedL(MMTPTransportConnection& aTransportConnection) = 0;
+    
+    /**
+    Returns the Secure Id of the process that sent the request
+    */
+    virtual TUid ClientSId()=0;
+            
+    };
+#endif // MMTPCONNECTIONMGR_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/transports/transportapi/inc/mmtpconnectionprotocol.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,134 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef MMTPCONNECTIONPROTOCOL_H
+#define MMTPCONNECTIONPROTOCOL_H
+
+#include <e32cmn.h>
+#include <e32def.h>
+#include <mtp/mtpdataproviderapitypes.h>
+
+class MMTPType;
+class TMTPTypeEvent;
+class TMTPTypeRequest;
+class TMTPTypeResponse;
+class MMTPTransportConnection;
+
+/** 
+Defines the MTP connection protocol layer interface.
+
+@internalTechnology
+  
+*/
+class MMTPConnectionProtocol
+    {
+public:
+
+    /**
+    Provides the unique MTP protocol layer assigned identifier of the
+    connection.
+    @return The MTP protocol layer assigned connection identifier.
+    */
+    virtual TUint ConnectionId() const = 0;
+
+    /**
+    Signals the availability of an MTP event data object received from the MTP
+    transport layer connection.
+    @param aEvent The received MTP event data object.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void ReceivedEventL(const TMTPTypeEvent& aEvent) = 0;
+
+    /**
+    Signals the availability of an MTP request data object received from the MTP
+    transport layer connection.
+    @param aRequest The received MTP request data object.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void ReceivedRequestL(const TMTPTypeRequest& aRequest) = 0;
+
+    /**
+    Signals the completion of an MTP data object receive sequence in the MTP
+    transport layer connection, that was previously initiated by a ReceiveData
+    signal to the transport layer connection interface.
+    @param aErr A system wide error code indicating the completion status of 
+    the sequence.
+    @param aData The MTP data object sink.
+    @param aRequest The MTP request dataset of the active MTP transaction.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    @see MMTPCMMTPTransportConnection::ReceiveData
+    @see MMTPCMMTPTransportConnection::ReceiveDataCancel
+    */
+    virtual void ReceiveDataCompleteL(TInt aErr, const MMTPType& aData, const TMTPTypeRequest& aRequest) = 0;
+
+    /**
+    Signals the completion of an MTP data object send sequence in the MTP
+    transport layer connection, that was previously initiated by a SendData
+    signal to the transport layer connection interface.
+    @param aErr A system wide error code indicating the completion status of 
+    the sequence.
+    @param aData The MTP data object source.
+    @param aRequest The MTP request dataset of the active MTP transaction.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    @see MMTPCMMTPTransportConnection::SendData
+    @see MMTPCMMTPTransportConnection::SendDataCancel
+    */
+    virtual void SendDataCompleteL(TInt aErr, const MMTPType& aData, const TMTPTypeRequest& aRequest) = 0;
+
+    /**
+    Signals the completion of an MTP event data object send sequence in the MTP
+    transport layer connection, that was previously initiated by a SendEvent
+    signal to the transport layer connection interface.
+    @param aErr A system wide error code indicating the completion status of 
+    the sequence.
+    @param aData The MTP event data object source.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    @see MMTPCMMTPTransportConnection::SendEvent
+    */
+    virtual void SendEventCompleteL(TInt aErr, const TMTPTypeEvent& aData) = 0;
+
+    /**
+    Signals the completion of an MTP response data object send sequence in the 
+    MTP transport layer connection, that was previously initiated by a 
+    SendResponse signal to the transport layer connection interface.
+    @param aErr A system wide error code indicating the completion status of 
+    the sequence.
+    @param aResponse The MTP response data object source.
+    @param aRequest The MTP request dataset of the active MTP transaction.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    @see MMTPCMMTPTransportConnection::SendResponse
+    */
+    virtual void SendResponseCompleteL(TInt aErr, const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest) = 0;
+
+    /**
+    Provides the current MTP transaction state for the specified session.
+    @param aMtpSessionId The MTP connection assigned identifier of the 
+    requested session.
+    @leave KErrArgument, if the specified session identifier is not currently
+    active on the connection.
+    @return The MTP transaction state for the specified session.
+    */
+    virtual TMTPTransactionPhase TransactionPhaseL(TUint32 aMtpSessionId) const = 0;  
+      
+    virtual void Unbind(MMTPTransportConnection& aConnection) = 0;
+
+    virtual void DisconnectionNotifyL()=0;
+    };
+#endif // MMTPCONNECTIONPROTOCOL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/transports/transportapi/inc/mmtptransportconnection.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,168 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef MMTPTRANSPORTCONNECTION_H
+#define MMTPTRANSPORTCONNECTION_H
+
+#include <e32cmn.h>
+
+class MMTPConnectionProtocol;
+class MMTPType;
+class TMTPTypeEvent;
+class TMTPTypeRequest;
+class TMTPTypeResponse;
+
+/** 
+Defines the MTP connection transport layer interface.
+@internalTechnology
+  
+*/
+class MMTPTransportConnection
+    {
+public:
+
+    /**
+    Binds the MTP protocol layer notification interface to the connection transport 
+    layer.
+    @param aProtocol The MTP protocol layer notification interface.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void BindL(MMTPConnectionProtocol& aProtocol) = 0;
+
+    /**
+    Provides the MTP protocol layer notification interface which is bound to
+    the connection transport layer.
+    @return The MTP protocol layer notification interface binding.
+    */
+    virtual MMTPConnectionProtocol& BoundProtocolLayer() = 0;
+    
+    /**
+    Initiates a connection shutdown sequence, usually as a result of an 
+    unrecoverable MTP protocol error. This sequence is completed when the 
+    connection transport layer signals ConnectionClosed to the MTP connection 
+    manager interface.
+    @see MMTPConnectionMgr::ConnectionClosed.
+    */
+    virtual void CloseConnection() = 0;
+
+    /**
+    Initiates an MTP data object receive sequence in the connection transport 
+    layer. This sequence is completed when the transport layer connection signals
+    ReceiveDataComplete to the MTP protocol layer notification interface.
+    @param aData The MTP data object sink.
+    @param aRequest The MTP request dataset of the active MTP transaction.
+    @see MMTPConnectionProtocol::ReceiveDataComplete
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest) = 0;
+
+    /**
+    Aborts an MTP data object receive sequence in-progress in the connection 
+    transport layer. This sequence is completed when the connection transport 
+    layer signals ReceiveDataComplete to the MTP connection protocol layer 
+    interface.
+    @param aRequest The MTP request dataset of the active MTP transaction.
+    @see ReceiveData
+    @see MMTPConnectionProtocol::ReceiveDataComplete
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void ReceiveDataCancelL(const TMTPTypeRequest& aRequest) = 0;
+    
+    /**
+    Initiates an MTP data object send sequence in the connection transport 
+    layer. This sequence is completed when the transport layer connection 
+    signals SendDataComplete to the MTP protocol layer notification interface.
+    @param aData The MTP data object source.
+    @param aRequest The MTP request dataset of the active MTP transaction.
+    @see MMTPConnectionProtocol::SendDataComplete
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void SendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest) = 0;
+
+    /**
+    Aborts an MTP data object send sequence in-progress in the connection 
+    transport layer. This sequence is completed when the connection transport 
+    layer signals SendDataComplete to the MTP connection protocol layer 
+    interface.
+    @param aRequest The MTP request dataset of the active MTP transaction.
+    @see SendData
+    @see MMTPConnectionProtocol::SendDataComplete
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void SendDataCancelL(const TMTPTypeRequest& aRequest) = 0;
+    
+    /**
+    Initiates an MTP event dataset send sequence in the connection 
+    transport layer. This sequence is completed when the connection transport 
+    layer signals SendEventComplete to the MTP connection protocol layer 
+    interface.
+    @param aEvent The MTP event data object source.
+    @see MMTPConnectionProtocol::SendEventComplete
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void SendEventL(const TMTPTypeEvent& aEvent) = 0;
+    
+    /**
+    Initiates an MTP response dataset send sequence in the connection 
+    transport layer. This sequence is completed when the connection transport 
+    layer signals SendResponseComplete to the MTP connection protocol layer 
+    interface.
+    @param aResponse The MTP response data object source.
+    @param aRequest The MTP request dataset of the active MTP transaction.
+    @see MMTPConnectionProtocol::SendResponseComplete
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void SendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest) = 0;
+    
+    /**
+    Signals the completion of the active MTP operation request transaction 
+    sequence initiated by a preceding ReceivedRequest signal made to the
+    MTP protocol layer notification interface.
+    @param aResponse The completed MTP request data object.
+    @param aRequest The MTP request dataset of the active MTP transaction.
+    @leave One of the system wide error codes, if a processing failure occurs.
+    */
+    virtual void TransactionCompleteL(const TMTPTypeRequest& aRequest) = 0;
+
+    /**
+    Unbinds the MTP protocol layer notification interface from the connection transport 
+    layer.
+    @param aProtocol The MTP protocol layer notification interface.
+    */
+    virtual void Unbind(MMTPConnectionProtocol& aProtocol) = 0;
+    
+    /**
+    Provides an MTP connection transport layer extension interface implementation 
+    for the specified interface Uid. 
+    @param aInterfaceUid Unique identifier for the extension interface being 
+    requested.
+    @return Pointer to an interface instance or 0 if the interface is not 
+    supported. Ownership is NOT transfered.
+    */
+    virtual TAny* GetExtendedInterface(TUid aInterfaceUid) = 0;
+    
+    /*
+     * Provide a method to get implementation UID of concrete transport connection bearer
+     * @return Implementation UID of concrete transport connection bearer.
+     */
+    virtual TUint GetImplementationUid() = 0;
+};
+    
+#endif // MMTPTRANSPORTCONNECTION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpfws/mtpfw/transports/transportapi/src/cmtptransportplugin.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,45 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <ecom/ecom.h>
+
+#include "cmtptransportplugin.h"
+
+EXPORT_C CMTPTransportPlugin* CMTPTransportPlugin::NewL(TUid aImplementationUid)
+    {
+    return NewL( aImplementationUid, NULL );
+    }
+
+EXPORT_C CMTPTransportPlugin* CMTPTransportPlugin::NewL(TUid aImplementationUid, const TAny* aParameter)
+    {
+    TAny* parameter = const_cast<TAny*>(aParameter);
+    CMTPTransportPlugin* self = reinterpret_cast<CMTPTransportPlugin*>(
+        REComSession::CreateImplementationL(
+            aImplementationUid,
+            _FOFF(CMTPTransportPlugin, iDtorIdKey),parameter));
+    return self;
+    }
+
+EXPORT_C CMTPTransportPlugin::~CMTPTransportPlugin()
+    {
+    REComSession::DestroyedImplementation(iDtorIdKey);
+    }
+
+EXPORT_C CMTPTransportPlugin::CMTPTransportPlugin()
+    {
+
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,31 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// MTP service controller implementation
+//
+
+
+
+/**
+ @file
+*/
+
+PRJ_PLATFORMS
+ARMV5
+WINSCW
+
+PRJ_EXPORTS
+mtp_controller.iby          /epoc32/rom/include/mtp_controller.iby
+
+PRJ_MMPFILES
+mtpcontroller.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/group/mtp_controller.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -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 MTP_CONTROLLER_IBY
+#define MTP_CONTROLLER_IBY
+
+#if !defined (SYMBIAN_EXCLUDE_MTP)
+
+#include <mtp_framework.iby>
+
+//MTP Controller LOCOD service plugin
+ECOM_PLUGIN(mtpcontroller.dll, mtpcontroller.rsc)
+
+#endif// SYMBIAN_EXCLUDE_MTP
+
+#endif// MTP_CONTROLLER_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/group/mtpcontroller.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,56 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mtpcontroller.dll MTP controller to turn on/off MTP Daemon
+// automatically MTP bearer is available or not available
+//
+
+
+
+/**
+ @file
+*/
+#include <platform_paths.hrh>
+#include <comms-infras/commsdebugutility.mmh>
+
+TARGETTYPE      PLUGIN
+TARGET          mtpcontroller.dll
+UID             0x10009D8D 0x20028787
+VENDORID        0x70000001
+
+CAPABILITY      ALL -TCB
+
+SYSTEMINCLUDE   /epoc32/include/ecom
+SYSTEMINCLUDE   ../locodinc
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../mtpfws/mtpfw/common/inc
+
+SOURCEPATH      ../src
+SOURCE          cmtpbearermonitor.cpp
+SOURCE          cmtpcontrollerbase.cpp
+SOURCE          cmtpbluetoothcontroller.cpp
+SOURCE          cmtpoperator.cpp
+SOURCE          proxy.cpp
+
+LIBRARY         euser.lib
+LIBRARY         ecom.lib
+LIBRARY         mtpclient.lib
+
+START RESOURCE  mtpcontroller.rss
+TARGET          mtpcontroller.rsc
+END
+
+SMPSAFE
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/group/mtpcontroller.mrp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,26 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component       mtpcontroller
+source          \sf\mw\remoteconn\mtptransports\mtpcontroller
+
+binary          \sf\mw\remoteconn\mtptransports\mtpcontroller\group all
+exports         \sf\mw\remoteconn\mtptransports\mtpcontroller\group
+
+notes_source    \component_defs\release.src
+
+ipr E 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/inc/cmtpbearermonitor.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,57 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPBEARERMONITOR_H
+#define CMTPBEARERMONITOR_H
+
+#include "locodserviceplugin.h"
+#include "mtpdebug.h"
+
+class CMTPControllerBase;
+
+NONSHARABLE_CLASS( CMTPBearerMonitor ) : public CLocodServicePlugin
+    {
+public:
+    static CMTPBearerMonitor* NewL( TLocodServicePluginParams& aParams );
+    
+    ~CMTPBearerMonitor();
+    
+public:
+    void ManageServiceCompleted( TLocodBearer aBearer, TBool aStatus, TInt aError );
+    
+private: // From CLocodServicePlugin
+    void ManageService( TLocodBearer aBearer, TBool aStatus );
+    
+private:
+    CMTPBearerMonitor( TLocodServicePluginParams& aParams );
+    void ConstructL();
+    
+private:
+    /**
+     * FLOGGER debug trace member variable.
+     */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    RPointerArray< CMTPControllerBase > iMTPControllers;
+    };
+
+#endif// CMTPBEARERMONITOR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/inc/cmtpbluetoothcontroller.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,56 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPBLUETOOTHCONTROLLER_H_
+#define CMTPBLUETOOTHCONTROLLER_H_
+
+#include "cmtpcontrollerbase.h"
+#include "cmtpoperator.h"
+#include "mtpdebug.h"
+
+NONSHARABLE_CLASS( CMTPBluetoothController ) : public CMTPControllerBase, public MMTPOperatorNotifier
+    {
+public:
+    static CMTPBluetoothController* NewL( CMTPBearerMonitor& aMon );
+    ~CMTPBluetoothController();
+    
+private:// From CMTPControllerBase
+    void ManageService( TBool aStatus );
+    
+private:// From MMTPOperatorNotifier
+    void HandleStartTrasnportCompleteL( TInt aError );
+    void HandleStopTrasnportCompleteL( TInt aError );
+    
+private:
+    CMTPBluetoothController( CMTPBearerMonitor& aMon );
+    
+private:
+    /**
+     * FLOGGER debug trace member variable.
+     */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    TBool iStat;
+    CMTPOperator* iMTPOperator;
+    };
+
+#endif /* CMTPBLUETOOTHCONTROLLER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/inc/cmtpcontrollerbase.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,47 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPCONTROLLERBASE_H_
+#define CMTPCONTROLLERBASE_H_
+
+#include <e32base.h>
+#include <locodbearer.h>
+#include "cmtpbearermonitor.h"
+
+NONSHARABLE_CLASS( CMTPControllerBase ) : public CBase
+    {
+public:
+    TLocodBearer Bearer() const;
+    
+    virtual void ManageService( TBool aStatus ) = 0;
+    
+protected:
+    CMTPControllerBase( CMTPBearerMonitor& aMon, TLocodBearer aBearer );
+    
+    CMTPBearerMonitor& Monitor() const;
+    
+private:
+    CMTPBearerMonitor &iMon;
+    TLocodBearer iBearer;
+    };
+
+#endif /* CMTPCONTROLLERBASE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/inc/cmtpoperator.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,78 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPOPERATOR_H_
+#define CMTPOPERATOR_H_
+
+#include <e32base.h>
+#include <mtp/rmtpclient.h>
+#include "mmtpoperatornotifier.h"
+#include "mtpdebug.h"
+
+NONSHARABLE_CLASS( CMTPOperator ) : public CActive
+    {
+private:
+    enum TOperationType
+        {
+        EStartTransport,
+        EStopTransport
+        };
+    
+    struct TOperation
+        {
+        TInt iType;
+        TUid iTransport;
+        };
+    
+public:
+    static CMTPOperator* NewL( MMTPOperatorNotifier& aNotifier );
+    
+    ~CMTPOperator();
+    
+public:
+    void StartTransport( TUid aTransport );
+    void StopTransport( TUid aTransport );
+    
+private:// From CActive
+    void DoCancel();
+    void RunL();
+    
+private:
+    CMTPOperator( MMTPOperatorNotifier& aNotifier );
+    void ConstructL();
+    TInt AppendOperation( TOperationType aType, TUid aTransport );
+    void Schedule( TInt aError );
+    void HandleOperationL( const TOperation& aOperation );
+private:
+    /**
+     * FLOGGER debug trace member variable.
+     */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+    MMTPOperatorNotifier& iNotifier;
+    
+    RArray< TOperation > iPendingOperations;
+    
+    RMTPClient iMTPClient;
+    };
+
+#endif /* CMTPOPERATOR_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/inc/mmtpoperatornotifier.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,33 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef MMTPOPERATORNOTIFIER_H_
+#define MMTPOPERATORNOTIFIER_H_
+
+NONSHARABLE_CLASS( MMTPOperatorNotifier )
+    {
+public:
+    virtual void HandleStartTrasnportCompleteL( TInt aError ) = 0;
+    virtual void HandleStopTrasnportCompleteL( TInt aError ) = 0;
+    };
+
+#endif /* MMTPOPERATORNOTIFIER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/locodinc/locodbearer.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Defines the LCD Bearer Plugin identifier.
+*
+*/
+
+
+#ifndef T_LOCODBEARER_H
+#define T_LOCODBEARER_H
+
+#include <e32base.h>
+
+/**  bearer value in LC */
+enum TLocodBearer
+    {
+    ELocodBearerBT =  0x0001,
+	ELocodBearerIR =  0x0010,
+	ELocodBearerUSB = 0x0100,
+    };
+
+#endif // T_LOCODBEARER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/locodinc/locodplugin.hrh	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definitions for plugin resource registration.
+*
+*/
+
+
+#ifndef LOCODPLUGIN_HRH
+#define LOCODPLUGIN_HRH
+
+/**
+ * This file contains the defintions for plugin resource registration.
+ *
+ * All plugins should use version 2 registration resource file and set the
+ * rom_only field to 1 to prevent it from being overridden by RAM-based plugins.
+ *
+ * All bearer plugins should use KLOCODBEARERINTERFACEUID as the interface UID.
+ *
+ * A bearer plugin should use its corresponding feature ID (from features.hrh) as the
+ * implementation UID,  that is, 
+ *  Implementation UID of IR bearer is KFeatureIdIrda,
+ *  Implementation UID of BT bearer is KFeatureIdBt,
+ *  Implementation UID of USB bearer is KFeatureIdUsb.
+ *
+ * All service plugins should use KLOCODSERVICEINTERFACEUID as the interface UID.
+ *
+ * A service plugin should use its corresponding feature ID (from features.hrh) as the
+ * implementation UID,  that is, 
+ *  Implementation UID of Dun is KFeatureIdDun, (not exist yet, CR created)
+ *  Implementation UID of Obex is KFeatureIdSrcs,
+ * 
+ */
+
+// Interface UID of bearer plugins
+#define  KLOCODBEARERINTERFACEUID 0x20002771
+
+// Interface UID of service plugins
+#define  KLOCODSERVICEINTERFACEUID 0x20002772
+
+#endif // LOCODPLUGIN_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/locodinc/locodserviceplugin.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,98 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Service Plugin base class declaration.
+*
+*/
+
+
+#ifndef C_LOCODSERVICEPLUGIN_H
+#define C_LOCODSERVICEPLUGIN_H
+
+#include <e32base.h>
+
+#include "locodservicepluginparams.h"
+#include "locodbearer.h"
+    
+/**
+ *  Service Plugin base class
+ *
+ *  This is the base class from which service plugins inherit.
+ *
+ * When a service plugin is constructed, it should not start any service by default.
+ * A service is started on demand when the bearer is available.
+ *
+ *  @euser.lib
+ *  @since S60 v3.2
+ */
+class CLocodServicePlugin : public CBase
+    {
+public:
+
+    static CLocodServicePlugin* NewL(TLocodServicePluginParams& aParams);
+
+    virtual ~CLocodServicePlugin();
+
+    /**
+     * Tell service plugin which service should be enabled or disabled according to
+     * specified bearer and its status.
+     * 
+     * On completion, the plugin should call 
+     * MLocodServicePluginObserver::ManageServiceCompleted() to inform the result.
+     *
+     * @since S60 v3.2
+     * @param  aBearer the bearer identification 
+     * @param  aStatus the status of this bearer, ETrue if it is available;
+     *                 EFalse otherwise.
+     */
+    virtual void ManageService(TLocodBearer aBearer, TBool aStatus) = 0;
+
+    TUid ImplementationUid() const;
+    
+protected:
+
+    CLocodServicePlugin(TLocodServicePluginParams& aParams);
+
+    /**
+     * Gets the observer interface object associated with this plugin
+     *
+     * @since S60 v3.2
+     * @return The observer object
+     */
+    MLocodServicePluginObserver& Observer() const;
+
+private: // data
+
+    /**
+     * UID set by ECOM when the instance is created.  Used when the instance
+     * is destroyed.
+     */
+    TUid iInstanceUid;
+
+    /**
+     * Implementation UID of the concrete instance.
+     */
+    const TUid iImplementationUid;
+
+    /**
+     * Holds the observer object which will be notified when the operations
+     * complete
+     * Not own.
+     */
+    MLocodServicePluginObserver& iObserver;
+
+    };
+
+#include <locodserviceplugin.inl>
+
+#endif // C_LOCODSERVICEPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/locodinc/locodserviceplugin.inl	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Service Plugin construction parameters
+*                declaration
+*
+*/
+
+
+#include <ecom.h>
+
+// -----------------------------------------------------------------------------
+// Constructor method, just saves the arguments into member variables
+// -----------------------------------------------------------------------------
+//
+inline CLocodServicePlugin* CLocodServicePlugin::NewL(TLocodServicePluginParams& aParams)
+    {
+	CLocodServicePlugin* self = reinterpret_cast<CLocodServicePlugin*>(
+		REComSession::CreateImplementationL(
+			aParams.ImplementationUid(),
+			_FOFF(CLocodServicePlugin, iInstanceUid),
+			(TAny*)&aParams)
+		);
+
+	return self;
+    }
+    
+
+// -----------------------------------------------------------------------------
+// Service plug ins destructor
+// -----------------------------------------------------------------------------
+//
+inline CLocodServicePlugin::~CLocodServicePlugin()
+    {
+    REComSession::DestroyedImplementation(iInstanceUid);
+    }
+    
+// -----------------------------------------------------------------------------
+// returns the implementation UID
+// -----------------------------------------------------------------------------
+//
+inline TUid CLocodServicePlugin::ImplementationUid() const
+    {
+    return iImplementationUid;
+    }
+
+// -----------------------------------------------------------------------------
+// CLocodServicePlugin C++ constructor
+// -----------------------------------------------------------------------------
+//
+inline CLocodServicePlugin::CLocodServicePlugin(TLocodServicePluginParams& aParams)
+    : iImplementationUid(aParams.ImplementationUid()),
+      iObserver(aParams.Observer())
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// return the observer class
+// -----------------------------------------------------------------------------
+//
+inline MLocodServicePluginObserver& CLocodServicePlugin::Observer() const
+    {
+    return iObserver;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/locodinc/locodservicepluginobserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Service Plugin observer interface definition.
+*
+*/
+
+
+#ifndef M_LOCODSERVICEPLUGINOBSERVER_H
+#define M_LOCODSERVICEPLUGINOBSERVER_H
+
+#include "locodbearer.h"
+
+/**
+ *  LCD Service Plugin Observer interface class
+ *
+ *  This is the service plugin observer interface definition used by LCD
+ *  Service Plugins to inform the daemon when an action is complete.
+ *
+ *  @lib 
+ *  @since S60 v3.2
+ */
+class MLocodServicePluginObserver
+    {
+public:
+
+    /**
+     * This is a callback function used by the plugins to inform when
+     * managing the service have completed.  The parameters passed should be
+     * identical to the ones used when the plugin's ManageService() was called,
+     * plus this service plugin's implemnetation UID and the completion status.
+     *
+     * @since S60 v3.2
+     * @param  aBearer the bearer identification passed in ManageService()
+     * @param  aStatus the status of this bearer passed in ManageService()
+     * @param  aServiceImplUid, the implementation UID of this service plugin.
+     * @param  err     KErrNone if the operation succeeded; otherwise a Symbian
+     *                 error code.
+     */
+    virtual void ManageServiceCompleted(
+        TLocodBearer aBearer,
+        TBool aStatus,
+        TUid aServiceImplUid,
+        TInt err) = 0;
+    };
+
+#endif // M_LOCODSERVICEPLUGINOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/locodinc/locodservicepluginparams.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Service Plugin construction parameters
+*                declaration
+*
+*/
+
+
+#ifndef T_LOCODSERVICEPLUGINPARAMS_H
+#define T_LOCODSERVICEPLUGINPARAMS_H
+
+class MLocodServicePluginObserver;
+
+/**
+ *  LCD Service Plugin Callback construction parameters
+ *
+ *  This interface class is used to pass construction parameters to the
+ *  plugins.  These parameters include the callback interface (usually
+ *  implemented by the LCD) and the ECOM plugin implementation UID 
+ *
+ *  @lib ?library
+ *  @since S60 v3.2
+ */
+class TLocodServicePluginParams
+    {
+public:
+    /**
+     * Constructor.
+     *
+     * @since S60 v3.2
+     * @param  aUid      Implementation UID of the plugin being constructed
+     * @param  aObserver Callback interface object
+     */
+    TLocodServicePluginParams(TUid aUid, MLocodServicePluginObserver& aObserver);
+
+    /**
+     * Gets the implementation UID of the plugin
+     *
+     * @since S60 v3.2
+     * @return Implementaion UID
+     */
+    TUid ImplementationUid() const;
+
+    /**
+     * Gets the observer interface object
+     *
+     * @since S60 v3.2
+     * @return The observer object
+     */
+    MLocodServicePluginObserver& Observer() const;    
+
+private: // data
+
+    /**
+     * The implementation UID
+     */
+    const TUid iImplementationUid;
+
+    /**
+     * Reference to the observer object
+     */
+    MLocodServicePluginObserver& iObserver;
+
+    };
+
+#include "locodservicepluginparams.inl"
+
+#endif // T_LOCODSERVICEPLUGINPARAMS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/locodinc/locodservicepluginparams.inl	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Service Plugin construction parameters
+*                declaration
+*
+*/
+
+
+// -----------------------------------------------------------------------------
+// Constructor method, just saves the arguments into member variables
+// -----------------------------------------------------------------------------
+//
+inline TLocodServicePluginParams::TLocodServicePluginParams(TUid aUid, MLocodServicePluginObserver& aObserver)
+    : iImplementationUid(aUid),
+      iObserver(aObserver)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Returns the implementation UID
+// -----------------------------------------------------------------------------
+//
+inline TUid TLocodServicePluginParams::ImplementationUid() const
+    {
+    return iImplementationUid;
+    }
+
+// -----------------------------------------------------------------------------
+// return the observer class
+// -----------------------------------------------------------------------------
+//
+inline MLocodServicePluginObserver& TLocodServicePluginParams::Observer() const
+    {
+    return iObserver;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/src/cmtpbearermonitor.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,87 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "cmtpbearermonitor.h"
+#include <locodservicepluginobserver.h>
+
+#include "cmtpbluetoothcontroller.h"
+
+__FLOG_STMT( _LIT8( KComponent, "mtpbearermonitor" ); )
+
+CMTPBearerMonitor* CMTPBearerMonitor::NewL( TLocodServicePluginParams& aParams )
+    {
+    CMTPBearerMonitor* self = new( ELeave ) CMTPBearerMonitor( aParams );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CMTPBearerMonitor::~CMTPBearerMonitor()
+    {
+    iMTPControllers.ResetAndDestroy();
+    iMTPControllers.Close();
+    __FLOG( _L8("+/-Dtor") );
+    __FLOG_CLOSE;
+    }
+
+void CMTPBearerMonitor::ManageServiceCompleted( TLocodBearer aBearer, TBool aStatus, TInt aError )
+    {
+    Observer().ManageServiceCompleted( aBearer, aStatus, ImplementationUid(), aError );
+    }
+
+void CMTPBearerMonitor::ManageService( TLocodBearer aBearer, TBool aStatus )
+    {
+    __FLOG_2( _L8("+/-ManageService( 0x%08X, %d )"), aBearer, aStatus );
+    TInt count = iMTPControllers.Count();
+    TBool foundController = EFalse;
+    for ( TInt i = 0; i < count; ++i )
+        {
+        if ( aBearer == iMTPControllers[i]->Bearer() )
+            {
+            iMTPControllers[i]->ManageService( aStatus );
+            foundController = ETrue;
+            }
+        }
+    if ( !foundController )
+        {
+        ManageServiceCompleted( aBearer, aStatus, KErrNone );
+        }
+    }
+
+CMTPBearerMonitor::CMTPBearerMonitor( TLocodServicePluginParams& aParams ):
+    CLocodServicePlugin( aParams )
+    {
+    __FLOG_OPEN( KMTPSubsystem, KComponent );
+    __FLOG( _L8("+/-Ctor") );
+    }
+
+void CMTPBearerMonitor::ConstructL()
+    {
+    __FLOG( _L8("+ConstructL") );
+    
+    CMTPBluetoothController* btController = CMTPBluetoothController::NewL( *this );
+    iMTPControllers.AppendL( btController );
+    
+    __FLOG( _L8("-ConstructL") );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/src/cmtpbluetoothcontroller.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,95 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "cmtpbluetoothcontroller.h"
+
+__FLOG_STMT( _LIT8( KComponent, "mtpbtcontroller" ); )
+LOCAL_D const TUid KMTPBtTransportUid = { 0x10286FCB };
+
+CMTPBluetoothController* CMTPBluetoothController::NewL( CMTPBearerMonitor& aMon )
+    {
+    CMTPBluetoothController* self = new( ELeave ) CMTPBluetoothController( aMon );
+    return self;
+    }
+
+CMTPBluetoothController::~CMTPBluetoothController()
+    {
+    delete iMTPOperator;
+    __FLOG( _L8("+/-Dtor") );
+    __FLOG_CLOSE;
+    }
+
+void CMTPBluetoothController::ManageService( TBool aStatus )
+    {
+    __FLOG_1( _L8("+/-ManageService( %d )"), aStatus );
+    iStat = aStatus;
+    TInt err = KErrNone;
+    if ( !iMTPOperator )
+        {
+        TRAP( err, iMTPOperator = CMTPOperator::NewL( *this ) );
+        }
+    if ( KErrNone != err )
+        {
+        Monitor().ManageServiceCompleted( Bearer(), iStat, err );
+        return;
+        }
+    
+    if ( aStatus )
+        {
+        iMTPOperator->StartTransport( KMTPBtTransportUid );
+        }
+    else
+        {
+        iMTPOperator->StopTransport( KMTPBtTransportUid );
+        }
+    }
+
+void CMTPBluetoothController::HandleStartTrasnportCompleteL( TInt aError )
+    {
+    __FLOG_1( _L8("+HandleStartTrasnportCompleteL( %d )"), aError );
+    switch( aError )
+        {
+        case KErrServerBusy:// Another transport is running, keep observing the status of the transport bearer
+            aError = KErrNone;
+            break;
+        default:
+            break;
+        }
+    Monitor().ManageServiceCompleted( Bearer(), iStat, aError );
+    __FLOG( _L8("-HandleStartTrasnportCompleteL") );
+    }
+
+void CMTPBluetoothController::HandleStopTrasnportCompleteL( TInt aError )
+    {
+    __FLOG_1( _L8("+HandleStopTrasnportCompleteL( %d )"), aError );
+    Monitor().ManageServiceCompleted( Bearer(), iStat, aError );
+    __FLOG( _L8("-HandleStopTrasnportCompleteL") );
+    }
+
+CMTPBluetoothController::CMTPBluetoothController( CMTPBearerMonitor& aMon ):
+    CMTPControllerBase( aMon, ELocodBearerBT ),
+    iStat( EFalse )
+    {
+    __FLOG_OPEN( KMTPSubsystem, KComponent );
+    __FLOG( _L8("+/-Ctor") );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/src/cmtpcontrollerbase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,38 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+#include "cmtpcontrollerbase.h"
+
+TLocodBearer CMTPControllerBase::Bearer() const
+    {
+    return iBearer;
+    }
+
+CMTPControllerBase::CMTPControllerBase( CMTPBearerMonitor& aMon, TLocodBearer aBearer ):
+    iMon( aMon ),
+    iBearer( aBearer )
+    {
+    }
+
+CMTPBearerMonitor& CMTPControllerBase::Monitor() const
+    {
+    return iMon;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/src/cmtpoperator.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,138 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "cmtpoperator.h"
+
+__FLOG_STMT( _LIT8( KComponent, "mtpoperator" ); )
+
+CMTPOperator* CMTPOperator::NewL( MMTPOperatorNotifier& aNotifier )
+    {
+    CMTPOperator* self = new( ELeave ) CMTPOperator( aNotifier );
+    self->ConstructL();
+    return self;
+    }
+
+CMTPOperator::~CMTPOperator()
+    {
+    Cancel();
+    iPendingOperations.Reset();
+    iPendingOperations.Close();
+    iMTPClient.Close();
+    __FLOG( _L8("+/-Dtor") );
+    __FLOG_CLOSE;
+    }
+
+void CMTPOperator::StartTransport( TUid aTransport )
+    {
+    __FLOG_1( _L8("+/-StartTransport( 0x%08X )"), aTransport.iUid );
+    TInt err = AppendOperation( EStartTransport, aTransport );
+    if ( KErrNone != err )
+        {
+        iNotifier.HandleStartTrasnportCompleteL( err );
+        }
+    }
+
+void CMTPOperator::StopTransport( TUid aTransport )
+    {
+    __FLOG_1( _L8("+/-StopTransport( 0x%08X )"), aTransport.iUid );
+    TInt err = AppendOperation( EStopTransport, aTransport );
+    if ( KErrNone != err )
+        {
+        iNotifier.HandleStartTrasnportCompleteL( err );
+        }
+    }
+
+void CMTPOperator::DoCancel()
+    {
+    __FLOG( _L8("+/-DoCancel") );
+    }
+
+void CMTPOperator::RunL()
+    {
+    __FLOG( _L8("+RunL") );
+    
+    TInt count = iPendingOperations.Count();
+    if ( count > 0 )
+        {
+        TOperation& operation = iPendingOperations[0];
+        TRAP_IGNORE( HandleOperationL( operation ) );
+        iPendingOperations.Remove( 0 );
+        }
+    
+    __FLOG( _L8("-RunL") );
+    }
+
+CMTPOperator::CMTPOperator( MMTPOperatorNotifier& aNotifier ):
+    CActive( EPriorityStandard ),
+    iNotifier( aNotifier )
+    {
+    __FLOG_OPEN( KMTPSubsystem, KComponent );
+    __FLOG( _L8("+/-Ctor") );
+    }
+
+void CMTPOperator::ConstructL()
+    {
+    __FLOG( _L8("+ConstructL") );
+    CActiveScheduler::Add( this );
+    User::LeaveIfError( iMTPClient.Connect() );
+    __FLOG( _L8("-ConstructL") );
+    }
+
+TInt CMTPOperator::AppendOperation( TOperationType aType, TUid aTransport )
+    {
+    TOperation operation = { aType, aTransport };
+    TInt err = iPendingOperations.Append( operation );
+    if ( ( KErrNone == err ) && !IsActive() )
+        {
+        Schedule( KErrNone );
+        }
+    __FLOG_1( _L8("+/-AppendOperation returns %d"), err );
+    return err;
+    }
+
+void CMTPOperator::Schedule( TInt aError )
+    {
+    __FLOG_1( _L8("+/-Schedule( %d )"), aError );
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete( status, aError );
+    SetActive();
+    }
+
+void CMTPOperator::HandleOperationL( const TOperation& aOperation )
+    {
+    __FLOG_2( _L8("+HandleOperationL( 0x%08X, 0x%08X )"), aOperation.iTransport.iUid, aOperation.iType );
+    TInt err = KErrNone;
+    switch ( aOperation.iType )
+        {
+        case EStartTransport:
+            err = iMTPClient.StartTransport( aOperation.iTransport );
+            iNotifier.HandleStartTrasnportCompleteL( err );
+            break;
+        default:
+            __ASSERT_DEBUG( ( EStopTransport == aOperation.iType ), User::Invariant() );
+            err = iMTPClient.StopTransport( aOperation.iTransport );
+            iNotifier.HandleStopTrasnportCompleteL( err );
+            break;
+        }
+    __FLOG( _L8("-HandleOperationL") );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/src/mtpcontroller.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,46 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <ecom/registryinfov2.rh>
+#include "locodplugin.hrh"
+
+RESOURCE REGISTRY_INFO theInfo
+    {
+    // resource_format_version must always be set as follows
+    resource_format_version = RESOURCE_FORMAT_VERSION_2;
+    
+    dll_uid = 0x20028787;
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            interface_uid = KLOCODSERVICEINTERFACEUID;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    // KFeatureIdS60MtpController = 272
+                    implementation_uid = 272;
+                    version_no = 1;
+                    display_name = "MTP Service Plugin";
+                    default_data = "";
+                    opaque_data = "";
+                    // This implementation CANNOT be overridden by a RAM-based plug-in
+                    rom_only = 1;
+                    }
+                };
+            }
+        };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpcontroller/src/proxy.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,38 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <ecom/implementationproxy.h>
+#include "cmtpbearermonitor.h"
+
+// Define the implementation UID of MTP Service Plugin implementation.
+static const TImplementationProxy ImplementationTable[] =
+    {
+    // KFeatureIdS60MtpController = 272
+    IMPLEMENTATION_PROXY_ENTRY( 272, CMTPBearerMonitor::NewL )
+    };
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+    {
+    aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+    return ImplementationTable;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/common/inc/ptpippanic.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,41 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef PTPIPPANIC_H
+#define PTPIPPANIC_H
+
+#include <e32std.h>
+
+_LIT(KPTPIPPanic, "PTPIP");
+
+enum TPTPIPPanic
+    {
+    EPTPIPReserved					= 0,
+    EPTPIPBadState    	 			= 1,
+    EPTPIPNotSupported 				= 2,
+    EPTPIPConnectionAlreadyExist	= 3
+    };
+
+inline void Panic(TPTPIPPanic aCode)
+    {
+    User::Panic(KPTPIPPanic, aCode);
+    };
+
+#endif // PTPIPPANIC_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/common/inc/ptpipprotocolconstants.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,57 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#ifndef PTPIPROTOCOLCONSTANTS_H
+#define PTPIPROTOCOLCONSTANTS_H
+
+#include <e32def.h>
+
+/** 
+Defines constant values specified in the PTPIP protocol.
+@internalComponent
+*/
+
+/**
+The PTPIP Protocol constants as defined in the PTPIP specification. 
+*/
+enum TPTPIPPacketTypeCode
+	{
+	EPTPIPPacketTypeUndefined = 		0x0000,
+	EPTPIPPacketTypeCmdReq = 			0x0001,
+	EPTPIPPacketTypeCmdAck = 			0x0002,
+	EPTPIPPacketTypeEventReq = 			0x0003,
+	EPTPIPPacketTypeEventAck = 			0x0004,
+	EPTPIPPacketTypeEventFail = 		0x0005,
+	EPTPIPPacketTypeOperationRequest = 	0x0006,
+	EPTPIPPacketTypeOperationResponse = 0x0007,
+	EPTPIPPacketTypeEvent = 			0x0008,
+	EPTPIPPacketTypeStartData = 		0x0009,
+	EPTPIPPacketTypeData = 				0x000A,
+	EPTPIPPacketTypeCancel = 			0x000B,
+	EPTPIPPacketTypeEndData = 			0x000C,
+	EPTPIPPacketTypeProbeRequest = 		0x000D,
+	EPTPIPPacketTypeProbeResponse = 	0x000E,
+	};
+
+/*
+ * PTPIP transport implementation UID
+ */
+const TUint KMTPPTPIPTransportImplementationUid  = 0xA0004A60;
+
+#endif // PTPIPROTOCOLCONSTANTS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/common/inc/ptpipsocketpublish.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,28 @@
+
+
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef PTPIPSOCKETPUBLISH_H
+#define PTPIPSOCKETPUBLISH_H
+
+
+
+enum TPropertyKeys
+				{
+				ECommandSocketName,EEventSocketName
+				};
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/filterapi/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+// BLD.INF
+// Component description file
+//
+PRJ_EXPORTS
+
+../interface/cptpiphostfilterinterface.h	SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/cptpiphostfilterinterface.h)
+../interface/mptpiphostfilter.h  			SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mptpiphostfilter.h)
+
+PRJ_MMPFILES
+ptpipfilterapi.mmp
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/filterapi/group/ptpipfilterapi.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+// ptpipfilterapi.mmp
+//
+//
+
+// using relative paths for sourcepath and user includes
+// exports are unfrozen
+
+TARGET        ptpipfilterapi.dll
+TARGETTYPE    dll
+UID           0x1000008d 0xA0004A5C
+CAPABILITY     All -Tcb
+
+SOURCEPATH    ../src
+SOURCE        cptpiphostfilterinterface.cpp
+
+
+USERINCLUDE   ../interface
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+LIBRARY       euser.lib ecom.lib esock.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/filterapi/interface/cptpiphostfilterinterface.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,55 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Provides an interface (ECOM-plugin interface)for loading any implementation of filter.
+// If multiple instances exist, which implementation is loaded is based either on UID 
+// mentioned or the parameters passed that distinguish it from the other implementations.
+// ListImplementations() can be called to get the list the list of implementations
+// for this particular interface.
+// 
+//
+
+/**
+ @publishedPartner
+ @released
+*/
+
+#ifndef __CPTPIPHOSTFILTERINTERFACE_H__
+#define __CPTPIPHOSTFILTERINTERFACE_H__
+
+
+#include <e32base.h>	
+#include <e32std.h>
+#include <es_sock.h>
+#include <e32cmn.h>
+#include <ecom/ecom.h>
+
+#include <mtp/mptpiphostfilter.h>
+
+
+class CPTPIPHostFilterInterface : public MPTPIPHostFilter
+{	
+	public:
+		IMPORT_C static CPTPIPHostFilterInterface* NewL();				
+
+		IMPORT_C static void ListImplementations(RImplInfoPtrArray & aImplInfoArray);	
+		
+		IMPORT_C virtual ~CPTPIPHostFilterInterface();	 				
+		
+	private:
+		TInt iID_offset;//offset of Implementation UID
+		
+};
+
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/filterapi/interface/mptpiphostfilter.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,48 @@
+
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Provides an interface to implement a filter(that filters the incoming requests), by mentioning 
+// a basic behaviour any filter has to exhibit. There has to be a method to authenticate or validate
+// an incoming request.This can be done by examining the Host GUID, or also, by prompting the user
+// to accept or reject the request, by giving the user the details of connection request.
+// 
+//
+
+/**
+ @publishedPartner
+ @released
+*/
+
+
+#ifndef MPTPIPHOSTFILTER_H_
+#define MPTPIPHOSTFILTER_H_
+ 
+ #include <e32def.h>
+ #include <e32cmn.h>
+
+
+class MPTPIPHostFilter
+{
+   public:
+    		
+   			/*Examine the parameters ,from PTPIP Controller i.e.,Host GUID,Host Friendly Name 
+   			& filter out the requests that cannot be authenticated.The User can also be prompted using 
+   			a dialog box asking whether to accept or reject the request by giving the details of connection request
+   			@param HostFriendly Name, Host GUID and iStatus of the Caller,i.e PTP/IP Controller
+   			 */
+   			virtual void Accept(const TDesC& aHostFriendlyName,TDesC8& aHostGUID,TRequestStatus& aStatus)=0;
+};
+
+#endif
+    		
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/filterapi/src/cptpiphostfilterinterface.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,65 @@
+
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "cptpiphostfilterinterface.h"
+
+/*
+Creates an implementation of an ECOM plugin with the specified UID
+*/
+EXPORT_C CPTPIPHostFilterInterface* CPTPIPHostFilterInterface::NewL()
+	{		
+	const TUid KFilterImplUid ={0xA0004A5F};
+	
+	TAny* defaultFilter=NULL;
+	
+	TRAPD(error,defaultFilter=REComSession::CreateImplementationL(KFilterImplUid,_FOFF(CPTPIPHostFilterInterface,iID_offset)));
+	if(error==KErrNone)
+	{
+	return (reinterpret_cast<CPTPIPHostFilterInterface*>(defaultFilter));
+	}
+	else 
+		{
+		return NULL;	
+		}
+	}
+
+
+/*
+Lists all the implementations for that Interface identified by the Interface ID
+*/
+EXPORT_C void CPTPIPHostFilterInterface::ListImplementations(RImplInfoPtrArray& aImplInfoArray)
+	{
+	const TUid KFilterInterfaceUid ={0xA0004A5E};
+	TRAPD(ret, REComSession::ListImplementationsL(KFilterInterfaceUid,aImplInfoArray));
+	if(ret != KErrNone)
+	{
+		RDebug::Print(_L("CPTPIPController::ListImplementations ERROR = %d\n") ,ret);
+	}
+
+	}
+
+
+/*
+Destructor
+*/
+EXPORT_C CPTPIPHostFilterInterface::~CPTPIPHostFilterInterface()
+{
+
+}
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,34 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// MTP framework PTP IP transport components
+// 
+//
+
+/**
+ @file
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+
+#include        "../ptpipdatatypes/group/bld.inf"
+#include        "../ptpipplugin/group/bld.inf"
+#include	"../ptpipcontroller/group/bld.inf"
+#include	"../filterapi/group/bld.inf"
+
+PRJ_EXPORTS
+mtp_ptpip.iby		/epoc32/rom/include/mtp_ptpip.iby
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/group/mtp_ptpip.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -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 MTP_PTPIP_IBY
+#define MTP_PTPIP_IBY
+
+#if !defined (SYMBIAN_EXCLUDE_MTP) && !defined(SYMBIAN_EXCLUDE_PTPTIP)
+
+#include <mtp_framework.iby>
+
+//MTP PTP IP Data Types Library
+file=ABI_DIR\BUILD_DIR\ptpipdatatypes.dll			system\libs\ptpipdatatypes.dll
+file=ABI_DIR\BUILD_DIR\ptpipcontroller.dll			system\libs\ptpipcontroller.dll
+file=ABI_DIR\BUILD_DIR\ptpipfilterapi.dll			system\libs\ptpipfilterapi.dll
+//TODO
+
+//MTP PTP IP transport plugin
+ECOM_PLUGIN(ptpipplugin.dll, ptpipplugin.rsc)
+
+
+#endif // SYMBIAN_EXCLUDE_MTP
+
+#endif // MTP_PTPIP_IBY
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/group/mtp_ptpip.mrp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,26 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	mtp_ptpip
+source \sf\mw\remoteconn\mtptransports\mtpptpiptransport
+
+binary	\sf\mw\remoteconn\mtptransports\mtpptpiptransport\group all
+exports	\sf\mw\remoteconn\mtptransports\mtpptpiptransport\group
+
+notes_source	\component_defs\release.src
+
+ipr E 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipcontroller/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -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
+DEFAULT
+
+PRJ_EXPORTS
+
+../interface/mptpipcontroller.h  SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mptpipcontroller.h)
+../interface/rptpipframework.h  SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/rptpipframework.h) 
+PRJ_MMPFILES
+ptpipcontroller.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipcontroller/group/ptpipcontroller.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,44 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+TARGET        ptpipcontroller.dll
+TARGETTYPE    DLL
+// This is taken from music dp
+UID	            	0x10009D8D 0xA0004A5B     
+CAPABILITY          All -Tcb
+VENDORID      0x70000001
+
+SOURCEPATH    ../src 
+
+
+SOURCE cptpipcontroller.cpp
+SOURCE cptpipsockethandler.cpp
+SOURCE rptpipframework.cpp
+SOURCE cptpiptimer.cpp
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+USERINCLUDE	    ../inc/
+USERINCLUDE	    ../interface/
+USERINCLUDE   ../../common/inc/ 
+USERINCLUDE   ../../ptpipdatatypes/inc/
+USERINCLUDE   ../../../../mtpfws/mtpfw/common/inc			
+
+
+
+LIBRARY             euser.lib esock.lib insock.lib ecom.lib
+LIBRARY             mtpdatatypes.lib  ptpipdatatypes.lib mtpclient.lib centralrepository.lib ptpipfilterapi.lib comsdbgutil.lib commdb.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipcontroller/inc/cptpipcontroller.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,194 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// This file defines the API for cptpipcontroller.dll
+// 
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef __CPTPIPCONTROLLER_H__
+#define __CPTPIPCONTROLLER_H__
+
+#include <e32base.h>	
+
+#include <e32property.h>
+#include "centralrepository.h"
+#include "cptpipsockethandler.h"
+#include <mtp/cptpiphostfilterinterface.h>
+#include <mtp/rmtpclient.h>
+#include "mptpipcontroller.h"
+#include "cptpipinitcmdreq.h"
+#include "cptpipinitcmdack.h"
+#include "tptpipinitevtreq.h"
+#include "tptpipinitfailed.h"
+#include <mtp/cmtptypestring.h>
+#include "cptpiptimer.h"
+#include "mtpdebug.h"
+
+
+  enum TInitFailReason
+        {
+        /**
+        Responder impliments a device bonding mechanism and initiator requesting 
+        the connection is not one of the 'allowed' device. see annex 5.3 for more 
+        detail on bonding mechanism.
+        */
+        EInitFailRejected,        
+        /**
+         Responder has too many active connections. The Initiator  may try to 
+         establish a connection latter.
+        */
+        EInitFailBusy,
+        /**
+        Covers all other rejection cases.
+        */
+        EInitFailUnSpecified,
+
+ 		};
+ 		
+enum TParameter
+{
+	/*
+	This parameter defines the Device Friendly Name MTP device property 
+	value. It is implemented as a string and has a maximum length of 254 
+	characters. The parameter value specified in the initialisation file 
+	may be overwritten in the course of MTP operational processing, if an 
+	MTP SetDevicePropValue specifying the Device Friendly Name device 
+	property is received.
+	*/
+	EDeviceFriendlyName  = 0x00000000
+}; 		
+
+
+class CPTPIPController : public MPTPIPController,public CActive
+{
+public:	 
+	IMPORT_C static CPTPIPController* NewL();
+	IMPORT_C static CPTPIPController* NewLC();
+	IMPORT_C ~CPTPIPController();
+			
+	IMPORT_C void SocketAccepted(TRequestStatus& aStatus);		
+	IMPORT_C void StopTransport();						
+	IMPORT_C TInt SetDeviceGUID(TDesC8& aDeviceGUID);
+	IMPORT_C void SetDeviceFriendlyName(TDesC16* aDeviceFriendlyName);
+	IMPORT_C RSocket& NewSocketL();
+			
+	IMPORT_C void OnTimeOut();
+										
+private:
+	TBool CompareHost(RSocket& aSocket);				
+	TInt PublishSocketNamePair();		
+	void CheckAndHandleErrorL(TInt aError);
+	TInt EnableSocketTransfer();		
+	TBool Validate();
+	void Schedule();
+			
+	TInt ParseInitPacketL();
+	TInt ParseEvtPacket();
+			
+	void RunL();
+	void DoCancel();	    	    
+	TInt RunError(TInt aErr);
+			
+	void CheckInitFailL(TInt aError);	    
+	CPTPIPController();
+	void ConstructL();
+	void BuildInitAckL();
+	void BuildInitFailL(TInitFailReason aReason);
+	void StartTimer(TInt aSecond);
+	TInt CheckMTPConnection();
+	void Reset();
+			
+	 enum TPTPIPControllerStates
+		{
+		/*EIdle:The Controller just got constructed, and any time
+		Listener will notify about new socket. */ 
+		EIdle,
+		
+	  /*EInitCommandAwaited:When SocketHandler is waiting for 
+	   InitCommandRequest to be sent over Command socket
+	   No socket connection request is validated at this state*/
+		EInitCommandAwaited,
+	 
+	 /*EInitCommandRead:When the InitCommandRequest is successfully
+	  read from the socket
+	  */
+		EInitCommandRead,
+		
+		
+		/*EFilterConsentAwaited:Controller is waiting for approval from Filter*/
+		EFilterConsentAwaited,
+		
+		
+		/*EWaitForInitFail:Filter has rejected the Connection request.Init Nack
+		built,Wait for Init NAck to be written and failure to connect reported*/
+		EWaitForInitFail,
+		
+		/*EWaitForInitCommandAck:Filter has accepted the conenction request.InitAck
+		built,Wait for Init Ack to be written*/
+		EWaitForInitCommandAck,       		                            
+		
+	 
+	  /*EInitEvtAwaited:When Socket Handler is waiting for InitEventRequest
+	   * No socket connection request is validated at this state*/
+		EInitEvtAwaited,
+		
+	  
+	 /*EInitEventRead:InitEventRequest read
+	  *No socket connection request is validated at this state */           
+		EInitEventRead,       		       	       	 
+						
+						 
+	 /*EConnected:Socket connection requests are not to be validated in this 
+	  state and the message Device Busy to be sent*/
+		EPTPIPConnected           
+		};
+		   
+private:
+		
+	CPTPIPSocketHandler* iCmdHandler,*iEvtHandler;
+	CPTPIPHostFilterInterface* iFilter;
+	TPTPIPControllerStates iCtrlState;
+	RProperty iProperty,iConnectionState;		
+	RMTPClient iMTP;
+	TBool iIsConnectedToMTP;
+	TMTPTypeUint128 iHostGUID;	
+	TDesC* iHostFriendlyName;							
+	TRequestStatus* iCallerStatus;		
+	CPTPIPInitCmdRequest* iInitCmdReq;
+	TPTPIPInitEvtRequest iInitEvtReq;
+	TPTPIPInitFailed iInitFailed;
+	CPTPIPInitCmdAck* iInitCmdAck;	
+	CRepository* iRepository;							
+	TMTPTypeUint128 iDeviceGUID;
+	HBufC16* iDeviceFriendlyName;		
+	RSocket iDummySocket;
+	TInt iCounter;
+	CPTPIPTimer* iTimer;
+	TUid iTransportId;			
+			
+	/**
+	FLOGGER debug trace member variable.
+	*/
+	__FLOG_DECLARATION_MEMBER;    
+			
+};
+
+
+#endif  // __CPTPIPCONTROLLER_H__
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipcontroller/inc/cptpipsockethandler.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,73 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+
+#ifndef CPTPIPSOCKETHANDLER_H_
+#define CPTPIPSOCKETHANDLER_H_
+
+#include <e32base.h>
+#include <es_sock.h>
+#include <mtp/mmtptype.h>
+
+
+const TInt KMaxBufSize=64;
+
+enum TSocketHandlerState
+{
+	EReadState,EWriteState
+};
+/*
+ Handles the Common Socket-Operations
+*/
+class CPTPIPSocketHandler:public CActive
+{
+  	public:
+  			
+  		static CPTPIPSocketHandler* NewL();
+  		static CPTPIPSocketHandler *NewLC();
+  		~CPTPIPSocketHandler();   		 		
+  		void ReadFromSocket(MMTPType& aData,TRequestStatus& aStatus);
+  		void WriteToSocket(MMTPType& aData,TRequestStatus& aStatus);  		  		
+  		RSocket& Socket();  			 		  				  			      	    
+		TSocketHandlerState& State();
+  		
+  	private:
+  	
+  		void RunL();
+  		void DoCancel();  		
+  		TInt RunError(TInt aErr);
+  		CPTPIPSocketHandler();
+  		void ConstructL();  		  		  		
+  		  		
+  	private:
+  	
+  		TPtr8 iReceiveChunk;
+  		TPtrC8 iWriteChunk;  		  	  			  		
+  		TRequestStatus* iCallerStatus;
+  		TBool iChunkStatus;  		  				 		  
+  		RSocket iSocket; 
+  		MMTPType* iReadData,*iWriteData;
+  		TSocketHandlerState iState;
+  		TSockXfrLength iLen;
+  		TInt iLength;
+};
+
+
+#endif /*CPTPIPSOCKETHANDLER_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipcontroller/inc/cptpiptimer.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,55 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cptpiptransport.h
+// 
+//
+
+/**
+ @internalComponent
+*/
+
+
+#ifndef CPTPIPTIMER_H_
+#define CPTPIPTIMER_H_
+
+#include <e32base.h>
+#include <e32def.h>
+
+const TUint KInitialTimeoutInSeconds = 30;
+const TInt KTimerMultiplier = 1000000;
+
+
+/**
+The CPTPIPTimer class sets up a timeout time for operations.
+*/
+
+class CPTPIPController;
+
+class CPTPIPTimer: public CTimer
+	{
+public:	
+	static CPTPIPTimer* NewLC(CPTPIPController& aController);
+	static CPTPIPTimer* NewL(CPTPIPController& aController);	
+	void IssueRequest(TInt aTimerValue);
+	void RunL();
+
+private:	
+	CPTPIPTimer(CPTPIPController& aController);
+	void ConstructL();	
+	
+private:
+	CPTPIPController* iController;	
+	};
+	
+#endif /*CPTPIPTIMER_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipcontroller/interface/mptpipcontroller.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,84 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+// Contributors:
+// Provides an interface to operate with PTP/IP Controller like., Notify the 
+// PTP/IP Controller of incoming requests, Stop the existing transport, Set the 
+// current Device GUID and Device Friendly Name,Get a new blank socket everytime 
+// there is a connection request.
+//
+
+
+
+/**
+ @publishedPartner
+ @released
+*/
+
+#ifndef __MPTPIPCONTROLLER_H__
+#define __MPTPIPCONTROLLER_H__
+
+#include <e32cmn.h>
+#include <es_sock.h>
+
+class MPTPIPController
+{
+	
+	public:
+	
+	
+		/*
+		Stops the existing PTPIP transport,In-turn closes the client-side session
+		with MTP server,Before calling StopTransport(),any outstanding Listen call
+		over socket,has to be cancelled.
+		*/
+		virtual void StopTransport()=0;
+
+	   /*
+	   	This method is called to notify the PTP/IP Controller that there is an incoming connection 
+	   	request.It hands over the Command or Event Sockets to the appropriate Socket Handlers.
+	   	There is a validation happening as to whether both of the above requests are coming
+	   	from the same host; it validates if it is from the same host; otherwise rejects the 
+	   	request and starts listening on the socket again.
+     	@param TRequestStatus of the caller.
+	   */
+		virtual void SocketAccepted(TRequestStatus& aStatus)=0;
+
+		/*
+		Saves the current Device GUID(Globally Unique Identifier)
+		@param GUID of the device which is obtained from the Device as a part of InitCommandAck Packet
+		@return KErrNone if GUID is valid, otherwise KErrArgument
+		*/
+		virtual TInt SetDeviceGUID(TDesC8& aDeviceGUID)=0;
+
+		/*
+		Saves the current Device Friendly Name
+		@param Friendly Name of the device which is obtained from the Device as a part of InitCommandAck Packet
+		*/
+		virtual void SetDeviceFriendlyName(TDesC16* aDeviceFriendlyName)=0;
+
+		/*
+		Issues a new blank socket.NewSocketL() has to be called when a socket is required to accept
+		the incoming connection request.
+		@return Reference to the socket the PTPIP/Controller owns.
+		@leave when it cannot return any more sockets.It leaves when there are more than 3 connection requests
+		per session
+		*/
+		virtual RSocket& NewSocketL()=0;
+
+	
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipcontroller/interface/rptpipframework.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,45 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// An instance of  PTP/IP Controller is created by RPTPIPFramework::OpenL().
+// Controller() method returns the instance created by OpenL().In the destructor of the 
+// caller of Controller(), RPTPIPFramework::Close() has to be called to delete the instance of 
+// PTP/IP Controller.
+// publishedPartner
+// 
+//
+
+
+#ifndef __RPTPIPFRAMEWORK_H__
+#define __RPTPIPFRAMEWORK_H__
+
+#include <mtp/mptpipcontroller.h>
+
+
+class CPTPIPController;
+
+class RPTPIPFramework
+{
+	public:
+			
+			IMPORT_C void OpenL();		
+			IMPORT_C MPTPIPController& Controller();
+			IMPORT_C void Close();	
+			IMPORT_C RPTPIPFramework();					
+													
+	private:
+																				
+			CPTPIPController* iCtrl;													 
+};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipcontroller/src/cptpipcontroller.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,635 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "cptpipcontroller.h"	// Cptpipcontroller	
+
+#include <mtp/tmtptypeuint128.h>
+#include "ptpipsocketpublish.h"
+#include <in_sock.h>
+#include "ptpipprotocolconstants.h"
+
+
+ 
+_LIT_SECURITY_POLICY_PASS(KAllowReadAll);
+_LIT_SECURITY_POLICY_C1(KProcPolicy,ECapability_None);
+__FLOG_STMT(_LIT8(KComponent,"PTPIPController");)
+
+
+#define PTPIP_INIT_COMMAND_REQUEST	1
+#define PTPIP_INIT_COMMAND_ACK		2
+#define PTPIP_INIT_EVENT_REQUEST	3
+#define PTPIP_INIT_FAIL				5
+#define PTPIP_FIXED_CONNECTION_ID	1
+#define PTPIP_PRPTOCOL_VERSION		0x00000001
+
+
+enum TPTPIPControllerPanicReasons
+    {
+    EPanicTransportNotStarted     = 0,
+    };
+
+
+EXPORT_C CPTPIPController* CPTPIPController::NewLC()
+	{
+	CPTPIPController* self = new (ELeave) CPTPIPController;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+/*
+ Factory Method
+*/
+EXPORT_C CPTPIPController* CPTPIPController::NewL()
+	{
+	CPTPIPController* self = CPTPIPController::NewLC();
+	CleanupStack::Pop(1);
+	return self;
+	}
+
+
+CPTPIPController::CPTPIPController():
+		CActive(EPriorityStandard),iDeviceGUID()
+	{
+	iCtrlState=EIdle;
+	iTransportId=TUid::Uid(KMTPPTPIPTransportImplementationUid);
+	iCounter=0;
+	CActiveScheduler::Add(this);
+	}
+
+/*
+Creates two PTPIP SocketHandlers and handles the sockets to 
+PTPIP SocketHandler & loads the Filter plugin.
+*/
+void CPTPIPController::ConstructL()
+	{
+   	 __FLOG_OPEN(KMTPSubsystem, KComponent);	 
+	 iCmdHandler = CPTPIPSocketHandler::NewL();
+	 iEvtHandler = CPTPIPSocketHandler::NewL();
+	 iFilter=CPTPIPHostFilterInterface::NewL();
+	 iInitCmdAck   = CPTPIPInitCmdAck::NewL(); 
+	 iTimer=CPTPIPTimer::NewL(*this);	 
+	 	
+	TParameter param=EDeviceFriendlyName;
+	
+	iIsConnectedToMTP = EFalse;
+	iDeviceGUID.Set(0,0);
+	const TUint32 KUidMTPRepositoryValue(0x10282FCC);
+	const TUid KUidMTPRepository = {KUidMTPRepositoryValue};
+	iRepository = CRepository::NewL(KUidMTPRepository);		
+	iDeviceFriendlyName = HBufC16::NewL(100);
+	TPtr16 name = iDeviceFriendlyName->Des();	
+	TInt result=iRepository->Get(param,name);		
+	}
+
+/*
+Destructor
+*/
+EXPORT_C CPTPIPController::~CPTPIPController()
+	{
+	delete iCmdHandler;
+   	delete iEvtHandler;
+   	delete iFilter; 
+   	delete iTimer;
+   	delete iDeviceFriendlyName;  
+	delete iRepository;
+	delete iInitCmdReq;
+	delete iInitCmdAck;
+   	iMTP.Close();
+	iIsConnectedToMTP = EFalse;
+	iProperty.Close();
+	iConnectionState.Close();
+   	__FLOG_CLOSE;
+	}
+
+
+
+EXPORT_C RSocket& CPTPIPController::NewSocketL()
+	{
+	iCounter++;
+	if(iCounter==1)
+	return iCmdHandler->Socket();
+	else if(iCounter==2)
+	return iEvtHandler->Socket();
+	else
+	return iDummySocket;
+	//Issue :If Newsocket is called 4 time then we are going to give 
+	 //the same socket that we have given him third time.
+	
+	}
+TInt  CPTPIPController::CheckMTPConnection()
+{
+	TInt error = KErrNone;
+	if(iIsConnectedToMTP == EFalse)
+		{
+		error = iMTP.Connect();	
+		}	
+	if(error ==KErrNone) 
+		{
+		iIsConnectedToMTP = ETrue;		
+		error = iMTP.IsAvailable(iTransportId);
+		}
+    return error;
+}
+/*
+Validates the socket connection based on the current value of iCtrlState
+@return ETrue on succes EFalse on failure*/
+TBool CPTPIPController::Validate()
+	{
+	if(iCtrlState==EIdle || iCtrlState==EInitEvtAwaited)
+	return ETrue;
+	else 
+	return EFalse;
+	}
+
+
+/*Saves the CommandSocket and EventSocket;The respective SocketHandlers are given the sockets
+and Calls itself on a CompleteSelf()
+ @param aSocket Pointer to socket
+ @param TRequestStatus of the caller i.e., CPTPIPAgent
+*/ 
+EXPORT_C void CPTPIPController::SocketAccepted(TRequestStatus& aStatus)
+	{
+   	iCallerStatus=&aStatus;
+   	aStatus=KRequestPending;    	   		
+	TBool result=Validate();
+	if(result==EFalse)
+		{
+		User::RequestComplete(iCallerStatus,KErrServerBusy);
+		return;
+		}
+	
+    if(iCtrlState==EInitEvtAwaited)  
+    	{ // we are not gracefully rejecting a new PTPIP connection from other  host
+    	  // as of now just socket closed.
+        if(CompareHost(iEvtHandler->Socket())==EFalse)
+        	{       
+        	User::RequestComplete(iCallerStatus,KErrServerBusy);	
+        	return;
+ 			}
+    	}
+	if(iCtrlState==EPTPIPConnected)  
+    	{ 
+         /*if(CompareHost(iDummySocket->Socket())==EFalse)
+          *	User::RequestComplete(status,KErrServerBusy);	
+          *	Note : As of now this check is not required because 
+          * call to Validate(0) will fail. 	
+         */
+ 		}
+	 			
+	/*
+	Check whether PTPIPController is in a state of accepting new socket connections
+	*/
+	if (iCtrlState == EIdle)
+      	{      
+      	iCtrlState = EInitCommandAwaited;
+      	}       
+    else if (iCtrlState == EInitEvtAwaited)
+      	{        
+       	iCtrlState = EInitEvtAwaited;
+      	}
+      	
+      Schedule();        
+	}
+	
+	
+/*
+Compares whether the second connection request is from the same remote host
+@param returns ETrue if the second request comes from the same host
+*/	
+TBool CPTPIPController::CompareHost(RSocket& aSocket)
+	{
+     
+	TInetAddr  thisaddr, newAddr;
+     
+    iCmdHandler->Socket().RemoteName(thisaddr);     
+	aSocket.RemoteName(newAddr);	
+    if(newAddr.Address() == thisaddr.Address())
+    	{
+		return ETrue;
+    	}
+    else
+    	{
+   	 	return EFalse;
+    	}
+
+	}		
+			
+/**
+Schedules the next request phase or event.
+*/
+void CPTPIPController::Schedule()
+	{	 
+ 	iStatus = KRequestPending; 
+ 	TRequestStatus* status(&iStatus);  
+    SetActive();
+    User::RequestComplete(status, KErrNone);	 
+	}
+
+/*
+ Defines the two socket names to be published
+ @return one of the system wide error codes on failure
+*/
+TInt  CPTPIPController::PublishSocketNamePair()
+	{
+	TName iCommandSocketSysName,iEventSocketSysName;			  
+   	iCmdHandler->Socket().Name(iCommandSocketSysName);
+   	iEvtHandler->Socket().Name(iEventSocketSysName);
+	
+	
+	
+	/******************Define command socket system name************************/		
+	RProcess serverprocess;
+	
+	const TUid KPropertyUid= serverprocess.Identity();		
+   
+    TInt error=iProperty.Define(KPropertyUid,ECommandSocketName,RProperty::EText,KAllowReadAll,KAllowReadAll);
+   
+    error=iProperty.Attach(KPropertyUid,ECommandSocketName);
+   
+	error=RProperty::Set(KPropertyUid,ECommandSocketName,iCommandSocketSysName);    
+
+	/*****************Define event socket system name***********************/		
+	
+	error=iProperty.Define(KPropertyUid,EEventSocketName,RProperty::EText,KAllowReadAll,KAllowReadAll);
+	
+	error=iProperty.Attach(KPropertyUid,EEventSocketName);
+	
+    error=RProperty::Set(KPropertyUid,EEventSocketName,iEventSocketSysName);  
+	
+	return error;
+	}
+	
+
+/*Makes the sockets Transfer enabled
+ @return one of the system wide error codes on failure
+ */
+TInt CPTPIPController::EnableSocketTransfer()
+	{
+	TInt err;
+	err = iCmdHandler->Socket().SetOpt(KSOEnableTransfer, KSOLSocket,KProcPolicy().Package());	
+	
+	if(err != KErrNone) return err;
+	
+	err = iEvtHandler->Socket().SetOpt(KSOEnableTransfer, KSOLSocket,KProcPolicy().Package());
+	
+	 return err;
+	}	
+
+/*
+Sets the obtained DeviceGUID as the current DeviceGUID
+@param TDesC8& aDeviceGUID
+@return TInt KErrArgument if DeviceGUID is invalid or KErrNone
+*/
+EXPORT_C TInt CPTPIPController::SetDeviceGUID(TDesC8& aDeviceGUID)
+	{	     
+    TInt size = aDeviceGUID.Size();
+    if (size != 16) return KErrArgument;
+	TMTPTypeUint128  guid(aDeviceGUID);	
+	iDeviceGUID = guid;	
+	return KErrNone;
+	}
+
+/*
+Sets the obtained DeviceFriendlyName
+@param TDesC16* aDeviceGUID
+*/    
+EXPORT_C void CPTPIPController::SetDeviceFriendlyName(TDesC16* aDeviceFreindlyName)
+	{
+	delete iDeviceFriendlyName;
+	
+	TRAPD(err, iDeviceFriendlyName=aDeviceFreindlyName->AllocL());
+	
+	if(err != KErrNone)
+		{
+		 __FLOG_VA((_L8("CPTPIPController::SetDeviceFriendlyName ERROR = %d\n"), err));	
+		}
+	
+	}
+	
+
+void CPTPIPController::Reset()
+	{
+	iCmdHandler->Socket().Close();
+	iEvtHandler->Socket().Close();
+	if(iIsConnectedToMTP)
+	{
+	TInt stopStatus=iMTP.StopTransport(iTransportId);
+	if (KErrNone != stopStatus)
+	{
+	 __FLOG_VA((_L8("CPTPIPController::Reset ERROR = %d\n"), stopStatus));	
+	}	
+		
+	}
+				
+	iMTP.Close();
+	iProperty.Close();
+	iConnectionState.Close();
+	iCounter=0;
+	iIsConnectedToMTP = EFalse;	
+	iCtrlState = EIdle;	
+	iCmdHandler->State()=EReadState;
+	iEvtHandler->State()=EReadState;
+	}
+
+EXPORT_C void CPTPIPController::StopTransport()
+	{
+	Reset();
+	}
+
+
+
+void CPTPIPController:: CheckAndHandleErrorL(TInt  aError)
+	{		
+	if(aError != KErrNone)
+		{
+		Reset();							
+		__FLOG_VA((_L8("PTPIP Controller CheckAndHandleErrorL, Error = %d"), aError));	
+		User::Leave(aError);
+		}
+	}
+	
+void CPTPIPController:: CheckInitFailL(TInt aError)	
+	{
+	
+	TInitFailReason reason = EInitFailUnSpecified;
+		
+	// we send Init fail packet to Initiator on command channel
+	// even after InitEvent is received.
+	if(aError!=KErrNone && (iCtrlState==EInitCommandRead|| iCtrlState==EInitEventRead))
+		{
+		if(aError == KErrAccessDenied)
+			{
+			reason = EInitFailRejected;
+			}
+		BuildInitFailL(reason);  				 				 				 		
+		iCtrlState= EWaitForInitFail;
+		if(iCmdHandler->State()==EWriteState)
+		iCmdHandler->WriteToSocket(iInitFailed,iStatus);		
+		else
+		iEvtHandler->WriteToSocket(iInitFailed,iStatus);	
+		StartTimer(30);
+		__FLOG_VA((_L8("PTPIP Controller Error, Error = %d"), aError));
+		User::Leave(aError);					
+		}	
+	}	
+
+/*
+Cause a Time-Out event to occur
+*/
+EXPORT_C void CPTPIPController::OnTimeOut()
+	{
+	TRequestStatus* status(&iStatus);
+	User::RequestComplete(status,KErrTimedOut);
+	}
+	
+void CPTPIPController::StartTimer(TInt aSecond)	
+	{	
+		iTimer->IssueRequest(aSecond);
+		iStatus = KRequestPending;	
+		SetActive(); 	
+	}
+	
+void CPTPIPController::RunL()
+	{
+	
+	TInt StatusError=iStatus.Int();
+		
+	if(iCmdHandler->IsActive() || iEvtHandler->IsActive())	
+	{		
+	if(iCmdHandler->IsActive())
+	iCmdHandler->Cancel();
+	if(iEvtHandler->IsActive())
+	iEvtHandler->Cancel();
+	
+	}
+	else if(iTimer->IsActive())
+	{	
+	iTimer->Cancel();	
+	}
+
+    TPtrC8 hostGUID;
+	TInt error;
+ 	 switch(iCtrlState)
+  	{
+  		case EIdle:
+  			 break;
+
+   		case EInitCommandAwaited :    		   			
+   		   				
+   				iInitCmdReq   = CPTPIPInitCmdRequest::NewL();  
+   											
+     			iCmdHandler->ReadFromSocket(*iInitCmdReq,iStatus);        			  							
+ 				iCtrlState=EInitCommandRead;
+ 												 										
+				StartTimer(30);
+  				break;
+ 
+  		case EInitCommandRead:
+  				CheckAndHandleErrorL(StatusError);
+  				
+
+  				error = ParseInitPacketL();  				
+  				CheckInitFailL(error);
+  				
+  				// Need special error number for MTP not available 
+  				// so that licensee can understand it.
+  				if(iMTP.IsProcessRunning() != KErrNotFound )
+	  				{
+					error = CheckMTPConnection();
+	                CheckInitFailL(error);  					
+	  				}
+
+  				//coverity[unchecked_value]
+                iHostGUID.FirstReadChunk(hostGUID);               
+                
+                iFilter->Accept(*iHostFriendlyName,hostGUID,iStatus);               
+                iCtrlState=EFilterConsentAwaited;                
+                StartTimer(30);                
+  				break;
+ 
+ 		 case EFilterConsentAwaited:  		  		 	
+ 		 			 	 		  		 	
+                // Please wriet in function in m class that filter must send KErrAccessDenied
+ 		 		CheckInitFailL(StatusError );
+ 				//give error code for rejection.
+ 				BuildInitAckL();  				 							
+ 				iCtrlState = EWaitForInitCommandAck; 				
+ 				iCmdHandler->WriteToSocket(*iInitCmdAck,iStatus); 				 				
+ 				StartTimer(30); 				
+				break;
+				
+ 		case EWaitForInitFail : 
+ 		       // Do not call any other leaving function here 		                 
+ 		       // because RunError is going to ignore it.
+ 		       
+ 		       // Error code is wrong if this happens due to local error.
+                CheckAndHandleErrorL(KErrAccessDenied);                                
+                break;
+				
+ 		case EWaitForInitCommandAck :  
+                CheckAndHandleErrorL(StatusError);                
+				iCtrlState = EInitEvtAwaited;				
+  				User::RequestComplete(iCallerStatus,KErrNone); 
+				break;
+				   				  	
+ 
+  		case EInitEvtAwaited:
+  		   				 	  			  		   		   				 				  								
+  				iEvtHandler->ReadFromSocket(iInitEvtReq,iStatus);
+  				iCtrlState=EInitEventRead;  				
+  				StartTimer(30);  			
+  				break;
+ 
+  		case EInitEventRead:    			 			
+ 					 				
+               	CheckInitFailL(StatusError);
+  				error = ParseEvtPacket();
+  				CheckInitFailL(error);
+  				               	
+				error = EnableSocketTransfer();
+				CheckInitFailL(error);
+				
+  				error = PublishSocketNamePair();
+  				CheckInitFailL(error);
+  				
+  				error = CheckMTPConnection();                             
+                CheckInitFailL(error); 
+  				error = iMTP.StartTransport(iTransportId);
+  	  			CheckAndHandleErrorL(error);
+  	  				
+  				/************Subscribe to the state of plugin********/  				
+  				TInt connState;
+  				error = iConnectionState.Attach(KMTPPublishConnStateCat,EMTPConnStateKey);
+  				CheckAndHandleErrorL(error);
+  				error = iConnectionState.Get(KMTPPublishConnStateCat,EMTPConnStateKey,connState);   				
+  				CheckAndHandleErrorL(error);
+               	iConnectionState.Subscribe(iStatus);                	            	              	               	
+               	iCtrlState = EPTPIPConnected;               	
+               	SetActive();               
+               	break;
+                
+               
+  		case EPTPIPConnected:  	
+  			{
+			error=iConnectionState.Get(connState);  				
+			if((error!=KErrNone) || (connState==EDisconnectedFromHost))
+  				{  					
+  				Reset();						
+				User::RequestComplete(iCallerStatus,KErrNone);				
+  				}
+  			else
+	  			{
+				iConnectionState.Subscribe(iStatus);
+	 		    SetActive();
+	  			}
+			break;
+  			}  				
+  		default :
+	  		{
+	  		break;  			
+	  		}
+
+  	} 
+ 	
+	}
+
+/*
+Over-ridden to return KErrNone by checking the state of PTPIP Controller
+*/
+TInt CPTPIPController::RunError(TInt aErr)	
+	{			
+   		if(iCtrlState != EWaitForInitFail)
+   		{ 
+   		User::RequestComplete(iCallerStatus,aErr);   			
+		iCtrlState = EIdle;
+		iCmdHandler->State()=EReadState;
+		iEvtHandler->State()=EReadState;
+		iCounter=0;		
+		iMTP.Close();		
+		iIsConnectedToMTP = EFalse; 			   	
+   		}
+   		//Return KErrNone back to RunL()
+   		return KErrNone;
+	}
+	
+
+
+
+void CPTPIPController::DoCancel()
+	{
+
+	}
+	
+TInt CPTPIPController::ParseInitPacketL()
+{
+		TUint32 length(iInitCmdReq->Uint32L(CPTPIPInitCmdRequest::ELength));
+		TUint32 type(iInitCmdReq->Uint32L(CPTPIPInitCmdRequest::EPktType));
+		if(type != PTPIP_INIT_COMMAND_REQUEST) 
+			{
+			return KErrBadHandle;	
+			}
+		
+		iInitCmdReq->GetL(CPTPIPInitCmdRequest::EInitiatorGUID,iHostGUID);
+
+
+		TDesC& name = iInitCmdReq->HostFriendlyName();
+		iHostFriendlyName = &name;
+		TUint32 version(iInitCmdReq->Uint32L(CPTPIPInitCmdRequest::EVersion));
+		return KErrNone;
+}
+
+TInt CPTPIPController::ParseEvtPacket()
+{
+		TUint32 length(iInitEvtReq.Uint32(TPTPIPInitEvtRequest::ELength));
+		TUint32 type(iInitEvtReq.Uint32(TPTPIPInitEvtRequest::EType));	
+		if(type != PTPIP_INIT_EVENT_REQUEST) return KErrBadHandle;
+		TUint32 conNumber(iInitEvtReq.Uint32(TPTPIPInitEvtRequest::EconNumber));	
+		if(conNumber !=PTPIP_FIXED_CONNECTION_ID)
+			{ 
+			// We are supporting only one connection,So connection Id is fixed.
+			return KErrBadHandle;
+			}
+
+		return KErrNone;
+}
+void CPTPIPController::BuildInitAckL()
+{	
+	iInitCmdAck->SetUint32L(CPTPIPInitCmdAck::EPktType,PTPIP_INIT_COMMAND_ACK);
+	// We are supporting only one connection,So connection Id is fixed
+	iInitCmdAck->SetUint32L(CPTPIPInitCmdAck::EConNumber,PTPIP_FIXED_CONNECTION_ID);
+
+	iInitCmdAck->SetL(CPTPIPInitCmdAck::EResponderGUID,iDeviceGUID);
+
+	iInitCmdAck->SetDeviceFriendlyName(*iDeviceFriendlyName);
+	iInitCmdAck->SetUint32L(CPTPIPInitCmdAck::EVersion,PTPIP_PRPTOCOL_VERSION);
+	TUint64 size =  iInitCmdAck->Size();
+	iInitCmdAck->SetUint32L(CPTPIPInitCmdAck::ELength,(TUint32)size);	
+}
+
+void CPTPIPController::BuildInitFailL(TInitFailReason aReason)
+{	
+	iInitFailed.SetUint32(TPTPIPInitFailed::ELength,iInitFailed.Size());
+	iInitFailed.SetUint32(TPTPIPInitFailed::EType,PTPIP_INIT_FAIL);
+	iInitFailed.SetUint32(TPTPIPInitFailed::EReason,aReason);		
+}
+
+TBool E32Dll()
+{
+	return ETrue;
+}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipcontroller/src/cptpipsockethandler.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,173 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include "cptpipsockethandler.h"	//CPTPIPSockethandler
+
+
+
+CPTPIPSocketHandler* CPTPIPSocketHandler::NewLC()
+	{
+	CPTPIPSocketHandler* self = new (ELeave) CPTPIPSocketHandler;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+/*
+ Factory Method
+*/
+CPTPIPSocketHandler* CPTPIPSocketHandler::NewL()
+	{
+	CPTPIPSocketHandler* self = CPTPIPSocketHandler::NewLC();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+
+CPTPIPSocketHandler::CPTPIPSocketHandler():
+		CActive(EPriorityStandard),iReceiveChunk(NULL,0),iWriteChunk(NULL,0)
+	{
+	CActiveScheduler::Add(this);
+	iState=EReadState;
+	}
+
+void CPTPIPSocketHandler::ConstructL()
+	{
+	
+			
+	}
+	
+	
+RSocket& CPTPIPSocketHandler::Socket()
+	{			
+	return	iSocket;	
+	}
+	
+TSocketHandlerState& CPTPIPSocketHandler::State()
+{
+	return iState;
+}
+	
+   
+	
+CPTPIPSocketHandler::~CPTPIPSocketHandler()
+	{
+	Socket().Close();
+	}
+
+/*
+ Reads from the current accepted socket
+ @param TRequestStatus passed from PTPIP Controller
+ */
+void CPTPIPSocketHandler::ReadFromSocket(MMTPType& aData,TRequestStatus& aCallerStatus)
+	{
+    iReadData = &aData;
+	iChunkStatus = aData.FirstWriteChunk(iReceiveChunk);
+	//ToDo check this works or not
+	iCallerStatus=&aCallerStatus;
+	  
+	/* complete the reading of whole packet and then hit RunL
+	*/          
+	Socket().Recv(iReceiveChunk,0,iStatus);
+	
+	//start timer	
+    SetActive();
+	}
+
+/*Writes to the current socket
+@param TRequestStatus passed from PTPIP Controller
+*/
+void CPTPIPSocketHandler::WriteToSocket(MMTPType& aData,TRequestStatus& aCallerStatus)
+	{
+	iWriteData=&aData;
+	iChunkStatus = aData.FirstReadChunk(iWriteChunk);
+
+	iCallerStatus=&aCallerStatus;		
+	Socket().Write(iWriteChunk,iStatus);	
+	SetActive();	
+    
+	}
+
+
+	
+void CPTPIPSocketHandler::RunL()
+	{
+	TInt err = iStatus.Int();
+	User::LeaveIfError(err);
+	
+	switch(iState)
+	{
+		case EReadState:
+			if(iChunkStatus!=KMTPChunkSequenceCompletion)  
+			{
+        	if(iReadData->CommitRequired())
+	        	{
+	        	iReadData->CommitChunkL(iReceiveChunk);	
+	        	}		
+			iChunkStatus = iReadData->NextWriteChunk(iReceiveChunk);		
+			Socket().Recv(iReceiveChunk,0,iStatus,iLen);	
+	    	SetActive();	
+			}
+	
+		else
+			{
+
+				   
+			User ::RequestComplete(iCallerStatus,err);
+			iState=EWriteState;	         	  		
+			}
+			break;
+			
+	case EWriteState:
+								
+			
+			if(iChunkStatus!=KMTPChunkSequenceCompletion) 
+			{       	        	        	        
+        		iChunkStatus = iWriteData->NextReadChunk(iWriteChunk);
+	        	Socket().Write(iWriteChunk,iStatus);	
+		    	SetActive();
+			}
+		
+			else
+			{			
+				   
+			User ::RequestComplete(iCallerStatus,err);	  
+			iState=EReadState;      	  							
+			}
+			break;
+	}
+}
+
+TInt CPTPIPSocketHandler::RunError(TInt aErr)
+	{
+	User ::RequestComplete(iCallerStatus,aErr);
+	return KErrNone;
+	}
+
+
+
+void CPTPIPSocketHandler::DoCancel()
+	{
+	if(iState==EReadState)	
+	Socket().CancelRecv();
+	else if(iState==EWriteState)
+	Socket().CancelWrite();	
+	}
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipcontroller/src/cptpiptimer.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,59 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cptpiptransport.cpp
+// 
+//
+
+/**
+ @internalComponent
+*/
+
+#include "cptpiptimer.h"
+#include "cptpipcontroller.h"
+
+CPTPIPTimer::CPTPIPTimer(CPTPIPController& aController) : CTimer(CActive::EPriorityStandard)
+	{
+	iController=&aController;
+	}
+
+CPTPIPTimer* CPTPIPTimer::NewLC(CPTPIPController& aController)
+	{
+	CPTPIPTimer* self=new (ELeave) CPTPIPTimer(aController);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CPTPIPTimer* CPTPIPTimer::NewL(CPTPIPController& aController)
+	{
+	CPTPIPTimer* self = NewLC(aController);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+void CPTPIPTimer::ConstructL()
+	{
+	CTimer::ConstructL();
+	CActiveScheduler::Add(this);
+	}
+
+void CPTPIPTimer::IssueRequest(TInt aTimerValue)
+	{	
+	CTimer::After(aTimerValue * KTimerMultiplier);
+	}
+
+void CPTPIPTimer::RunL()
+	{
+ 	iController->OnTimeOut();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipcontroller/src/rptpipframework.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,43 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mtp/rptpipframework.h>
+#include "cptpipcontroller.h"
+
+EXPORT_C RPTPIPFramework::RPTPIPFramework()
+{
+	
+}
+
+EXPORT_C void RPTPIPFramework::OpenL()
+{
+	iCtrl=CPTPIPController::NewL();	
+}
+
+EXPORT_C MPTPIPController& RPTPIPFramework::Controller()
+{
+	return (MPTPIPController&)*iCtrl;
+}
+
+
+EXPORT_C void RPTPIPFramework::Close()
+{	
+	delete iCtrl;
+	iCtrl=NULL;			
+}
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,30 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// PTPIP implementation MTP/SIC device class
+// 
+//
+
+/**
+ @file
+*/
+
+PRJ_PLATFORMS
+ARMV5
+winscw
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES 
+ptpipdatatypes.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/group/ptpipdatatypes.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,51 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// ptpipdatatypes.dll which has all the ptppip datatypes derived from the generic MTPTypes
+// TODO: See about the capapbility and uid
+// 
+//
+
+/**
+ @file
+*/
+
+#include <comms-infras/commsdebugutility.mmh>
+
+
+TARGETTYPE		DLL
+TARGET			ptpipdatatypes.dll
+
+UID				0x10009D8D 0xA0004A58
+VENDORID		0x70000001
+
+CAPABILITY		All -Tcb
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+USERINCLUDE		../inc/ 
+
+SOURCEPATH		../src/
+SOURCE			cptpipgenericcontainer.cpp
+SOURCE			cptpipdatacontainer.cpp
+SOURCE			tptpipstartdatapayload.cpp
+SOURCE			tptpiprequestpayload.cpp
+SOURCE			tptpipresponsepayload.cpp
+SOURCE			cptpipinitcmdreq.cpp
+SOURCE			cptpipinitcmdack.cpp
+SOURCE			tptpipinitevtreq.cpp
+SOURCE			tptpipinitevtack.cpp
+SOURCE			tptpipinitfailed.cpp
+
+LIBRARY			euser.lib
+LIBRARY			mtpdatatypes.lib 
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/inc/cptpipdatacontainer.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,129 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#ifndef CPTPIPDATACONTINER_H_
+#define CPTPIPDATACONTINER_H_
+
+#include "ptpipdatatypes.h"
+
+/**
+ Defines the MTP PTPIP device class generic container dataset. 
+ This will contain a data payload which will have the actual mtp data. 
+
+ The structure would be as follows:
+ 1. packet length	4 bytes
+ 2. packet size		4 bytes
+ 3. payload = mtp data.
+
+ */
+class CPTPIPDataContainer : public CMTPTypeCompoundBase
+	{
+public:
+
+	/**
+	 PTPIP operation request dataset element identifiers.
+	 */
+	enum TElements
+		{
+		EPacketLength,
+		EPacketType,
+		ETransactionId,
+		EPayload,
+		ENumElements
+		};
+		
+public:
+	IMPORT_C static CPTPIPDataContainer* NewL();
+	IMPORT_C ~CPTPIPDataContainer();
+
+	IMPORT_C MMTPType* Payload() const;
+	IMPORT_C void SetPayloadL(MMTPType* aPayload);
+	IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);	
+	IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+
+public:
+	// From MMTPType	
+	IMPORT_C TUint Type() const;
+
+private:
+	// From CMTPTypeCompoundBase
+
+	const TElementInfo& ElementInfo(TInt aElementId ) const;	
+
+private:
+	CPTPIPDataContainer( );
+	void ConstructL( );
+
+private:
+
+	/**
+	 Data chunk identifiers.
+	 */
+	enum TChunkIds
+		{
+		/**
+		 The flat data chunk ID.
+		 */
+		EIdFlatChunk,
+
+		/**
+		 The EMTPExtensions element data chunk ID.
+		 */
+		EIdPayloadChunk,
+
+		/**
+		 The number of data chunks.
+		 */
+		EIdNumChunks
+		};
+
+	/**
+	 The flat data chunk comprising the header elements EPacketLength, EPacketType and the transaction Id
+	 */
+	RMTPTypeCompoundFlatChunk iChunkHeader;
+
+	/**
+	 The dataset element metadata table content.
+	 */
+	static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+
+	/**
+	 The dataset element metadata table.
+	 */
+	const TFixedArray<TElementInfo, ENumElements> iElementInfo;
+
+	/**
+	 The size in bytes of the header data chunk.
+	 */
+	static const TUint KFlatChunkSize;
+
+private:
+	MMTPType* iPayload;  // Not owned
+	
+	// If the Initiator sends the data in this form,
+	// | ptp header| content part1 | ptp header | content part2 |
+	// But,mtp framework gives us the payload as | content part1 | content part2 |
+	// thus we need to ignore the ptp header that comes second time onwards.
+	TInt iIsNextHeader;
+	
+	
+
+	};
+
+#endif /*CPTPIPCONTINERDATA_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/inc/cptpipgenericcontainer.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,119 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#ifndef CPTPIPGENERICCONTAINER_H_
+#define CPTPIPGENERICCONTAINER_H_
+
+#include "ptpipdatatypes.h"
+#include <mtp/cmtptypecompoundbase.h>
+
+/**
+ Defines the PTPIP  device class generic bulk container dataset. This is used to hold all the PTPIP packets except data packets
+ by changing the payload. It holds the packet length and packet type as its first two elements, after which it holds a payload, 
+ which will change, depending on the kind of PTPIPpacket. For eg this could be a request packet, a cancel packet or a start
+ data packet. 
+
+ Eg :  the structure of the class while getting a request can be as follows
+ 1. packet length	4 bytes
+ 2. packet size		4 bytes
+ 3. payload = request packet.
+ */
+class CPTPIPGenericContainer : public CMTPTypeCompoundBase
+	{
+public:
+
+	/**
+	 PTPIP operation dataset element identifiers.
+	 */
+	enum TElements
+		{
+		EPacketLength,
+		EPacketType,
+		EPayload,
+		ENumElements
+		};
+
+public:
+	IMPORT_C static CPTPIPGenericContainer* NewL();
+	IMPORT_C ~CPTPIPGenericContainer();
+
+	IMPORT_C MMTPType* Payload() const;
+	IMPORT_C void SetPayloadL(MMTPType* aPayload);
+
+	// from MTP
+	IMPORT_C TUint Type() const;
+
+private:
+	// from CMTPTypeCompoundBase
+	const TElementInfo& ElementInfo(TInt aElementId ) const;
+
+private:
+	CPTPIPGenericContainer( );
+	void ConstructL( );
+
+private:
+
+	/**
+	 Data chunk identifiers.
+	 */
+	enum TChunkIds
+		{
+		/**
+		 The flat data chunk ID.
+		 */
+		EIdFlatChunk,
+
+		/**
+		 The EMTPExtensions element data chunk ID.
+		 */
+		EIdPayloadChunk,
+
+		/**
+		 The number of data chunks.
+		 */
+		EIdNumChunks
+		};
+
+	/**
+	 The flat data chunk comprising the header elements EPacketLength & EPacketType
+	 */
+	RMTPTypeCompoundFlatChunk iChunkHeader;
+
+	/**
+	 The dataset element metadata table content.
+	 */
+	static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+
+	/**
+	 The dataset element metadata table.
+	 */
+	const TFixedArray<TElementInfo, ENumElements> iElementInfo;
+
+	/**
+	 The size in bytes of the header data chunk.
+	 */
+	static const TUint KFlatChunkSize;
+
+private:
+	// Not owned
+
+	MMTPType* iPayload;
+	};
+
+#endif /*CPTPIPGENERICCONTAINER_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/inc/cptpipinitcmdack.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,122 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef CPTPIPINITCMDACK_H_
+#define CPTPIPINITCMDACK_H_
+
+
+
+#include <mtp/cmtptypecompoundbase.h>
+
+
+class CPTPIPInitCmdAck : public CMTPTypeCompoundBase
+    {
+public:
+
+    /**
+    MTP USB generic bulk container dataset element identifiers.
+    */
+    enum TElements
+        {
+		ELength,
+		EPktType,
+		EConNumber,
+		EResponderGUID,
+		EVersion,
+        
+        /**
+        The number of elements.
+        */
+        ENumElements        
+ 		}; 
+public:
+    
+    IMPORT_C static CPTPIPInitCmdAck* NewL();
+    IMPORT_C ~CPTPIPInitCmdAck();
+	IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;   		
+	IMPORT_C TInt NextReadChunk(TPtrC8& aChunk)  const;
+	IMPORT_C void SetDeviceFriendlyName(TDesC16& aName); 
+	IMPORT_C TUint64 Size() const;
+     
+public: // From MMTPType
+
+	IMPORT_C TUint Type() const;
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    
+private:
+
+    CPTPIPInitCmdAck();        
+    void ConstructL();   
+    
+private: // Owned
+        
+    /**
+    Data chunk identifiers.
+    */
+    enum TChunkIds
+        {
+        /**
+        The flat data chunk ID.
+        */
+        EIdFlatChunk,
+        
+        /**
+        The EMTPExtensions element data chunk ID.
+        */
+     //   EIdNameChunk,
+        /**
+        
+        */
+        EIdVersionChunk,        
+        /**
+        The number of data chunks.
+        */
+        EIdNumChunks
+        };
+    
+    /**
+    The flat data chunk comprising the header elements EContainerLength to 
+    ETransactionId.
+    */
+    RMTPTypeCompoundFlatChunk                       iChunkHeader;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The size in bytes of the header data chunk.
+    */
+    static const TUint                              KFlatChunkSize;
+    
+private: // Not owned
+	TMTPTypeUint32									iVersion;
+    mutable TInt 									iChunkCount;
+    RBuf16   iBuffer;		           
+    };
+
+
+
+
+#endif /*CPTPIPINITCMDACK_H_*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/inc/cptpipinitcmdreq.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,123 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef CPTPIPINITCMDREQ_H_
+#define CPTPIPINITCMDREQ_H_
+#include <mtp/cmtptypecompoundbase.h>
+
+
+#include <mtp/cmtptypestring.h>
+class CPTPIPInitCmdRequest : public CMTPTypeCompoundBase
+    {
+public:
+
+    /**
+    MTP USB generic bulk container dataset element identifiers.
+    */
+    enum TElements
+        {
+		ELength,
+		EPktType,
+		EInitiatorGUID,
+
+		EVersion,
+        
+        /**
+        The number of elements.
+        */
+        ENumElements        
+ 		}; 
+public:
+    
+     IMPORT_C static CPTPIPInitCmdRequest* NewL();
+     IMPORT_C ~CPTPIPInitCmdRequest();
+    
+
+     
+public: // From MMTPType
+
+     IMPORT_C TUint Type() const;
+     IMPORT_C TDes16& HostFriendlyName();
+     IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
+	 IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
+	 IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);	
+	 
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+
+   
+
+private:
+
+    CPTPIPInitCmdRequest();        
+    void ConstructL();   
+    
+private: // Owned
+        
+    /**
+    Data chunk identifiers.
+    */
+    enum TChunkIds
+        {
+        /**
+        The flat data chunk ID.
+        */
+        EIdFlatChunk,
+        
+        /**
+        The EMTPExtensions element data chunk ID.
+        */
+   //     EIdNameChunk,
+        /**
+        
+        */
+        EIdVersionChunk,        
+        /**
+        The number of data chunks.
+        */
+        EIdNumChunks
+        };
+    
+    /**
+    The flat data chunk comprising the header elements EContainerLength to 
+    ETransactionId.
+    */
+    RMTPTypeCompoundFlatChunk                       iChunkHeader;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The size in bytes of the header data chunk.
+    */
+    static const TUint                              KFlatChunkSize;
+    
+private: // Not owned
+
+    CMTPTypeString*                                    iString; 
+    TMTPTypeUint32									iVersion;
+    TInt 									iChunkCount;
+    RBuf16   iBuffer;
+    };
+
+#endif /*CPTPIPINITCMDREQ_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/inc/ptpipdatatypes.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,68 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#ifndef CPTPIPDATATYPES_H_
+#define CPTPIPDATATYPES_H_
+
+/**
+PTPIP data types:
+1. request packet & response packet
+2. data packets: start data, data, end data
+3. cancel packet
+4. probe packet and response
+
+The structure as per the MTP type hierarchy is as follows:
+
+One ptpip container of the mtp compound type for the generic use ( it would be 
+used for everything except the data phase commands). This contains the type and 
+length as its first 8 bytes. The next part is the payload, which can be of the 
+following types:
+1. Request type 
+2. Cancel type
+3. Start data type
+ 
+One generic ptpip container of the Mtp compound type for the data phase. This 
+contains the len, type and transaction id as its first 12 bytes. The next part 
+is the payload which is provided by the mtp framework. 
+*/
+   
+#include <mtp/cmtptypecompoundbase.h>
+#include <mtp/mtpdatatypeconstants.h>
+
+/**
+PTPIP MTP device class data type identifiers. 
+*/
+
+enum TMTPPTPIPTypeIds
+	{
+	EPTPIPTypeRequestPayload    = (EMTPFirstTransportDataType + 0x100),   
+	EPTPIPTypeResponsePayload   = (EMTPFirstTransportDataType + 0x101),
+	EPTPIPTypeStartDataPayload 	= (EMTPFirstTransportDataType + 0x102),
+	EPTPIPTypeGenericContainer	= (EMTPFirstTransportDataType + 0x103),
+	EPTPIPTypeDataContainer		= (EMTPFirstTransportDataType + 0x104),
+	EPTPIPTypeInitCmdRequest	= (EMTPFirstTransportDataType + 0x105),
+	EPTPIPTypeInitCmdAck		= (EMTPFirstTransportDataType + 0x106),
+	EPTPIPTypeInitEvtRequest	= (EMTPFirstTransportDataType + 0x107),
+	EPTPIPTypeInitEvtAck		= (EMTPFirstTransportDataType + 0x108),
+	EPTPIPTypeInitFail		    = (EMTPFirstTransportDataType + 0x109)
+	
+	};
+
+
+#endif /*CPTPIPDATATYPES_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/inc/tptpipinitevtack.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,75 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+#ifndef _TPTPIPInitEvtAck_H_
+#define _TPTPIPInitEvtAck_H_
+
+#include <mtp/tmtptypeflatbase.h>
+
+/**
+Defines the PTP/IP InitAck DataSet.
+@internalComponent
+ */
+class TPTPIPInitEvtAck: public TMTPTypeFlatBase 
+    {
+public:
+
+	/**
+	PTP/IP Init Ack packet.
+	*/
+    enum TElements
+        {
+        ELength,
+        EType,
+        ENumElements
+        };
+        
+public:
+    IMPORT_C TPTPIPInitEvtAck();
+     
+public: // From TMTPTypeFlatBase
+    IMPORT_C TUint Type() const;
+    
+private: // From TMTPTypeFlatBase
+    IMPORT_C const TMTPTypeFlatBase::TElementInfo& ElementInfo(TInt aElementId) const;
+
+private:
+	/**
+	The dataset size in bytes.
+	*/
+    static const TInt                               KSize = 8;
+    
+	/**
+	The dataset element metadata table content.
+	*/
+    static const TMTPTypeFlatBase::TElementInfo     iElementMetaData[];
+    
+	/**
+	The dataset element metadata table.
+	*/
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+	/**
+	The data buffer.
+	*/
+    TBuf8<KSize>                                    iBuffer;        
+    };
+
+#endif // _TPTPIPInitEvtAck_H_
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/inc/tptpipinitevtreq.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,82 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+#ifndef TPTPIPINITEVTREQ_H_
+#define TPTPIPINITEVTREQ_H_
+
+#include <mtp/tmtptypeflatbase.h>
+
+/**
+Defines the MTP USB device class control request setup dataset.
+@internalComponent
+ 
+*/
+class TPTPIPInitEvtRequest : public TMTPTypeFlatBase 
+    {
+    
+public:
+
+    /**
+    MTP USB control request setup dataset element identifiers.
+    */
+    enum TElements
+        {
+        ELength,
+        EType,
+		EconNumber,
+        ENumElements
+        };
+        
+public:
+
+    IMPORT_C TPTPIPInitEvtRequest();
+     
+public: // From TMTPTypeFlatBase
+
+    IMPORT_C TUint Type() const;
+    
+private: // From TMTPTypeFlatBase
+
+    IMPORT_C const TMTPTypeFlatBase::TElementInfo& ElementInfo(TInt aElementId) const;
+
+private:
+   
+    /**
+    The dataset size in bytes.
+    */
+    static const TInt                               KSize = 12;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const TMTPTypeFlatBase::TElementInfo     iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The data buffer.
+    */
+    TBuf8<KSize>                                    iBuffer;        
+    };
+
+#endif // TPTPIPINITEVTREQ_H_
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/inc/tptpipinitfailed.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,82 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+#ifndef _TPTPIPINITFAILED_H_
+#define _TPTPIPINITFAILED_H_
+
+#include <mtp/tmtptypeflatbase.h>
+
+/**
+Defines the PTP/IP InitFailed DataSet.
+@internalComponent
+ 
+*/
+class TPTPIPInitFailed: public TMTPTypeFlatBase 
+    {
+    
+public:
+
+    /**
+    PTP/IP Init Failed packet.
+    */
+    enum TElements
+        {
+        ELength,
+        EType,
+		EReason,
+        ENumElements
+        };
+        
+public:
+
+    IMPORT_C TPTPIPInitFailed();
+     
+public: // From TMTPTypeFlatBase
+
+    IMPORT_C TUint Type() const;
+    
+private: // From TMTPTypeFlatBase
+
+    IMPORT_C const TMTPTypeFlatBase::TElementInfo& ElementInfo(TInt aElementId) const;
+
+private:
+   
+    /**
+    The dataset size in bytes.
+    */
+    static const TInt                               KSize = 12;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const TMTPTypeFlatBase::TElementInfo     iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The data buffer.
+    */
+    TBuf8<KSize>                                    iBuffer;        
+    };
+
+#endif // _TPTPIPINITFAILED_H_
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/inc/tptpiprequestpayload.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,107 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#ifndef CPTPIPPAYLOADREQUEST_H_
+#define CPTPIPPAYLOADREQUEST_H_
+
+#include "ptpipdatatypes.h"
+
+/**
+ Defines the PTPIP dataset for the ptpip request operation. This is used 
+ as the payload in the generic container when the PTPIP request operation is sent. 
+ */
+class TPTPIPTypeRequestPayload : public TMTPTypeFlatBase
+	{
+public:
+
+	/**
+	 PTPIP operation request dataset element identifiers.
+	 */
+	enum TElements
+		{
+		EDataPhase,
+		EOpCode,
+		ETransactionId,
+		EParameter1,
+		EParameter2,
+		EParameter3,
+		EParameter4,
+		EParameter5,
+		ENumElements
+		};
+
+public:
+	IMPORT_C TPTPIPTypeRequestPayload();
+	IMPORT_C TUint NumParameters() const;
+	IMPORT_C void CopyIn(const TMTPTypeFlatBase& aFrom, TUint aParamStartOffset, TUint aParamEndOffSet, TBool aIsNullParamValid, TUint aNumOfNullParam);
+	IMPORT_C void CopyOut(TMTPTypeFlatBase& aTo, TUint aParamStartOffset, TUint aParamEndOffset);
+
+public:
+	// From TMTPTypeFlatBase
+	IMPORT_C void Reset();
+	IMPORT_C void SetUint16(TInt aElementId, TUint16 aData);
+	IMPORT_C TUint16 Uint16(TInt aElementId) const;
+	IMPORT_C void SetUint32(TInt aElementId, TUint32 aData);
+	IMPORT_C TUint32 Uint32(TInt aElementId) const;
+	IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+	IMPORT_C TUint64 Size() const;
+	IMPORT_C TUint Type() const;
+	IMPORT_C TBool CommitRequired() const;
+	IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+
+private:
+	// From TMTPTypeFlatBase
+	IMPORT_C const TMTPTypeFlatBase::TElementInfo& ElementInfo(TInt aElementId) const;
+
+private:
+	/**
+	 The dataset size in bytes.
+	 */
+	static const TInt KSize = 30;
+
+	/**
+	 The size of the 3 header elements - data phase, op code and transaction id
+	 */
+	static const TInt KHeaderElementsSize = 10;
+
+	/**
+	 The dataset element metadata table content.
+	 */
+	static const TMTPTypeFlatBase::TElementInfo iElementMetaData[];
+
+	/**
+	 The dataset element metadata table.
+	 */
+	const TFixedArray<TElementInfo, ENumElements> iElementInfo;
+
+	/**
+	 The data buffer.
+	 */
+	TBuf8<KSize> iBuffer;
+
+	/**
+	 The number of parameters(EParameter1 to EParameter5)  in the block which are set.
+	 It will be between 1 to 5 and 
+	 will never include the count of the first 3 header elements- data phase, op code and tran id.
+	 */
+//	TUint iNumParameters;
+	TUint iMaxSetParam;
+	};
+
+#endif /*CPTPIPPAYLOADREQUEST_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/inc/tptpipresponsepayload.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,108 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// tptpippayloadresponse.h
+// 
+//
+
+/**
+ @internalComponent
+*/
+
+#ifndef CPTPIPPAYLOADRESPONSE_H_
+#define CPTPIPPAYLOADRESPONSE_H_
+
+#include "ptpipdatatypes.h"
+
+/**
+ Defines the PTPIP dataset for the ptpip response operation. This is used 
+ as the payload in the generic container when the PTPIP response operation is sent. 
+ */
+class TPTPIPTypeResponsePayload : public TMTPTypeFlatBase
+	{
+public:
+
+	/**
+	 PTPIP operation request dataset element identifiers.
+	 */
+	enum TElements
+		{
+		EResponseCode,
+		ETransactionId,
+		EParameter1,
+		EParameter2,
+		EParameter3,
+		EParameter4,
+		EParameter5,
+		ENumElements
+		};
+
+public:
+	IMPORT_C TPTPIPTypeResponsePayload();
+	IMPORT_C TUint NumParameters() const;
+	IMPORT_C void CopyIn(const TMTPTypeFlatBase& aFrom, TUint aParamStartOffset, TUint aParamEndOffSet, TBool aIsNullParamValid, TUint aNumOfNullParam);
+	IMPORT_C void CopyOut(TMTPTypeFlatBase& aTo, TUint aParamStartOffset, TUint aParamEndOffset);
+
+public:
+	// From TMTPTypeFlatBase
+	IMPORT_C void Reset();
+	IMPORT_C void SetUint16(TInt aElementId, TUint16 aData);
+	IMPORT_C TUint16 Uint16(TInt aElementId) const;
+	IMPORT_C void SetUint32(TInt aElementId, TUint32 aData);
+	IMPORT_C TUint32 Uint32(TInt aElementId) const;
+	IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+	IMPORT_C TUint64 Size() const;
+	IMPORT_C TUint Type() const;
+	IMPORT_C TBool CommitRequired() const;
+	IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+
+private:
+	// From TMTPTypeFlatBase
+	IMPORT_C const TMTPTypeFlatBase::TElementInfo& ElementInfo(TInt aElementId) const;
+
+private:
+
+	/**
+	 The dataset size in bytes.
+	 */
+	static const TInt KSize = 26;
+
+	/**
+	 The size of the 2 header elements - response code and transaction id
+	 */
+	static const TInt KHeaderElementsSize = 6;
+
+	/**
+	 The dataset element metadata table content.
+	 */
+	static const TMTPTypeFlatBase::TElementInfo iElementMetaData[];
+
+	/**
+	 The dataset element metadata table.
+	 */
+	const TFixedArray<TElementInfo, ENumElements> iElementInfo;
+
+	/**
+	 The data buffer.
+	 */
+	TBuf8<KSize> iBuffer;
+
+	/**
+	 The number of parameters in the block which are set.
+	 */
+	//TUint iNumParameters;
+	TUint iMaxSetParam;
+
+	};
+
+#endif /*CPTPIPPAYLOADRESPONSE_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/inc/tptpipstartdatapayload.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,88 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// ptpipstartdatapayload.h
+// 
+//
+
+/**
+ @internalComponent
+*/
+
+#ifndef CPTPIPPAYLOADSTARTDATA_H_
+#define CPTPIPPAYLOADSTARTDATA_H_
+
+#include "ptpipdatatypes.h"
+
+/**
+ Defines the PTPIP dataset for the start data operation. This is used as the 
+ payload in the generic container when the start data PTPIP operation is sent.
+ */
+class TPTPIPTypeStartDataPayload : public TMTPTypeFlatBase
+	{
+public:
+
+	/**
+	 PTPIP operation startdata's dataset element identifiers.
+	 */
+	enum TElements
+		{
+		ETransactionId,
+		ETotalSize,
+		ENumElements
+		};
+
+public:
+	IMPORT_C TPTPIPTypeStartDataPayload();
+
+public:
+	// From TMTPTypeFlatBase
+	IMPORT_C void Reset();
+	IMPORT_C void SetUint32(TInt aElementId, TUint32 aData);
+	IMPORT_C TUint32 Uint32(TInt aElementId) const;
+	IMPORT_C void SetUint64(TInt aElementId, TUint64 aData);
+	IMPORT_C TUint64 Uint64(TInt aElementId) const;
+	IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+	IMPORT_C TUint64 Size() const;
+	IMPORT_C TUint Type() const;
+	IMPORT_C TBool CommitRequired() const;
+	IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+
+private:
+	// From TMTPTypeFlatBase
+	IMPORT_C const TMTPTypeFlatBase::TElementInfo& ElementInfo(TInt aElementId) const;
+
+private:
+
+	/**
+	 The dataset size in bytes.
+	 */
+	static const TInt KSize = 12;
+
+	/**
+	 The dataset element metadata table content.
+	 */
+	static const TMTPTypeFlatBase::TElementInfo iElementMetaData[];
+
+	/**
+	 The dataset element metadata table.
+	 */
+	const TFixedArray<TElementInfo, ENumElements> iElementInfo;
+
+	/**
+	 The data buffer.
+	 */
+	TBuf8<KSize> iBuffer;
+	};
+
+#endif /*CPTPIPPAYLOADSTARTDATA_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/src/cptpipdatacontainer.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,196 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#include "ptpipdatatypes.h"
+#include "cptpipdatacontainer.h"
+
+// Dataset constants
+const TUint CPTPIPDataContainer::KFlatChunkSize(12);
+
+// Dataset element metadata.
+const CMTPTypeCompoundBase::TElementInfo CPTPIPDataContainer::iElementMetaData[CPTPIPDataContainer::ENumElements] = 
+    {
+		{EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT32,    0,                  KMTPTypeUINT32Size}},   // EContainerLength
+        {EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT32,    4,                  KMTPTypeUINT32Size}},   // EContainerType
+        {EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT32,    8,                  KMTPTypeUINT32Size}},   // ETransactionId
+		{EIdPayloadChunk,   EMTPTypeUndefined,  {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}}     // EPayload
+    };
+
+/**
+ Generic Container's factory method. 
+ This is used to create an empty MTP PTPIP data container dataset type. 
+ @return  Ownership IS transfered.
+ @leave One of the system wide error codes, if unsuccessful.
+ */
+EXPORT_C CPTPIPDataContainer* CPTPIPDataContainer::NewL()
+	{
+	CPTPIPDataContainer* self = new (ELeave) CPTPIPDataContainer();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+ Destructor.
+ */
+EXPORT_C CPTPIPDataContainer::~CPTPIPDataContainer()
+	{
+	iChunkHeader.Close();
+	}
+
+/**
+ Constructor.
+ */
+CPTPIPDataContainer::CPTPIPDataContainer( ) :
+	CMTPTypeCompoundBase((!KJustInTimeConstruction), EIdNumChunks), iChunkHeader(
+			KFlatChunkSize, *this),
+			iElementInfo(iElementMetaData, ENumElements),iIsNextHeader(EFalse)
+	{
+	
+	}
+
+/**
+ Second phase constructor.
+ */
+void CPTPIPDataContainer::ConstructL( )
+	{
+	iChunkHeader.OpenL ( );
+	ChunkAppendL (iChunkHeader );
+	}
+
+/**
+ Provides the bulk container payload.
+ @return The bulk container payload.
+ */
+EXPORT_C MMTPType* CPTPIPDataContainer::Payload() const
+	{
+	return iPayload;
+	}
+
+/**
+ Sets the bulk container payload.
+ @param aPayload The new bulk container payload.
+ */
+EXPORT_C void CPTPIPDataContainer::SetPayloadL(MMTPType* aPayload)
+	{
+	if (iPayload)
+		{
+		// Remove the existing payload from the super class.
+		ChunkRemove(iElementMetaData[EPayload].iChunkId);
+		}
+
+	if (aPayload)
+		{
+		// Pass the payload to the super class for management.
+		ChunkAppendL(*aPayload);
+		}
+	iPayload = aPayload;
+	iIsNextHeader = EFalse; 
+	}
+
+EXPORT_C TUint CPTPIPDataContainer::Type() const
+	{
+	return EPTPIPTypeDataContainer;
+	}
+
+const CMTPTypeCompoundBase::TElementInfo& CPTPIPDataContainer::ElementInfo(
+		TInt aElementId ) const
+	{
+	__ASSERT_DEBUG((aElementId < ENumElements), User::Invariant());
+	return iElementInfo[aElementId];
+	}
+	
+/**
+  Over-ridden implementation of FirstWriteChunk() derived from CMTPTypeCompoundBase.
+  This sets the Write Sequence-State to EInProgressNext, forcing the headers, from the second 
+  PTP/IP packet onwards,to be ignored
+  @param aChunk The data that is currently given by Initiator
+ **/
+EXPORT_C TInt CPTPIPDataContainer::FirstWriteChunk(TPtr8& aChunk)
+	        {
+	        TInt err(KErrNone);	        
+	        
+	        aChunk.Set(NULL, 0, 0);
+	        
+	        
+	        if (iChunks.Count() == 0)
+	            {
+	            err = KErrNotFound;            
+	            }
+	        else
+	            {
+	            iWriteChunk = 0;
+	            
+	            TInt iWriteErr = iChunks[iWriteChunk]->FirstWriteChunk(aChunk);
+	            
+	            if ((iIsNextHeader) && (iWriteErr == KMTPChunkSequenceCompletion))
+	            	iWriteErr = KErrNone;
+	            
+		        switch (iWriteErr)
+		            {
+		        case KMTPChunkSequenceCompletion:
+		            if ((iWriteChunk + 1) < iChunks.Count()) 
+		                {
+		                iWriteSequenceState = EInProgressFirst;
+		                err = KErrNone;
+		                }
+		            else
+		                {
+		                iWriteSequenceState = EIdle;                 
+		                }
+		            break;
+		            
+		        case KErrNone:
+		            iWriteSequenceState = EInProgressNext;
+		            break;
+		            
+		        default:
+		            break;                      
+	           } 
+	            } 
+	        
+	        iIsNextHeader = ETrue;
+	        
+	        return err;
+	        }
+
+/**
+  Over-ridden implementation of CommitChunkL() derived from CMTPTypeCompoundBase.
+  This increments the number of chunks read only after, the first header is read
+  @param aChunk The data that is currently given by Initiator
+ **/
+EXPORT_C MMTPType* CPTPIPDataContainer::CommitChunkL(TPtr8& aChunk)
+	    {       
+	    MMTPType *chunk(iChunks[iWriteChunk]);
+	    MMTPType* res = NULL;
+	    if (chunk->CommitRequired())
+	        {
+	        res = chunk->CommitChunkL(aChunk);
+	        }
+	        
+	    
+	    if (iWriteChunk == 0)
+	        {
+	        iWriteChunk++;            
+	        }
+
+	    return res;
+	    }
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/src/cptpipgenericcontainer.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,116 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#include "ptpipdatatypes.h"
+#include "cptpipgenericcontainer.h"
+
+// Dataset constants
+const TUint CPTPIPGenericContainer::KFlatChunkSize(8);
+
+// Dataset element metadata.
+const CMTPTypeCompoundBase::TElementInfo CPTPIPGenericContainer::iElementMetaData[CPTPIPGenericContainer::ENumElements] = 
+    {
+        {EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT32,    0,                  KMTPTypeUINT32Size}},   // EContainerLength
+        {EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT32,    4,                  KMTPTypeUINT32Size}},   // EContainerType
+		{EIdPayloadChunk,   EMTPTypeUndefined,  {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}}     // EPayload
+    };
+
+/**
+ Generic Container's factory method. 
+ This is used to create an empty MTP PTPIP generic container dataset type. 
+ @return  Ownership IS transfered.
+ @leave One of the system wide error codes, if unsuccessful.
+ */
+EXPORT_C CPTPIPGenericContainer* CPTPIPGenericContainer::NewL()
+	{
+	CPTPIPGenericContainer* self = new (ELeave) CPTPIPGenericContainer();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+ Destructor.
+ */
+EXPORT_C CPTPIPGenericContainer::~CPTPIPGenericContainer()
+	{
+	iChunkHeader.Close();
+	}
+
+/**
+ Constructor.
+ */
+CPTPIPGenericContainer::CPTPIPGenericContainer( ) :
+	CMTPTypeCompoundBase((!KJustInTimeConstruction), EIdNumChunks), iChunkHeader(
+			KFlatChunkSize, *this),
+			iElementInfo(iElementMetaData, ENumElements)
+	{
+
+	}
+
+/**
+ Second phase constructor.
+ */
+void CPTPIPGenericContainer::ConstructL( )
+	{
+	iChunkHeader.OpenL ( );
+	ChunkAppendL (iChunkHeader );
+	}
+/**
+ Provides the container payload.
+ @return The container payload.
+ */
+EXPORT_C MMTPType* CPTPIPGenericContainer::Payload() const
+	{
+	return iPayload;
+	}
+
+/**
+ Sets the container payload.
+ @param aPayload The new container payload.
+ */
+EXPORT_C void CPTPIPGenericContainer::SetPayloadL(MMTPType* aPayload)
+	{
+	if (iPayload)
+		{
+		// Remove the existing payload from the super class.
+		ChunkRemove(iElementMetaData[EPayload].iChunkId);
+		}
+
+	if (aPayload)
+		{
+		// Pass the payload to the super class for management.
+		ChunkAppendL(*aPayload);
+		}
+	iPayload = aPayload;
+	}
+
+EXPORT_C TUint CPTPIPGenericContainer::Type() const
+	{
+	return EPTPIPTypeGenericContainer;
+	}
+
+const CMTPTypeCompoundBase::TElementInfo& CPTPIPGenericContainer::ElementInfo(
+		TInt aElementId ) const
+	{
+	__ASSERT_DEBUG((aElementId < ENumElements), User::Invariant());
+	return iElementInfo[aElementId];
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/src/cptpipinitcmdack.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,119 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#include "cptpipinitcmdack.h"
+#include "ptpipdatatypes.h"   
+// Dataset constants
+const TUint CPTPIPInitCmdAck::KFlatChunkSize(28);  
+const CMTPTypeCompoundBase::TElementInfo CPTPIPInitCmdAck::iElementMetaData[CPTPIPInitCmdAck::ENumElements] = 
+    {
+        {EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT32,	0,					KMTPTypeUINT32Size}},   // ELength
+		{EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT32,	4,					KMTPTypeUINT32Size}},   // EType
+		{EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT32,	8,					KMTPTypeUINT32Size}},   // EConNumber
+		{EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT128,	12,					KMTPTypeUINT128Size}},   // GUID
+	//	{EIdNameChunk,      EMTPTypeString,     {EMTPTypeString,    KMTPNotApplicable,	KMTPNotApplicable}},   // friendly name
+        {EIdVersionChunk,	EMTPTypeUINT32,     {EMTPTypeUINT32,    KMTPNotApplicable,	KMTPNotApplicable}}   // version
+        
+    };
+
+EXPORT_C  CPTPIPInitCmdAck* CPTPIPInitCmdAck::NewL()
+    {
+    CPTPIPInitCmdAck* self = new (ELeave) CPTPIPInitCmdAck(); 
+    CleanupStack::PushL(self); 
+    self->ConstructL();   
+    CleanupStack::Pop(self);
+    return self; 
+    }
+/**
+Constructor.
+*/
+EXPORT_C CPTPIPInitCmdAck::CPTPIPInitCmdAck() : 
+    CMTPTypeCompoundBase((!KJustInTimeConstruction), EIdNumChunks), 
+    iChunkHeader(KFlatChunkSize, *this),
+    iElementInfo(iElementMetaData, ENumElements)
+    {
+    
+    }
+
+/**
+Destructor.
+*/
+ EXPORT_C CPTPIPInitCmdAck::~CPTPIPInitCmdAck()
+    {
+    iChunkHeader.Close();
+    iBuffer.Close();
+    }
+    /**
+Second phase constructor.
+*/   
+ void CPTPIPInitCmdAck::ConstructL()
+    {
+    iChunkHeader.OpenL();
+    ChunkAppendL(iChunkHeader);
+    ChunkAppendL(iVersion);
+   iChunkCount = EIdNumChunks;    
+    }
+    
+    
+ EXPORT_C TUint CPTPIPInitCmdAck::Type() const
+    {
+    return EPTPIPTypeInitCmdAck;
+    } 
+const CMTPTypeCompoundBase::TElementInfo& CPTPIPInitCmdAck::ElementInfo(TInt aElementId) const
+    {
+    __ASSERT_DEBUG((aElementId < ENumElements), User::Invariant());
+    return iElementInfo[aElementId];
+    }
+    
+ EXPORT_C TInt CPTPIPInitCmdAck::FirstReadChunk(TPtrC8& aChunk) const
+{
+	iChunkCount = EIdFlatChunk;
+	return CMTPTypeCompoundBase::FirstReadChunk(aChunk);
+	
+}   		
+EXPORT_C TInt CPTPIPInitCmdAck::NextReadChunk(TPtrC8& aChunk) const
+{
+	TInt ret = KErrNone;
+	if(iChunkCount == EIdFlatChunk)
+		{	
+		aChunk.Set((const TUint8*)&iBuffer[0],iBuffer.Size());		
+		}
+	else
+		{
+		ret = CMTPTypeCompoundBase::NextReadChunk(aChunk);	
+		}
+	iChunkCount++;
+	return ret;
+}
+
+
+
+EXPORT_C  void CPTPIPInitCmdAck::SetDeviceFriendlyName(TDesC16& aName)
+{
+	iBuffer.Create(aName,aName.Length()+KMTPNullCharLen);
+	iBuffer.Append(KMTPNullChar);
+}    
+
+EXPORT_C TUint64 CPTPIPInitCmdAck::Size() const
+{
+	TUint64 size = CMTPTypeCompoundBase::Size();
+	size += iBuffer.Size();
+	return size;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/src/cptpipinitcmdreq.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,132 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+
+#include "cptpipinitcmdreq.h"
+#include "ptpipdatatypes.h"    
+
+
+
+
+// Dataset constants
+const TUint CPTPIPInitCmdRequest::KFlatChunkSize(24);  
+const CMTPTypeCompoundBase::TElementInfo CPTPIPInitCmdRequest::iElementMetaData[CPTPIPInitCmdRequest::ENumElements] = 
+    {
+        {EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT32,	0,					KMTPTypeUINT32Size}},   // ELength
+		{EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT32,	4,					KMTPTypeUINT32Size}},   // EType
+		{EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT128,	8,					KMTPTypeUINT128Size}},   // GUID
+	//	{EIdNameChunk,      EMTPTypeUndefined,     {EMTPTypeUndefined,    KMTPNotApplicable,	KMTPNotApplicable}},   // friendly name
+        {EIdVersionChunk,	EMTPTypeUINT32,     {EMTPTypeUINT32,    KMTPNotApplicable,	KMTPNotApplicable}}   // version
+        
+    };
+
+EXPORT_C  CPTPIPInitCmdRequest* CPTPIPInitCmdRequest::NewL()
+    {
+    CPTPIPInitCmdRequest* self = new (ELeave) CPTPIPInitCmdRequest(); 
+    CleanupStack::PushL(self); 
+    self->ConstructL();   
+    CleanupStack::Pop(self);
+    return self; 
+    }
+/**
+Constructor.
+*/
+EXPORT_C CPTPIPInitCmdRequest::CPTPIPInitCmdRequest() : 
+    CMTPTypeCompoundBase((!KJustInTimeConstruction), EIdNumChunks), 
+    iChunkHeader(KFlatChunkSize, *this),
+    iElementInfo(iElementMetaData, ENumElements),iBuffer()
+    {
+    
+    }
+
+/**
+Destructor.
+*/
+ EXPORT_C CPTPIPInitCmdRequest::~CPTPIPInitCmdRequest()
+    {
+    iChunkHeader.Close();
+    iBuffer.Close();
+    }
+    /**
+Second phase constructor.
+*/   
+ void CPTPIPInitCmdRequest::ConstructL()
+    {
+    iChunkHeader.OpenL();
+    ChunkAppendL(iChunkHeader);
+    ChunkAppendL(iVersion);
+   iChunkCount = EIdNumChunks;
+    
+    }
+    
+    
+ EXPORT_C TUint CPTPIPInitCmdRequest::Type() const
+    {
+    return EPTPIPTypeInitCmdRequest;
+    } 
+const CMTPTypeCompoundBase::TElementInfo& CPTPIPInitCmdRequest::ElementInfo(TInt aElementId) const
+    {
+    __ASSERT_DEBUG((aElementId < ENumElements), User::Invariant());
+    return iElementInfo[aElementId];
+    }
+EXPORT_C TInt CPTPIPInitCmdRequest::FirstWriteChunk(TPtr8& aChunk)
+{
+	iChunkCount = EIdFlatChunk;
+	return CMTPTypeCompoundBase::FirstWriteChunk(aChunk);
+	
+}
+EXPORT_C TInt CPTPIPInitCmdRequest::NextWriteChunk(TPtr8& aChunk)
+{
+	TInt ret = KErrNone;
+	if(iChunkCount == EIdFlatChunk)
+		{	
+		
+		TUint32 size(Uint32L(CPTPIPInitCmdRequest::ELength));
+		size-=28;
+		size/=2;
+		TRAP_IGNORE(iBuffer.CreateMaxL(size));
+		
+		size = iBuffer.Size();
+		aChunk.Set((TUint8*)&iBuffer[0],iBuffer.Size(),iBuffer.Size());
+		
+		}
+	else
+		{
+		ret = CMTPTypeCompoundBase::NextWriteChunk(aChunk);	
+		}
+	iChunkCount++;
+	return ret;
+}
+
+EXPORT_C MMTPType* CPTPIPInitCmdRequest::CommitChunkL(TPtr8& aChunk)
+{
+
+	if(iChunkCount != EIdVersionChunk)
+		{
+		return CMTPTypeCompoundBase::CommitChunkL(aChunk);
+			
+		}
+	return NULL;	
+}
+
+EXPORT_C TDes16& CPTPIPInitCmdRequest::HostFriendlyName()
+{
+return iBuffer;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/src/tptpipinitevtack.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,49 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#include "tptpipinitevtack.h"
+#include "ptpipdatatypes.h"
+    
+// Dataset element metadata.
+const TPTPIPInitEvtAck::TElementInfo TPTPIPInitEvtAck::iElementMetaData[ENumElements] = 
+    {
+        {EMTPTypeUINT32,	0,	KMTPTypeUINT32Size}, // ELength
+        {EMTPTypeUINT32,	4,	KMTPTypeUINT32Size}, // EType
+    }; 
+
+/** 
+Constructor
+*/
+EXPORT_C TPTPIPInitEvtAck::TPTPIPInitEvtAck() :
+    iElementInfo(iElementMetaData, ENumElements),
+    iBuffer(KSize)
+    {
+    SetBuffer(iBuffer);
+    }     
+
+EXPORT_C TUint TPTPIPInitEvtAck::Type() const
+	{
+	return EPTPIPTypeInitEvtAck ;
+	}
+    
+EXPORT_C const TMTPTypeFlatBase::TElementInfo& TPTPIPInitEvtAck::ElementInfo(TInt aElementId) const
+    {
+    __ASSERT_DEBUG((aElementId < ENumElements), User::Invariant());
+    return iElementInfo[aElementId];
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/src/tptpipinitevtreq.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,53 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// tptpipinitevetreq.cpp
+// 
+//
+
+/**
+ @internalComponent
+*/
+
+
+#include "tptpipinitevtreq.h"
+#include "ptpipdatatypes.h"     
+// Dataset element metadata.
+const TPTPIPInitEvtRequest::TElementInfo TPTPIPInitEvtRequest::iElementMetaData[ENumElements] = 
+    {
+        {EMTPTypeUINT32,	0,	KMTPTypeUINT32Size},     // EbmRequestType
+        {EMTPTypeUINT32,	4,	KMTPTypeUINT32Size},     // EbRequest
+        {EMTPTypeUINT32,	8,	KMTPTypeUINT32Size},    // EwValue
+    }; 
+
+/** 
+Constructor
+*/
+EXPORT_C TPTPIPInitEvtRequest::TPTPIPInitEvtRequest() :
+    iElementInfo(iElementMetaData, ENumElements),
+    iBuffer(KSize)
+    {
+    SetBuffer(iBuffer);
+    }     
+
+EXPORT_C TUint TPTPIPInitEvtRequest::Type() const
+	{
+	return EPTPIPTypeInitEvtRequest;
+	}
+    
+EXPORT_C const TMTPTypeFlatBase::TElementInfo& TPTPIPInitEvtRequest::ElementInfo(TInt aElementId) const
+    {
+    __ASSERT_DEBUG((aElementId < ENumElements), User::Invariant());
+    return iElementInfo[aElementId];
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/src/tptpipinitfailed.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,51 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+
+#include "tptpipinitfailed.h"
+#include "ptpipdatatypes.h"    
+// Dataset element metadata.
+const TPTPIPInitFailed::TElementInfo TPTPIPInitFailed::iElementMetaData[ENumElements] = 
+    {
+        {EMTPTypeUINT32,	0,	KMTPTypeUINT32Size},     // EbmRequestType
+        {EMTPTypeUINT32,	4,	KMTPTypeUINT32Size},     // EbRequest
+        {EMTPTypeUINT32,	8,	KMTPTypeUINT32Size},    // EwValue
+    }; 
+
+/** 
+Constructor
+*/
+EXPORT_C TPTPIPInitFailed::TPTPIPInitFailed() :
+    iElementInfo(iElementMetaData, ENumElements),
+    iBuffer(KSize)
+    {
+    SetBuffer(iBuffer);
+    }     
+
+EXPORT_C TUint TPTPIPInitFailed::Type() const
+	{
+	return EPTPIPTypeInitFail;
+	}
+    
+EXPORT_C const TMTPTypeFlatBase::TElementInfo& TPTPIPInitFailed::ElementInfo(TInt aElementId) const
+    {
+    __ASSERT_DEBUG((aElementId < ENumElements), User::Invariant());
+    return iElementInfo[aElementId];
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/src/tptpiprequestpayload.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,236 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#include <mtp/mtpprotocolconstants.h>
+#include "ptpipdatatypes.h"
+#include "tptpiprequestpayload.h"
+
+// Dataset element metadata.
+const TPTPIPTypeRequestPayload::TElementInfo
+		TPTPIPTypeRequestPayload::iElementMetaData[ENumElements] =
+			{
+				{EMTPTypeUINT32, 0, KMTPTypeUINT32Size	}, // EDataPhase
+				{EMTPTypeUINT16, 4, KMTPTypeUINT16Size	}, // EOpCode
+				{EMTPTypeUINT32, 6, KMTPTypeUINT32Size	}, // ETransactionId
+				{EMTPTypeUINT32, 10, KMTPTypeUINT32Size	}, // EParameter1
+				{EMTPTypeUINT32, 14, KMTPTypeUINT32Size	}, // EParameter2
+				{EMTPTypeUINT32, 18, KMTPTypeUINT32Size	}, // EParameter3
+				{EMTPTypeUINT32, 22, KMTPTypeUINT32Size	}, // EParameter4
+				{EMTPTypeUINT32, 26, KMTPTypeUINT32Size	}  // EParameter5
+			};
+
+/**
+ Constructor.
+ */
+EXPORT_C TPTPIPTypeRequestPayload::TPTPIPTypeRequestPayload( ) :
+iElementInfo(iElementMetaData, ENumElements),
+iBuffer(KSize),
+//iNumParameters(0)
+iMaxSetParam(0)
+	{
+	SetBuffer (iBuffer );
+	}
+
+/**
+ Provides the number of parameters in the block which are set.
+ @return the number of set parameters.
+ */
+EXPORT_C TUint TPTPIPTypeRequestPayload::NumParameters() const
+	{
+	//return iNumParameters;
+	//return (iMaxSetParam - EParameter1 + 1);
+	return (iMaxSetParam > 0 )? (iMaxSetParam - EParameter1 + 1) : 0;
+	}
+
+/**
+ Copies up to five parameter values into the parameter block dataset from the specified dataset. 
+ The paramters to be copied should be non null paramter or valid null paramter.
+
+ @param aFrom The parameter values source dataset. This dataset should define three or five contiguous 32-bit parameter values starting at the specified offset.
+ @param aParamStartOffset The element ID of the first in the set of contiguous 
+ source dataset parameter values.
+ @param aParamEndOffset The element ID of the last in the set of contiguous 
+ source dataset parameter values.
+ @param aIsNullParamValid a boolean value to check if a null parameter is valid. A value of ETrue means a null parameter is valid; EFalse means invalid.
+ @param aNumOfNullParam the number of valid null parameters to be copied.
+ */
+EXPORT_C void TPTPIPTypeRequestPayload::CopyIn( const TMTPTypeFlatBase& aFrom,
+		TUint aParamStartOffset, TUint aParamEndOffset,
+		TBool aIsNullParamValid, TUint aNumOfNullParam )
+
+	{
+	__ASSERT_DEBUG((aParamEndOffset >= aParamStartOffset && (aParamEndOffset - aParamStartOffset + 1) <= ENumElements), User::Invariant());
+	TUint32 parameter = 0;
+	TUint numberOfNullParam = 0;
+
+	for (TUint t(EParameter1), s(aParamStartOffset); s <= aParamEndOffset; t++, s++)
+		{
+		parameter = aFrom.Uint32(s);
+		if (parameter != KMTPNotSpecified32)
+			{
+			SetUint32(t, parameter);
+			}
+		else if(aIsNullParamValid && (numberOfNullParam < aNumOfNullParam))
+			{
+			SetUint32(t, parameter);
+			numberOfNullParam++;
+			}
+		}
+
+	}
+
+/**
+ Copies the non-null parameter values from the parameter block dataset into the specified dataset. 
+ Note: the number of parameters to be copied out depends on two conditions:
+ 1. The number of parameters contained in this parameter block dataset.
+ 2. The number of parameters to be copied out to the parameter values sink dataset, 
+ which is (aParamEndOffset - aParamStartOffset + 1) by the caller.
+
+ @param aTo The parameter values sink dataset. This dataset should define three or five contiguous 32-bit parameter values starting at the specified offset.
+ @param aParamStartOffset the element ID of the first in the set of contiguous sink dataset parameter values.
+ @param aParamEndOffset the element ID of the last in the set of contiguous sink dataset parameter values.
+ */
+EXPORT_C void TPTPIPTypeRequestPayload::CopyOut( TMTPTypeFlatBase& aTo,
+		TUint aParamStartOffset, TUint aParamEndOffset )
+	{
+	__ASSERT_DEBUG((aParamEndOffset >= aParamStartOffset && (aParamEndOffset - aParamStartOffset + 1) <= ENumElements), User::Invariant());
+	for (TUint s(EParameter1), t(aParamStartOffset); (s <= iMaxSetParam && t <= aParamEndOffset); s++, t++)
+		{
+		aTo.SetUint32((t), Uint32(s));
+		}
+	}
+
+/**
+ Resets the dataset.
+ */
+EXPORT_C void TPTPIPTypeRequestPayload::Reset( )
+	{
+	TMTPTypeFlatBase::Reset();
+	iMaxSetParam = 0;
+	}
+
+/**
+ Setter for the op code.
+ */
+EXPORT_C void TPTPIPTypeRequestPayload::SetUint16(TInt aElementId, TUint16 aData)
+	{
+	__ASSERT_DEBUG((aElementId == EOpCode), User::Invariant());
+	TMTPTypeFlatBase::SetUint16(aElementId, aData);
+	}
+
+/**
+ Getter for the op code. 
+ */
+EXPORT_C TUint16 TPTPIPTypeRequestPayload::Uint16(TInt aElementId) const
+	{
+	__ASSERT_DEBUG((aElementId == EOpCode), User::Invariant());
+	return TMTPTypeFlatBase::Uint16(aElementId);
+	}
+
+/**
+ Setter for the parameters, data phase and tran id
+ */
+EXPORT_C void TPTPIPTypeRequestPayload::SetUint32(TInt aElementId, TUint32 aData )
+	{
+	__ASSERT_DEBUG((aElementId != EOpCode), User::Invariant());
+	if (aElementId >= EParameter1)
+		{
+		if (aElementId > iMaxSetParam)
+			iMaxSetParam = aElementId;
+		/**
+		// Recalculate iNumParameters.
+		TInt num((aElementId - EParameter1) + 1);
+
+		if (num > iNumParameters)
+			{
+			iNumParameters = num;
+			}
+			*/
+		}
+
+	//  Set the element value.
+	TMTPTypeFlatBase::SetUint32(aElementId, aData);
+	}
+
+/**
+ Getter for the parameters, data phase and tran id. 
+ */
+EXPORT_C TUint32 TPTPIPTypeRequestPayload::Uint32(TInt aElementId) const
+	{
+//	__ASSERT_DEBUG((aElementId < iMaxSetParam ), User::Invariant());
+//	__ASSERT_DEBUG((aElementId != EOpCode), User::Invariant());
+	return TMTPTypeFlatBase::Uint32(aElementId);
+	}
+
+/**
+ todo
+ */
+EXPORT_C TInt TPTPIPTypeRequestPayload::FirstReadChunk(TPtrC8& aChunk) const
+	{
+	TInt ret(TMTPTypeFlatBase::FirstReadChunk(aChunk));
+	TUint64 size(Size());
+
+	if (size < aChunk.Size())
+		{
+		// Truncate the buffer at the last set parameter.
+		aChunk.Set(aChunk.Left(size));
+		}
+
+	return ret;
+	}
+
+EXPORT_C TUint64 TPTPIPTypeRequestPayload::Size() const
+	{
+	return (NumParameters() * KMTPTypeUINT32Size + KHeaderElementsSize);
+	}
+
+EXPORT_C TUint TPTPIPTypeRequestPayload::Type() const
+	{
+	return EPTPIPTypeRequestPayload;
+	}
+
+EXPORT_C TBool TPTPIPTypeRequestPayload::CommitRequired() const
+	{
+	return ETrue;
+	}
+
+/**
+Reset the value of the max set param. 
+ */
+EXPORT_C MMTPType* TPTPIPTypeRequestPayload::CommitChunkL(TPtr8& /*aChunk*/)
+	{
+//	iNumParameters = 0;
+
+	// Recalculate iNumParameters.
+	for (TUint i(EParameter1); (i <= EParameter5); i++)
+		{
+		if (TMTPTypeFlatBase::Uint32(i) != KMTPNotSpecified32)
+			{
+			//iNumParameters = (i - EParameter1 + 1 );
+			iMaxSetParam = i;
+			}
+		}
+	return NULL;
+	}
+
+EXPORT_C const TMTPTypeFlatBase::TElementInfo& TPTPIPTypeRequestPayload::ElementInfo(TInt aElementId) const
+	{
+	return iElementInfo[aElementId];
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/src/tptpipresponsepayload.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,234 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#include <mtp/mtpprotocolconstants.h>
+#include "ptpipdatatypes.h"
+#include "tptpipresponsepayload.h"
+
+
+// Dataset element metadata.
+const TPTPIPTypeResponsePayload::TElementInfo TPTPIPTypeResponsePayload::iElementMetaData[ENumElements] = 
+    {
+        {EMTPTypeUINT16, 0,  KMTPTypeUINT16Size},   // EResponseCode
+        {EMTPTypeUINT32, 2,  KMTPTypeUINT32Size},   // ETransactionId
+        {EMTPTypeUINT32, 6,  KMTPTypeUINT32Size},   // EParameter1
+        {EMTPTypeUINT32, 10,  KMTPTypeUINT32Size},  // EParameter2
+        {EMTPTypeUINT32, 14,  KMTPTypeUINT32Size},  // EParameter3
+        {EMTPTypeUINT32, 18,  KMTPTypeUINT32Size},  // EParameter4
+        {EMTPTypeUINT32, 22,  KMTPTypeUINT32Size}   // EParameter5
+    };
+
+/**
+ Constructor.
+ */
+EXPORT_C TPTPIPTypeResponsePayload::TPTPIPTypeResponsePayload() :
+	iElementInfo(iElementMetaData, ENumElements),
+	iBuffer(KSize),
+	//iNumParameters(0)
+	iMaxSetParam(0)
+	{
+	SetBuffer(iBuffer);
+	}
+
+/**
+ Provides the number of parameters in the block which are set.
+ @return the number of set parameters.
+ */
+EXPORT_C TUint TPTPIPTypeResponsePayload::NumParameters() const
+	{
+	return (iMaxSetParam > 0 )? (iMaxSetParam - EParameter1 + 1) : 0;
+	//return iMaxSetParam - EParameter1 + 1;
+	}
+
+/**
+ Copies up to five parameter values into the parameter block dataset from the specified dataset. 
+ The paramters to be copied should be non null paramter or valid null paramter.
+
+ @param aFrom The parameter values source dataset. This dataset should define three or five contiguous 32-bit parameter values starting at the specified offset.
+ @param aParamStartOffset The element ID of the first in the set of contiguous 
+ source dataset parameter values.
+ @param aParamEndOffset The element ID of the last in the set of contiguous 
+ source dataset parameter values.
+ @param aIsNullParamValid a boolean value to check if a null parameter is valid. A value of ETrue means a null parameter is valid; EFalse means invalid.
+ @param aNumOfNullParam the number of valid null parameters to be copied.
+ */
+EXPORT_C void TPTPIPTypeResponsePayload::CopyIn ( 	const TMTPTypeFlatBase& aFrom,
+													TUint aParamStartOffset, TUint aParamEndOffset,
+													TBool aIsNullParamValid, TUint aNumOfNullParam)
+
+	{
+	__ASSERT_DEBUG((aParamEndOffset >= aParamStartOffset && (aParamEndOffset - aParamStartOffset + 1) <= ENumElements), User::Invariant());
+	TUint32 parameter = KMTPNotSpecified32;
+	TUint numberOfNullParam = 0;
+
+	for (TUint t(EParameter1), s(aParamStartOffset); s <= aParamEndOffset; t++, s++)	
+		{
+		parameter = aFrom.Uint32(s);
+		if (parameter != KMTPNotSpecified32)
+		    {
+		    SetUint32(t, parameter);
+		    }
+		else if(aIsNullParamValid && (numberOfNullParam < aNumOfNullParam))
+		    {
+		    SetUint32(t, parameter);
+		    numberOfNullParam++;
+		    }
+		}
+	}
+
+/**
+ Copies the non-null parameter values from the parameter block dataset into the specified dataset. 
+ Note: the number of parameters to be copied out depends on two conditions:
+ 1. The number of parameters contained in this parameter block dataset.
+ 2. The number of parameters to be copied out to the parameter values sink dataset, 
+ which is (aParamEndOffset - aParamStartOffset + 1) by the caller.
+
+ @param aTo The parameter values sink dataset. This dataset should define three or five contiguous 32-bit parameter values starting at the specified offset.
+ @param aParamStartOffset the element ID of the first in the set of contiguous sink dataset parameter values.
+ @param aParamEndOffset the element ID of the last in the set of contiguous sink dataset parameter values.
+ */
+EXPORT_C void TPTPIPTypeResponsePayload::CopyOut( 	TMTPTypeFlatBase& aTo,
+													TUint aParamStartOffset, TUint aParamEndOffset)
+	{
+	__ASSERT_DEBUG((aParamEndOffset >= aParamStartOffset && (aParamEndOffset - aParamStartOffset + 1) <= ENumElements), User::Invariant());
+//	TUint loopCount = aParamEndOffset - aParamStartOffset;
+	for (TUint s(EParameter1), t(aParamStartOffset); (s <= iMaxSetParam && t <= aParamEndOffset); s++, t++)
+		{
+		aTo.SetUint32((t), Uint32(s));
+		}
+	}
+
+/**
+ Resets the dataset.
+ */
+EXPORT_C void TPTPIPTypeResponsePayload::Reset()
+	{
+	TMTPTypeFlatBase::Reset();
+	//iNumParameters = 0;
+	iMaxSetParam = 0;
+	}
+
+/**
+ Setter for the response op code.
+ */
+EXPORT_C void TPTPIPTypeResponsePayload::SetUint16(TInt aElementId, TUint16 aData)
+	{
+	__ASSERT_DEBUG((aElementId == EResponseCode), User::Invariant());
+	TMTPTypeFlatBase::SetUint16(aElementId, aData);
+	}
+
+/**
+ Getter for the response op code. 
+ */
+EXPORT_C TUint16 TPTPIPTypeResponsePayload::Uint16(TInt aElementId) const
+	{
+	__ASSERT_DEBUG((aElementId == EResponseCode), User::Invariant());
+	return TMTPTypeFlatBase::Uint16(aElementId);
+	}
+
+/**
+ Setter for the parameters and tran id
+ */
+EXPORT_C void TPTPIPTypeResponsePayload::SetUint32(TInt aElementId, TUint32 aData)
+	{
+	__ASSERT_DEBUG((aElementId != EResponseCode), User::Invariant());
+	if (aElementId >= EParameter1)
+		{
+		if (aElementId > iMaxSetParam)
+			iMaxSetParam = aElementId;		
+		
+		/**
+		// Recalculate iNumParameters.
+		TInt num((aElementId - EParameter1) + 1);
+
+		if (num > iNumParameters)
+			{
+			iNumParameters = num;
+			}
+			*/
+		}
+
+	//  Set the element value.
+	TMTPTypeFlatBase::SetUint32(aElementId, aData);
+	}
+
+/**
+ Getter for the parameters and tran id. 
+ */
+EXPORT_C TUint32 TPTPIPTypeResponsePayload::Uint32(TInt aElementId) const
+	{
+//	__ASSERT_DEBUG((aElementId < iMaxSetParam ), User::Invariant());
+//	__ASSERT_DEBUG((aElementId != EResponseCode), User::Invariant());
+	return TMTPTypeFlatBase::Uint32(aElementId);
+	}
+
+
+EXPORT_C TInt TPTPIPTypeResponsePayload::FirstReadChunk(TPtrC8& aChunk) const
+	{
+	TInt ret(TMTPTypeFlatBase::FirstReadChunk(aChunk));
+	TUint64 size(Size());
+
+	if (size < aChunk.Size())
+		{
+		// Truncate the buffer at the last set parameter.
+		aChunk.Set(aChunk.Left(size));
+		}
+
+	return ret;
+	}
+
+EXPORT_C TUint64 TPTPIPTypeResponsePayload::Size() const
+	{
+	return (NumParameters() * KMTPTypeUINT32Size + KHeaderElementsSize);
+	}
+
+EXPORT_C TUint TPTPIPTypeResponsePayload::Type() const
+	{
+	return EPTPIPTypeResponsePayload;
+	}
+
+EXPORT_C TBool TPTPIPTypeResponsePayload::CommitRequired() const
+	{
+	return ETrue;
+	}
+
+/**
+ todo: optimise, start from 5, break on set. 
+ */
+EXPORT_C MMTPType* TPTPIPTypeResponsePayload::CommitChunkL(TPtr8& /*aChunk*/)
+	{
+	//iNumParameters = 0;
+
+	// Recalculate iNumParameters.
+	for (TUint i(EParameter1); (i <= EParameter5); i++)
+		{
+		if (TMTPTypeFlatBase::Uint32(i) != KMTPNotSpecified32)
+			{
+			//iNumParameters = (i + 1);
+				iMaxSetParam = i;
+			}
+		}
+	return NULL;
+	}
+
+EXPORT_C const TMTPTypeFlatBase::TElementInfo& TPTPIPTypeResponsePayload::ElementInfo(TInt aElementId) const
+	{
+	return iElementInfo[aElementId];
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/src/tptpipstartdatapayload.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,121 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#include "ptpipdatatypes.h"
+#include "tptpipstartdatapayload.h"
+
+	
+// Dataset element metadata.
+const TPTPIPTypeStartDataPayload::TElementInfo TPTPIPTypeStartDataPayload::iElementMetaData[ENumElements] = 
+    {
+        {EMTPTypeUINT32, 0,  KMTPTypeUINT32Size},  // Transaction Id
+        {EMTPTypeUINT64, 4,  KMTPTypeUINT64Size}   // Total Data size
+    };
+
+/**
+ Constructor.
+ */
+EXPORT_C TPTPIPTypeStartDataPayload::TPTPIPTypeStartDataPayload() :
+	iElementInfo(iElementMetaData, ENumElements),
+	iBuffer(KSize)
+	{
+	SetBuffer(iBuffer);
+	}
+
+/**
+ Resets the dataset.
+ */
+EXPORT_C void TPTPIPTypeStartDataPayload::Reset()
+	{
+	TMTPTypeFlatBase::Reset();
+	}
+
+/**
+ Sets the transaction id.
+ */
+EXPORT_C void TPTPIPTypeStartDataPayload::SetUint32(TInt aElementId, TUint32 aData)
+	{
+	__ASSERT_DEBUG((aElementId == ETransactionId), User::Invariant());
+	TMTPTypeFlatBase::SetUint32(aElementId, aData);
+	}
+
+/**
+ Gets the transaction id
+ */
+EXPORT_C TUint32 TPTPIPTypeStartDataPayload::Uint32(TInt aElementId) const
+	{
+	__ASSERT_DEBUG((aElementId == ETransactionId), User::Invariant());
+	return TMTPTypeFlatBase::Uint32(aElementId);
+	}
+
+/**
+ Sets the 64 bit size of total data in the data phase. 
+ */
+EXPORT_C void TPTPIPTypeStartDataPayload::SetUint64(TInt aElementId, TUint64 aData)
+	{
+	__ASSERT_DEBUG((aElementId == ETotalSize), User::Invariant());
+	TMTPTypeFlatBase::SetUint64(aElementId, aData);
+	}
+
+/**
+ Gets the 64 bit size of the total data in the data phase. 
+ */
+EXPORT_C TUint64 TPTPIPTypeStartDataPayload::Uint64(TInt aElementId) const
+	{
+	__ASSERT_DEBUG((aElementId == ETotalSize), User::Invariant());
+	return TMTPTypeFlatBase::Uint64(aElementId);
+	}
+
+/**
+ todo
+ */
+EXPORT_C TInt TPTPIPTypeStartDataPayload::FirstReadChunk(TPtrC8& aChunk) const
+	{
+	TInt ret(TMTPTypeFlatBase::FirstReadChunk(aChunk));
+	return ret;
+	}
+
+EXPORT_C TUint64 TPTPIPTypeStartDataPayload::Size() const
+	{
+	return KSize;
+	}
+
+EXPORT_C TUint TPTPIPTypeStartDataPayload::Type() const
+	{
+	return EPTPIPTypeStartDataPayload;
+	}
+
+EXPORT_C TBool TPTPIPTypeStartDataPayload::CommitRequired() const
+	{
+	return ETrue;
+	}
+
+/**
+ todo: nothing to do here?
+ */
+EXPORT_C MMTPType* TPTPIPTypeStartDataPayload::CommitChunkL(TPtr8& /*aChunk*/)
+	{
+	return NULL;
+	}
+
+EXPORT_C const TMTPTypeFlatBase::TElementInfo& TPTPIPTypeStartDataPayload::ElementInfo(TInt aElementId) const
+	{
+	return iElementInfo[aElementId];
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipplugin/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,31 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// PTPIP implementation MTP/SIC device class
+// 
+//
+
+/**
+ @file
+*/
+
+PRJ_PLATFORMS
+ARMV5
+winscw
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES 
+
+ptpipplugin.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipplugin/group/ptpipplugin.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,69 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// ptpipplugin.dll MTP transport plug-in for ptpip
+// 
+//
+
+/**
+ @file
+*/
+
+#include <comms-infras/commsdebugutility.mmh>
+
+
+TARGETTYPE PLUGIN
+TARGET ptpipplugin.dll
+
+UID 0x10009D8D 0xA0004A61
+VENDORID 			0x70000001
+
+CAPABILITY          CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+USERINCLUDE         ../inc/ 
+USERINCLUDE         ../../ptpipdatatypes/inc
+USERINCLUDE			../../common/inc/
+USERINCLUDE         ../../../../mtpfws/mtpfw/transports/transportapi/inc
+USERINCLUDE         ../../../../mtpfws/mtpfw/common/inc
+
+
+SOURCEPATH 			../src/
+SOURCE 				cptpiptransport.cpp 
+SOURCE 				cptpipconnection.cpp
+SOURCE				cptpipsockhandlerbase.cpp
+SOURCE				cptpipcommandhandler.cpp
+SOURCE				cptpipeventhandler.cpp
+
+
+
+LIBRARY             euser.lib
+
+LIBRARY             mtpdatatypes.lib 
+LIBRARY             mtptransportapi.lib
+LIBRARY				ptpipdatatypes.lib
+LIBRARY				esock.lib 
+LIBRARY				commdb.lib 
+LIBRARY				insock.lib 
+
+
+
+
+
+START RESOURCE      ptpipplugin.rss    
+TARGET              ptpipplugin.rsc
+
+END
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipplugin/inc/cptpipcommandhandler.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,63 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#ifndef CCOMMANDHANDLER_H_
+#define CCOMMANDHANDLER_H_
+
+#include "cptpipsockhandlerbase.h"
+#include "cptpipconnection.h"
+
+/**
+The PTP/IP protocol specifies two TCP Connections - 
+
+1) Command or Data Connection ( this class encapsulates this)
+2) Event Connection.
+
+This class is responsible for handling the command connection of the PTPIP protocol.
+This class will control the socket used to send and receive the PTPIP command data
+over the TCP/IP Connection .
+
+*/
+class CPTPIPCommandHandler : public CPTPIPSocketHandlerBase
+	{
+public :
+	static CPTPIPCommandHandler* NewL(CPTPIPConnection& aConnection);
+	~CPTPIPCommandHandler();
+	
+	void ReceiveCommandDataL(MMTPType& aItoRData);
+	void ReceiveCommandRequestL(MMTPType& aRequest);
+	void SendCommandDataL(const MMTPType& aRtoIData, TUint32 aTransactionId);
+	void SendCommandL(const MMTPType& aResponse);
+	
+	TInt ParsePTPIPHeaderL();
+	TBool HandleInitAck();
+private :
+	CPTPIPCommandHandler(CPTPIPConnection& aConnection);
+
+	void SendDataCompleteL(TInt aError, const MMTPType& aSource);
+	void ReceiveDataCompleteL(TInt aError, MMTPType& aSink);
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER;    
+	
+	};
+
+#endif /*CCOMMANDHANDLER_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipplugin/inc/cptpipconnection.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,357 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+
+#ifndef CPTPIPCONNECTION_H_
+#define CPTPIPCONNECTION_H_
+
+#include <mtp/tmtptyperequest.h>
+#include <mtp/tmtptypeevent.h>
+#include <mtp/mtpdataproviderapitypes.h>
+#include <mtp/tmtptypenull.h>
+
+
+#include "mmtpconnectionmgr.h"
+#include "mmtpconnectionprotocol.h"
+
+
+#include "mmtptransportconnection.h"
+#include "ptpipdatatypes.h"
+#include "cptpipgenericcontainer.h"
+#include "cptpipdatacontainer.h"
+#include "tptpiprequestpayload.h"
+#include "tptpipresponsepayload.h"
+#include "tptpipstartdatapayload.h"
+#include "tptpipinitevtack.h"
+
+#include "mtpdebug.h"
+#include "ptpipprotocolconstants.h"
+
+
+
+class CPTPIPCommandHandler;
+class CPTPIPEventHandler;
+class MMTPConnectionProtocol;
+class MMTPConnectionMgr;
+
+/**
+Implements the MTP USB device class connection protocol and transport layer 
+interface.
+
+This is the class implementing the main API functions exposed to the framework layer
+for exchange of data with the transport layer.
+
+It also has the communication protocol which exposes the SPI / observer functions 
+exposed by the framework layer , which is used by the transport to communicate with 
+the framework. 
+
+It implements a state machine which keeps track of whether we are sending data , 
+expecting response etc. 
+
+The error handling strategy is as follows:
+If unexpected data is received on the event channel , we close the connection.
+If unexpected data is received on the command channel the we close the connection.
+If the internal state is invalid, then a panic is raised. 
+Any errors received, are passed up to the MTP fw, except for TCP disconnection
+which is converted to KErrAbort. 
+
+@internalComponent
+*/
+class CPTPIPConnection : public CActive,
+						 public MMTPTransportConnection
+{
+public :
+
+	enum TConnectionState
+		{
+		EIdle                   = 0x00000000,
+		EInitialising           = 0x00000001,
+		EInitialisationComplete = 0x00000002,
+		EStartListening         = 0x00000003,
+		EDataSendInProgress     = 0x00000004,
+		EDataSendFinished       = 0x00000007,
+		ECancelled				= 0x00000008
+		};
+
+	
+	enum TCancelState
+		{
+		ECancelNotReceived        = 0x00000000,
+		
+		ECancelCmdReceived        = 0x10000001,
+		ECancelCmdHandleInProgress= 0x10000002,
+		ECancelCmdHandled         = 0x10000003,
+		
+		ECancelEvtReceived        = 0x20000001,
+		ECancelEvtHandled         = 0x20000003,
+		
+		ECancelChannel            = 0xF0000000
+		};
+
+
+	static CPTPIPConnection* NewL(MMTPConnectionMgr& aConnectionMgr);
+	~CPTPIPConnection();
+	
+
+public : // from MMTPTransportConnection
+	virtual void BindL(MMTPConnectionProtocol& aProtocol) ;
+	virtual MMTPConnectionProtocol& BoundProtocolLayer(); 
+	virtual void CloseConnection() ;
+	virtual void ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest) ;
+	virtual void ReceiveDataCancelL(const TMTPTypeRequest& aRequest) ;
+	virtual void SendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest) ; 
+	virtual void SendDataCancelL(const TMTPTypeRequest& aRequest) ;
+	virtual void SendEventL(const TMTPTypeEvent& aEvent) ;
+	virtual void SendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest) ;
+	virtual void TransactionCompleteL(const TMTPTypeRequest& aRequest) ;
+	virtual void Unbind(MMTPConnectionProtocol& aProtocol) ;
+	virtual TAny* GetExtendedInterface(TUid aInterfaceUid) ; 
+	virtual TUint GetImplementationUid();
+	
+public : //from CActive
+	void DoCancel();
+	void RunL();
+	TInt RunError(TInt aError);
+	
+public : // Other functions
+	void GetCancelPayload();
+	void CompleteSelf(TInt aCompletionCode);
+	void SetConnectionState(TConnectionState);
+	
+	// Receiving functions:
+	void ReceiveCommandChannelCompleteL(TInt aError, MMTPType& aSource);
+	
+	void ReceiveEventCompleteL(TInt aError, MMTPType& aSource);
+	void ReceiveCommandCompleteL(TInt aError);
+	
+	void ReceiveCommandDataL(MMTPType& aData) ;
+	void ReceiveCommandDataCompleteL(TInt aError);
+	
+	
+
+	// Sending funtions
+	void SendCommandChannelCompleteL(TInt aError, const MMTPType& aSource);
+	
+	void SendResponseCompleteL(TInt aError, MMTPType& aSource);
+	void SendEventCompleteL(TInt aError, const MMTPType& aSource);
+
+	void SendStartDataPacketL();
+	void SendDataPacketL();
+	void SendCommandCompleteL(TInt aError);
+	void SendCommandDataCompleteL(TInt aError);
+
+	
+	CPTPIPGenericContainer* CommandContainer();
+	CPTPIPGenericContainer* EventContainer();
+	CPTPIPDataContainer* DataContainer();
+	TUint32 ValidateAndSetCommandPayloadL();
+	TUint32 ValidateAndSetEventPayloadL();
+	TUint32 ValidateDataPacketL();
+	TMTPTransactionPhase TransactionPhase() const;
+	void HandleError(TInt aError);
+	void SetDataTypeInDataContainerL(TPTPIPPacketTypeCode aType);
+	TBool ConnectionOpen() const;
+
+private:
+	CPTPIPConnection(MMTPConnectionMgr& aConnectionMgr);
+	void ConstructL();	
+
+	void TransferSocketsL();
+
+	void InitiateCommandRequestPhaseL();
+	void InitiateEventRequestPhaseL();
+	
+	void SendInitAckL();
+	
+	void DoSendDataL();
+	void DoReceiveDataL();
+	
+	// Cancel handling functions
+	void HandleEventCancelL();
+	void HandleCommandCancelL(TUint32 aTransId);
+	void HandleCommandCancelCompleteL();
+	void SendCancelToFrameworkL(TUint32 aTransId);
+	void SendCancelResponseL(TUint32 aTransId);
+	void HandleCancelDuringSendL();
+	
+	void SetTransactionPhase(TMTPTransactionPhase);
+	TBool ValidateTransactionPhase(TMTPTransactionPhase aExpectedTransactionState);
+	TBool HandleTCPError(TInt& aError);
+	void StopConnection();
+	
+	void SetNULLPacketL();
+	
+private: // Owned
+
+	/**
+	The current state of the MTP transaction, ( request, response, data phase) 
+	*/
+	TMTPTransactionPhase        iTransactionState;
+	
+	/**
+	Current state of the Connection, ( whether its initialisting, transferring data, listening)
+	*/
+	TInt                        iState;
+	
+	/**
+	Flag, which is turned on when the cancel operation is received on the command channel. 
+	*/
+	TCancelState                iCancelOnCommandState;
+	
+	/**
+	Flag, which is turned on when the cancel operation is received on the event channel. 
+	*/
+	TCancelState                iCancelOnEventState;
+	
+	/**
+	During the sending of data this keeps track of the total data to send
+	*/
+	TUint64                     iTotalDataLen;
+
+	/**
+	Command handler to send the data via the command socket.
+	*/
+	CPTPIPCommandHandler*       iCommandHandler;
+	
+	/**
+	EventHandler to send the data via the event socket.
+	*/
+	CPTPIPEventHandler*         iEventHandler;
+	
+	// Command Container & payloads //
+	/**
+	Command Container, its payload can be request, response, start data or cancel. 
+	*/
+	CPTPIPGenericContainer*     iPTPIPCommandContainer;
+	
+	/**
+	Command Request Paramenter Payload
+	4 - data phase
+	2 - op code
+	4 - tran id
+	20 - 5 params
+	*/
+	TPTPIPTypeRequestPayload    iPTPIPRequestPayload;
+	
+	/**
+	CommandData Response Parameter Payload
+	2 - res code
+	4 tran id
+	20 - 5 params
+	*/
+	TPTPIPTypeResponsePayload   iPTPIPResponsePayload;
+	
+	/**
+	StartData parameter payload
+	4 - tran id
+	8 - total length
+	*/
+	TPTPIPTypeStartDataPayload  iPTPIPStartDataPayload;
+	
+	/**
+	Cancel data Parameter payload
+	4 trans id
+	*/
+	TMTPTypeInt32               iPTPIPCommandCancelPayload;
+	
+	
+	// Event Container & payloads //
+	/**
+	Event Container, its payload can be event, cancel or probe (ie no payload) 
+	*/
+	CPTPIPGenericContainer*     iPTPIPEventContainer;
+	
+	/**
+	Event Payload 
+	2 - res code
+	4 tran id
+	20 - 5 params
+	*/
+	TPTPIPTypeResponsePayload   iPTPIPEventPayload;
+
+	/**
+	Event Payload 
+	*/
+	TMTPTypeUint32              iPTPIPEventCancelPayload;
+
+	// Data Container ( payload comes from mtp f/w) //
+	/**
+	4 - tran id
+	? - payload, given by the framework. 
+	*/
+	CPTPIPDataContainer*        iPTPIPDataContainer;
+
+	/** 
+    The current active MTP SessionID, set while sending response to open session.
+    */
+    TUint32                     iMTPSessionId;
+    
+    /**
+    The active MTP operation request dataset buffer.
+    */
+    TMTPTypeRequest             iMTPRequest;
+    
+    /**
+    The MTP event dataset buffer.
+    */
+    TMTPTypeEvent               iMTPEvent;
+	
+	/**
+    The total amount of data expected, this is filled from the ptpip start data packet. 
+    */
+    TUint64	                    iTotalRecvData;
+	
+	/**
+    The data receved so far. 
+    */
+    TUint64	                    iRecvData;
+    
+	/**
+	Data sink for consuming data during error recovery from
+	a failed ItoR transaction.
+	*/
+	TMTPTypeNull                iNull;
+	
+	/**
+	Buffer for reading discarded data into.
+	*/
+	RBuf8                       iNullBuffer;
+	
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER;    
+	
+private: // Not Owned
+
+	/** 
+    The MTP connection manager.
+    */
+    MMTPConnectionMgr*			iConnectionMgr;
+
+	/** 
+    The MTP connection protocol layer binding. 
+    This is the SPI/ observer - transport uses it to communicate to the MTP framework.
+    */
+    MMTPConnectionProtocol*		iProtocolLayer;
+
+};
+
+
+#endif /*CPTPIPCONNECTION_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipplugin/inc/cptpipeventhandler.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,63 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#ifndef CEVENTHANDLER_H_
+#define CEVENTHANDLER_H_
+
+#include "e32def.h"
+#include "cptpipsockhandlerbase.h"
+
+/**
+The PTP/IP protocol specifies two TCP Connections - 
+
+1) Command or Data Connection
+2) Event Connection.
+
+This class is responsible for handling the event connection of the PTPIP protocol.
+This class will control the socket used to send and receive the PTPIP events over 
+the TCP/IP Connection .
+*/
+
+class CPTPIPEventHandler : public CPTPIPSocketHandlerBase
+	{
+public:
+	static CPTPIPEventHandler* NewL(CPTPIPConnection& aConnectionHandler);
+	~CPTPIPEventHandler();
+	void SendInitAck(CPTPIPGenericContainer* aEvtAck);
+
+	void SendEventL(const MMTPType& aData);
+	void ReceiveEventL(MMTPType& aEvent);
+	
+private:
+	CPTPIPEventHandler(CPTPIPConnection& aConnectionHandler);
+	
+	void SendDataCompleteL(TInt aError, const MMTPType& aSource);
+	void ReceiveDataCompleteL(TInt aError, MMTPType& aSink);
+	
+	TInt ParsePTPIPHeaderL();
+	TBool HandleInitAck();
+	
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER;    
+	
+	};
+
+#endif /*CEVENTHANDLER_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipplugin/inc/cptpipsockhandlerbase.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,261 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#ifndef CSOCKETHANDLER_H_
+#define CSOCKETHANDLER_H_
+
+#include "es_sock.h"
+#include "in_sock.h"
+#include "e32base.h"
+#include "cptpipconnection.h"
+
+#include "mtpdebug.h"
+#include "ptpipprotocolconstants.h"
+
+
+//The maximum number of bytes buffered locally before sending over socket
+// If the data chunk is larger than this, it is sent directly, if its smaller its buffered.
+const TInt KBufferSize = 64;
+
+/**
+This class encapsulates the functions for sending and receving data over
+the @see RSocket over TCP/IP
+
+It has the common functionality for handling and communicating with the socket, 
+and for communicating with the ptpip connection class. 
+
+The command and Event handler classes derived from this class.
+ 
+*/
+class CPTPIPSocketHandlerBase : public CActive
+	{
+public :
+
+	enum TSocketState
+		{
+		
+		EIdle                     = 0x00000000,
+		EInitSendInProgress       = 0x80000005,
+		
+        // The receive data stream is active.
+        EReceivingState           = 0x40000000,
+		EReceiveInProgress        = 0x40000001,
+		EReceiveFastInProgress    = 0x40000002,
+		EReceiveComplete          = 0x40000003,
+
+        // The send data stream is active.
+        ESendingState             = 0x80000000,
+		ESendInitialising         = 0x80000001,
+		ESendInProgress           = 0x80000002,
+		ESendCompleting           = 0x80000003,
+		ESendComplete             = 0x80000004,
+		
+		// Send stream is active and is sending the data in packets during R to I data phase
+		ESendDataState            = 0x60000000,
+		ESendDataInitialising     = 0x60000001,
+		ESendingDataHeader        = 0x60000002,
+		ESendingDataPacket        = 0x60000003,
+		ESendDataPacketCompleting = 0x60000004,
+		ESendDataComplete         = 0x60000005,
+		ESendDataCancelled        = 0x60000006,
+
+		EStateDirection           = 0xF0000000
+		};
+	
+	// Data Sending functions
+	void SendDataL(const MMTPType& aData, TUint32 aTransactionId);
+    virtual void SendDataCompleteL(TInt aError, const MMTPType& aSource);
+	void CancelSendL(TInt aReason);
+
+	// Data Receiving functions
+	void ReceiveDataL(MMTPType& aData);
+    virtual void ReceiveDataCompleteL(TInt aError, MMTPType& aSink);
+	void CancelReceiveL(TInt aReason);
+    
+    // Other helper functions
+	virtual ~CPTPIPSocketHandlerBase();
+	CPTPIPConnection& Connection();
+	RSocket& Socket();
+	void SetSocket(RSocket& aSocket);
+	void SetState(TSocketState aState);
+	void SetSocketOptions();
+	void SetCancel()
+		{
+		iCancelReceived = ETrue;
+		}
+	
+	// From CActive
+	void DoCancel();
+
+public:
+
+	/*Flag to inidicate whether to populate the chunk given by MTP framework, 
+	 from the last saved location or beginning if its a new chunk
+	 * */
+	TBool iUseOffset ;			
+		
+protected:
+
+	CPTPIPSocketHandlerBase(CPTPIPConnection& aConnection, TPriority priority );
+#ifdef __FLOG_ACTIVE    
+    virtual void ConstructL(const TDesC8& aComponentName);
+#else
+    virtual void ConstructL();
+#endif  
+	virtual TInt ParsePTPIPHeaderL() = 0;
+	virtual TBool HandleInitAck() = 0;
+	
+	
+private:
+
+	// From CActive
+	void RunL();
+	TInt RunError(TInt aError);
+
+	// other helper functions.
+	void ProcessSendDataL();
+	void ProcessFirstReceivedChunkL();
+	void ResumeReceiveDataStreamL();
+	void InitiateFirstChunkReceiveL();
+	void ResetSendDataStream();
+	void ResetReceiveDataStream();
+	void CompleteSelf(TInt aCompletionCode);
+	TInt32 DataStreamDirection() const;
+	void SendDataPacketL();
+	void SendHeaderPacketL();
+	void CreateAndSendDataPacketsL();	
+
+protected :
+	/**
+	This is the socket used for transferring data , 
+	it is controlled by the socketHandler
+	*/
+	RSocket 			iSocket;
+	
+    /**
+    The active data stream chunk status.
+    */
+    TInt                iChunkStatus;
+
+    /**
+    The pointer to the current chunk in the send data stream.
+    */
+    TPtrC8              iSendChunkData;
+    
+    /**
+    The send data stream data pointer.
+    */
+    TPtrC8              iSendData;
+    
+    /**
+    The pointer to the current chunk in the receive data stream
+    */
+    TPtr8               iReceiveChunkData;
+    
+       
+    
+    /**
+    The amount of data expected in one ptpip packet, this is filled from the size from ptp header
+    */
+    TUint32				iPTPPacketLength;
+	
+    /**
+    Keeps track of whether socket is sending, receiving, idle etc.
+    */
+    TSocketState		iState;
+    
+    /**
+    FLOGGER debug trace member variable.
+    */
+	__FLOG_DECLARATION_MEMBER_MUTABLE;
+
+private :
+    /**
+    The packet data buffer used to copy and append the chunk locally
+    if the individual chunks are too small to send as one tcp packet. 
+    */
+    RBuf8               iPacketBuffer;
+    
+    /**
+    The maximum size of the packet buffer
+    */
+    TUint               iPacketSizeMax;
+    
+    /**
+    The receive data stream data pointer.
+    */
+    TPtr8               iReceiveData;
+
+    /**
+    A flag to tell if the receive stream is the first chunk.
+    */			
+    TBool 				iIsFirstChunk;
+    
+    /**
+    The amount of data received so far, keeps incrementing with each tcp packet.
+    */
+    TUint32 			iPTPPacketLengthReceived;
+     
+    /** 
+    The receive data stream commit flag.
+    */
+    TBool               iReceiveDataCommit;
+	
+    /**
+    The send data stream data pointer.
+    */
+    TPtrC8              iSendHeaderData;
+    
+	/**
+    The header for the ptp ip data packet.
+    */
+    CPTPIPDataContainer* iPTPIPDataHeader;
+    
+    /**
+    The flag to keep track whether cancel has been received. 
+    */
+    TBool               iCancelReceived;
+    
+    
+private : // Not owned
+	CPTPIPConnection& iConnection;
+
+	/**
+	This is the buffer used to receive data from the socket. This will be a pointer 
+	to the PTPIP data type. 
+	*/
+	MMTPType* iReceiveDataSink;
+	
+	/**
+	This is the buffer used to send data to the socket. This will be a pointer 
+	to the PTPIP data type. 
+	*/
+	const MMTPType* iSendDataSource;	
+	
+	/**
+    The pointer to the current chunk in the receive data stream
+    */
+    TPtr8               iCurrentChunkData; 
+    
+    /*Type of the current PTP/IP Packet */
+    TUint32 iType;
+	
+	};
+
+#endif /*CSOCKETHANDLER_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipplugin/inc/cptpiptransport.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,76 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#ifndef CPTPIPTRANSPORT_H_
+#define CPTPIPTRANSPORT_H_
+
+#include "cmtptransportplugin.h"
+#include "mtpdebug.h"
+
+class CPTPIPConnection;
+
+/**
+
+PTPIP plugin transport:
+
+Implements the transport plug-in for using MTP over TCPIP as defined by the 
+PTPIP Specification.
+
+The MTP protocol is currrently supported by Symbian over two transports, 
+USB and TCP/IP. 
+The PTPIP specification details how the MPT protocol can be used over TCP/IP. 
+Thus the transport plugin for taking MTP over TCPIP is called PTPIP, 
+after the specification which it implements. 
+
+This class implements the API functions given by the mtp framework for a 
+transport as defined in the CMTPTransportPlugin class. 
+@internalComponent
+ 
+*/
+class CPTPIPTransport : public CMTPTransportPlugin
+	{
+
+public :
+	static TAny* NewL(TAny* aParameter);
+	~CPTPIPTransport();
+
+public : // from CMTPTransportPlugin	
+	void ModeChanged(TMTPOperationalMode aMode) ;
+	void StartL(MMTPConnectionMgr& aConnectionMgr) ;
+	void Stop(MMTPConnectionMgr& aConnectionMgr) ;
+	TAny* GetExtendedInterface(TUid aInterfaceUid) ;
+
+private : 
+	CPTPIPTransport();
+	void ConstructL();
+	
+private : //Owned
+	/**
+	The PTPIP device class connection
+	*/
+	CPTPIPConnection* iConnection;
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER;
+  
+	};   
+  
+#endif /*CPTPIPTRANSPORT_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipplugin/src/cptpipcommandhandler.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,184 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#include "cptpipcommandhandler.h"
+
+const TUint32 KPTPIPHeaderSize = 8;
+const TUint32 KPTPIPDataHeaderSize = 12;
+
+__FLOG_STMT(_LIT8(KComponent,"CCommandHandler");) 
+
+/**
+Creates the channel for commands. The base class constructl is called. 
+*/
+CPTPIPCommandHandler* CPTPIPCommandHandler::NewL(CPTPIPConnection& aConnection)
+	{
+	
+	CPTPIPCommandHandler* self = new(ELeave) CPTPIPCommandHandler(aConnection);
+	CleanupStack::PushL(self);
+#ifdef __FLOG_ACTIVE    
+    self->ConstructL(KComponent);
+#else
+    self->ConstructL();
+#endif	
+	CleanupStack::Pop();
+	return self;
+	}
+
+/**
+Desctructor
+*/
+CPTPIPCommandHandler::~CPTPIPCommandHandler()
+	{
+	__FLOG(_L8("Destructor - Entry"));
+	__FLOG(_L8("Destructor - Exit"));
+	}
+
+/**
+Constructor
+*/
+CPTPIPCommandHandler::CPTPIPCommandHandler(CPTPIPConnection& aConnection):
+								CPTPIPSocketHandlerBase(aConnection, CActive::EPriorityStandard)
+								
+	{
+	}
+
+/**
+Initiates the sending of the command data. The base class implements the handling
+of the socket to send the actual data. 
+@param aRtoIData The buffer containing data populated by the framework to be sent to the initiator
+@param aTransactionId The id of the current ongoing transaction.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CPTPIPCommandHandler::SendCommandDataL(const MMTPType& aRtoIData, TUint32 aTransactionId)
+    {
+	__FLOG(_L8("SendCommandDataL - Entry"));
+    SendDataL(aRtoIData, aTransactionId);
+	__FLOG(_L8("SendCommandDataL - Exit"));
+    }
+    
+/**
+Initiates the sending of the command data. The base class implements the handling
+of the socket to send the actual data. 
+@param aData The buffer containing the response populated by the framework to be sent to the initiator 
+@param aTransactionId The id of the current ongoing transaction.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CPTPIPCommandHandler::SendCommandL(const MMTPType& aResponse)
+    {
+	__FLOG(_L8("SendCommandDataL - Entry"));
+    SendDataL(aResponse, 0);
+	__FLOG(_L8("SendCommandDataL - Exit"));
+    }
+
+/**
+Signals the completion of sending data over the socket, which was started by 
+SendCommandDataL. Its called by the base sockethandler and in turn informs the 
+connection.
+@param aError - The error if any returned by the sockethandler. (KErrNone if no errors)
+@param aSource - The buffer of data which had been given by the framework to send to initiator.
+*/
+void CPTPIPCommandHandler::SendDataCompleteL(TInt aError, const MMTPType& aSource)
+    {
+	__FLOG(_L8("SendDataCompleteL - Entry"));
+    Connection().SendCommandChannelCompleteL(aError, aSource);
+	__FLOG(_L8("SendDataCompleteL - Exit"));
+    }
+
+
+/**
+Initiates the receiving of the info on the command channel, used for both commands
+ and data. 
+@param aData The buffer given by the framework in which the command request will be received from the initiator
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CPTPIPCommandHandler::ReceiveCommandRequestL(MMTPType& aRequest)
+    {
+	__FLOG(_L8("ReceiveCommandDataL - Entry"));
+    ReceiveDataL(aRequest);
+	__FLOG(_L8("ReceiveCommandDataL - Exit"));
+    }
+
+/**
+Initiates the receiving of the info on the command channel, used for both commands
+ and data. 
+@param aItoRData The buffer given by the framework in which the command data will be received from the initiator
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CPTPIPCommandHandler::ReceiveCommandDataL(MMTPType& aItoRData)
+    {
+	__FLOG(_L8("ReceiveCommandDataL - Entry"));
+	ReceiveDataL(aItoRData);
+	__FLOG(_L8("ReceiveCommandDataL - Exit"));
+    }
+
+
+/**
+Marks the completion of receiving data over the command socket, which was started 
+by ReceiveCommandDataL. 
+@param aError - The error if any returned by the sockethandler. (KErrNone if no errors)
+@param aSink - The buffer in which data received from the initiator is returned to the framework
+*/
+void CPTPIPCommandHandler::ReceiveDataCompleteL(TInt aError, MMTPType& aSink)
+    {
+	__FLOG(_L8("ReceiveDataCompleteL - Entry"));
+	
+	Connection().ReceiveCommandChannelCompleteL(aError, aSink);
+	__FLOG(_L8("ReceiveDataCompleteL - Exit"));
+    }
+    
+/**
+Validates if the current payload in the container is the correct type to hold the
+data that is coming in. 
+
+For command container, the payloads can be request, response and start data. 
+For the data container, the payload is already set from the MTP framework. 
+
+@return type The ptpip packet type, like request, cancel etc 
+*/   
+TInt CPTPIPCommandHandler::ParsePTPIPHeaderL()
+	{
+	__FLOG(_L8("ValidateAndSetPayload - Entry"));
+	TUint32 type = 0;
+	
+	// If this is a request or event, then the first chunk will have 8 bytes
+    if (KPTPIPHeaderSize == iReceiveChunkData.MaxLength())
+    	{
+    	iPTPPacketLength = Connection().CommandContainer()->Uint32L(CPTPIPGenericContainer::EPacketLength);
+    	type = Connection().ValidateAndSetCommandPayloadL();
+    	}
+    // if this is a data header, then the first chunk will have 12 bytes. 
+    else if (KPTPIPDataHeaderSize == iReceiveChunkData.MaxLength()) 
+    	{
+       	iPTPPacketLength = Connection().DataContainer()->Uint32L(CPTPIPDataContainer::EPacketLength);
+    	type = Connection().ValidateDataPacketL();
+    	}
+	__FLOG(_L8("ValidateAndSetPayload - Exit"));	
+	return type;
+
+	}
+
+/**
+ * This function is implemented in the event handler class for 
+ * handling the sending of the init acknowledgement. 
+ */
+TBool CPTPIPCommandHandler::HandleInitAck()
+	{
+	return EFalse;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipplugin/src/cptpipconnection.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1597 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+// System includes
+#include "e32base.h"
+#include "ptpippanic.h"
+#include "e32property.h" 
+
+// MTP includes
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptyperesponse.h>
+
+// Plugin includes
+#include "cptpipcommandhandler.h"
+#include "cptpipeventhandler.h"
+#include "cptpipconnection.h"
+#include "ptpipsocketpublish.h" 
+
+// File type constants.
+const TInt KMTPNullChunkSize(0x00020000); // 100KB
+const TUint32 KPTPIPDataHeaderSize = 12;  // Size of len, type and tran id. 
+__FLOG_STMT(_LIT8(KComponent,"PTPIPConnection");)
+#define UNUSED_VAR(a) (a) = (a)
+
+/**
+ PTPIP device class connection factory method.
+ @param aConnectionMgr The MTP connection manager interface.
+ @return A pointer to an PTPIP device class connection. Ownership IS transfered.
+ @leave One of the system wide error codes, if a processing failure occurs.
+ */
+CPTPIPConnection* CPTPIPConnection::NewL(MMTPConnectionMgr& aConnectionMgr )
+	{
+	CPTPIPConnection* self = new(ELeave) CPTPIPConnection(aConnectionMgr);
+	CleanupStack::PushL (self );
+	self->ConstructL ( );
+	CleanupStack::Pop (self );
+	return self;
+	}
+
+/**
+ Destructor
+ */
+CPTPIPConnection::~CPTPIPConnection( )
+	{
+	__FLOG(_L8("Destructor - Entry"));
+	StopConnection ( );
+
+	// Delete all the handlers which will close the sockets.
+	delete iCommandHandler;
+	delete iEventHandler;
+
+	delete iPTPIPCommandContainer;
+	delete iPTPIPDataContainer;
+	delete iPTPIPEventContainer;
+	
+	iNullBuffer.Close();
+
+	__FLOG(_L8("Destructor - Exit"));
+	__FLOG_CLOSE;
+	}
+
+/**
+ Second phase constructor
+ @leave One of the system wide error codes, if a processing failure occurs.
+ */
+void CPTPIPConnection::ConstructL( )
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry"));
+
+	// Construct the Command and event handlers
+	iCommandHandler = CPTPIPCommandHandler::NewL (*this );
+	iEventHandler = CPTPIPEventHandler::NewL (*this );
+
+	iPTPIPCommandContainer = CPTPIPGenericContainer::NewL ( );
+	iPTPIPDataContainer = CPTPIPDataContainer::NewL ( );
+	iPTPIPEventContainer = CPTPIPGenericContainer::NewL ( );
+
+	// Transfer the sockets
+	TransferSocketsL();
+
+	SetConnectionState (EInitialising );
+	CompleteSelf (KErrNone );
+
+	__FLOG(_L8("ConstructL - Exit"));
+	}
+
+/**
+ Constructor
+ */
+CPTPIPConnection::CPTPIPConnection(MMTPConnectionMgr& aConnectionMgr ) :
+									CActive(EPriorityStandard), 
+									iConnectionMgr(&aConnectionMgr)
+	{
+	CActiveScheduler::Add (this );
+	}
+
+//
+// MMTPTransportConnection functions
+//
+
+/**
+ Binds the protocol layer. 
+ @param aProtocol - The connectionProtocol provides the SPI or the observer
+ for the communication to happen from the transport to the framework. 
+ */
+void CPTPIPConnection::BindL(MMTPConnectionProtocol& aProtocol )
+	{
+	__FLOG(_L8("BindL - Entry"));
+	iProtocolLayer = &aProtocol;
+	__FLOG(_L8("BindL - Exit"));
+	}
+
+/**
+ Returns the protocol layer.
+ @return The SPI or the observer protocol layer
+ */
+MMTPConnectionProtocol& CPTPIPConnection::BoundProtocolLayer( )
+	{
+	__FLOG(_L8("BoundProtocolLayer - Entry"));
+	__ASSERT_ALWAYS(iProtocolLayer, Panic(EPTPIPBadState));
+	__FLOG(_L8("BoundProtocolLayer - Exit"));
+	return *iProtocolLayer;
+	}
+
+/**
+ Close the connection, stop all data transfer activity and and wait for the host 
+ to issue a Device Reset Request.
+ */
+void CPTPIPConnection::CloseConnection( )
+	{
+	__FLOG(_L8("CloseConnection - Entry"));
+	StopConnection ( );
+	__FLOG(_L8("CloseConnection - Exit"));
+	}
+
+/**
+ A transaction is one set of request, data transfer and response phases. 
+ The fw calls this to mark the end of an MTP transaction. 
+ */
+void CPTPIPConnection::TransactionCompleteL(const TMTPTypeRequest& /*aRequest*/)
+	{
+	__FLOG(_L8("TransactionCompleteL - Entry"));
+	__FLOG(_L8("******** Transaction Complete **************"));
+	SetTransactionPhase (EIdlePhase );
+
+	// Clear the cancel flag.
+	iCancelOnCommandState = ECancelNotReceived;
+	iCancelOnEventState = ECancelNotReceived;
+
+	// Again start listening for the command request. 
+	InitiateCommandRequestPhaseL( );
+
+	__FLOG(_L8("TransactionCompleteL - Exit"));
+	}
+
+/**
+ Called by the fw to indicate that protocol layer is not using this transport anymore 
+ and so we will not have any callback/SPI funtions to the fw any more
+ */
+void CPTPIPConnection::Unbind(MMTPConnectionProtocol& /*aProtocol*/)
+	{
+	__FLOG(_L8("Unbind - Entry"));
+	__ASSERT_DEBUG(iProtocolLayer, Panic(EPTPIPBadState));
+	// Protocol will no longer be bound to the transport
+	iProtocolLayer = NULL;
+	__FLOG(_L8("Unbind - Exit"));
+	}
+
+/**
+ Not used
+ */
+TAny* CPTPIPConnection::GetExtendedInterface(TUid /*aInterfaceUid*/)
+	{
+	return NULL;
+	}
+
+/*
+ * return PTPIP transport implementation UID
+ */
+TUint CPTPIPConnection::GetImplementationUid()
+    {
+    return KMTPPTPIPTransportImplementationUid;
+    }
+
+//
+// Active Object functions
+//
+
+/**
+ Used to cancel the outstanding requests, and reset internal states as appropriate. 
+ */
+void CPTPIPConnection::DoCancel( )
+	{
+	__FLOG(_L8("DoCancel - Entry"));
+
+	iCommandHandler->Cancel( );
+	iEventHandler->Cancel( );
+
+	SetConnectionState(ECancelled );
+
+	__FLOG(_L8("DoCancel - Exit"));
+	}
+
+/**
+The connection behaves as an active object during the PTPIP connection establishment phase.
+Subsequently, it behaves as a normal object whose functions are invoked by the MTP framework
+or by the SocketHandler on sending/ receiving data. 
+
+Thus the runl is not hit after the initial connection establishment. 
+ */
+void CPTPIPConnection::RunL( )
+	{
+	__FLOG(_L8("RunL - Entry"));
+	__FLOG_VA((_L8("Current State is %d, and status is %d"), iState, iStatus.Int()));
+
+	if(iStatus != KErrNone )
+		{
+		CloseConnection( );
+		}
+	else 
+		{
+
+		switch(iState )
+		{
+		// ConstructL is complete, 
+		// the PTPIP connection establishment will be complete after the init ack is sent.
+		case EInitialising:
+			SendInitAckL( );
+			break;
+
+			// Now the PTPIP connection has been established. 
+		case EInitialisationComplete:
+			SetConnectionState(EStartListening );
+			CompleteSelf(KErrNone );
+			break;
+
+			// Start listeing for requests on the 2 channels
+		case EStartListening:
+			InitiateEventRequestPhaseL( );
+			InitiateCommandRequestPhaseL( );
+			break;
+
+		default:
+			__FLOG(_L8("PTPIP ERROR: Invalid  connection state"));
+			Panic(EPTPIPBadState );
+			break;
+		}
+		}
+
+	__FLOG(_L8("RunL - Exit"));
+	}
+
+/**
+ Called when an error occurs in the RunL 
+ */
+#ifdef __FLOG_ACTIVE
+TInt CPTPIPConnection::RunError(TInt aError )
+#else
+TInt CPTPIPConnection::RunError(TInt /*aError*/ )
+#endif
+	{
+	__FLOG(_L8("RunError - Entry"));
+	__FLOG_VA((_L8("PTPIP ERROR: Error received is %d"), aError));
+
+	// Cancel all the outstanding requests.
+	Cancel( );
+
+	// Stop the connection, if necessary.
+	StopConnection( );
+
+	__FLOG(_L8("RunError - Exit"));
+	return KErrNone;
+	}
+
+//
+// Receive data functions
+//
+
+/**
+ Called internally to recevive the commands over the command channel. 
+ This will invoke the command handler 
+ to listen on the socket and get the data into the buffers passed. 
+ */
+void CPTPIPConnection::InitiateCommandRequestPhaseL( )
+	{
+	__FLOG(_L8("InitiateCommandRequestPhaseL - Entry"));
+	__FLOG(_L8("******** Phase 1 - Request **************"));
+	// Set current state to request phase
+	SetTransactionPhase(ERequestPhase );
+
+	// The PTPIP data buffer is a member of connection.  
+	// Since we are expecting a request now, set the payload to request type
+	iPTPIPRequestPayload.Reset( );
+	iPTPIPCommandContainer->SetPayloadL(&iPTPIPRequestPayload );
+
+	// Call the CommandHandler to get the request in the container
+	iCommandHandler->ReceiveCommandRequestL(*iPTPIPCommandContainer );
+
+	__FLOG(_L8("InitiateCommandRequestPhaseL - Exit"));
+	}
+
+/** 
+ Called to indicate completion of receive of data started by InitiateCommandRequestPhaseL.
+ There is no point in reporting the error up to the f/w since no transaction has started.
+ USB does nothing at this stage. In PTP , the connection is closed.
+ @param aError - The error if any, received from socket.
+ */
+void CPTPIPConnection::ReceiveCommandCompleteL(TInt aError )
+	{
+	__FLOG(_L8("ReceiveCommandCompleteL - Entry"));
+
+	if(KErrNone != aError )
+		{
+		__FLOG_VA((_L8("PTPIP Error: Received error=%d in request phase, closing  connection"), aError));
+		CloseConnection( );
+		}
+	else if(ValidateTransactionPhase(ERequestPhase ) )
+		{
+		// Request block received.
+		TPTPIPTypeRequestPayload* pRequest = static_cast<TPTPIPTypeRequestPayload*>(iPTPIPCommandContainer->Payload());
+
+		TUint16 op(pRequest->Uint16(TPTPIPTypeRequestPayload::EOpCode ));
+		TUint32	tran(pRequest->Uint32(TPTPIPTypeRequestPayload::ETransactionId ));
+		TUint32 sessionId = KMTPSessionNone;
+		__FLOG_VA((_L8("Command block received with op = 0x%04X ,transId = %d"), op, tran));
+
+		// Reset the iMTPRequest.
+		iMTPRequest.Reset( );
+
+		// Setup the MTP request dataset buffer. Set Operation Code and TransactionID
+		iMTPRequest.SetUint16(TMTPTypeRequest::ERequestOperationCode, op );
+		iMTPRequest.SetUint32(TMTPTypeRequest::ERequestTransactionID, tran );
+
+		// Set SessionID.
+		if(op == EMTPOpCodeOpenSession )
+			{
+			__FLOG(_L8("Processing OpenSession request"));
+			}
+		else if(op == EMTPOpCodeCloseSession || op == EMTPOpCodeResetDevice )
+			{
+			__FLOG(_L8("Processing CloseSession or the ResetDevice request"));
+			// Force CloseSession requests to be processed outside an active session. 
+			// ResetDevice currently behaves the same way as CloseSession. 
+			iMTPRequest.SetUint32(TMTPTypeRequest::ERequestParameter1,
+					iMTPSessionId );
+			}
+		else
+			{
+			sessionId = iMTPSessionId;
+			__FLOG_VA((_L8("Processing general request on session %d"), sessionId));
+			}
+		
+		iMTPRequest.SetUint32(TMTPTypeRequest::ERequestSessionID,sessionId );
+
+		// Set Parameter 1 .. Parameter 5.
+		pRequest->CopyOut(iMTPRequest, TMTPTypeRequest::ERequestParameter1,	TMTPTypeRequest::ERequestParameter5 );
+		pRequest->Reset( );
+
+		// Notify the protocol layer.
+		
+		BoundProtocolLayer().ReceivedRequestL(iMTPRequest );
+
+		}
+	__FLOG(_L8("ReceiveCommandCompleteL - Exit"));
+	}
+
+/**
+ Called to get data over the command channel,( in turn its called by f/ws ReceiveData)
+ @param aData - The buffer provided by the F/w in which to receive data.
+ */
+void CPTPIPConnection::ReceiveCommandDataL(MMTPType& aData )
+	{
+	__FLOG(_L8("ReceiveCommandDataL - Entry"));
+
+	iRecvData = 0;
+	iTotalRecvData = 0;
+	
+	// First we will receive a PTPIP start data packet which is stored in the commandContainer
+	iPTPIPCommandContainer->SetPayloadL(&iPTPIPStartDataPayload );
+
+	// The mtp buffer is passed from the framework and will be passed on as the payload.
+	// in the next ptpip data packet.
+	iPTPIPDataContainer->SetPayloadL(&aData );
+	iCommandHandler->ReceiveCommandDataL(*iPTPIPCommandContainer );
+
+	__FLOG(_L8("ReceiveCommandDataL - Exit"));
+	}
+
+/**
+ Called to indicate completion of receive of data started by ReceiveCommandDataL.
+ Any errors received are sent back up to the framework. 
+ */
+void CPTPIPConnection::ReceiveCommandDataCompleteL(TInt aError )
+	{
+	__FLOG(_L8("ReceiveCommandDataCompleteL - Entry"));
+	if(ValidateTransactionPhase(EDataIToRPhase ) )
+		{
+		// Data block received, notify the protocol layer.
+		iPTPIPDataContainer->SetUint32L(CPTPIPDataContainer::EPacketType, 0 );
+		BoundProtocolLayer().ReceiveDataCompleteL(aError, *iPTPIPDataContainer->Payload(), iMTPRequest );
+		}
+	__FLOG(_L8("ReceiveCommandDataCompleteL - Exit"));
+	}
+
+/**
+ Called by the command handler to indicate completion of receive on the command channel.
+ Now check whether it was commands or data completion and call the appropriate function. 
+ */
+
+void CPTPIPConnection::ReceiveCommandChannelCompleteL(TInt aError, MMTPType& /*aSource*/)
+	{
+	__FLOG(_L8("ReceiveCommandChannelCompleteL - Entry"));
+	__FLOG(_L8("******** Receiving 1 ptpip packet on command/data channel complete **************"));
+	HandleTCPError(aError );
+	TUint32	typeCommand = iPTPIPCommandContainer->Uint32L(CPTPIPGenericContainer::EPacketType );
+	TUint32	typeData = iPTPIPDataContainer->Uint32L(CPTPIPGenericContainer::EPacketType );
+	__FLOG_VA((_L8("type on the command buffer is %d and type on the data buffer is %d"), typeCommand, typeData ) );
+
+
+	switch (typeCommand)
+	{
+	case EPTPIPPacketTypeOperationRequest:
+		ReceiveCommandCompleteL(aError );
+		break;
+		
+	case EPTPIPPacketTypeStartData:
+		if(aError != KErrNone )
+			{
+			ReceiveCommandCompleteL(aError );
+			}
+		else
+			{
+			// Save the total data expected. 
+			iTotalRecvData =(static_cast<TPTPIPTypeStartDataPayload*>(iPTPIPCommandContainer->Payload()))->Uint64(TPTPIPTypeStartDataPayload::ETotalSize );
+			__FLOG_VA((_L8("Total data to receive in data phase is %ld"), iTotalRecvData));						
+			
+			//reset the command container 
+			iPTPIPCommandContainer->SetUint32L(CPTPIPGenericContainer::EPacketType, 0 );
+			iCommandHandler->ReceiveCommandDataL(*iPTPIPDataContainer );
+			}
+		break;
+		
+	case EPTPIPPacketTypeCancel:
+		{
+		TMTPTypeInt32* pTransId;
+		pTransId = static_cast<TMTPTypeInt32*>(iPTPIPCommandContainer->Payload());
+		iCancelOnCommandState = ECancelCmdReceived;
+		HandleCommandCancelL(pTransId->Value());
+		}
+		break;
+		
+		
+	default:
+		// No known types came on the command container, now check the data container.
+		switch (typeData)
+		{
+		case EPTPIPPacketTypeData:
+			// One PTPIP packet has been received. We will now continue getting the next PTPIP packets. 
+			iRecvData += iPTPIPDataContainer->Uint32L(CPTPIPDataContainer::EPacketLength );
+			iRecvData -= KPTPIPDataHeaderSize; // The header size is not included in the total size sent. 
+			
+			//If more data is expected,then set the flag to use the current offset
+			//in the chunk
+			if (iRecvData < iTotalRecvData)
+			{
+			iCommandHandler->iUseOffset = ETrue;	
+				
+			}
+			
+			
+			__FLOG_VA((_L8("Data received so far in data phase is %ld"), iRecvData));
+			if(iRecvData <= iTotalRecvData )
+				{
+				iCommandHandler->ReceiveCommandDataL(*iPTPIPDataContainer );
+				}
+			else
+				{
+				__FLOG_VA((_L8("PTPIP ERROR: The data received so far= %ld is more than expected data = %ld "), iRecvData, iTotalRecvData));
+				CloseConnection( );
+				}			
+			break;
+		
+		case EPTPIPPacketTypeEndData:
+			iRecvData += iPTPIPDataContainer->Uint32L(CPTPIPDataContainer::EPacketLength );
+			iRecvData -= KPTPIPDataHeaderSize; // The header size is not included in the total size sent. 
+			
+			iCommandHandler->iUseOffset = EFalse;
+			
+			__FLOG_VA((_L8("Data received so far in data phase is %ld"), iRecvData));
+			if(iTotalRecvData == iRecvData )
+				{
+				ReceiveCommandDataCompleteL(aError );
+				}
+			else
+				{
+				__FLOG_VA((_L8("PTPIP ERROR: The data received so far= %ld is not equal to expected data = %ld "), iRecvData, iTotalRecvData));
+				CloseConnection( );
+				}
+			break;
+		
+		case EPTPIPPacketTypeCancel:
+			{
+			TUint32 transId = iPTPIPDataContainer->Uint32L(CPTPIPDataContainer::ETransactionId);
+			iCancelOnCommandState = ECancelCmdReceived;
+			iPTPIPDataContainer->SetUint32L(CPTPIPDataContainer::EPacketType, 0 );
+			HandleCommandCancelL(transId);
+			}
+			break;
+		
+		default:
+			__FLOG_VA((_L8("PTPIP ERROR: Unexpected type received,  data container = %d, command container =%d "), typeData, typeCommand));
+			CloseConnection( );
+			break;
+		} // switch data
+	} // switch command
+
+	__FLOG(_L8("ReceiveCommandChannelCompleteL - Exit"));
+	}
+
+/**
+ Called by MTP fw to get data from the transport.
+ */
+void CPTPIPConnection::ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& /*aRequest*/)
+	{
+	__FLOG(_L8("ReceiveDataL - Entry"));
+	__FLOG(_L8("******** Phase 2 - Data I to R **************"));
+	SetTransactionPhase(EDataIToRPhase );
+	ReceiveCommandDataL(aData );
+	__FLOG(_L8("ReceiveDataL - Exit"));
+	}
+
+/**
+ Called by MTP fw to cancel the receiving data.
+ */
+void CPTPIPConnection::ReceiveDataCancelL(const TMTPTypeRequest& /*aRequest*/)
+	{
+	__FLOG(_L8("ReceiveDataCancelL - Entry"));
+
+	iCommandHandler->CancelReceiveL(KErrCancel );
+	__FLOG(_L8("ReceiveDataCancelL - Exit"));
+	}
+
+/**
+ This will invoke the event handler to listen on the socket and get the events 
+ into the buffers passed. 
+ */
+void CPTPIPConnection::InitiateEventRequestPhaseL( )
+	{
+	__FLOG(_L8("InitiateEventRequestPhaseL - Entry"));
+
+	// Initialise the PTP buffers to get the data. 
+	iPTPIPEventPayload.Reset( );
+	iPTPIPEventContainer->SetUint32L(CPTPIPGenericContainer::EPacketType, NULL );
+	iPTPIPEventContainer->SetUint32L(CPTPIPGenericContainer::EPacketLength,	NULL );
+	iPTPIPEventContainer->SetPayloadL(&iPTPIPEventPayload );
+
+	// Call the EventHandler
+	iEventHandler->ReceiveEventL(*iPTPIPEventContainer );
+	__FLOG(_L8("InitiateEventRequestPhaseL - Exit"));
+	}
+
+/**
+ Signals the completion of receving an event. 
+ */
+void CPTPIPConnection::ReceiveEventCompleteL(TInt aError, MMTPType& /*aSource*/)
+	{
+	__FLOG(_L8("ReceiveEventCompleteL - Entry"));
+
+	TUint32	type = iPTPIPEventContainer->Uint32L(CPTPIPGenericContainer::EPacketType );
+	__FLOG_VA((_L8("Error value is %d and type is %d"), aError, type));
+
+	if(KErrNone != aError )
+		{
+		__FLOG_VA((_L8("PTPIP Error: Received error=%d in request phase, closing  connection"), aError));
+		CloseConnection( );
+		}
+	else
+		{
+		// For a probe request, we just send a probe response and don't notify the MTP f/w. 
+		if( type == EPTPIPPacketTypeProbeRequest )
+			{
+			__FLOG(_L8("Received a probe request, sending back a probe response"));
+			// Send the response, 
+			iPTPIPEventContainer->SetPayloadL(NULL );
+			iPTPIPEventContainer->SetUint32L(CPTPIPGenericContainer::EPacketLength, iPTPIPEventContainer->Size( ) );
+			iPTPIPEventContainer->SetUint32L(CPTPIPGenericContainer::EPacketType, EPTPIPPacketTypeProbeResponse );
+
+			// Call the EventHandler
+			iEventHandler->SendEventL(*iPTPIPEventContainer );
+			}
+		else if(type == EPTPIPPacketTypeCancel )
+			{			
+			iCancelOnEventState = ECancelCmdReceived;
+			HandleEventCancelL(); 
+			}
+		else if(type == EPTPIPPacketTypeEvent )
+			{
+			// Request block received.
+			TPTPIPTypeResponsePayload* pEvent = static_cast<TPTPIPTypeResponsePayload*>(iPTPIPEventContainer->Payload());
+			TUint16	op(pEvent->Uint16(TPTPIPTypeResponsePayload::EResponseCode ));
+			__FLOG_VA((_L8("Event block 0x%04X received"), op));
+
+			// Reset the iMTPRequest.
+			iMTPEvent.Reset( );
+
+			// Setup the MTP request dataset buffer. Set Operation Code and TransactionID
+			iMTPEvent.SetUint16(TMTPTypeEvent::EEventCode, op );
+			iMTPEvent.SetUint32(TMTPTypeEvent::EEventSessionID,	iMTPSessionId );
+			iMTPEvent.SetUint32(TMTPTypeEvent::EEventTransactionID,	pEvent->Uint32(TPTPIPTypeResponsePayload::ETransactionId ) );
+
+			// Set Parameter 1 .. Parameter 3.
+			pEvent->CopyOut(iMTPRequest,TMTPTypeResponse::EResponseParameter1, TMTPTypeResponse::EResponseParameter3 );
+			pEvent->Reset( );
+
+			BoundProtocolLayer().ReceivedEventL(iMTPEvent );
+			InitiateEventRequestPhaseL( );
+			}
+		// If unexpected data is received , its ignored in the release mode. 
+		else
+			{
+			__FLOG(_L8("PTPIP ERROR : Unknown event type received, ignoring it."));
+			__ASSERT_DEBUG(type, Panic(EPTPIPBadState));
+			}
+		}
+	__FLOG(_L8("ReceiveEventCompleteL - Exit"));
+	}
+
+//
+// Send data functions
+//
+/**
+ Called by the MTP f/w to send the response to the initiator.
+ Also called from this connection itself to send the cancel response. 
+ */
+void CPTPIPConnection::SendResponseL(const TMTPTypeResponse& aResponse,	const TMTPTypeRequest& aRequest )
+	{
+	__FLOG(_L8("SendResponseL - Entry"));
+
+	// Update the transaction state.
+	SetTransactionPhase(EResponsePhase );
+	__FLOG(_L8("******** Phase 3 - Response **************"));
+	
+	if(iCancelOnCommandState  )
+		{
+		__FLOG(_L8("Cancel has been received from initiator, so send own response"));
+		
+		SendCancelResponseL(aRequest.Uint32(TMTPTypeRequest::ERequestTransactionID ));
+		}
+	else
+		{
+		TUint16	opCode(aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode ));
+		TUint16 rspCode(aResponse.Uint16(TMTPTypeResponse::EResponseCode ));
+		__FLOG_VA((_L8("ResponseCode = 0x%04X, Operation Code = 0x%04X"), rspCode, opCode));
+
+		if((opCode == EMTPOpCodeOpenSession) &&(rspCode == EMTPRespCodeOK) )
+			{
+			// An session has been opened. Record the active SessionID.
+			iMTPSessionId = aRequest.Uint32(TMTPTypeRequest::ERequestParameter1 );
+			__FLOG_VA((_L8("Processing OpenSession response, SessionID = %d"), iMTPSessionId));
+			}
+		else if(((opCode == EMTPOpCodeCloseSession) ||
+				(opCode == EMTPOpCodeResetDevice))&&(rspCode == EMTPRespCodeOK) )
+			{
+			// An session has been closed. Clear the active SessionID.        
+			__FLOG_VA((_L8("Processing CloseSession or ResetDevice response, SessionID = %d"), iMTPSessionId));
+			iMTPSessionId = KMTPSessionNone;
+			}
+
+		//Setup the parameter block payload dataset. Note that since this is a 
+		//variable length dataset, it must first be reset.
+
+		iPTPIPResponsePayload.Reset( );
+		TUint numberOfNullParam = TMTPTypeResponse::EResponseParameter5 - TMTPTypeResponse::EResponseParameter1 + 1;
+
+		iPTPIPResponsePayload.CopyIn(aResponse,	
+		                             TMTPTypeResponse::EResponseParameter1, TMTPTypeResponse::EResponseParameter5, 
+		                             ETrue,
+		                             numberOfNullParam);
+		iPTPIPResponsePayload.SetUint16(TPTPIPTypeResponsePayload::EResponseCode, rspCode );
+		iPTPIPResponsePayload.SetUint32(TPTPIPTypeResponsePayload::ETransactionId, aRequest.Uint32(TMTPTypeRequest::ERequestTransactionID ) );
+
+		// Setup the command container.
+		iPTPIPCommandContainer->SetPayloadL(const_cast<TPTPIPTypeResponsePayload*>(&iPTPIPResponsePayload) );
+		iPTPIPCommandContainer->SetUint32L(	CPTPIPGenericContainer::EPacketLength, static_cast<TUint32>(iPTPIPCommandContainer->Size()) );
+		iPTPIPCommandContainer->SetUint32L(	CPTPIPGenericContainer::EPacketType, EPTPIPPacketTypeOperationResponse );
+
+		// Initiate the command send sequence.
+		__FLOG_VA((_L8("Sending response 0x%04X(%d bytes)"),
+						iPTPIPResponsePayload.Uint16(TPTPIPTypeResponsePayload::EResponseCode),
+						iPTPIPCommandContainer->Uint32L(CPTPIPGenericContainer::EPacketLength)));
+		iCommandHandler->SendCommandL(*iPTPIPCommandContainer );
+		}
+
+	__FLOG(_L8("SendResponseL - Exit"));
+	}
+
+/**
+ Send response complete
+ */
+void CPTPIPConnection::SendCommandCompleteL(TInt aError )
+	{
+
+	__FLOG(_L8("SendCommandCompleteL - Entry"));
+
+	if(ValidateTransactionPhase(EResponsePhase ) )
+		{
+		BoundProtocolLayer().SendResponseCompleteL( aError,
+		                                            *static_cast<TMTPTypeResponse*>(iPTPIPCommandContainer->Payload()), 
+		                                            iMTPRequest );
+		}
+	__FLOG(_L8("SendCommandCompleteL - Exit"));
+	}
+
+/**
+ Send data complete
+ */
+void CPTPIPConnection::SendCommandDataCompleteL(TInt aError )
+	{
+	__FLOG(_L8("SendCommandDataCompleteL - Entry"));
+
+	if(ValidateTransactionPhase(EDataRToIPhase ) )
+		{
+		BoundProtocolLayer().SendDataCompleteL(aError, *iPTPIPDataContainer->Payload(), iMTPRequest );
+		}
+	SetConnectionState(EDataSendFinished);
+	iPTPIPDataContainer->SetPayloadL(NULL );
+
+	__FLOG(_L8("SendCommandDataCompleteL - Exit"));
+	}
+
+/**
+ Called by the command handler to indicate completion of send on the command channel.
+ Now check whether it was commands or data completion and call the appropriate function. 
+ */
+void CPTPIPConnection::SendCommandChannelCompleteL(TInt aError, const MMTPType& /*aSource*/)
+	{
+	__FLOG(_L8("SendCommandChannelCompleteL - Entry"));
+
+	// Now see whether we have completed getting data or commands, and call the appropriate function.
+	TUint typeCommand = iPTPIPCommandContainer->Uint32L(CPTPIPGenericContainer::EPacketType );
+	TUint typeData = iPTPIPDataContainer->Uint32L(CPTPIPGenericContainer::EPacketType );
+	__FLOG_VA((_L8("type on the command buffer is %d and type on the data buffer is %d"), typeCommand, typeData ) );
+	
+	
+	// if we have received a cancel on the event channel then terminate the current sending
+	// and handle the receiving and sending of cancel on the channel.
+	if (iCancelOnEventState && !iCancelOnCommandState)
+		{
+		HandleCancelDuringSendL(); 	
+		}
+	
+	// A command has been sent
+	else if((EPTPIPPacketTypeOperationResponse == typeCommand) &&(0 == typeData) )
+		{
+		// If this response was a cancel, then we don't inform the framework, as it was internally generated
+		if(iCancelOnCommandState )
+			{
+			iCancelOnCommandState = ECancelCmdHandled;
+			SendCommandCompleteL(aError );
+			HandleCommandCancelCompleteL( );
+			}
+		// Tell the framework that a command has been received. 
+		else
+			{
+			iPTPIPCommandContainer->SetUint32L(CPTPIPGenericContainer::EPacketType, 0 );
+			SendCommandCompleteL(aError );
+			}
+		}
+
+	// Tell the connection that data has been sent.
+	else if((EPTPIPPacketTypeEndData == typeData) &&(0 == typeCommand ) )
+			{
+			iPTPIPDataContainer->SetUint32L(CPTPIPDataContainer::EPacketType, 0 );
+			SendCommandDataCompleteL(aError );
+			}
+
+	// We sent the start data packet, and we now have to send the actual data.  
+	else if((EPTPIPPacketTypeStartData == typeCommand) &&(EDataSendInProgress == iState ) )
+			{
+			iPTPIPCommandContainer->SetUint32L(	CPTPIPGenericContainer::EPacketType, 0 );
+			SendDataPacketL( );
+			}
+
+	// Any other type indicates a programming error, and a panic is raised. 
+	else
+		{
+		__FLOG_VA((_L8("PTPIP ERROR: Unexpected type in sent data, type = = %d, command =%d "), typeData, typeCommand));
+		Panic(EPTPIPBadState );
+		}
+
+	__FLOG(_L8("SendCommandChannelCompleteL - Exit"));
+	}
+
+/**
+ Called by the MTP fw to send the data by the transport via the sockets
+ */
+void CPTPIPConnection::SendDataL(const MMTPType& aData,	const TMTPTypeRequest& aRequest )
+	{
+	__FLOG(_L8("SendDataL - Entry"));
+
+	__FLOG(_L8("******** Phase 2 - Data R to I **************"));
+	SetTransactionPhase(EDataRToIPhase );
+	SetConnectionState(EDataSendInProgress );
+
+	// Save the actual data in the dataContainer
+	iPTPIPDataContainer->SetPayloadL(const_cast<MMTPType*>(&aData) );
+	iPTPIPDataContainer->SetUint32L(CPTPIPDataContainer::EPacketLength,	iPTPIPDataContainer->Size( ) );
+
+	iPTPIPDataContainer->SetUint32L(CPTPIPDataContainer::EPacketType,EPTPIPPacketTypeEndData );
+	iPTPIPDataContainer->SetUint32L(CPTPIPDataContainer::ETransactionId,aRequest.Uint32(TMTPTypeRequest::ERequestTransactionID ) );
+
+	// Create the start data ptpip packet. 
+	iPTPIPStartDataPayload.Reset( );
+	iPTPIPStartDataPayload.SetUint32(TPTPIPTypeStartDataPayload::ETransactionId, aRequest.Uint32(TMTPTypeRequest::ERequestTransactionID ) );
+	iPTPIPStartDataPayload.SetUint64(TPTPIPTypeStartDataPayload::ETotalSize, aData.Size( ) );
+
+	iPTPIPCommandContainer->SetPayloadL(&iPTPIPStartDataPayload );
+	iPTPIPCommandContainer->SetUint32L(CPTPIPGenericContainer::EPacketLength, iPTPIPCommandContainer->Size( ) );
+	iPTPIPCommandContainer->SetUint32L(CPTPIPGenericContainer::EPacketType,	EPTPIPPacketTypeStartData );
+
+	// First send the start data packet, once this is complete, it will invoke the 
+	// SendCommandChannelCompleteL, where we will check the state and send the 
+	// actual data in the next packet, which has been saved in the dataContainer. 
+	SendStartDataPacketL( );
+
+	__FLOG(_L8("SendDataL - Exit"));
+	}
+
+/**
+ The data will be sent in 2 ptpip operations. 
+ first the start data ptpip packet will be sent. This has the totalk size and transaction. 
+ next the actual data packet will be sent, with the end data ptp ip header.
+ */
+void CPTPIPConnection::SendStartDataPacketL( )
+	{
+	__FLOG(_L8("SendStartDataPacketL - Entry"));
+
+	SetConnectionState(EDataSendInProgress );
+	iCommandHandler->SendCommandL(*iPTPIPCommandContainer );
+	__FLOG(_L8("SendStartDataPacketL - Exit"));
+	}
+
+/**
+ Send the actual data, which has come from the MTP framework 
+ */
+void CPTPIPConnection::SendDataPacketL( )
+	{
+	__FLOG(_L8("SendDataPacketL - Entry"));
+	
+	MMTPType* payLoad = iPTPIPDataContainer->Payload();
+	
+	TPtr8 headerChunk(NULL, 0);
+	TBool hasTransportHeader = payLoad->ReserveTransportHeader(KPTPIPDataHeaderSize, headerChunk);
+	if (hasTransportHeader)
+	    {
+        const TInt KLengthOffset = 0;
+        const TInt KTypeOffset = 4;
+        const TInt KXIDOffset = 8;
+        TUint32 pkgLength = iPTPIPDataContainer->Uint32L(CPTPIPDataContainer::EPacketLength);
+        TUint32 pkgType = iPTPIPDataContainer->Uint32L(CPTPIPDataContainer::EPacketType);
+        TUint32 transId = iPTPIPDataContainer->Uint32L(CPTPIPDataContainer::ETransactionId);
+        
+        memcpy(&(headerChunk[KLengthOffset]), &pkgLength, sizeof(TUint32));
+        memcpy(&(headerChunk[KTypeOffset]), &pkgType, sizeof(TUint32));
+        memcpy(&(headerChunk[KXIDOffset]), &transId, sizeof(TUint32));
+
+        SetConnectionState(EDataSendInProgress );
+        iCommandHandler->SendCommandDataL(*payLoad, transId);
+	    }
+	else
+	    {
+	    
+	    SetConnectionState(EDataSendInProgress );
+	    iCommandHandler->SendCommandDataL(*iPTPIPDataContainer,	iPTPIPDataContainer->Uint32L(TMTPTypeRequest::ERequestTransactionID ) );
+	    }
+
+	__FLOG(_L8("SendDataPacketL - Exit"));
+	}
+
+/**
+ Called by the fw to cancel the sending of data
+ */
+void CPTPIPConnection::SendDataCancelL(const TMTPTypeRequest& /*aRequest*/)
+	{
+	__FLOG(_L8("SendDataCancelL - Entry"));
+	iCommandHandler->CancelSendL(KErrCancel );
+	__FLOG(_L8("SendDataCancelL - Exit"));
+	}
+
+/**
+ Called by the fw to send an event. 
+ */
+void CPTPIPConnection::SendEventL(const TMTPTypeEvent& aEvent )
+	{
+	__FLOG(_L8("SendEventL - Entry"));
+
+    // Reset the event.
+    iMTPEvent.Reset(); 
+    MMTPType::CopyL(aEvent, iMTPEvent);
+    
+	TUint16 opCode(aEvent.Uint16(TMTPTypeEvent::EEventCode ));
+	TUint32 tran(aEvent.Uint32(TMTPTypeEvent::EEventTransactionID ));
+	__FLOG_VA((_L8(" Sending event with Operation Code = 0x%04X and tran id = %d"), opCode, tran ));
+
+	TBool isNullParamValid = EFalse;
+	TUint numberOfNullParam = 0;
+
+	iPTPIPEventPayload.CopyIn(aEvent, 
+	                          TMTPTypeResponse::EResponseParameter1,TMTPTypeResponse::EResponseParameter3, 
+	                          isNullParamValid,
+	                          numberOfNullParam );
+	
+	iPTPIPEventPayload.SetUint16(TPTPIPTypeResponsePayload::EResponseCode, opCode );
+	iPTPIPEventPayload.SetUint32(TPTPIPTypeResponsePayload::ETransactionId,	tran );
+
+	// Setup the bulk container.
+	iPTPIPEventContainer->SetPayloadL(const_cast<TPTPIPTypeResponsePayload*>(&iPTPIPEventPayload) );
+	iPTPIPEventContainer->SetUint32L(CPTPIPGenericContainer::EPacketLength,	static_cast<TUint32>(iPTPIPEventContainer->Size()) );
+	iPTPIPEventContainer->SetUint32L(CPTPIPGenericContainer::EPacketType, EPTPIPPacketTypeEvent );
+
+	// Initiate the event send sequence.
+	__FLOG_VA((_L8("Sending response 0x%04X(%d bytes)"),
+					iPTPIPEventPayload.Uint16(TPTPIPTypeResponsePayload::EResponseCode),
+					iPTPIPEventContainer->Uint32L(CPTPIPGenericContainer::EPacketLength)));
+
+	iEventHandler->SendEventL(*iPTPIPEventContainer );
+	__FLOG(_L8("SendEventL - Exit"));
+	}
+
+/**
+ Marks the completion of the asynchronous send event. 
+ */
+void CPTPIPConnection::SendEventCompleteL(TInt aError, const MMTPType& /*aSource*/)
+	{
+	__FLOG(_L8("SendEventCompleteL - Entry"));
+	TUint type = iPTPIPEventContainer->Uint32L(CPTPIPGenericContainer::EPacketType );
+
+	// Notify the fw that event was sent. 
+	if(type == EPTPIPPacketTypeEvent )
+		{
+		// Notify the fw
+		BoundProtocolLayer().SendEventCompleteL(aError, iMTPEvent );
+		}
+
+#ifdef _DEBUG
+	//In case we sent a probe response, we dont' need to notify the fw.
+	else
+		if(type == EPTPIPPacketTypeProbeResponse )
+			{
+			__FLOG(_L8("Probe response was sent successfully"));
+			}
+		else
+			{
+			// If unexpected data was sent , it is ignored in the release mode. 
+			__FLOG(_L8("PTPIP ERROR: An invalid send event completion signalled"));
+			__ASSERT_DEBUG(type, Panic(EPTPIPBadState));
+			}
+#endif
+	
+	// Restart listening for events
+	InitiateEventRequestPhaseL( );
+	__FLOG(_L8("SendEventCompleteL - Exit"));
+	}
+
+//
+// Cancel handling functions
+//
+
+/**
+ Handle the cancel on the event channel. This can come before 
+ or after the cancel on the command channle, and it can also come 
+ in any of the MTP transaction states ( request, response, data)
+ */
+void CPTPIPConnection::HandleEventCancelL( )
+	{
+	__FLOG(_L8("HandleEventCancelL - Entry"));
+	__FLOG_VA((_L8("iCancelOnCommandState = 0x%04X, and  iCancelOnEventState = 0x%04X"), iCancelOnCommandState, iCancelOnEventState));
+
+	// Check whether the cancel has already been received on the command channel. 
+	// If so then we can simply ignore this on the event channel. 
+	switch(iCancelOnCommandState )
+		{
+		case ECancelCmdHandled:
+			// Cancel has already been received and handled on the command channel
+			// ignore the cancel on event channel and reset the state to none, 
+			// and start listening for the next transaction.
+			iCancelOnCommandState = ECancelNotReceived;
+			iCancelOnEventState = ECancelNotReceived;
+			InitiateEventRequestPhaseL();
+			break;
+
+		case ECancelCmdReceived:
+		case ECancelCmdHandleInProgress:
+			// cancel has already been received on the command channel and is being 
+			// handled. Ignore the cancel on event channel. 
+			iCancelOnEventState = ECancelEvtHandled;
+			break;
+
+		case ECancelNotReceived:
+			// cancel on command has not yet been received. depending on the current 
+			// mtp transaction state, handle the cancel. 
+
+			switch(iTransactionState )
+				{
+				case EDataIToRPhase:
+					SetNULLPacketL();
+					iCancelOnEventState = ECancelEvtHandled;
+					break;
+
+				case EDataRToIPhase:
+					// Set the commandHandler's cancel flag on. 
+					// It will complete sending the current PTPIP packet and then handle.
+					// Once a PTPIP packet has been sent , the sendCommandChannel complete will 
+					// be invoked, and the cancel will be checked and handled. 
+					iCancelOnEventState = ECancelEvtHandled;
+					iCommandHandler->SetCancel();
+					break;
+
+				case EResponsePhase:
+				case ERequestPhase:
+				default:
+					__FLOG(_L8(" Cancel received on event channel during a non data phase, ignoring, as this will be handled when its received on command channel."));
+					iCancelOnEventState = ECancelEvtHandled;
+					break;
+				}// end of switch for transaction phase.
+
+			break;
+		default:
+			break;
+		}
+	__FLOG(_L8("HandleEventCancelL - Exit"));
+	}
+
+/** 
+ Handle the cancel on the command channel. This can come before 
+ or after the cancel on the event channel, and it can also come 
+ in any of the MTP transaction states ( request, response, data)
+ */
+void CPTPIPConnection::HandleCommandCancelL(TUint32 aTransId )
+	{
+	__FLOG(_L8("HandleCommandCancelL - Entry"));
+
+	switch(iTransactionState )
+		{
+		case ERequestPhase:
+			__FLOG(_L8(" Cancel received during the request phase before the request packet, ignoring."));
+			iCancelOnCommandState = ECancelCmdHandled;
+			if (iCancelOnEventState == ECancelNotReceived)
+				{
+				// Wait for it to be received on event
+				__FLOG(_L8("Awaiting cancel on the event channel."));
+				}
+			else
+				{
+				HandleCommandCancelCompleteL();
+				}			
+			InitiateCommandRequestPhaseL();
+			break;
+			
+		case EDataRToIPhase:
+			iCancelOnCommandState = ECancelCmdHandleInProgress;
+			SendCancelToFrameworkL(aTransId );
+			SendCommandDataCompleteL(KErrCancel);
+			break;
+			
+		case EDataIToRPhase:
+			iCancelOnCommandState = ECancelCmdHandleInProgress;
+			SendCancelToFrameworkL(aTransId );
+			ReceiveCommandDataCompleteL(KErrCancel);
+			break;
+			
+		case EResponsePhase:
+			iCancelOnCommandState = ECancelCmdHandled;
+			if (iCancelOnEventState == ECancelNotReceived)
+				{
+				// Wait for it to be received on event
+				__FLOG(_L8("Awaiting cancel on the event channel."));
+				}
+			else
+				{
+				HandleCommandCancelCompleteL();
+				}
+			
+			break;
+		}// switch
+
+	__FLOG(_L8("HandleCommandCancelL - Exit"));
+	}
+	
+	
+void CPTPIPConnection::HandleCancelDuringSendL()
+	{
+	__FLOG(_L8("HandleCancelDuringSendL - Entry"));	
+	iCommandHandler->Cancel( );
+	// Now start listening for the cancel on command channel.
+	iPTPIPDataContainer->SetUint32L(CPTPIPDataContainer::EPacketType, 0 );
+	iPTPIPCommandContainer->SetUint32L(	CPTPIPGenericContainer::EPacketType, 0 );
+	iPTPIPCommandCancelPayload.Set(0 );
+	iPTPIPCommandContainer->SetPayloadL(&iPTPIPCommandCancelPayload );
+	iCommandHandler->ReceiveCommandRequestL(*iPTPIPCommandContainer );	
+	__FLOG(_L8("HandleCancelDuringSendL - Exit"));
+	}
+
+/**
+ Called when the reponse to the cancel has been sent to the initiator
+ */
+void CPTPIPConnection::HandleCommandCancelCompleteL( )
+	{
+	__FLOG(_L8("HandleCommandCancelCompleteL - Entry"));	
+	//now cancel handling is complete.
+
+	if((ECancelCmdHandled == iCancelOnCommandState) &&(ECancelEvtHandled == iCancelOnEventState) )
+		{
+		__FLOG(_L8("Completed handling cancel on both channels. "));
+		// Cancel has already been received and handled on the command channel
+		// ignore the cancel on event channel and reset the state to none, 
+		// and start listening for the next transaction.
+		iCancelOnCommandState = ECancelNotReceived;
+		iCancelOnEventState = ECancelNotReceived;
+		// The transaction has been cancelled, now start listening again for next transaction.
+		InitiateEventRequestPhaseL();
+		}
+	// if the cancel has not been received yet on event, we wait for it. 
+	else if(ECancelEvtHandled != iCancelOnEventState )
+		{
+		__FLOG(_L8("Waiting for the cancel on the event channel. "));
+		}
+	__FLOG(_L8("HandleCommandCancelCompleteL - Exit"));
+	}
+
+/**
+ Inform the MTP framework that a cancel has been received. 
+ */
+void CPTPIPConnection::SendCancelToFrameworkL(TUint32 aTransId )
+	{
+	__FLOG(_L8("SendCancelToFramework - Entry"));
+
+	// Setup the MTP request dataset buffer. Set Operation Code and TransactionID
+	iMTPEvent.Reset( );
+	iMTPEvent.SetUint16(TMTPTypeEvent::EEventCode,	EMTPEventCodeCancelTransaction );
+	iMTPEvent.SetUint32(TMTPTypeEvent::EEventSessionID, iMTPSessionId );
+	iMTPEvent.SetUint32(TMTPTypeEvent::EEventTransactionID, aTransId );
+
+	BoundProtocolLayer().ReceivedEventL(iMTPEvent );
+	__FLOG(_L8("SendCancelToFramework - Exit"));
+	}
+
+/**
+ Send the response to the cancel event. 
+ */
+void CPTPIPConnection::SendCancelResponseL(TUint32 aTransId )
+	{
+	__FLOG(_L8("SendCancelResponse - Entry"));
+	iPTPIPResponsePayload.Reset( );
+	iPTPIPResponsePayload.SetUint16(TPTPIPTypeResponsePayload::EResponseCode, EMTPRespCodeTransactionCancelled );
+	iPTPIPResponsePayload.SetUint32(TPTPIPTypeResponsePayload::ETransactionId, aTransId );
+
+	// Setup the command container.
+	iPTPIPCommandContainer->SetPayloadL(const_cast<TPTPIPTypeResponsePayload*>(&iPTPIPResponsePayload) );
+	iPTPIPCommandContainer->SetUint32L(CPTPIPGenericContainer::EPacketLength, static_cast<TUint32>(iPTPIPCommandContainer->Size()) );
+	iPTPIPCommandContainer->SetUint32L(CPTPIPGenericContainer::EPacketType,	EPTPIPPacketTypeOperationResponse );
+
+	// Initiate the command send sequence.
+	__FLOG_VA((_L8("Sending response 0x%04X(%d bytes)"),
+					iPTPIPResponsePayload.Uint16(TPTPIPTypeResponsePayload::EResponseCode),
+					iPTPIPCommandContainer->Uint32L(CPTPIPGenericContainer::EPacketLength)));
+	iCommandHandler->SendCommandL(*iPTPIPCommandContainer );
+	__FLOG(_L8("SendCancelResponse - Exit"));
+	}
+
+/**
+ * If the cancel packet is received on the event channel first
+ * and we are in the DataItoR phase, we have to continue reading and ignoreing the 
+ * data packets sent by the initiator, into dummy buffers until the cancel packet is received. 
+ */
+void CPTPIPConnection::SetNULLPacketL()
+	{
+	__FLOG(_L8("SetNULLPacketL - Entry"));
+    // Setup the bulk container and initiate the bulk data receive sequence.
+    iNullBuffer.Close();
+    iNullBuffer.CreateL(KMTPNullChunkSize);
+    iNullBuffer.SetLength(KMTPNullChunkSize);
+    iNull.SetBuffer(iNullBuffer);
+	iPTPIPDataContainer->SetPayloadL(&iNull);
+	__FLOG(_L8("SetNULLPacketL - Exit"));
+	}
+
+//
+// Getters , Setters and other helper functions
+//
+
+/**
+ This function will transfer the two command and event sockets from the Controller
+ and indicate the successful transfer to the PTP controller
+ @leave - In case the Publish and Subscribe mechanism gives any errors while getting the 
+ property names, then a leave occurs. 
+ Also in case opening or transferring the socket fails, a leave is generated. 
+ */
+void CPTPIPConnection::TransferSocketsL( )
+	{
+
+	__FLOG(_L8("TransferSocketsL - Entry"));
+
+	TName evtsockname, cmdsockname;
+	TUid propertyUid=iConnectionMgr->ClientSId();
+	User::LeaveIfError(RProperty::Get(propertyUid, ECommandSocketName,	cmdsockname ));
+	User::LeaveIfError(RProperty::Get(propertyUid, EEventSocketName, evtsockname ));
+
+	RSocketServ serversocket;
+	TInt err=serversocket.Connect( );
+	__FLOG_VA((_L8("Connected to socketServer with %d code"), err) );
+	
+	if (KErrNone == err)
+		{			
+		User::LeaveIfError(iCommandHandler->Socket().Open(serversocket ));
+		User::LeaveIfError(iEventHandler->Socket().Open(serversocket ));
+	
+		User::LeaveIfError(err=iCommandHandler->Socket().Transfer(serversocket, cmdsockname ));
+		User::LeaveIfError(err=iEventHandler->Socket().Transfer(serversocket, evtsockname ));
+		}
+	
+	iCommandHandler->SetSocketOptions();
+	iEventHandler->SetSocketOptions();
+
+	__FLOG(_L8("TransferSocketsL - Exit"));
+	}
+
+
+/**
+ Connection establishment has 4 steps, the first 3 are completed by the controller process:
+
+ 1. Initiator connects to command socket, sends the init command request
+ 2. Responder replies with the init command ack
+ 3. Initiator connects to the command socket, sends the init event request
+
+ 4. Responder replies with the init event ack or init event fail. 
+
+ The last step of sending the init ack is done by the transport plugin from 
+ the mtp process. This is done after the the framework has loaded, the sockets have
+ been transferred to this process and the transport is up. 
+ */
+void CPTPIPConnection::SendInitAckL( )
+	{
+
+	__FLOG(_L8("SendInitAckL - Entry"));
+
+	iPTPIPEventContainer->SetPayloadL(NULL );
+	iPTPIPEventContainer->SetUint32L(TPTPIPInitEvtAck::ELength,	iPTPIPEventContainer->Size( ) );
+	iPTPIPEventContainer->SetUint32L(TPTPIPInitEvtAck::EType, EPTPIPPacketTypeEventAck );
+
+	// Send the packet
+	iEventHandler->SendInitAck(iPTPIPEventContainer );
+
+	__FLOG(_L8("SendInitAckL - Exit"));
+	}
+
+/**
+ Stop the connection. 
+
+ First cancel the command and socket handlers which are controlled by it
+ and complete any data send of receive commands with error code of abort. 
+
+ Also inform the fw that connection is closed. 
+
+ */
+void CPTPIPConnection::StopConnection( )
+	{
+	__FLOG(_L8("StopConnection - Entry"));
+
+	if(ConnectionOpen( ) )
+		{
+		__FLOG(_L8("Stopping socket handlers"));
+		iEventHandler->Cancel( );
+		iCommandHandler->Cancel( );
+		if(iTransactionState == EDataIToRPhase )
+			{
+			__FLOG(_L8("Aborting active I to R data phase"));
+			TRAPD(err, BoundProtocolLayer().ReceiveDataCompleteL(KErrAbort, *iPTPIPDataContainer->Payload(), iMTPRequest));
+			UNUSED_VAR(err);
+			}
+		else
+			if(iTransactionState == EDataRToIPhase )
+				{
+				__FLOG(_L8("Aborting active R to I data phase"));
+				TRAPD(err, BoundProtocolLayer().SendDataCompleteL(KErrAbort, *iPTPIPDataContainer->Payload(), iMTPRequest))	;
+				UNUSED_VAR(err);
+				}
+
+		__FLOG(_L8("Notifying protocol layer connection closed"));
+		iConnectionMgr->ConnectionClosed(*this );
+		SetTransactionPhase(EUndefined );
+		SetConnectionState(EIdle );
+		}
+
+	__FLOG(_L8("StopConnection - Exit"));
+	}
+
+/**
+ * Invoked by the SocketHandler when there is an error.
+ */
+#ifdef __FLOG_ACTIVE
+void CPTPIPConnection::HandleError(TInt aError)
+#else
+void CPTPIPConnection::HandleError(TInt /*aError*/)
+#endif
+	{
+	__FLOG_VA((_L8("SocketHandler received an error=%d, stopping connection.)"),aError));
+	StopConnection();
+	}
+
+/**
+ Used to trigger the RunL, by first setting itself to active and 
+ then simulating a fake asynchronous service provider which will complete us 
+ with a completion code.
+ */
+void CPTPIPConnection::CompleteSelf(TInt aCompletionCode )
+	{
+	// Setting ourselves active to wait to be done by ASP.
+	SetActive( );
+
+	// Simulating a fake ASP which completes us.
+	TRequestStatus* stat = &iStatus;
+	User::RequestComplete(stat, aCompletionCode );
+	}
+
+/**
+ Setter for transaction phase(request, dataItoR, dataRtoI, or response)
+ */
+void CPTPIPConnection::SetTransactionPhase(TMTPTransactionPhase aPhase )
+	{
+	__FLOG(_L8("SetTransactionPhase - Entry"));
+	iTransactionState = aPhase;
+	__FLOG_VA((_L8("Transaction Phase set to 0x%08X"), iTransactionState));
+	__FLOG(_L8("SetTransactionPhase - Exit"));
+	}
+
+/**
+ Setter for connection state,( initialising, send data, etc)
+ */
+void CPTPIPConnection::SetConnectionState(TConnectionState aState )
+	{
+	__FLOG(_L8("SetConnectionState - Entry"));
+	iState = aState;
+	__FLOG_VA((_L8("Connection state set to 0x%08X"), iState));
+	__FLOG(_L8("SetConnectionState - Exit"));
+	}
+
+/**
+ Getter 
+ */
+TBool CPTPIPConnection::ConnectionOpen( ) const
+	{
+	return((iState >= EInitialising) && (iState <= EDataSendFinished));
+	}
+
+/**
+ Getter for the command container, 
+ */
+CPTPIPGenericContainer* CPTPIPConnection::CommandContainer( )
+	{
+	return iPTPIPCommandContainer;
+	}
+
+/**
+ Getter for the event container
+ */
+CPTPIPGenericContainer* CPTPIPConnection::EventContainer( )
+	{
+	return iPTPIPEventContainer;
+	}
+
+/**
+ Getter for the data container
+ */
+CPTPIPDataContainer* CPTPIPConnection::DataContainer( )
+	{
+	return iPTPIPDataContainer;
+	}
+
+/**
+ Getter for the transaction phase: request, dataItoR, dataRtoI or response
+ */
+TMTPTransactionPhase CPTPIPConnection::TransactionPhase( ) const
+	{
+	return iTransactionState;
+	}
+
+/**
+ Takes the 4 bytes from the chunk(iReceiveChunkData) and return 
+ whether the type is a valid request, cancel or probe packet. 
+
+ @return: The container type, in case of an unknown type, 
+ the value 0 ( undefined) is returned
+
+ */
+TUint32 CPTPIPConnection::ValidateAndSetCommandPayloadL( )
+	{
+	__FLOG(_L8("ValidateAndSetCommandPayload - Entry"));
+
+	TUint32 containerType = CommandContainer()->Uint32L(CPTPIPGenericContainer::EPacketType );
+	
+	__FLOG_VA((_L8("PTP packet type  = %d, adjust payload accordingly"), containerType));
+
+	switch(containerType )
+		{
+		case EPTPIPPacketTypeOperationRequest:
+			if (!ValidateTransactionPhase(ERequestPhase ))
+				{
+				__FLOG(_L8("PTPIP ERROR: Request data unexpected in this phase, setting type to undefined"));
+				containerType = EPTPIPPacketTypeUndefined;
+				}
+			// Nothing to do , the payload is already set.  In case this is unexpected, 
+			//then the validate function will close the connection. 
+			break;
+
+		case EPTPIPPacketTypeStartData:
+			if (!ValidateTransactionPhase(EDataIToRPhase ))
+				{
+				__FLOG(_L8("PTPIP ERROR: Start data unexpected in this phase, setting type to undefined"));
+				containerType = EPTPIPPacketTypeUndefined;
+				}
+			// Nothing to do , the payload is already set.  In case this is unexpected, 
+			//then the validate function will close the connection. 
+			break;
+
+		case EPTPIPPacketTypeCancel:
+			// This can come on the command channel either during the data phase or 
+			// during the command phase. 
+			// In data phase, no payload is needed on the data container. 
+			if (EDataIToRPhase == iTransactionState)
+				{
+				DataContainer()->SetPayloadL(NULL);
+				}
+			else 
+				{
+				CommandContainer()->SetPayloadL(&iPTPIPCommandCancelPayload );
+				}
+			break;
+			
+		case EPTPIPPacketTypeOperationResponse:
+			__FLOG(_L8("PTPIP ERROR: Response not expected from the initiator, setting type to undefined"));
+			containerType = EPTPIPPacketTypeUndefined;			
+			// As per the protocol, the initiator cannot send a response, 
+			// only the responder( here device)  will create a response, 
+			// if this is recieved it is an erro
+			break;
+			
+
+		default:
+			__FLOG_VA((_L8("PTPIP ERROR: Invalid packet type received %d )"), containerType));
+			containerType = EPTPIPPacketTypeUndefined;
+			break;
+		}
+
+	__FLOG(_L8("ValidateAndSetCommandPayload - Exit"));
+	return containerType;
+	}
+
+/**
+ Takes the 4 bytes from the chunk(iReceiveChunkData) and return 
+ whether the type is a valid event packet. 
+
+ @return: The container type, in case of an unknown type, 
+ the value 0 ( undefined) is returned
+
+ */
+TUint32 CPTPIPConnection::ValidateDataPacketL( )
+	{
+	__FLOG(_L8("ValidateDataPacketL - Entry"));
+
+	TUint32 containerType = DataContainer()->Uint32L(CPTPIPDataContainer::EPacketType );
+	__FLOG_VA((_L8("PTP data packet type  = %d, "), containerType));
+
+	switch(containerType )
+		{
+		case EPTPIPPacketTypeData:
+		case EPTPIPPacketTypeEndData:
+			if (!ValidateTransactionPhase(EDataIToRPhase ))
+				{
+				__FLOG(_L8("PTPIP ERROR: Receiving data unexpected in this phase, setting type to undefined"));
+				containerType = EPTPIPPacketTypeUndefined;
+				}
+			break;
+
+		default:
+			__FLOG_VA((_L8("PTPIP ERROR: Unexpected or Invalid packet type received while expecting data packet%d )"), containerType));
+			containerType = EPTPIPPacketTypeUndefined;
+			break;
+		}
+
+	__FLOG(_L8("ValidateDataPacket - Exit"));
+	return containerType;
+	}
+
+/**
+ Takes the 4 bytes from the chunk(iReceiveChunkData) and return 
+ whether the type is a valid event packet. 
+
+ @return: The container type, in case of an unknown type, 
+ the value 0 ( undefined) is returned
+
+ */
+TUint32 CPTPIPConnection::ValidateAndSetEventPayloadL( )
+	{
+	__FLOG(_L8("ValidateAndSetEventPayload - Entry"));
+
+	TUint32 containerType = EventContainer()->Uint32L(CPTPIPGenericContainer::EPacketType );
+	__FLOG_VA((_L8("PTP event packet type  = %d, adjust payload accordingly"), containerType));
+
+	switch(containerType )
+		{
+		case EPTPIPPacketTypeProbeRequest:
+			EventContainer()->SetPayloadL(NULL );
+			break;
+
+		case EPTPIPPacketTypeCancel:
+			EventContainer()->SetPayloadL(&iPTPIPEventCancelPayload );
+			break;
+
+		case EPTPIPPacketTypeEvent:
+			EventContainer()->SetPayloadL(&iPTPIPEventPayload );
+			break;
+
+		default:
+			__FLOG_VA((_L8("PTPIP ERROR: Invalid packet type received %d )"), containerType));
+			containerType = EPTPIPPacketTypeUndefined;
+			break;
+		}
+
+	__FLOG(_L8("ValidateAndSetEventPayload - Exit"));
+	return containerType;
+	}
+
+/**
+ Processes bulk transfer request transaction state checking. If the transaction 
+ state is invalid, then the connection is shutdown.
+ @return ETrue if the control request completion status was abnormal, otherwise
+ EFalse.
+ */
+TBool CPTPIPConnection::ValidateTransactionPhase(
+		TMTPTransactionPhase aExpectedTransactionState )
+	{
+	__FLOG(_L8("ValidateTransactionPhase - Entry"));
+	__FLOG_VA((_L8("transaction state = %d"), iTransactionState));
+	TBool valid(iTransactionState == aExpectedTransactionState);
+	if(!valid )
+		{
+		// Invalid transaction state, close the connection.
+		__FLOG_VA((_L8("PTPIP ERROR: invalid transaction state, current = %d, expected = %d"), iTransactionState, aExpectedTransactionState));
+		CloseConnection( );
+		}
+	__FLOG(_L8("ValidateTransactionPhase - Exit"));
+	return valid;
+	}
+
+/**
+ Convert the TCP errors, the disconnect should be reported as an abort, 
+ since that is what the MTP frameword expects.
+ */
+TBool CPTPIPConnection::HandleTCPError(TInt& aError )
+	{
+	__FLOG(_L8("TCPErrorHandled - Entry"));
+	TInt ret(EFalse);
+	if(aError == KErrDisconnected || aError == KErrEof)
+		{
+		aError = KErrAbort;
+		CloseConnection( );
+		ret = ETrue;
+		}
+	__FLOG(_L8("TCPErrorHandled - Exit"));
+	return ret;
+	}
+
+void CPTPIPConnection::SetDataTypeInDataContainerL(TPTPIPPacketTypeCode aType )
+	{
+	iPTPIPDataContainer->SetUint32L(CPTPIPDataContainer::EPacketType, aType );
+	}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipplugin/src/cptpipeventhandler.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,174 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// ceventhandler.cpp
+// 
+//
+
+/**
+ @internalComponent
+*/
+
+#include "cptpipeventhandler.h"
+#include "tptpipinitevtack.h"
+#include "ptpippanic.h"
+
+__FLOG_STMT(_LIT8(KComponent,"CEventHandler");) 
+
+/**
+Creates the channel for commands. The base class constructl is called. 
+*/
+CPTPIPEventHandler* CPTPIPEventHandler::NewL(CPTPIPConnection& aConnection)
+	{
+	
+	CPTPIPEventHandler* self = new(ELeave) CPTPIPEventHandler(aConnection);
+	CleanupStack::PushL(self);
+#ifdef __FLOG_ACTIVE    
+    self->ConstructL(KComponent);
+#else
+    self->ConstructL();
+#endif
+	CleanupStack::Pop();
+	return self;
+	}
+
+/**
+Destructor
+*/
+CPTPIPEventHandler::~CPTPIPEventHandler()
+	{
+	__FLOG(_L8("Destructor - Entry"));
+	__FLOG(_L8("Destructor - Exit"));
+	}
+
+/**
+Constructor
+*/
+CPTPIPEventHandler::CPTPIPEventHandler(CPTPIPConnection& aConnection): 
+	CPTPIPSocketHandlerBase(aConnection, CActive::EPriorityUserInput )
+	{
+	}
+
+/**
+Sends the init ack packet, which is created in the connection class. 
+@param aEvtAck The packet containing the event acknowledgement to be sent to initiator.
+*/
+void CPTPIPEventHandler::SendInitAck(CPTPIPGenericContainer* aEvtAck)
+	{
+	__FLOG(_L8("SendInitAck - Entry"));
+	iChunkStatus = aEvtAck->FirstReadChunk(iSendChunkData);
+	iSendData.Set(iSendChunkData);
+	iSocket.Send(iSendData,0,iStatus);
+	SetState(EInitSendInProgress);
+	SetActive();
+	__FLOG(_L8("SendInitAck - Exit"));
+	}
+
+/**
+Initiates the sending of the event data over the event channel. The base class
+ implements the handling of the socket to send the actual data. 
+@param aData The buffer containing the event which is created by the framework to send to the initiator
+*/
+void CPTPIPEventHandler::SendEventL(const MMTPType& aEvent)
+    {
+	__FLOG(_L8("SendEventL - Entry"));
+	
+	// We need to stop listening, and send the event. 
+	Cancel();
+	
+    SendDataL(aEvent, 0);
+	__FLOG(_L8("SendEventL - Exit"));
+    }
+
+/**
+Signals the completion of sending data over the socket, which was started by 
+SendEventL. It is called by the base sockethandler and in turn informs the 
+connection.
+@param aError - The error if any returned by the sockethandler. (KErrNone if no errors)
+@param aSource - The event buffer which had been given by the framework to send to initiator.
+*/
+void CPTPIPEventHandler::SendDataCompleteL(TInt aError, const MMTPType& aSource)
+    {
+	__FLOG(_L8("SendDataCompleteL - Entry"));
+    Connection().SendEventCompleteL(aError, aSource);
+	__FLOG(_L8("SendDataCompleteL - Exit"));
+    }
+
+/**
+Initiates the receiving of the event data on the event channel. 
+@param aEvent The buffer containing the event received from the initiator
+*/
+void CPTPIPEventHandler::ReceiveEventL(MMTPType& aEvent)
+    {
+	__FLOG(_L8("ReceiveEventL - Entry"));
+    ReceiveDataL(aEvent);
+	__FLOG(_L8("ReceiveEventL - Exit"));
+    }
+
+/**
+Marks the completion of receiving data over the event channel, which was started 
+by ReceiveEventL. It is called by the base sockethandler and in turn informs the
+connection.
+@param aError - The error if any returned by the sockethandler. (KErrNone if no errors)
+@param aSink - The event buffer in which an event has been received from the initiator
+*/
+void CPTPIPEventHandler::ReceiveDataCompleteL(TInt aError, MMTPType& aSink)
+    {
+	__FLOG(_L8("ReceiveDataCompleteL - Entry"));
+    Connection().ReceiveEventCompleteL(aError, aSink); 
+	__FLOG(_L8("ReceiveDataCompleteL - Exit"));
+    }
+
+/**
+Parses the PTPIP header, gets and validates that the packet type is correct 
+and sets the value of the packet length.
+@return Type The PTPIP packet type received ie event or cancel. In case of invalid type, it returns 0
+*/   
+TInt CPTPIPEventHandler::ParsePTPIPHeaderL()
+	{
+	__FLOG(_L8("ParsePTPIPHeaderL - Entry"));
+	
+	TUint32 type = Connection().ValidateAndSetEventPayloadL();
+	iPTPPacketLength = Connection().EventContainer()->Uint32L(CPTPIPGenericContainer::EPacketLength);
+	
+	__FLOG(_L8("ParsePTPIPHeaderL - Exit"));
+	return type;
+	}
+
+/**
+Called during the PTP connection establishment phase to mark the completion 
+of sending the init ack to the initiator
+@return Flag stating that the ini has been sent successfully.
+*/
+TBool CPTPIPEventHandler::HandleInitAck()
+	{
+	__FLOG(_L8("HandleInitAck - Entry"));
+	TBool isHandled(EFalse);
+	
+	if (iState == EInitSendInProgress)
+		{
+		//Now signal the connection, set its state and set it to active.
+		Connection().SetConnectionState(CPTPIPConnection::EInitialisationComplete);
+		Connection().CompleteSelf(iStatus.Int());
+		iState = EIdle;
+		isHandled = ETrue;
+		}
+	__FLOG(_L8("HandleInitAck - Exit"));
+	return isHandled;
+	}
+
+
+
+	
+	
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipplugin/src/cptpipsockhandlerbase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1008 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cptpipsockethandler.cpp
+// 
+//
+
+/**
+ @internalComponent
+*/
+
+#include "cptpipsockhandlerbase.h"
+#include "cptpipconnection.h"
+#include "ptpippanic.h"
+
+const TUint32 KPTPIPHeaderSize = 8;
+const TUint KMaxPacketSixe   = 16;
+const TUint64 KMaxPTPIPPacketSize = 0x18FF4; // 100 KB - 12
+
+//#define MTP_DEBUG_FLOG_HEX_DUMP
+
+#define UNUSED_VAR(a) (a)=(a)
+
+/**
+Constructor 
+*/
+CPTPIPSocketHandlerBase::CPTPIPSocketHandlerBase(CPTPIPConnection& aConnection, TPriority priority ) : 
+						CActive(priority),
+						iChunkStatus(0),
+						iSendChunkData(NULL, 0),
+						iSendData(NULL, 0),
+						iReceiveChunkData(NULL, 0),
+						iPTPPacketLength(0),
+						iState(EIdle),
+						iPacketBuffer(NULL),
+						iPacketSizeMax(NULL),
+						iReceiveData(NULL, 0),
+						iIsFirstChunk(EFalse),
+						iPTPPacketLengthReceived(0),
+						iReceiveDataCommit(EFalse),
+						iSendHeaderData(NULL, 0),
+						iPTPIPDataHeader(NULL),
+						iConnection(aConnection),
+						iReceiveDataSink(NULL),
+						iSendDataSource(NULL),
+						iCurrentChunkData(NULL,0,0)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+
+
+/**
+Second phase constructor.
+*/
+#ifdef __FLOG_ACTIVE    
+void CPTPIPSocketHandlerBase::ConstructL(const TDesC8& aComponentName)
+#else
+void CPTPIPSocketHandlerBase::ConstructL()
+#endif
+    {
+    __FLOG_OPEN(KMTPSubsystem, aComponentName);
+    __FLOG(_L8("CSocketHandler::ConstructL - Entry"));
+    iPacketSizeMax = KMaxPacketSixe; 
+    iPacketBuffer.ReAllocL(iPacketSizeMax);
+    iPTPIPDataHeader = CPTPIPDataContainer::NewL();
+    __FLOG(_L8("CSocketHandler::ConstructL - Exit"));
+    }
+  
+ /**
+ Destructor
+ */  
+ CPTPIPSocketHandlerBase::~CPTPIPSocketHandlerBase()
+ {
+    __FLOG(_L8("CSocketHandler::~CSocketHandler - Entry"));
+    Cancel();
+    iPacketBuffer.Close();
+    iSocket.Close();
+    delete iPTPIPDataHeader;
+    __FLOG(_L8("CSocketHandler::~CSocketHandler - Exit"));
+    __FLOG_CLOSE;
+ }
+
+
+//
+// CActive Functions
+//
+
+/**
+ This will be called after every chunk is sent or received over the socket. 
+*/
+void CPTPIPSocketHandlerBase::RunL()
+	{
+	__FLOG(_L8("RunL - Entry"));
+    __FLOG_VA((_L8("Current State is 0x%08X, and status is %d"), iState, iStatus.Int()));	
+    
+	switch ( DataStreamDirection() )
+		{
+	case EReceivingState:
+	
+        __FLOG_VA((_L8("Receive data completion status = %d"), iStatus.Int()));
+        if (iState == EReceiveFastInProgress)
+        	{
+        	InitiateFirstChunkReceiveL(); 
+        	}
+        
+        else if (iStatus != KErrNone)
+            {
+            // Abnormal completion.
+            __FLOG_VA((_L8("PTPIP Error: Receive data completed with error = %d"), iStatus.Int()));
+            SetState(EReceiveComplete);
+            }
+        else if (iState != EReceiveComplete)
+            {
+	        // Update the chunk data length. We use the iReceiveData variable with the socket 
+	        // so only its length gets updated on receive. 
+	        
+	        // However during remaining processing we use iReceiveChunkData, so update its len.
+            iReceiveChunkData.SetLength(iReceiveChunkData.Length() + iReceiveData.Length());
+            if (iIsFirstChunk)
+	            {
+	            // process the first chunk.
+	            ProcessFirstReceivedChunkL();  
+	            }
+	        else
+		        {
+		        ResumeReceiveDataStreamL(); 
+		        }
+            }
+            
+        if (iState == EReceiveComplete)
+            {             
+            // Save the pointer to the last populated location on the current chunk            
+            iCurrentChunkData.Set(iReceiveChunkData);             
+            // Reset the receive data stream and notify the connection.
+            MMTPType& data(*iReceiveDataSink);
+            ResetReceiveDataStream();
+            TRAPD(err, ReceiveDataCompleteL(iStatus.Int(), data));
+            if (err != KErrNone)
+            	{
+            	__FLOG_VA((_L8("Framework threw an error from ReceiveDataCompleteL = %d"), err)); 
+            	ReceiveDataCompleteL(err, data);
+            	}
+            }
+        break;
+        
+	case ESendingState:
+		// Special case for handling the sending of init ack, handled in the derived class.
+		if (HandleInitAck())
+			{
+			ResetSendDataStream();
+			break;
+			}
+
+        __FLOG_VA((_L8("Send data stream completion status = %d"), iStatus.Int())); 
+        if (iStatus != KErrNone)
+            {
+            // Abnormal completion.
+            SetState(ESendComplete);
+            }
+		else
+			{
+            ProcessSendDataL(); 
+            }
+         if (iState == ESendComplete)
+            {
+            // Reset the send data stream and notify the connection.
+            const MMTPType& data(*iSendDataSource);
+            ResetSendDataStream();
+            TRAPD(err, SendDataCompleteL(iStatus.Int(), data));
+            if (err != KErrNone)
+            	{
+            	__FLOG_VA((_L8("Framework threw an error from SendDataCompleteL = %d"), err)); 
+            	SendDataCompleteL(err, data);
+            	}
+            }
+        break;
+        
+	case ESendDataState:
+		if (iStatus != KErrNone)
+            {
+            // Abnormal completion.
+            SetState(ESendDataComplete);
+            }
+ 		else if (iState == ESendingDataHeader)
+			{
+			SetState(ESendingDataPacket);	
+			}
+		else if (iState == ESendingDataPacket)
+			{
+			SetState(ESendingDataHeader);		
+			}
+		else if (iState == ESendDataPacketCompleting)
+			{
+			SetState(ESendDataComplete);	
+			}
+		
+		if (iState == ESendDataComplete || iState == ESendDataCancelled)
+            {
+            // Reset the send data stream and notify the connection.
+            const MMTPType& data(*iSendDataSource);
+            ResetSendDataStream();
+            SendDataCompleteL(iStatus.Int(), data);
+            }
+   		else
+	        {
+	        CreateAndSendDataPacketsL();	
+	        }
+		break;
+		
+	default:
+		
+		__FLOG_VA((_L8("PTPIP ERROR: Invalid state of the sockethandler: RunL should not be called with 0x%08X state"), iState));	
+        Panic(EPTPIPBadState);
+		break;
+		
+		}// switch
+		
+    __FLOG_VA((_L8("IsActive = %d"), IsActive()));
+	__FLOG(_L8("RunL - Exit"));
+	}
+
+/**
+Tell the Asynchronous Service provider to cancel all outstanding operations. 
+*/
+void CPTPIPSocketHandlerBase::DoCancel()
+	{
+	__FLOG(_L8("DoCancel - Entry"));
+    switch (iState & EStateDirection)
+        {
+    case EReceivingState:
+        __FLOG(_L8("Cancelling receive on the socket"));
+        iSocket.CancelRecv();
+        ResetReceiveDataStream();
+        break;
+
+    case ESendingState:    
+        __FLOG(_L8("Cancelling send on the socket"));
+        iSocket.CancelSend();
+        ResetSendDataStream();
+        break;
+        
+    case ESendDataState:
+	    __FLOG(_L8("Cancelling send on the socket"));
+	    iSocket.CancelSend();
+	    ResetSendDataStream();
+	    break;
+	    
+    default:
+        break;
+		}
+	__FLOG(_L8("DoCancel - Exit"));
+	}
+
+/**
+This is invoked when a panic occurs during RunL. 
+To handle this , all operations are cancelled, and if we were processing
+a send or recv operation, we complete it with the error code. 
+@param - The error code with which RunL left
+*/
+TInt CPTPIPSocketHandlerBase::RunError(TInt aError)
+	{
+	__FLOG(_L8("RunError - Entry"));
+    __FLOG_VA((_L8("Error reported is  %d and state is 0x%08X, and status is %d"), aError, iState, iStatus.Int()));
+ 
+    // Cancel any outstanding request.
+    Cancel();  
+    
+    // Notify the protocol layer of the error.
+    TInt32 streamDirection = DataStreamDirection();
+    if (streamDirection == EReceivingState)
+	    {
+		__FLOG(_L8("Error in EReceivingState"));            
+        // Notify the connection and reset the receive data stream.
+        MMTPType& data(*iReceiveDataSink);
+        ResetReceiveDataStream();
+        TRAPD(err, ReceiveDataCompleteL(aError, data));
+        UNUSED_VAR(err);
+	    }
+	else if (streamDirection == ESendingState || (streamDirection == ESendDataState))
+		{
+		__FLOG(_L8("Error in ESendingState"));
+        // Notify the connection and reset the send data stream.
+        const MMTPType& data(*iSendDataSource);
+        ResetSendDataStream();
+        TRAPD(err, SendDataCompleteL(aError, data));
+        UNUSED_VAR(err);
+		}
+    // We are neither in sending nor receiving state, the error in RunL
+    // must have originated from the MTP framework, tell the connection 
+    // to stop.
+	else 
+		{
+		Connection().HandleError(aError);
+		}
+ 
+	__FLOG(_L8("RunError - Exit"));
+	return KErrNone;
+	}
+	
+//
+// Send Data Functions
+//
+
+/**
+This sends the data over the socket. The buffer is provided by the MTP fw.
+@param aData - The data buffer to be sent
+@param aTransactionId - The id of the current onging transaction. This is needed 
+ in case the data in R to I phase has to be split into multiple PTPIP data packets
+ In such a case the PTPIP Data packet header needs to be created which contains the tran id. 
+*/
+void CPTPIPSocketHandlerBase::SendDataL(const MMTPType& aData, TUint32 aTransactionId )
+	{
+	__FLOG(_L8("SendDataL - Entry"));
+    iSendDataSource = &aData;
+	TUint64 size = iSendDataSource->Size();
+    __FLOG_VA((_L8("Size of total data to be sent = %ld bytes"), size));
+	
+	// if the data is less than KMaxPTPIPPacketSize then it can be sent in a shot, 
+	// Currently the ptp ip packet has the end data packet already, so it can be sent directly. 
+	if ( size < KMaxPTPIPPacketSize)
+		{
+		__FLOG(_L8("Size of data is less than KMaxPTPIPPacketSize, sending as one ptpip packet."));
+	    SetState(ESendInitialising);
+		ProcessSendDataL();
+		}
+		
+	// if the data is greater than KMaxPTPIPPacketSize then it needs to be split into 
+	// multiple packets. The PTPIP header will be locally created , and sent
+	// and then one chunk will be sent as one PTPIP packet.
+	else 
+		{
+		__FLOG(_L8("Size of data is more than KMaxPTPIPPacketSize, sending as multiple ptpip packets."));
+		iPTPIPDataHeader->SetUint32L(CPTPIPDataContainer::ETransactionId, aTransactionId);
+		iPTPIPDataHeader->SetPayloadL(NULL);
+		
+		// We can ignore this header, since we create our own while sending each packet.
+		iChunkStatus = iSendDataSource->FirstReadChunk(iSendChunkData);
+        
+		SetState(ESendingDataHeader);
+		CreateAndSendDataPacketsL();
+		}
+	
+	__FLOG(_L8("SendDataL - Exit"));
+	}
+
+/**
+Using the same algo as the USB send, to buffer into a local buffer, and sending 
+only when buffer exceeds the max socket send size, or all chunks have been buffered. 
+*/
+void CPTPIPSocketHandlerBase::ProcessSendDataL()
+	{
+	__FLOG(_L8("ProcessSendDataL - Entry"));	
+	
+    iSendData.Set(KNullDesC8);
+
+    TUint chunkAvailableLen(iSendChunkData.Length());
+    if (!chunkAvailableLen)
+        {    
+        // Fetch the next read data chunk. 
+        switch (iState)
+            {
+        case ESendInitialising:
+            __FLOG(_L8("Fetching first read data chunk"));
+            iChunkStatus = iSendDataSource->FirstReadChunk(iSendChunkData);
+            iPacketBuffer.Zero();
+            break;
+            
+        case ESendInProgress:
+            __FLOG(_L8("Fetching next read data chunk"));
+            iChunkStatus = iSendDataSource->NextReadChunk(iSendChunkData);
+            break;
+            
+        case ESendCompleting:
+            break;            
+           
+        case EIdle:
+        default:
+            __FLOG(_L8("Invalid send data stream state"));
+            Panic(EPTPIPBadState);
+            break;
+            }
+        
+        // Fetch the new chunk data size available.
+        chunkAvailableLen = iSendChunkData.Length();
+        
+        // Update data stream state.
+        switch (iChunkStatus)
+            {
+        case KErrNone:
+            SetState(ESendInProgress);
+            break;
+            
+        case KMTPChunkSequenceCompletion:
+            if (iState == ESendCompleting)
+                {
+                SetState(ESendComplete);
+                }
+            else
+                {
+                SetState(ESendCompleting);
+                }
+            break;
+            
+          case KErrNotFound:// CMTPTypeFile returns this when it has zero length
+        	if( 0 == iSendChunkData.Length() )
+        		{
+                if (iState == ESendCompleting)
+                {
+                SetState(ESendComplete);
+                }
+            else
+                {
+                SetState(ESendCompleting);
+                }
+                }  
+                break;
+        default:
+            User::Leave(iChunkStatus);
+            break;
+            }          
+        }
+    __FLOG_VA((_L8("Chunk status = %d"), iChunkStatus));
+    
+    // Process the buffered residual and/or available chunk data.
+    TUint bufferedLen(iPacketBuffer.Length());
+    TUint chunkIntegralLen((chunkAvailableLen / iPacketSizeMax) * iPacketSizeMax);
+    TUint chunkResidualLen(chunkAvailableLen % iPacketSizeMax);
+    __FLOG_VA((_L8("Buffered residual data = %d bytes"), bufferedLen));
+    __FLOG_VA((_L8("Chunk data available = %d bytes"), chunkAvailableLen));
+    __FLOG_VA((_L8("Chunk data packet integral portion = %d bytes"), chunkIntegralLen));
+    __FLOG_VA((_L8("Chunk data packet residual portion = %d bytes"), chunkResidualLen));
+    
+    if (bufferedLen)
+        {
+        // Data is buffered in the packet buffer. Fill the available packet buffer space.
+        if (chunkAvailableLen)
+            {
+            // Fill the packet buffer.
+            TUint consumedLen(0);
+            TUint unconsumedLen(0);
+            TUint capacity(iPacketBuffer.MaxLength() - iPacketBuffer.Length());
+            if (chunkAvailableLen > capacity)
+                {
+                consumedLen     = capacity;
+                unconsumedLen   = (chunkAvailableLen - consumedLen);              
+                }
+            else
+                {
+                consumedLen = chunkAvailableLen;
+                }
+            __FLOG_VA((_L8("Buffering %d bytes"), consumedLen));
+            iPacketBuffer.Append(iSendChunkData.Left(consumedLen));
+            
+            // Update the available chunk data to reflect only the unconsumed portion.
+            __FLOG_VA((_L8("Residual chunk data = %d bytes"), unconsumedLen));
+            if (unconsumedLen)
+                {
+                iSendChunkData.Set(iSendChunkData.Right(unconsumedLen));
+                }
+            else
+                {
+                iSendChunkData.Set(NULL, 0);                    
+                }
+            }
+        
+        // Send the packet buffer when full.
+        if ((iState == ESendCompleting) || (iPacketBuffer.Size() == iPacketBuffer.MaxSize()))
+            {
+            iSendData.Set(iPacketBuffer);
+            iPacketBuffer.Zero();
+            }
+       
+        }
+    else if (iState == ESendInProgress)
+        {
+        // Send the chunk data packet integral portion.
+        if (chunkIntegralLen)
+            {
+            iSendData.Set(iSendChunkData.Left(chunkIntegralLen));   
+            }
+    
+        // Buffer the chunk data packet residual portion.
+        if (chunkResidualLen)
+            {
+            __FLOG_VA((_L8("Buffering %d bytes"), chunkResidualLen));
+            iPacketBuffer.Append(iSendChunkData.Right(chunkResidualLen));  
+            }
+            
+        // All data has been consumed and/or buffered.
+        iSendChunkData.Set(NULL, 0);
+        }
+    else if (iState == ESendCompleting)
+        {
+        // Send all available chunk data.
+        iSendData.Set(iSendChunkData);
+            
+        // All data has been consumed.
+        iSendChunkData.Set(NULL, 0);
+        }
+
+    // Send the available data or reschedule to process the next chunk.
+    TUint sendBytes(iSendData.Length());
+    if (sendBytes)
+        {
+        __FLOG_VA((_L8("Send data length = %d bytes"), iSendData.Length()));
+#ifdef MTP_DEBUG_FLOG_HEX_DUMP 
+        __FLOG_HEXDUMP((iSendData, _L8("Sending data on socket ")));
+#endif
+        iSocket.Send(iSendData, 0, iStatus);
+        SetActive(); 
+        __FLOG(_L8("Request issued"));
+        }
+    else if (iState != ESendComplete)
+        {    
+        iStatus = KRequestPending;
+		CompleteSelf(KErrNone);      
+		}
+
+    __FLOG_VA((_L8("CSocketHandler state on exit = 0x%08X"), iState));
+	__FLOG(_L8("ProcessSendDataL - Exit"));
+	}
+
+
+	
+/**
+first the data header will be sent, 
+next the packet will be sent. 
+
+in case this is the last chunk, then the data header will have the last data 
+*/
+	
+void CPTPIPSocketHandlerBase::CreateAndSendDataPacketsL()	
+	{
+	__FLOG(_L8("CreateAndSendDataPacketsL - Entry"));
+	
+	// Create the data header and prepare to send it.
+	if (iState == ESendingDataHeader)
+		{
+		// if we've received a Cancel, then don't send further packets and return to the connection. 
+		if (iCancelReceived)
+			{
+			iState = ESendDataCancelled;
+			CompleteSelf(KErrNone);
+			__FLOG(_L8("Sending the PTPIP data "));
+			return;
+			}
+		else 
+			{
+			iChunkStatus = iSendDataSource->NextReadChunk(iSendChunkData);
+			TInt32 size = iPTPIPDataHeader->Size() + iSendChunkData.Size();
+			iPTPIPDataHeader->SetUint32L(CPTPIPDataContainer::EPacketLength, size);
+	   		__FLOG_VA((_L8("Size of ptpip packet data to be sent = %d bytes"), size));
+	
+			switch (iChunkStatus)
+		        {
+		    case KErrNone:
+		        iPTPIPDataHeader->SetUint32L(CPTPIPDataContainer::EPacketType, EPTPIPPacketTypeData);
+		        break;
+		        
+		    case KMTPChunkSequenceCompletion:
+		    	iPTPIPDataHeader->SetUint32L(CPTPIPDataContainer::EPacketType, EPTPIPPacketTypeEndData);
+		        break;
+		        
+		    default:
+		    	__FLOG(_L8("PTPIP Error :chunkStatus returned an error"));
+		        User::Leave(iChunkStatus);
+		        break;
+		        } 
+			// Set the iSendData to point to the ptpip header. 
+			TInt ret = iPTPIPDataHeader->FirstReadChunk(iSendData);
+			}
+ 		}
+	
+	// Set the iSendData to point to the actual data chunk. 
+	else if (iState == ESendingDataPacket)
+		{
+		iSendData.Set(iSendChunkData);
+    	__FLOG(_L8("Sending the PTPIP data "));
+		// if this is the last packet then set state. 	
+		if (iChunkStatus == KMTPChunkSequenceCompletion)
+			SetState(ESendDataPacketCompleting);
+		}
+	// We exited due to an error condition, 
+	else 
+		{
+        Panic(EPTPIPBadState);
+		}
+		
+    __FLOG_VA((_L8("Send data length = %d bytes"), iSendData.Length()));
+#ifdef MTP_DEBUG_FLOG_HEX_DUMP 
+    __FLOG_HEXDUMP((iSendData, _L8("Sending data on socket ")));
+#endif
+    iSocket.Send(iSendData, 0, iStatus);
+    SetActive();
+    __FLOG(_L8("Request issued"));
+	__FLOG(_L8("CreateAndSendDataPacketsL - Exit"));
+	}
+	
+	
+	
+/**
+Signals tthe data transfer controller that an asynchronous data send sequence 
+has completed.
+@leave One of the system wide error codes, if a processing failure occurs.
+@panic EPTPIPNotSupported In debug builds only, if the derived class has not fully 
+implemented the send data path.
+*/
+void CPTPIPSocketHandlerBase::SendDataCompleteL(TInt /*aError*/, const MMTPType& /*aSource*/)
+    {
+    __FLOG(_L8("CSocketHandler::SendDataCompleteL - Entry"));
+    __DEBUG_ONLY(Panic(EPTPIPNotSupported));
+    __FLOG(_L8("CSocketHandler::SendDataCompleteL - Exit"));
+    }	
+
+/**
+Forces the completion of a transfer in progress. 
+
+@param aReason error code describing the reason for cancelling.
+@leave Any of the system wide error codes.
+*/
+void CPTPIPSocketHandlerBase::CancelSendL(TInt aReason)
+	{
+	__FLOG(_L8("CSocketHandler::CancelSendL - Entry"));
+    
+	if ( (DataStreamDirection() == ESendingState) || (DataStreamDirection() == ESendDataState))
+		{
+		__FLOG(_L8("Cancel in ESendingState"));
+		// Cancel any outstanding request.
+		Cancel();
+		ResetSendDataStream();
+		SendDataCompleteL(aReason, *iSendDataSource);
+		}
+		
+	__FLOG(_L8("CSocketHandler::CancelSendL - Exit"));
+	}
+
+	
+//
+// Receive Data Functions
+//
+
+/**
+This receives the data over the socket. The data may be event or command data. 
+The buffer is provided by the fw in case its a data in.
+@param aSink The buffer into which the data from initiator will be received. 
+*/
+void CPTPIPSocketHandlerBase::ReceiveDataL(MMTPType& aSink)
+	{
+	__FLOG(_L8("ReceiveDataL - Entry"));
+	
+	// Set the state 
+	SetState(EReceiveInProgress);
+	
+	// The memory has come from the conection. In case it was a command receive
+	// then the connection itself had put the memory for the payload 
+	// from its members, 
+	// in case it was a data receive , then the payload buffer was provided by
+	// the framework. 
+	
+    iReceiveDataSink    = &aSink;
+    iReceiveDataCommit  = iReceiveDataSink->CommitRequired();
+    
+    InitiateFirstChunkReceiveL(); 
+	__FLOG(_L8("ReceiveDataL - Exit"));
+	}
+
+/**
+Reads the first chunk. Then validates what was read and adjusts the buffer accordingly. 
+*/
+void CPTPIPSocketHandlerBase::InitiateFirstChunkReceiveL()
+	{
+	__FLOG(_L8("InitiateFirstChunkReceiveL - Entry"));
+	
+	// sink refers to the buffer from connection.
+	// Now the ptr iReceiveChunkData is set to it first chunk.
+	iChunkStatus = iReceiveDataSink->FirstWriteChunk(iReceiveChunkData);
+	
+	// The first chunk is going to be read.
+	iIsFirstChunk = ETrue;
+    __FLOG_VA((_L8("Receive chunk capacity = %d bytes, length = %d bytes"), iReceiveChunkData.MaxLength(), iReceiveChunkData.Length()));
+    __FLOG_VA((_L8("Chunk status = %d"), iChunkStatus)); 
+
+	iReceiveData.Set(iReceiveChunkData);
+	
+	// start the timer. 
+	
+	// Make the async request to read on the socket and set ourselves active.
+	// once data is read on the socket, the iStatus will be changed by the comms framework. 
+ 	iSocket.Recv(iReceiveData, 0, iStatus);
+#ifdef MTP_DEBUG_FLOG_HEX_DUMP 
+    __FLOG_HEXDUMP((iReceiveData, _L8("Received data on socket ")));
+#endif
+
+    SetActive();
+    __FLOG(_L8("Request issued"));
+	__FLOG(_L8("InitiateFirstChunkReceiveL - Exit"));
+	}
+
+/**
+The first chunk received will have the length of the data and the ptpip packet type.
+Validate the ptp packet type, and set the correct packet type in the generic container.
+Set the state to complete or read further depending on the size.
+*/
+void CPTPIPSocketHandlerBase::ProcessFirstReceivedChunkL()
+	{
+	__FLOG(_L8("ProcessFirstReceivedChunkL - Entry"));
+    iIsFirstChunk = EFalse;
+    // Reset the data counter, This will be filled in later in the ResumeReceiveDataStreamL.
+    iPTPPacketLengthReceived = 0; 
+    iType = EPTPIPPacketTypeUndefined;
+    
+    // Parse and get the packet type, and packet length into type and iPTPPacketLength.
+    // This will also validate that the correct payload is set to get the remaining data. 
+    iType = ParsePTPIPHeaderL();
+	
+	// If the PTPIP type is not one of the standard expected types, 
+	// or not expected in the current transaction phase then we stop further receiving
+	// This current RunL will 
+	if (EPTPIPPacketTypeUndefined == iType ) 
+		{
+		__FLOG(_L8("PTPIP ERROR: Unexpected value in the type field of PTPIP header, appears corrupt"));
+		SetState(EReceiveComplete);
+		iStatus = KErrCorrupt;
+		}
+	
+	// If there is nothing to receive after the header, possible for probe packet.
+	else if (KPTPIPHeaderSize == iPTPPacketLength )
+		{
+		SetState(EReceiveComplete);
+		}
+	   
+    if (iState == EReceiveComplete)
+		{
+#ifdef MTP_DEBUG_FLOG_HEX_DUMP 
+        __FLOG_HEXDUMP((iReceiveChunkData, _L8("Received data ")));
+#endif
+
+		// Commit the received data if required.
+        if (iReceiveDataCommit)
+		    {
+		 	__FLOG(_L8("Commiting write data chunk"));
+	        iReceiveDataSink->CommitChunkL(iReceiveChunkData);       
+		    }
+		}
+	else
+		{
+		ResumeReceiveDataStreamL();
+		}
+
+	__FLOG(_L8("ProcessFirstReceivedChunkL - Exit"));
+	}
+
+
+
+/**
+Called after the first chunk has been received and we are expecting more packets. 
+This will be called repeatedly until all the packets have been received.
+*/
+void CPTPIPSocketHandlerBase::ResumeReceiveDataStreamL()
+	{
+	__FLOG(_L8("ResumeReceiveDataStreamL - Entry"));
+	TBool endStream(EFalse);
+	MMTPType *needCommit = NULL;
+		
+    // Process the received chunk (if any).
+   	iPTPPacketLengthReceived += iReceiveData.Length();
+   	__FLOG_VA((_L8("Data received = iPTPPacketLengthReceived = %d bytes, Data expected = iPTPPacketLength = %d"), iPTPPacketLengthReceived, iPTPPacketLength));
+   	
+	if (iPTPPacketLengthReceived == iPTPPacketLength)
+	   	{
+	   	SetState(EReceiveComplete);
+	   	endStream = ETrue;
+	   	
+	   	//if type  is data then end stream is not true
+	   	if (iType == EPTPIPPacketTypeData)
+	   	endStream = EFalse;
+	   	}
+
+    __FLOG_VA((_L8("Received = %d bytes, write data chunk capacity = %d bytes"), iReceiveChunkData.Length(), iReceiveChunkData.MaxLength()));		   
+#ifdef MTP_DEBUG_FLOG_HEX_DUMP 
+    __FLOG_HEXDUMP((iReceiveChunkData, _L8("Received data ")));
+#endif
+
+
+    // Commit the received data if required.
+	if (iReceiveDataCommit)
+         {
+         // if the chunk has been read completely.
+         // or if the end of stream has been reached. 
+         if (iReceiveChunkData.Length() == iReceiveChunkData.MaxLength()
+         	|| endStream )
+        	 {
+        	 needCommit = iReceiveDataSink->CommitChunkL(iReceiveChunkData);
+        	 }   
+         
+         
+         } 
+
+    // Fetch the next read data chunk.  
+    switch (iState)
+        {
+    case EReceiveInProgress:
+   	
+	// If we're in the middle of receiving a ptp data packet, 
+	// then at this stage we might have already used some of this chunk. 
+	// so reset its length to previously saved value
+    if (iUseOffset)
+		
+		{		
+		iUseOffset = EFalse;	
+		iReceiveChunkData.Set(iCurrentChunkData);
+		iChunkStatus = KErrNone;		
+		}
+    
+    	// get the next chunk only if this chunk has been read completely. 
+    	if (iReceiveChunkData.Length() == iReceiveChunkData.MaxLength())
+    		{
+    		
+    		iChunkStatus = iReceiveDataSink->NextWriteChunk(iReceiveChunkData);
+    		
+    		}
+    	__FLOG_VA((_L8("iReceiveChunkData pointer address is %08x"), iReceiveChunkData.Ptr()));
+	    break;
+        
+    case EReceiveComplete:
+        __FLOG(_L8("Write data chunk sequence complet"));
+        break;
+                  
+    case EIdle:
+    default:
+        __FLOG(_L8("Invalid stream state"));
+        Panic(EPTPIPBadState);
+        break;
+        }
+        
+    __FLOG_VA((_L8("Chunk status = %d"), iChunkStatus)); 
+        
+        
+    // If necessary, process the next chunk. 
+    if (iState != EReceiveComplete)
+        {
+        __FLOG_VA((_L8("Receive chunk capacity = %d bytes, length = %d bytes"), iReceiveChunkData.MaxLength(), iReceiveChunkData.Length()));
+        __FLOG_VA((_L8("iReceiveChunkData pointer address is %08x"), iReceiveChunkData.Ptr()));
+        
+        
+	        // When we reach the end of receiving a PTPIP packet, it is possible that our PTPIP chunk
+	        // length is greater than the actual data that is expected. 
+	        // eg when parameters 1to 5 are not set in a PTPIP request. In this case 
+	        // we need to read the remaining length which will be less than the max length of the chunk.
+	        TUint32 remainingLen = iPTPPacketLength - iPTPPacketLengthReceived;
+	        if (remainingLen < (iReceiveChunkData.MaxLength() - iReceiveChunkData.Length()))
+	        	{
+	        	iReceiveData.Set(const_cast<TUint8*>(iReceiveChunkData.Ptr() + iReceiveChunkData.Length()), 
+	        	                 0,
+	        					remainingLen); 
+	        	}
+	        else
+	        	{
+	        	iReceiveData.Set(const_cast<TUint8*>(iReceiveChunkData.Ptr() + iReceiveChunkData.Length()), 
+	        					0, 
+	        					iReceiveChunkData.MaxLength() - iReceiveChunkData.Length());
+	        	}        	
+	       
+        	
+        	
+	        __FLOG_VA((_L8("Length read this time is= %d"), iReceiveData.MaxLength()));
+        	
+        
+ 		iSocket.Recv(iReceiveData, 0, iStatus);
+#ifdef MTP_DEBUG_FLOG_HEX_DUMP 
+    __FLOG_HEXDUMP((iReceiveData, _L8("Received data on socket ")));
+#endif 		
+        SetActive();
+        __FLOG(_L8("Request issued"));
+        }
+        if(needCommit != NULL)
+            {
+            TPtr8 tmp(NULL, 0, 0);
+            needCommit->CommitChunkL(tmp);
+            }
+ 	__FLOG(_L8("ResumeReceiveDataStreamL - Exit"));
+	}
+
+/**
+Signals the data transfer controller that an asynchronous data receive sequence 
+has completed.
+@leave One of the system wide error codes, if a processing failure occurs.
+@panic EPTPIPNotSupported In debug builds only, if the derived class has not fully 
+implemented the receive data path.
+*/
+void CPTPIPSocketHandlerBase::ReceiveDataCompleteL(TInt /*aError*/, MMTPType& /*aSink*/)
+    {
+    __FLOG(_L8("CSocketHandler::ReceiveDataCompleteL - Entry"));
+    __DEBUG_ONLY(Panic(EPTPIPNotSupported));
+    __FLOG(_L8("CSocketHandler::ReceiveDataCompleteL - Exit"));
+    }
+
+/**
+Forces the completion of a transfer in progress. 
+
+@param aReason error code describing the reason for cancelling.
+@leave Any of the system wide error codes.
+*/
+void CPTPIPSocketHandlerBase::CancelReceiveL(TInt aReason)
+	{
+	__FLOG(_L8("CSocketHandler::CancelReceiveL - Entry"));
+     
+    if (DataStreamDirection() == EReceivingState)
+	    {
+		__FLOG(_L8("Cancel in EReceivingState"));            
+	    // Cancel any outstanding request.
+    	Cancel();  
+
+        // Notify the connection and reset the receive data stream.
+		ResetReceiveDataStream();
+        ReceiveDataCompleteL(aReason, *iReceiveDataSink);
+	    }
+	    
+    __FLOG(_L8("CSocketHandler::CancelReceiveL - Exit"));	
+	}
+
+//
+// Getters , Setters and other helper functions
+//
+
+CPTPIPConnection& CPTPIPSocketHandlerBase::Connection()
+	{
+	return iConnection;
+	}
+
+RSocket& CPTPIPSocketHandlerBase::Socket()
+	{
+	return iSocket;	
+	}
+
+
+void CPTPIPSocketHandlerBase::ResetSendDataStream()
+    {
+	__FLOG(_L8("CSocketHandler::ResetSendDataStream - Entry"));
+    iSendChunkData.Set(NULL, 0);
+    iSendData.Set(NULL, 0);
+    iSendDataSource = NULL;
+    iCancelReceived = EFalse;
+    SetState(EIdle);
+	__FLOG(_L8("CSocketHandler::ResetSendDataStream - Exit"));
+    }
+    
+void CPTPIPSocketHandlerBase::ResetReceiveDataStream()
+    {
+	__FLOG(_L8("CSocketHandler::ResetReceiveDataStream - Entry"));
+    iReceiveChunkData.Set(NULL, 0, 0);
+    iReceiveData.Set(NULL, 0, 0);
+    iReceiveDataSink = NULL;
+    iCancelReceived = EFalse;
+    SetState(EIdle);
+	__FLOG(_L8("CSocketHandler::ResetReceiveDataStream - Exit"));
+    }
+
+    
+void CPTPIPSocketHandlerBase::SetState(TSocketState aState)
+	{
+	__FLOG(_L8("SetState - Entry"));
+	iState = aState;
+	__FLOG_VA((_L8(" state = 0x%08X"), iState));
+	__FLOG(_L8("SetState - Exit"));
+	}
+	
+void CPTPIPSocketHandlerBase::CompleteSelf(TInt aCompletionCode)
+     {
+     SetActive();
+     TRequestStatus* stat = &iStatus;
+     User::RequestComplete(stat, aCompletionCode);
+     }	
+
+/**
+Provides the current data stream direction, sending or receiving
+*/
+TInt32 CPTPIPSocketHandlerBase::DataStreamDirection() const
+    {
+    return (iState & EStateDirection);
+    }
+    
+void CPTPIPSocketHandlerBase::SetSocket(RSocket& aSocket)
+	{
+	iSocket = aSocket;	
+	}
+
+/**
+Ignore any errors in setting the socket options
+*/
+void CPTPIPSocketHandlerBase::SetSocketOptions()
+	{
+	TInt error=iSocket.SetOpt(KSoTcpKeepAlive,KSolInetTcp,1);
+	__FLOG_VA((_L8(" setting the keep alive option returned = %d"), error));
+	error=iSocket.SetOpt(KSoTcpNoDelay,KSolInetTcp,1);
+	__FLOG_VA((_L8(" setting the no delay to disable Nagle's algo returned %d"), error));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipplugin/src/cptpiptransport.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,160 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @internalComponent
+*/
+
+#include <ecom/implementationproxy.h>
+
+#include "cptpiptransport.h"
+#include "cptpipconnection.h"
+#include "mmtpconnectionmgr.h"
+#include "ptpippanic.h"
+
+__FLOG_STMT(_LIT8(KComponent,"PTPIPTransport");)
+
+/**
+PTPIP transport plug-in factory method.
+@return A pointer to a PTP IP transport plug-in. Ownership IS transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+TAny* CPTPIPTransport::NewL(TAny* aParameter)
+	{
+	if ( aParameter != NULL )
+		{
+		User::Leave(KErrArgument);
+		}
+
+	CPTPIPTransport* self = new (ELeave) CPTPIPTransport;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+	
+
+/**
+Destructor
+*/
+CPTPIPTransport::~CPTPIPTransport()
+	{
+    __FLOG(_L8("~Destructor - Entry"));
+    delete iConnection;
+    __FLOG(_L8("~Destructor - Exit"));
+    __FLOG_CLOSE;
+	}
+
+/**
+Second phase constructor. 
+*/
+void CPTPIPTransport::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry"));
+	__FLOG(_L8("PTPIP MTP Device class plug-in loaded."));    
+	__FLOG(_L8("ConstructL - Exit"));	
+	}
+
+/**
+Constructor
+*/
+CPTPIPTransport::CPTPIPTransport()
+	{
+	// Do nothing.
+	}
+	
+/**
+Starts the Transport. Creates the connection object which controls the TCP/IP sockets.
+*/
+void CPTPIPTransport::StartL(MMTPConnectionMgr& aConnectionMgr)
+	{
+    __FLOG(_L8("CPTPIPTransport::StartL - Entry"));
+    __ASSERT_ALWAYS(!iConnection, Panic(EPTPIPConnectionAlreadyExist));
+    iConnection = CPTPIPConnection::NewL(aConnectionMgr);
+    aConnectionMgr.ConnectionOpenedL(*iConnection);
+    __FLOG(_L8("CPTPIPTransport::StartL - Exit"));
+	}
+
+/**
+Stops the transport. Deletes the connection object controlling the TCP/IP sockets
+*/
+void CPTPIPTransport::Stop(MMTPConnectionMgr& aConnectionMgr)
+	{
+	__FLOG(_L8("Stop - Entry"));
+    if(iConnection)
+	    {
+	    // Check that we did not earlier close the connection due to some
+	    // error. If so then the connectionclosed would already have been closed. 
+	    if (iConnection->ConnectionOpen())
+	    	{
+	    	aConnectionMgr.ConnectionClosed(*iConnection);
+	    	}
+	    delete iConnection;
+	    iConnection = NULL;
+	    }
+	
+	__FLOG(_L8("Stop - Exit"));
+	}
+
+/**
+Nothing to do in mode change. 
+*/
+void CPTPIPTransport::ModeChanged(TMTPOperationalMode /*aMode*/)
+	{
+	__FLOG(_L8("ModeChanged - Entry"));
+	__FLOG(_L8("ModeChanged - Exit"));
+	}
+
+/**
+No Extended Interface.   
+*/
+TAny* CPTPIPTransport::GetExtendedInterface(TUid /*aInterfaceUid*/)
+	{
+	__FLOG(_L8("GetExtendedInterface - Entry"));
+	__FLOG(_L8("GetExtendedInterface - Exit"));	
+	return 0;
+	}
+
+/**
+Define the implementation UID of PTPIP transport implementation.
+*/
+static const TImplementationProxy ImplementationTable[] =
+    {
+        
+    IMPLEMENTATION_PROXY_ENTRY((0xA0004A60), CPTPIPTransport::NewL)
+        
+    };
+
+/**
+PTPIP transport implementation table. 
+*/
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
+
+/**
+Dummy dll entry point.
+*/
+TBool E32Dll()
+    {
+    return ETrue;
+    }
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpptpiptransport/ptpipplugin/src/ptpipplugin.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,41 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mtptcpipimp.rss
+// 
+//
+
+#include <ecom/registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = 0xA0004A61;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x102827AE;
+			implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0xA0004A60;
+					version_no = 1;
+					display_name = "MTP Transport PTP/IP protocol implementation plug-in.";
+					default_data = "";
+					opaque_data = "";
+					}	
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/common/inc/mtpusbpanic.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,41 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef MTPUSBPANIC_H
+#define MTPUSBPANIC_H
+
+#include <e32std.h>
+
+enum TMTPUsbPanic
+    {
+    EMTPUsbReserved					= 0,
+    
+    EMTPUsbBadState    	 			= 1,
+    EMTPUsbNotSupported 			= 2,
+    EMTPUsbConnectionAlreadyExist 	= 3
+    };
+
+_LIT(KMTPUsbPanic, "MTPUsb");
+inline void Panic(TMTPUsbPanic aCode)
+    {
+    User::Panic(KMTPUsbPanic, aCode);
+    };
+
+#endif // MTPUSBPANIC_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/common/inc/mtpusbprotocolconstants.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,97 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef MTPUSBPROTOCOLCONSTANTS_H
+#define MTPUSBPROTOCOLCONSTANTS_H
+
+#include <e32def.h>
+
+/** 
+Defines constant values specified USB MTP device class protocol.
+@internalComponent
+*/
+
+/**
+MTP USB device class device status datacodes. For a description of these 
+datacodes, please refer to the "Universal Serial Bus Still Image Capture 
+Device Definition" specification.
+*/
+enum TMTPUsbContainerTypeCode
+    {
+    EMTPUsbContainerTypeUndefined       = 0x0000,
+    EMTPUsbContainerTypeCommandBlock    = 0x0001,
+    EMTPUsbContainerTypeDataBlock       = 0x0002,
+    EMTPUsbContainerTypeResponseBlock   = 0x0003,
+    EMTPUsbContainerTypeEventBlock      = 0x0004,
+    };
+
+/**
+MTP USB device class control request datacodes. For a description of these 
+datacodes, please refer to the "Universal Serial Bus Still Image Capture 
+Device Definition" specification.
+*/
+enum TMTPUsbControlRequestCode
+    {
+    EMTPUsbControlRequestCancel             = 0x64,
+    EMTPUsbControlRequestDeviceReset        = 0x66,
+    EMTPUsbControlRequestDeviceStatus       = 0x67,  
+    };
+
+/**
+MTP USB device class device status datacodes. For a description of these 
+datacodes, please refer to the "Universal Serial Bus Still Image Capture 
+Device Definition" specification.
+*/
+enum TMTPUsbDeviceCode
+    {
+    EMTPUsbDeviceStatusOK                   = 0x2001,  
+    EMTPUsbDeviceStatusBusy                 = 0x2019,  
+    EMTPUsbDeviceStatusTransactionCancelled = 0x201F,  
+    };
+
+/**
+The MTP USB device class interface description string.
+*/
+_LIT16(KMTPUsbInterfaceString, "MTP");
+
+/**
+Still Image Capture (SIC) device class definitions, as specified in the 
+"Universal Serial Bus Still Image Capture Device Definition" specification.
+*/
+const TUint8 KMTPUsbInterfaceClassSIC(0x06);
+const TUint8 KMTPUsbInterfaceSubClassSIC(0x01);
+const TUint8 KMTPUsbInterfaceProtocolSIC(0x01);
+
+/**
+MTP device class definitions.
+*/
+const TUint8 KMTPUsbInterfaceClassUnknown(0x00);
+
+/**
+The maximum value of the USB generic containrer dataset ContainerLength field.
+*/
+const TUint32 KMTPUsbContainerLengthMax(0xFFFFFFFF);
+
+/*
+ * Usb transport implementation UID
+ */
+const TUint KMTPUsbTransportImplementationUid  = 0x102827B2;
+
+#endif // MTPUSBPROTOCOLCONSTANTS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,32 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// MTP framework transport components
+// 
+//
+
+/**
+ @file
+*/
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+
+#include        "../usbdatatypes/group/bld.inf"
+#include        "../usbsic_imp/group/bld.inf"
+#include        "../usbsic_cc/group/bld.inf"
+
+PRJ_EXPORTS
+mtp_usbsic.iby		/epoc32/rom/include/mtp_usbsic.iby
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/group/mtp_usbsic.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -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 MTP_USBSIC_IBY
+#define MTP_USBSIC_IBY
+
+#if !defined (SYMBIAN_EXCLUDE_MTP) && !defined(SYMBIAN_EXCLUDE_USB)
+
+#include <mtp_framework.iby>
+
+//MTP USB Data Types Library
+file=ABI_DIR\BUILD_DIR\mtpusbdatatypes.dll				system\libs\mtpusbdatatypes.dll
+
+//MTP USB Still Image Class Controller
+ECOM_PLUGIN(mtpusbsiccc.dll, mtpusbsiccc.rsc)
+
+//MTP USB SIC transport plugin
+ECOM_PLUGIN(mtpusbsicimp.dll, mtpusbsicimp.rsc)
+
+#endif // SYMBIAN_EXCLUDE_MTP
+
+#endif // MTP_USBSIC_IBY
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/group/mtp_usbsic.mrp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,26 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	mtp_usbsic
+source \sf\mw\remoteconn\mtptransports\mtpusbtransport
+
+binary	\sf\mw\remoteconn\mtptransports\mtpusbtransport\group all
+exports	\sf\mw\remoteconn\mtptransports\mtpusbtransport\group
+
+notes_source	\component_defs\release.src
+
+ipr E 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbdatatypes/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,28 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// MTP USB data types 
+// 
+//
+
+/**
+ @file
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES 
+mtpusbdatatypes.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbdatatypes/group/mtpusbdatatypes.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,46 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mtpusbdatatypes.dll MTP USB Data Types Library
+// 
+//
+
+/**
+ @file
+*/
+
+TARGET              mtpusbdatatypes.dll
+TARGETTYPE          DLL
+UID         	    0x1000008D 0x102827A9
+VENDORID 			0x70000001
+
+CAPABILITY          All -Tcb
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+USERINCLUDE         ../inc
+
+SOURCEPATH          ../src/ 
+SOURCE              cmtpusbcontainer.cpp
+SOURCE              tmtpusbcontrolrequestcanceldata.cpp
+SOURCE              tmtpusbcontrolrequestdevicestatus.cpp
+SOURCE              tmtpusbcontrolrequestmodfunction.cpp
+SOURCE              tmtpusbcontrolrequestmodheader.cpp
+SOURCE              tmtpusbcontrolrequestsetup.cpp
+SOURCE              tmtpusbparameterpayloadblock.cpp
+
+LIBRARY             euser.lib
+
+LIBRARY             mtpdatatypes.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbdatatypes/inc/cmtpusbcontainer.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,142 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPUSBCONTAINER_H
+#define CMTPUSBCONTAINER_H
+
+#include <mtp/cmtptypecompoundbase.h>
+
+/**
+Defines the MTP USB device class generic bulk container dataset.
+@internalComponent
+ 
+*/
+class CMTPUsbContainer : public CMTPTypeCompoundBase
+    {
+
+public:
+
+    /**
+    MTP USB generic bulk container dataset element identifiers.
+    */
+    enum TElements
+        {
+        /**
+        The Container Length field element.
+        */
+        EContainerLength,
+        
+        /**
+        The Container Type field element.
+        */
+        EContainerType,
+        
+        /**
+        The Codeh field element.
+        */
+        ECode,
+        
+        /**
+        The TransactionID field element.
+        */
+        ETransactionID,
+        
+        /**
+        The Payload field element.
+        */
+        EPayload,
+        
+        /**
+        The number of elements.
+        */
+        ENumElements
+        };
+     
+public:
+    
+    IMPORT_C static CMTPUsbContainer* NewL();
+    IMPORT_C ~CMTPUsbContainer();
+    
+    IMPORT_C MMTPType* Payload() const;
+    IMPORT_C void SetPayloadL(MMTPType* aPayload);
+     
+public: // From MMTPType
+
+    IMPORT_C TUint Type() const;
+        
+private: // From CMTPTypeCompoundBase
+    
+    const TElementInfo& ElementInfo(TInt aElementId) const;
+    
+private:
+
+    CMTPUsbContainer();        
+    void ConstructL();   
+    
+private: // Owned
+        
+    /**
+    Data chunk identifiers.
+    */
+    enum TChunkIds
+        {
+        /**
+        The flat data chunk ID.
+        */
+        EIdFlatChunk,
+        
+        /**
+        The EMTPExtensions element data chunk ID.
+        */
+        EIdPayloadChunk,
+        
+        /**
+        The number of data chunks.
+        */
+        EIdNumChunks
+        };
+    
+    /**
+    The flat data chunk comprising the header elements EContainerLength to 
+    ETransactionId.
+    */
+    RMTPTypeCompoundFlatChunk                       iChunkHeader;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The size in bytes of the header data chunk.
+    */
+    static const TUint                              KFlatChunkSize;
+    
+private: // Not owned
+
+    MMTPType*                                       iPayload;
+    };
+    
+#endif // CMTPUSBCONTAINER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbdatatypes/inc/mtpusbdatatypeconstants.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,42 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef MTPUSBDATATYPECONSTANTS_H
+#define MTPUSBDATATYPECONSTANTS_H
+
+#include <mtp/mtpdatatypeconstants.h>
+
+/**
+USB MTP device class data type identifiers. 
+*/
+enum TMTPUsbTypeIds
+    {
+    EMTPUsbTypeContainer                    = (EMTPFirstTransportDataType),
+    EMTPUsbTypeContainerHeader              = (EMTPFirstTransportDataType + 1),
+    EMTPUsbTypeControlRequestCancelData     = (EMTPFirstTransportDataType + 2),
+    EMTPUsbTypeControlRequestDeviceStatus   = (EMTPFirstTransportDataType + 3),
+    EMTPUsbTypeControlRequestMODFunction    = (EMTPFirstTransportDataType + 4),
+    EMTPUsbTypeControlRequestMODHeader      = (EMTPFirstTransportDataType + 5),
+    EMTPUsbTypeControlRequestSetup          = (EMTPFirstTransportDataType + 6),
+    EMTPUsbTypeEventContainer               = (EMTPFirstTransportDataType + 7),
+    EMTPUsbTypeParameterPayloadBlock        = (EMTPFirstTransportDataType + 8),
+    };
+
+#endif // MTPUSBDATATYPECONSTANTS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbdatatypes/inc/tmtpusbcontrolrequestcanceldata.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,81 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef TMTPUSBCONTROLREQUESTCANCELDATA_H
+#define TMTPUSBCONTROLREQUESTCANCELDATA_H
+
+#include <mtp/tmtptypeflatbase.h>
+
+/**
+Defines the MTP USB device class cancel control request dataset.
+@internalComponent
+ 
+*/
+class TMTPUsbControlRequestCancelData : public TMTPTypeFlatBase 
+    {
+    
+public:
+
+    /**
+    MTP USB cance request dataset element identifiers.
+    */
+    enum TElements
+        {
+        ECancellationCode,
+        ETransactionID,
+        ENumElements
+        };
+        
+public:
+
+    IMPORT_C TMTPUsbControlRequestCancelData();
+     
+public: // From TMTPTypeFlatBase
+
+    IMPORT_C TUint Type() const;
+    
+private: // From TMTPTypeFlatBase
+
+    IMPORT_C const TMTPTypeFlatBase::TElementInfo& ElementInfo(TInt aElementId) const;
+
+private:
+   
+    /**
+    The dataset size in bytes.
+    */
+    static const TInt                               KSize = 6;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const TMTPTypeFlatBase::TElementInfo     iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The data buffer.
+    */
+    TBuf8<KSize>                                    iBuffer; 
+    };
+    
+#endif // TMTPUSBCONTROLREQUESTCANCELDATA_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbdatatypes/inc/tmtpusbcontrolrequestdevicestatus.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,134 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef TMTPUSBCONTROLREQUESTDEVICESTATUS_H
+#define TMTPUSBCONTROLREQUESTDEVICESTATUS_H
+
+#include <mtp/tmtptypeflatbase.h>
+
+/**
+Defines the MTP USB device class device status control request dataset. This 
+dataset is of variable length depending on the number of non-zero parameter
+values.
+@internalComponent
+ 
+*/
+class TMTPUsbControlRequestDeviceStatus : public TMTPTypeFlatBase 
+    {
+    
+public:
+
+    /**
+    MTP USB device status control request dataset element identifiers.
+    */
+    enum TElements
+        {
+        EwLength,
+        ECode,
+        EParameter1,
+        EParameter2,
+        EParameter3,
+        EParameter4,
+        EParameter5,
+        EParameter6,
+        EParameter7,
+        EParameter8,
+        EParameter9,
+        EParameter10,
+        EParameter11,
+        EParameter12,
+        EParameter13,
+        EParameter14,
+        EParameter15,
+        EParameter16,
+        EParameter17,
+        EParameter18,
+        EParameter19,
+        EParameter20,
+        EParameter21,
+        EParameter22,
+        EParameter23,
+        EParameter24,
+        EParameter25,
+        EParameter26,
+        EParameter27,
+        EParameter28,
+        EParameter29,
+        EParameter30,
+        EParameter31,
+        EParameter32,
+        ENumElements
+        };
+   
+    /**
+    The dataset size in bytes.
+    */
+    static const TInt   KMaxSize        = 132;
+    
+    /**
+    The maximum parameter count.
+    */
+    static const TUint  KMaxParameters  = (ENumElements - EParameter1);
+        
+public:
+
+    IMPORT_C TMTPUsbControlRequestDeviceStatus();
+    
+    IMPORT_C TUint NumParameters() const;
+     
+public: // From TMTPTypeFlatBase
+    
+    IMPORT_C void Reset();
+    IMPORT_C void SetUint32(TInt aElementId, TUint32 aData); 
+    IMPORT_C TUint32 Uint32(TInt aElementId) const;
+    IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TUint64 Size() const;
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+    
+private: // From TMTPTypeFlatBase
+
+    IMPORT_C const TMTPTypeFlatBase::TElementInfo& ElementInfo(TInt aElementId) const;
+
+private:
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const TMTPTypeFlatBase::TElementInfo     iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The data buffer.
+    */
+    TBuf8<KMaxSize>                                 iBuffer;
+    
+    /**
+    The number of parameters in the dataset which are set.
+    */
+    TUint                                           iNumParameters;
+    };
+    
+#endif // TMTPUSBCONTROLREQUESTDEVICESTATUS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbdatatypes/inc/tmtpusbcontrolrequestmodfunction.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,87 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef TMTPUSBCONTROLREQUESTMODFUNCTION_H
+#define TMTPUSBCONTROLREQUESTMODFUNCTION_H
+
+#include <mtp/tmtptypeflatbase.h>
+
+/**
+Defines the MTP USB device class Microsoft OS Feature Descriptor (MOD) function 
+section dataset.
+@internalComponent
+ 
+*/
+class TMTPUsbControlRequestMODFunction : public TMTPTypeFlatBase 
+    {
+
+public:
+
+    /**
+    MTP USB MOD function section dataset element identifiers.
+    */
+    enum TElements
+        {
+        EdwLength,
+        EbcdVersion,
+        EwIndex,
+        EbCount,
+        EReserved1,
+        EReserved2,
+        EReserved3,
+        EReserved4,
+        EReserved5,
+        EReserved6,
+        EReserved7,
+        EbFirstInterfaceNo,
+        EbInterfaceCount,
+        EcompatibleID,
+        EsubCompatibleID,
+        EReserved8,
+        EReserved9,
+        EReserved10,
+        EReserved11,
+        EReserved12,
+        EReserved13,
+        ENumElements
+        };   
+     
+public:
+
+    IMPORT_C TMTPUsbControlRequestMODFunction();
+     
+public: // From TMTPTypeFlatBase
+
+    IMPORT_C TUint Type() const;
+    
+private: // From TMTPTypeFlatBase
+
+    IMPORT_C const TMTPTypeFlatBase::TElementInfo& ElementInfo(TInt aElementId) const;
+       
+private:
+   
+    static const TInt                               KSize = 40;
+    static const TMTPTypeFlatBase::TElementInfo     iElementMetaData[];
+    
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    TBuf8<KSize>                                    iBuffer;      
+    };
+
+#endif // TMTPUSBCONTROLREQUESTMODFUNCTION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbdatatypes/inc/tmtpusbcontrolrequestmodheader.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,91 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef TMTPUSBCONTROLREQUESTMODHEADER_H
+#define TMTPUSBCONTROLREQUESTMODHEADER_H
+
+#include <mtp/tmtptypeflatbase.h>
+
+/**
+Defines the MTP USB device class Microsoft OS Feature Descriptor (MOD) header 
+section dataset.
+@internalComponent
+ 
+*/
+class TMTPUsbControlRequestMODHeader : public TMTPTypeFlatBase 
+    {
+    
+public:
+
+    /**
+    MTP USB MOD header section dataset element identifiers.
+    */
+    enum TElements
+        {
+        EdwLength,
+        EbcdVersion,
+        EwIndex,
+        EbCount,
+        EReserved1,
+        EReserved2,
+        EReserved3,
+        EReserved4,
+        EReserved5,
+        EReserved6,
+        EReserved7,
+        ENumElements
+        };
+     
+public:
+
+    IMPORT_C TMTPUsbControlRequestMODHeader();
+     
+public: // From TMTPTypeFlatBase
+
+    IMPORT_C TUint Type() const;
+    
+private: // From TMTPTypeFlatBase
+
+    IMPORT_C const TMTPTypeFlatBase::TElementInfo& ElementInfo(TInt aElementId) const;
+       
+private:
+   
+    /**
+    The dataset size in bytes.
+    */
+    static const TInt                               KSize = 16;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const TMTPTypeFlatBase::TElementInfo     iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The data buffer.
+    */
+    TBuf8<KSize>                                    iBuffer;     
+    };
+    
+#endif // TMTPUSBCONTROLREQUESTMODHEADER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbdatatypes/inc/tmtpusbcontrolrequestsetup.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,84 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef TMTPUSBCONTROLREQUESTSETUP_H
+#define TMTPUSBCONTROLREQUESTSETUP_H
+
+#include <mtp/tmtptypeflatbase.h>
+
+/**
+Defines the MTP USB device class control request setup dataset.
+@internalComponent
+ 
+*/
+class TMTPUsbControlRequestSetup : public TMTPTypeFlatBase 
+    {
+    
+public:
+
+    /**
+    MTP USB control request setup dataset element identifiers.
+    */
+    enum TElements
+        {
+        EbmRequestType,
+        EbRequest,
+        EwValue,
+        EwIndex,
+        EwLength,
+        ENumElements
+        };
+        
+public:
+
+    IMPORT_C TMTPUsbControlRequestSetup();
+     
+public: // From TMTPTypeFlatBase
+
+    IMPORT_C TUint Type() const;
+    
+private: // From TMTPTypeFlatBase
+
+    IMPORT_C const TMTPTypeFlatBase::TElementInfo& ElementInfo(TInt aElementId) const;
+
+private:
+   
+    /**
+    The dataset size in bytes.
+    */
+    static const TInt                               KSize = 8;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const TMTPTypeFlatBase::TElementInfo     iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The data buffer.
+    */
+    TBuf8<KSize>                                    iBuffer;        
+    };
+
+#endif // TMTPUSBCONTROLREQUESTSETUP_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbdatatypes/inc/tmtpusbparameterpayloadblock.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,101 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef TMTPUSBPARAMETERPAYLOADBLOCK_H
+#define TMTPUSBPARAMETERPAYLOADBLOCK_H
+
+#include <mtp/tmtptypeflatbase.h> 
+
+/**
+Defines the MTP USB device class parameter block dataset. This dataset is used
+as the variable length Command and Response type bulk container payload.
+@internalComponent
+ 
+*/
+class TMTPUsbParameterPayloadBlock : public TMTPTypeFlatBase
+    {
+public:
+
+    /**
+    MTP operation request dataset element identifiers.
+    */      
+    enum TElements
+        {
+        EParameter1,
+        EParameter2,
+        EParameter3,
+        EParameter4,
+        EParameter5,
+        ENumElements, 
+        };  
+        
+public:
+
+    IMPORT_C TMTPUsbParameterPayloadBlock();
+    
+    IMPORT_C TUint NumParameters() const;
+    IMPORT_C void CopyIn(const TMTPTypeFlatBase& aFrom, TUint aParamStartOffset, TUint aParamEndOffSet, TBool aIsNullParamValid, TUint aNumOfNullParam);
+    IMPORT_C void CopyOut(TMTPTypeFlatBase& aTo, TUint aParamStartOffset, TUint aParamEndOffset);
+    
+public: // From TMTPTypeFlatBase
+    
+    IMPORT_C void Reset();
+    IMPORT_C void SetUint32(TInt aElementId, TUint32 aData); 
+    IMPORT_C TUint32 Uint32(TInt aElementId) const;
+    IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const;
+    IMPORT_C TUint64 Size() const;
+    IMPORT_C TUint Type() const;
+    IMPORT_C TBool CommitRequired() const;
+    IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk);
+    
+private: // From TMTPTypeFlatBase
+    
+    IMPORT_C const TMTPTypeFlatBase::TElementInfo& ElementInfo(TInt aElementId) const; 
+
+private: 
+   
+    /**
+    The maximum dataset size in bytes.
+    */
+    static const TInt                               KMaxSize = 20;
+    
+    /**
+    The dataset element metadata table content.
+    */
+    static const TMTPTypeFlatBase::TElementInfo     iElementMetaData[];
+    
+    /**
+    The dataset element metadata table.
+    */
+    const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
+    
+    /**
+    The data buffer.
+    */
+    TBuf8<KMaxSize>                                 iBuffer;
+    
+    /**
+    The number of parameters in the block which are set.
+    */
+    TUint                                           iNumParameters;
+    };
+
+#endif // TMTPUSBPARAMETERPAYLOADBLOCK_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbdatatypes/src/cmtpusbcontainer.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,122 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "cmtpusbcontainer.h"
+#include "mtpusbdatatypeconstants.h"
+
+// Dataset constants
+const TUint CMTPUsbContainer::KFlatChunkSize(12);
+
+// Dataset element metadata.
+const CMTPTypeCompoundBase::TElementInfo CMTPUsbContainer::iElementMetaData[CMTPUsbContainer::ENumElements] = 
+    {
+        {EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT32,    0,                  KMTPTypeUINT32Size}},   // EContainerLength
+        {EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT16,    4,                  KMTPTypeUINT16Size}},   // EContainerType
+        {EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT16,    6,                  KMTPTypeUINT16Size}},   // ECode
+        {EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT32,    8,                  KMTPTypeUINT32Size}},   // ETransactionID
+        {EIdPayloadChunk,   EMTPTypeUndefined,  {EMTPTypeUndefined, KMTPNotApplicable,  KMTPNotApplicable}}     // EPayload
+    };
+
+/**
+MTP USB device class generic bulk container dataset factory method. This method
+is used to create an empty MTP USB device class generic bulk container dataset 
+type. 
+@return A pointer to an empty an empty MTP USB device class generic bulk 
+container dataset type. Ownership IS transfered.
+@leave One of the system wide error codes, if unsuccessful.
+*/ 
+EXPORT_C CMTPUsbContainer* CMTPUsbContainer::NewL()
+    {
+    CMTPUsbContainer* self = new (ELeave) CMTPUsbContainer(); 
+    CleanupStack::PushL(self); 
+    self->ConstructL();   
+    CleanupStack::Pop(self);
+    return self; 
+    }
+
+/**
+Destructor.
+*/
+EXPORT_C CMTPUsbContainer::~CMTPUsbContainer()
+    {
+    iChunkHeader.Close();
+    }
+
+/**
+Provides the bulk container payload.
+@return The bulk container payload.
+*/
+EXPORT_C MMTPType* CMTPUsbContainer::Payload() const
+    {    
+    return iPayload;
+    }
+
+/**
+Sets the bulk container payload.
+@param aPayload The new bulk container payload.
+*/
+EXPORT_C void CMTPUsbContainer::SetPayloadL(MMTPType* aPayload)
+    {    
+    if (iPayload)
+        {
+        // Remove the existing payload from the super class.
+        ChunkRemove(iElementMetaData[EPayload].iChunkId);
+        }
+        
+    if (aPayload)
+        {
+        // Pass the payload to the super class for management.
+        ChunkAppendL(*aPayload);  
+        }
+    iPayload = aPayload; 
+    }
+
+
+EXPORT_C TUint CMTPUsbContainer::Type() const
+    {
+    return EMTPUsbTypeContainer;
+    }
+    
+const CMTPTypeCompoundBase::TElementInfo& CMTPUsbContainer::ElementInfo(TInt aElementId) const
+    {
+    __ASSERT_DEBUG((aElementId < ENumElements), User::Invariant());
+    return iElementInfo[aElementId];
+    }
+       
+/**
+Constructor.
+*/
+CMTPUsbContainer::CMTPUsbContainer() : 
+    CMTPTypeCompoundBase((!KJustInTimeConstruction), EIdNumChunks), 
+    iChunkHeader(KFlatChunkSize, *this),
+    iElementInfo(iElementMetaData, ENumElements)
+    {
+    
+    }
+
+/**
+Second phase constructor.
+*/   
+void CMTPUsbContainer::ConstructL()
+    {
+    iChunkHeader.OpenL();
+    ChunkAppendL(iChunkHeader);
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbdatatypes/src/tmtpusbcontrolrequestcanceldata.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,52 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+
+#include "mtpusbdatatypeconstants.h"
+#include "tmtpusbcontrolrequestcanceldata.h"
+    
+// Dataset element metadata.
+const TMTPUsbControlRequestCancelData::TElementInfo TMTPUsbControlRequestCancelData::iElementMetaData[ENumElements] = 
+    {
+        {EMTPTypeUINT16,    0,  KMTPTypeUINT16Size},    // ECancellationCode
+        {EMTPTypeUINT32,    2,  KMTPTypeUINT32Size},    // ETransactionID
+    }; 
+
+/** 
+Constructor
+*/
+EXPORT_C TMTPUsbControlRequestCancelData::TMTPUsbControlRequestCancelData() :
+    iElementInfo(iElementMetaData, ENumElements),
+    iBuffer(KSize)
+    {
+    SetBuffer(iBuffer);
+    }     
+
+EXPORT_C TUint TMTPUsbControlRequestCancelData::Type() const
+	{
+	return EMTPUsbTypeControlRequestCancelData;
+	}
+    
+EXPORT_C const TMTPTypeFlatBase::TElementInfo& TMTPUsbControlRequestCancelData::ElementInfo(TInt aElementId) const
+    {
+    __ASSERT_DEBUG((aElementId < ENumElements), User::Invariant());
+    return iElementInfo[aElementId];
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbdatatypes/src/tmtpusbcontrolrequestdevicestatus.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,162 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <mtp/mtpprotocolconstants.h>
+
+#include "mtpusbdatatypeconstants.h"
+#include "tmtpusbcontrolrequestdevicestatus.h"
+    
+// Dataset element metadata.
+const TMTPUsbControlRequestDeviceStatus::TElementInfo TMTPUsbControlRequestDeviceStatus::iElementMetaData[ENumElements] = 
+    {
+        {EMTPTypeUINT16,   0,   KMTPTypeUINT16Size},    // EwLength
+        {EMTPTypeUINT16,   2,   KMTPTypeUINT16Size},    // ECode
+        {EMTPTypeUINT32,    4,   KMTPTypeUINT32Size},     // EParameter1
+        {EMTPTypeUINT32,    8,   KMTPTypeUINT32Size},     // EParameter2
+        {EMTPTypeUINT32,    12,  KMTPTypeUINT32Size},     // EParameter3 
+        {EMTPTypeUINT32,    16,  KMTPTypeUINT32Size},     // EParameter4 
+        {EMTPTypeUINT32,    20,  KMTPTypeUINT32Size},     // EParameter5
+        {EMTPTypeUINT32,    24,  KMTPTypeUINT32Size},     // EParameter6
+        {EMTPTypeUINT32,    28,  KMTPTypeUINT32Size},     // EParameter7
+        {EMTPTypeUINT32,    32,  KMTPTypeUINT32Size},     // EParameter8
+        {EMTPTypeUINT32,    36,  KMTPTypeUINT32Size},     // EParameter9
+        {EMTPTypeUINT32,    40,  KMTPTypeUINT32Size},     // EParameter10
+        {EMTPTypeUINT32,    44,  KMTPTypeUINT32Size},     // EParameter11
+        {EMTPTypeUINT32,    48,  KMTPTypeUINT32Size},     // EParameter12
+        {EMTPTypeUINT32,    52,  KMTPTypeUINT32Size},     // EParameter13
+        {EMTPTypeUINT32,    56,  KMTPTypeUINT32Size},     // EParameter14
+        {EMTPTypeUINT32,    60,  KMTPTypeUINT32Size},     // EParameter15
+        {EMTPTypeUINT32,    64,  KMTPTypeUINT32Size},     // EParameter16
+        {EMTPTypeUINT32,    68,  KMTPTypeUINT32Size},     // EParameter17
+        {EMTPTypeUINT32,    72,  KMTPTypeUINT32Size},     // EParameter18
+        {EMTPTypeUINT32,    76,  KMTPTypeUINT32Size},     // EParameter19
+        {EMTPTypeUINT32,    80,  KMTPTypeUINT32Size},     // EParameter20
+        {EMTPTypeUINT32,    84,  KMTPTypeUINT32Size},     // EParameter21
+        {EMTPTypeUINT32,    88,  KMTPTypeUINT32Size},     // EParameter22
+        {EMTPTypeUINT32,    92,  KMTPTypeUINT32Size},     // EParameter23
+        {EMTPTypeUINT32,    96,  KMTPTypeUINT32Size},     // EParameter24
+        {EMTPTypeUINT32,    100,  KMTPTypeUINT32Size},     // EParameter25
+        {EMTPTypeUINT32,    104,  KMTPTypeUINT32Size},     // EParameter26
+        {EMTPTypeUINT32,    108,  KMTPTypeUINT32Size},     // EParameter27
+        {EMTPTypeUINT32,    112,  KMTPTypeUINT32Size},     // EParameter28
+        {EMTPTypeUINT32,    116,  KMTPTypeUINT32Size},     // EParameter29
+        {EMTPTypeUINT32,    120,  KMTPTypeUINT32Size},     // EParameter30
+        {EMTPTypeUINT32,    124,  KMTPTypeUINT32Size},     // EParameter31
+        {EMTPTypeUINT32,    128,  KMTPTypeUINT32Size},     // EParameter32
+    }; 
+
+/** 
+Constructor
+*/
+EXPORT_C TMTPUsbControlRequestDeviceStatus::TMTPUsbControlRequestDeviceStatus() :
+    iElementInfo(iElementMetaData, ENumElements),
+    iBuffer(KMaxSize),
+    iNumParameters(0)
+    {
+    SetBuffer(iBuffer);
+    }   
+    
+/**
+Provides the number of parameters in the dataset which are set.
+@return the number of set parameters.
+*/
+EXPORT_C TUint TMTPUsbControlRequestDeviceStatus::NumParameters() const
+    {
+    return iNumParameters;        
+    }  
+    
+/**
+Resets the dataset.
+*/
+EXPORT_C void TMTPUsbControlRequestDeviceStatus::Reset()
+    {
+    TMTPTypeFlatBase::Reset();
+    iNumParameters = 0;
+    }
+	
+EXPORT_C void TMTPUsbControlRequestDeviceStatus::SetUint32(TInt aElementId, TUint32 aData)
+    {
+    // Recalculate iNumParameters.
+    TUint num((aElementId - EParameter1) + 1);
+    if (num > iNumParameters)
+        {
+        iNumParameters = num;            
+        }
+        
+    //  Set the element value.
+    TMTPTypeFlatBase::SetUint32(aElementId, aData);
+    }
+    
+EXPORT_C TUint32 TMTPUsbControlRequestDeviceStatus::Uint32(TInt aElementId) const
+    {
+    __ASSERT_DEBUG((aElementId - EParameter1 < iNumParameters), User::Invariant());
+    return TMTPTypeFlatBase::Uint32(aElementId);
+    }
+
+EXPORT_C TInt TMTPUsbControlRequestDeviceStatus::FirstReadChunk(TPtrC8& aChunk) const
+    {
+    TInt    ret(TMTPTypeFlatBase::FirstReadChunk(aChunk));
+    TUint64 size(Size());
+    
+    if (size < aChunk.Size())
+        {
+        // Truncate the buffer at the last set parameter.
+        aChunk.Set(aChunk.Left(size));
+        }
+
+    return ret;
+    }
+
+EXPORT_C TUint64 TMTPUsbControlRequestDeviceStatus::Size() const
+    {
+    const TUint emptyParams(((ENumElements - EParameter1) - iNumParameters) * iElementInfo[EParameter1].iSize);
+    return (KMaxSize - emptyParams);
+    }
+
+EXPORT_C TUint TMTPUsbControlRequestDeviceStatus::Type() const
+	{
+	return EMTPUsbTypeControlRequestDeviceStatus;
+	}
+    
+EXPORT_C TBool TMTPUsbControlRequestDeviceStatus::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* TMTPUsbControlRequestDeviceStatus::CommitChunkL(TPtr8& /*aChunk*/)
+    {
+    iNumParameters = 0;
+    
+    // Recalculate iNumParameters.
+    for (TUint i(EParameter1); (i <= KMaxParameters); i++)
+        {
+        if (TMTPTypeFlatBase::Uint32(i) != 0)
+            {
+            iNumParameters = i - EParameter1 + 1;
+            }
+        }
+    return NULL;
+    }
+    
+EXPORT_C const TMTPTypeFlatBase::TElementInfo& TMTPUsbControlRequestDeviceStatus::ElementInfo(TInt aElementId) const
+    {
+    __ASSERT_DEBUG((aElementId < ENumElements), User::Invariant());
+    return iElementInfo[aElementId];
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbdatatypes/src/tmtpusbcontrolrequestmodfunction.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,70 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "mtpusbdatatypeconstants.h"
+#include "tmtpusbcontrolrequestmodfunction.h"
+    
+// Dataset element metadata.
+const TMTPUsbControlRequestMODFunction::TElementInfo TMTPUsbControlRequestMODFunction::iElementMetaData[ENumElements] = 
+    {
+        {EMTPTypeUINT32,    0,  KMTPTypeUINT32Size},    // EdwLength
+        {EMTPTypeUINT16,    4,  KMTPTypeUINT16Size},    // EbcdVersion
+        {EMTPTypeUINT16,    6,  KMTPTypeUINT16Size},    // EwIndex
+        {EMTPTypeUINT8,     8,  KMTPTypeUINT8Size},     // EbCount
+        {EMTPTypeUINT8,     9,  KMTPTypeUINT8Size},     // EReserved1 
+        {EMTPTypeUINT8,     10, KMTPTypeUINT8Size},     // EReserved2 
+        {EMTPTypeUINT8,     11, KMTPTypeUINT8Size},     // EReserved3 
+        {EMTPTypeUINT8,     12, KMTPTypeUINT8Size},     // EReserved4 
+        {EMTPTypeUINT8,     13, KMTPTypeUINT8Size},     // EReserved5 
+        {EMTPTypeUINT8,     14, KMTPTypeUINT8Size},     // EReserved6 
+        {EMTPTypeUINT8,     15, KMTPTypeUINT8Size},     // EReserved7 
+        {EMTPTypeUINT8,     16, KMTPTypeUINT8Size},     // EbFirstInterfaceNo  
+        {EMTPTypeUINT8,     17, KMTPTypeUINT8Size},     // EbInterfaceCount  
+        {EMTPTypeUINT64,    18, KMTPTypeUINT64Size},    // EcompatibleID  
+        {EMTPTypeUINT64,    26, KMTPTypeUINT64Size},    // EsubCompatibleID  
+        {EMTPTypeUINT8,     34, KMTPTypeUINT8Size},     // EReserved8 
+        {EMTPTypeUINT8,     35, KMTPTypeUINT8Size},     // EReserved9 
+        {EMTPTypeUINT8,     36, KMTPTypeUINT8Size},     // EReserved10 
+        {EMTPTypeUINT8,     37, KMTPTypeUINT8Size},     // EReserved11
+        {EMTPTypeUINT8,     38, KMTPTypeUINT8Size},     // EReserved12 
+        {EMTPTypeUINT8,     39, KMTPTypeUINT8Size},     // EReserved13 
+    }; 
+
+/** 
+Constructor
+*/
+EXPORT_C TMTPUsbControlRequestMODFunction::TMTPUsbControlRequestMODFunction() :
+    iElementInfo(iElementMetaData, ENumElements),
+    iBuffer(KSize)
+    {
+    SetBuffer(iBuffer);
+    }     
+
+EXPORT_C TUint TMTPUsbControlRequestMODFunction::Type() const
+	{
+	return EMTPUsbTypeControlRequestMODFunction;
+	}
+    
+EXPORT_C const TMTPTypeFlatBase::TElementInfo& TMTPUsbControlRequestMODFunction::ElementInfo(TInt aElementId) const
+    {
+    __ASSERT_DEBUG((aElementId < ENumElements), User::Invariant());
+    return iElementInfo[aElementId];
+    }
+   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbdatatypes/src/tmtpusbcontrolrequestmodheader.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,59 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "mtpusbdatatypeconstants.h"
+#include "tmtpusbcontrolrequestmodheader.h"
+    
+// Dataset element metadata.
+const TMTPUsbControlRequestMODHeader::TElementInfo TMTPUsbControlRequestMODHeader::iElementMetaData[ENumElements] = 
+    {
+        {EMTPTypeUINT32,    0,  KMTPTypeUINT32Size},    // EdwLength
+        {EMTPTypeUINT16,    4,  KMTPTypeUINT16Size},    // EbcdVersion
+        {EMTPTypeUINT16,    6,  KMTPTypeUINT16Size},    // EwIndex
+        {EMTPTypeUINT8,     8,  KMTPTypeUINT8Size},     // EbCount
+        {EMTPTypeUINT8,     9,  KMTPTypeUINT8Size},     // EReserved1 
+        {EMTPTypeUINT8,     10, KMTPTypeUINT8Size},     // EReserved2 
+        {EMTPTypeUINT8,     11, KMTPTypeUINT8Size},     // EReserved3 
+        {EMTPTypeUINT8,     12, KMTPTypeUINT8Size},     // EReserved4 
+        {EMTPTypeUINT8,     13, KMTPTypeUINT8Size},     // EReserved5 
+        {EMTPTypeUINT8,     14, KMTPTypeUINT8Size},     // EReserved6 
+        {EMTPTypeUINT8,     15, KMTPTypeUINT8Size},     // EReserved7 
+    }; 
+
+/** 
+Constructor
+*/
+EXPORT_C TMTPUsbControlRequestMODHeader::TMTPUsbControlRequestMODHeader() :
+    iElementInfo(iElementMetaData, ENumElements),
+    iBuffer(KSize)
+    {
+    SetBuffer(iBuffer);
+    }     
+
+EXPORT_C TUint TMTPUsbControlRequestMODHeader::Type() const
+	{
+	return EMTPUsbTypeControlRequestMODHeader;
+	}
+    
+EXPORT_C const TMTPTypeFlatBase::TElementInfo& TMTPUsbControlRequestMODHeader::ElementInfo(TInt aElementId) const
+    {
+    __ASSERT_DEBUG((aElementId < ENumElements), User::Invariant());
+    return iElementInfo[aElementId];
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbdatatypes/src/tmtpusbcontrolrequestsetup.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,53 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "mtpusbdatatypeconstants.h"
+#include "tmtpusbcontrolrequestsetup.h"
+    
+// Dataset element metadata.
+const TMTPUsbControlRequestSetup::TElementInfo TMTPUsbControlRequestSetup::iElementMetaData[ENumElements] = 
+    {
+        {EMTPTypeUINT8,     0,  KMTPTypeUINT8Size},     // EbmRequestType
+        {EMTPTypeUINT8,     1,  KMTPTypeUINT8Size},     // EbRequest
+        {EMTPTypeUINT16,    2,  KMTPTypeUINT16Size},    // EwValue
+        {EMTPTypeUINT16,    4,  KMTPTypeUINT16Size},    // EwIndex
+        {EMTPTypeUINT16,    6,  KMTPTypeUINT16Size},    // EwLength 
+    }; 
+
+/** 
+Constructor
+*/
+EXPORT_C TMTPUsbControlRequestSetup::TMTPUsbControlRequestSetup() :
+    iElementInfo(iElementMetaData, ENumElements),
+    iBuffer(KSize)
+    {
+    SetBuffer(iBuffer);
+    }     
+
+EXPORT_C TUint TMTPUsbControlRequestSetup::Type() const
+	{
+	return EMTPUsbTypeControlRequestSetup;
+	}
+    
+EXPORT_C const TMTPTypeFlatBase::TElementInfo& TMTPUsbControlRequestSetup::ElementInfo(TInt aElementId) const
+    {
+    __ASSERT_DEBUG((aElementId < ENumElements), User::Invariant());
+    return iElementInfo[aElementId];
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbdatatypes/src/tmtpusbparameterpayloadblock.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,188 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mtpprotocolconstants.h>
+
+#include "mtpusbdatatypeconstants.h"
+#include "tmtpusbparameterpayloadblock.h"
+
+// Dataset element metadata.
+const TMTPUsbParameterPayloadBlock::TElementInfo TMTPUsbParameterPayloadBlock::iElementMetaData[ENumElements] = 
+    {
+        {EMTPTypeUINT32, 0,     KMTPTypeUINT32Size},    // EParameter1  
+        {EMTPTypeUINT32, 4,     KMTPTypeUINT32Size},    // EParameter2
+        {EMTPTypeUINT32, 8,     KMTPTypeUINT32Size},    // EParameter3
+        {EMTPTypeUINT32, 12,    KMTPTypeUINT32Size},    // EParameter4
+        {EMTPTypeUINT32, 16,    KMTPTypeUINT32Size},    // EParameter5
+    };
+
+/**
+Constructor.
+*/
+EXPORT_C TMTPUsbParameterPayloadBlock::TMTPUsbParameterPayloadBlock() :
+    iElementInfo(iElementMetaData, ENumElements),
+    iBuffer(KMaxSize),
+    iNumParameters(0)
+    {
+    SetBuffer(iBuffer);
+    }
+    
+/**
+Provides the number of parameters in the block which are set.
+@return the number of set parameters.
+*/
+EXPORT_C TUint TMTPUsbParameterPayloadBlock::NumParameters() const
+    {
+    return iNumParameters;        
+    }
+    
+/**
+Copies up to five parameter values into the parameter block dataset 
+from the specified dataset. The paramters to be copied should be non null paramter or valid null paramter.
+@param aFrom The parameter values source dataset. This dataset should define three or five contiguous 32-bit parameter values starting at the specified offset.
+@param aParamStartOffset The element ID of the first in the set of contiguous 
+source dataset parameter values.
+@param aParamEndOffset The element ID of the last in the set of contiguous 
+source dataset parameter values.
+@param aIsNullParamValid a boolean value to check if a null parameter is valid. A value of ETrue means a null parameter is valid; EFalse means invalid.
+@param aNumOfNullParam the number of valid null parameters to be copied.
+*/
+EXPORT_C void TMTPUsbParameterPayloadBlock::CopyIn(const TMTPTypeFlatBase& aFrom, TUint aParamStartOffset, TUint aParamEndOffset, TBool aIsNullParamValid, TUint aNumOfNullParam)
+    {
+    __ASSERT_DEBUG((aParamEndOffset >= aParamStartOffset && (aParamEndOffset - aParamStartOffset + 1) <= ENumElements), User::Invariant());
+    TUint32 parameter = KMTPNotSpecified32;
+    TUint numberOfNullParam = 0;
+    TUint loopCount =  aParamEndOffset - aParamStartOffset;  
+	
+	for (TUint i(TMTPUsbParameterPayloadBlock::EParameter1); i <= loopCount; i++)
+	    {
+	    parameter = aFrom.Uint32(aParamStartOffset + i);
+	    if (parameter != KMTPNotSpecified32)
+	        {
+	        SetUint32(i, parameter);
+	        }
+	    else if(aIsNullParamValid && (numberOfNullParam < aNumOfNullParam))
+	        {
+	        SetUint32(i, parameter);
+	        numberOfNullParam++;
+	        }
+	    }     		
+    }
+
+/**
+Copies the non-null parameter values from the parameter block dataset into the 
+specified dataset. Note: the number of parameters to be copied out depends on two conditions:
+1. The number of parameters contained in this USB parameter block dataset.
+2. The number of parameters to be copied out to the parameter values sink dataset, which is (aParamEndOffset - aParamStartOffset + 1) by the caller.
+@param aTo The parameter values sink dataset. This dataset should define three or five contiguous 32-bit parameter values starting at the specified offset.
+@param aParamStartOffset the element ID of the first in the set of contiguous sink dataset parameter values.
+@param aParamEndOffset the element ID of the last in the set of contiguous sink dataset parameter values.
+*/
+EXPORT_C void TMTPUsbParameterPayloadBlock::CopyOut(TMTPTypeFlatBase& aTo, TUint aParamStartOffset, TUint aParamEndOffset)
+    {
+    __ASSERT_DEBUG((aParamEndOffset >= aParamStartOffset && (aParamEndOffset - aParamStartOffset + 1) <= ENumElements), User::Invariant());
+    TUint loopCount =  aParamEndOffset - aParamStartOffset; 
+    for (TUint i(TMTPUsbParameterPayloadBlock::EParameter1); (i < iNumParameters && i <= loopCount); i++)
+        {
+        aTo.SetUint32((aParamStartOffset + i), Uint32(i));
+        } 
+    }
+    
+/**
+Resets the dataset.
+*/
+EXPORT_C void TMTPUsbParameterPayloadBlock::Reset()
+    {
+    TMTPTypeFlatBase::Reset();
+    iNumParameters = 0;
+    }
+	
+EXPORT_C void TMTPUsbParameterPayloadBlock::SetUint32(TInt aElementId, TUint32 aData)
+    {
+    // Recalculate iNumParameters.
+    TUint num((aElementId - EParameter1) + 1);
+    
+    if (num > iNumParameters)
+        {
+        iNumParameters = num;            
+        }
+        
+    //  Set the element value.
+    TMTPTypeFlatBase::SetUint32(aElementId, aData);
+
+    }
+    
+EXPORT_C TUint32 TMTPUsbParameterPayloadBlock::Uint32(TInt aElementId) const
+    {
+    __ASSERT_DEBUG((aElementId < iNumParameters), User::Invariant());
+    return TMTPTypeFlatBase::Uint32(aElementId);
+    }
+
+EXPORT_C TInt TMTPUsbParameterPayloadBlock::FirstReadChunk(TPtrC8& aChunk) const
+    {
+    TInt    ret(TMTPTypeFlatBase::FirstReadChunk(aChunk));
+    TUint64 size(Size());
+    
+    if (size < aChunk.Size())
+        {
+        // Truncate the buffer at the last set parameter.
+        aChunk.Set(aChunk.Left(size));
+        }
+
+    return ret;
+    }
+
+EXPORT_C TUint64 TMTPUsbParameterPayloadBlock::Size() const
+    {
+    return (iNumParameters * KMTPTypeUINT32Size); 
+    }
+
+EXPORT_C TUint TMTPUsbParameterPayloadBlock::Type() const
+    {
+    return EMTPUsbTypeParameterPayloadBlock;
+    }
+    
+EXPORT_C TBool TMTPUsbParameterPayloadBlock::CommitRequired() const
+    {
+    return ETrue;
+    }
+
+EXPORT_C MMTPType* TMTPUsbParameterPayloadBlock::CommitChunkL(TPtr8& /*aChunk*/)
+    {
+    iNumParameters = 0;
+    
+    // Recalculate iNumParameters.
+    for (TUint i(EParameter1); (i <= EParameter5); i++)
+        {
+        if (TMTPTypeFlatBase::Uint32(i) != KMTPNotSpecified32)
+            {
+            iNumParameters = (i + 1);                
+            }
+        }
+    return NULL;
+    }
+    
+EXPORT_C const TMTPTypeFlatBase::TElementInfo& TMTPUsbParameterPayloadBlock::ElementInfo(TInt aElementId) const
+    {
+    __ASSERT_DEBUG((aElementId < ENumElements), User::Invariant());
+    return iElementInfo[aElementId];
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_cc/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,30 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// MTP USB device class controller plugin
+// 
+//
+
+/**
+ @file
+*/
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+#ifndef WINSCW 
+mtpusbsiccc.mmp
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_cc/group/mtpusbsiccc.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,47 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mtpusbsiccc.dll Media Transfer Protocol Framework USB SIC class controller plugin
+// 
+//
+
+/**
+ @file
+*/
+#include <comms-infras/commsdebugutility.mmh>
+
+TARGET mtpusbsiccc.dll
+TARGETTYPE PLUGIN
+CAPABILITY CommDD NetworkControl NetworkServices LocalServices ProtServ
+UID  0x10009D8D 0x102827AB
+
+SOURCEPATH ../src
+SOURCE cmtpusbsicclasscontroller.cpp
+SOURCE cmtpusbsicclassimpcollection.cpp
+
+USERINCLUDE ../inc
+USERINCLUDE ../../common/inc
+USERINCLUDE ../../../../mtpfws/mtpfw/common/inc
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+LIBRARY euser.lib 
+LIBRARY	usbclasscontroller.lib
+LIBRARY mtpclient.lib
+
+START RESOURCE  mtpusbsiccc.rss    
+TARGET          mtpusbsiccc.rsc
+END
+VENDORID 0x70000001
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_cc/inc/cmtpusbsicclasscontroller.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,75 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+#ifndef CMTPUSBSICCLASSCONTROLLER_H
+#define CMTPUSBSICCLASSCONTROLLER_H
+
+#include <e32std.h>
+#include <cusbclasscontrollerplugin.h>
+#include <mtp/rmtpclient.h>
+
+#include "mtpdebug.h"
+
+class MUsbClassControllerNotify;
+class TUsbDescriptor;
+
+/**
+Implements the USB MTP Class Controller API 
+@internalComponent
+*/
+class CMTPUsbSicClassController : public CUsbClassControllerPlugIn
+	{
+
+public: 
+
+	static CMTPUsbSicClassController* NewL(MUsbClassControllerNotify& aOwner);
+	~CMTPUsbSicClassController();
+
+private: // From CActive.
+
+	void RunL();
+	void DoCancel();
+	TInt RunError(TInt aError);
+
+private: // From CUsbClassControllerBase
+
+	void Start(TRequestStatus& aStatus);
+	void Stop(TRequestStatus& aStatus);
+
+	void GetDescriptorInfo(TUsbDescriptor& aDescriptorInfo) const;
+
+private:
+
+	CMTPUsbSicClassController(MUsbClassControllerNotify& aOwner);
+	void ConstructL();
+	
+protected:
+
+	/**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+private:
+
+	RMTPClient iMTPSession;
+	};
+
+#endif // CMTPUSBSICCLASSCONTROLLER_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_cc/src/cmtpusbsicclasscontroller.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,176 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "cmtpusbsicclasscontroller.h"
+#include <musbclasscontrollernotify.h>
+#include "mtpdebug.h"
+#include "mtpusbprotocolconstants.h"
+
+const TInt  KSicCCStartupPriority           = 3;
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"CMTPUsbSicClassController");)
+
+/**
+This method returns a pointer to a newly created CMTPUsbSicClassController object.
+@param aOwner USB Device that owns and manages the class.
+@return a newly created CMTPUsbSicClassController object.  
+*/
+CMTPUsbSicClassController* CMTPUsbSicClassController::NewL(MUsbClassControllerNotify& aOwner)
+	{
+	CMTPUsbSicClassController* self = new (ELeave) CMTPUsbSicClassController(aOwner);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+Destructor
+*/
+CMTPUsbSicClassController::~CMTPUsbSicClassController()
+	{
+	__FLOG(_L8("~CMTPUsbSicClassController - Entry"));
+	Cancel();
+	__FLOG(_L8("~CMTPUsbSicClassController - Exit"));
+	__FLOG_CLOSE;
+	}
+	
+/**
+Constructor
+@param aOwner USB Device that owns and manages the class. 
+*/
+CMTPUsbSicClassController::CMTPUsbSicClassController(MUsbClassControllerNotify& aOwner):
+	CUsbClassControllerPlugIn(aOwner, KSicCCStartupPriority)	
+	{
+	// do nothing.
+	}
+
+/**
+Second phase constructor.
+*/
+void CMTPUsbSicClassController::ConstructL()
+	{
+	__FLOG_OPEN(KMTPSubsystem, KComponent);
+	__FLOG(_L8("ConstructL - Entry"));
+	__FLOG(_L8("ConstructL - Exit"));
+	}
+
+/**
+Called by UsbMan when it wants to start the MTP USB Still Image Capture class.
+@param aStatus The caller's request status, filled in with an error code
+*/
+void CMTPUsbSicClassController::Start(TRequestStatus& aStatus)
+	{
+	__FLOG(_L8("Start - Entry"));
+	TRequestStatus* reportStatus = &aStatus;
+
+	iState = EUsbServiceStarting;
+
+	// Connect to MTP server
+	TInt err = iMTPSession.Connect();
+
+	if (err != KErrNone)
+		{
+		__FLOG_VA((_L8("iMTPSession.Connect()  failed with %d"), err));
+		iState = EUsbServiceIdle;
+		User::RequestComplete(reportStatus, err);
+		return;
+		}
+	// Start MTP USB Still Image class transport.
+	err = iMTPSession.StartTransport(TUid::Uid(KMTPUsbTransportImplementationUid));
+    __FLOG_VA((_L8("StartTransport returns %d"), err));
+	if (err != KErrNone)
+		{
+		iState = EUsbServiceIdle;
+		iMTPSession.Close();
+        }
+    else
+        {
+        iState = EUsbServiceStarted;            
+        }
+        
+    User::RequestComplete(reportStatus, err);
+    __FLOG(_L8("Start - Exit"));
+    }
+
+
+/**
+Called by UsbMan when it wants to stop the USB Still Image Capture class.
+@param aStatus KErrNone on success or a system wide error code
+*/
+void CMTPUsbSicClassController::Stop(TRequestStatus& aStatus)
+    {
+    __FLOG(_L8("Stop - Entry"));
+    TRequestStatus* reportStatus = &aStatus;
+        
+    TInt err = iMTPSession.StopTransport(TUid::Uid(KMTPUsbTransportImplementationUid));
+    __FLOG_VA((_L8("StopTransport returns %d"), err));    
+    if (err != KErrNone)
+        {
+        iState = EUsbServiceStarted;
+        User::RequestComplete(reportStatus, err);
+        return;
+        }
+    iMTPSession.Close();
+
+    User::RequestComplete(reportStatus, KErrNone);
+    __FLOG(_L8("Stop - Exit"));
+    }
+
+
+/**
+Gets information about the descriptor which this class provides. Never called
+by usbMan. 
+@param aDescriptorInfo Descriptor info structure filled in by this function
+*/
+void CMTPUsbSicClassController::GetDescriptorInfo(TUsbDescriptor& /*aDescriptorInfo*/) const
+    {
+    // do nothing.
+    }
+    
+/**
+RunL of CActive. Never called because this class has no
+asynchronous requests.
+*/
+void CMTPUsbSicClassController::RunL()
+    {
+    // do nothing.
+    }
+    
+/**
+DoCancel of CActive. Never called because this class has no
+asynchronous requests.
+*/
+void CMTPUsbSicClassController::DoCancel()
+    {
+    // do nothing.
+    }
+    
+/**
+RunError of CActive. Never called because this class has no
+asynchronous requests.
+*/
+TInt CMTPUsbSicClassController::RunError(TInt /*aError*/)
+{
+// avoid the panic of CActiveScheduler.
+return KErrNone;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_cc/src/cmtpusbsicclassimpcollection.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,38 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+#include <e32base.h>
+#include <e32std.h>
+#include <ecom/ecom.h>
+#include <ecom/implementationproxy.h>
+#include "cmtpusbsicclasscontroller.h"
+
+// Define the private interface UIDs
+const TImplementationProxy UsbCCImplementationTable[] =
+    {
+	IMPLEMENTATION_PROXY_ENTRY(0x102827B3, CMTPUsbSicClassController::NewL)
+    };
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(UsbCCImplementationTable) / sizeof(TImplementationProxy);
+
+    return UsbCCImplementationTable;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_cc/src/mtpusbsiccc.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,39 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <ecom/registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = 0x102827AB;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x101fbf21;
+			implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x102827B3;
+					version_no = 1;
+					display_name = "MTP Transport USB SIC class controller plug-in.";
+					default_data = "";
+					opaque_data = "";
+					}	
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,30 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// USB MTP/SIC device class
+// 
+//
+
+/**
+ @file
+*/
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES 
+#ifndef WINSCW
+mtpusbsicimp.mmp
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/group/mtpusbsicimp.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,57 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mtpusbtransport.dll USB MTP device class MTP transport plug-in.
+// 
+//
+
+/**
+ @file
+*/
+
+#include <comms-infras/commsdebugutility.mmh>
+
+TARGET              mtpusbsicimp.dll
+TARGETTYPE          PLUGIN
+UID                 0x10009D8D 0x102827AC
+VENDORID 			0x70000001
+
+CAPABILITY          CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+USERINCLUDE         ../inc/ 
+USERINCLUDE         ../../common/inc/ 
+USERINCLUDE         ../../usbdatatypes/inc
+USERINCLUDE         ../../../../mtpfws/mtpfw/transports/transportapi/inc
+USERINCLUDE         ../../../../mtpfws/mtpfw/common/inc
+
+SOURCEPATH          ../src/ 
+SOURCE              cmtpusbconnection.cpp
+SOURCE              cmtpusbepbase.cpp
+SOURCE              cmtpusbepbulkin.cpp
+SOURCE              cmtpusbepbulkout.cpp
+SOURCE              cmtpusbepcontrol.cpp
+SOURCE              cmtpusbepinterruptin.cpp
+SOURCE              cmtpusbtransport.cpp
+
+LIBRARY             euser.lib
+LIBRARY             mtpdatatypes.lib 
+LIBRARY             mtptransportapi.lib
+LIBRARY             mtpusbdatatypes.lib
+
+START RESOURCE      mtpusbsicimp.rss    
+TARGET              mtpusbsicimp.rsc
+END
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbconnection.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,448 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPUSBCONNECTION_H
+#define CMTPUSBCONNECTION_H
+
+#include <e32base.h>
+#include <d32usbc.h>
+#include <mtp/mtpdataproviderapitypes.h>
+#include <mtp/tmtptyperequest.h>
+#include <mtp/tmtptypeevent.h>
+#include <mtp/tmtptypenull.h>
+
+#include "mtpusbtransportconstants.h"
+#include "mmtptransportconnection.h"
+#include "mtpdebug.h"
+#include "tmtpusbcontrolrequestsetup.h"
+#include "tmtpusbcontrolrequestcanceldata.h"
+#include "tmtpusbcontrolrequestdevicestatus.h"
+#include "tmtpusbcontrolrequestmodfunction.h"
+#include "tmtpusbcontrolrequestmodheader.h"
+#include "tmtpusbparameterpayloadblock.h"
+
+class CMTPUsbContainer;
+class CMTPUsbEpBase;
+class MMTPConnectionProtocol;
+class MMTPConnectionMgr;
+class MMTPType;
+
+/** 
+Implements the MTP USB device class connection protocol and transport layer 
+interface.
+@internalComponent
+ 
+*/
+class CMTPUsbConnection : 
+    public CActive, 
+    public MMTPTransportConnection 
+    {
+public:
+    
+    static CMTPUsbConnection* NewL(MMTPConnectionMgr& aConnectionMgr);
+    ~CMTPUsbConnection();
+    
+public: // From MMTPTransportConnection
+
+    void BindL(MMTPConnectionProtocol& aProtocol);
+    MMTPConnectionProtocol& BoundProtocolLayer();
+    void CloseConnection();
+    void ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest);
+    void ReceiveDataCancelL(const TMTPTypeRequest& aRequest);   
+    void SendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest);
+    void SendDataCancelL(const TMTPTypeRequest& aRequest);    
+    void SendEventL(const TMTPTypeEvent& aEvent);  
+    void SendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest);  
+    void TransactionCompleteL(const TMTPTypeRequest& aRequest); 
+    void Unbind(MMTPConnectionProtocol& aProtocol);
+    TAny* GetExtendedInterface(TUid aInterfaceUid); 
+    TUint GetImplementationUid();
+     
+public:
+  
+    void ReceiveBulkDataCompleteL(TInt aError, MMTPType& aData);
+    void ReceiveControlRequestDataCompleteL(TInt aError, MMTPType& aData);
+    void ReceiveControlRequestSetupCompleteL(TInt aError, MMTPType& aData);
+    void SendBulkDataCompleteL(TInt aError, const MMTPType& aData);
+    void SendControlRequestDataCompleteL(TInt aError, const MMTPType& aData);
+    void SendInterruptDataCompleteL(TInt aError, const MMTPType& aData);
+    
+    TUint EndpointBitPosition(TUint aId) const;
+    const TUsbcEndpointCaps& EndpointCapsL(TUint aId);
+    TUint EndpointDirection(TUint aId) const;
+    TUint EndpointDirectionAndType(TUint aId) const;
+    TEndpointNumber EndpointNumber(TUint aId) const;
+    TUint EndpointType(TUint aId) const;
+        
+    RDevUsbcClient& Ldd();
+    CMTPUsbContainer& BulkContainer();
+    
+    TMTPTypeRequest& GetCurrentRequest()
+        {
+        return iMTPRequest;
+        }
+
+private: // From CActive
+
+    void DoCancel();
+    TInt RunError(TInt aError);
+    void RunL();
+
+private:
+ 
+    CMTPUsbConnection(MMTPConnectionMgr& aConnectionMgr);
+    void ConstructL();
+    
+    void IssueAlternateDeviceStatusNotifyRequest();
+    
+    void BufferEventDataL(const TMTPTypeEvent& aEvent);
+    void SendEventDataL();
+    void SendUnreportedStatusEventL();
+    
+    void InitiateBulkRequestSequenceL();
+    void InitiateControlRequestSequenceL();
+    
+    void ProcessBulkCommandL(TInt aError);
+    void ProcessBulkDataInL(const TMTPTypeRequest& aRequest, const MMTPType& aData);
+    void ProcessBulkDataOutL(TInt aError);
+    void ProcessControlRequestCancelL(const TMTPUsbControlRequestSetup& aRequest);
+    void ProcessControlRequestDeviceResetL(const TMTPUsbControlRequestSetup& aRequest);
+    void ProcessControlRequestDeviceStatusL(const TMTPUsbControlRequestSetup& aRequest);
+  
+    TBool BulkRequestErrorHandled(TInt aError);
+    TBool BulkRequestTransactionStateValid(TMTPTransactionPhase aExpectedTransactionState);
+    TBool ControlRequestErrorHandled(TInt aError);
+    
+    void ConfigurationDescriptorSetL();
+    void ConfigurationDescriptorClear();
+    
+    TBool ConnectionClosed() const;
+    TBool ConnectionOpen() const;
+    
+    void ControlEndpointStartL();
+    void ControlEndpointStop();
+    
+    void BulkEndpointsStallL();
+    void BulkEndpointsStallClearL();
+
+    void DataEndpointsStartL();
+    void DataEndpointsStop();
+    
+    void EndpointStallL(TMTPUsbEndpointId aId);
+    void EndpointStallClearL(TMTPUsbEndpointId aId);
+    
+    void ResumeConnectionL();
+    void StartConnectionL();
+    void StopConnection();
+    void SuspendConnectionL();
+    
+    void StartUsbL();
+    void StopUsb();
+    
+    TInt32 ConnectionState() const;
+    TInt32 SuspendState() const;
+    
+    void SetBulkTransactionState(TMTPTransactionPhase aState);
+    void SetConnectionState(TInt32 aState);
+    void SetDeviceStatus(TUint16 aCode);
+    void SetInterfaceDescriptorL();
+    void SetSuspendState(TInt32 aState);
+    void SetTransportPacketSizeL();
+
+    TBool IsEpStalled(const TUint& aEpNumber);
+    
+private: // Owned.
+
+    /**
+    The MTP USB device class connection state bit flags.
+    */
+    enum TConnectionState
+        {
+        /**
+        The Connection is closed.
+        */
+        EIdle                   = 0x00000000,
+        
+        /**
+        The Connection is open and in an error state pending a device reset control
+        request from the host.
+        */
+        EStalled                = 0x00000001,
+        
+        /**
+        The Connection is open and inactive.
+        */
+        EOpen                   = 0x00000002,
+        
+        /**
+        The Connection is open and actively processing a bulk data transfer.
+        */
+        EBusy                   = 0x00000004,
+        
+        /**
+        The connection state bit flags mask.
+        */
+        EConnectionStateMask    = 0x0000000F,
+        };
+
+    /**
+    The MTP USB suspend state bit flags.
+    */
+    enum TSuspendState
+        {
+        /**
+        The USB device is not suspended.
+        */
+        ENotSuspended           = 0x00000000,
+        
+        /**
+        The USB device is suspended.
+        */
+        ESuspended              = 0x80000000,
+        
+        /**
+        The USB device is suspended and asynchronous MTP event data is awaiting
+        transmission to the host.
+        */
+        ESuspendedEventsPending = 0xC0000000,
+        
+        /**
+        The suspend state bit flags mask.
+        */
+        ESuspendStateMask       = 0xF0000000,
+        };
+      
+    /**
+    Defines the MTP USB device class endpoint meta data.
+    */
+    struct TEpInfo
+        {        
+        /**
+        The logical endpoint bit position.
+        */
+        TUint           iBitPosition;   
+        
+        /**
+        The endpoint direction flag bits.
+        */
+        TUint           iDirection; 
+        
+        /**
+        The endpoint polling interval.
+        */
+        TUint           iInterval;
+        
+        /**
+        The high speed NAK rate
+        */
+        TUint			iInterval_Hs;    
+        
+        /**
+        The logical endpoint number.
+        */
+        TEndpointNumber iNumber; 
+        
+        /**
+        The endpoint type flag bits.
+        */
+        TUint           iType;         
+        };
+    
+    /**
+    The bulk transfer transaction state.
+    */
+    TMTPTransactionPhase                                iBulkTransactionState;
+    
+    /** 
+    The current USB controller/interface alternate setting state.
+    */
+    TUint                                               iControllerStateCurrent;
+    
+    /** 
+    The previous USB controller/interface alternate setting state.
+    */
+    TUint                                               iControllerStatePrevious;
+    
+    /**
+    The USB device capabilities buffer.
+    */
+    TUsbDeviceCaps                                      iDeviceCaps;
+    
+    /**
+    The current device status.
+    */
+    TUint16                                             iDeviceStatusCode;
+    
+    /**
+    The endpoint capabilities buffer.
+    */
+    TUsbcEndpointCaps                                   iEndpointCaps;
+    
+    /**
+    The USB device endpoints capability sets.
+    */
+    TUsbcEndpointData                                   iEndpointCapSets[KUsbcMaxEndpoints];
+    
+    /** 
+    The USB MTP device class endpoints.
+    */
+    RPointerArray<CMTPUsbEpBase>                        iEndpoints;
+    
+    /** 
+    The USB device.
+    */
+    RDevUsbcClient                                      iLdd;
+    
+    /**
+    The MTP event dataset buffer.
+    */
+    TMTPTypeEvent                                       iMTPEvent;
+    
+    /**
+    Event pending flag.
+    */
+    TBool												iEventPending;
+    
+    /**
+    The active MTP operation request dataset buffer.
+    */
+    TMTPTypeRequest                                     iMTPRequest;
+    
+    /** 
+    The active MTP SessionID.
+    */
+    TUint32                                             iMTPSessionId;
+    
+    /**
+    The remote wakeup enabled flag.
+    */
+    TBool                                               iRemoteWakeup;
+    
+    /**
+    The MTP USB device class state variable.
+    */
+    TInt32                                              iState;
+    
+    /** 
+    The USB MTP device class generic bulk pipe container buffer.
+    */
+    CMTPUsbContainer*                                   iUsbBulkContainer;
+    
+    /**
+    The USB MTP device class variable length Command/Response Block payload 
+    dataset. 
+    */
+    TMTPUsbParameterPayloadBlock                        iUsbBulkParameterBlock;
+    
+    /** 
+    The USB MTP device class event dataset buffer.
+    */
+    CMTPUsbContainer*                                   iUsbEventContainer;
+    
+    /**
+    The USB MTP device class variable length Event Block payload dataset. 
+    */
+    TMTPUsbParameterPayloadBlock                        iUsbEventParameterBlock;
+    
+    /** 
+    MTP USB device class cancel control request dataset buffer.
+    */
+    TMTPUsbControlRequestCancelData                     iUsbControlRequestCancelData;
+    
+    
+    /** 
+    MTP USB device class device status control request dataset buffer.
+    */
+    TMTPUsbControlRequestDeviceStatus                   iUsbControlRequestDeviceStatus;
+    
+    /** 
+    The MTP USB device class control request setup dataset buffer.
+    */
+    TMTPUsbControlRequestSetup                          iUsbControlRequestSetup;
+    
+    /** 
+    The MTP USB device class Microsoft OS Feature Descriptor (MOD) header 
+    section dataset buffer.
+    */
+    TMTPUsbControlRequestMODHeader                      iUsbMODHeader;
+    
+    /** 
+    The MTP USB device class Microsoft OS Feature Descriptor (MOD) function 
+    section dataset buffer.
+    */
+    TMTPUsbControlRequestMODFunction                    iUsbMODFunction;
+    
+    /**
+    The MTP USB device class endpoint meta data table.
+    */
+    static const TEpInfo                                KEndpointMetaData[];
+    const TFixedArray<TEpInfo, EMTPUsbEpNumEndpoints>   iEndpointInfo;
+
+	/**
+	Cached error code in case of a ItoR transaction error.
+	*/
+	TInt												iXferError;
+
+	/**
+	Data sink for consuming data during error recovery from
+	a failed ItoR transaction.
+	*/
+	TMTPTypeNull										iNull;
+
+	/**
+	Buffer for reading discarded data into.
+	*/
+	RBuf8												iNullBuffer;
+	
+	/**
+	A flag to reflect if a Host initiated cancel transaction
+	is triggered.
+	*/
+	TBool 												iIsCancelReceived;
+	
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+private: // Not owned.
+    
+    /** 
+    The MTP connection manager.
+    */
+    MMTPConnectionMgr*                                  iConnectionMgr;
+
+    /** 
+    The MTP connection protocol layer binding.
+    */
+    MMTPConnectionProtocol*                             iProtocolLayer;
+ 
+    /**
+     * indicate if a transaction_cannled needs to be return to PC
+     */
+    TBool                                               isResponseTransactionCancelledNeeded;
+	/**
+	 * indicate if a transaction has been ignored
+	 */
+	TBool												isCommandIgnored;
+
+    };
+    
+#endif // CMTPUSBCONNECTION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepbase.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,226 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPUSBEPBASE_H
+#define CMTPUSBEPBASE_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <d32usbc.h>
+
+#include "mtpdebug.h"
+
+class CMTPUsbConnection;
+
+/**
+Defines the USB MTP device class endpoint data transfer controller base class.
+@internalComponent
+ 
+*/
+class CMTPUsbEpBase : public CActive
+    {
+public:
+  
+    virtual ~CMTPUsbEpBase();
+
+    TEndpointNumber EndpointNumber() const;
+    TUint Id() const;
+    void SetMaxPacketSizeL(TUint aSize);
+    void Stall();
+    void StallClear();
+    TBool Stalled() const;
+    
+    static TInt LinearOrder(const CMTPUsbEpBase& aL, const CMTPUsbEpBase& aR);
+    
+    void ResumeReceiveDataL(MMTPType& aSink);    
+    void CancelReceiveL(TInt aReason);
+    void CancelSendL(TInt aReason);
+    
+protected:
+
+    CMTPUsbEpBase(TUint aId, TPriority aPriority, CMTPUsbConnection& aConnection);
+    
+#ifdef __FLOG_ACTIVE    
+    virtual void ConstructL(const TDesC8& aComponentName);
+#else
+    virtual void ConstructL();
+#endif  
+
+    CMTPUsbConnection& Connection() const;
+    
+    void ReceiveDataL(MMTPType& aSink);
+    virtual void ReceiveDataCompleteL(TInt aError, MMTPType& aSink);
+    
+    void SendDataL(const MMTPType& aSource);
+    virtual void SendDataCompleteL(TInt aError, const MMTPType& aSource);
+    
+protected: // From CActive
+
+   	void DoCancel();
+
+private: // From CActive
+
+    TInt RunError(TInt aError);
+    void RunL();
+    
+private:
+
+    TInt32 DataStreamDirection() const;
+    void ResetReceiveDataStream();
+    void ResetSendDataStream();
+    void ResumeReceiveDataStreamL();
+    void ProcessSendDataStreamL();
+    
+    void SetStreamState(TInt aState);
+    TBool ValidateUSBHeaderL();
+    void InitiateFirstChunkReceiveL();
+    void ProcessFirstReceivedChunkL();
+    void FlushRxDataL();
+    
+protected: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER_MUTABLE;
+    
+private: // Owned
+
+    /**
+    The data stream states.
+    */
+    enum TState
+        {
+        /**
+        Both send and receive data streams are inactive.
+        */
+        EIdle                   = 0x00000000,
+        
+        /**
+        Both send and receive data streams are stalled.
+        */
+        EStalled                = 0x0F000000,
+        
+        /**
+        The receive data stream is active.
+        */
+        EReceivingState         = 0x40000000,
+        EReceiveInitialising    = 0x40000001,
+        EReceiveInProgress      = 0x40000002,
+        EReceiveCompleting      = 0x40000003,
+        EReceiveComplete        = 0x40000004,
+        
+        /**
+        The send data stream is active.
+        */
+        ESendingState           = 0x80000000,
+        ESendInitialising       = 0x80000001,
+        ESendInProgress         = 0x80000002,
+        ESendCompleting         = 0x80000003,
+        ESendComplete           = 0x80000004,
+        
+        EStateDirection         = 0xF0000000
+        }; 
+    
+    /**
+    The active data stream chunk status.
+    */
+    TInt                iChunkStatus;
+
+    /**
+    The internal endpoint identifier.
+    */
+    TUint               iId;
+    
+    /**
+    The residual packet data buffer.
+    */
+    RBuf8               iPacketBuffer;
+    
+    /**
+    The maximum bulk-in endpoint size.
+    */
+    TUint               iPacketSizeMax;
+
+    /** 
+    The receive data stream commit flag.
+    */
+    TBool               iReceiveDataCommit;
+    
+    /**
+    The receive data stream chunk data buffer.
+    */
+    TPtr8               iReceiveChunkData;
+    
+    /**
+    The receive data stream data pointer.
+    */
+    TPtr8               iReceiveData;
+
+    /**
+    The send data stream chunk data.
+    */
+    TPtrC8              iSendChunkData;
+    
+    /**
+    The send data stream data pointer.
+    */
+    TPtrC8              iSendData;
+    
+    /**
+    The data stream state variable.
+    */
+    TInt32              iState;   
+    
+    /**
+    A flag to tell if the receive stream is the first chunk.
+    */			
+    TBool 				iIsFirstChunk;
+    
+    /**
+    The amount of data received.
+    */
+    TUint64 			iDataCounter;
+    
+    /**
+    The amount of data expected.
+    */    
+    TUint64 			iDataLength;
+    
+    
+private: // Not owned
+
+    /**
+    The MTP USB device class transport connection which controls the endpoint.
+    */
+    CMTPUsbConnection&  iConnection;
+
+    /**
+    The receive data stream sink buffer
+    */
+    MMTPType*           iReceiveDataSink;
+
+    /**
+    The send data stream source buffer
+    */
+    const MMTPType*     iSendDataSource;
+    };
+    
+#endif // CMTPUSBEPBASE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepbulkin.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,52 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPUSBEPBULKIN_H
+#define CMTPUSBEPBULKIN_H
+
+#include "cmtpusbepbase.h"
+
+class CMTPUsbConnection;
+class MMTPType;
+
+/**
+Implements the USB MTP device class bulk-in endpoint data transfer controller.
+@internalComponent
+ 
+*/
+class CMTPUsbEpBulkIn: public CMTPUsbEpBase
+    {
+public:
+
+    static CMTPUsbEpBulkIn* NewL(TUint aId, CMTPUsbConnection& aConnection);
+    ~CMTPUsbEpBulkIn();
+
+    void SendBulkDataL(const MMTPType& aData);
+
+private: // From CMTPUsbEpBase
+
+    void SendDataCompleteL(TInt aError, const MMTPType& aSource);
+    
+private:
+
+    CMTPUsbEpBulkIn(TUint aId, CMTPUsbConnection& aConnection);
+    };
+    
+#endif // CMTPUSBEPBULKIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepbulkout.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,52 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPUSBEPBULKOUT_H
+#define CMTPUSBEPBULKOUT_H
+
+#include "cmtpusbepbase.h"
+
+class CMTPUsbConnection;
+class MMTPType;
+
+/**
+Implements the USB MTP device class bulk-out endpoint data transfer controller.
+@internalComponent
+ 
+*/
+class CMTPUsbEpBulkOut: public CMTPUsbEpBase
+    {
+public:
+
+    static CMTPUsbEpBulkOut* NewL(TUint aId, CMTPUsbConnection& aConnection);
+    ~CMTPUsbEpBulkOut();
+    
+    void ReceiveBulkDataL(MMTPType& aData);
+
+private: // From CMTPUsbEpBase
+
+    void ReceiveDataCompleteL(TInt aError, MMTPType& aSink);
+    
+private:
+
+    CMTPUsbEpBulkOut(TUint aId, CMTPUsbConnection& aConnection);
+    };
+    
+#endif // CMTPUSBEPBULKOUT_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepcontrol.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,81 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPUSBEPCONTROL_H
+#define CMTPUSBEPCONTROL_H
+
+#include "cmtpusbepbase.h"
+
+class CMTPUsbConnection;
+class MMTPType;
+
+/**
+Implements the USB MTP device class control endpoint data transfer controller.
+@internalComponent
+ 
+*/
+class CMTPUsbEpControl: public CMTPUsbEpBase
+    {         
+public:
+
+    static CMTPUsbEpControl* NewL(TUint aId, CMTPUsbConnection& aConnection);
+    ~CMTPUsbEpControl();
+    
+    void ReceiveControlRequestDataL(MMTPType& aData);
+    void ReceiveControlRequestSetupL(MMTPType& aData);
+    void SendControlRequestDataL(const MMTPType& aData);
+    void SendControlRequestStatus();
+
+private: // From CMTPUsbEpBase
+
+    void ReceiveDataCompleteL(TInt aError, MMTPType& aSink);
+    void SendDataCompleteL(TInt aError, const MMTPType& aSource);
+    
+private: // From CActive
+	void DoCancel();
+    
+private:
+
+    CMTPUsbEpControl(TUint aId, CMTPUsbConnection& aConnection);
+    
+    void SetState(TUint aState);
+     
+private: // Owned
+
+    /**
+    The control endpoint data send/receive states.
+    */
+    enum TMTPUsbEpControlState
+        {
+        EIdle,
+        EControlRequestSetupPending,
+        EControlRequestSetupComplete,
+        EControlRequestDataReceive,
+        EControlRequestDataSend,
+        EControlRequestStatusSend
+        };
+        
+    /**
+    The control endpoint data send/receive state variable.
+    */
+    TUint iState;
+    
+    };
+#endif // CMTPUSBEPCONTROL_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepinterruptin.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,52 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef CMTPUSBEPINTERRUPTIN_H
+#define CMTPUSBEPINTERRUPTIN_H
+
+#include "cmtpusbepbase.h"
+
+class CMTPUsbConnection;
+class MMTPType;
+
+/**
+Implements the USB MTP device class interrupt endpoint data transfer controller.
+@internalComponent
+ 
+*/
+class CMTPUsbEpInterruptIn: public CMTPUsbEpBase
+    {
+public:
+
+    static CMTPUsbEpInterruptIn* NewL(TUint aId, CMTPUsbConnection& aConnection);
+    ~CMTPUsbEpInterruptIn();
+
+    void SendInterruptDataL(const MMTPType& aData);
+
+private: // From CMTPUsbEpBase
+
+    void SendDataCompleteL(TInt aError, const MMTPType& aSource);
+
+private:
+
+    CMTPUsbEpInterruptIn(TUint aId, CMTPUsbConnection& aConnection);
+
+    };
+#endif // CMTPUSBEPINTERRUPTIN_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepwatcher.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,76 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+#ifndef CMTPUSBENDPOINTWATCHER_H
+#define CMTPUSBENDPOINTWATCHER_H
+
+#include "mtpdebug.h"
+
+class CMTPUsbConnection;
+
+/**
+Implements the USB MTP device class endpoint stall status observer.
+@internalComponent
+ 
+*/
+class CMTPUsbEpWatcher: public CActive
+    {
+public:
+
+    static CMTPUsbEpWatcher* NewL(CMTPUsbConnection& aConnection);
+    ~CMTPUsbEpWatcher();
+    
+    void Start();
+    void Stop();
+    
+private: // From CActive
+
+    void DoCancel();
+    TInt RunError(TInt aError);
+    void RunL();
+    
+private:
+
+    CMTPUsbEpWatcher(CMTPUsbConnection& aConnection);
+    void ConstructL();
+    
+    void RequestCancel();
+    void RequestIssue();
+      
+private: // Owned
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER;
+
+    /**
+    The endpoint stall status flags.
+    */
+    TUint               iEndpointStatus;
+      
+private: // Not owned
+
+    /**
+    The MTP USB device class connection.
+    */
+    CMTPUsbConnection&  iConnection;
+    };
+    
+#endif // CMTPUSBENDPOINTWATCHER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbtransport.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,69 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+#ifndef CMTPUSBTRANSPORT_H
+#define CMTPUSBTRANSPORT_H
+
+#include "cmtptransportplugin.h"
+#include "mtpdebug.h"
+
+class CMTPUsbConnection;
+
+/**
+Implements the USB MTP device class transport plug-in.
+@internalComponent
+ 
+*/
+class CMTPUsbTransport: public CMTPTransportPlugin
+    {
+    
+public:
+
+    static TAny* NewL(TAny* aParameter);
+    ~CMTPUsbTransport();
+
+    const CMTPUsbConnection& MTPUsbConnection();
+
+    
+public: // From CMTPTransportPlugin
+
+    void ModeChanged(TMTPOperationalMode aMode);
+    void StartL(MMTPConnectionMgr& aConnectionMgr);
+    void Stop(MMTPConnectionMgr& aConnectionMgr);
+    TAny* GetExtendedInterface(TUid aInterfaceUid);
+    
+private:
+
+    CMTPUsbTransport();
+    void ConstructL();
+      
+private: // Owned
+
+    /**
+    The USB MTP device class connection
+    */
+    CMTPUsbConnection* iConnection;
+
+    /**
+    FLOGGER debug trace member variable.
+    */
+    __FLOG_DECLARATION_MEMBER;
+    };
+    
+#endif // CMTPUSBTRANSPORT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/inc/mtpusbtransportconstants.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,127 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef MTPUSBTRANSPORTCONSTANTS_H
+#define MTPUSBTRANSPORTCONSTANTS_H
+
+#include <d32usbc.h>
+#include <e32def.h>
+
+/**
+The USB MTP device class alternate interface number.
+*/
+const TUint KMTPUsbAlternateInterface(0);
+
+/**
+* Endpoint address index of Endpoint descriptor
+*/
+const TUint KEpAddressOffsetInEpDesc(2);
+
+/**
+The USB MTP device class USB client controller number.
+*/
+const TUint KDefaultUsbClientController(0);
+
+
+/**
+The Full Speed USB MaxPacketsize for different Endpoints.
+*/
+const TUint KMaxPacketTypeControlFS(16);
+const TUint KMaxPacketTypeBulkFS(64);
+
+/**
+The High Speed USB MaxPacketSize for different Endpoints.
+*/
+const TUint KMaxPacketTypeControlHS(64);
+const TUint KMaxPacketTypeBulkHS(512);
+
+/*
+ * USB MaxPacketSize for interrupt Endpoint.
+ */
+const TUint KMaxPacketTypeInterrupt(64);
+
+/**
+The minimum number of endpoints required to support the USM MTP device class, 
+as specified in the "Universal Serial Bus Still Image Capture Device 
+Definition" specification. This value excludes the control, endpoint.
+*/
+const TUint KMTPUsbRequiredNumEndpoints(3);
+
+/**
+USB MTP device class logical endpoint bit position bits.
+*/
+const TUint KMTPUsbControlEpBit(KUsbcEndpoint0Bit);
+const TUint KMTPUsbBulkInEpBit(KUsbcEndpoint1Bit);
+const TUint KMTPUsbBulkOutEpBit(KUsbcEndpoint2Bit);
+const TUint KMTPUsbInterruptEpBit(KUsbcEndpoint3Bit);
+
+/**
+USB MTP device class endpoint direction flag bits.
+*/
+const TUint KMTPUsbControlEpDir(KUsbEpDirBidirect);
+const TUint KMTPUsbBulkInEpDir(KUsbEpDirIn);
+const TUint KMTPUsbBulkOutEpDir(KUsbEpDirOut);
+const TUint KMTPUsbInterruptEpDir(KUsbEpDirIn);
+
+/**
+USB MTP device class logical endpoint numbers.
+*/
+const TEndpointNumber KMTPUsbControlEp(EEndpoint0);
+const TEndpointNumber KMTPUsbBulkInEp(EEndpoint1);
+const TEndpointNumber KMTPUsbBulkOutEp(EEndpoint2);
+const TEndpointNumber KMTPUsbInterruptEp(EEndpoint3);
+
+/**
+USB MTP device class logical endpoint polling intervals (Ms).
+*/
+const TUint KMTPUsbControlEpPoll(0);
+const TUint KMTPUsbBulkInEpPoll(0);
+const TUint KMTPUsbBulkOutEpPoll(0);
+const TUint KMTPUsbInterruptEpPoll(5);
+
+/**
+USB MTP high speed NAK rates.
+*/
+const TUint KMTPUsbControlEpNAKRate(1);
+const TUint KMTPUsbBulkInEpNAKRate(1);
+const TUint KMTPUsbBulkOutEpNAKRate(1);
+const TUint KMTPUsbInterruptEpNAKRate(1);
+
+/**
+USB MTP device class endpoint type flag bits.
+*/
+const TUint KMTPUsbControlEpType(KUsbEpTypeControl);
+const TUint KMTPUsbBulkInEpType(KUsbEpTypeBulk);
+const TUint KMTPUsbBulkOutEpType(KUsbEpTypeBulk);
+const TUint KMTPUsbInterruptEpType(KUsbEpTypeInterrupt);
+
+/**
+USM MTP device class internal endpoint identifiers.
+*/
+enum TMTPUsbEndpointId
+    {
+    EMTPUsbEpControl,
+    EMTPUsbEpBulkIn,
+    EMTPUsbEpBulkOut,
+    EMTPUsbEpInterrupt,
+    EMTPUsbEpNumEndpoints,
+    };
+
+#endif // MTPUSBTRANSPORTCONSTANTS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbconnection.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1921 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+#include <mtp/mtpprotocolconstants.h>
+#include <mtp/tmtptyperesponse.h>
+
+#include "cmtpusbepbulkin.h"
+#include "cmtpusbepbulkout.h"
+#include "cmtpusbconnection.h"
+#include "cmtpusbcontainer.h"
+#include "cmtpusbepcontrol.h"
+#include "cmtpusbepinterruptin.h"
+#include "mmtpconnectionmgr.h"
+#include "mmtpconnectionprotocol.h"
+#include "mtpbuildoptions.hrh"
+#include "mtpdebug.h"
+#include "mtpusbpanic.h"
+#include "mtpusbprotocolconstants.h"
+
+#ifdef _DEBUG
+#include <e32debug.h>
+#endif
+
+#define UNUSED_VAR(a) (a)=(a)
+
+
+// File type constants.
+const TInt KMTPNullChunkSize(0x00020000); // 100KB
+const TUint KUSBHeaderSize = 12;
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"UsbConnection");)
+    
+// Endpoint meta data.
+const CMTPUsbConnection::TEpInfo CMTPUsbConnection::KEndpointMetaData[EMTPUsbEpNumEndpoints] = 
+    {
+        {KMTPUsbControlEpBit,   KMTPUsbControlEpDir,    KMTPUsbControlEpPoll,   KMTPUsbControlEpNAKRate,	KMTPUsbControlEp,   KMTPUsbControlEpType},  // EMTPUsbEpControl
+        {KMTPUsbBulkInEpBit,    KMTPUsbBulkInEpDir,     KMTPUsbBulkInEpPoll,    KMTPUsbBulkInEpNAKRate,		KMTPUsbBulkInEp,    KMTPUsbBulkInEpType},   // EMTPUsbEpBulkIn
+        {KMTPUsbBulkOutEpBit,   KMTPUsbBulkOutEpDir,    KMTPUsbBulkOutEpPoll,   KMTPUsbBulkOutEpNAKRate,	KMTPUsbBulkOutEp,   KMTPUsbBulkOutEpType},  // EMTPUsbEpBulkOut
+        {KMTPUsbInterruptEpBit, KMTPUsbInterruptEpDir,  KMTPUsbInterruptEpPoll, KMTPUsbInterruptEpNAKRate,	KMTPUsbInterruptEp, KMTPUsbInterruptEpType} // EMTPUsbEpInterrupt
+    }; 
+    
+/**
+USB MTP USB device class connection factory method.
+@param aConnectionMgr The MTP connection manager interface.
+@return A pointer to an MTP USB device class connection. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+CMTPUsbConnection* CMTPUsbConnection::NewL(MMTPConnectionMgr& aConnectionMgr)
+    {
+    CMTPUsbConnection* self = new (ELeave) CMTPUsbConnection(aConnectionMgr);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+Destructor.
+*/
+CMTPUsbConnection::~CMTPUsbConnection()
+    {
+    __FLOG(_L8("~CMTPUsbConnection - Entry"));
+
+    // Terminate all endpoint data transfer activity.
+    StopConnection();
+        
+    // Close the device class endpoints and generic container buffers.
+    iEndpoints.ResetAndDestroy();
+    delete iUsbBulkContainer;
+    delete iUsbEventContainer;
+    
+    // Stop the USB device.
+    StopUsb();
+    
+    iNullBuffer.Close();
+    if (iProtocolLayer)
+	    {    	
+	    iProtocolLayer->Unbind(*this);
+	    }
+
+    __FLOG(_L8("~CMTPUsbConnection - Exit"));
+    __FLOG_CLOSE;
+    }
+
+void CMTPUsbConnection::BindL(MMTPConnectionProtocol& aProtocol)
+    {
+    __FLOG(_L8("BindL - Entry"));
+    __ASSERT_DEBUG(!iProtocolLayer, Panic(EMTPUsbBadState));
+    iProtocolLayer = &aProtocol;
+    __FLOG(_L8("BindL - Exit"));
+    }
+    
+MMTPConnectionProtocol& CMTPUsbConnection::BoundProtocolLayer()
+    {
+    __FLOG(_L8("BoundProtocolLayer - Entry"));
+    __ASSERT_DEBUG(iProtocolLayer, Panic(EMTPUsbBadState));
+    __FLOG(_L8("BoundProtocolLayer - Exit"));
+    return *iProtocolLayer;
+    }
+    
+void CMTPUsbConnection::CloseConnection()
+    {
+    __FLOG(_L8("CloseConnection - Entry"));
+    /* 
+    Terminate all endpoint data transfer activity, stall all but the control 
+    endpoints, and wait for the host to issue a Device Reset Request.
+    */
+    StopConnection();
+    TRAPD(err, BulkEndpointsStallL());
+    UNUSED_VAR(err);
+    __FLOG(_L8("CloseConnection - Exit"));
+    }
+    
+void CMTPUsbConnection::ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& /*aRequest*/)
+    {
+    __FLOG(_L8("ReceiveDataL - Entry"));
+    
+    // Update the transaction state.
+    SetBulkTransactionState(EDataIToRPhase);
+    
+    // Setup the bulk container and initiate the bulk data receive sequence.
+    iUsbBulkContainer->SetPayloadL(&aData);
+    
+    //Expected containerType pre-setup here in case we don't receive IToR dataphase at all so 
+    //Cancel operation can trigger right call inside ReceiveBulkDataCompleteL(). 
+    iUsbBulkContainer->SetUint16L(CMTPUsbContainer::EContainerType, EMTPUsbContainerTypeDataBlock);
+    
+    static_cast<CMTPUsbEpBulkOut*>(iEndpoints[EMTPUsbEpBulkOut])->ReceiveBulkDataL(*iUsbBulkContainer);
+    
+    __FLOG(_L8("ReceiveDataL - Exit"));       
+    }
+
+void CMTPUsbConnection::ReceiveDataCancelL(const TMTPTypeRequest& /*aRequest*/)
+    {
+    __FLOG(_L8("ReceiveDataCancelL - Entry"));
+    
+    // Store the device status code.
+    TUint16 deviceStatus = iDeviceStatusCode;
+    
+    SetDeviceStatus(EMTPUsbDeviceStatusTransactionCancelled);
+   	static_cast<CMTPUsbEpBulkOut*>(iEndpoints[EMTPUsbEpBulkOut])->CancelReceiveL(KErrCancel);
+   	
+   	// Restore it.
+   	SetDeviceStatus(deviceStatus);
+    __FLOG(_L8("ReceiveDataCancelL - Exit"));
+    }
+
+void CMTPUsbConnection::SendDataL(const MMTPType& aData, const TMTPTypeRequest& aRequest)
+    {
+    __FLOG(_L8("SendDataL - Entry"));  
+    ProcessBulkDataInL(aRequest, aData);
+    __FLOG(_L8("SendDataL - Exit"));  
+    }
+
+void CMTPUsbConnection::SendDataCancelL(const TMTPTypeRequest& /*aRequest*/)
+    {
+    __FLOG(_L8("SendDataCancelL - Entry"));
+    // Store the device status code.
+    TUint16 deviceStatus = iDeviceStatusCode;
+    
+    SetDeviceStatus(EMTPUsbDeviceStatusTransactionCancelled);
+ 	static_cast<CMTPUsbEpBulkIn*>(iEndpoints[EMTPUsbEpBulkIn])->CancelSendL(KErrCancel);
+ 	// Restore it.
+   	SetDeviceStatus(deviceStatus);
+    __FLOG(_L8("SendDataCancelL - Exit"));
+    }
+        
+void CMTPUsbConnection::SendEventL(const TMTPTypeEvent& aEvent)
+    {    
+    __FLOG(_L8("SendEventL - Entry"));
+    
+    // Reset the event.
+    iMTPEvent.Reset(); 
+    MMTPType::CopyL(aEvent, iMTPEvent);
+    
+    switch (ConnectionState())
+        {
+    case EIdle:
+    case EStalled:
+        // Drop the event.    
+        __FLOG(_L8("Dropping the event")); 
+        BoundProtocolLayer().SendEventCompleteL(KErrNone, aEvent);
+        break;
+        
+    case EOpen:
+    case EBusy:
+        // Process the event.    
+        switch (SuspendState())
+            {
+        case ENotSuspended:
+            // Only send event if there are no pending events
+            if (!iEventPending)
+            	{
+            	// Send the event data.
+	            __FLOG(_L8("Sending the event"));
+    	        BufferEventDataL(aEvent);
+        	    SendEventDataL(); 	
+            	}
+             break;
+                
+        case ESuspended:
+            /* 
+            If remote wakeup is enabled then signal remote wakeup and buffer 
+            the event. The event will be sent when bus signalling is resumed. 
+            Otherwise the event is dropped, and a PTP UnreportedStatus event 
+            issued when the host resumes the connection.
+            */
+            if (iLdd.SignalRemoteWakeup() == KErrNone)
+                {
+                // Remote wakeup is enabled, buffer the event data.
+                __FLOG(_L8("Buffer event data and signal remote wakeup"));
+                BufferEventDataL(aEvent);
+                }
+            else
+                {
+                // Remote wakeup is not enabled, drop the event.    
+                __FLOG(_L8("Dropping the event")); 
+                BoundProtocolLayer().SendEventCompleteL(KErrNone, aEvent);
+                }
+            
+            /*
+            Update state to trigger the correct processing when the USB connection is resumed.
+            */
+            SetSuspendState(ESuspendedEventsPending);
+            break;
+                
+        case ESuspendedEventsPending:
+            // Drop the event.    
+            __FLOG(_L8("Dropping the event")); 
+            BoundProtocolLayer().SendEventCompleteL(KErrNone, aEvent);
+            break; 
+              
+        default:
+            __FLOG(_L8("Invalid suspend state"));
+            Panic(EMTPUsbBadState);
+            break;
+            }
+        break;
+                
+    default:
+        __FLOG(_L8("Invalid connection state"));
+        Panic(EMTPUsbBadState);
+        break;
+        }
+    
+    __FLOG(_L8("SendEventL - Exit"));
+    }
+    
+void CMTPUsbConnection::SendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest)
+    {
+    __FLOG(_L8("SendResponseL - Entry"));
+    __FLOG_VA((_L8("DeviceState: 0x%x TransactionState: 0x%x Connection: 0x%x"), iDeviceStatusCode, iBulkTransactionState, ConnectionState()));
+    
+    // Update the transaction state.
+	SetBulkTransactionState(EResponsePhase);
+    if (SuspendState() != ESuspended && !iIsCancelReceived)
+    	{  	      
+   		TUint16 opCode(aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode));
+   		TUint16 rspCode(aResponse.Uint16(TMTPTypeResponse::EResponseCode));
+   		__FLOG_VA((_L8("ResponseCode = 0x%04X, Operation Code = 0x%04X"), rspCode, opCode));
+    
+   		if ((opCode == EMTPOpCodeOpenSession) && (rspCode == EMTPRespCodeOK))
+        	{        
+   	    	// An session has been opened. Record the active SessionID.
+       		iMTPSessionId = aRequest.Uint32(TMTPTypeRequest::ERequestParameter1);
+       		__FLOG_VA((_L8("Processing OpenSession response, SessionID = %d"), iMTPSessionId));
+       		}
+   		else if (((opCode == EMTPOpCodeCloseSession) || (opCode == EMTPOpCodeResetDevice))&& (rspCode == EMTPRespCodeOK))
+        	{
+   	    	// An session has been closed. Clear the active SessionID.        
+       		__FLOG_VA((_L8("Processing CloseSession or ResetDevice response, SessionID = %d"), iMTPSessionId));
+       		iMTPSessionId = KMTPSessionNone;
+       		}
+
+   		/* 
+   		Setup the parameter block payload dataset. Note that since this is a 
+   		variable length dataset, it must first be reset.
+   		*/
+   		iUsbBulkParameterBlock.Reset();
+        TBool isNullParamValid = EFalse;
+        TUint numberOfNullParam = 0;    
+        /*
+        A special case: for GetNumObjects the first response parameter can be null, which means 0 objects.
+        */
+        if(opCode == EMTPOpCodeGetNumObjects)
+            {
+            isNullParamValid = ETrue;
+            numberOfNullParam = 1;
+            }
+        iUsbBulkParameterBlock.CopyIn(aResponse, TMTPTypeResponse::EResponseParameter1, TMTPTypeResponse::EResponseParameter5, isNullParamValid, numberOfNullParam);
+
+   		// Setup the bulk container.
+   		iUsbBulkContainer->SetPayloadL(const_cast<TMTPUsbParameterPayloadBlock*>(&iUsbBulkParameterBlock));
+   		iUsbBulkContainer->SetUint32L(CMTPUsbContainer::EContainerLength, static_cast<TUint32>(iUsbBulkContainer->Size()));
+   		iUsbBulkContainer->SetUint16L(CMTPUsbContainer::EContainerType, EMTPUsbContainerTypeResponseBlock);
+   		iUsbBulkContainer->SetUint16L(CMTPUsbContainer::ECode, rspCode);
+   		iUsbBulkContainer->SetUint32L(CMTPUsbContainer::ETransactionID, aRequest.Uint32(TMTPTypeRequest::ERequestTransactionID));
+
+    	// Initiate the bulk data send sequence.
+   		__FLOG_VA((_L8("Sending response 0x%04X (%d bytes)"), iUsbBulkContainer->Uint16L(CMTPUsbContainer::ECode), iUsbBulkContainer->Uint32L(CMTPUsbContainer::EContainerLength)));
+   		static_cast<CMTPUsbEpBulkIn*>(iEndpoints[EMTPUsbEpBulkIn])->SendBulkDataL(*iUsbBulkContainer);
+    	}
+    else
+    	{
+    	BoundProtocolLayer().SendResponseCompleteL(KErrNone, aResponse, aRequest);
+    	}
+    
+    __FLOG(_L8("SendResponseL - Exit"));
+    } 
+    
+void CMTPUsbConnection::TransactionCompleteL(const TMTPTypeRequest& /*aRequest*/)
+    {
+    __FLOG(_L8("TransactionCompleteL - Entry"));
+   
+   	__FLOG_VA((_L8("DeviceState: 0x%x TransactionState: 0x%x"), iDeviceStatusCode, iBulkTransactionState));
+    
+    if (iBulkTransactionState != ERequestPhase)
+    	{
+	    // Update the transaction state.
+    	SetBulkTransactionState(EIdlePhase);
+    	
+   		// Update the device status
+   		SetDeviceStatus(EMTPUsbDeviceStatusOK); 
+   		
+   		// Clear the cancel flag.
+   		iIsCancelReceived = EFalse; 
+   		
+   		// Initiate the next request phase bulk data receive sequence.
+   		InitiateBulkRequestSequenceL();
+    	}
+    
+    __FLOG(_L8("TransactionCompleteL - Exit"));
+    } 
+
+void CMTPUsbConnection::Unbind(MMTPConnectionProtocol& /*aProtocol*/)
+    {
+    __FLOG(_L8("Unbind - Entry"));
+    __ASSERT_DEBUG(iProtocolLayer, Panic(EMTPUsbBadState));
+    iProtocolLayer = NULL;
+    __FLOG(_L8("Unbind - Exit"));
+    } 
+    
+TAny* CMTPUsbConnection::GetExtendedInterface(TUid /*aInterfaceUid*/)
+    {
+    return NULL;    
+    }
+
+TUint CMTPUsbConnection::GetImplementationUid()
+    {
+    return KMTPUsbTransportImplementationUid;
+    }
+
+void CMTPUsbConnection::ReceiveBulkDataCompleteL(TInt aError, MMTPType& /*aData*/)
+    {
+    __FLOG(_L8("ReceiveBulkDataCompleteL - Entry"));  
+    if (!BulkRequestErrorHandled(aError))
+        { 
+        TUint type(iUsbBulkContainer->Uint16L(CMTPUsbContainer::EContainerType));        
+	    __FLOG_VA((_L8("Received container type 0x%04X"), type));
+	    
+	    // The proper behaviour at this point is to stall the end points
+	    // but alas Microsoft does not honor this.
+	    // The solution is to store the error code, consume all the data
+	    // sent and then forward the error code to the upper layers
+	    // which will then go through all the phases
+	    
+	    // Only go here if...
+       	if (aError != KErrNone // there is an error
+       		&& type == EMTPUsbContainerTypeDataBlock // it is a data transfer
+       		&& iDeviceStatusCode != EMTPUsbDeviceStatusTransactionCancelled // we haven't been cancelled by the initiator
+            )
+       		{
+       		__FLOG_VA((_L8("ReceiveBulkDataCompleteL - error: %d"), aError));
+       		iXferError = aError;
+       		
+       		// Update the transaction state.
+    		SetBulkTransactionState(EDataIToRPhase);
+    
+		    // Setup the bulk container and initiate the bulk data receive sequence.
+		    iNullBuffer.Close();
+		    iNullBuffer.CreateL(KMTPNullChunkSize);
+		    iNullBuffer.SetLength(KMTPNullChunkSize);
+		    iNull.SetBuffer(iNullBuffer);
+    		iUsbBulkContainer->SetPayloadL(&iNull);
+    		static_cast<CMTPUsbEpBulkOut*>(iEndpoints[EMTPUsbEpBulkOut])->ResumeReceiveDataL(*iUsbBulkContainer);
+       		}            
+	    else
+	    	{
+	    	if (iXferError != KErrNone)
+	    		{
+	    		aError = iXferError;
+	    		iXferError = KErrNone;
+	    		iNullBuffer.Close();
+	    		}
+	    	
+   	        switch (type)
+	            {
+    	    case EMTPUsbContainerTypeCommandBlock:
+        	    ProcessBulkCommandL(aError);
+           		break;
+            
+        	case EMTPUsbContainerTypeDataBlock:
+            	ProcessBulkDataOutL(aError);
+            	break;
+            
+        	case EMTPUsbContainerTypeResponseBlock:
+        	case EMTPUsbContainerTypeEventBlock:
+        	default:
+            	// Invalid container received, shutdown the bulk data pipe.
+            	__FLOG_VA((_L8("Invalid container type = 0x%04X"), type));
+            	CloseConnection();
+            	}
+	        // Reset the bulk container.
+			/* A special case for handling MTP framework's synchronous error handling during the request phase. 
+				( ie at the beginning of this function, we are in the request phase, the request is sent to the 
+				mtp f/w, which may send a synchronous error response, which will be populated into the usb bulk 
+				container and sent out by the bulk In AO. When this function is completing, the response phase 
+				has already been reached, and the container is in use by the bulk In AO, so the payload is not 
+				reset)*/
+    	    if((iBulkTransactionState != EResponsePhase)&&(!isCommandIgnored))
+	        	{
+				iUsbBulkContainer->SetPayloadL(NULL);
+				}    	    
+			// clear the flag
+			isCommandIgnored = false;
+	    	}         
+        }
+        
+    __FLOG(_L8("ReceiveBulkDataCompleteL - Exit"));
+    }
+    
+void CMTPUsbConnection::ReceiveControlRequestDataCompleteL(TInt aError, MMTPType& /*aData*/)
+    {
+    __FLOG(_L8("ReceiveControlRequestDataCompleteL - Entry"));
+    if (!ControlRequestErrorHandled(aError))
+        {
+        // Complete the control request sequence.
+        static_cast<CMTPUsbEpControl*>(iEndpoints[EMTPUsbEpControl])->SendControlRequestStatus();
+          
+        if (iUsbControlRequestSetup.Uint8(TMTPUsbControlRequestSetup::EbRequest) == EMTPUsbControlRequestCancel)
+            {
+            // Cancel data received.
+            __FLOG(_L8("Cancel request data received."));
+    
+            // Setup the event dataset.
+            __FLOG_VA((_L8("Cancellation Code = 0x%04X"), iUsbControlRequestCancelData.Uint16(TMTPUsbControlRequestCancelData::ECancellationCode)));
+            __FLOG_VA((_L8("Transaction ID = 0x%08X"), iUsbControlRequestCancelData.Uint32(TMTPUsbControlRequestCancelData::ETransactionID)));
+  
+			#ifdef _DEBUG            
+            // print log about the cacel event
+            RDebug::Print(_L("cancel event received!!!!!!!!!!!!!!!!!Transaction phase is %d ----------------\n"), BoundProtocolLayer().TransactionPhaseL(iMTPSessionId));
+            RDebug::Print(_L("The Transaction ID want to canceled is %d -------------"), iUsbControlRequestCancelData.Uint32(TMTPUsbControlRequestCancelData::ETransactionID));
+            RDebug::Print(_L("Current Transaction ID is %d ----------------"),iMTPRequest.Uint32(TMTPTypeRequest::ERequestTransactionID));
+			#endif
+            
+            isResponseTransactionCancelledNeeded = true;
+            if(  BoundProtocolLayer().TransactionPhaseL(iMTPSessionId) > EIdlePhase   ) 
+            	{
+            	
+               	  
+
+	            iMTPEvent.Reset();
+	            iMTPEvent.SetUint16(TMTPTypeEvent::EEventCode, iUsbControlRequestCancelData.Uint16(TMTPUsbControlRequestCancelData::ECancellationCode));
+	            iMTPEvent.SetUint32(TMTPTypeEvent::EEventSessionID, iMTPSessionId);
+	            
+	            // replace the transaction id in the event with the current transaction id
+	            iMTPEvent.SetUint32(TMTPTypeEvent::EEventTransactionID, iMTPRequest.Uint32(TMTPTypeRequest::ERequestTransactionID));
+	            
+	            // Set the cancel flag.
+	            iIsCancelReceived = ETrue;
+	            
+	            // Update the device status.
+	       		SetDeviceStatus(EMTPUsbDeviceStatusBusy);   
+	       		         
+	            // Notify the protocol layer.
+	            if (ConnectionOpen())
+	                {
+	                BoundProtocolLayer().ReceivedEventL(iMTPEvent);
+	                }
+            	}
+            else
+            	{
+
+				#ifdef _DEBUG 
+            	RDebug::Print(_L("cancel evnet received at idle state, stop data EPs, flush rx data, restart data eps,statusOK\n"));
+				#endif
+
+            	// stop data endpoint
+            	DataEndpointsStop();
+      
+            	//flush rx data
+            	TInt  nbytes = 0;
+            	TInt err = iLdd.QueryReceiveBuffer(EndpointNumber(EMTPUsbEpBulkOut), nbytes);
+				#ifdef _DEBUG
+            	RDebug::Print(_L("QueryReceiveBuffer()-----err is %d , nbytes is %d"), err, nbytes);
+				#endif	  
+
+            	// has data, read it
+            	if( (err == KErrNone) && (nbytes > 0) )
+            		{
+            		// create the read buff
+            		RBuf8 readBuf;
+            		readBuf.CreateL(nbytes);
+            		// synchronously read the data
+            		TRequestStatus status;
+            		iLdd.ReadOneOrMore(status, EndpointNumber(EMTPUsbEpBulkOut), readBuf);
+            		User::WaitForRequest(status);
+            		if (KErrNone == status.Int())
+            			{
+	      		 		#ifdef _DEBUG
+            			RDebug::Print(_L("%d bytes is flushed"), nbytes);
+	      		  		#endif
+            			}
+            		readBuf.Close(); 
+            		}
+            	// initiate bulk request sequence.
+            	InitiateBulkRequestSequenceL();
+                       
+            	SetDeviceStatus(EMTPUsbDeviceStatusOK);                   
+            	}
+            }
+
+        // Initiate the next control request sequence.     
+        InitiateControlRequestSequenceL();
+        }
+    __FLOG(_L8("ReceiveControlRequestDataCompleteL - Exit"));
+    }
+   
+void CMTPUsbConnection::ReceiveControlRequestSetupCompleteL(TInt aError, MMTPType& aData)
+    {
+    __FLOG(_L8("ReceiveControlRequestSetupCompleteL - Entry"));
+    if (!ControlRequestErrorHandled(aError))
+        {
+        TMTPUsbControlRequestSetup& data(static_cast<TMTPUsbControlRequestSetup&> (aData));
+        __FLOG_VA((_L8("bRequest = 0x%X"), data.Uint8(TMTPUsbControlRequestSetup::EbRequest)));
+        __FLOG_VA((_L8("wLength = %d bytes"), data.Uint16(TMTPUsbControlRequestSetup::EwLength)));
+        
+        switch (data.Uint8(TMTPUsbControlRequestSetup::EbRequest))
+            {
+        case EMTPUsbControlRequestCancel:
+            ProcessControlRequestCancelL(data);
+            break;
+            
+        case EMTPUsbControlRequestDeviceReset:
+            ProcessControlRequestDeviceResetL(data);
+            break;
+            
+        case EMTPUsbControlRequestDeviceStatus:
+            ProcessControlRequestDeviceStatusL(data);
+            break;
+  
+        default:
+            __FLOG(_L8("Unrecognised class specific request received"));
+            CloseConnection();
+            break;
+            }
+        }
+    __FLOG(_L8("ReceiveControlRequestSetupCompleteL - Exit"));
+    }
+    
+void CMTPUsbConnection::SendBulkDataCompleteL(TInt aError, const MMTPType& /*aData*/)
+    {
+    __FLOG(_L8("SendBulkDataCompleteL - Entry")); 
+
+#ifdef _DEBUG
+    RDebug::Print(_L("\nCMTPUsbConnection::SendBulkDataCompleteL----entry"));
+#endif
+    if (!BulkRequestErrorHandled(aError))
+        {
+        TUint16 containerType(iUsbBulkContainer->Uint16L(CMTPUsbContainer::EContainerType));
+
+#ifdef _DEBUG        
+      
+        TUint16 transactionID(iUsbBulkContainer->Uint32L(CMTPUsbContainer::ETransactionID));
+        RDebug::Print(_L("Time Stamp is :%d"), User::TickCount());
+        RDebug::Print(_L("the container Type is 0x%x, the transaction ID is 0x%x\n"), containerType,transactionID);
+#endif
+        
+        if (containerType == EMTPUsbContainerTypeResponseBlock)
+            {
+            // Response block sent.
+            BoundProtocolLayer().SendResponseCompleteL(aError, *static_cast<TMTPTypeResponse*>(iUsbBulkContainer->Payload()), iMTPRequest);
+    
+            // Update the transaction state.
+            if(ERequestPhase != iBulkTransactionState)
+	            {
+	            SetBulkTransactionState(ECompletingPhase);	
+	            }
+            }
+        else if (containerType == EMTPUsbContainerTypeDataBlock)
+            {
+            // Data block sent.
+            BoundProtocolLayer().SendDataCompleteL(aError, *iUsbBulkContainer->Payload(), iMTPRequest);
+            }
+        else
+	        {
+	        __FLOG(_L8("Invalid container type"));
+            Panic(EMTPUsbBadState);
+	        }
+             
+        // Reset the bulk container.
+        if(ERequestPhase != iBulkTransactionState)
+            {
+    		iUsbBulkContainer->SetPayloadL(NULL);
+            }		     
+        }
+    __FLOG(_L8("SendBulkDataCompleteL - Exit"));
+    }
+    
+void CMTPUsbConnection::SendControlRequestDataCompleteL(TInt aError, const MMTPType& /*aData*/)
+    {
+    __FLOG(_L8("SendControlRequestDataCompleteL - Entry"));
+    if (!ControlRequestErrorHandled(aError))
+        {
+        // Complete the control request sequence.
+        if (iUsbControlRequestSetup.Uint8(TMTPUsbControlRequestSetup::EbRequest) == EMTPUsbControlRequestCancel)
+            {
+            // Cancel request processed, clear the device status.
+            SetDeviceStatus(EMTPUsbDeviceStatusOK);
+            __FLOG(_L8("Cancel Request processed"));
+            }
+        
+        // Initiate the next control request sequence. 
+        InitiateControlRequestSequenceL();            
+        }
+    __FLOG(_L8("SendControlRequestDataCompleteL - Exit"));
+    }
+
+void CMTPUsbConnection::SendInterruptDataCompleteL(TInt aError, const MMTPType& /*aData*/)
+    {
+    __FLOG(_L8("SendInterruptDataCompleteL - Entry"));
+    iEventPending = EFalse;	
+    BoundProtocolLayer().SendEventCompleteL(aError, iMTPEvent);
+    __FLOG(_L8("SendInterruptDataCompleteL - Exit"));
+    }    
+
+/**
+Provides the logical endpoint bit position bits of the specified endpoint.
+@param aId The internal endpoint identifier of the endpoint.
+@return The logical endpoint bit position bits.
+*/
+TUint CMTPUsbConnection::EndpointBitPosition(TUint aId) const
+    {
+    return iEndpointInfo[aId].iBitPosition;
+    }    
+
+/**
+Provides the endpoint direction flag bits of the specified endpoint.
+@param aId The internal endpoint identifier of the endpoint.
+@return The endpoint direction flag bits.
+*/
+TUint CMTPUsbConnection::EndpointDirection(TUint aId) const
+    {
+    return iEndpointInfo[aId].iDirection;      
+    }   
+
+/**
+Provides the capabilities of the specified endpoint.
+@param aId The internal endpoint identifier of the endpoint.
+@leave KErrOverflow, if the USB device does not support the minimum number of 
+endpoints required by the USB MTP device class.
+*/
+const TUsbcEndpointCaps& CMTPUsbConnection::EndpointCapsL(TUint aId)
+    {
+    __FLOG(_L8("EndpointCapsL - Entry"));
+    
+    // Verify the the USB device supports the minimum number of endpoints.
+    TInt totalEndpoints = iDeviceCaps().iTotalEndpoints;
+    
+    __FLOG_VA((_L8("% d endpoints available, %d required"), totalEndpoints, KMTPUsbRequiredNumEndpoints));
+    if (totalEndpoints < KMTPUsbRequiredNumEndpoints)
+        {
+        User::Leave(KErrOverflow);            
+        }      
+        
+    TUint   flags(EndpointDirectionAndType(aId));
+    __FLOG_VA((_L8("Required EP%d iTypesAndDir = 0x%X"), aId, flags));
+	
+    TBool   found(EFalse);
+    for (TUint i(0); ((!found) && (i < totalEndpoints)); i++)
+        {
+        TUsbcEndpointCaps&  caps(iEndpointCapSets[i].iCaps);
+        
+        if ((caps.iTypesAndDir & flags) == flags)
+            {
+            found           = ETrue;
+            iEndpointCaps   = caps;
+			
+            __FLOG_VA((_L8("Matched EP%d iTypesAndDir = 0x%X"), i, caps.iTypesAndDir));
+            __FLOG_VA((_L8("Matched EP%d MaxPacketSize = %d"), i, caps.MaxPacketSize()));
+            __FLOG_VA((_L8("Matched EP%d MinPacketSize = %d"), i, caps.MinPacketSize()));
+            }
+        }
+        
+    if (!found)    
+        {
+        User::Leave(KErrHardwareNotAvailable);
+        }
+                
+    __FLOG(_L8("EndpointCapsL - Exit"));
+    return iEndpointCaps; 
+    }   
+
+/**
+Provides the endpoint direction and type flag bits of the specified endpoint.
+@param aId The internal endpoint identifier of the endpoint.
+@return The logical endpoint number.
+*/
+TUint CMTPUsbConnection::EndpointDirectionAndType(TUint aId) const
+    {
+    return (EndpointDirection(aId) | EndpointType(aId));      
+    } 
+
+/**
+Provides the logical endpoint number of the specified endpoint.
+@param aId The internal endpoint identifier of the endpoint.
+@return The logical endpoint number.
+*/
+TEndpointNumber CMTPUsbConnection::EndpointNumber(TUint aId) const
+    {
+    return iEndpointInfo[aId].iNumber;     
+    }    
+
+/**
+Provides the endpoint type flag bits of the specified endpoint.
+@param aId The internal endpoint identifier of the endpoint.
+@return The endpoint type flag bits.
+*/
+TUint CMTPUsbConnection::EndpointType(TUint aId) const
+    {
+    return iEndpointInfo[aId].iType;      
+    } 
+    
+/**
+Provides the USB device client interface.
+@return The USB device client interface.
+*/
+RDevUsbcClient& CMTPUsbConnection::Ldd()
+    {
+    return iLdd;
+    }
+    
+void CMTPUsbConnection::DoCancel()
+    {
+    __FLOG(_L8("DoCancel - Entry"));    
+    iLdd.AlternateDeviceStatusNotifyCancel();
+    __FLOG(_L8("DoCancel - Exit"));  
+    }
+    
+#ifdef __FLOG_ACTIVE
+TInt CMTPUsbConnection::RunError(TInt aError)
+#else
+TInt CMTPUsbConnection::RunError(TInt /*aError*/)
+#endif
+    {
+    __FLOG(_L8("RunError - Entry"));
+    __FLOG_VA((_L8("Error = %d"), aError));
+    
+    // Cancel all the outstanding requests.
+    Cancel();   
+    
+    // Stop the connection, if necessary.
+    StopConnection(); 
+    
+    // Stop the control end point.
+    ControlEndpointStop();
+    
+    // Issue the notify request again.
+    IssueAlternateDeviceStatusNotifyRequest();
+    
+    __FLOG(_L8("RunError - Exit"));
+    return KErrNone;
+    }
+    
+void CMTPUsbConnection::RunL()
+    {
+    __FLOG(_L8("RunL - Entry"));
+    
+    if (!(iControllerStateCurrent & KUsbAlternateSetting))
+        {
+        // Alternative interface setting has not changed.
+        __FLOG_VA((_L8("Alternate device state changed to %d"), iControllerStateCurrent));
+        
+        if ((SuspendState() & ESuspended) &&
+        	(iControllerStateCurrent != EUsbcDeviceStateSuspended))
+        	{
+		    //  Update state.
+		    SetSuspendState(ENotSuspended);	
+        	}
+        
+        switch (iControllerStateCurrent)
+            {
+            case EUsbcDeviceStateUndefined:
+            case EUsbcDeviceStateAttached:
+            case EUsbcDeviceStatePowered:
+            case EUsbcDeviceStateDefault:
+                StopConnection(); 
+                ControlEndpointStop();
+                break;
+            
+            case EUsbcDeviceStateAddress:
+            	// Set the Endpoint packet sizes.
+            	SetTransportPacketSizeL();
+            	
+            	// Stop the control endpoint first, in case there is still 
+            	// outstanding request.
+            	ControlEndpointStop();
+            	
+                // Initiate control endpoint data transfer activity.
+                ControlEndpointStartL();
+                break;
+            
+            case EUsbcDeviceStateConfigured:
+                {
+				__FLOG(_L8("Device state : EUsbcDeviceStateConfigured"));
+
+                if (iControllerStatePrevious == EUsbcDeviceStateSuspended)
+                    {
+                    // Resume connection data transfer activity.
+                    ResumeConnectionL();
+                    
+                    // Process buffered events.
+                    if (SuspendState() == ESuspendedEventsPending)
+                        {
+                        /* 
+                        If remote wakeup is enabled then signal remote wakeup
+                        before sending the buffered event data. Otherwise issue 
+                        a PTP UnreportedStatus event.
+                        */
+                        
+                        // Don't check for pending events since this
+                        // is after a suspend
+                        if (iRemoteWakeup)
+                            {
+                            // Send the event data.
+                            __FLOG(_L8("Sending buffered event data"));
+                            SendEventDataL();
+                            }
+                        else
+                            {
+                            // Send PTP UnreportedStatus event
+                            __FLOG(_L8("Sending PTP UnreportedStatus event"));
+                            SendUnreportedStatusEventL();
+                            }
+                        } 
+                    }
+                else
+                    {                    
+                    //restart the control endpoint    
+                    ControlEndpointStop(); 
+                    InitiateControlRequestSequenceL(); 
+
+                    //restart the data endpoint
+                    StartConnectionL();
+                    }
+                break;    
+            
+            case EUsbcDeviceStateSuspended:
+                // Suspend connection activity.
+	            SuspendConnectionL();   
+                break;
+                }
+                
+            default:
+                __FLOG(_L8("Invalid alternate device state"));
+                Panic(EMTPUsbBadState);
+                break;
+            }
+        }
+    else
+        {
+        // Alternate interface setting has changed.
+        __FLOG_VA((_L8("Alternate interface setting changed from %d to %d"), iControllerStatePrevious, iControllerStateCurrent));
+        }
+        
+        
+    // Record the controller state and issue the next notification request.
+    iControllerStatePrevious = iControllerStateCurrent;
+    IssueAlternateDeviceStatusNotifyRequest();
+    
+    __FLOG(_L8("RunL - Exit"));
+    }
+    
+/**
+Constructor.
+@param aConnectionMgr The MTP connection manager interface.
+*/
+CMTPUsbConnection::CMTPUsbConnection(MMTPConnectionMgr& aConnectionMgr) :
+    CActive(EPriorityStandard),
+    iEndpointInfo(KEndpointMetaData, EMTPUsbEpNumEndpoints),
+    iConnectionMgr(&aConnectionMgr)
+    {
+    CActiveScheduler::Add(this);
+    }
+    
+/**
+Second phase constructor.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbConnection::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry"));
+    
+    // Start the USB device.
+    StartUsbL();
+    
+    // Create the device class endpoints.
+    iEndpoints.InsertInOrderL(CMTPUsbEpControl::NewL(EMTPUsbEpControl, *this), CMTPUsbEpBase::LinearOrder);
+    iEndpoints.InsertInOrderL(CMTPUsbEpBulkIn::NewL(EMTPUsbEpBulkIn, *this), CMTPUsbEpBase::LinearOrder);
+    iEndpoints.InsertInOrderL(CMTPUsbEpBulkOut::NewL(EMTPUsbEpBulkOut, *this), CMTPUsbEpBase::LinearOrder);
+    iEndpoints.InsertInOrderL(CMTPUsbEpInterruptIn::NewL(EMTPUsbEpInterrupt, *this), CMTPUsbEpBase::LinearOrder);
+       
+    // Create the generic data container buffers.
+    iUsbBulkContainer   = CMTPUsbContainer::NewL();
+    iUsbEventContainer  = CMTPUsbContainer::NewL();
+    
+    // Initialise the device status.
+    SetDeviceStatus(EMTPUsbDeviceStatusOK);
+    
+    // Fetch the remote wakeup flag.
+    TUsbDeviceCaps dCaps;
+    User::LeaveIfError(iLdd.DeviceCaps(dCaps));
+    iRemoteWakeup = dCaps().iRemoteWakeup;
+    __FLOG_VA((_L8("iRemote = %d"), iRemoteWakeup));
+    
+    // Start monitoring the USB device controller state.
+    IssueAlternateDeviceStatusNotifyRequest();
+    
+    __FLOG(_L8("ConstructL - Exit"));
+    }
+
+/**
+Issues a request for notification of USB device controller state and alternate
+interface setting changes.
+*/
+void CMTPUsbConnection::IssueAlternateDeviceStatusNotifyRequest()
+    {
+    __FLOG(_L8("IssueAlternateDeviceStatusNotifyRequest - Entry"));
+    
+    if (!IsActive())
+        {
+        iLdd.AlternateDeviceStatusNotify(iStatus, iControllerStateCurrent);
+        }
+
+    SetActive();
+    __FLOG(_L8("IssueAlternateDeviceStatusNotifyRequest - Exit"));
+    }
+    
+/**
+Populates the asynchronous event interrupt dataset buffer.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbConnection::BufferEventDataL(const TMTPTypeEvent& aEvent)
+    {
+    __FLOG(_L8("BufferEventData - Entry")); 
+    /* 
+    Setup the parameter block payload dataset. Note that since this is a 
+    variable length dataset, it must first be reset.
+    */ 
+    iUsbEventParameterBlock.Reset();
+    iUsbEventParameterBlock.CopyIn(aEvent, TMTPTypeEvent::EEventParameter1, TMTPTypeEvent::EEventParameter3, EFalse, 0);
+    
+    // Setup the bulk container.
+    iUsbEventContainer->SetPayloadL(const_cast<TMTPUsbParameterPayloadBlock*>(&iUsbEventParameterBlock));
+    iUsbEventContainer->SetUint32L(CMTPUsbContainer::EContainerLength, iUsbEventContainer->Size());
+    iUsbEventContainer->SetUint16L(CMTPUsbContainer::EContainerType, EMTPUsbContainerTypeEventBlock);
+    iUsbEventContainer->SetUint16L(CMTPUsbContainer::ECode, aEvent.Uint16(TMTPTypeEvent::EEventCode));
+    iUsbEventContainer->SetUint32L(CMTPUsbContainer::ETransactionID, aEvent.Uint32(TMTPTypeEvent::EEventTransactionID));
+    __FLOG(_L8("BufferEventData - Exit"));
+    }
+    
+/**
+Initiates an interrupt data send sequence.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbConnection::SendEventDataL()
+    {
+    __FLOG(_L8("SendEventData - Entry"));
+    __FLOG_VA((_L8("Sending event 0x%4X (%d bytes)"), iUsbEventContainer->Uint16L(CMTPUsbContainer::ECode), iUsbEventContainer->Uint32L(CMTPUsbContainer::EContainerLength)));
+    static_cast<CMTPUsbEpInterruptIn*>(iEndpoints[EMTPUsbEpInterrupt])->SendInterruptDataL(*iUsbEventContainer);
+    iEventPending = ETrue;
+    __FLOG(_L8("SendEventData - Exit"));
+    }
+    
+/**
+Issues a PTP UnreportedStatus event.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbConnection::SendUnreportedStatusEventL()
+    {
+    __FLOG(_L8("SendUnreportedStatusEventL - Entry"));
+        
+    // Construct an UnreportedStatus event
+    TMTPTypeEvent mtpEvent;
+    mtpEvent.SetUint16(TMTPTypeEvent::EEventCode, EMTPEventCodeUnreportedStatus);
+    mtpEvent.SetUint32(TMTPTypeEvent::EEventSessionID, KMTPSessionNone);
+    mtpEvent.SetUint32(TMTPTypeEvent::EEventTransactionID, KMTPTransactionIdNone);
+    SendEventL(mtpEvent);
+    
+    __FLOG(_L8("SendUnreportedStatusEventL - Exit"));
+    }
+    
+/**
+Issues a request to the bulk-out endpoint to receive a command block dataset.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbConnection::InitiateBulkRequestSequenceL()
+    {
+    __FLOG(_L8("InitiateBulkRequestSequenceL - Entry"));
+    CMTPUsbEpBulkOut& bulkOut(*static_cast<CMTPUsbEpBulkOut*>(iEndpoints[EMTPUsbEpBulkOut]));
+
+        // Update the transaction state.
+        SetBulkTransactionState(ERequestPhase);
+        
+        // Setup the bulk container.
+        iUsbBulkParameterBlock.Reset();
+        iUsbBulkContainer->SetPayloadL(&iUsbBulkParameterBlock);
+        
+        // Initiate the next request phase bulk data receive sequence.
+        bulkOut.ReceiveBulkDataL(*iUsbBulkContainer);
+        
+    __FLOG(_L8("InitiateBulkRequestSequenceL - Exit"));
+    }
+
+/**
+Issues a request to the control endpoint to receive a request setup dataset.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbConnection::InitiateControlRequestSequenceL()
+    {
+    __FLOG(_L8("InitiateControlRequestSequenceL - Entry"));
+    CMTPUsbEpControl& ctrl(*static_cast<CMTPUsbEpControl*>(iEndpoints[EMTPUsbEpControl]));
+    if (!ctrl.Stalled())
+        {
+        ctrl.ReceiveControlRequestSetupL(iUsbControlRequestSetup);
+        }
+    __FLOG(_L8("InitiateControlRequestSequenceL - Exit"));        
+    }
+
+/**
+Processes received USB SIC bulk command block containers received from the 
+connected host on the bulk out data pipe.
+@param aError The error completion status of the bulk data receive request.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/         
+#ifdef __FLOG_ACTIVE
+void CMTPUsbConnection::ProcessBulkCommandL(TInt aError)
+#else
+void CMTPUsbConnection::ProcessBulkCommandL(TInt /*aError*/)
+#endif
+    {
+    __FLOG(_L8("ProcessBulkCommandL - Entry"));
+    __FLOG_VA((_L8("aError = %d"), aError));
+    if (BulkRequestTransactionStateValid(ERequestPhase))
+        {
+        // Request block received.
+        TUint16 op(iUsbBulkContainer->Uint16L(CMTPUsbContainer::ECode));
+   	    __FLOG_VA((_L8("Command block 0x%04X received"), op));
+        
+       	// Reset the iMTPRequest.
+       	iMTPRequest.Reset();
+
+       	// Setup the MTP request dataset buffer. Set Operation Code and TransactionID
+       	iMTPRequest.SetUint16(TMTPTypeRequest::ERequestOperationCode, op);
+       	iMTPRequest.SetUint32(TMTPTypeRequest::ERequestTransactionID, iUsbBulkContainer->Uint32L(CMTPUsbContainer::ETransactionID));
+        
+       	// Set SessionID.
+       	if (op == EMTPOpCodeOpenSession)
+           	{
+           	__FLOG(_L8("Processing OpenSession request"));
+           	// Force OpenSession requests to be processed outside an active session.
+           	// It is a known problem for MTP Protocol, it is a workaround here.
+           	iMTPRequest.SetUint32(TMTPTypeRequest::ERequestSessionID, KMTPSessionNone);  
+           	}
+       	else if (op == EMTPOpCodeCloseSession || op == EMTPOpCodeResetDevice)
+           	{
+           	__FLOG(_L8("Processing CloseSession or the ResetDevice request"));
+           	// Force CloseSession requests to be processed outside an active session. 
+           	// ResetDevice currently behaves the same way as CloseSession. 
+           	iMTPRequest.SetUint32(TMTPTypeRequest::ERequestSessionID, KMTPSessionNone); 
+           	iMTPRequest.SetUint32(TMTPTypeRequest::ERequestParameter1, iMTPSessionId); 
+           	}       	
+       	else
+           	{
+           	__FLOG_VA((_L8("Processing general request on session %d"), iMTPSessionId));
+           	// Update the request dataset with the single active session's SessionID.
+           	iMTPRequest.SetUint32(TMTPTypeRequest::ERequestSessionID, iMTPSessionId);
+           	}
+       	
+#ifdef _DEBUG
+       	RDebug::Print(_L("The time stamp is: %d"), User::TickCount());
+       	RDebug::Print(_L("New command comes, Operation code is 0x%x, transaction id is %d \n"), op, iUsbBulkContainer->Uint32L(CMTPUsbContainer::ETransactionID));  	
+#endif
+       	
+        TUint  commandTransID(iUsbBulkContainer->Uint32L(CMTPUsbContainer::ETransactionID));
+        	   
+        // process this command as usual
+        // Update the device status.
+        SetDeviceStatus(EMTPUsbDeviceStatusBusy);
+                  
+        // Set Parameter 1 .. Parameter 5.
+        iUsbBulkParameterBlock.CopyOut(iMTPRequest, TMTPTypeRequest::ERequestParameter1, TMTPTypeRequest::ERequestParameter5);
+        iUsbBulkParameterBlock.Reset();
+       
+        // Notify the protocol layer.
+        BoundProtocolLayer().ReceivedRequestL(iMTPRequest);
+        }
+    __FLOG(_L8("ProcessBulkCommandL - Exit"));
+    }
+
+/**
+Processes USB SIC bulk data block containers onto the connected host on the 
+bulk in data pipe.
+@param aRequest The MTP request dataset of the active MTP transaction.
+@param aData The MTP data object source.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/       
+void CMTPUsbConnection::ProcessBulkDataInL(const TMTPTypeRequest& aRequest, const MMTPType& aData)
+    {
+    __FLOG(_L8("ProcessBulkDataInL - Entry"));
+    
+    // Update the transaction state.
+    SetBulkTransactionState(EDataRToIPhase);
+    
+    // Setup the bulk container.
+    iUsbBulkContainer->SetPayloadL(const_cast<MMTPType*>(&aData));
+    
+    TUint64 size(iUsbBulkContainer->Size());
+    TUint32 containerLength((size > KMTPUsbContainerLengthMax) ? KMTPUsbContainerLengthMax : static_cast<TUint32>(size));
+    iUsbBulkContainer->SetUint32L(CMTPUsbContainer::EContainerLength, containerLength);
+    
+    iUsbBulkContainer->SetUint16L(CMTPUsbContainer::EContainerType, EMTPUsbContainerTypeDataBlock);
+    iUsbBulkContainer->SetUint16L(CMTPUsbContainer::ECode, aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode));
+    iUsbBulkContainer->SetUint32L(CMTPUsbContainer::ETransactionID, aRequest.Uint32(TMTPTypeRequest::ERequestTransactionID));
+
+    // Initiate the bulk data send sequence.
+    __FLOG_VA((_L8("Sending %d data bytes"), iUsbBulkContainer->Uint32L(CMTPUsbContainer::EContainerLength)));
+    
+#ifdef _DEBUG
+    RDebug::Print(_L("ProcessBulkDataInL:    iIsCancelReceived = %d, SuspendState() is  %d \n"),iIsCancelReceived,SuspendState());
+#endif
+    
+    // if the cancel event is received before send data. That is, the phase is before DATA R2I, 
+    // Device should not send the transaction  data to the host,just like what sendResponse does.
+    if (SuspendState() != ESuspended && !iIsCancelReceived)
+    	{
+    	TPtr8 headerChunk(NULL, 0);
+    	TBool hasTransportHeader = const_cast<MMTPType&>(aData).ReserveTransportHeader(KUSBHeaderSize, headerChunk);
+        if(hasTransportHeader)
+            {
+            TUint16 containerType = EMTPUsbContainerTypeDataBlock;
+            TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
+            TUint32 transId = aRequest.Uint32(TMTPTypeRequest::ERequestTransactionID);
+            memcpy(const_cast<TUint8*>(headerChunk.Ptr()), &containerLength, sizeof(TUint32));
+            memcpy(const_cast<TUint8*>(headerChunk.Ptr()) + 4, &containerType, sizeof(TUint16));
+            memcpy(const_cast<TUint8*>(headerChunk.Ptr()) + 6, &operationCode, sizeof(TUint16)); 
+            memcpy(const_cast<TUint8*>(headerChunk.Ptr()) + 8, &transId, sizeof(TUint32));
+            static_cast<CMTPUsbEpBulkIn*>(iEndpoints[EMTPUsbEpBulkIn])->SendBulkDataL(aData);
+            }
+        else
+            {
+            static_cast<CMTPUsbEpBulkIn*>(iEndpoints[EMTPUsbEpBulkIn])->SendBulkDataL(*iUsbBulkContainer);
+            }
+        }
+    else
+    	{
+    	
+#ifdef _DEBUG    	
+    	RDebug::Print(_L("the senddata is canceled!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"));
+#endif    	
+    	// by pass the calling to lower level send data
+    	SendBulkDataCompleteL(KErrNone, *iUsbBulkContainer);
+    	
+    	}
+    __FLOG(_L8("ProcessBulkDataInL - Exit"));
+    }
+
+/**
+Processes received USB SIC bulk data block containers received from the 
+connected host on the bulk out data pipe.
+@param aError The error completion status of the bulk data receive request.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/       
+void CMTPUsbConnection::ProcessBulkDataOutL(TInt aError)
+    {
+    __FLOG(_L8("ProcessBulkDataOutL - Entry"));
+    if ((BulkRequestTransactionStateValid(EDataIToRPhase)))
+        {
+        // Data block received, notify the protocol layer.
+        __FLOG_VA((_L8("Data block received (%d bytes)"), iUsbBulkContainer->Uint32L(CMTPUsbContainer::EContainerLength)));
+        BoundProtocolLayer().ReceiveDataCompleteL(aError, *iUsbBulkContainer->Payload(), iMTPRequest);
+        }
+    __FLOG(_L8("ProcessBulkDataOutL - Exit"));
+    }
+
+/**
+Processes received USB SIC class specific Cancel requests
+@param aRequest The USB SIC class specific request setup data.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/   
+void CMTPUsbConnection::ProcessControlRequestCancelL(const TMTPUsbControlRequestSetup& /*aRequest*/)
+    {
+    __FLOG(_L8("ProcessControlRequestCancelL - Entry"));
+    static_cast<CMTPUsbEpControl*>(iEndpoints[EMTPUsbEpControl])->ReceiveControlRequestDataL(iUsbControlRequestCancelData);
+    __FLOG(_L8("Waiting for Cancel Request Data"));
+    __FLOG(_L8("ProcessControlRequestCancelL - Exit"));
+    }
+    
+/**
+Processes received USB SIC class specific Device Reset requests
+@param aRequest The USB SIC class specific request setup data.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/ 
+void CMTPUsbConnection::ProcessControlRequestDeviceResetL(const TMTPUsbControlRequestSetup& /*aRequest*/)
+    {
+    __FLOG(_L8("ProcessControlRequestDeviceResetL - Entry"));
+                
+    // Clear stalled endpoints and re-open connection
+    BulkEndpointsStallClearL();
+    StartConnectionL();
+    
+    /*
+    The Device Reset Request is data-less. Complete the control request
+    sequence and initiate the next control request sequence. 
+    */
+    static_cast<CMTPUsbEpControl*>(iEndpoints[EMTPUsbEpControl])->SendControlRequestStatus();
+    StopConnection();
+    InitiateControlRequestSequenceL();
+    StartConnectionL();
+    __FLOG(_L8("ProcessControlRequestDeviceResetL - Exit"));
+    }
+    
+/**
+Processes received USB SIC class specific Get Device Status requests
+@param aRequest The USB SIC class specific request setup data.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/ 
+void CMTPUsbConnection::ProcessControlRequestDeviceStatusL(const TMTPUsbControlRequestSetup& aRequest)
+    {
+    __FLOG(_L8("ProcessControlRequestDeviceStatusL - Entry"));
+    iUsbControlRequestDeviceStatus.Reset();
+    
+    TUint offset = 0;
+    for(TUint i(EMTPUsbEpControl); i<EMTPUsbEpNumEndpoints; ++i)
+    	{
+        
+        if ( IsEpStalled(i) )
+            {
+            TInt epSize(0);
+            User::LeaveIfError( iLdd.GetEndpointDescriptorSize(KMTPUsbAlternateInterface, i, epSize) );
+            
+            RBuf8 epDesc; //endpoint descriptor, epDesc[2] is the address of endpoint. More info, pls refer to USB Sepc2.0 - 9.6.6
+            epDesc.CreateL(epSize);
+            CleanupClosePushL(epDesc); 
+            User::LeaveIfError( iLdd.GetEndpointDescriptor(KMTPUsbAlternateInterface, i, epDesc) );
+
+            //Maybe here is a little bit confused. Although an endpoint address is a 8-bit byte in Endpoint Descriptor,
+            //but in practice, it's requested by host with a 32-bit value, so we plus offset with 4 to reflect this.
+            TUint32 epAddress = epDesc[KEpAddressOffsetInEpDesc];
+            iUsbControlRequestDeviceStatus.SetUint32((offset + TMTPUsbControlRequestDeviceStatus::EParameter1), epAddress);            
+            CleanupStack::PopAndDestroy(); // calls epDesc.Close()
+            
+            ++offset;
+            }
+        }
+   
+
+  
+   
+    
+    // if the current status is OK and a cancel event has been received but the device has not respond 
+    // transaction_cancelled yet, return transaction_cancelled firstly.
+    TUint16 originalStatus = iDeviceStatusCode;
+    if( (iDeviceStatusCode == EMTPUsbDeviceStatusOK) && isResponseTransactionCancelledNeeded )
+    	{
+    	SetDeviceStatus(EMTPUsbDeviceStatusTransactionCancelled);
+    	  // clear the transaction cancelled flag
+        isResponseTransactionCancelledNeeded = false;
+    	}
+    
+    
+
+    
+    // Set the Code and wLength fields and send the dataset.
+    iUsbControlRequestDeviceStatus.SetUint16(TMTPUsbControlRequestDeviceStatus::ECode, iDeviceStatusCode);
+    iUsbControlRequestDeviceStatus.SetUint16(TMTPUsbControlRequestDeviceStatus::EwLength, iUsbControlRequestDeviceStatus.Size());
+    // send the response
+    static_cast<CMTPUsbEpControl*>(iEndpoints[EMTPUsbEpControl])->SendControlRequestDataL(iUsbControlRequestDeviceStatus);
+      
+    // restore the original device status
+    SetDeviceStatus(originalStatus);
+    
+    __FLOG(_L8("ProcessControlRequestDeviceStatusL - Exit"));
+    }
+
+/**
+Processes bulk transfer request completion error checking. If the completion 
+status is abnormal then the connection is shutdown.
+@param aError bulk transfer request completion error. 
+@return ETrue if the control request completion status was abnormal, otherwise
+EFalse.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+TBool CMTPUsbConnection::BulkRequestErrorHandled(TInt aError)
+    {
+    __FLOG(_L8("BulkRequestErrorHandled - Entry"));
+    __FLOG_VA((_L8("Bulk transfer request completion status = %d"), aError));
+    TBool ret(EFalse);
+    
+    // Only handle USB error codes
+    if (aError <= KErrUsbDriverBase &&
+    	aError >= KErrUsbEpNotReady)
+        {   
+        switch (aError)  
+            {        
+       	case KErrUsbDeviceNotConfigured:
+        case KErrUsbInterfaceChange:
+        case KErrUsbDeviceClosing:
+        case KErrUsbCableDetached:
+        case KErrUsbDeviceBusReset:
+            // Interface state is changing (@see RunL).
+            ret = ETrue;
+            break;
+
+        default:
+            // Unknown error on a bulk endpoint, close the connection.
+            CloseConnection();
+            ret = ETrue;
+            break;            
+            }
+        }
+    __FLOG(_L8("BulkRequestErrorHandled - Exit"));
+    return ret;
+    }
+    
+/**
+Processes bulk transfer request transaction state checking. If the transaction 
+state is invalid, then the connection is shutdown.
+@return ETrue if the control request completion status was abnormal, otherwise
+EFalse.
+*/
+TBool CMTPUsbConnection::BulkRequestTransactionStateValid(TMTPTransactionPhase aExpectedTransactionState)
+    {
+    __FLOG(_L8("BulkRequestTransactionStateValid - Entry"));
+    __FLOG_VA((_L8("Bulk transaction state = %d"), iBulkTransactionState));
+    TBool valid(iBulkTransactionState == aExpectedTransactionState);
+    if (!valid)
+        {
+        // Invalid bulk transaction state, close the connection.
+        __FLOG_VA((_L8("Expected bulk transaction state = %d"), aExpectedTransactionState));
+        CloseConnection();
+        }
+    __FLOG(_L8("BulkRequestTransactionStateValid - Exit"));
+    return valid;
+    }
+    
+/**
+Processes control request completion. If the completion status is abnormal then
+the connection is shutdown.
+@param aError control request completion error code.
+@return ETrue if the control request completion status was abnormal, otherwise
+EFalse.
+*/
+TBool CMTPUsbConnection::ControlRequestErrorHandled(TInt aError)
+    {
+    __FLOG(_L8("ControlRequestErrorHandled - Entry"));
+    __FLOG_VA((_L8("Control request completion status = %d"), aError));
+    TBool ret(EFalse);
+    
+    if (aError != KErrNone)
+        {
+        switch (aError)  
+            {
+        case KErrCancel:
+            // Control request sequence cancelled.
+            break;
+        
+        case KErrUsbDeviceNotConfigured:    
+        case KErrUsbInterfaceChange:
+        case KErrUsbDeviceClosing:
+        case KErrUsbCableDetached:
+        case KErrUsbDeviceBusReset:
+            // Interface state is changing (@see RunL).
+            break;
+
+        default:
+            // Unknown error on the control endpoint, shutdown the connection.
+            CloseConnection();
+            break;            
+            }
+            
+        // Signal abnormal completion.
+        ret = ETrue;
+        }
+    
+    __FLOG(_L8("ControlRequestErrorHandled - Exit"));
+    return ret;
+    }
+
+/**
+Clears the USB MTP device class configuration descriptor.
+*/
+void CMTPUsbConnection::ConfigurationDescriptorClear()
+    {
+    __FLOG(_L8("ConfigurationDescriptorClear - Entry"));
+    const TInt KNumInterfacesOffset(4);
+    
+    TInt descriptorSize(0);
+    iLdd.GetConfigurationDescriptorSize(descriptorSize);
+    
+    if (static_cast<TUint>(descriptorSize) == KUsbDescSize_Config)
+        {
+        TBuf8<KUsbDescSize_Config> descriptor;
+        if (iLdd.GetConfigurationDescriptor(descriptor) == KErrNone)
+            {
+            --descriptor[KNumInterfacesOffset];
+            iLdd.SetConfigurationDescriptor(descriptor);
+            }
+        }
+    
+    __FLOG(_L8("ConfigurationDescriptorClear - Exit"));
+    }
+
+/**
+Sets the USB MTP device class configuration descriptor.
+@leave KErrCorrupt, if the configuration descriptor size is invalid.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbConnection::ConfigurationDescriptorSetL()
+    {
+    __FLOG(_L8("SetupConfigurationDescriptorL - Entry"));
+    const TInt KNumInterfacesOffset(4);
+    
+    TInt descriptorSize(0);
+    iLdd.GetConfigurationDescriptorSize(descriptorSize);
+    
+    if (static_cast<TUint>(descriptorSize) != KUsbDescSize_Config)
+        {
+        User::Leave(KErrCorrupt);
+        }
+ 
+    TBuf8<KUsbDescSize_Config> descriptor;
+    User::LeaveIfError(iLdd.GetConfigurationDescriptor(descriptor));
+    ++descriptor[KNumInterfacesOffset];
+    User::LeaveIfError(iLdd.SetConfigurationDescriptor(descriptor));
+    
+    __FLOG(_L8("SetupConfigurationDescriptorL - Exit"));
+    }
+
+/**
+Indicates whether the connection state is closed.
+*/    
+TBool CMTPUsbConnection::ConnectionClosed() const
+    {
+    return (ConnectionState() < EOpen);        
+    }
+
+/**
+Indicates whether the connection state is open.
+*/
+TBool CMTPUsbConnection::ConnectionOpen() const
+    {
+    return (!ConnectionClosed());        
+    }
+    
+/**
+Starts data transfer activity on the control endpoint.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbConnection::ControlEndpointStartL()
+    {
+    __FLOG(_L8("StartControlEndpoint - Entry"));
+    InitiateControlRequestSequenceL();
+    __FLOG(_L8("StartControlEndpoint - Exit"));  
+    }
+
+/**
+Stops data transfer activity on the control endpoint.
+*/    
+void CMTPUsbConnection::ControlEndpointStop()
+    {
+    __FLOG(_L8("ControlEndpointStop - Entry"));
+    iEndpoints[EMTPUsbEpControl]->Cancel();
+    __FLOG(_L8("ControlEndpointStop - Exit"));    
+    }
+
+/**
+Stalls all but the control endpoint.
+*/    
+void CMTPUsbConnection::BulkEndpointsStallL()
+    {
+    __FLOG(_L8("BulkEndpointsStallL - Entry"));
+    EndpointStallL(EMTPUsbEpBulkIn);
+    EndpointStallL(EMTPUsbEpBulkOut);
+    SetDeviceStatus(EMTPUsbDeviceStatusTransactionCancelled);
+    __FLOG(_L8("BulkEndpointsStallL - Exit"));
+    }
+
+/**
+Clears stall conditions all but the control endpoint.
+*/
+void CMTPUsbConnection::BulkEndpointsStallClearL()
+    {
+    __FLOG(_L8("BulkEndpointsStallClearL - Entry"));
+    EndpointStallClearL(EMTPUsbEpBulkIn);
+    EndpointStallClearL(EMTPUsbEpBulkOut);
+    SetDeviceStatus(EMTPUsbDeviceStatusOK);
+    __FLOG(_L8("BulkEndpointsStallClearL - Exit"));  
+    }
+
+/**
+Starts data transfer activity on the data endpoints.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/    
+void CMTPUsbConnection::DataEndpointsStartL()
+    {
+    __FLOG(_L8("DataEndpointsStartL - Entry"));
+    InitiateBulkRequestSequenceL();
+    __FLOG(_L8("DataEndpointsStartL - Exit"));
+    }
+
+/**
+Stops data transfer activity on all but the control endpoint.
+*/    
+void CMTPUsbConnection::DataEndpointsStop()
+    {
+    __FLOG(_L8("DataEndpointsStop - Entry"));
+    if (ConnectionOpen() && (!(SuspendState() & ESuspended))&& (iControllerStatePrevious != EUsbcDeviceStateSuspended))
+        {
+        __FLOG(_L8("Stopping active endpoints"));
+        iEndpoints[EMTPUsbEpBulkIn]->Cancel();
+        iEndpoints[EMTPUsbEpBulkOut]->Cancel();
+        iEndpoints[EMTPUsbEpInterrupt]->Cancel();
+        if ((iBulkTransactionState == EDataIToRPhase) && iUsbBulkContainer->Payload())
+            {
+            __FLOG(_L8("Aborting active I to R data phase"));
+            TRAPD(err, BoundProtocolLayer().ReceiveDataCompleteL(KErrAbort, *iUsbBulkContainer->Payload(), iMTPRequest));
+            UNUSED_VAR(err);
+            }
+        else if ((iBulkTransactionState == EDataRToIPhase) && iUsbBulkContainer->Payload())
+            {
+            __FLOG(_L8("Aborting active R to I data phase"));
+            TRAPD(err, BoundProtocolLayer().SendDataCompleteL(KErrAbort, *iUsbBulkContainer->Payload(), iMTPRequest));
+            UNUSED_VAR(err);
+            }
+        }
+#ifdef __FLOG_ACTIVE
+    else
+        {
+        __FLOG(_L8("Endpoints inactive, do nothing"));
+        }
+#endif // __FLOG_ACTIVE
+    __FLOG(_L8("DataEndpointsStop - Exit"));
+    }
+    
+void CMTPUsbConnection::EndpointStallL(TMTPUsbEndpointId aId)
+    {
+    __FLOG(_L8("EndpointStallL - Entry"));
+    __FLOG_VA((_L8("Creating stall condition on endpoint %d"), aId));
+    __ASSERT_DEBUG((aId < EMTPUsbEpNumEndpoints), Panic(EMTPUsbReserved));
+    
+    // Stall the endpoint.
+    CMTPUsbEpBase& ep(*iEndpoints[aId]);
+    ep.Stall();
+    
+    // Stop the connection.
+    StopConnection();
+    
+    // Update the connection state.
+    if (!(ConnectionState() & EStalled))
+        {
+        SetConnectionState(EStalled);
+        }
+    __FLOG(_L8("EndpointStallL - Exit"));
+    }
+    
+void CMTPUsbConnection::EndpointStallClearL(TMTPUsbEndpointId aId)
+    {
+    __FLOG(_L8("EndpointStallClearL - Entry"));
+    __FLOG_VA((_L8("Clearing stall condition on endpoint %d"), aId));
+    __ASSERT_DEBUG((aId < EMTPUsbEpNumEndpoints), Panic(EMTPUsbReserved));
+    
+    // Check the endoints current stall condition.
+    CMTPUsbEpBase& ep(*iEndpoints[aId]);
+    if ( IsEpStalled( aId ) )
+        {
+        // Clear the stalled endpoint.
+        ep.StallClear();
+        
+        // Update the device status.
+        if ((aId == EMTPUsbEpControl) &&
+            ((iControllerStateCurrent == EUsbcDeviceStateAddress) ||
+                (iControllerStateCurrent == EUsbcDeviceStateConfigured)))
+            {
+            // Control endpoint stall cleared on an active connection.    
+            InitiateControlRequestSequenceL();
+            }
+        else if (!IsEpStalled( aId ) )
+            {
+            // All data endpoint stall conditions are clear.
+          	SetConnectionState(EIdlePhase);
+            }
+        }
+    __FLOG(_L8("EndpointStallClearL - Exit"));
+    }
+       
+/**
+Resumes USB MTP device class processing.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/ 
+void CMTPUsbConnection::ResumeConnectionL()
+    {
+    __FLOG(_L8("ResumeConnectionL - Entry"));
+    if (ConnectionOpen())
+        {    
+        // Restart data transfer activity.
+        ControlEndpointStartL();
+        DataEndpointsStartL();
+        }
+    __FLOG(_L8("ResumeConnectionL - Exit"));
+    }
+       
+/**
+Initiates USB MTP device class processing.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/ 
+void CMTPUsbConnection::StartConnectionL()
+    {
+    __FLOG(_L8("StartConnectionL - Entry"));   
+    
+    // Notify the connection manager and update state, if necessary. 
+    if (ConnectionClosed())
+        {
+        __FLOG(_L8("Notifying protocol layer connection opened"));
+        iConnectionMgr->ConnectionOpenedL(*this);  
+        SetConnectionState(EOpen);
+        InitiateBulkRequestSequenceL();
+        }
+    __FLOG(_L8("StartConnectionL - Exit"));
+    }
+       
+/**
+Halts USB MTP device class processing.
+*/ 
+void CMTPUsbConnection::StopConnection()
+    {
+    __FLOG(_L8("StopConnection - Entry"));
+    
+    // Stop all data transfer activity.
+    DataEndpointsStop();    
+    
+    // Notify the connection manager and update state, if necessary.
+    if (ConnectionOpen())
+        {
+        __FLOG(_L8("Notifying protocol layer connection closed"));
+        iConnectionMgr->ConnectionClosed(*this);
+        SetBulkTransactionState(EUndefined);
+        SetConnectionState(EIdle);
+        SetSuspendState(ENotSuspended);
+        }
+    
+    __FLOG(_L8("StopConnection - Exit"));
+    }
+       
+/**
+Suspends USB MTP device class processing.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/ 
+void CMTPUsbConnection::SuspendConnectionL()
+    {
+    __FLOG(_L8("SuspendConnectionL - Entry"));
+    if (ConnectionOpen())
+        {    
+        // Stop all data transfer activity.
+        DataEndpointsStop();
+        }
+    ControlEndpointStop();
+
+    //  Update state.
+    SetSuspendState(ESuspended);
+    __FLOG(_L8("SuspendConnectionL - Exit"));
+    }
+
+/**
+Configures the USB MTP device class.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbConnection::StartUsbL()
+    {
+    __FLOG(_L8("StartUsbL - Exit"));
+    
+    // Open the USB device interface.
+    User::LeaveIfError(iLdd.Open(KDefaultUsbClientController));
+    
+    // Configure the class descriptors.
+    ConfigurationDescriptorSetL();
+    SetInterfaceDescriptorL();
+    
+    __FLOG(_L8("StartUsbL - Exit"));
+    }
+    
+/**
+This method stops the end points transfer.
+*/
+void CMTPUsbConnection::StopUsb()
+    {
+    __FLOG(_L8("StopUsb - Entry"));
+    // Stop monitoring the USB device controller state.
+    iLdd.AlternateDeviceStatusNotifyCancel();
+    
+    // Stop monitoring the USB device controller state.
+    Cancel();
+    
+    // Clear the configuration descriptor.
+    ConfigurationDescriptorClear();
+    
+    // Close the USB device interface.
+    iLdd.ReleaseInterface(KMTPUsbAlternateInterface);
+    iLdd.Close();
+    
+    __FLOG(_L8("StopUsb - Exit"));
+    }
+    
+/**
+Provides the USB bulk container. 
+@return The USB bulk container
+*/
+CMTPUsbContainer& CMTPUsbConnection::BulkContainer()
+	{
+	return *iUsbBulkContainer;
+	}
+	
+/**
+Provides the current state of the USB MTP device class connection.
+@return The current USB MTP device class connection state.
+@see TConnectionState
+*/
+TInt32 CMTPUsbConnection::ConnectionState() const
+    {
+    TInt32 state(iState & EConnectionStateMask);
+    __FLOG_VA((_L8("Connection state = 0x%08X"), state));
+    return (state); 
+    }
+
+/**
+Provides the current USB device suspend state..
+@return The current USB device suspend state.
+@see TSuspendState
+*/
+TInt32 CMTPUsbConnection::SuspendState() const
+    {
+    TInt32 state(iState & ESuspendStateMask);
+    __FLOG_VA((_L8("Suspend state = 0x%08X"), state));
+    
+    return (state);
+    }
+
+/**
+Sets the bulk transfer transaction state.
+@param aState The new connectio state bit flags.
+@see TConnectionState
+*/
+void CMTPUsbConnection::SetBulkTransactionState(TMTPTransactionPhase aState)
+    {
+    __FLOG(_L8("SetBulkTransactionState - Entry"));
+    iBulkTransactionState = aState;
+    __FLOG_VA((_L8("SetBulkTransactionState state set to 0x%08X"), iBulkTransactionState));
+    __FLOG(_L8("SetBulkTransactionState - Exit"));
+    }
+
+/**
+Sets the MTP USB device class device status Code value.
+@param aCode The PIMA 15740 Response Code or Vendor Code value.
+*/
+void CMTPUsbConnection::SetDeviceStatus(TUint16 aCode)
+    {
+    __FLOG(_L8("SetDeviceStatus - Entry"));
+    iDeviceStatusCode = aCode;
+    __FLOG_VA((_L8("Device status set to 0x%04X"), iDeviceStatusCode));
+    __FLOG(_L8("SetDeviceStatus - Exit"));
+    }
+
+/**
+Sets the USB MTP device class interface descriptor.
+@leave KErrCorrupt, if the configuration descriptor size is invalid.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbConnection::SetInterfaceDescriptorL()
+    {
+    __FLOG(_L8("SetInterfaceDescriptorL - Entry"));
+    
+    TUsbcInterfaceInfoBuf ifc;
+    // Get device capabilities.
+    User::LeaveIfError(iLdd.DeviceCaps(iDeviceCaps));
+    
+    // Fetch the endpoint capabilities set.
+    TPtr8 capsPtr(reinterpret_cast<TUint8*>(iEndpointCapSets), sizeof(iEndpointCapSets), sizeof(iEndpointCapSets));
+    User::LeaveIfError(iLdd.EndpointCaps(capsPtr));
+    // Set the interface endpoint properties.
+    for (TUint i(EMTPUsbEpBulkIn); (i < EMTPUsbEpNumEndpoints); i++)
+        {
+        // Fetch the endpoint capabilities and meta data.
+        const TUsbcEndpointCaps&    caps(EndpointCapsL(i));
+        const TEpInfo&              info(iEndpointInfo[i]);
+        
+        // Define the endpoint properties.
+        const TUint idx(EndpointNumber(i) - 1);
+        ifc().iEndpointData[idx].iType      	= info.iType;
+        ifc().iEndpointData[idx].iFeatureWord1  = KUsbcEndpointInfoFeatureWord1_DMA|KUsbcEndpointInfoFeatureWord1_DoubleBuffering;
+        ifc().iEndpointData[idx].iDir       	= info.iDirection;
+
+		//set endpoint maxpacketsize.
+        if (info.iType == KMTPUsbInterruptEpType)
+            {
+            //As default interface, interrupt endpoint maxpacketsize shall be up to 0x40
+            ifc().iEndpointData[idx].iSize      = KMaxPacketTypeInterrupt;
+            }
+        else
+            {
+            ifc().iEndpointData[idx].iSize      = caps.MaxPacketSize();
+            }
+			
+        ifc().iEndpointData[idx].iInterval  	= info.iInterval;
+        ifc().iEndpointData[idx].iInterval_Hs 	= info.iInterval_Hs;
+        }
+        
+    // Set the required interface descriptor values.
+    ifc().iString               = const_cast<TDesC16*>(&KMTPUsbInterfaceString);
+    ifc().iClass.iClassNum      = KMTPUsbInterfaceClassSIC;
+	ifc().iClass.iSubClassNum   = KMTPUsbInterfaceSubClassSIC;
+	ifc().iClass.iProtocolNum   = KMTPUsbInterfaceProtocolSIC;
+    ifc().iTotalEndpointsUsed   = KMTPUsbRequiredNumEndpoints;
+    
+    // Allocate 512KB buffer for OUT EndPoint, and 64KB for IN EndPoint
+    TUint32 bandwidthPriority = EUsbcBandwidthINPlus2 | EUsbcBandwidthOUTMaximum;
+        
+    // Write the active interface descriptor.
+    User::LeaveIfError(iLdd.SetInterface(KMTPUsbAlternateInterface, ifc, bandwidthPriority));
+        
+    __FLOG(_L8("SetInterfaceDescriptorL - Exit"));
+    }
+
+/**
+Sets the USB MTP device class connection state.
+@param aState The new connection state bit flags.
+@see TConnectionState
+*/
+void CMTPUsbConnection::SetConnectionState(TInt32 aState)
+    {
+    __FLOG(_L8("SetConnectionState - Entry"));
+    iState = ((~EConnectionStateMask & iState) | aState);
+    __FLOG_VA((_L8("Connection state set to 0x%08X"), iState));
+    __FLOG(_L8("SetConnectionState - Exit"));
+    }
+
+/**
+Sets the USB device suspend state.
+@param aState The new suspend state bit flags.
+@see TSuspendState
+*/
+void CMTPUsbConnection::SetSuspendState(TInt32 aState)
+    {
+    __FLOG(_L8("SetSuspendState - Entry"));
+    iState = ((~ESuspendStateMask & iState) | aState);
+    __FLOG_VA((_L8("Connection state set to 0x%08X"), iState));
+    __FLOG(_L8("SetSuspendState - Exit"));
+    }
+    
+/**
+This method is called when EUsbcDeviceStateAddress state is reached. 
+It sets the transport packet size based on the host type the device is
+connected to.
+*/
+void CMTPUsbConnection::SetTransportPacketSizeL()
+	{
+	__FLOG(_L8("SetTransportPacketSizeL - Entry"));
+	if(iLdd.CurrentlyUsingHighSpeed())
+		{
+		__FLOG(_L8("HS USB connection"));
+		iEndpoints[EMTPUsbEpControl]->SetMaxPacketSizeL(KMaxPacketTypeControlHS);
+		iEndpoints[EMTPUsbEpBulkIn]->SetMaxPacketSizeL(KMaxPacketTypeBulkHS);
+		iEndpoints[EMTPUsbEpBulkOut]->SetMaxPacketSizeL(KMaxPacketTypeBulkHS);
+		}
+	else
+		{
+		__FLOG(_L8("FS USB connection"));
+		iEndpoints[EMTPUsbEpControl]->SetMaxPacketSizeL(KMaxPacketTypeControlFS);
+		iEndpoints[EMTPUsbEpBulkIn]->SetMaxPacketSizeL(KMaxPacketTypeBulkFS);
+		iEndpoints[EMTPUsbEpBulkOut]->SetMaxPacketSizeL(KMaxPacketTypeBulkFS);
+		}		
+	iEndpoints[EMTPUsbEpInterrupt]->SetMaxPacketSizeL(KMaxPacketTypeInterrupt);
+	
+	__FLOG(_L8("SetTransportPacketSizeL - Exit"));
+	}
+
+TBool CMTPUsbConnection::IsEpStalled(const TUint& aEpNumber)
+    {
+    const TEndpointNumber number( static_cast<TEndpointNumber>(aEpNumber) );
+    TEndpointState state;
+    iLdd.EndpointStatus(number, state);
+    return ( EEndpointStateStalled == state );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1087 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "cmtpusbconnection.h"
+#include "cmtpusbepbase.h"
+#include "mtpusbpanic.h"
+#include "cmtpusbcontainer.h"
+#include "mtpbuildoptions.hrh"
+#include "mtpusbprotocolconstants.h"
+#include <e32debug.h>
+
+const TUint KUSBHeaderSize = 12;
+#define UNUSED_VAR(a) (a)=(a)
+
+/**
+Destructor
+*/
+CMTPUsbEpBase::~CMTPUsbEpBase()
+    {
+    __FLOG(_L8("CMTPUsbEpBase::~CMTPUsbEpBase - Entry"));
+    Cancel();
+    iPacketBuffer.Close();
+    __FLOG(_L8("CMTPUsbEpBase::~CMTPUsbEpBase - Exit"));
+    __FLOG_CLOSE;
+    }
+    
+/**
+Provides the logical endpoint number of the endpoint.
+@return The logical endpoint number. 
+*/
+TEndpointNumber CMTPUsbEpBase::EndpointNumber() const
+    {
+    return iConnection.EndpointNumber(iId);
+    }
+    
+/**
+Provides the internal endpoint identifier of the endpoint.
+@return The internal endpoint identifier. 
+*/
+TUint CMTPUsbEpBase::Id() const
+    {
+    return iId;
+    }
+
+/**
+Constructor
+@param aId The internal endpoint identifier of the endpoint.
+@param aPriority the priority of the active object assigned. 
+@param aConnection MTP USB device class transport connection which controls 
+the endpoint.
+*/
+CMTPUsbEpBase::CMTPUsbEpBase(TUint aId, TPriority aPriority, CMTPUsbConnection& aConnection) :
+    CActive(aPriority),
+    iId(aId),
+    iReceiveChunkData(NULL, 0),
+    iReceiveData(NULL, 0),
+    iSendChunkData(NULL, 0),
+    iSendData(NULL, 0),
+    iIsFirstChunk(EFalse), 
+    iConnection(aConnection)
+    {
+    CActiveScheduler::Add(this);
+    }
+    
+/**
+Second phase constructor.
+*/
+#ifdef __FLOG_ACTIVE    
+void CMTPUsbEpBase::ConstructL(const TDesC8& aComponentName)
+#else
+void CMTPUsbEpBase::ConstructL()
+#endif
+    {
+    __FLOG_OPEN(KMTPSubsystem, aComponentName);
+    __FLOG(_L8("CMTPUsbEpBase::ConstructL - Entry"));
+    __FLOG(_L8("CMTPUsbEpBase::ConstructL - Exit"));
+    }
+    
+/**
+Sets the MaxPacketSize for the endpoint.
+@param aSize The maximum packet size.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbEpBase::SetMaxPacketSizeL(TUint aSize)
+	{
+	__FLOG(_L8("CMTPUsbEpBase::SetMaxPacketSizeL - Entry"));
+	iPacketSizeMax = aSize;
+	__FLOG_VA((_L8("Endpoint %d maximum packetsize = %u"), iId, iPacketSizeMax));
+	// Allocate the packet buffer.
+    iPacketBuffer.ReAllocL(iPacketSizeMax);
+    __FLOG(_L8("CMTPUsbEpBase::SetMaxPacketSizeL - Exit"));
+	}    
+
+/**
+Creates a stall condition on the endpoint.
+*/  
+void CMTPUsbEpBase::Stall()
+    {
+    __FLOG(_L8("CMTPUsbEpBase::Stall - Entry"));
+    __FLOG_VA((_L8("CMTPUsbEpBase state on entry = 0x%08X"), iState));
+    Cancel();
+    RDevUsbcClient& ldd(Connection().Ldd());
+    const TEndpointNumber number(EndpointNumber());
+    TEndpointState state;
+    ldd.EndpointStatus(number, state);
+    __FLOG_VA((_L8("EndpointStatus = %d"), state));
+    if (state != EEndpointStateStalled)
+        {
+        __FLOG_VA((_L8("Halting endpoint = %d"), number));
+        ldd.HaltEndpoint(number);
+        }
+    SetStreamState(EStalled);
+    __FLOG(_L8("CMTPUsbEpBase::Stall - Exit"));
+    }
+
+/**
+Clears a stall condition on the endpoint.
+*/    
+void CMTPUsbEpBase::StallClear()
+    {
+    __FLOG(_L8("CMTPUsbEpBase::StallClear - Entry"));
+    __FLOG_VA((_L8("CMTPUsbEpBase state on entry = 0x%08X"), iState));
+    RDevUsbcClient& ldd(Connection().Ldd());
+    const TEndpointNumber number(EndpointNumber());
+    TEndpointState state;
+    ldd.EndpointStatus(number, state);
+    __FLOG_VA((_L8("EndpointStatus = %d"), state));
+    if (state != EEndpointStateNotStalled)
+        {
+        __FLOG_VA((_L8("Clearing halt on endpoint = %d"), number));
+        Connection().Ldd().ClearHaltEndpoint(number);
+        }
+    SetStreamState(EIdle);
+    __FLOG(_L8("CMTPUsbEpBase::StallClear - Exit"));
+    }
+
+/**
+Indicates whether the endpoint is currently in a stalled condition.
+@return ETrue if the endpoint is in a stalled condition, otherwise EFalse.
+*/
+TBool CMTPUsbEpBase::Stalled() const
+    {
+    return (iState == EStalled);
+    }
+
+/**
+Determines the relative order of the two endpoints based on their IDs. 
+@return Zero, if the two objects are equal; a negative value, if the first 
+endpoint's ID is less than the second, or; a positive value, if the first 
+endpoint's ID is greater than the second.
+*/    
+TInt CMTPUsbEpBase::LinearOrder(const CMTPUsbEpBase& aL, const CMTPUsbEpBase& aR)
+    {
+    return (aL.iId - aR.iId);
+    }
+    
+/**
+Provides the MTP USB device class transport connection which controls the 
+endpoint.
+@return The MTP USB device class transport connection. 
+*/
+CMTPUsbConnection& CMTPUsbEpBase::Connection() const
+    {
+    return iConnection;
+    }
+
+/**
+Forces the completion of a transfer in progress. This will
+reset the data streams without having to stall the endpoints.
+
+This is needed because Windows does not expect endpoints to 
+stall on error conditions.
+
+@param aReason error code describing the reason for cancelling.
+@leave Any of the system wide error codes.
+*/
+
+void CMTPUsbEpBase::CancelReceiveL(TInt aReason)
+	{
+	__FLOG(_L8("CMTPUsbEpBase::CancelReceiveL - Entry"));
+     
+    if (DataStreamDirection() == EReceivingState)
+	    {
+		__FLOG(_L8("Cancel in EReceivingState"));            
+	    // Cancel any outstanding request.
+    	Cancel();  
+
+        // Notify the connection and reset the receive data stream.
+        ResetReceiveDataStream();
+        ReceiveDataCompleteL(aReason, *iReceiveDataSink);
+        // Flush incoming data, otherwise device and PC may get out of sync
+        FlushRxDataL();
+	    }
+	    
+    __FLOG(_L8("CMTPUsbEpBase::CancelReceiveL - Exit"));	
+	}
+
+/**
+Forces the completion of a transfer in progress. This will
+reset the data streams without having to stall the endpoints.
+
+This is needed because Windows does not expect endpoints to 
+stall on error conditions.
+
+@param aReason error code describing the reason for cancelling.
+@leave Any of the system wide error codes.
+*/
+
+void CMTPUsbEpBase::CancelSendL(TInt aReason)
+	{
+	__FLOG(_L8("CMTPUsbEpBase::CancelSendL - Entry"));
+    
+	if (DataStreamDirection() == ESendingState)
+		{
+ 		__FLOG(_L8("Cancel in ESendingState"));
+ 		// Cancel any outstanding request.
+    	Cancel();  
+        // Notify the connection and reset the send data stream.
+        ResetSendDataStream();
+        SendDataCompleteL(aReason, *iSendDataSource);
+		}
+		
+	__FLOG(_L8("CMTPUsbEpBase::CancelSendL - Exit"));
+	}
+
+/**
+Initiates an asynchronous data receive sequence. 
+@param aSink The receive data sink buffer.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbEpBase::ReceiveDataL(MMTPType& aSink)
+    {
+    __FLOG(_L8("CMTPUsbEpBase::ReceiveDataL - Entry"));
+    __FLOG_VA((_L8("CMTPUsbEpBase state on entry = 0x%08X"), iState));
+    if(iState != EIdle)
+      {
+    	Cancel();
+      }
+    
+
+    __ASSERT_DEBUG(iState == EIdle, Panic(EMTPUsbBadState));
+    
+    iReceiveDataSink    = &aSink;
+    iReceiveDataCommit  = iReceiveDataSink->CommitRequired();
+    SetStreamState(EReceiveInitialising);
+    InitiateFirstChunkReceiveL(); 
+        
+    __FLOG_VA((_L8("CMTPUsbEpBase state on exit = 0x%08X"), iState));
+    __FLOG(_L8("CMTPUsbEpBase::ReceiveDataL - Exit")); 
+    }
+
+/**
+Resumes a halted data receive sequence.
+@param aSink The receive data sink buffer.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+
+void CMTPUsbEpBase::ResumeReceiveDataL(MMTPType& aSink)
+	{
+	__FLOG(_L8("CMTPUsbEpBase::ResumeReceiveDataL - Entry"));
+    __FLOG_VA((_L8("CMTPUsbEpBase state on entry = 0x%08X"), iState));
+    __ASSERT_DEBUG(iState == EIdle, Panic(EMTPUsbBadState));
+    
+    iReceiveDataSink    = &aSink;
+    iReceiveDataCommit  = iReceiveDataSink->CommitRequired();
+    
+    iChunkStatus = iReceiveDataSink->NextWriteChunk(iReceiveChunkData);
+    // The first chunk is going to be read.
+    iReceiveData.Set(iReceiveChunkData);
+    __FLOG_VA((_L8("Issuing ReadUntilShort request on endpoint %d"), EndpointNumber()));
+    __FLOG_VA((_L8("Receive chunk capacity = %d bytes, length = %d bytes"), iReceiveChunkData.MaxLength(), iReceiveChunkData.Length()));
+    __FLOG_VA((_L8("Chunk status = %d"), iChunkStatus)); 
+    Connection().Ldd().ReadUntilShort(iStatus, EndpointNumber(), iReceiveData);
+    SetStreamState(EReceiveInProgress);
+    SetActive();
+    __FLOG(_L8("CMTPUsbEpBase::ResumeReceiveDataL - Exit")); 
+	}
+
+/**
+Signals the data transfer controller that an asynchronous data receive 
+sequence has completed.
+@leave One of the system wide error codes, if a processing failure occurs.
+@panic MTPUsb 2 In debug builds only, if the derived class has not fully 
+implemented the receive data path.
+*/
+void CMTPUsbEpBase::ReceiveDataCompleteL(TInt /*aError*/, MMTPType& /*aSink*/)
+    {
+    __FLOG(_L8("CMTPUsbEpBase::ReceiveDataCompleteL - Entry"));
+    __DEBUG_ONLY(Panic(EMTPUsbNotSupported));
+    __FLOG(_L8("CMTPUsbEpBase::ReceiveDataCompleteL - Exit"));
+    }
+
+/**
+Initiates an asynchronous data send sequence. 
+@param aSource The send data source buffer.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbEpBase::SendDataL(const MMTPType& aSource)
+    {
+    __FLOG(_L8("CMTPUsbEpBase::SendDataL - Entry"));
+    __FLOG_VA((_L8("CMTPUsbEpBase state on entry = 0x%08X"), iState));
+    __ASSERT_DEBUG(iState == EIdle, Panic(EMTPUsbBadState));
+    
+    iSendDataSource = &aSource;
+    SetStreamState(ESendInitialising);
+    ProcessSendDataStreamL();
+        
+    __FLOG_VA((_L8("CMTPUsbEpBase state on exit = 0x%08X"), iState));
+    __FLOG(_L8("CMTPUsbEpBase::SendDataL - Exit"));
+    }
+
+/**
+Signals tthe data transfer controller that an asynchronous data send sequence 
+has completed.
+@leave One of the system wide error codes, if a processing failure occurs.
+@panic MTPUsb 2 In debug builds only, if the derived class has not fully 
+implemented the send data path.
+*/
+void CMTPUsbEpBase::SendDataCompleteL(TInt /*aError*/, const MMTPType& /*aSource*/)
+    {
+    __FLOG(_L8("CMTPUsbEpBase::SendDataCompleteL - Entry"));
+    __DEBUG_ONLY(Panic(EMTPUsbNotSupported));
+    __FLOG(_L8("CMTPUsbEpBase::SendDataCompleteL - Exit"));
+    }
+
+void CMTPUsbEpBase::DoCancel()
+    {
+    __FLOG(_L8("CMTPUsbEpBase::DoCancel - Entry"));
+    __FLOG_VA((_L8("CMTPUsbEpBase state on entry = 0x%08X"), iState));
+    switch (iState & EStateDirection)
+        {
+    case EReceivingState:
+        __FLOG_VA((_L8("Issuing ReadCancel on endpoint %d"), EndpointNumber()));
+        Connection().Ldd().ReadCancel(EndpointNumber());
+        ResetReceiveDataStream();
+        break;
+
+    case ESendingState:    
+        __FLOG_VA((_L8("Issuing WriteCancel on endpoint %d"), EndpointNumber()));
+        Connection().Ldd().WriteCancel(EndpointNumber());
+        ResetSendDataStream();
+        break;
+
+    default:
+        break;
+        }
+    __FLOG(_L8("CMTPUsbEpBase::DoCancel - Exit"));
+    }
+    
+TInt CMTPUsbEpBase::RunError(TInt aError)
+    {
+    __FLOG(_L8("CMTPUsbEpBase::RunError - Entry"));
+    __FLOG_VA((_L8("Error = %d"), aError));  
+    
+    // Cancel any outstanding request.
+    Cancel();  
+    
+    // Notify the protocol layer of the error.
+    TInt32 streamDirection = DataStreamDirection();
+    if (streamDirection == EReceivingState)
+	    {
+		__FLOG(_L8("Error in EReceivingState"));            
+        // Notify the connection and reset the receive data stream.
+        MMTPType& data(*iReceiveDataSink);
+        ResetReceiveDataStream();
+        TRAPD(err, ReceiveDataCompleteL(aError, data));
+        UNUSED_VAR(err);
+	    }
+	else if (streamDirection == ESendingState)
+		{
+		__FLOG(_L8("Error in ESendingState"));
+        // Notify the connection and reset the send data stream.
+        const MMTPType& data(*iSendDataSource);
+        ResetSendDataStream();
+        TRAPD(err, SendDataCompleteL(aError, data));
+        UNUSED_VAR(err);
+		}
+	    
+    __FLOG(_L8("CMTPUsbEpBase::RunError - Exit"));
+    return KErrNone;
+    }
+
+void CMTPUsbEpBase::RunL()
+    {
+    __FLOG(_L8("CMTPUsbEpBase::RunL - Entry"));
+    __FLOG_VA((_L8("Current endpoint is %d"), EndpointNumber()));
+    __FLOG_VA((_L8("CMTPUsbEpBase state on entry = 0x%08X"), iState));
+    
+    switch (DataStreamDirection())
+        {
+    case EReceivingState:
+        __FLOG_VA((_L8("Receive data completion status = %d"), iStatus.Int()));
+        if (iStatus != KErrNone)
+            {
+            // Abnormal completion.
+            SetStreamState(EReceiveComplete);
+            }
+        else
+            {
+            // Reissue the request if we got a null packet because the upper layers are not 
+        	// interested in null packets.
+        	if ((iReceiveData.Length() == 0) && (iReceiveData.MaxLength() > 0))
+        		{
+        		Connection().Ldd().ReadUntilShort(iStatus, EndpointNumber(), iReceiveData);
+        		SetActive();
+        		return;
+        		}  
+            // Update the chunk data length.
+            iReceiveChunkData.SetLength(iReceiveChunkData.Length() + iReceiveData.Length());
+            if (iIsFirstChunk)
+	            {
+	            // process the first chunk.
+	            ProcessFirstReceivedChunkL();  
+	            }
+	        else
+		        {
+		        ResumeReceiveDataStreamL(); 
+		        }
+            }
+            
+        if (iState == EReceiveComplete)
+            {
+            // Reset the receive data stream and notify the connection.
+            MMTPType& data(*iReceiveDataSink);
+            ResetReceiveDataStream();
+            ReceiveDataCompleteL(iStatus.Int(), data);
+            }
+        break;
+        
+    case ESendingState:   
+        __FLOG_VA((_L8("Send data stream completion status = %d"), iStatus.Int())); 
+        if (iStatus != KErrNone)
+            {
+            // Abnormal completion.
+            SetStreamState(ESendComplete);
+            }
+        else
+            {
+            ProcessSendDataStreamL(); 
+            }
+            
+        if (iState == ESendComplete)
+            {
+            // Reset the send data stream and notify the connection.
+            const MMTPType& data(*iSendDataSource);
+            ResetSendDataStream();
+            SendDataCompleteL(iStatus.Int(), data);
+            }
+        break;
+        
+    default:
+        __FLOG_VA((_L8("Invalid data stream state, status = %d"), iStatus.Int())); 
+        Panic(EMTPUsbBadState);
+        break;
+        }
+        
+    __FLOG_VA((_L8("IsActive = %d"), IsActive()));
+    __FLOG(_L8("CMTPUsbEpBase::RunL - Exit"));
+    }
+
+/**
+Provides the current data stream direction.
+@return The current data stream direction (EIdle, EReceivingState, or 
+ESendingState).
+@see TState.
+*/
+TInt32 CMTPUsbEpBase::DataStreamDirection() const
+    {
+    return (iState & EStateDirection);
+    }
+
+/**
+Resets the receive data stream by clearing all receive buffer pointers and
+setting the stream state to EIdle.
+*/    
+void CMTPUsbEpBase::ResetReceiveDataStream()
+    {
+	__FLOG(_L8("CMTPUsbEpBase::ResetReceiveDataStream - Entry"));
+    iReceiveChunkData.Set(NULL, 0, 0);
+    iReceiveData.Set(NULL, 0, 0);
+    iReceiveDataSink = NULL;
+    SetStreamState(EIdle);
+	__FLOG(_L8("CMTPUsbEpBase::ResetReceiveDataStream - Exit"));
+    }
+
+/**
+Resets the receive data stream by clearing all receive buffer pointers and
+setting the stream state to EIdle.
+*/    
+void CMTPUsbEpBase::ResetSendDataStream()
+    {
+	__FLOG(_L8("CMTPUsbEpBase::ResetSendDataStream - Entry"));
+    iSendChunkData.Set(NULL, 0);
+    iSendData.Set(NULL, 0);
+    iSendDataSource = NULL;
+    SetStreamState(EIdle);
+	__FLOG(_L8("CMTPUsbEpBase::ResetSendDataStream - Exit"));
+    }
+    
+/**
+This method verify if the received first chunk data is a valid
+USB header for BulkOut EP.
+@pre this method should only be called after the USB header is received.
+@return ETrue if the received first chunk data is a vaild USB header, otherwise EFalse.
+*/
+TBool CMTPUsbEpBase::ValidateUSBHeaderL()
+	{	
+	__FLOG(_L8("CMTPUsbEpBase::ValidateUSBHeader - Entry"));
+	
+	TBool result(EFalse);
+	TUint16 containerType(Connection().BulkContainer().Uint16L(CMTPUsbContainer::EContainerType));
+	iDataLength = Connection().BulkContainer().Uint32L(CMTPUsbContainer::EContainerLength);
+	
+	//Due to an issue of Windows OS, the value of CMTPUsbContainer::EContainerLength is incorrect if the
+	//object >= 4G-12. The value should be KMaxTUint32 in this kind of cases, but in current Windows
+	//implementation it will be a value between 0 and 11.
+	//Here we reset the iDateLength to the actual size of iReceiveDataSink as a walkaround.
+	if(containerType == 2 && (iDataLength <= 11 || iDataLength == KMaxTUint32))
+		{
+		__FLOG(_L8("iDataLength <= 11, change to size of receive data sink"));			
+		iDataLength = iReceiveDataSink->Size();
+		}
+	
+	__FLOG_VA((_L8("containerType = %u , dataLength = %lu bytes"), containerType, iDataLength));
+	
+	if (iDataLength >= KUSBHeaderSize && 
+		(containerType == EMTPUsbContainerTypeCommandBlock || containerType == EMTPUsbContainerTypeDataBlock))
+		{
+		result = ETrue;
+		iDataCounter = 0;
+#ifdef _DEBUG
+ 		RDebug::Print(_L("Find the valid usb header------------------------------------------------------\n"));
+ 		TUint16 code(Connection().BulkContainer().Uint16L(CMTPUsbContainer::ECode));
+ 		TUint32 transactionID(Connection().BulkContainer().Uint32L(CMTPUsbContainer::ETransactionID));
+ 		RDebug::Print(_L("ContainerLength = 0x%x, containerType = 0x%x , code = 0x%x , transactionID = 0x%x "),  iDataLength, containerType, code, transactionID);
+ 		}
+ 	else
+ 		{
+ 		RDebug::Print(_L("inValid usb Header read..........................................................."));
+#endif
+ 		}
+	__FLOG(_L8("CMTPUsbEpBase::ValidateUSBHeader - Exit"));
+	return result;
+	}
+
+/**
+Initiates the first chunk received data.
+*/
+void CMTPUsbEpBase::InitiateFirstChunkReceiveL()
+	{
+	__FLOG(_L8("CMTPUsbEpBase::InitiateFirstChunkReceiveL - Entry"));
+	
+	__FLOG(_L8("Fetching first write data chunk"));
+    iChunkStatus = iReceiveDataSink->FirstWriteChunk(iReceiveChunkData);
+    // The first chunk is going to be read.
+    iIsFirstChunk = ETrue;
+    iReceiveData.Set(iReceiveChunkData);
+    __FLOG_VA((_L8("Issuing ReadUntilShort request on endpoint %d"), EndpointNumber()));
+    __FLOG_VA((_L8("Receive chunk capacity = %d bytes, length = %d bytes"), iReceiveChunkData.MaxLength(), iReceiveChunkData.Length()));
+    __FLOG_VA((_L8("Chunk status = %d"), iChunkStatus)); 
+    Connection().Ldd().ReadUntilShort(iStatus, EndpointNumber(), iReceiveData);
+    SetStreamState(EReceiveInProgress);
+    SetActive();
+    
+    __FLOG(_L8("Request issued"));
+	__FLOG(_L8("CMTPUsbEpBase::InitiateFirstChunkReceiveL - Exit"));
+	}
+	
+/**
+Processes the first received chunk data.
+*/
+void CMTPUsbEpBase::ProcessFirstReceivedChunkL()
+	{
+	__FLOG(_L8("CMTPUsbEpBase::ProcessFirstReceivedChunkL - Entry"));	
+	    
+    // Reset it back.
+    iIsFirstChunk = EFalse;
+        
+    if (iReceiveChunkData.MaxLength() == KUSBHeaderSize
+      && iReceiveChunkData.Length() == KUSBHeaderSize)
+	    {
+	    // USB header received from BulkOut EP.
+	    // USB Header validation
+	    if (!ValidateUSBHeaderL())
+		    {
+			// If device has received trash data, flush the rest of the packet and try again.
+  	  	 	// This will occur when cancelling a transfer and the PC sends buffered data after 
+  	  	 	// the cancellation.
+		    TRequestStatus status;
+  	  		do
+				{
+				// Keep looking for headers.
+				// The case we are trying to catch is when we have 12 garbage bytes followed by 12 good bytes.
+				// In this case the ReadOneOrMore is acting on the next packet rather than the current packet.
+				// If the garbage data is a multiple of 12 bytes, we should still be able to catch the next good
+				// header. Otherwise the ReadOneOrMore will return will <12 bytes and we will fall through
+				// to the retry code below. 
+				iReceiveData.Zero();
+				Connection().Ldd().ReadOneOrMore(status, EndpointNumber(), iReceiveData, KUSBHeaderSize);
+				User::WaitForRequest(status);
+				} while (iReceiveData.Length()==KUSBHeaderSize && !ValidateUSBHeaderL());
+
+			if(!ValidateUSBHeaderL())
+				{ 
+				InitiateFirstChunkReceiveL();  
+				return;
+				}
+			}
+			
+		if ((iDataLength - KUSBHeaderSize) == 0)
+			{
+			// only USB header.
+			SetStreamState(EReceiveComplete);
+			}	        
+	    }
+     else if (iReceiveChunkData.MaxLength() == iReceiveChunkData.Length())
+		{
+		// USB Control request setup or data packet is received from Control EP.		    		    		    
+	    // All the desired data should be received. 
+		SetStreamState(EReceiveComplete);			
+		}
+		
+	__FLOG_VA((_L8("CMTPUsbEpBase state = 0x%08X"), iState));
+	
+	if (iState == EReceiveComplete)
+		{
+		// All data is received just using the first chunk. It could be a USB Command block without parameters
+		// or USB control request setup or data. 
+		__FLOG_VA((_L8("Received = %d bytes, write data chunk capacity = %d bytes"), iReceiveChunkData.Length(), iReceiveChunkData.MaxLength()));
+		
+#ifdef MTP_DEBUG_FLOG_HEX_DUMP 
+        __FLOG_HEXDUMP((iReceiveChunkData, _L8("Received data ")));
+#endif
+
+		// Commit the received data if required.
+        if (iReceiveDataCommit)
+		    {
+		 	__FLOG(_L8("Commiting write data chunk"));
+	        iReceiveDataSink->CommitChunkL(iReceiveChunkData);       
+		    }
+		}
+	// Receive more data.
+	else
+		{
+		ResumeReceiveDataStreamL();
+		}
+	
+	__FLOG(_L8("CMTPUsbEpBase::ProcessFirstReceivedChunkL - Exit"));
+	}
+
+/**
+Implements the receive data streaming algorithm. It is called after the first chunk data is received provided
+there is still more data to be received. 
+*/
+void CMTPUsbEpBase::ResumeReceiveDataStreamL()
+    {
+    __FLOG(_L8("CMTPUsbEpBase::ResumeReceiveDataStreamL - Entry"));
+    __FLOG_VA((_L8("CMTPUsbEpBase state on entry = 0x%08X"), iState));
+    TBool endStream(EFalse);
+	TBool lastChunkCommited(EFalse);
+	TBool nullPacketReceived(EFalse);
+	MMTPType *needCommit = NULL;
+    // Process the received chunk (if any).
+   	iDataCounter += iReceiveData.Length();
+   	__FLOG_VA((_L8("iDataLength = %lu bytes"), iDataLength));
+   	__FLOG_VA((_L8("iDataCounter = %lu bytes"), iDataCounter));   	
+   	
+   	if (iDataCounter == iDataLength)
+	   	{
+	   	endStream = ETrue;
+        nullPacketReceived = ((iState == EReceiveCompleting) && (iReceiveData.Length() == 0));
+	   	}
+
+    __FLOG_VA((_L8("Received = %d bytes, write data chunk capacity = %d bytes"), iReceiveChunkData.Length(), iReceiveChunkData.MaxLength()));		   
+#ifdef MTP_DEBUG_FLOG_HEX_DUMP 
+    __FLOG_HEXDUMP((iReceiveChunkData, _L8("Received data ")));
+#endif
+    __FLOG_VA((_L8("End of stream = %d"), endStream)); 		   
+        
+      // Commit the received data if required.
+	if (iReceiveDataCommit)
+         {
+         if ((iChunkStatus != KMTPChunkSequenceCompletion)
+       		&& !endStream
+          	&& (iReceiveChunkData.Length() == iReceiveChunkData.MaxLength()))
+	           {
+	           	// Two cases are covered here:
+	           	// 1. MTP file receiving: MTP type file never returns KMTPChunkSequenceCompletion,It can be received        
+          		//    one part after another. Also it can be commited mutiple times.
+            	// 2. Other MTP datatype receiving during the middle of data stream
+	           __FLOG(_L8("Commiting write data chunk"));
+	           needCommit = iReceiveDataSink->CommitChunkL(iReceiveChunkData);
+	           lastChunkCommited = ETrue;   
+	           }
+		else if ((iChunkStatus != KMTPChunkSequenceCompletion)
+	        	&& endStream
+	        	&& !nullPacketReceived)
+		      {
+		      // It should be the end of MTP type file receiving since it never returns KMTPChunkSequenceCompletion.
+	 	      // it can be commited mutiple times.
+		      __FLOG(_L8("Commiting write data chunk"));
+		      needCommit = iReceiveDataSink->CommitChunkL(iReceiveChunkData);
+		      }
+		else if ((iChunkStatus == KMTPChunkSequenceCompletion)
+	        	&& endStream
+	        	&& !nullPacketReceived)
+		      {
+		      // The last chunk data which type is any other MTP data type than MTP file type. 
+		      // It will not be commited until all the chunk data is received.
+		      __FLOG(_L8("Commiting write data chunk"));
+		      needCommit = iReceiveDataSink->CommitChunkL(iReceiveChunkData); 
+		      }          
+         }  
+
+    // Fetch the next read data chunk.  
+    switch (iState)
+        {
+    case EReceiveInProgress:
+    	if (iReceiveDataCommit) // Commiting the received data is required 
+		    {
+		    if (lastChunkCommited)
+			    {
+			    __FLOG(_L8("Fetching next write data chunk"));
+	    	 	iChunkStatus = iReceiveDataSink->NextWriteChunk(iReceiveChunkData, iDataLength - KUSBHeaderSize);
+			    }
+		    }
+		else
+			{
+			__FLOG(_L8("Fetching next write data chunk"));
+    	 	iChunkStatus = iReceiveDataSink->NextWriteChunk(iReceiveChunkData, iDataLength - KUSBHeaderSize);	
+			}	         		    					      
+        break;
+        
+    case EReceiveCompleting:
+        __FLOG(_L8("Write data chunk sequence completing"));
+        __FLOG_VA((_L8("Null packet received = %d"), nullPacketReceived)); 
+        break;
+                  
+    case EIdle:
+    default:
+        __FLOG(_L8("Invalid receive data stream state"));
+        Panic(EMTPUsbBadState);
+        break;
+        }
+    __FLOG_VA((_L8("Chunk status = %d"), iChunkStatus)); 
+        
+    // Update the data stream state.
+    switch (iChunkStatus)
+        {
+    case KErrNone:
+        if (endStream)
+            {
+            __FLOG(_L8("Terminating packet received."));
+            SetStreamState(EReceiveComplete);
+            }
+        else
+            {
+            // Full (intermediate) packet data received.
+            SetStreamState(EReceiveInProgress);
+            }
+        break;
+        
+    case KMTPChunkSequenceCompletion:
+
+        if (endStream)
+            {
+            __FLOG(_L8("Terminating packet received."));
+            SetStreamState(EReceiveComplete);
+            }
+        else
+            {           
+            // Processing the last received data chunk.
+            // It will be processed once or mutiple times. 
+            SetStreamState(EReceiveCompleting);            
+            }
+        break;
+        
+    default:
+        User::Leave(iChunkStatus);
+        break;
+        } 
+        
+    // If necessary, process the next chunk. 
+    if (iState != EReceiveComplete)
+        {
+        __FLOG_VA((_L8("Issuing ReadUntilShort request on endpoint %d"), EndpointNumber()));
+        __FLOG_VA((_L8("Receive chunk capacity = %d bytes, length = %d bytes"), iReceiveChunkData.MaxLength(), iReceiveChunkData.Length()));
+        __FLOG_VA((_L8("iReceiveChunkData pointer address is %08x"), iReceiveChunkData.Ptr()));
+        // TDesC8's Right() method is not used here, because the parameter passed in like iReceiveChunkData.MaxLength() - iReceiveChunkData.Length()is greater than 
+        // the length of the descriptor, the function extracts the whole of the descriptor.
+        if(iDataLength-iDataCounter < iReceiveChunkData.MaxLength() - iReceiveChunkData.Length())
+			{
+			iReceiveData.Set(const_cast<TUint8*>(iReceiveChunkData.Ptr() + iReceiveChunkData.Length()), 0, iDataLength - iDataCounter);
+			}
+		else
+			{
+			iReceiveData.Set(const_cast<TUint8*>(iReceiveChunkData.Ptr() + iReceiveChunkData.Length()), 0, iReceiveChunkData.MaxLength() - iReceiveChunkData.Length());
+			}  
+        Connection().Ldd().ReadUntilShort(iStatus, EndpointNumber(), iReceiveData);
+        SetActive();
+        if(needCommit != NULL)
+        	{
+        	TPtr8 tmp(NULL, 0, 0);
+        	needCommit->CommitChunkL(tmp);
+        	}
+        __FLOG(_L8("Request issued"));
+        }
+        
+    __FLOG_VA((_L8("CMTPUsbEpBase state on exit = 0x%08X"), iState));
+    __FLOG(_L8("CMTPUsbEpBase::ResumeReceiveDataStreamL - Exit"));
+    }
+    
+/**
+Implements the send data streaming algorithm. This algorithm regulates the 
+sequence of data chunks making up the send data stream to ensure that data is
+passed to the USB device interface in units of wMaxPacketSize integral length. 
+The algorithm attempts to avoid re-buffering unless absolutely necessary, as 
+follows:
+    1.  If the data chunk size is greater than or equal to the endpoint's 
+        wMaxPacketSize, then the maximum wMaxPacketSize integral data portion 
+        is sent directly. Any residual data is buffered in a wMaxPacketSize 
+        packet buffer.
+    2.  If the data chunk size is less than the endpoint's wMaxPacketSize, then
+        the data is buffered in the packet buffer. As soon as the packet buffer 
+        is filled it is sent.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbEpBase::ProcessSendDataStreamL()
+    {
+    __FLOG(_L8("CMTPUsbEpBase::ProcessSendDataStreamL - Entry"));
+    __FLOG_VA((_L8("CMTPUsbEpBase state on entry = 0x%08X"), iState));
+    
+    // Clear the send data stream data pointer.
+    iSendData.Set(KNullDesC8);
+    
+    TUint chunkAvailableLen(iSendChunkData.Length());
+    if (!chunkAvailableLen)
+        {    
+        // Fetch the next read data chunk. 
+        switch (iState)
+            {
+        case ESendInitialising:
+            __FLOG(_L8("Fetching first read data chunk"));
+            iChunkStatus = iSendDataSource->FirstReadChunk(iSendChunkData);
+            iPacketBuffer.Zero();
+            break;
+            
+        case ESendInProgress:
+            __FLOG(_L8("Fetching next read data chunk"));
+            iChunkStatus = iSendDataSource->NextReadChunk(iSendChunkData);
+            break;
+            
+        case ESendCompleting:
+            break;
+            
+        case EIdle:
+        default:
+            __FLOG(_L8("Invalid send data stream state"));
+            Panic(EMTPUsbBadState);
+            break;
+            }
+        
+        // Fetch the new chunk data size available.
+        chunkAvailableLen = iSendChunkData.Length();
+        
+        // Update data stream state.
+        switch (iChunkStatus)
+            {
+        case KErrNone:
+            SetStreamState(ESendInProgress);
+            break;
+            
+        case KMTPChunkSequenceCompletion:
+            if (iState == ESendCompleting)
+                {
+                SetStreamState(ESendComplete);
+                }
+            else
+                {
+                SetStreamState(ESendCompleting);
+                }
+            break;
+            
+        default:
+            User::Leave(iChunkStatus);
+            break;
+            }          
+        }
+        
+    __FLOG_VA((_L8("Chunk status = %d"), iChunkStatus));
+    
+    // Process the buffered residual and/or available chunk data.
+    TUint bufferedLen(iPacketBuffer.Length());
+    TUint chunkIntegralLen((chunkAvailableLen / iPacketSizeMax) * iPacketSizeMax);
+    TUint chunkResidualLen(chunkAvailableLen % iPacketSizeMax);
+    TBool zlp(EFalse);
+    __FLOG_VA((_L8("Buffered residual data = %u bytes"), bufferedLen));
+    __FLOG_VA((_L8("Chunk data available = %u bytes"), chunkAvailableLen));
+    __FLOG_VA((_L8("Chunk data packet integral portion = %u bytes"), chunkIntegralLen));
+    __FLOG_VA((_L8("Chunk data packet residual portion = %u bytes"), chunkResidualLen));
+    
+    if (bufferedLen)
+        {
+        // Data is buffered in the packet buffer. Fill the available packet buffer space.
+        if (chunkAvailableLen)
+            {
+            // Fill the packet buffer.
+            TUint consumedLen(0);
+            TUint unconsumedLen(0);
+            TUint capacity(iPacketBuffer.MaxLength() - iPacketBuffer.Length());
+            if (chunkAvailableLen > capacity)
+                {
+                consumedLen     = capacity;
+                unconsumedLen   = (chunkAvailableLen - consumedLen);              
+                }
+            else
+                {
+                consumedLen = chunkAvailableLen;
+                }
+            __FLOG_VA((_L8("Buffering %u bytes"), consumedLen));
+            iPacketBuffer.Append(iSendChunkData.Left(consumedLen));
+            
+            // Update the available chunk data to reflect only the unconsumed portion.
+            __FLOG_VA((_L8("Residual chunk data = %u bytes"), unconsumedLen));
+            if (unconsumedLen)
+                {
+                iSendChunkData.Set(iSendChunkData.Right(unconsumedLen));
+                }
+            else
+                {
+                iSendChunkData.Set(NULL, 0);                    
+                }
+            }
+        
+        // Send the packet buffer when full.
+        if ((iState == ESendCompleting) || (iPacketBuffer.Size() == iPacketBuffer.MaxSize()))
+            {
+            iSendData.Set(iPacketBuffer);
+            iPacketBuffer.Zero();
+            }
+        
+        // Set the end of stream flag.
+        zlp = ((iState == ESendCompleting) && (iSendChunkData.Length() == 0));
+        }
+    else if (iState == ESendInProgress)
+        {
+        // Send the chunk data packet integral portion.
+        if (chunkIntegralLen)
+            {
+            iSendData.Set(iSendChunkData.Left(chunkIntegralLen));   
+            }
+    
+        // Buffer the chunk data packet residual portion.
+        if (chunkResidualLen)
+            {
+            __FLOG_VA((_L8("Buffering %u bytes"), chunkResidualLen));
+            iPacketBuffer.Append(iSendChunkData.Right(chunkResidualLen));  
+            }
+            
+        // All data has been consumed and/or buffered.
+        iSendChunkData.Set(NULL, 0);
+        }
+    else if (iState == ESendCompleting)
+        {
+        // Send all available chunk data.
+        iSendData.Set(iSendChunkData);
+        zlp = ETrue;
+            
+        // All data has been consumed.
+        iSendChunkData.Set(NULL, 0);
+        }
+
+    // Send the available data or reschedule to process the next chunk.
+    TUint sendBytes(iSendData.Length());
+    if ( sendBytes||zlp )
+        {
+        __FLOG_VA((_L8("Issuing Write request on endpoint %d, Zlp = %d"), EndpointNumber(), zlp));
+        __FLOG_VA((_L8("Send data length = %d bytes"), iSendData.Length()));
+        Connection().Ldd().Write(iStatus, EndpointNumber(), iSendData, sendBytes, zlp);
+        SetActive(); 
+        __FLOG(_L8("Request issued"));
+        }
+    else if (iState != ESendComplete)
+        {    
+        iStatus = KRequestPending;
+        TRequestStatus* status = &iStatus;
+        SetActive();
+        User::RequestComplete(status, KErrNone);
+        }
+
+    __FLOG_VA((_L8("CMTPUsbEpBase state on exit = 0x%08X"), iState));
+    __FLOG(_L8("CMTPUsbEpBase::ProcessSendDataStreamL - Exit"));   
+    }
+
+/**
+Sets the data stream state variable.
+@param aState The new data stream state.
+*/
+void CMTPUsbEpBase::SetStreamState(TInt aState)
+    {
+    __FLOG(_L8("SetStreamState - Entry"));
+    iState = aState;
+    __FLOG_VA((_L8("Stream state set to 0x%08X"), iState));
+    __FLOG(_L8("SetStreamState - Exit"));
+    }
+
+// Fix so that cancelling works.
+/*
+ * Flush USB driver received data
+ * 
+ */
+const TInt KFlushBufferMaxLen = 50*1024; // 50K bytes
+#define INTERVAL_FOR_READ_TRASH_DATA   (1000*50)  // 50 Miliseconds
+#define INTERVAL_FOR_FLUSH_TRASH_DATA  (9*INTERVAL_FOR_READ_TRASH_DATA)  // 450 Miliseconds
+// if there is no data read in flushRxData, wait for 1.5 second at most in case forever waiting
+#define INTERVAL_FOR_FLUSH_TRASH_DATA_IF_NO_DATA_READ  (30*INTERVAL_FOR_READ_TRASH_DATA) //1.5 SECOND 
+
+void CMTPUsbEpBase::FlushRxDataL()
+    {
+    				  
+    // create the read buff
+    RBuf8 readBuf;
+    readBuf.CreateL(KFlushBufferMaxLen);
+		      
+    TUint32 uRestTimeToWait = INTERVAL_FOR_FLUSH_TRASH_DATA_IF_NO_DATA_READ;
+ 			      
+    do{
+ 			    	
+      // get the data size in the receive buffer ready to read
+      TInt nbytes = 0;
+      TInt err = Connection().Ldd().QueryReceiveBuffer(EndpointNumber(), nbytes);
+#ifdef _DEBUG
+      RDebug::Print(_L("FlushRxDataL()--1---err is %d , nbytes is %d"), err, nbytes);	  
+#endif
+ 					  
+      // has data, read it
+      if( (err == KErrNone) && (nbytes > 0) )
+         {
+   
+         // synchronously read the data
+         TRequestStatus status;
+         Connection().Ldd().ReadOneOrMore(status, EndpointNumber(), readBuf);
+         User::WaitForRequest(status);
+	 		 
+         if(status.Int() != KErrNone)  break;
+         			               
+         // whenever some data read, reset the rest wait time .
+         uRestTimeToWait = INTERVAL_FOR_FLUSH_TRASH_DATA;
+ 			               
+#ifdef _DEBUG 			               
+         RDebug::Print(_L("FlushRxDataL()---Reset the rest wait time"));	  
+#endif             
+         }
+       else 
+         {	
+         // wait for the data from the usb channel.
+         User::After(INTERVAL_FOR_READ_TRASH_DATA);
+         // reduce the rest time to wait 
+         uRestTimeToWait -=  INTERVAL_FOR_READ_TRASH_DATA ;
+         }	
+ 	  
+#ifdef _DEBUG 	  
+       RDebug::Print(_L("FlushRxDataL()---uRestTimeToWait is %d"), uRestTimeToWait);	  
+#endif
+ 			    	
+    }while( uRestTimeToWait > 0);
+			    	
+    readBuf.Close();
+ 
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbulkin.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,94 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <mtp/mmtptype.h>
+
+#include "cmtpusbconnection.h"
+#include "cmtpusbepbulkin.h"
+#include "mtpdebug.h"
+#include "mtpusbpanic.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"UsbEpBulkIn");)
+
+/**
+USB MTP device class bulk-in endpoint data transfer controller factory method.
+@param aId The internal endpoint identifier of the endpoint.
+@param aConnection USB MTP device class transport connection which controls 
+the endpoint.
+@return A pointer to an USB MTP device class bulk-in endpoint data transfer 
+controller. Ownership IS transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+CMTPUsbEpBulkIn* CMTPUsbEpBulkIn::NewL(TUint aId, CMTPUsbConnection& aConnection)
+    {
+    CMTPUsbEpBulkIn* self = new(ELeave) CMTPUsbEpBulkIn(aId, aConnection);
+    CleanupStack::PushL(self);
+    
+#ifdef __FLOG_ACTIVE    
+    self->ConstructL(KComponent);
+#else
+    self->ConstructL();
+#endif
+
+    CleanupStack::Pop(self);
+    return self;    
+    }
+    
+/**
+Destructor.
+*/
+CMTPUsbEpBulkIn::~CMTPUsbEpBulkIn()
+    {
+    __FLOG(_L8("~CMTPUsbEpBulkIn - Entry"));
+    __FLOG(_L8("~CMTPUsbEpBulkIn - Exit"));
+    }
+
+/**
+Initiates an asynchronous bulk data send sequence. 
+@param aData The bulk data source buffer.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbEpBulkIn::SendBulkDataL(const MMTPType& aData)
+    {
+    __FLOG(_L8("SendBulkDataL - Entry"));
+    // Pass the bulk data source buffer to the base class for processing.
+    SendDataL(aData);
+    __FLOG(_L8("SendBulkDataL - Exit"));
+    }
+    
+void CMTPUsbEpBulkIn::SendDataCompleteL(TInt aError, const MMTPType& aSource)
+    {
+    __FLOG(_L8("SendDataCompleteL - Entry"));
+    Connection().SendBulkDataCompleteL(aError, aSource);
+    __FLOG(_L8("SendDataCompleteL - Exit"));
+    }
+
+/**
+Constructor.
+@param aId The internal endpoint identifier of the endpoint.
+@param aConnection USB MTP device class transport connection which controls 
+the endpoint.
+*/
+CMTPUsbEpBulkIn::CMTPUsbEpBulkIn(TUint aId, CMTPUsbConnection& aConnection) :
+    CMTPUsbEpBase(aId, EPriorityStandard, aConnection)
+    {
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbulkout.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,93 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <mtp/mmtptype.h>
+
+#include "cmtpusbconnection.h"
+#include "cmtpusbepbulkout.h"
+#include "mtpdebug.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"UsbEpBulkOut");)
+
+/**
+USB MTP device class bulk-out endpoint data transfer controller factory method.
+@param aId The internal endpoint identifier of the endpoint.
+@param aConnection USB MTP device class transport connection which controls 
+the endpoint.
+@return A pointer to an USB MTP device class bulk-out endpoint data transfer 
+controller. Ownership IS transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+CMTPUsbEpBulkOut* CMTPUsbEpBulkOut::NewL(TUint aId, CMTPUsbConnection& aConnection)
+    {
+    CMTPUsbEpBulkOut* self = new(ELeave) CMTPUsbEpBulkOut(aId, aConnection);
+    CleanupStack::PushL(self);
+    
+#ifdef __FLOG_ACTIVE    
+    self->ConstructL(KComponent);
+#else
+    self->ConstructL();
+#endif
+
+    CleanupStack::Pop(self);
+    return self;    
+    }
+    
+/**
+Destructor.
+*/
+CMTPUsbEpBulkOut::~CMTPUsbEpBulkOut()
+    {
+    __FLOG(_L8("~CMTPUsbEpBulkOut - Entry"));
+    __FLOG(_L8("~CMTPUsbEpBulkOut - Exit"));
+    }
+
+/**
+Initiates an asynchronous generic bulk container dataset receive sequence. 
+@param aData The bulk data sink buffer.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbEpBulkOut::ReceiveBulkDataL(MMTPType& aData)
+    {
+    __FLOG(_L8("ReceiveBulkContainerL - Entry"));
+    // Pass the bulk data sink buffer to the base class for processing.
+    ReceiveDataL(aData);
+    __FLOG(_L8("ReceiveBulkContainerL - Exit"));  
+    }
+    
+void CMTPUsbEpBulkOut::ReceiveDataCompleteL(TInt aError, MMTPType& aSink)
+    {
+    __FLOG(_L8("ReceiveDataCompleteL - Entry"));
+    Connection().ReceiveBulkDataCompleteL(aError, aSink);
+    __FLOG(_L8("ReceiveDataCompleteL - Exit"));
+    }
+
+/**
+Constructor.
+@param aId The internal endpoint identifier of the endpoint.
+@param aConnection USB MTP device class transport connection which controls 
+the endpoint.
+*/
+CMTPUsbEpBulkOut::CMTPUsbEpBulkOut(TUint aId, CMTPUsbConnection& aConnection) :
+    CMTPUsbEpBase(aId, EPriorityStandard, aConnection)
+    {
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepcontrol.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,214 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "cmtpusbconnection.h"
+#include "cmtpusbepcontrol.h"
+#include "mtpusbpanic.h"
+#include "mtpusbtransportconstants.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"UsbEpControl");)
+
+/**
+USB MTP device class control endpoint data transfer controller factory method.
+@param aId The internal endpoint identifier of the endpoint.
+@param aConnection USB MTP device class transport connection which controls 
+the endpoint.
+@return A pointer to an USB MTP device class control endpoint data transfer 
+controller. Ownership IS transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+CMTPUsbEpControl* CMTPUsbEpControl::NewL(TUint aId, CMTPUsbConnection& aConnection)
+    {
+    CMTPUsbEpControl* self = new(ELeave) CMTPUsbEpControl(aId, aConnection);
+    CleanupStack::PushL(self);
+    
+#ifdef __FLOG_ACTIVE    
+    self->ConstructL(KComponent);
+#else
+    self->ConstructL();
+#endif
+
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+/**
+Destructor.
+*/
+CMTPUsbEpControl::~CMTPUsbEpControl()
+    {
+    __FLOG(_L8("~CMTPUsbEpControl - Entry"));
+    __FLOG(_L8("~CMTPUsbEpControl - Exit"));
+    }
+
+/**
+Initiates an USB MTP device class specific request data receive sequence.
+@param aData The control request data sink buffer.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbEpControl::ReceiveControlRequestDataL(MMTPType& aData)
+    {
+    __FLOG(_L8("ReceiveControlRequestDataL - Entry"));
+    __FLOG_VA((_L8("CMTPUsbEpControl state on entry = %d"), iState));
+    __ASSERT_DEBUG((iState == EControlRequestSetupComplete), Panic(EMTPUsbBadState));
+    
+    // Pass the bulk data sink buffer to the base class and update state..
+    ReceiveDataL(aData);
+    SetState(EControlRequestDataReceive);
+    
+    __FLOG_VA((_L8("CMTPUsbEpControl state on entry = %d"), iState));
+    __FLOG(_L8("ReceiveControlRequestDataL - Exit"));
+    }
+
+/**
+Initiates an USB MTP device class specific request request processing sequence.
+@param aData The control request setup data sink buffer.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbEpControl::ReceiveControlRequestSetupL(MMTPType& aData)
+    {
+    __FLOG(_L8("ReceiveControlRequestSetupL - Entry"));
+    __FLOG_VA((_L8("CMTPUsbEpControl state on entry = %d"), iState));
+    __ASSERT_DEBUG((iState == EIdle), Panic(EMTPUsbBadState));
+    
+    // Pass the bulk data sink buffer to the base class and update state.
+    ReceiveDataL(aData);
+    SetState(EControlRequestSetupPending);
+    
+    __FLOG_VA((_L8("CMTPUsbEpControl state on entry = %d"), iState));
+    __FLOG(_L8("ReceiveControlRequestSetupL - Exit"));
+    }
+
+/**
+Initiates an USB MTP device class specific request data send sequence.
+@param aData The control request data source buffer.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbEpControl::SendControlRequestDataL(const MMTPType& aData)
+    {
+    __FLOG(_L8("SendControlRequestDataL - Entry"));
+    __ASSERT_DEBUG((iState == EControlRequestSetupComplete), Panic(EMTPUsbBadState));
+    
+    // Pass the bulk data source buffer to the base class and update state.
+    SendDataL(aData);
+    SetState(EControlRequestDataSend);
+    
+    __FLOG(_L8("SendControlRequestDataL - Exit"));
+    }
+
+/**
+Concludes an USB MTP device class specific request request processing sequence.
+*/
+void CMTPUsbEpControl::SendControlRequestStatus()
+    {
+    __FLOG(_L8("SendControlRequestStatus - Entry"));
+    __FLOG_VA((_L8("CMTPUsbEpControl state on entry = %d"), iState));
+    __ASSERT_DEBUG(((iState == EControlRequestStatusSend) || (iState == EControlRequestSetupComplete)), Panic(EMTPUsbBadState));
+    TInt ret = Connection().Ldd().SendEp0StatusPacket();
+    __FLOG_VA((_L8("SendEp0StatusPacket result = %d."), ret));
+    SetState(EIdle);
+    __FLOG_VA((_L8("CMTPUsbEpControl state on exit = %d"), iState));
+    __FLOG(_L8("SendControlRequestStatus - Exit"));
+    }
+    
+void CMTPUsbEpControl::ReceiveDataCompleteL(TInt aError, MMTPType& aSink)
+    {
+    __FLOG(_L8("ReceiveDataCompleteL - Entry"));
+    __FLOG_VA((_L8("CMTPUsbEpControl state on entry = %d"), iState));
+    switch (iState)
+        {
+    case EControlRequestSetupPending:
+        SetState(EControlRequestSetupComplete);
+        Connection().ReceiveControlRequestSetupCompleteL(aError, aSink);
+        break;          
+        
+    case EControlRequestDataReceive:
+        SetState(EControlRequestStatusSend);
+        Connection().ReceiveControlRequestDataCompleteL(aError, aSink);
+        break;  
+    
+    case EIdle:
+    	// State will be EIdle if CancelReceive is called
+    	break;
+    	
+    case EControlRequestSetupComplete:
+    case EControlRequestDataSend:
+    case EControlRequestStatusSend:
+    default:
+        __DEBUG_ONLY(Panic(EMTPUsbBadState));
+        break;          
+        }
+    if(aError != KErrNone)
+	    {
+	    // Reset the internal state to idle.
+	    SetState(EIdle);
+	    }
+    __FLOG_VA((_L8("CMTPUsbEpControl state on exit = %d"), iState));
+    __FLOG(_L8("ReceiveDataCompleteL - Exit"));
+    }
+    
+void CMTPUsbEpControl::SendDataCompleteL(TInt aError, const MMTPType& aSource)
+    {
+    __FLOG(_L8("SendDataCompleteL - Entry"));
+    __FLOG_VA((_L8("CMTPUsbEpControl state on entry = %d"), iState));
+    __ASSERT_DEBUG((iState == EControlRequestDataSend), Panic(EMTPUsbBadState));
+    SetState(EIdle);
+    Connection().SendControlRequestDataCompleteL(aError, aSource);        
+    __FLOG_VA((_L8("CMTPUsbEpControl state on exit = %d"), iState));
+    __FLOG(_L8("SendDataCompleteL - Exit"));
+    }    
+    
+/**
+Constructor.
+@param aId The internal endpoint identifier of the endpoint.
+@param aConnection USB MTP device class transport connection which controls 
+the endpoint.
+*/
+CMTPUsbEpControl::CMTPUsbEpControl(TUint aId, CMTPUsbConnection& aConnection) :
+    CMTPUsbEpBase(aId, EPriorityStandard, aConnection)
+    {
+
+    }
+
+/**
+Sets the endpoint data send/receive state variable.
+@param aState The new data stream state.
+*/
+void CMTPUsbEpControl::SetState(TUint aState)
+    {
+    __FLOG(_L8("SetState - Entry"));
+    iState = aState;
+    __FLOG_VA((_L8("State set to %d"), iState));
+    __FLOG(_L8("SetState - Exit"));
+    }
+/**
+Overide this method derived from base class.
+reset the state.
+*/      
+void CMTPUsbEpControl::DoCancel()
+	{
+	__FLOG(_L8("DoCancel - Entry"));
+	CMTPUsbEpBase::DoCancel();
+	SetState(EIdle);
+	__FLOG(_L8("DoCancel - Exit"));
+	}
+	
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepinterruptin.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,96 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <mtp/mmtptype.h>
+
+#include "cmtpusbconnection.h"
+#include "cmtpusbepinterruptin.h"
+#include "mtpdebug.h"
+
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"UsbEpInterruptIn");)
+
+/**
+USB MTP device class interrupt endpoint data transfer controller factory 
+method.
+@param aId The internal endpoint identifier of the endpoint.
+@param aConnection USB MTP device class transport connection which controls 
+the endpoint.
+@return A pointer to an USB MTP device class interrupt endpoint data transfer 
+controller. Ownership IS transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+CMTPUsbEpInterruptIn* CMTPUsbEpInterruptIn::NewL(TUint aId, CMTPUsbConnection& aConnection)
+    {
+    CMTPUsbEpInterruptIn* self = new(ELeave) CMTPUsbEpInterruptIn(aId, aConnection);
+    CleanupStack::PushL(self);
+    
+#ifdef __FLOG_ACTIVE    
+    self->ConstructL(KComponent);
+#else
+    self->ConstructL();
+#endif
+
+    CleanupStack::Pop(self);
+    return self;    
+    }
+    
+/**
+Destructor.
+*/
+CMTPUsbEpInterruptIn::~CMTPUsbEpInterruptIn()
+    {
+    __FLOG(_L8("~CMTPUsbEpInterruptIn - Entry"));
+    __FLOG(_L8("~CMTPUsbEpInterruptIn - Exit"));
+    }
+
+/**
+Initiates an asynchronous interrupt data send sequence. 
+@param aData The interrupt data source buffer.
+@leave KErrNotSupported, if the data source buffer is comprised of more than 
+one data chunk.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+void CMTPUsbEpInterruptIn::SendInterruptDataL(const MMTPType& aData)
+    {
+    __FLOG(_L8("SendInterruptDataL - Entry"));
+    // Pass the bulk data source buffer to the base class for processing.
+    SendDataL(aData);
+    __FLOG(_L8("SendInterruptDataL - Exit"));
+    }
+    
+void CMTPUsbEpInterruptIn::SendDataCompleteL(TInt aError, const MMTPType& aData)
+    {
+    __FLOG(_L8("SendDataCompleteL - Entry"));
+    Connection().SendInterruptDataCompleteL(aError, aData);
+    __FLOG(_L8("SendDataCompleteL - Exit"));
+    }    
+
+/**
+Constructor.
+@param aId The internal endpoint identifier of the endpoint.
+@param aConnection USB MTP device class transport connection which controls 
+the endpoint.
+*/
+CMTPUsbEpInterruptIn::CMTPUsbEpInterruptIn(TUint aId, CMTPUsbConnection& aConnection) :
+    CMTPUsbEpBase(aId, EPriorityHigh, aConnection)
+    {
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepwatcher.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,124 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "cmtpusbconnection.h"
+#include "cmtpusbepwatcher.h"
+
+__FLOG_STMT(_LIT8(KComponent,"UsbEpWatcher");)
+
+/**
+USB MTP device class endpoint stall status observer factory method.
+@return A pointer to an USB MTP device class endpoint stall status 
+observer object. Ownership IS transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+CMTPUsbEpWatcher* CMTPUsbEpWatcher::NewL(CMTPUsbConnection& aConnection)
+    {
+    CMTPUsbEpWatcher* self = new (ELeave) CMTPUsbEpWatcher(aConnection);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+    
+/**
+Destructor.
+*/
+CMTPUsbEpWatcher::~CMTPUsbEpWatcher()
+    {
+    __FLOG(_L8("~CMTPUsbEpWatcher - Entry"));
+    Cancel();
+    __FLOG(_L8("~CMTPUsbEpWatcher - Exit"));
+    __FLOG_CLOSE;
+    }
+
+void CMTPUsbEpWatcher::Start()
+    {
+    __FLOG(_L8("Start - Entry"));
+    if (!IsActive())
+        {
+        RequestIssue();
+        }
+    __FLOG(_L8("Start - Exit"));
+    }
+    
+void CMTPUsbEpWatcher::Stop()
+    {
+    __FLOG(_L8("Stop - Entry"));
+    Cancel();
+    __FLOG(_L8("Stop - Exit"));
+    }
+    
+void CMTPUsbEpWatcher::DoCancel()
+    {
+    __FLOG(_L8("DoCancel - Entry"));    
+    RequestCancel();
+    __FLOG(_L8("DoCancel - Exit"));  
+    }
+    
+#ifdef __FLOG_ACTIVE
+TInt CMTPUsbEpWatcher::RunError(TInt aError)
+#else
+TInt CMTPUsbEpWatcher::RunError(TInt /*aError*/)
+#endif
+    {
+    __FLOG(_L8("RunError - Entry"));
+    __FLOG_VA((_L8("Error = %d"), aError));
+    __FLOG(_L8("RunError - Exit"));
+    RequestIssue();
+    return KErrNone;  
+    }
+    
+void CMTPUsbEpWatcher::RunL()
+    {
+    __FLOG(_L8("RunL - Entry"));
+    iConnection.EndpointStallStatusChangedL(iEndpointStatus);
+    RequestIssue();
+    __FLOG(_L8("RunL - Exit"));  
+    }
+
+CMTPUsbEpWatcher::CMTPUsbEpWatcher(CMTPUsbConnection& aConnection) :
+    CActive(EPriorityStandard),
+    iConnection(aConnection)
+    {
+    CActiveScheduler::Add(this);
+    }
+    
+void CMTPUsbEpWatcher::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry"));    
+    __FLOG(_L8("ConstructL - Exit")); 
+    }
+
+void CMTPUsbEpWatcher::RequestCancel()
+    {
+    __FLOG(_L8("RequestCancel - Entry"));    
+    iConnection.Ldd().EndpointStatusNotifyCancel();
+    __FLOG(_L8("RequestCancel - Exit")); 
+    }
+    
+void CMTPUsbEpWatcher::RequestIssue()
+    {
+    __FLOG(_L8("RequestIssue - Entry"));    
+    iConnection.Ldd().EndpointStatusNotify(iStatus, iEndpointStatus);
+    SetActive();
+    __FLOG(_L8("RequestIssue - Exit")); 
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbtransport.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,137 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <ecom/implementationproxy.h>
+
+#include "cmtpusbconnection.h"
+#include "cmtpusbtransport.h"
+#include "mmtpconnectionmgr.h"
+#include "mtpusbpanic.h"
+
+__FLOG_STMT(_LIT8(KComponent,"UsbTransport");)
+
+/**
+USB MTP device class transport plug-in factory method.
+@return A pointer to an MTP device class transport plug-in. Ownership IS 
+transfered.
+@leave One of the system wide error codes, if a processing failure occurs.
+*/
+TAny* CMTPUsbTransport::NewL(TAny* aParameter)
+    {
+    if ( aParameter != NULL )
+    	{
+    	User::Leave(KErrArgument);
+    	}
+    CMTPUsbTransport* self = new (ELeave) CMTPUsbTransport;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+    
+/**
+Destructor.
+*/
+CMTPUsbTransport::~CMTPUsbTransport()
+    {
+    __FLOG(_L8("~CMTPUsbTransport - Entry"));
+    delete iConnection;
+    __FLOG(_L8("~CMTPUsbTransport - Exit"));
+    __FLOG_CLOSE;
+    }
+    
+/**
+This method returns a refrence to CMTPUsbConnection object.
+@return a reference to CMTPUsbConnection object. 
+*/
+const CMTPUsbConnection& CMTPUsbTransport::MTPUsbConnection()
+    {
+    return *iConnection;
+    }
+
+void CMTPUsbTransport::ModeChanged(TMTPOperationalMode /*aMode*/)
+    {
+    __FLOG(_L8("ModeChanged - Entry"));
+    __FLOG(_L8("ModeChanged - Exit"));
+    }
+    
+void CMTPUsbTransport::StartL(MMTPConnectionMgr& aConnectionMgr)
+    {
+    __FLOG(_L8("StartL - Entry"));
+    __ASSERT_ALWAYS(!iConnection, Panic(EMTPUsbConnectionAlreadyExist));
+    iConnection = CMTPUsbConnection::NewL(aConnectionMgr);
+    __FLOG(_L8("StartL - Exit"));
+    }
+
+void CMTPUsbTransport::Stop(MMTPConnectionMgr& /*aConnectionMgr*/)
+    {
+    __FLOG(_L8("Stop - Entry"));
+    if(iConnection)
+	    {
+	    delete iConnection;
+	    iConnection = NULL;
+	    }
+    __FLOG(_L8("Stop - Exit")); 
+    }
+
+TAny* CMTPUsbTransport::GetExtendedInterface(TUid /*aInterfaceUid*/)
+    {
+    return 0;    
+    }
+
+/**
+Constructor
+*/    
+CMTPUsbTransport::CMTPUsbTransport()
+    {
+    // Do nothing.
+    }
+    
+/**
+Second phase constructor.
+*/
+void CMTPUsbTransport::ConstructL()
+    {
+    __FLOG_OPEN(KMTPSubsystem, KComponent);
+    __FLOG(_L8("ConstructL - Entry"));
+    __FLOG(_L8("USB MTP Device class plug-in loaded."));    
+    __FLOG(_L8("ConstructL - Exit"));
+    }
+
+// Define the implementation UID of MTP USB transport implementation.
+static const TImplementationProxy ImplementationTable[] =
+    {
+        
+        IMPLEMENTATION_PROXY_ENTRY((0x102827B2), CMTPUsbTransport::NewL)
+        
+    };
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
+
+// Dummy dll entry point.
+TBool E32Dll()
+    {
+    return ETrue;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtptransports/mtpusbtransport/usbsic_imp/src/mtpusbsicimp.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,39 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <ecom/registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = 0x102827AC;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x102827AE;
+			implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x102827B2;
+					version_no = 1;
+					display_name = "MTP Transport USB SIC class transport plug-in.";
+					default_data = "";
+					opaque_data = "";
+					}	
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+// Extension API provider for OBEX
+// 
+//
+
+/**
+ @file
+*/
+
+PRJ_EXPORTS
+// Extension API headers
+../public/obexserverpacketaccessextension.h			SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/extensionapis/obexserverpacketaccessextension.h)
+../public/mobexserverrequestpacketnotify.h 			SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/extensionapis/mobexserverrequestpacketnotify.h)
+../public/obexclienterrorresolver.h					SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/extensionapis/obexclienterrorresolver.h)
+
+// Internal OBEX headers
+../public/mobexserverrequestpacketnotifyregister.h	SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/mobexserverrequestpacketnotifyregister.h)
+../public/mobexclienterrorresolver.h				SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/mobexclienterrorresolver.h)
+
+
+PRJ_MMPFILES
+obexextensionapis.mmp
+
+PRJ_TESTEXPORTS
+
+PRJ_TESTMMPFILES
+../test/headercheck/group/t_obexextensionapisheadercheck.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/group/obex_extensionapis.history.xml	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<relnotes name="OBEX Extension API">
+  <purpose>
+  </purpose>
+  
+  <defect number="PDEF139836" title=".esk and .cmi files do not have header" revision="001">
+    Added copyright headers
+  </defect>
+  
+</relnotes>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/group/obex_extensionapis.mrp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,25 @@
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+component	obex_extensionapis
+source	\sf\mw\remoteconn\obex\obexextensionapi
+binary	\sf\mw\remoteconn\obex\obexextensionapi\group	all
+exports	\sf\mw\remoteconn\obex\obexextensionapi\group
+notes_source	\component_defs\release.src
+
+
+ipr E 
+ipr T \sf\mw\remoteconn\obex\obexextensionapi\test
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/group/obexextensionapis.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+// obexextension.mmp
+// ObexExtension DLL
+// obexextension.dll DLL providing extension APIs for OBEX
+// 
+//
+
+/**
+ @file
+*/
+
+
+TARGET			obexextensionapis.dll //Recommended unpaged
+
+CAPABILITY 		All -Tcb
+TARGETTYPE		dll
+
+UID				0x1000008d 0x10281917
+
+SOURCEPATH		../src
+SOURCE			obexserverpacketaccessextension.cpp
+SOURCE 			obexerrorextension.cpp
+
+USERINCLUDE		../../obexprotocol/common
+USERINCLUDE		../inc
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+LIBRARY			euser.lib 
+LIBRARY			obex.lib
+
+VENDORID 		0x70000001
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/inc/obexextensionapifaults.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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 __OBEXEXTENSIONAPIFAULTS_H
+#define __OBEXEXTENSIONAPIFAULTS_H
+/**
+@file 
+@internalComponent
+*/
+
+enum TObexExtensionApiFaultCode
+	{
+	EInterfaceInstanceIsANullPointer					= 0,
+	};
+	
+#endif // __OBEXEXTENSIONAPIFAULTS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/public/mobexclienterrorresolver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __MOBEXCLIENTERRORRESOLVER_H
+#define __MOBEXCLIENTERRORRESOLVER_H
+
+#include <obex/extensionapis/obexclienterrorresolver.h>
+
+/**
+UID with which applications can request the MObexClientErrorResolver API
+through CObexClient::ExtensionInterface().
+*/
+const TUid KObexClientErrorResolverInterface = {0x10281918};
+
+/**
+Definition of the Obex client error extension API.
+*/
+class MObexClientErrorResolver
+	{
+public:
+	/**
+	Function used to retreive an extended error code for the last completed client operation.
+
+	@param aErrorSet The set of errors that the resolved error will lie within.
+	@return An extended error code that lies within the error set specified.
+	*/
+	virtual TUint LastError(TObexClientErrorResolutionSetType aErrorSet) const = 0;
+	};
+
+#endif __MOBEXCLIENTERRORRESOLVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/public/mobexserverrequestpacketnotify.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef OBEXSERVERREQUESTPACKETNOTIFY_H
+#define OBEXSERVERREQUESTPACKETNOTIFY_H
+
+#include <e32std.h>
+#include <obexbase.h>
+
+class TObexConnectInfo;
+
+typedef TUint8 TObexRequestCode;
+
+const TObexRequestCode KObexRequestFinalConnect		= 0x80;
+const TObexRequestCode KObexRequestFinalDisconnect	= 0x81;
+const TObexRequestCode KObexRequestPut				= 0x02;
+const TObexRequestCode KObexRequestFinalPut			= 0x82;
+const TObexRequestCode KObexRequestGet				= 0x03;
+const TObexRequestCode KObexRequestFinalGet			= 0x83;
+const TObexRequestCode KObexFinalSetPath			= 0x85;
+const TObexRequestCode KObexFinalAbort				= 0xFF;
+
+/**
+A Mixin to provide a notification interface for the receipt of request
+packets by an OBEX server.
+
+@publishedPartner
+@released
+*/
+class MObexServerRequestPacketNotify
+	{
+public:
+	
+	/**
+	Receipt of a generic request packet.
+	
+	@param aRequest 	The opcode of the request packet received.
+	@param aResponse 	The implementer should set this to the response they
+						want to send to the client if they are abandoning
+						processing.
+	@return EFalse to abandon processing the packet, ETrue to process as normal 
+	*/
+	virtual TBool RequestPacket(TObexRequestCode aRequest, TObexResponse& aResponse) = 0;
+	
+	/**
+	Receipt of a Connect Request packet. Overload of the generic case.
+	
+	@param aRequest 	The opcode of the Connect Request packet received.
+	@param aConnectInfo	The Connect Info of the Connect Request packet.
+	@param aResponse 	The implementer should set this to the response they
+						want to send to the client if they are abandoning
+						processing.
+	@return EFalse to abandon processing the packet, ETrue to process as normal 
+	*/
+	virtual TBool RequestPacket(TObexRequestCode aRequest, TObexConnectInfo& aConnectInfo, TObexResponse& aResponse) = 0;
+	
+	/**
+	Receipt of a SetPath Request packet. Overload of the generic case.
+	
+	@param aRequest 	The opcode of the SetPath Request packet received.
+	@param aSetPathInfo	The SetPath Info of the SetPath Request packet.
+	@param aResponse 	The implementer should set this to the response they
+						want to send to the client if they are abandoning
+						processing.
+	@return EFalse to abandon processing the packet, ETrue to process as normal 
+	*/
+	virtual TBool RequestPacket(TObexRequestCode aRequest, CObex::TSetPathInfo& aSetPathInfo, TObexResponse& aResponse) = 0;
+	
+	};
+
+#endif // OBEXSERVERREQUESTPACKETNOTIFY_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/public/mobexserverrequestpacketnotifyregister.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef OBEXSERVERREQUESTPACKETNOTIFYREGISTER_H
+#define OBEXSERVERREQUESTPACKETNOTIFYREGISTER_H
+
+#include <e32std.h>
+
+class MObexServerRequestPacketNotify;
+
+/**
+	UID with which one can request the 
+	MObexServerRequestPacketNotifyRegister API through	
+	CObexServer::ExtensionInterface(). 
+	
+	Some implementations may use KObexRequestPacketNotifyInterfaceId
+	which is considered deprecated.
+*/
+const TUid KObexServerRequestPacketNotifyRegisterInterface = {0x10274CB4};
+
+/**
+Mixin class to be implemented by instances providing a means to
+set an observer for the receipt of Obex request packets by a server.
+
+This provides part of the packet access API.
+*/
+class MObexServerRequestPacketNotifyRegister
+	{
+public:
+	/**
+	Sets the notifier to be called when an Obex server receives a request packet.
+	
+	@param aRequestPacketNotify A pointer to the observer interface instance to receive the notifications.
+	*/
+	virtual void SetObexServerRequestPacketObserver(MObexServerRequestPacketNotify& aRequestPacketNotify) = 0;
+	
+	/**
+	Inform the Obex server that we have finished with this interface,
+	and delete the engine to allow a new one to be created.
+	*/
+	virtual void DeleteObexServerRequestPacketNotifyRegister() = 0;
+	};
+
+#endif // OBEXSERVERREQUESTPACKETNOTIFYREGISTER_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/public/obexclienterrorresolver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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
+ @publishedPartner
+ @released
+*/
+
+#ifndef __OBEXCLIENTERRORRESOLVER_H
+#define __OBEXCLIENTERRORRESOLVER_H
+
+#include <obexclient.h>
+
+class MObexClientErrorResolver;
+
+/**
+Types of error set that an Obex client error can be resolved to.
+*/
+enum TObexClientErrorResolutionSetType
+	{
+	/**
+	The basic error set that errors can be resolved to.
+	@see TObexClientBasicErrorResolutionSet
+	*/
+	EObexClientBasicErrorResolutionSet = 0,
+	};
+
+/**
+The basic error set that errors can be resolved to.
+*/
+enum TObexClientBasicErrorResolutionSet
+	{
+	/**
+	The last client operation completed without error.
+	This value is unused but remains here for compatibility.
+	*/
+	EObexNoExtendedError = 0,
+
+	/**
+	The last client operation completed without error.
+	*/
+	EObexRequestAccepted = 1,
+
+	/**
+	The last client operation was unauthorised or resulted in
+	an error being returned from the server.
+	*/
+	EObexRequestNotAccepted = 2,
+
+	/**
+	The last client operation timed out.
+	*/
+	EObexRequestTimeout = 3,
+
+	/**
+	The last client operation was interrupted by an error
+	detected on the client side, which includes the following:
+	- Cancellation of the operation (Abort)
+	- Obex protocol error
+	- Out of memory condition
+	*/
+	EObexRequestLocalInterruption = 4,
+
+	/**
+	The last client operation was interrupted due to the
+	transport link going down.  This may be caused by:
+	- Failure to find a remote device capable of Obex
+	- Blocking of the IrDA beam
+	*/
+	EObexRequestLinkInterruption = 5,
+	};
+
+/**
+Extension class for CObexClient that allows Obex client applications to
+retrieve an extended error code for the last completed client operation.
+*/
+NONSHARABLE_CLASS(CObexClientErrorResolver) : public CBase
+	{
+public:
+	IMPORT_C static CObexClientErrorResolver* NewL(CObexClient& aClient);
+	IMPORT_C static CObexClientErrorResolver* NewL(CObexClient& aClient, TObexClientErrorResolutionSetType aErrorSet);
+	IMPORT_C TUint LastError() const;
+
+private:
+	// Private constructor - this class is not intended for derivation.
+	CObexClientErrorResolver(CObexClient& aClient, TObexClientErrorResolutionSetType aErrorSet);
+	void ConstructL();
+
+private:
+	CObexClient& iObexClient;
+	MObexClientErrorResolver* iClientErrorResolver;
+	TObexClientErrorResolutionSetType iErrorSet;
+	};
+
+#endif // __OBEXCLIENTERRORRESOLVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/public/obexserverpacketaccessextension.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#ifndef OBEXSERVERPACKETACCESSEXTENSION_H
+#define OBEXSERVERPACKETACCESSEXTENSION_H
+
+#include <e32base.h>
+
+class CObexServer;
+class MObexServerRequestPacketNotify;
+class MObexServerRequestPacketNotifyRegister;
+
+/**
+This class provides the extension API to give an OBEX server application
+the option of registering a callback interface for being informed of
+packets the server receives before the server processes them.
+
+@publishedPartner
+@released
+*/
+NONSHARABLE_CLASS(CObexServerPacketAccessExtension) : public CBase
+	{
+public:
+	IMPORT_C static CObexServerPacketAccessExtension* NewL(CObexServer& aServer, MObexServerRequestPacketNotify& aRequestPacketNotify);
+	
+	~CObexServerPacketAccessExtension();
+	
+private:
+	CObexServerPacketAccessExtension();
+	void ConstructL(CObexServer& aServer, MObexServerRequestPacketNotify& aRequestPacketNotify);
+	
+private:
+	MObexServerRequestPacketNotifyRegister* iRequestPacketNotify;
+	
+	};
+
+#endif // OBEXSERVERPACKETACCESSEXTENSION_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/src/obexerrorextension.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <obex/extensionapis/obexclienterrorresolver.h>
+#include <obex/internal/mobexclienterrorresolver.h>
+
+/**
+Factory function for CObexClientErrorResolver.  Will leave if the associated CObexClient
+does not support this extension type.
+
+@param aClient Reference to the instance of CObexClient being extended.
+@return A pointer to a new CObexClientErrorResolver object.
+*/
+EXPORT_C CObexClientErrorResolver* CObexClientErrorResolver::NewL(CObexClient& aClient)
+	{
+	return NewL(aClient, EObexClientBasicErrorResolutionSet);
+	}
+
+/**
+Factory function for CObexClientErrorResolver.  Will leave if the associated CObexClient
+does not support this extension type.
+
+@param aClient Reference to the instance of CObexClient being extended.
+@param aErrorSet The set of errors that the resolved error will lie within.
+@return A pointer to a new CObexClientErrorResolver object.
+*/
+EXPORT_C CObexClientErrorResolver* CObexClientErrorResolver::NewL(CObexClient& aClient, TObexClientErrorResolutionSetType aErrorSet)
+	{
+	CObexClientErrorResolver* self = new (ELeave)CObexClientErrorResolver(aClient, aErrorSet);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+	}
+
+/**
+Function used to retreive an extended error code for the last completed client operation.
+
+@return An extended error code that lies within the error set specified at construction time.
+*/
+EXPORT_C TUint CObexClientErrorResolver::LastError() const
+	{
+	return iClientErrorResolver->LastError(iErrorSet);
+	}
+
+CObexClientErrorResolver::CObexClientErrorResolver(CObexClient& aClient, TObexClientErrorResolutionSetType aErrorSet)
+	: iObexClient(aClient), iErrorSet(aErrorSet)
+	{
+	}
+
+void CObexClientErrorResolver::ConstructL()
+	{
+	iClientErrorResolver = static_cast<MObexClientErrorResolver*>(iObexClient.ExtensionInterface(KObexClientErrorResolverInterface));
+	User::LeaveIfNull(iClientErrorResolver);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/src/obexserverpacketaccessextension.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,84 @@
+// 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 <obex/extensionapis/obexserverpacketaccessextension.h>
+#include <obexserver.h>
+#include <obex/internal/mobexserverrequestpacketnotifyregister.h>
+#include "obexextensionapifaults.h"
+
+//Category used for internal panics
+_LIT(KPanicCat, "ObexExtApis");
+
+/**
+Factory function for CObexServerPacketAccessExtension. Will leave if the associated CObexServer 
+does not support this extension type.
+
+Note that this object needs to be deleted before the CObexServer object it is registered to is
+deleted.
+
+@param aServer Reference to the instance of CObexServer being extended.
+@param aPacketNotify Reference to the instance of MObexRequestPacketNotify to be notified of 
+incoming packets. Notifications will stop when this CObexServerPacketAccessExtension object is
+deleted.
+@return A pointer to a new CObexServerPacketAccessExtension object.
+*/
+EXPORT_C CObexServerPacketAccessExtension* CObexServerPacketAccessExtension::NewL(CObexServer& aServer, MObexServerRequestPacketNotify& aRequestPacketNotify)
+	{
+	CObexServerPacketAccessExtension* self = new (ELeave) CObexServerPacketAccessExtension();
+	CleanupStack::PushL(self);
+	self->ConstructL(aServer, aRequestPacketNotify);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+The destructor will not delete the instance of the MObexServerRequestPacketNotify
+it holds.  It will signal to the CObexServer instance that packet notification is
+no longer required, and so re-allow another CObexServerPacketAccessExtension to bind
+to the CObexServer instance.
+
+This should be called before the CObexServer instance the object is registered to
+is deleted.
+*/
+CObexServerPacketAccessExtension::~CObexServerPacketAccessExtension()
+	{
+	if (iRequestPacketNotify)
+		{
+		iRequestPacketNotify->DeleteObexServerRequestPacketNotifyRegister();
+		}
+	}
+
+/**
+Constructor.
+*/
+CObexServerPacketAccessExtension::CObexServerPacketAccessExtension()
+	{
+	
+	}
+
+/**
+Performs the main construction of the CObexServerPacketAccessExtension.
+
+@param aServer The CObexServer instance to register request packet notification callbacks.
+@param aRequestPacketNotify The mixin instance that will receive notification of request packets.
+*/
+void CObexServerPacketAccessExtension::ConstructL(CObexServer& aServer, MObexServerRequestPacketNotify& aRequestPacketNotify)
+	{
+	iRequestPacketNotify = static_cast<MObexServerRequestPacketNotifyRegister*>(aServer.ExtensionInterfaceL(KObexServerRequestPacketNotifyRegisterInterface));
+	// by here we should have a correctly cast instance, as otherwise we should have already left.
+	__ASSERT_ALWAYS(iRequestPacketNotify, User::Panic(KPanicCat, EInterfaceInstanceIsANullPointer));
+	iRequestPacketNotify->SetObexServerRequestPacketObserver(aRequestPacketNotify);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/test/headercheck/group/t_obexextensionapisheadercheck.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,43 @@
+// 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:
+// Pointless file produced by test project; the test is that it 
+// compiles at all.
+// 
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+target			t_obexextensionheadercheck.exe
+targettype		exe
+uid 			0
+VENDORID		0x70000001
+
+sourcepath		../src
+source			main.cpp
+
+source			t_obexserverpacketaccessextension.cpp
+source			t_mobexserverrequestpacketnotify.cpp
+source			t_mobexserverrequestpacketnotifyregister.cpp
+
+source			t_obexclienterrorresolver.cpp
+source			t_mobexclienterrorresolver.cpp
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+library 		euser.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/test/headercheck/src/main.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,21 @@
+// 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:
+//
+
+#include <e32std.h>
+
+GLDEF_C TInt E32Main()
+	{
+	return KErrNone;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/test/headercheck/src/t_mobexclienterrorresolver.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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 <obex/internal/mobexclienterrorresolver.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/test/headercheck/src/t_mobexserverrequestpacketnotify.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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 <obex/extensionapis/mobexserverrequestpacketnotify.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/test/headercheck/src/t_mobexserverrequestpacketnotifyregister.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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 <obex/internal/mobexserverrequestpacketnotifyregister.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/test/headercheck/src/t_obexclienterrorresolver.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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 <obex/extensionapis/obexclienterrorresolver.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/test/headercheck/src/t_obexserverpacketaccessextension.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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 <obex/extensionapis/obexserverpacketaccessextension.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+// OBject EXchange Protocol
+// 
+//
+
+/**
+ @file
+*/
+
+// Main
+#include "group/bld.inf"
+
+// Extension APIs
+#include "../obexextensionapi/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/common/logger.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,163 @@
+// 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:
+// All rights reserved.
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+
+#ifndef LOGGER_H
+#define LOGGER_H
+
+#include <e32base.h>
+
+// Control function entry and exit logging using a compile-time switch.
+//#define __LOG_FUNCTIONS__
+
+// Dump contents of packets using a compile-time switch.
+//#define __LOG_PACKET_DUMP__
+
+class TFunctionLogger;
+
+#ifndef __COMMSDEBUGUTILITY_H__		// comms-infras/commsdebugutility.h not included
+#ifdef _DEBUG						// If this is a debug build...
+// Set flogging active.
+#define __FLOG_ACTIVE
+#endif
+#endif
+
+#ifdef __FLOG_ACTIVE
+#define IF_FLOGGING(a) a
+#else
+#define IF_FLOGGING(a)
+#endif
+
+_LIT8(KDefaultLogFile, "obex");
+
+#ifdef __FLOG_ACTIVE
+#define LEAVEIFERRORL(a)				VerboseLeaveIfErrorL(KLogComponent, __FILE__, __LINE__, a)
+#define PANIC(CAT, CODE) 				VerbosePanic(KLogComponent, __FILE__, __LINE__, CODE, (TText8*)#CODE, CAT)
+#define FLOG(a)							CObexLog::Write(KDefaultLogFile, a);
+
+#define FTRACE(a)						{a;}
+#define LOG(text)						CObexLog::Write(KLogComponent, text);
+#define LOG1(text, a)					CObexLog::WriteFormat(KLogComponent, text, a);
+#define LOG2(text, a, b)				CObexLog::WriteFormat(KLogComponent, text, a, b);
+#define LOG3(text, a, b, c)				CObexLog::WriteFormat(KLogComponent, text, a, b, c);
+#define LOGHEXDESC(desc)				CObexLog::HexDump(KLogComponent, 0, 0, desc.Ptr() , desc.Length());
+#define LOGHEXRAW(data, len)			CObexLog::HexDump(KLogComponent, 0, 0, data, len);
+#else
+#define LEAVEIFERRORL(a)				static_cast<void>(User::LeaveIfError(a))
+#define PANIC(CAT, CODE) 				User::Panic(CAT, CODE)
+#define FLOG(a)
+#define FTRACE(a)
+#define LOG(text)
+#define LOG1(text, a)
+#define LOG2(text, a, b)
+#define LOG3(text, a, b, c)
+#define LOGHEXDESC(desc)
+#define LOGHEXRAW(data, len)
+#endif // __FLOG_ACTIVE
+
+#define FORCED_LOG_FUNC					TFunctionLogger __instrument(KLogComponent, TPtrC8((TUint8*)__PRETTY_FUNCTION__), (TAny*)this);
+#define FORCED_LOG_STATIC_FUNC_ENTRY	TFunctionLogger __instrument(KLogComponent, TPtrC8((TUint8*)__PRETTY_FUNCTION__), (TAny*)NULL);
+
+#if ( defined __FLOG_ACTIVE && defined __LOG_FUNCTIONS__ )
+#define LOG_LINE						CObexLog::Write(KLogComponent, KNullDesC8());
+#define LOG_FUNC						FORCED_LOG_FUNC
+#define LOG_STATIC_FUNC_ENTRY			FORCED_LOG_STATIC_FUNC_ENTRY
+#else
+#define LOG_LINE
+#define LOG_FUNC
+#define LOG_STATIC_FUNC_ENTRY
+#endif
+
+
+
+NONSHARABLE_CLASS(CObexLog) : public CBase
+	{
+public:
+	IMPORT_C static TInt Connect();
+	IMPORT_C static void Close();
+	
+	IMPORT_C static void Write(const TDesC8& aCmpt, const TDesC8& aText);
+	IMPORT_C static void WriteFormat(const TDesC8& aCmpt, TRefByValue<const TDesC8> aFmt, ...);
+	IMPORT_C static void WriteFormat(const TDesC8& aCmpt, TRefByValue<const TDesC8> aFmt, VA_LIST& aList);
+	IMPORT_C static void Write(const TDesC8& aCmpt, const TDesC16& aText);
+	IMPORT_C static void WriteFormat(const TDesC8& aCmpt, TRefByValue<const TDesC16> aFmt, ...);
+	IMPORT_C static void WriteFormat(const TDesC8& aCmpt, TRefByValue<const TDesC16> aFmt, VA_LIST& aList);
+	IMPORT_C static void HexDump(const TDesC8& aCmpt, const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen);
+	};
+
+
+#ifndef NO_FPRINT
+inline void FPrint(const TRefByValue<const TDesC> IF_FLOGGING(aFmt), ...)
+	{
+#ifdef __FLOG_ACTIVE
+	VA_LIST list;
+	VA_START(list,aFmt);
+	CObexLog::WriteFormat(KDefaultLogFile, aFmt, list);
+#endif
+	}
+#endif
+
+
+#ifndef NO_FHEX_PTR
+inline void FHex(const TUint8* IF_FLOGGING(aPtr), TInt IF_FLOGGING(aLen))
+	{
+#ifdef __FLOG_ACTIVE
+	CObexLog::HexDump(KDefaultLogFile, 0, 0, aPtr, aLen);
+#endif
+	}
+#endif
+
+
+#ifndef NO_FHEX_DESC
+inline void FHex(const TDesC8& IF_FLOGGING(aDes))
+	{
+#ifdef __FLOG_ACTIVE
+	FHex(aDes.Ptr(), aDes.Length());
+#endif
+	}
+#endif
+
+
+IMPORT_C void VerboseLeaveIfErrorL(const TDesC8& aCpt, 
+						  char* aFile, 
+						  TInt aLine, 
+						  TInt aReason);
+						  
+IMPORT_C void VerbosePanic(const TDesC8& aCpt, 
+				  char* aFile, 
+				  TInt aLine, 
+				  TInt aPanicCode, 
+				  TText8* aPanicName,
+				  const TDesC& aPanicCategory);
+				  
+NONSHARABLE_CLASS(TFunctionLogger)
+	{
+public:
+	IMPORT_C TFunctionLogger(const TDesC8& aCpt, const TDesC8& aString, TAny* aThis);
+	IMPORT_C ~TFunctionLogger();
+	
+private:
+	TPtrC8 iCpt;
+	TPtrC8 iString;
+	};
+
+#endif	// LOGGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -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 "../obextransport/group/BLD.INF"
+#include "../obex/group/BLD.INF"
+#include "../obexbttransport/group/BLD.INF"
+#include "../obexusbtransport/group/BLD.INF"
+
+
+PRJ_EXPORTS
+obexprotocol.iby			/epoc32/rom/include/obexprotocol.iby
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/group/obex.history.xml	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<relnotes name="OBEX Protocol">
+  <purpose>
+    OBEX session protocol over IrDA, Bluetooth, and USB transports, supporting connections from simple beaming all the way to full-fledged synchronisation technologies such as SyncML and IrMC (note: Obex can support IrMC, but it is not actually supported in the OS at the moment).
+  </purpose>
+
+  <defect number="DEF141510" title="Missing distribution.policy.s60 files " revision="032">
+    Added source \sf\mw\remoteconn\obex\obexprotocol in obex.mrp file 
+  </defect>
+
+  <defect number="PDEF139836" title=".esk and .cmi files do not have header" revision="031">
+    Added copyright headers
+  </defect>
+  
+  <deliverystep number="1657" name="Remove IrDA" osproject="SymTB9.2" revision="001">
+	  <preq number="2613" title="Remove IrDA"/>
+  </deliverystep>
+  <milestone project="GT0418" number="3.3"/>
+
+  <defect number="DEF133406" title="Obex def files changes for armv7 " revision="030">
+    Remove IMPORT_C from CObexServer::~CObexServer and the entry in mark bwins def file absent.
+  </defect>
+
+  <defect number="DEF132890" title="[ONB Coverity] CHECKED_RETURN error in TObex " revision="029">
+    Static analysis failures corrected.
+  </defect>
+
+  <defect number="DEF130710" title="Remove filename case check test code errors from OBEX" revision="028">
+    Static analysis failures corrected.
+  </defect>
+
+  <defect number="DEF130790" title="[Coverity]-MISSING_BREAK -obex/obextransport" revision="027">
+    Static analysis failures corrected.
+  </defect>
+
+  <defect number="DEF128204" title="errors in IM tagging in shortlink" revision="026">
+    Correct the IM tagging.
+  </defect>
+
+  <defect number="PDEF126953" title="It is often useful to call RFile::Flush() before a file is closed" revision="025">
+     Invoke RFile::Flush() when final file write is finished.
+  </defect>
+
+  <defect number="DEF126185" title="Extra member qualifications" revision="024">
+    'CObex::' removed from member function CancelObexConnection declaration.
+  </defect>
+
+  <defect number="DEF124961" title="[Coverity]CHECKED_RETURN failure in TObexInternalHeader" revision="023">
+    If GetHVText returns an error, the number of bytes actually written by WriteOut is 0.
+  </defect>
+
+  <defect number="DEF124960" title="[Coverity]4 CHECKED_RETURN failures in CObexClient" revision="022">
+    Check returned value from InsertData and leave if not enough space to insert data.
+  </defect>
+
+  <defect number="DEF124958" title="[Coverity]FORWARD_NULL failure in CObexBaseObject" revision="021">
+	The "if is null" statements were not necessary. replaced with debug assertions.     
+  </defect>
+
+  <defect number="DEF124957" title="[Coverity]FORWARD_NULL failure in CObexBufObject" revision="020">
+    Added two assertions to avoid calling the methods on an invalid pointer.
+  </defect>
+
+  <defect number="DEF124956" title="[Coverity] REVERSE_INULL failure in CObexServer" revision="019">
+    put some assertions to be sure that this pointer is not null (it must be valid)
+  </defect>
+
+  <defect number="DEF121787" title="Changes required to match fix made in Base USB Peripheral driver" revision="018">
+    Add indication that no control transfers are expected on either obex interface.
+  </defect>
+
+  <defect number="PDEF119945" title="Configuring L2CAP MTU for optimum performance " revision="017">
+    Changes to accomodate MTU size changes.
+  </defect>
+
+  <defect number="DEF119732" title="OBEX logger's LEAVEIFERRORL sometimes leaves if not error" revision="016">
+    OBEX logger's LEAVEIFERRORL did not leave from User::LeaveIfError if you pass it a positive value.
+  </defect>
+
+  <defect number="DEF117240" title="Correct LeaveScan error in emptyheaderstest.cpp" revision="015">
+    Changed methods names according to coding standard due to avoid LeaveScan error.
+  </defect>
+
+  <defect number="DEF117239" title="Correct LeaveScan error in IrOBEXUtil" revision="014">
+    Changed code to avoid LeaveScan reporting error.
+  </defect>
+
+  <defect number="PDEF114506" title="Klocwork issues in obex" revision="013">
+    Initialise max send/recv packet sizes to the maximum size of an IrDA packet before GetOpt is called.
+  </defect>
+
+  <defect number="PDEF113644" title="Obex needs to ignore malformed time Headers " revision="012">
+    Modified function CObexBaseObject::ParseNextReceivePacket so that, instead of interrupting the parsing and returning an error when there are problems with the TIME header, it ignores the header and continues parsing the packet.
+  </defect>
+
+  <defect number="PDEF112614" title="TObex panics if it gets a large name header when acting as FTP server" revision="011">
+    TObex will now truncate filename of an object that is PUT on the server if its complete path is too long to fit within the OS limit (256 chars).
+  </defect>
+
+  <defect number="PDEF112489" title="Misleading Obex error code" revision="010">
+    Rename error code to EUnexpectedChallengeResponse.
+  </defect>
+
+  <defect number="PDEF107489" title="Obex server error handling problem" revision="009">
+    ERespUnauthorized will be treated as a valid response to connect request, because this can be originated from obex packet access extension.
+  </defect>
+
+  <defect number="PDEF106896" title="TTG:Unexpected response to PUT/GET Requests with Auth'n Challenge" revision="008">
+    Alter Obex response to Put, Get and SetPath requests that contain an authentication challenge. These now respond with the "Unauthorized" opcode.
+  </defect>
+
+  <minorchange revision="007">
+    PDEF106501: Correctly set final bit flag on EOB header response for empty objects.
+  </minorchange>
+
+  <defect number="DEF101319" title="Filename case check failures in source build and test" revision="006">
+    Corrected filenames to enable building of Symbian OS in Linux
+  </defect>
+
+  <defect number="PDEF103383" title="?P903i? could not receive Contact data via Infrared" revision="005">
+    Workaround for interop with P903i and others whose servers return opcode success (instead of continue) in response to a Put request.
+  </defect>
+
+  <defect number="PDEF101514" title="TTG:OBEX server respond improper response instead of Bad Request(0xC0)" revision="004">
+    Upgrade the Obex server so that if an Abort command is received whilst an Obex Session his being Connected or when it is not Connected then, instead of bringing the underlying transport down, the Obex server replies with success.
+  </defect>
+
+  <defect number="PDEF101048" title="Renameobex test files testDef094745.*" revision="003">
+    Renamed test files and menu items in the manual test Tobex so that they are based on the functionality being tested rather than using the numerical code for the defect that they were produced for.
+  </defect>
+
+  <defect number="PDEF100899" title="TTG:&lt;On receiving other than Other Response(OK(A0h), it cannot be disconnected &gt;" revision="002">
+    Fix to Obex to bring transport down if clean disconnection fails.
+  </defect>
+
+  <defect number="PDEF100845" title="Fix for PDEF091783 causes authentication regression" revision="001">
+    Authentication loophole removed
+  </defect>
+ </relnotes>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/group/obex.mrp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+#
+
+component	obex
+source	\sf\mw\remoteconn\obex\obexprotocol
+
+binary	\sf\mw\remoteconn\obex\obexprotocol\group	all
+exports	\sf\mw\remoteconn\obex\obexprotocol\group
+notes_source	\component_defs\release.src
+
+
+ipr E 
+ipr T \sf\mw\remoteconn\obex\obexprotocol\obex\test
+ipr T \sf\mw\remoteconn\obex\obexprotocol\obextransport\test
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/group/obexprotocol.iby	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+// Obex
+// obexprotocol.iby
+// 
+//
+
+#ifndef  __OBEXPROTOCOL_IBY__
+#define  __OBEXPROTOCOL_IBY__
+
+REM If __OBEX_DEBUG__ is defined pull in debug versions of the
+REM OBEX DLLs and transport controllers regardless of the ROM type
+#ifdef __OBEX_DEBUG__
+define OBEX_DIR UDEB
+#define OBEX_PLUGIN ECOM_PLUGIN_UDEB
+#else
+define OBEX_DIR BUILD_DIR
+#define OBEX_PLUGIN ECOM_PLUGIN
+#endif
+
+REM *** The following iby files are always included, whether obex is
+REM *** supported by the device or not.
+
+#include <ecom.iby>
+
+#if defined(_DEBUG) || defined (__OBEX_DEBUG__)
+#include <commsdebugutility.iby>
+#endif
+
+REM *** The following dlls are client side dlls. They are always included
+REM *** in the ROM, whether obex is supported by the device or not, so
+REM *** that client applications can link against them regardless.
+
+file=ABI_DIR\OBEX_DIR\obex.dll	sys\bin\OBEX.dll
+REM Alias new obex.dll to also appear as irobex.dll to support legacy apps
+alias sys\bin\obex.dll			sys\bin\irobex.dll
+
+file=ABI_DIR\OBEX_DIR\obexcommontransport.dll 	System\Libs\obexcommontransport.dll
+
+#ifdef SYMBIAN_INCLUDE_OBEX_EXTENSIONAPIS
+file=ABI_DIR\OBEX_DIR\obexextensionapis.dll	sys\bin\obexextensionapis.dll
+#endif
+
+REM *** Now for things which should only be included if the device
+REM *** supports OBEX, to save ROM space...
+
+#ifdef SYMBIAN_EXCLUDE_OBEX
+REM Feature OBEX is not in this ROM
+#else
+
+
+REM *** Now for things which should only be included if the device
+REM *** supports USB, to save ROM space...
+
+#ifdef SYMBIAN_EXCLUDE_USB
+REM OBEX USB transport is not included in this ROM as it depends on USB
+#else
+OBEX_PLUGIN(obexusbtransportcontroller.dll,1020de87.rsc)
+#endif
+
+REM *** Now for things which should only be included if the device
+REM *** supports bluetooth, to save ROM space...
+
+#ifdef SYMBIAN_EXCLUDE_BLUETOOTH
+REM OBEX Bluetooth transport is not included in this ROM as it depends on BLUETOOTH
+#else
+OBEX_PLUGIN(obexbtrfcommtransportcontroller.dll,1020e043.rsc)
+#endif
+
+#endif // SYMBIAN_EXCLUDE_OBEX
+
+#endif //  __OBEXPROTOCOL_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/group/BLD.INF	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+// Implementation of Object Exchange Protocol
+// 
+//
+
+/**
+ @file
+*/
+
+PRJ_EXPORTS
+
+../public/OBEX.H SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obex.h)
+../public/obexbase.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexbase.h)
+../public/obexbaseobject.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexbaseobject.h)
+../public/obexclient.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexclient.h)
+../public/obexconstants.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexconstants.h)
+../public/obexpanics.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexpanics.h)
+../public/obexheaders.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexheaders.h)
+../public/obexobjects.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexobjects.h)
+../public/obexserver.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexserver.h)
+../public/obextypes.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obextypes.h)
+../public/obexfinalpacketobserver.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexfinalpacketobserver.h)
+../public/obexreadactivityobserver.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obexreadactivityobserver.h)
+../inc/obexconstantsinternal.h	SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obexconstantsinternal.h)
+// NB obexcommontransport depends on these files to compile, but obex depends 
+// on obexcommontransport to link. This is a circular dependency. Due to how 
+// our build system works (export all the headers before trying to build 
+// anything) it doesn't cause a build break.
+../public/ObexBtTransportInfo.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexbttransportinfo.h)
+../public/ObexUsbTransportInfo.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexusbtransportinfo.h)
+../public/ObexTransportInfo.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obextransportinfo.h)
+../public/ObexIrTransportInfo.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexirtransportinfo.h)
+
+PRJ_MMPFILES
+obex.mmp
+irobex.mmp	// Build irobex.lib to allow legacy components to continue linking without source changes
+
+
+PRJ_TESTEXPORTS
+../test/tobex/Contactsbak.vcf /epoc32/wins/c/contactsbak.vcf
+../test/tobex/Contactsbak2.vcf /epoc32/wins/c/contactsbak2.vcf
+../test/tobex/Contactsbak3.vcf /epoc32/wins/c/contactsbak3.vcf
+
+PRJ_TESTMMPFILES
+
+../test/tobex/TOBEX.MMP
+../test/testobexerrorcodes/TestObexErrorCodes.mmp
+../test/headercheck/group/t_obexheadercheck.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/group/irobex.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+// Obex
+// irobex.lib Build irobex.lib to allow legacy apps to effectively link to obex.dll
+// 
+//
+
+/**
+ @file
+*/
+
+TARGET irobex.lib
+TARGETTYPE IMPLIB
+#ifdef WINSCW
+DEFFILE IROBEX2.DEF
+#else
+DEFFILE irobex2.def
+#endif
+UID	0x1000008d 0x10201EF5
+LINKAS obex.dll
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/group/obex.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,101 @@
+// 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:
+// Obex
+// irobex.dll Implementation of Object Exchange Protocol
+// 
+//
+
+/**
+ @file
+*/
+
+
+TARGET							obex.dll //Recommended unpaged
+
+CAPABILITY All -Tcb
+TARGETTYPE		dll
+
+uid			0x1000008d 0x10201EF5
+
+#ifdef WINSCW
+DEFFILE			IROBEX2.DEF
+#else
+DEFFILE			irobex2.def
+#endif
+
+SOURCEPATH		../src
+SOURCE			OBEX.CPP
+SOURCE			obexobjectexpandedbaseobject.cpp
+SOURCE			obexheader.cpp
+SOURCE			obexheaderset.cpp
+SOURCE			obexconstants.cpp
+SOURCE			obexheaderutil.cpp
+SOURCE			obexobjects.cpp
+SOURCE			obexclient.cpp
+SOURCE			obexserver.cpp
+SOURCE			obexserverstatemachine.cpp
+SOURCE			obexfilewriter.cpp
+SOURCE			obexasyncfilewriter.cpp
+SOURCE			obexsyncfilewriter.cpp
+SOURCE 			obexsetpathdata.cpp
+SOURCE			OBEXUTIL.CPP 
+SOURCE			authentication.cpp
+SOURCE			obexservernotify.cpp
+SOURCE			obexauthchallengehandler.cpp
+SOURCE			obexpacketsignaller.cpp
+SOURCE			obexpackettimer.cpp
+SOURCE			obexnotifyhandlerbase.cpp
+SOURCE			obexnotifyhandlerclient.cpp
+SOURCE			obexnotifyhandlerserver.cpp
+SOURCE			obexservernotifysyncwrapper.cpp
+SOURCE			obexserverrequestpacketengine.cpp
+SOURCE			obexerrorengine.cpp
+SOURCE			TObexServerOperationState.cpp
+SOURCE			TObexServerStateDisconnected.cpp
+SOURCE			TObexServerStateTransportConnected.cpp
+SOURCE			TObexServerStateObexConnecting.cpp
+SOURCE			TObexServerStateWaitForUserPassword.cpp
+SOURCE			TObexServerStateReady.cpp
+SOURCE			TObexServerStatePutOpWaitForUser.cpp
+SOURCE			TObexServerStatePutOpReceiveObject.cpp
+SOURCE			TObexServerStateGetOpReceiveSpecification.cpp
+SOURCE			TObexServerStateGetOpWaitForUser.cpp
+SOURCE			TObexServerStateGetOpSendObject.cpp
+SOURCE			TObexServerStateSetPathOp.cpp
+SOURCE			TObexServerStatePutOpFinal.cpp
+SOURCE			TObexServerStateGetOpFinal.cpp
+SOURCE			TObexServerStateDisconnecting.cpp
+
+USERINCLUDE		../inc
+USERINCLUDE		../../common
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+LIBRARY			euser.lib 
+LIBRARY			efsrv.lib 
+LIBRARY			esock.lib 
+LIBRARY			hash.lib 
+LIBRARY			charconv.lib 
+LIBRARY  		obexcommontransport.lib
+LIBRARY			irda.lib		// Needed by IrOBEXUtil::CreateTransportInfoL
+LIBRARY			bluetooth.lib	// Needed by IrOBEXUtil::CreateTransportInfoL
+LIBRARY 		ecom.lib
+
+START WINS
+    BASEADDRESS 0x73900000
+END
+
+VENDORID 0x70000001
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/OBEXUTIL.H	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,51 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+*/
+
+//defined for testing purposes only
+//#define TEST_CLIENT_CHANGES_ITS_MIND_ABOUT_CHALLENGE
+
+#ifndef __OBEXUTIL_H
+#define __OBEXUTIL_H
+
+#include <obexconstants.h>
+#include "obexconstantsinternal.h"
+#include "obexfaults.h"
+
+class TObexTransportInfo;
+
+//this macro traps the leave and if an error has occured it calls the function defined by _trap
+#define OBEX_TRAP(_trap, _stmt)  TRAPD(_code, _stmt);if(_code != KErrNone) _trap (_code)
+
+inline TInt ObexHeaderType(TUint8 aHI)
+	{
+	return ((aHI & KObexHeaderTypeMask) >> KObexHeaderTypeOffset);
+	}
+
+NONSHARABLE_CLASS(IrOBEXUtil) 
+	{
+public:
+ 	static void Panic(TObexPanicCode aCode);
+ 	static void Fault(TObexFaultCode aCode);
+	static TInt EpocError(TUint8 aResp);
+	static TObexResponse ObexResponse(TInt aErr,TObexResponse aDefault);
+	static TObexTransportInfo*  CreateTransportInfoL(TObexProtocolInfo& aObexProtocolInfoPtr, TObexProtocolPolicy& aObexProtocolPolicy);
+	};
+	
+#endif // __OBEXUTIL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/authentication.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,49 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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 AUTHENTICATION_H
+#define AUTHENTICATION_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <obex.h>
+#include <obex/internal/obextransportconstants.h>
+
+const TUid KObexAuthenticationNotifierUid = {0x12341234};	//fixme
+
+class CMD5;
+
+NONSHARABLE_CLASS(CObexAuthenticator) : public CBase
+	{
+public:
+	static CObexAuthenticator* NewL();
+	~CObexAuthenticator();
+	TInt GenerateNonce(TDes8& aNonce);
+	void GenerateResponseL(const TDesC8& aPasswd, const TNonce& aNonce, TRequestDigest& aRequestDigest);
+	void ChallengeResponseL(const TDesC8& aPasswd, const TNonce& aNonce, const TRequestDigest& aRequestDigest);
+private:
+	void ConstructL();
+	CObexAuthenticator();
+private:
+	CMD5* iMD5;
+	TInt64 iSeed;
+	};
+
+#endif // AUTHENTICATION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexasyncfilewriter.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,71 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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 __OBEXASYNCFILEWRITER_H__
+#define __OBEXASYNCFILEWRITER_H__
+
+#include <e32base.h>
+#include "obexfilewriter.h"
+
+class RFile;
+
+/** 
+Obex Asynchronous File Writer.
+
+This active object writes data from Obex objects to disk asynchronously.
+
+Not intended for derivation.
+
+@internalComponent
+@released
+*/
+NONSHARABLE_CLASS(CObexAsyncFileWriter) : public CActive, public MObexFileWriter
+	{
+public:
+	// Construction / destruction
+	static MObexFileWriter* NewL(RFile& aFile);
+	~CObexAsyncFileWriter();
+
+private:
+	// From MObexFileWriter
+	TInt Write(TInt aPos, CBufBase*& aBuf);
+	TInt FinalWrite(TInt aPos, CBufBase*& aBuf, TInt aLength);
+
+private:
+	// From CActive
+	void DoCancel();
+	void RunL();
+
+private:
+	// Construction
+	void ConstructL();
+	CObexAsyncFileWriter(RFile& aFile);
+	
+// Unowned
+private:
+	/** Reference to the file which this object is used to write to */
+	RFile&		iFile;
+	/** Pointer to the buffer this object is currently writing to file */
+	CBufBase*	iBuffer;
+	/** Descriptor for the buffer this object is currently writing to file */
+	TPtr8		iBufPtr;
+	};
+
+#endif // __OBEXASYNCFILEWRITER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexcommon.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef __OBEXCOMMON_H__
+#define __OBEXCOMMON_H__
+
+#include <obextypes.h>
+#include <obexconstants.h>
+#include <obexbaseobject.h>
+#include <obexobjects.h>
+
+#endif // __OBEXCOMMON_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexconstantsinternal.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,125 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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 __OBEXCONSTANTSINTERNAL_H
+#define __OBEXCONSTANTSINTERNAL_H
+
+#include <e32def.h>
+
+//common to request & resp digests
+
+/** @internalComponent */
+const TInt KMinChallResponseSize = 18; //Nonce(16) + tag(1) + size(1)
+/** @internalComponent */
+const TInt KObexNonceSize = 16;
+/** @internalComponent */
+const TUint8 KObexRequireUID = 0x01;
+
+//request or chall
+/** @internalComponent */
+const TUint KObexChallNonceTag = 0;
+/** @internalComponent */
+const TUint8 KObexChallOptionsTag = 0x01;
+/** @internalComponent */
+const TUint8 KObexChallRealmTag = 0x02;
+/** @internalComponent */
+const TInt KObexChallOptionSize = 1; //this can't be changed from one without making
+/** @internalComponent */
+const TUint KObexChallHeaderSize = 23; //assuming no Realm data
+
+//response
+/** @internalComponent */
+const TUint KObexRespTag = 0;
+/** @internalComponent */
+const TUint8 KObexRespUserIDTag = 0x01;
+/** @internalComponent */
+const TUint8 KObexRespNonceTag = 0x02;
+
+/** @internalComponent */
+const TUint8 KObexHeaderTypeMask = 0xc0;
+/** @internalComponent */
+const TUint8 KObexHeaderTypeOffset = 6;
+
+
+#ifdef _UNICODE
+/** @internalComponent */
+const TInt KUidOBEXTransportModule = 0x10003d56;
+#else
+/** @internalComponent */
+const TInt KUidOBEXTransportModule = 0x1000169c;
+#endif
+
+/** @internalComponent */
+const TUint8 KFourByteTimeHeaderAddress = 0xc4;
+
+// Header mask definitions.
+// Old style accessor for which headers are present or
+// should be sent by an object.  Now deprecated, use the
+// header iterator instead.
+/** @internalComponent */
+const TUint16 KObexHdrName				= 0x0001;
+/** @internalComponent */
+const TUint16 KObexHdrType				= 0x0002;
+/** @internalComponent */
+const TUint16 KObexHdrLength			= 0x0004;
+/** @internalComponent */
+const TUint16 KObexHdrTime				= 0x0008;
+/** @internalComponent */
+const TUint16 KObexHdrDescription		= 0x0010;
+/** @internalComponent */
+const TUint16 KObexHdrTarget			= 0x0020;
+/** @internalComponent */
+const TUint16 KObexHdrConnectionID		= 0x0040;
+/** @internalComponent */
+const TUint16 KObexHdrBody				= 0x0080;
+/** @internalComponent */
+const TUint16 KObexHdrEndOfBody			= 0x0100;
+/** @internalComponent */
+const TUint16 KObexHdrHttp				= 0x0200;
+/** @internalComponent */
+const TUint16 KObexHdrAppParam			= 0x0400;
+/** @internalComponent */
+const TUint16 KObexHdrUserDefined		= 0x0800;
+/** @internalComponent */
+const TUint16 KObexHdrCount				= 0x1000;
+/** @internalComponent */
+const TUint16 KObexHdrCreatorID			= 0x2000;
+/** @internalComponent */
+const TUint16 KObexHdrWanUUID			= 0x4000;
+/** @internalComponent */
+const TUint16 KObexHdrObjectClass		= 0x8000;
+
+
+/** @internalComponent */
+const TUint8  KObexUserDefinedHdrAddrMin	 = 0x30; //start of user defined header address range
+/** @internalComponent */
+const TUint8  KObexUserDefinedHdrAddrMax	 = 0x3F; //end of user defined header address range
+
+/** @internalComponent */
+const TUint8 KObexVersion           	= 0x10;		//< Version 1.0 (still correct for Obex spec v 1.2)
+
+/** @internalComponent */
+const TUint8 KObexObjectFieldSize   	= 127;
+
+// Flags used by SetPath
+/** @internalComponent */
+const TUint8 KObexSetPathParent	= 0x01;
+
+#endif // __OBEXCONSTANTSINTERNAL_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexerrorengine.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,219 @@
+// 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 __OBEXERRORENGINE_H
+#define __OBEXERRORENGINE_H
+
+#include <obex/internal/mobexclienterrorresolver.h>
+
+/**
+Implements the Obex client error resolver extension functionality.
+Keeps a record of the last underlying client error that occurred.
+Resolves the underlying error to an error set specified by the user.
+*/
+NONSHARABLE_CLASS(CObexErrorEngine) : public CBase, public MObexClientErrorResolver
+	{
+public:
+	/**
+	The Obex client sets a detailed "underlying" error on the error
+	engine for resolving to a specific error set later on.  This
+	mechanism adds extensibility to different error sets.
+	*/
+	enum TObexClientUnderlyingError
+		{
+		/**
+		No error in the last operation.
+		@see CObexClient::OnPacketReceive()
+		*/
+		ENoError = 0,
+
+		/**
+		The last operation failed to bring the transport up.
+		@see CObexClient::ClientCommandL()
+		@see CObexClient::CompleteRequest()
+		*/
+		ETransportUpFailed = 1,
+
+		/**
+		Tried to connect but already connected.
+		@see CObexClient::ClientCommandL()
+		*/
+		EAlreadyConnected = 2,
+
+		/**
+		Failed to insert local connection info into connect packet.
+		@see CObexClient::PrepareConnectPacket()
+		*/
+		ECannotInsertConnectInfo = 3,
+
+		/**
+		Connection challenge received but unable to ask the user for a password.
+		@see CObexClient::PrepareConnectPacket()
+		*/
+		EChallengeRejected = 4,
+
+		/**
+		The client's connect state was set to an erroneous value.
+		@see CObexClient::PrepareConnectPacket()
+		*/
+		EPrepareConnectPacketIncorrectState = 5,
+
+		/**
+		A packet was received while the client was sending.
+		@see CObexClient::OnPacketReceive()
+		*/
+		EResponseWhileWriting = 6,
+
+		/**
+		Failed to extract remote connection info from server connect packet.
+		@see CObexClient::ParseConnectPacket()
+		*/
+		ECannotExtractConnectInfo = 7,
+
+		/**
+		Cannot process the challenge/challenge response from the server.
+		@see CObexClient::ParseConnectPacket()
+		*/
+		ECannotProcessChallenge = 8,
+
+		/**
+		Challenge response received but the client did not request one.
+		@see CObexClient::ParseConnectPacket()
+		*/
+		EUnexpectedChallengeResponse = 9,
+
+		/**
+		Unauthorised opcode in server connect packet and there is no challenge header.
+		This means that the server failed to authenticate the client.
+		@see CObexClient::ParseConnectPacket()
+		*/
+		EChallengeAbsent = 10,
+
+		/**
+		The server connect packet contained an unknown opcode.
+		@see CObexClient::ParseConnectPacket()
+		*/
+		EBadOpcodeInConnectPacket = 11,
+
+		/**
+		The client operation timed out.
+		@see CObexClient::TimeoutCompletion()
+		*/
+		EResponseTimeout = 12,
+
+		/**
+		The client operation was aborted by the user.
+		@see CObexClient::OnPacketReceive()
+		*/
+		EAborted = 13,
+
+		/**
+		The transport went down while an operation was outstanding.
+		@see CObexClient::OnTransportDown()
+		@see CObexClient::CompleteRequest()
+		*/
+		EOpOutstandingOnTransportDown = 14,
+
+		/**
+		The server refused the disconnection request
+		because it did not recognise the connection ID.
+		@see CObexClient::OnPacketReceive()
+		*/
+		EBadConnectionId = 15,
+
+		/**
+		The client attempted an operation other than connect while disconnected.
+		@see CObexClient::ClientCommandL()
+		*/
+		EDisconnected = 16,
+
+		/**
+		Could not initialise the object to be sent in the Put/Get request.
+		@see CObexClient::ClientCommandL()
+		*/
+		ECannotInitialiseObject = 17,
+
+		/**
+		Could not set the connection ID on the
+		object to be sent in the Put/Get request.
+		@see CObexClient::ClientCommandL()
+		*/
+		ECannotSetConnectionId = 18,
+
+		/**
+		Could not prepare the next send packet in the Put/Get request.
+		@see CObexClient::ClientCommandL()
+		*/
+		ECannotPreparePacket = 19,
+
+		/**
+		Multipacket response from server to Put/Get (not GetResponse) request.
+		@see CObexClient::OnPacketReceive()
+		*/
+		EMultipacketResponse = 20,
+
+		/**
+		The response from the server contained an error code.
+		@see CObexClient::OnPacketReceive()
+		*/
+		EErrorResponseFromServer = 21,
+
+		/**
+		Could not extract the header from the final Put response packet.
+		@see CObexClient::OnPacketReceive()
+		*/
+		ECannotExtractFinalPutHeader = 22,
+
+		/**
+		The opcode of the Put response packet from the server is
+		not consistent with the progress of the Put operation.
+		@see CObexClient::OnPacketReceive()
+		*/
+		EPutOutOfSync = 23,
+
+		/**
+		The opcode of the Get response packet from the server is Success
+		but the client hasn't finished sending all the Get request packets.
+		@see CObexClient::OnPacketReceive()
+		*/
+		EGetPrematureSuccess = 24,
+
+		/**
+		Could not parse a GetResponse packet from the server.
+		@see CObexClient::OnPacketReceive()
+		*/
+		EGetResponseParseError = 25,
+		};
+
+	static CObexErrorEngine* NewL();
+
+	// Implements MObexClientErrorResolver::LastError().
+	virtual TUint LastError(TObexClientErrorResolutionSetType aErrorSet) const;
+
+	void SetLastError(TObexClientUnderlyingError aError);
+
+private:
+	CObexErrorEngine();
+
+private:
+	TObexClientUnderlyingError iLastError;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexfaults.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,208 @@
+// 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 OBEX_FAULTS_H
+#define OBEX_FAULTS_H
+
+/**
+@file
+@internalComponent
+
+This file contains details of all Obex panics which may be raised as a result
+of an internal programming error.
+*/
+
+
+/**
+Category for Obex faults
+*/
+_LIT(KObexFaultCategory, "ObexFault");
+
+
+/**
+Obex fault codes
+*/
+enum TObexFaultCode
+	{
+	/** USB has entered an unknown state.  This probably means TUsbcDeviceState
+	has changed without Obex being updated accordingly.
+	@see TUsbcDeviceState
+	@see CObexUsbHandler
+	*/
+	EUnknownUsbState				= 0,
+	
+	
+	/** The object still has references to it on destruction.
+	@see CRefCounted
+	*/
+	ERefCountNonZero				= 1,
+	
+	
+	/** An attempt has been made to construct an unknown buffering details
+	object.
+	@see TObexBufferingDetails
+	*/
+ 	EBadBufferDetailsVersion		= 2,
+ 	
+ 	
+	/** No receive packet is available to return.
+	@see CObexServerStateMachine
+	*/
+	ENoReceivePacketAvailable		= 3,
+	
+	
+	/** No notifier has been set to notify of an event.
+	Server should not be started without a notifier, so event handling is
+	not expected to occur.
+	@see CObexServerStateMachine
+	*/
+	ENoNotifierAvailable			= 4,
+	
+	
+	/** Synchronous state wrapper has been errored when calling
+	CObexServer::RequestIndicationCallback().
+	@see CObexServerSyncWrapper
+	*/
+	ESyncWrapperCallbackError		= 5,
+
+
+	/** An unexpected event has been sent to the state machine
+	@see CObexServer
+	@see CObexServerStateMachine
+	*/
+	EServerStateMachineBadEvent		= 6,
+
+	/** CreateTransportInfoL has been given an unrecognised 
+	TObexProtocolInfo::iTransport, and has therefore been unable to create a 
+	TObexTransportInfo.
+	@see IrOBEXUtil
+	*/
+	EUtilNoTransportInfo			= 7,
+
+	/** CObex::TransportDown() has been called
+	This is a legacy function that is retained for backwards compatibility.
+	It does not do anything and should not be called
+	@see CObex::TransportDown()
+	*/
+	ETransportDownCalled			= 8,
+
+	/** RespondAndEndOperation has been called, but the authentication
+	state machine does not think there is an OBEX connection
+	@see TObexServerOperationState::RespondAndEndOperation
+	*/
+	ERespondAndEndOpWithoutObexConnection	= 9,
+
+	/** CObexClient::ClientCommandL() does not recognise the operation
+	code value it is supplied.
+	@see CObexClient::ClientCommandL()
+	*/
+	EClientCommandOpUnrecognised		= 10,
+
+	/** CObexErrorEngine::LastError() does not recognise the error set
+	argument it is supplied.
+	@see CObexErrorEngine::LastError()
+	*/
+	EErrorSetUnrecognised			= 11,
+
+	/** CObexErrorEngine::LastError() does not recognise the underlying
+	error value that has been set.
+	@see CObexErrorEngine::LastError()
+	*/
+	EUnderlyingErrorUnrecognised		= 12,
+
+	/** The last underlying error is set twice during the lifetime
+	of a client operation.
+	@see CObexClient
+	*/
+	ELastErrorSetTwice			= 13,
+
+	/** The last underlying error was not set during the lifetime
+	of a client operation.
+	@see CObexClient
+	*/
+	ELastErrorNotSet			= 14,
+	
+	/** OnPacketReceive has been called but the state machine does not
+	believe the server to have been started.
+	@see CObexServerStateMachine::OnPacketReceive
+	*/
+	EPacketReceivedWhenServerNotStarted = 15,
+	
+	/** ConnectionComplete has been called but the state machine does
+	not believe the server to have been started.
+	@see CObexServerStateMachine::ConnectionComplete
+	*/
+	EConnectionCompleteWhenServerStopped = 16,
+	
+	/** Put received in bad state.  Note that all states where a put
+	is expected to be possible (even if due to invalid remote 
+	behaviour) override the base implementation.
+	@see TObexServerOperationState::Put
+	*/
+	EPutInBadState = 17,
+	
+	/** Get received in bad state.  Note that all states where a get
+	is expected to be possible (even if due to invalid remote 
+	behaviour) override the base implementation.
+	@see TObexServerOperationState::Get
+	*/
+	EGetInBadState = 18,
+	
+	/** SetPath received in bad state.  Note that all states where a 
+	setpath is expected to be possible (even if due to invalid remote 
+	behaviour) override the base implementation.
+	@see TObexServerOperationState::SetPath
+	*/
+	ESetPathInBadState = 19,
+	
+	/** Abort received in bad state.  Note that all states where an
+	abort is expected to be possible (even if due to invalid remote 
+	behaviour) override the base implementation.
+	@see TObexServerOperationState::Abort
+	*/
+	EAbortInBadState = 20,
+	
+	/** ConnectionComplete received in bad state.  Note that all states where
+	this is expected to be possible (even if due to invalid remote 
+	behaviour) override the base implementation.
+	@see TObexServerOperationState::ConnectionComplete
+	*/
+	EConnectionCompleteInBadState = 21,
+	
+	/** TransportUp received in bad state.  Note that all states where
+	this is expected to be possible override the base implementation.
+	@see TObexServerOperationState::TransportUp
+	*/
+	ETransportUpInBadState = 22,
+	
+	/** Connect received in bad state.  Note that all states where
+	this is expected to be possible override the base implementation.
+	@see TObexServerOperationState::Connect
+	*/
+	EConnectInBadState = 23,
+	
+	/** Disconnect received in bad state.  Note that all states where
+	this is expected to be possible override the base implementation.
+	@see TObexServerOperationState::Disconnect
+	*/
+	EDisconnectInBadState = 24,
+
+	/** In the current implementation, the transport controller should be 
+	created at CObex::ConstructL time and persist until ~CObex.
+	*/
+	ETransportControllerNotCreated = 25,
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexfilewriter.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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
+ @internalComponent
+*/
+
+#ifndef __OBEXFILEWRITER_H__
+#define __OBEXFILEWRITER_H__
+
+#include <e32base.h>
+
+/**
+Obex File Writer Interface
+
+This interface is used by Obex objects to write to disk.
+
+Note that this class is the interface to the strategies used as part of
+a Strategy pattern.  CObexAsyncFileWriter and CObexSyncFileWriter provide
+the alternative strategy implementations, with CObexBufObject as the context
+for these strategies.
+
+@see CObexAsyncFileWriter
+@see CObexSyncFileWriter
+@see CObexBufObject
+
+@internalComponent
+@released
+*/
+NONSHARABLE_CLASS(MObexFileWriter)
+
+	{
+public:
+	/**
+	Write the buffer.
+	
+	@param aPos The file position to write at
+	@param aBuf The buffer to write. This object will use the buffer
+ 	            specified by the pointer and may return another buffer
+ 	            to the caller by updating the pointer.  If an error
+ 	            occurs, the pointer will not be updated.  Note that
+ 	            this class never owns any buffers and that passing
+ 	            a buffer to this function does not imply a transfer
+ 	            of ownership
+	@return Symbian OS error code
+	
+	@internalComponent
+	@released
+	*/
+	virtual TInt Write(TInt aPos, CBufBase*& aBuf) =0;
+
+	/**
+	Write the final buffer of the file.
+	
+	This method should synchronously write the
+	buffer, in order to complete writing a file.
+	
+	@param aPos The file position to write at
+	@param aBuf The buffer to write. This object will use the buffer
+ 	            specified by the pointer and may return another buffer
+ 	            to the caller by updating the pointer.  If an error
+ 	            occurs, the pointer will not be updated.  Note that
+ 	            this class never owns any buffers and that passing
+ 	            a buffer to this function does not imply a transfer
+ 	            of ownership
+	@param aLength The amount of the buffer to write
+	@return Symbian OS error code
+	
+	@internalComponent
+	@released
+	*/
+	virtual TInt FinalWrite(TInt aPos, CBufBase*& aBuf, TInt aLength) =0;
+
+	/**
+	Destructor.
+	
+	The usage pattern of MObexFileWriter is such that implementors' NewL 
+	functions return pointers to MObexFileWriter, and clients use them only 
+	via pointers to MObexFileWriter. Therefore a virtual destructor is 
+	required for complete cleanup of implementor objects.
+	
+	@internalComponent
+	@released
+	*/
+	virtual ~MObexFileWriter();
+	};
+
+#endif // __OBEXFILEWRITER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexheaderutil.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,38 @@
+// 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
+ @internalComponent
+*/
+
+#ifndef __OBEXHEADERUTIL_H__
+#define __OBEXHEADERUTIL_H__
+
+class TObexInternalHeader;
+class CObexHeaderSet;
+class CObexHeader;
+
+NONSHARABLE_CLASS(IrOBEXHeaderUtil)
+	{
+public:
+	static TInt ParseHeader(TObexInternalHeader& aHeader, CObexHeaderSet& aHeaderSet);
+	static CObexHeader* CreateAndSetUnicodeHeader(const TUint8 aHI, const TDesC16& aUnicode);
+	static CObexHeader* CreateAndSetByteSeqHeader(const TUint8 aHI, const TDesC8& aByteSeq);
+	static CObexHeader* CreateAndSetUnicodeHeaderL(const TUint8 aHI, const TDesC16& aUnicode);
+	static CObexHeader* CreateAndSetByteSeqHeaderL(const TUint8 aHI, const TDesC8& aByteSeq);
+	}; 
+
+#endif // __OBEXHEADERUTIL_H__ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexnotifyhandlerbase.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,66 @@
+// 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 OBEXNOTIFYHANDLERBASE_H
+#define OBEXNOTIFYHANDLERBASE_H
+
+/**
+@file
+@released
+@internalComponent
+*/
+
+#include <obex.h>
+#include <obex/internal/mobexnotifyextend.h>
+
+class CObexPacket;
+struct TObexConnectionInfo;
+/** Receives notifications from transport.
+
+This is provided as a way of retaining BC for the CObexClient and 
+CObexServer classes.
+
+This class implements the MObexNotifyExtend interface which is provided
+to the transport.  Functions can safely be added to MObexNotifyExtend to 
+allow the transport to provide additional notifications in future without
+altering the vtable for the published classes.  
+
+A CObex owns a CObexNotifyHandlerBase.  The CObexNotifyHandler base
+should not be instantiated directly, instead one of the derived classes
+should be used.  The derived class then knows the type of the CObex
+object created it, as the constructor will require an appropriately
+derived type.  This allows the non-virtual functions in the appropriate
+class to be called to handle notifications.
+
+Functions that are generic CObex functions, rather than functions that
+are handled differently by CObexClient and CObexServer, may be implemented
+in the base class.
+*/
+NONSHARABLE_CLASS(CObexNotifyHandlerBase) : public CBase, public MObexNotifyExtend
+	{
+public:
+	virtual void Process(CObexPacket& aPacket);
+	virtual void Error(TInt aError);
+	virtual void TransportUp();	
+	virtual void TransportDown(TBool aForceTransportDeletion);
+	
+protected:
+	CObexNotifyHandlerBase(CObex& aObex);
+
+protected:
+	CObex& iObex;
+	};
+	
+#endif // OBEXNOTIFYHANDLERBASE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexnotifyhandlerclient.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#ifndef OBEXNOTIFYHANDLERCLIENT_H
+#define OBEXNOTIFYHANDLERCLIENT_H
+
+/**
+@file
+@released
+@internalComponent
+*/
+
+#include "obexnotifyhandlerbase.h"
+
+class CObexClient;
+/** Recieves notifications from transport.
+
+This handles MObexNotifyExtend functions that require knowledge
+that the CObex that owns this class is a CObexClient.
+*/
+NONSHARABLE_CLASS(CObexNotifyHandlerClient) : public CObexNotifyHandlerBase
+	{
+public:
+	CObexNotifyHandlerClient(CObexClient& aObex);
+
+private:
+	virtual void SignalPacketProcessEvent(TObexPacketProcessEvent aEvent);
+	};
+	
+#endif // OBEXNOTIFYHANDLERCLIENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexnotifyhandlerserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#ifndef OBEXNOTIFYHANDLERSERVER_H
+#define OBEXNOTIFYHANDLERSERVER_H
+
+/**
+@file
+@released
+@internalComponent
+*/
+
+#include "obexnotifyhandlerbase.h"
+
+class CObexServer;
+/** Recieves notifications from transport.
+
+This handles MObexNotifyExtend functions that require knowledge
+that the CObex that owns this class is a CObexServer.
+*/
+NONSHARABLE_CLASS(CObexNotifyHandlerServer) : public CObexNotifyHandlerBase
+	{
+public:
+	CObexNotifyHandlerServer(CObexServer& aObex);
+
+private:
+	virtual void SignalPacketProcessEvent(TObexPacketProcessEvent aEvent);
+	};
+	
+#endif // OBEXNOTIFYHANDLERSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexpacketsignaller.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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 OBEXPACKETSIGNALLER_H
+#define OBEXPACKETSIGNALLER_H
+
+/**
+@file
+@internalComponent
+@released
+*/
+
+#include <e32base.h>
+#include <obexfinalpacketobserver.h>
+#include <obexreadactivityobserver.h>
+#include <obex/transport/mobextransportnotify.h>
+
+const TUint KObexPacketSignallerInterestingEvents = EObexFinalPacketStarted | EObexFinalPacketFinished | EObexReadActivityDetected;
+const TUint KObexPacketSignallerInterestingClientEvents = EObexFinalPacketStarted | EObexFinalPacketFinished;
+
+/** This class handles packet process events.  
+
+Currently the only events handled are those for final packet 
+notification and read activity.
+*/
+NONSHARABLE_CLASS(CObexPacketSignaller) : public CActive
+	{
+public:
+	static CObexPacketSignaller* NewL();
+	virtual ~CObexPacketSignaller();
+
+	void SetFinalPacketObserver(MObexFinalPacketObserver* aObserver);
+	void SetReadActivityObserver(MObexReadActivityObserver* aObserver);
+	void Signal(TObexPacketProcessEvent aEvent);
+	
+private:
+	CObexPacketSignaller();
+	
+	void RunL();
+	void DoCancel();
+	
+	void NotifyObserver(TObexPacketProcessEvent aEvent);
+
+private:
+	MObexFinalPacketObserver* iFinalPacketObserver;
+	MObexReadActivityObserver* iReadActivityObserver;
+	TObexPacketProcessEvents iOutstandingEvents;	
+	};
+	
+#endif // OBEXPACKETSIGNALLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexpackettimer.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#ifndef OBEXPACKETTIMER_H
+#define OBEXPACKETTIMER_H
+
+/**
+@file
+@internalComponent
+@released
+*/
+
+#include <e32base.h>
+
+const TInt KLowestPossibleTimerValue = 0;
+
+/** This class handles the timing of Obex reponse packets 
+    from the server
+*/
+class CObexClient;
+	
+NONSHARABLE_CLASS(CObexPacketTimer) : public CTimer
+	{
+public:
+	static CObexPacketTimer* NewL(CObexClient& aObexClient);
+	virtual ~CObexPacketTimer();
+	
+	void SetTimer(TTimeIntervalMicroSeconds32 anInterval);
+	
+private:
+	CObexPacketTimer(CObexClient& aObexClient);
+	virtual void RunL();
+	
+private:
+	CObexClient& iObexClient;
+	};
+	
+#endif // OBEXPACKETTIMER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexservernotifysyncwrapper.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,78 @@
+// 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:
+// All rights reserved.
+// 
+//
+
+#ifndef OBEXSERVERNOTIFYSYNCWRAPPER_H
+#define OBEXSERVERNOTIFYSYNCWRAPPER_H
+
+
+/**
+@file
+@internalComponent
+*/
+
+#include <e32base.h>
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KSyncWrapper, "syncwrapper");
+
+#define WRAPPER_LOG(str) CObexLog::Write(KSyncWrapper, str)
+#else
+#define WRAPPER_LOG(str)
+#endif
+
+/**
+Implements a synchronous wrapper around the asynchronous notification API
+now used by the Obex server.  It therefore provides an SC and BC migration
+path for existing code.
+@see MObexServerNotify
+@see MObexServerNotifyAsync
+*/
+NONSHARABLE_CLASS(CObexServerNotifySyncWrapper) : public CBase, public MObexServerNotifyAsync
+	{
+public:
+	static CObexServerNotifySyncWrapper* NewL(CObexServer& aOwner, CObexServerStateMachine& aStateMachine);
+	~CObexServerNotifySyncWrapper();
+	void SetNotifier(MObexServerNotify* aNotify);
+	
+private:
+	CObexServerNotifySyncWrapper(CObexServer& aOwner, CObexServerStateMachine& aStateMachine);
+
+private:
+	// From MObexServerNotifyAsync
+	void ErrorIndication(TInt aError);
+	void TransportUpIndication();
+	void TransportDownIndication();
+	void ObexConnectIndication(const TObexConnectInfo& aRemoteInfo, const TDesC8& aInfo);
+	void ObexDisconnectIndication(const TDesC8& aInfo);
+	void PutRequestIndication();
+	TInt PutPacketIndication();
+	void PutCompleteIndication();
+	void GetRequestIndication(CObexBaseObject* aRequiredObject);
+	TInt GetPacketIndication();
+	void GetCompleteIndication();
+	void SetPathIndication(const CObex::TSetPathInfo& aPathInfo, const TDesC8& aInfo);
+	void AbortIndication();
+	void CancelIndicationCallback();
+
+private:
+	CObexServer& iOwner;
+	MObexServerNotify* iNotify;
+	TBool		iCallbackOutstanding;
+	CObexServerStateMachine& iStateMachine;
+	};
+
+#endif	// OBEXSERVERNOTIFYSYNCWRAPPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexserveroperationstates.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,425 @@
+// 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 OBEX_SERVER_OPERATION_STATES_H
+#define OBEX_SERVER_OPERATION_STATES_H
+
+/**
+@file
+@internalComponent
+
+Defines base state class and derived state classes for each operation
+*/
+
+#include <obextypes.h>
+#include "logger.h"
+
+static const TInt KMaxStatenameLength = 32;
+
+/**
+Defines the state class interface and default operations for events
+Also provides utility functions for common actions
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerOperationState)
+	{
+public:
+	// Default implementation of events
+	virtual void Entry(CObexServerStateMachine& aContext);
+	
+	virtual void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	
+	virtual void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	
+	virtual void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	
+	virtual void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	
+	virtual void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	
+	virtual void Abort(CObexServerStateMachine& aContext);
+	
+	virtual void TransportUp(CObexServerStateMachine& aContext);
+	
+	virtual void Start(CObexServerStateMachine& aContext);
+	
+	virtual void Reset(CObexServerStateMachine& aContext);
+	
+	virtual void RequestNotificationCompleted(CObexServerStateMachine& aContext, CObexBaseObject* aObject);
+
+	virtual void RequestNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse);
+
+	virtual void RequestCompleteNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse);
+	
+	virtual void ConnectionComplete(CObexServerStateMachine& aContext);
+	
+	virtual void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+
+	virtual TBool ValidResponse(TObexResponse aResponseCode);
+
+	virtual void WriteComplete(CObexServerStateMachine& aContext);
+	
+	virtual void ReadActivityDetected(CObexServerStateMachine& aContext);
+
+
+protected:
+	// Utility functions
+	static void PerformDisconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	static void RespondAndEndOperation(CObexServerStateMachine& aContext, TObexResponse aResponseCode);
+
+#ifdef __FLOG_ACTIVE
+public:
+	TBuf8<KMaxStatenameLength> iName;
+#endif
+	};
+
+
+// State class definitions - defines methods for all the non-default events
+// default events are provided by TObexServerOperationState
+
+/**
+Initial unconnected state
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateDisconnected) : public TObexServerOperationState
+	{
+public:
+	TObexServerStateDisconnected();
+	void Entry(CObexServerStateMachine& aContext);
+	void TransportUp(CObexServerStateMachine& aContext);
+	void Reset(CObexServerStateMachine& aContext);
+	};
+
+/**
+Idle transport connected state (no OBEX connection)
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateTransportConnected) : public TObexServerOperationState
+	{
+public:
+	TObexServerStateTransportConnected();
+	void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Abort(CObexServerStateMachine& aContext);
+	void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+	};
+
+/**
+Processes an OBEX connection attempt
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateObexConnecting) : public TObexServerOperationState
+	{
+public:
+	//Failure cases
+	void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+	
+	//Functional
+	TObexServerStateObexConnecting();
+	void Entry(CObexServerStateMachine& aContext);
+	void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Abort(CObexServerStateMachine& aContext);
+	};
+
+/**
+Waits for a password from the Application as part of connection attempt
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateWaitForUserPassword) : public TObexServerOperationState
+	{
+public:
+	//Failure
+	void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Abort(CObexServerStateMachine& aContext);
+	void Start(CObexServerStateMachine& aContext);
+	void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+	//Functional
+	TObexServerStateWaitForUserPassword();
+	void ConnectionComplete(CObexServerStateMachine& aContext);
+	};
+
+/**
+Idle OBEX connected state
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateReady) : public TObexServerOperationState
+	{
+public:
+	TObexServerStateReady();
+	void Entry(CObexServerStateMachine& aContext);
+	void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Abort(CObexServerStateMachine& aContext);
+	void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+	void ReadActivityDetected(CObexServerStateMachine& aContext);
+	};
+
+/**
+Waits for object to return to Client as part of PUT operation
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStatePutOpWaitForUser) : public TObexServerOperationState
+	{
+public:
+	//Failure cases
+	void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Abort(CObexServerStateMachine& aContext);
+	void Start(CObexServerStateMachine& aContext);
+	void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+	
+	//Functional
+	TObexServerStatePutOpWaitForUser();
+	void Entry(CObexServerStateMachine& aContext);
+	void Reset(CObexServerStateMachine& aContext);
+	void RequestNotificationCompleted(CObexServerStateMachine& aContext, CObexBaseObject* aObject);
+	void RequestNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse);
+	TBool ValidResponse(TObexResponse aResponseCode);
+	
+	// Call-back function used by asynchronous one-shot
+	static TInt ProcessNotification(TAny* aPtr);
+	static TInt ProcessErrorNotification(TAny* aPtr);
+	};
+
+/**
+Receives object from Client as part of PUT operation
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStatePutOpReceiveObject) : public TObexServerOperationState
+	{
+public:
+	//Failure cases
+	void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+	//Functional
+	TObexServerStatePutOpReceiveObject();
+	void Entry(CObexServerStateMachine& aContext);
+	void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Abort(CObexServerStateMachine& aContext);
+	void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	};
+
+/**
+Recevies from Client specification of object to GET
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateGetOpReceiveSpecification) : public TObexServerOperationState
+	{
+public:
+	//Failure cases
+	void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+	//Functional
+	TObexServerStateGetOpReceiveSpecification();
+	void Entry(CObexServerStateMachine& aContext);
+	void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Abort(CObexServerStateMachine& aContext);
+	};
+
+/**
+Waits for object to return to Client as part of GET operation
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateGetOpWaitForUser) : public TObexServerOperationState
+	{
+public:
+	//Failure cases
+	void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Abort(CObexServerStateMachine& aContext);
+	void Start(CObexServerStateMachine& aContext);
+	void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+	
+	//Functional
+	TObexServerStateGetOpWaitForUser();
+	void Entry(CObexServerStateMachine& aContext);
+	void Reset(CObexServerStateMachine& aContext);
+	void RequestNotificationCompleted(CObexServerStateMachine& aContext, CObexBaseObject* aObject);
+	void RequestNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse);
+	TBool ValidResponse(TObexResponse aResponseCode);
+	
+	// Call-back function used by asynchronous one-shot
+	static TInt ProcessNotification(TAny* aPtr);
+	static TInt ProcessErrorNotification(TAny* aPtr);
+	};
+
+/**
+Returns requested object to Client as part of GET operation
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateGetOpSendObject) : public TObexServerOperationState
+	{
+public:
+	//Failure cases
+	void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+	
+	//Functional
+	TObexServerStateGetOpSendObject();
+	void Entry(CObexServerStateMachine& aContext);
+	void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Abort(CObexServerStateMachine& aContext);
+	};
+
+/**
+Performs SETPATH operation and waits for user interaction
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateSetPathOp) : public TObexServerOperationState
+	{
+public:
+	//Failure cases
+	void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Abort(CObexServerStateMachine& aContext);
+	void Start(CObexServerStateMachine& aContext);
+	void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+	
+	//Functional
+	TObexServerStateSetPathOp();
+	void Entry(CObexServerStateMachine& aContext);
+	void Reset(CObexServerStateMachine& aContext);
+	void RequestCompleteNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse);
+	TBool ValidResponse(TObexResponse aResponseCode);
+	
+	static TInt ProcessNotification(TAny* aPtr);
+	};
+
+/**
+Waits for user interaction after receiving the final PUT
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStatePutOpFinal) : public TObexServerOperationState
+	{
+public:
+	//Failure cases	
+	void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Abort(CObexServerStateMachine& aContext);
+	void Start(CObexServerStateMachine& aContext);
+	void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+	
+	//Functional
+	TObexServerStatePutOpFinal();
+	void Entry(CObexServerStateMachine& aContext);
+	void Reset(CObexServerStateMachine& aContext);
+	void RequestCompleteNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse);
+	TBool ValidResponse(TObexResponse aResponseCode);
+	
+	static TInt ProcessNotification(TAny* aPtr);
+private:
+	static void PrepareFinalResponseHeaderSet(CObexHeader* aHeader, CObexHeaderSet& aHeaderSet, CObexPacket& aPacket);
+	};
+
+/**
+Waits for user interaction after receiving the final Get
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateGetOpFinal) : public TObexServerOperationState
+	{
+public:
+	
+	//Failure cases
+	void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Abort(CObexServerStateMachine& aContext);
+	void Start(CObexServerStateMachine& aContext);
+	void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+	
+	//Fucntional
+	TObexServerStateGetOpFinal();
+	void Reset(CObexServerStateMachine& aContext);
+	void Entry(CObexServerStateMachine& aContext);
+	void RequestCompleteNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse);
+	TBool ValidResponse(TObexResponse aResponseCode);
+	
+	static TInt ProcessNotification(TAny* aPtr);
+	};
+		
+/**
+Disconnecting state
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateDisconnecting) : public TObexServerOperationState
+	{
+public:
+	TObexServerStateDisconnecting();
+	
+	//Failure cases
+	void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+	void Abort(CObexServerStateMachine& aContext);
+	void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+
+	//Functional
+	void WriteComplete(CObexServerStateMachine& aContext);
+	};
+
+#endif	// OBEX_SERVER_OPERATION_STATES_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexserverrequestpacketengine.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,61 @@
+// 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:
+// NOTE: This class provides inline functions - DO NOT EXPORT THIS HEADER.
+// 
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef OBEXSERVERREQUESTPACKETENGINE_H
+#define OBEXSERVERREQUESTPACKETENGINE_H
+
+#include <e32base.h>
+#include <obex/internal/mobexserverrequestpacketnotifyregister.h>
+
+class CObexServer;
+class MObexServerRequestPacketNotify;
+
+/**
+Utility class for CObexServer - to allow the OBEX Server extension API for 
+packet access.
+*/
+NONSHARABLE_CLASS(CObexServerRequestPacketEngine) : public CBase, public MObexServerRequestPacketNotifyRegister
+	{
+public:
+	static CObexServerRequestPacketEngine* NewL(CObexServer& aServer);
+	~CObexServerRequestPacketEngine();
+	
+	virtual void SetObexServerRequestPacketObserver(MObexServerRequestPacketNotify& aPacketNotify);
+	virtual void DeleteObexServerRequestPacketNotifyRegister();
+	
+	inline MObexServerRequestPacketNotify* RequestPacketNotify() const;
+	
+private:
+	CObexServerRequestPacketEngine(CObexServer& aServer);
+
+private:
+	CObexServer& iServer;
+	MObexServerRequestPacketNotify* iRequestPacketNotify;
+	};
+
+inline MObexServerRequestPacketNotify* CObexServerRequestPacketEngine::RequestPacketNotify() const
+	{
+	return iRequestPacketNotify;
+	}
+
+#endif // OBEXSERVERREQUESTPACKETENGINE_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexserverstatemachine.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,146 @@
+// 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 OBEX_SERVER_STATE_MACHINE_H
+#define OBEX_SERVER_STATE_MACHINE_H
+
+#include <obextypes.h>
+#include <obex/internal/obexpacket.h>
+#include <obex/transport/obextransportcontrollerbase.h>
+#include "obexserveroperationstates.h"
+#include "OBEXUTIL.H"
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KStateMachineCmpt, "statemachine");
+
+#define STATE_LOG(str) CObexLog::Write(KStateMachineCmpt, str)
+#define STATE_LOG_2(str, a, b) CObexLog::WriteFormat(KStateMachineCmpt, str, a, b)
+#else
+#define STATE_LOG(str)
+#define STATE_LOG_2(str, a, b)
+#endif
+
+/**
+The OBEX Server state machine's context.
+This class holds all the state context information and acts
+as the interface between CObexServer and the current state
+@see TObexServerOperationState
+*/
+NONSHARABLE_CLASS(CObexServerStateMachine) : public CBase
+	{
+public:
+	enum TObexServerOperationStateEnum
+		{
+		EDisconnected,
+		ETransportConnected,
+		EObexConnecting,
+		EWaitForUserPassword,
+		EReady,
+		EPutOpWaitForUser,
+		EPutOpReceiveObject,
+		EGetOpReceiveSpecification,
+		EGetOpWaitForUser,
+		EGetOpSendObject,
+		ESetPathOp,
+		EPutOpFinal,
+		EGetOpFinal,
+		EDisconnecting,
+		EEndOfStates
+		};
+	
+	static CObexServerStateMachine* NewL(CObexServer& aOwner, CObexTransportControllerBase& aTransport);
+	~CObexServerStateMachine();
+	
+	
+	// Events
+	void ChangeState(TObexServerOperationStateEnum aState);
+	void OnPacketReceive(CObexPacket& aPacket);
+	void TransportUp();
+	void TransportDown();
+	void Error();
+	TInt RequestNotificationCompleted(CObexBaseObject* aObject);
+	TInt RequestNotificationCompleted(TObexResponse aAppResponse);
+	TInt RequestCompleteNotificationCompleted(TObexResponse aAppResponse);
+	void ConnectionComplete();
+	void Start(MObexServerNotifyAsync& aNotify);
+	void Stop();
+	void OverrideRequestHandling(TObexResponse aResponse);
+	void WriteComplete();	
+	void ReadActivityDetected();
+	
+	// Getter/setter functions
+	CObexPacket& LastReceivedPacket() const; // no setter needed as is only ever set in OnPacketReceive()
+	
+	// Object specifiying object to GET
+	CObexBaseObject* SpecObject() const; 	// Don't need a setter as we own
+	
+	// Object returned from Application for GET/PUT
+	CObexBaseObject* TransObject() const;
+	void SetTransObject(CObexBaseObject* aTransObject);
+	
+	// Access to CObexServer members
+	CObexTransportControllerBase& Transport() const;
+	CObexServer& Owner() const;
+	MObexServerNotifyAsync& Notification() const;
+	
+	// Header set for final Put response
+	CObexHeaderSet* PutFinalResponseHeaderSet();
+	void SetPutFinalResponseHeaderSet(CObexHeaderSet* aHeaderSet);
+	CObexHeader* GetHeader(); // don't need setter as we own
+
+	// Call-back used to wrap NotificationComplete event
+	void CallBack(TInt (*aFunction)(TAny* aPtr));
+	void CancelCallBack();
+	TBool IsCallBackActive() const;
+	TObexResponse AppResponse() const;
+	void SetAppResponse(TObexResponse aAppResponse);
+
+	void ControlledTransportDown();
+
+private:
+	CObexServerStateMachine(CObexServer& aOwner, CObexTransportControllerBase& aTransport);
+	void ConstructL();
+	
+private:
+	TFixedArray<TObexServerOperationState, EEndOfStates> iStates;	
+	TObexServerOperationState* iCurrentState;
+	
+	CObexPacket* iLastReceivedPacket;
+	CObexBaseObject* iSpecObject;
+	CObexBaseObject* iTransObject;
+	CObexTransportControllerBase& iTransport;
+	
+	CObexServer& iOwner;
+	MObexServerNotifyAsync* iNotification;
+
+	CObexHeaderSet* iPutFinalResponseHeaderSet;
+	CObexHeader* iHeader;
+
+	TBool iServerStarted;
+	
+	CAsyncCallBack* iCallBack;
+	TObexResponse iAppResponse;
+	TObexServerOperationStateEnum iCurrentStateEnum;
+	};
+
+#endif	// OBEX_SERVER_STATE_MACHINE_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexsetpathdata.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,45 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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 __OBEXSETPATHDATA_H__
+#define __OBEXSETPATHDATA_H__
+
+#include <e32def.h>
+#include <obex/internal/obexdata.h>
+
+/**
+Contains the non-standard set-path information in set-path request packets
+@internalComponent
+*/
+NONSHARABLE_CLASS(TObexSetPathData) : public TObexData
+	{
+public:
+	TObexSetPathData ();
+protected:
+	// Implementation of TObexData functions
+	virtual TUint16 DoTotalSize () const;	//< Total size of this data element
+	virtual TUint16 ParseIn (TUint8* aSource, const TUint16 aMaxSize);
+	virtual TUint16 WriteOut (TUint8* aDest, const TUint16 aMaxSize) const;
+public:
+	TUint8 iFlags;
+	TUint8 iConstants;
+	};
+
+#endif // __OBEXSETPATHDATA_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexsyncfilewriter.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,61 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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 __OBEXSYNCFILEWRITER_H__
+#define __OBEXSYNCFILEWRITER_H__
+
+#include <e32base.h>
+#include "obexfilewriter.h"
+
+class RFile;
+/**
+Obex Synchronous File Writer
+
+This object writes data from Obex objects to disk synchronously.
+
+Not intended for derivation.
+
+@internalComponent
+@released
+*/
+NONSHARABLE_CLASS(CObexSyncFileWriter) : public CBase, public MObexFileWriter
+	{
+public:
+	// Construction / destruction
+	static MObexFileWriter* NewL(RFile& aFile);
+	~CObexSyncFileWriter();
+
+private:
+	// From MObexFileWriter
+	TInt Write(TInt aPos, CBufBase*& aBuf);
+	TInt FinalWrite(TInt aPos, CBufBase*& aBuf, TInt aLength);
+
+private:
+	// Construction
+	void ConstructL();
+	CObexSyncFileWriter(RFile& aFile);
+	
+// Unowned
+private:
+	/** Reference to the file which this object is used to write to */
+	RFile&		iFile;
+	};
+
+#endif // __OBEXSYNCFILEWRITER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexunderlyingheader.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,107 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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 __OBEXUNDERLYINGHEADER_H
+#define __OBEXUNDERLYINGHEADER_H
+
+#include <obextypes.h>
+#include <obexheaders.h>
+
+/**
+Implements reference counting.
+
+@internalComponent
+*/
+NONSHARABLE_CLASS(CRefCounted) : public CBase
+	{
+public:
+	CRefCounted();
+	virtual ~CRefCounted();
+	void Open() const;
+	void Close() const;
+
+private:
+	mutable TInt iCount;
+	};
+	
+/**
+Encapsulates an Obex header.
+
+This class provides the ability to hold a header of any of the Obex
+supported types as a native Symbian OS type.
+
+A header may also have one or more attributes set.  These are used by
+the object which owns the header collection so that it can keep track
+of which headers should be sent (!(ESuppressed || EDeleted)), which have
+been sent (ESent), and whether the header should be deleted (EDeleted).
+
+This is a reference counted object and should not be used directly.
+Instead the CObexHeader object provides a facade which not only allows
+the CRefCounted nature of this class to be concealed, but also
+allows header objects to be deleted normally, which decrements the
+count.  Ultimately the count will reach zero, at which point this header
+object will be destroyed.
+
+@see CObexBaseObject 
+@see CObexHeader
+@internalComponent
+*/
+NONSHARABLE_CLASS(CObexUnderlyingHeader) : public CRefCounted
+	{
+public:
+	static CObexUnderlyingHeader* NewL();
+	virtual ~CObexUnderlyingHeader();
+	
+	void ResetContents();
+	void SetAttributes(TUint16 aAttr);
+	TUint16 Attributes() const;
+	
+	CObexHeader::THeaderType Type() const;
+	
+	TUint8   HI() const;
+	TUint8   AsByte() const;
+	TUint32  AsFourByte() const;
+	const TDesC8&  AsByteSeq() const;
+	const TDesC16& AsUnicode() const;
+
+	void SetByte(const TUint8 aHI, const TUint8 aByte);
+	void SetFourByte(const TUint8 aHI, const TUint32 aFourByte);
+	void SetByteSeqL(const TUint8 aHI, const TDesC8& aByteSeq);
+	void SetUnicodeL(const TUint8 aHI, const TDesC16& aUnicode);
+	
+	TInt EncodedSize() const;
+	
+private:
+	CObexUnderlyingHeader();
+
+private:
+	TUint16 iAttributes;
+	TUint8 iHI;
+
+	union
+		{
+		TUint8   iByte;
+		TUint32  iFourByte;
+		HBufC8*  iByteSeq;
+		HBufC16* iUnicode;
+		} iHV;
+	};
+
+#endif // __OBEXUNDERLYINGHEADER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/OBEX.H	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,34 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @publishedAll
+ @released
+*/
+
+#ifndef OBEX_H
+#define OBEX_H
+
+#include <obextypes.h>
+#include <obexconstants.h>
+#include <obexbaseobject.h>
+#include <obexobjects.h>
+#include <obexheaders.h>
+#include <obexbase.h>
+#include <obexclient.h>
+#include <obexserver.h>
+
+#endif // OBEX_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/ObexBtTransportInfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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 __OBEXBTTRANSPORTINFO_H__
+#define __OBEXBTTRANSPORTINFO_H__
+
+#include <bt_sock.h>
+#include <obextransportinfo.h>
+
+/**
+Concrete transport info type for use when using RFCOMM transport controller.
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexBtTransportInfo) : public TObexTransportInfo
+	{
+public:
+	/**
+	The BT device address of the remote party.
+	*/
+	TBTSockAddr iAddr;
+	};
+
+#endif // __OBEXBTTRANSPORTINFO_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/ObexIrTransportInfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,96 @@
+// 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 __OBEXIRTRANSPORTINFO_H__
+#define __OBEXIRTRANSPORTINFO_H__
+
+#include <ir_sock.h>
+#include <obextransportinfo.h>
+
+/**
+Concrete transport info type for use when using Irda ttp  transport controller.
+@see KObexIrTTPProtocol
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexIrTransportInfo) : public TObexTransportInfo
+
+	{
+//From TObexIrProtocolInfo
+public:
+	/** IrDA address information for this connection, as used in the IrDA sockets interface.
+	Refer to the SDK for more information about this.
+	Its main use is for setting the port that the local machine will listen on. */
+	TIrdaSockAddr iAddr;
+	/** The IAS class value that the OBEX session will register its listener port,
+	or request remote port with. */
+	TBuf8<KIASClassNameMax> iClassName;
+	/** The IAS attribute value that the OBEX session will register its listener port,
+	or request remote port with. */
+	TBuf8<KIASAttributeNameMax> iAttributeName;
+	};
+
+/**
+Concrete transport info type for use when using Irda ttp  transport controller, with discovery extensions.
+@see KObexIrTTPProtocolV2
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexIrV2TransportInfo) : public TObexIrTransportInfo
+
+	{
+//From TObexIrProtocolInfo
+public:
+	/** The number of discovery slots to use. */
+	TUint8 iDiscoverySlots;
+	/** The number of discovery attempts to make. */
+	TUint8 iDiscoveryAttempts;
+	
+private:
+	// This data padding has been added to help prevent future binary compatibility breaks	
+	// None of these padding variables have been zero'd because they are currently not used
+	TUint32     iPadding1; 
+	TUint32     iPadding2; 		
+	TUint32     iPadding3; 
+	TUint32     iPadding4; 	
+	};
+
+
+/**
+Concrete transport info type for use when using Irda ttp transport controller, with nickname extension.
+@see KObexIrTTPProtocolV3
+@publishedAll
+
+@capability WriteDeviceData If the TObexIrV3TransportInfo is passed as the argument
+                            to CObexServer::NewL or CObexClient::NewL and the associated 
+                            name is valid.
+
+@released
+*/
+NONSHARABLE_CLASS(TObexIrV3TransportInfo) : public TObexIrV2TransportInfo
+	{
+public:
+	/** The device nickname.  The maximum length in the IrDA specification
+	is defined as 23 - (number of hint octets [2] + 1)  =  20
+	*/
+	TBuf<20> iLocalDeviceNickname;
+	
+	/** A flag indicating if the device nickname field is valid.  This
+	allows Symbian to make further derivations of this interface without making
+	the device nickname mandatory */
+	TBool iLocalDeviceNicknameValid;
+	};
+
+#endif // __OBEXIRTRANSPORTINFO_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/ObexTransportInfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#ifndef __OBEXTRANSPORTINFO_H__
+#define __OBEXTRANSPORTINFO_H__
+
+#include <e32std.h>
+
+/**
+This class is a combination of the TObexProtocolInfo and TObexProtocolPolicy 
+classes.
+This class is designed for licensee derivation, to support novel transport 
+controllers. Existing superclasses include @c TObexUsbTransportInfo, @c 
+TObexUsbV2TransportInfo, @c TObexBtTransportInfo and @c TObexIrTransportInfo. 
+It is also designed for 3rd party instantiation, for use when creation a 
+CObexServer or a CObexClient.
+
+Note that, being a T-type, this type and all derived types must hold data by 
+value, to support bitwise copying.
+
+@publishedAll
+@released
+*/
+class TObexTransportInfo
+	{
+public:
+	/**
+	The type of the transport over which obex will run.
+	The size of the buffer is chosen for historical reasons. This is the size 
+	originally used by TObexProtocolInfo.
+	@publishedAll
+	@released
+	*/
+	TBuf<60> iTransportName; 
+	
+	/**
+	The version of the protocol policy format that this class supports
+	@publishedAll
+	@released
+	*/
+	TUint16 iVersion;
+	
+	/**
+	The maximum size of the receive packet buffer for the policy
+	@publishedAll
+	@released
+	*/
+	TUint16 iReceiveMtu;
+	
+	/**
+	The maximum size of the transmit packet buffer for the policy
+	@publishedAll
+	@released
+	*/
+	TUint16 iTransmitMtu;
+	
+	/**	*/
+	TUint16 iFuture1;
+	
+	/**	*/
+	TUint32 iFuture2;
+	
+	/**	*/
+	TInt iFuture3;
+	
+	/**	*/
+	TInt iFuture4;
+	};
+
+#endif // __OBEXTRANSPORTINFO_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/ObexUsbTransportInfo.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,56 @@
+// 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 __OBEXUSBTRANSPORTINFO_H__
+#define __OBEXUSBTRANSPORTINFO_H__
+
+#include "obextransportinfo.h"
+#include <obexconstants.h>
+
+/**
+Concrete transport info type for use when using the usb  transport controller.
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexUsbTransportInfo) : public TObexTransportInfo
+	{	
+//Data from TObexUsbProtocolInfo class, declared in obex\public\obexconstants.h
+public:
+		/** Provides a string to be attached to the Obex function's Communication Class interface,
+		which may be used to identify the Obex service. */
+		TBuf16<KUsbIntStringDescLength> iInterfaceStringDescriptor;
+	};
+
+/**
+Concrete transport info type when using the USB transport controller with client driver extensions.
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexUsbV2TransportInfo) : public TObexUsbTransportInfo
+	{
+		
+	//Data from TObexUsbProtocolInfoV2 class, declared in obex\public\obexconstants.h
+public:
+	/** Bitmap containing the bandwidth priorities to use on IN and OUT endpoints
+	@see TUsbcBandwidthPriority
+	*/
+	TInt iBandwidthPriority;
+	/** Specifies whether to use DMA on the bulk OUT endpoint */
+	TBool iDmaOnOutEndpoint;
+	/** Specifies whether to use DMA on the bulk IN endpoint */
+	TBool iDmaOnInEndpoint;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexbase.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,235 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @publishedAll
+ @released
+*/
+
+#ifndef __OBEXBASE_H
+#define __OBEXBASE_H
+
+#include <obextypes.h>
+#include <mobexnotify.h>
+
+class CObexTransportControllerBase;
+class TObexTransportInfo;
+class CObexPacket;
+class CObexNotifyHandlerBase;
+
+/**
+@publishedAll
+@released
+
+This class is the common base class for any object which wishes
+to use the Obex Server or Client.
+The class which owns a CObexClient or CObexServer must be provide an object
+derived from this class to handle the call from the Server/Client for a request
+for a Password.
+@see CObex::SetCallBack
+*/
+class MObexAuthChallengeHandler
+	{
+public:
+	/**
+	Indicates that the server/client has received an Authentication challenge. The challenge
+	can only be responded to once a password has been retrieved by some means and passed
+	back to the calling class. The password is passed back via CObex::UserPasswordL
+	@param aRealm This will contain the Realm specified by the unit forcing the
+	Authentication, if no UserID was supplied then this parameter will be of zero length. 
+	*/
+	virtual void GetUserPasswordL(const TDesC& aRealm) = 0;
+		
+	/**
+ 	Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
+	@param aInterface UID of the interface to return
+	@param aObject the container for another interface as specified by aInterface
+	*/
+	IMPORT_C virtual void MOACH_ExtensionInterfaceL(TUid aInterface, void*& aObject);
+	};
+
+/**
+This class is the common base class for CObexClient and CObexServer. It is 
+an abstract class and cannot be instantiated in itself. However, it does 
+contain user functionality common to both client and server connections.
+
+Provides the basic OBEX transport functionality (sending and receiving 
+files)
+Client and server provide the more specialied APIs for
+- initiation or response to puts & gets
+- (possible) handling of more generalised 'objects' (prob. with data buffered through a file).
+
+This class is not designed for user derivation
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObex) : public CBase, protected MObexNotify
+	{
+public:
+	/**
+	Describes the information set or received in a SETPATH command.
+	
+	The first bit of iFlags, 0, can be set to indicate to the receiver of SETPATH to backup a level before applying the path name.
+	The second bit of iFlags, 1, can be set to indicate to the receiver of SETPATH to NOT create the directory if it doesn't exist.
+	The iConstants variable is always set to zero as it is reserved. 
+	The iName variable indicates the directory to create or go to, and does not include the root directory of the receiver (i.e. 
+	if the directory to be set is C:\notes then iName is set to "notes").
+	 If  a name is not set then set CObex::TSetPathInfo::iNamePresent to false. 
+	*/
+	NONSHARABLE_CLASS(TSetPathInfo)
+		{
+	public:
+		IMPORT_C TSetPathInfo();
+		TSetPathInfo(const TObexSetPathData& aData);
+		IMPORT_C TBool Parent() const;
+		TUint8 iFlags;
+		TUint8 iConstants;
+		TBuf<KObexObjectDescriptionSize> iName;
+		/** Whether iName is present in this SETPATH info */	
+		TBool iNamePresent;	
+	private:
+		// This data padding has been added to help prevent future binary compatibility breaks	
+		// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+		TUint32     iPadding1; 
+		TUint32     iPadding2; 				
+		};
+		
+	/**
+	Current obex connection state
+	In general, the further through the enum the values are,
+	the further through the connection process the state machine
+	will be.
+	*/
+	enum TConnectState 
+		{ 
+		EConnIdle,					/** Nothing is happening */
+		EConnTransport,				/** Transport Link connected not yet established true Link */
+		EConnObex,					/** full connection established */
+		ESimpleConnRequest,			/** Connect without Auth has been sent by ClientReceived by Server */
+		EConnChallRxed,				/**  Server has issued a challenge, to a Client cionnect */
+		ESimpleConnChallIssued,		/** Server, received Simple Connect but Server Challenge issued */
+		EChallConnRequested,		/** Connect with Auth has been sent by Client/Received by Server */
+		EChallConnChallIssued,		/** Server has sent a Challenge & Resp to a Client EChallConnRequest */
+		EWaitForFinalResponse,		/** Client, waiting for final success/fail not chall-response expected
+									    Server, Waiting for final Resp fromm Client to Challenge */
+		EFinalResponseReceived,		/** Server, the final response has been received */
+		EFinalChallRxed,			/** Server, Client connect with challenge, Server responds with challenge, Client re-issued original/new challenge */
+		EWaitForUserInput,			/** waiting for the user */
+		EDropLink					/** drop the link */
+		};
+
+	/**
+	The Obex operation currently being performed.
+	*/
+	enum TOperation 
+		{ 
+		EOpConnect		= 0x00, /** Connect */
+		EOpDisconnect	= 0x01, /** Disconnect */
+		EOpPut			= 0x02, /** Put */
+		EOpGet			= 0x03, /** Get */
+		EOpSetPath		= 0x05, /** SetPath */
+		EOpAbort		= 0xFF,	/** Abort - must fit in one pkt so final bit is always set */
+		EOpAbortNoFBit	= 0x7F, /** Abort (internal, never transmitted) */
+		EOpGetResponse  = 0xFD,	/** Internal - not actually an obex operation. */
+		EOpIdle			= 0xFE,	/** Internal - not actually an obex operation. */
+		};
+		
+	/**
+	Flags to suppress the authentication elements of the authentication challenge header.
+	*/
+	enum TObexSuppressedAuthElements
+		{
+		EObexNoSuppressedAuthElements				= 0x00,
+		EObexSuppressChallengeOptionsAuthElement	= 0x01,
+		EObexSuppressRealmAuthElement				= 0x02,
+		EObexSuppressAllAuthElements				= EObexSuppressChallengeOptionsAuthElement | EObexSuppressRealmAuthElement // Must be last
+		};
+	
+	virtual ~CObex();
+	IMPORT_C void SetCallBack(MObexAuthChallengeHandler& aCallBack);
+	IMPORT_C TBool IsConnected() const;
+	IMPORT_C TBool IsStrictPeer() const;
+	IMPORT_C const TObexConnectInfo& LocalInfo() const;
+	IMPORT_C TInt SetLocalWho(const TDesC8& aInfo); 
+    IMPORT_C const TObexConnectInfo& RemoteInfo() const;
+   	IMPORT_C void SuppressAuthenticationHeaderElements(TObexSuppressedAuthElements aSuppressedObexAuthElements);
+	
+	virtual void UserPasswordL( const TDesC& aPassword) = 0; 
+	IMPORT_C void RemoteAddr(TSockAddr& anAddr); 
+
+	TConnectState GetConnectState() const;
+
+	IMPORT_C TBool IsAuthenticating() const;
+	
+	// Handling notified events.
+	void NotifyProcess(CObexPacket& aPacket);
+	void NotifyError(TInt aError);
+	void NotifyTransportUp();
+	void NotifyTransportDown(TBool);
+	
+public: // Implementation of MObexNotify Interface (No longer used)
+	virtual void Process(CObexPacket& aPacket);
+	virtual void Error(TInt aError) ;
+	virtual void TransportUp();
+	virtual void TransportDown(TBool aForceTransportDeletion);
+	
+protected:
+	CObex();
+	virtual void ConstructL(TObexTransportInfo& aObexTransportInfo);
+	virtual TInt ParseConnectPacket(CObexPacket& aPacket) = 0;	
+	void SetConnectState(TConnectState aNewState);
+	IMPORT_C TConnectState ConnectState() const;	// same as GetConnectState - has to be maintained here for BC
+	virtual void OnPacketReceive(CObexPacket& aPacket) =0;
+	virtual void OnError(TInt aError) =0;
+	virtual void OnTransportUp() =0;
+	virtual void OnTransportDown() =0;
+	void ProcessChallengeL(const TObexInternalHeader& hdr);			//process the received challenge
+	void ProcessChallResponseL(const TObexInternalHeader& hdr);		//process the response to challenge
+	TInt GenerateChallenge(CObexPacket& aPacket);					//generate a challenge 
+	void PrepareChallResponseL(const TDesC& aPassword);				//generate a response to challenge
+																		//after user Password input
+	void ForcedTransportDown();
+	void ControlledTransportDown();
+	void RemoteInfoCleanup();
+	void CancelObexConnection();
+protected:
+	TConnectState iConnectState;
+	CObexTransportControllerBase* iTransportController;
+	TObexConnectInfo iLocalInfo;
+	TObexConnectInfo iRemoteInfo;
+	MObexAuthChallengeHandler* iCallBack;
+	TNonce iOutgoingNonce; //nonce used when challenging
+	TNonce iIncomingNonce; //nonce used when receiving a challenge
+	HBufC8* iChallPassword; //password used when challenging
+	HBufC8* iRespPassword; //password used when responding to a challenge
+	HBufC8* iRxChallenge;
+	TBuf8<KChallResponseSize> iOutgoingChallResp;//response to the previously issued challenge
+								//16 nonce, 16 digest resp, 20 UserID, 3*(tag+size)
+	TBuf8<KChallResponseSize> iIncomingChallResp;//response received from previous challenge
+	TBuf8<KObexRespSize> iIncomingRequestDigest;
+	HBufC* iRemoteUID; //UID of remote device
+	HBufC* iRemoteRealm;//Realm of remote device
+	CObexAuthenticator* iAuthEngine;
+	TBool iChallenge; //to challenge or not to challenge?
+	TBool iUserIDRequested; //does the challenge insist that a UserID is returned
+	TBool iReserved; //released boolean now available for future use
+	TOperation iCurrentOperation;
+	CObexNotifyHandlerBase* iNotifyHandler;
+	TUint iSuppressedObexAuthElements;
+	};
+
+#endif // __OBEXBASE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexbaseobject.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,145 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @publishedAll
+ @released
+*/
+
+#ifndef __OBEXBASEOBJECT_H
+#define __OBEXBASEOBJECT_H
+
+#include <obextypes.h>
+#include <f32file.h>
+
+const TUint32 KConnIDInvalid = 0xffffffff;
+
+/**
+Objects of this class are used to describe the objects to be transferred and
+those received via Obex.
+Consists of a number of attributes describing the object, along with
+methods to set them. CObexBaseObject is an abstract base class, which defines
+attribute setting and transferring functionality, but does not specify the
+storage mechanism for the data part (called the object body) of the object.
+This body part is defined in derived classes.
+
+Object description attributes are tracked for validity automatically, so
+that only valid attributes are sent to the remote machine. Also has the
+concept of "header masks". This selects which of the various attributes
+will actually be sent out/read in when the object is used in an operation
+with the remote machine. Objects default to transferring all valid
+attributes, use the header mask if restriction is required on the headers
+exchanged.
+
+See the various derived classes for description of object body
+representation.
+
+The common attributes are defined to be as close to the underlying OBEX
+headers as usefully possible, hence any OBEX header specified as a Unicode
+string (e.g. Name) translate to TDes (variant) EPOC descriptors, "byte
+sequences" (e.g. Type) are TDes8 (or ASCII invariant), and byte and 32 bit
+integers (e.g. Length) are TUint32s.
+
+This class is not designed for user derivation (ie. outside of this dll).
+
+@see CObexHeader
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObexBaseObject) : public CBase
+	{
+// required for access to iValidHeaders in CObexServer::CheckForConnectionID
+friend class CObexServer;
+
+public:
+	virtual ~CObexBaseObject();
+	IMPORT_C void SetHeaderMask(const TObexHeaderMask aHeaderMask);
+	IMPORT_C void SetNameL(const TDesC& aDesc);
+	IMPORT_C void SetTypeL(const TDesC8& aDesc);
+	IMPORT_C void SetLengthL(const TUint32 aLength);
+	IMPORT_C void SetTimeL(const TTime aLocalTime);
+	IMPORT_C void SetDescriptionL(const TDesC& aDesc);
+	IMPORT_C void SetTargetL(const TDesC8& aDesc);
+	IMPORT_C void AddHttpL(const TDesC8& aDesc);
+	IMPORT_C void SetAppParamL(const TDesC8& aDesc);
+	
+	IMPORT_C void AddHeaderL(CObexHeader& aHeader);
+	IMPORT_C TInt BytesSent();
+	IMPORT_C TInt BytesReceived();
+	IMPORT_C TObexHeaderMask HeaderMask();
+	IMPORT_C TObexHeaderMask ValidHeaders();
+	IMPORT_C const TDesC& Name();
+	IMPORT_C const TDesC8& Type();
+	IMPORT_C TUint32 Length();
+	IMPORT_C const TTime Time();
+	IMPORT_C const TDesC& Description();
+	IMPORT_C const TDesC8& Target();
+	IMPORT_C const RPointerArray<HBufC8>* Http() const;
+	IMPORT_C const TDesC8& AppParam() const;
+	IMPORT_C void Reset();
+	IMPORT_C const CObexHeaderSet& HeaderSet() const;
+	IMPORT_C CObexHeaderSet& HeaderSet();
+
+	// Public unexported functions used by CObexServer, CObexClient, etc
+	enum TProgress { EContinue,EComplete,EError,ELastPacket };
+	TInt InitSend(TObexOpcode aOpcode);
+	TProgress PrepareNextSendPacket(CObexPacket& aPacket);
+	TInt InitReceive();
+	TProgress ParseNextReceivePacket(CObexPacket& aPacket);
+	void PrepareConnectionHeader( CObexPacket& aPacket );
+	void SetConnectionIdL(TUint32 aFourByte);
+	TUint32 ConnectionID();
+	TObexResponse GetLastError() const;
+
+protected:
+	CObexBaseObject();
+	void GuessTypeFromExtL(const TDesC& aExt);
+	void ResetHeaders();
+	// Pure virtuals that all derived objects must implement
+	virtual void GetData(TInt aPos, TDes8& aDes) =0;
+	virtual void NewData(TInt aPos, TDes8& aDes) =0;
+	virtual TInt DataSize() =0;
+	virtual void ResetData() =0;
+	void CreateHeaderStorageDataL();
+	void SetTimeHeaderL(const TDesC8& aTimeDes);
+	void SetUtcTimeL(const TTime aUtcTime);
+	
+// Data
+private:
+	TObexHeaderMask iHeaderMask;
+	TObexHeaderMask iValidHeaders;
+
+	mutable RPointerArray<HBufC8>* iHttp;
+
+	CObexHeaderSet* iHeaderSet;
+	
+	TProgress iSendProgress;
+	TProgress iRecvProgress;
+	TObexOpcode iSendOpcode;
+
+	// This data item is used to store a CObexHeader which is used as a temporary
+	// store when finding headers
+	CObexHeader* iObexHeader;
+	
+	TObexHeaderMask iSendHeaders; 
+	TInt iSendBytes;
+	TInt iRecvBytes;
+	
+	TObexResponse iLastError;
+	
+	};
+
+#endif // __OBEXBASEOBJECT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexclient.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,108 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @publishedAll
+ @released
+*/
+
+#ifndef __OBEXCLIENT_H
+#define __OBEXCLIENT_H
+
+#include <obextypes.h>
+#include <obexbase.h>
+
+class CObexPacket;
+class MObexFinalPacketObserver;
+class CObexPacketSignaller;
+class CObexPacketTimer;
+class CObexErrorEngine;
+
+/**
+Client side functionality. Connection based.
+Supports ...
+- Opening IrDA TTP sockets for the OBEX session.
+- Opening an OBEX session over a connected socket
+- Standard OBEX (spec. version 1.2) operations.
+ 
+This class is not designed for user derivation.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObexClient) : public CObex
+	{
+public:
+	IMPORT_C ~CObexClient();
+	IMPORT_C static CObexClient* NewL(TObexProtocolInfo& aObexProtocolInfoPtr);
+	IMPORT_C static CObexClient* NewL(TObexProtocolInfo& aObexProtocolInfoPtr, TObexProtocolPolicy& aObexProtocolPolicy);
+	IMPORT_C static CObexClient* NewL(TObexTransportInfo& aObexTransportInfo);
+	IMPORT_C void Connect(TRequestStatus& aStatus);
+	IMPORT_C void Connect(CObexBaseObject& aObject, TRequestStatus& aStatus);	
+	IMPORT_C void ConnectL(CObexBaseObject& aObject, const TDesC& aPassword, TRequestStatus& aStatus);
+	IMPORT_C void ConnectL(const TDesC& aPassword, TRequestStatus& aStatus);
+	IMPORT_C void Disconnect(TRequestStatus& aStatus);						
+	IMPORT_C void Put(CObexBaseObject& aObject, TRequestStatus& aStatus);
+	IMPORT_C void Get(CObexBaseObject& aObject, TRequestStatus& aStatus);		
+	IMPORT_C void SetPath(TSetPathInfo& aPathInfo, TRequestStatus& aStatus);
+	IMPORT_C void Abort();					
+	IMPORT_C void UserPasswordL( const TDesC& aPassword);
+	IMPORT_C const CObexHeaderSet& GetPutFinalResponseHeaders();
+	IMPORT_C void SetFinalPacketObserver(MObexFinalPacketObserver* aObserver);
+	IMPORT_C TObexResponse LastServerResponseCode() const;
+	IMPORT_C void SetCommandTimeOut(TTimeIntervalMicroSeconds32 aTimeOut);
+	IMPORT_C TAny* ExtensionInterface(TUid aUid);
+
+public:	// Called from CObexNotifyExtendClient
+	void SignalPacketProcessEvent(TInt aEvent);
+	void TimeOutCompletion();
+	
+private:
+	CObexClient();
+	void ConstructL(TObexTransportInfo& aObexTransportInfo);
+	TBool AlreadyActive(TRequestStatus& aStatus);
+	void ClientCommandL(TOperation aOp, TAny* aParam, TRequestStatus& aStatus);
+	// Implementation of CObex Events
+	virtual void OnPacketReceive(CObexPacket& aPacket);
+	virtual void OnError(TInt aError);
+	virtual void OnTransportUp();
+	virtual void OnTransportDown();
+	void SetRequest(TRequestStatus& aStatus, TOperation aOperation);
+	void CompleteRequest(const TInt aCompletion);
+	TInt PrepareConnectPacket(CObexPacket& aPacket);	// Should be members of TConnectInfo
+	TInt ParseConnectPacket(CObexPacket& aPacket);	
+	void ResetConnectionID();
+	void SetConnectionID(TUint32 aConnectionID);
+	void EmptyHeaderSet();
+	void SendRequestPacket();
+	void SendRequestPacket(TObexOpcode aObexOpcode);
+
+private: 
+	TRequestStatus* iPendingRequest;
+	CObexBaseObject* iCurrentObject;
+	TUint32 iConnectionID; 
+	TBool iConnectionIdSet;
+	CObexHeaderSet* iHeaderSet;
+	CObexHeader* iHeader;
+	CObexPacketSignaller* iPacketProcessSignaller;
+	TObexResponse iLastReceivedResponseOpcode;
+	CObexErrorEngine* iErrorEngine;
+	TBool iIsLastErrorSet;
+	TTimeIntervalMicroSeconds32 iCmdTimeOutDuration;
+	CObexPacketTimer* iPacketTimer;
+	};
+
+#endif // __OBEXCLIENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexconstants.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,595 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @publishedAll
+ @released
+*/
+
+#ifndef __OBEXCONSTANTS_H
+#define __OBEXCONSTANTS_H
+
+#include <e32std.h>
+#include <es_sock.h>
+#include <ir_sock.h>
+#include <bt_sock.h>
+#include <obexpanics.h>
+#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <obexconstantsinternal.h>
+#endif
+
+
+/** @publishedAll */
+const TInt KChallResponseSize = 58;
+/** @publishedAll */
+const TInt KObexRespSize = 16;
+/** @publishedAll */
+const TInt KUsbIntStringDescLength = 30;
+/** @publishedAll */
+const TUint8 KObexObjectDescriptionSize = 255;
+
+// Extended errors for IrObex
+
+/** Must not use as not in the allocated range */
+const TInt KErrIrObexRespBase			= - 5500; 
+
+/** Extended error for IrObex - No other infrared device found */
+const TInt KErrIrObexClientNoDevicesFound = -5501;
+
+/** Extended error for IrObex - Other IR device cannot handle IrObex */
+const TInt KErrIrObexClientPeerDoesNotHaveObex = -5502;
+
+/** Extended error for IrObex - Other IR device aborted the transfer */
+const TInt KErrIrObexClientPutPeerAborted	= -5503;
+
+/** Extended error for IrObex - Peer device aborted data transmission/obex sending */
+const TInt KErrIrObexServerPutPeerAborted = -5507;
+
+/** Extended error for IrObex - Cannot authorise the challenge so link dropped */
+const TInt KErrIrObexConnectChallRejected = -5512;
+
+// Other Obex errors defined in the system but no longer used
+// Do not reuse the number!
+// KErrIrObexClientPutPeerCannotHandleObject -5504
+// KErrIrObexServerPutFileWriteError		-5509
+// KErrIrObexClientFirstPutFailed			-5510
+// KErrIrObexClientSubsequentPutFailed		-5511
+
+/** Unexpected event for the given state */
+const TInt KErrIrObexBadEvent = -5513;
+
+/** Event occurred while Server is stopped */
+const TInt KErrIrObexServerStopped = -5514;
+
+/** Packet received while state machine is in a wait state */
+const TInt KErrIrObexPacketDuringWait = -5515;
+
+// There are other error codes defined at the end of this file,
+// which are a direct mapping of specific Obex error codes and
+// are returned by the client.
+
+
+// Flags used by Connect
+// ...None in OBEX 1.0
+
+
+/**
+Version number for TObexTransportInfo and derived classes.  
+When iVersion is set to this value the following fields of TObexTransportInfo  
+must be set:
+iTransportName, 
+iReceiveMtu
+iTransmitMtu
+The iVersion member variable must be set to this value. If in future any of the 
+iFuture variables are used a new version constant will be created.
+
+@see TObexTransportInfo
+@publishedAll
+@released
+*/
+const TInt KObexTransportInfoVersion0 = 0;	
+
+/**
+Default for the receive and transmit MTU sizes
+Use this default value for setting the iReceiveMtu or iTransmitMtu in TObexTransportInfo
+objects or derived classes.
+
+@see TObexTransportInfo
+@publishedAll
+@released
+*/
+const TInt KObexDefaultMtuSize = 4000;
+
+/**
+Default value for the number of discovery slots to use.  Use this value as a default 
+for iDiscoverySlots in TObexIrdaV2TransportInfo.  
+
+@see TObexIrdaV2TransportInfo
+@publishedAll
+@released
+*/
+const TUint KObexIrdaDefaultDiscoverySlotsToUse = 1;
+
+/**
+Default value for the number of discovery attempts made.  Use this value as a default for iDiscoveryAttempts
+in TObexIrdaV2TransportInfo.  
+@see TObexIrdaV2TransportInfo
+@publishedAll
+@released
+*/
+const TUint KObexIrdaDefaultDiscoveryAttempts = 4;
+
+// Constants used to define which transport Obex will run over.
+// Used in TObexTransportInfo and TObexProtocolInfo's iTransport member.
+
+/**
+Protocol string when running over IrDA
+@see TObexIrProtocolInfo
+@see TObexTransportInfo
+@publishedAll
+@released
+*/
+_LIT(KObexIrTTPProtocol, "IrTinyTP");
+
+/**
+Protocol string when running over IrDA
+Using this version indicates that the configuration object contains discovery parameters.
+@see TObexIrProtocolInfo
+@publishedAll
+@released
+*/
+_LIT(KObexIrTTPProtocolV2, "IrTinyTP-V2");
+
+/**
+Protocol string when running over IrDA
+Using this version indicates that the configuration object contains the device nickname.
+@see TObexIrProtocolInfo
+@publishedAll
+
+@capability WriteDeviceData If the TObexIrV3TransportInfo is passed as the argument
+                            to CObexServer::NewL or CObexClient::NewL and the associated 
+                            name is valid.
+@released
+*/
+_LIT(KObexIrTTPProtocolV3, "IrTinyTP-V3");
+
+/**
+Protocol string when running over Bluetooth
+@see TObexBluetoothProtocolInfo
+@see TObexTransportInfo
+@publishedAll
+@released
+*/
+_LIT(KObexRfcommProtocol, "RFCOMM");
+
+/**
+Protocol string when running over USB
+@see TObexUsbProtocolInfo
+@see TObexTransportInfo
+@publishedAll
+@released
+*/
+_LIT(KObexUsbProtocol, "USB");
+
+/**
+Place holder for...
+protocol string that should be used 
+if a Win32 emulator USB transport were 
+to be created for testing.
+@see TObexUsbProtocolInfo
+@see TObexTransportInfo
+@publishedAll
+@released
+*/
+_LIT(KObexWin32UsbProtocol, "Win32Usb");
+
+/**
+Protocol string when running over USB using client driver extensions
+@see TObexUsbProtocolInfoV2
+@see TObexTransportInfo
+@publishedAll
+@released
+*/
+_LIT(KObexUsbProtocolV2, "USB-V2");
+
+/** 
+This class is derived for each underlying transport protocol OBEX 
+runs over.
+
+The iTransport member holds the unique name for the transport. For example for
+infra-red (TinyTP) this is "IrTinyTP" or KObexIrTTPProtocol.
+
+@see TObexIrProtocolInfo for running over TinyTP
+@see TObexBluetoothProtocolInfo for running over Rfcomm
+@see TObexUsbProtocolInfo for running over USB
+@see TObexUsbProtocolInfoV2 for running over USB using client driver extensions
+
+@see KObexIrTTPProtocol
+@see KObexIrTTPProtocolV2
+@see KObexRfcommProtocol
+@see KObexUsbProtocol
+@see KObexUsbProtocolV2
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexProtocolInfo)
+	{
+public:
+	/** Holds the unique name for the transport. */
+	TBuf<60> iTransport;
+private:
+	// This data padding has been added to help prevent future binary compatibility breaks	
+	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+	TUint32     iPadding1; 
+	TUint32     iPadding2; 		
+	};
+
+/** 
+Used to describe IrDA specific protocol information
+	
+To access the default OBEX server, the IAS class value should be "OBEX"
+and the IAS attribute name "IrDA:TinyTP:LsapSel". 
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexIrProtocolInfo) : public TObexProtocolInfo
+	{
+public:
+	/** IrDA address information for this connection, as used in the IrDA sockets interface.
+	Refer to the SDK for more information about this.
+	Its main use is for setting the port that the local machine will listen on. */
+	TIrdaSockAddr iAddr;
+	/** The IAS class value that the OBEX session will register its listener port,
+	or request remote port with. */
+	TBuf8<KIASClassNameMax> iClassName;
+	/** The IAS attribute value that the OBEX session will register its listener port,
+	or request remote port with. */
+	TBuf8<KIASAttributeNameMax> iAttributeName;
+	/** The number of discovery slots to use. */
+	TUint8 iDiscoverySlots;
+	/** The number of discovery attempts to make. */
+	TUint8 iDiscoveryAttempts;
+
+private:
+	// This data padding has been added to help prevent future binary compatibility breaks	
+	// None of these padding variables have been zero'd because they are currently not used
+	TUint16     iPadding1; 
+	TUint32     iPadding2; 		
+	TUint32     iPadding3; 
+	TUint32     iPadding4; 	
+	};
+
+/** 
+Used to describe Bluetooth specific protocol information
+	
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexBluetoothProtocolInfo) : public TObexProtocolInfo
+	{
+public:
+	/** 
+	For OBEX servers:
+	This defines the server channel on which the OBEX server listens 
+	for connections. The server channel is set using SetPort on the 
+	TRfcommSockAddr.
+	Note:
+	1) Unless the channel is defined as KRfcommPassiveAutoBind 
+	it may be in use when the obex server attempts to 'bind' to it
+	2) If the channel is defined as KRfcommPassiveAutoBind 
+	then when the server is FIRST started it will attempt 
+	to find a free RFComm channel. If this is successful 
+	that free channel will be used as the server channel 
+	for the life time of the obex server including
+	when it is 'stopped' and re-'started'.
+	3) When the obex server is stopped, and very
+	briefly when a bluetooth connection comes down, the
+	obex server releases its server channel. It is possible
+	therefore that during this time another application might bind
+	to it. This will cause an error when the obex server tries
+	to re-bind.
+
+	Also note that a Bluetooth OBEX server will itself set the Object Transfer
+	bit in the Service Class as required by the Generic Object Exchange
+	Profile so the user need not do this.	
+	@see CObexServer
+	
+	For OBEX clients:
+	This defines the server channel and the 
+	device address to connect to. The server channel 
+	and device address are set respectively using SetPort 
+	and SetBTAddr on the TRfcommSockAddr.
+	*/
+	TRfcommSockAddr iAddr;
+	
+private:
+	// This data padding has been added to help prevent future binary compatibility breaks	
+	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+	TUint32     iPadding1; 
+	TUint32     iPadding2; 	
+	};
+
+/** 
+Used to describe USB specific protocol information
+	
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexUsbProtocolInfo) : public TObexProtocolInfo
+	{
+public:
+	/** Provides a string to be attached to the Obex function's Communication Class interface,
+	which may be used to identify the Obex service. */
+	TBuf16<KUsbIntStringDescLength> iInterfaceStringDescriptor;
+	};
+
+/** 
+Used to set options used by the extended USB client driver for improved performance
+	
+@see TObexUsbProtocolInfo
+@see RDevUsbcClient
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexUsbProtocolInfoV2) : public TObexUsbProtocolInfo
+	{
+public:
+	/** Bitmap containing the bandwidth priorities to use on IN and OUT endpoints
+	@see TUsbcBandwidthPriority
+	*/
+	TInt iBandwidthPriority;
+	/** Specifies whether to use DMA on the bulk OUT endpoint */
+	TBool iDmaOnOutEndpoint;
+	/** Specifies whether to use DMA on the bulk IN endpoint */
+	TBool iDmaOnInEndpoint;
+	
+private:
+	// This data padding has been added to help prevent future binary compatibility breaks	
+	// None of these padding variables have been zero'd because they are currently not used
+	TUint32     iPadding1; 
+	TUint32     iPadding2; 		
+	TUint32     iPadding3; 
+	TUint32     iPadding4; 	
+	};
+
+/**
+Contains information about OBEX packet sizing policy, defining the
+maximum buffer size for receive and transmit packets
+*/
+NONSHARABLE_CLASS(TObexProtocolPolicy)
+	{
+public:
+	IMPORT_C TObexProtocolPolicy ();	// Sets version and default values
+
+	IMPORT_C TInt SetReceiveMtu ( TUint16 aReceiveMtu );
+	IMPORT_C TInt SetTransmitMtu ( TUint16 aTransmitMtu );
+	IMPORT_C TUint16 Version () const;
+	IMPORT_C TUint16 ReceiveMtu () const;
+	IMPORT_C TUint16 TransmitMtu () const;
+
+private:
+	TUint16 iVersion;
+	TUint16 iReceiveMtu;
+	TUint16 iTransmitMtu;
+
+	// This data padding has been added to help prevent future binary compatibility breaks	
+	// None of these padding variables have been zero'd because they are currently not used
+	TUint32     iPadding1; 
+	TUint32     iPadding2; 		
+	TUint32     iPadding3; 
+	TUint32     iPadding4; 	
+	};
+
+struct TObexConnectionInfo;
+
+/**
+TObexConnectInfo
+This structure contains information used during OBEX connection. iVersion
+holds the encoded OBEX version of the machine, use @c VersionMajor() and
+@c VersionMinor() to extract the parts of the version number (each having a
+value from 0 to 15). @c iFlags holds OBEX connection flags. @c iWho holds 
+the Who attribute from the connect packet, if any was specified, or 
+otherwise has a length of 0. 
+It is recommended that this class is only ever allocated on the heap as it is quite big.
+*/
+NONSHARABLE_CLASS(TObexConnectInfo)
+	{
+public:
+	IMPORT_C TObexConnectInfo();
+	IMPORT_C TUint8 VersionMajor() const;
+	IMPORT_C TUint8 VersionMinor() const;
+public:
+	TUint8 iVersion; /** Encoded OBEX version of the machine*/
+	TUint8 iFlags; /** iFlags holds OBEX connection flags*/
+	TBuf8<KObexObjectDescriptionSize> iWho; /** the Who attribute from the connect packet, if any was specified */
+	TBuf8<KObexObjectDescriptionSize> iTargetHeader; /** the Target header from the connect packet, if any was specified */
+	
+private:
+	// This data padding has been added to help prevent future binary compatibility breaks	
+	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+	TUint32     iPadding1; 
+	TUint32     iPadding2; 	
+	};
+
+
+
+//if these codes are extended due to a IRObex spec update ensure 
+//that the TInt immediately below are updated 
+//and the default in the method IrOBEXUtil::ObexResponse is also updated
+enum TObexResponse  
+	{ 
+/** Response is "Continue" */	
+	ERespContinue			= 0x10,
+	
+/** Response is "Success" */		
+	ERespSuccess			= 0x20,
+	
+/** Response is "Created" */		
+	ERespCreated			= 0x21,
+	
+/** Response is "Accepted" */		
+	ERespAccepted			= 0x22,
+	
+/** Response is "Non-Authenticated Information" */		
+	ERespNonAuthInfo		= 0x23,
+	
+/** Response is "No Content" */			
+	ERespNoContent			= 0x24,
+	
+/** Response is "Reset Content" */				
+	ERespResetContent		= 0x25,
+	
+/** Response is "Partial Content" */					
+	ERespPartialContent		= 0x26,
+	
+/** Response is "Multiple Choices" */						
+	ERespMultipleChoices	= 0x30,
+	
+/** Response is "Moved Permanently" */						
+	ERespMovedPerm			= 0x31,
+	
+/** Response is "Moved Temporarily" */							
+	ERespMovedTemp			= 0x32,
+
+/** Response is "See Other" */								
+	ERespSeeOther			= 0x33,
+
+/** Response is "Not Modified" */									
+	ERespNotModified		= 0x34,
+
+/** Response is "Use Proxy" */									
+	ERespUseProxy			= 0x35,
+
+/** Response is "Bad Request" */									
+	ERespBadRequest			= 0x40,
+
+/** Response is "Unauthorized" */									
+	ERespUnauthorized		= 0x41,
+
+/** Response is "Payment Required" */									
+	ERespPaymentRequired	= 0x42,
+
+/** Response is "Forbidden" */									
+	ERespForbidden			= 0x43,
+
+/** Response is "Not Found" */										
+	ERespNotFound			= 0x44,
+
+/** Response is "Method Not Allowed" */										
+	ERespMethodNotAllowed	= 0x45,
+
+/** Response is "Not Acceptable" */									
+	ERespNotAcceptable		= 0x46,
+
+/** Response is "Proxy Authentication is Required" */										
+	ERespProxyAuthenReqd	= 0x47,
+
+/** Response is "Timed Out" */										
+	ERespTimedOut			= 0x48,
+
+/** Response is "Conflict" */										
+	ERespConflict			= 0x49,
+
+/** Response is "Gone" */										
+	ERespGone				= 0x4A,
+
+/** Response is "Length Required" */										
+	ERespLengthReqd			= 0x4B,
+
+/** Response is "Precondition Failed" */											
+	ERespPreCondFailed		= 0x4C,
+
+/** Response is "Required Entity is Too Large" */											
+	ERespReqEntityTooLarge	= 0x4D,
+
+/** Response is "Required URL is Too Large" */											
+	ERespReqURLTooLarge		= 0x4E,
+
+/** Response is "Unsupported Media Type" */											
+	ERespUnsupMediaType		= 0x4F,
+
+/** Response is "Internal Error" */											
+	ERespInternalError		= 0x50,
+
+/** Response is "Not Implemented" */											
+	ERespNotImplemented		= 0x51,
+
+/** Response is "Bad Gateway" */											
+	ERespBadGateway			= 0x52,
+
+/** Response is "Service Unavailable" */											
+	ERespServiceUnavail		= 0x53,
+
+/** Response is "Gateway Timeout" */											
+	ERespGatewayTimeout		= 0x54,
+
+/** Response is "HTTP Version is Not Supported" */											
+	ERespHTTPVerNotSupp		= 0x55,
+
+/** Response is "Database is Full" */											
+	ERespDatabaseFull		= 0x60,
+
+/** Response is "Database is Locked" */											
+	ERespDatabaseLocked		= 0x61,
+
+/** Response is "Service is Unavailable" */											
+	ERespServiceUnavailable = 0xD3,
+	};
+
+
+//some error codes to be used specifically by the client
+//these shall, be mapped directly to OBEX defined error codes.
+const TInt KErrIrObexRespSuccess		= KErrIrObexRespBase - ERespSuccess;			//-5532 returns 0x20 (0xA0)
+const TInt KErrIrObexRespCreated		= KErrIrObexRespBase - ERespCreated;			//-5533 returns 0x21 (0xA1)
+const TInt KErrIrObexRespAccepted		= KErrIrObexRespBase - ERespAccepted;			//-5534 returns 0x22 (0xA2)
+const TInt KErrIrObexRespNonAuthInfo	= KErrIrObexRespBase - ERespNonAuthInfo;		//-5535 returns 0x23 (0xA3)
+const TInt KErrIrObexRespNoContent		= KErrIrObexRespBase - ERespNoContent;			//-5536 returns 0x24 (0xA4)
+const TInt KErrIrObexRespResetContent	= KErrIrObexRespBase - ERespResetContent;		//-5537 returns 0x25 (0xA5)
+const TInt KErrIrObexRespPartialContent = KErrIrObexRespBase - ERespPartialContent;		//-5538 returns 0x26 (0xA6)
+const TInt KErrIrObexRespMultipleChoices = KErrIrObexRespBase - ERespMultipleChoices;	//-5548 returns 0x30 (0xB0)
+const TInt KErrIrObexRespMovedPerm		= KErrIrObexRespBase - ERespMovedPerm;			//-5549 returns 0x31 (0xB1)
+const TInt KErrIrObexRespMovedTemp		= KErrIrObexRespBase - ERespMovedTemp;			//-5550 returns 0x32 (0xB2)
+const TInt KErrIrObexRespSeeOther		= KErrIrObexRespBase - ERespSeeOther;			//-5551 returns 0x33 (0xB3)
+const TInt KErrIrObexRespNotModified	= KErrIrObexRespBase - ERespNotModified;		//-5552 returns 0x34 (0xB4)
+const TInt KErrIrObexRespUseProxy		= KErrIrObexRespBase - ERespUseProxy;			//-5553 returns 0x35 (0xB5)
+const TInt KErrIrObexRespBadRequest		= KErrIrObexRespBase - ERespBadRequest;			//-5564 returns 0x40 (0xC0)
+const TInt KErrIrObexRespUnauthorized	= KErrIrObexRespBase - ERespUnauthorized;		//-5565 returns 0x41 (0xC1)
+const TInt KErrIrObexRespPaymentRequired = KErrIrObexRespBase - ERespPaymentRequired;	//-5566 returns 0x42 (0xC2)
+const TInt KErrIrObexRespForbidden		= KErrIrObexRespBase - ERespForbidden;			//-5567 returns 0x43 (0xC3)
+const TInt KErrIrObexRespNotFound		= KErrIrObexRespBase - ERespNotFound;			//-5568 returns 0x44 (0xC4)
+const TInt KErrIrObexRespMethodNotAllowed = KErrIrObexRespBase - ERespMethodNotAllowed;	//-5569 returns 0x45 (0xC5)
+const TInt KErrIrObexRespNotAcceptable	= KErrIrObexRespBase - ERespNotAcceptable;		//-5570 returns 0x46 (0xC6)
+const TInt KErrIrObexRespProxyAuthenReqd = KErrIrObexRespBase - ERespProxyAuthenReqd;	//-5571 returns 0x47 (0xC7)
+const TInt KErrIrObexRespTimedOut		= KErrIrObexRespBase - ERespTimedOut;			//-5572 returns 0x48 (0xC8)
+const TInt KErrIrObexRespConflict		= KErrIrObexRespBase - ERespConflict;			//-5573 returns 0x49 (0xC9)
+const TInt KErrIrObexRespGone			= KErrIrObexRespBase - ERespGone;				//-5574 returns 0x4A (0xCA)
+const TInt KErrIrObexRespLengthReqd		= KErrIrObexRespBase - ERespLengthReqd;			//-5575 returns 0x4B (0xCB)
+const TInt KErrIrObexRespPreCondFailed	= KErrIrObexRespBase - ERespPreCondFailed;		//-5576 returns 0x4C (0xCC)
+const TInt KErrIrObexRespReqEntityTooLarge = KErrIrObexRespBase - ERespReqEntityTooLarge;//-5577 returns 0x4D (0xCD)
+const TInt KErrIrObexRespReqURLTooLarge	= KErrIrObexRespBase - ERespReqURLTooLarge;		//-5578 returns 0x4E (0xCE)
+const TInt KErrIrObexRespUnsupMediaType = KErrIrObexRespBase - ERespUnsupMediaType;		//-5579 returns 0x4F (0xCF)
+const TInt KErrIrObexRespInternalError	= KErrIrObexRespBase - ERespInternalError;		//-5580 returns 0x50 (0xD0)
+const TInt KErrIrObexRespNotImplemented = KErrIrObexRespBase - ERespNotImplemented;		//-5581 returns 0x51 (0xD1)
+const TInt KErrIrObexRespBadGateway		= KErrIrObexRespBase - ERespBadGateway;			//-5582 returns 0x52 (0xD2)
+const TInt KErrIrObexRespServiceUnavail = KErrIrObexRespBase - ERespServiceUnavail;		//-5583 returns 0x53 (0xD3)
+const TInt KErrIrObexRespGatewayTimeout = KErrIrObexRespBase - ERespGatewayTimeout;		//-5584 returns 0x54 (0xD4)
+const TInt KErrIrObexRespHTTPVerNotSupp = KErrIrObexRespBase - ERespHTTPVerNotSupp;		//-5585 returns 0x55 (0xD5)
+const TInt KErrIrObexRespDatabaseFull	= KErrIrObexRespBase - ERespDatabaseFull;		//-5596 returns 0x60 (0xE0)
+const TInt KErrIrObexRespDatabaseLocked = KErrIrObexRespBase - ERespDatabaseLocked;		//-5597 returns 0x61 (0xE1)
+
+#endif // __OBEXCONSTANTS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexfinalpacketobserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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 OBEXFINALPACKETOBSERVER_H
+#define OBEXFINALPACKETOBSERVER_H
+
+#include <e32std.h>
+
+/**
+This mixin class must be inherited by any class interested in final packet notifications. 
+
+@publishedAll
+@released
+*/
+
+class MObexFinalPacketObserver
+	{
+public:
+
+	/** Indicates start of final packet.
+	@publishedAll
+	@released
+	*/
+	virtual void MofpoFinalPacketStarted() {};
+
+	/** Indicates end of final packet.
+	@publishedAll
+	@released
+	*/
+	virtual void MofpoFinalPacketFinished() {};
+	};
+
+#endif // OBEXFINALPACKETOBSERVER_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexheaders.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,239 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @publishedAll
+ @released
+*/
+
+#ifndef __OBEXHEADERS_H
+#define __OBEXHEADERS_H
+
+#include <obextypes.h>
+
+/**
+Encapsulates an Obex header.
+
+This class provides the ability to hold a header of any of the Obex
+supported types as a native Symbian OS type.
+
+A header may also have one or more attributes set.  These are used by
+the object which owns the header collection so that it can keep track
+of which headers should be sent (!(ESuppressed || EDeleted)), which have
+been sent (ESent), and whether the header should be deleted (EDeleted).
+Deletion is a special case---any operation on the Object which causes
+a scan of the headers will trigger deletion of any marked headers.
+This is required as they are owned by the Object, but can be accessed
+seperately (including through the creator keeping a pointer to the
+header).
+
+@see CObexBaseObject
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObexHeader) : public CBase
+	{
+public:
+	// Requires friendship with CObexBaseObject to support some aspects of the
+	// legacy API (specifically the HTTP accessor method).
+	friend class CObexBaseObject;
+
+	enum THeaderType
+		{
+		EUnicode  = 0x00,
+		EByteSeq  = 0x01,
+		EByte     = 0x02,
+		EFourByte = 0x03
+		};
+	
+	enum THeaderAttr
+		{
+		ESuppressed = 0x01,
+		ESent       = 0x02,
+		EDeleted    = 0x04,
+		};
+		
+	IMPORT_C static CObexHeader* NewL();
+	virtual ~CObexHeader();
+	IMPORT_C CObexHeader* CopyL() const;
+	
+	//Sets this object to use the same underlying header as the parameter.
+	IMPORT_C void Set(CObexHeader* aHeader);
+	//Resets the contents of this header, discarding the underlying data.
+	IMPORT_C void Reset();
+	
+	//Resets and destroys all header attributes.
+	IMPORT_C void ResetContents();
+	
+	IMPORT_C void SetAttributes(TUint16 aAttr);
+	IMPORT_C TUint16 Attributes() const;
+	
+	IMPORT_C THeaderType Type() const;
+	
+	IMPORT_C TUint8   HI() const;
+	IMPORT_C TUint8   AsByte() const;
+	IMPORT_C TUint32  AsFourByte() const;
+	IMPORT_C const TDesC8&  AsByteSeq() const;
+	IMPORT_C const TDesC16& AsUnicode() const;
+
+	IMPORT_C void SetByte(const TUint8 aHI, const TUint8 aByte);
+	IMPORT_C void SetFourByte(const TUint8 aHI, const TUint32 aFourByte);
+	IMPORT_C void SetByteSeqL(const TUint8 aHI, const TDesC8& aByteSeq);
+	IMPORT_C void SetUnicodeL(const TUint8 aHI, const TDesC16& aUnicode);
+
+	IMPORT_C TInt EncodedSize() const;
+	
+private:
+	CObexHeader();
+	CObexHeader(CObexUnderlyingHeader* aHeader);
+	void ConstructL();
+	
+private:
+	CObexUnderlyingHeader* iHeader;
+	};
+
+/**
+Used to allow the iterator to decide whether to present a header to
+the user, by passing in a possible header HI value.  Headers present
+in the object will be presented to the Interested() function in the 
+object in which they are held (if received from a remote device
+this will be the order in which they were received, otherwise this will
+be the order in which they were set).
+The function can implement any desired behaviour, including relying on
+the order in which the headers are presented.
+
+In case any state is held, the object also provides a Reset() function.
+Reset() provides a default empty implementation.
+
+Note: there is no destructor. 
+ 
+@publishedAll
+@released
+*/
+class MObexHeaderCheck 
+	{
+public:
+	/**
+	Called to discover is the user is interested in the contents of
+	this header.
+	
+	@param aHI The identifier of the header, including type bits.
+	@return ETrue if the user is interested in the contents of this
+	header.
+	@publishedAll
+	@released
+	*/
+	IMPORT_C virtual TBool Interested(TUint8 aHI) =0;
+	
+	/**
+	Called in response to First() being called on the iterator object.
+	The default implementation does nothing---some implementations may
+	wish to reset state variables.
+	
+	@publishedAll
+	@released
+	*/
+	IMPORT_C virtual void Reset();
+	
+	/**
+ 	Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
+	@param aInterface UID of the interface to return
+	@param aObject the container for another interface as specified by aInterface
+	@publishedAll
+	*/
+	IMPORT_C virtual void MOHC_ExtensionInterfaceL(TUid aInterface, void*& aObject);
+	};
+
+/**
+A collection of headers.  Includes code to filter based on the header HI
+value, iterate through the set of interesting headers, and extract headers
+with specific HI values.
+ 
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObexHeaderSet) : public CBase
+	{
+public:
+	IMPORT_C static CObexHeaderSet* NewL();
+	IMPORT_C CObexHeaderSet* CopyL();
+	IMPORT_C CObexHeaderSet* CopyL(MObexHeaderCheck& aHeaderCheck);
+	~CObexHeaderSet();
+
+	IMPORT_C TInt AddHeader(CObexHeader* aHeader);
+	IMPORT_C void DeleteCurrentHeader();
+
+	IMPORT_C void SetMask(MObexHeaderCheck* aMask);
+	IMPORT_C void DeleteMasked();
+	
+	IMPORT_C void First() const;
+	IMPORT_C TInt This(CObexHeader* aHeader) const;
+	IMPORT_C TInt Next() const;
+	IMPORT_C TInt Next(TInt aSkip) const;
+	IMPORT_C TInt Count() const;
+	
+	IMPORT_C TInt Find(TUint8 aHI, CObexHeader& aHeader) const;
+	
+private:
+	CObexHeaderSet();
+
+private:
+	RPointerArray<CObexHeader> iHeaders;
+	mutable MObexHeaderCheck* iMask;
+	mutable TInt iPos;
+	};
+
+/** 
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexMatchHeader) : public MObexHeaderCheck
+	{
+public:
+	virtual EXPORT_C TBool Interested(TUint8 aHI);
+	IMPORT_C void SetHeader(TUint8 aHI);
+
+private:
+	TUint8 iHI;
+	
+private:
+	// This data padding has been added to help prevent future binary compatibility breaks	
+	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+	TUint32     iPadding1; 
+	TUint32     iPadding2; 	
+	};
+
+/** 
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexMatchHeaderType) : public MObexHeaderCheck
+{
+public:
+	virtual EXPORT_C TBool Interested(TUint8 aHI);
+	IMPORT_C void SetType(CObexHeader::THeaderType aType);
+
+private:
+	TInt iType;
+
+private:
+	// This data padding has been added to help prevent future binary compatibility breaks	
+	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+	TUint32     iPadding1; 
+	TUint32     iPadding2; 	
+	};
+
+#endif // __OBEXHEADERS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexobjects.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,341 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @publishedAll
+ @released
+*/
+
+#ifndef __OBEXOBJECTS_H
+#define __OBEXOBJECTS_H
+
+#include <obextypes.h>
+#include <obexbaseobject.h>
+#include <f32file.h>
+
+class MObexFileWriter;
+class TObexBufferingDetails;
+
+/**
+This class is a concrete derivation of the CObexBaseObject class. Use it to 
+store and transfer OBEX objects with the body part stored in an EPOC file. 
+Hence this class is particularly suited to OBEX "file" beaming applications 
+(c.f. arbitrary object beaming), although there is in reality no 
+restriction in what it is used to transfer. Access to the body is acheived 
+through an additional attribute to the object; the data file. This is the 
+file-system name of the file used to store the body of the object. Note 
+that there is no explicit relation between this and the Name of the object, 
+although it is expected that most applications would attempt to relate the 
+two.
+
+When ever a valid data file is set (i.e. DataFile().Length > 0), this file 
+is effectively open, hence stopping any other application from opening it 
+with exclusive rights. Therefore, it is recommended that Reset () be called 
+on the object as soon as it is no longer required, and definitely before 
+(conceptually) passing ownership of the data file to any other object or 
+user.
+
+CObexFileObject is also suited to situations where an object is expected to 
+be received, but no information about the purpose of this object is known. 
+This is due to CObexFileObject’s ability to create temporary files "on the 
+fly" to store received data into, when a specific file is not provided by 
+the application.
+
+This class is not designed for user derivation.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObexFileObject) : public CObexBaseObject
+	{
+public:
+	static IMPORT_C CObexFileObject* NewL();
+	static IMPORT_C CObexFileObject* NewL(const TDesC &aDataFile);
+	virtual IMPORT_C ~CObexFileObject();
+	IMPORT_C void InitFromFileL(const TDesC& aFile);
+
+private:
+	void ConstructL(const TDesC &aDataFile);
+	void SetDataFileL(const TDesC& aDesc);
+	const TDesC& DataFile();
+	TBool RenameFile(const TDesC& aDesC);
+	void SetTempFilePath(const TDesC& aPath);
+	void QueryTempFilePath(TDes& aPath);
+	// From CObexBaseObject
+	virtual void GetData(TInt aPos, TDes8& aDes);
+	virtual void NewData(TInt aPos, TDes8& aDes);
+	virtual TInt DataSize();
+	virtual void ResetData();
+// Data
+private:
+	RFs iFs;
+	TParse iDataFile;
+	RFile iFile;
+	TBuf<KObexObjectDescriptionSize> iTempFilePath;
+	};
+
+
+
+/**
+Use this class to hold objects where the body part is stored in a CBufFlat
+object. Please note that although parameters are supplied as CBufBase objects,
+non-CBufFlat parameters are not supported and will have unpredictable results.
+At no point does the CObexBufObject create, or take ownership of any CBaseBuf
+object it uses - it is always the responsibility of the creator/owner of the
+CBaseBuf to free it when no longer required.
+
+As this class does not take ownership of the buffers it uses, it equally can
+not create its own buffers ad-hoc for storing new data into. Hence at no 
+time is it valid for a CObexBufObject to exist with out it having a valid 
+data buffer set. If such a situation arises, where it is required that 
+received information should be discarded, consider using a CObexNullObject.
+
+It is also posible to supply a file instead of a memory buffer, or to supply
+both.  This functionality is due to the MObexServerNotify class expecting to
+work only on CObexBufObjects, so CObexFileObjects cannot be returned from the
+upcalls.
+To use a file for body storage, call NewL() passing in a NULL pointer, then
+call SetDataBufL() manually afterwards.  There are three overloads---to allow
+purely memory based objects, purely file based, or a hybrid.  The hybrid object
+buffers into a memory buffer (which is not allowed to grow), then writes data
+to the file when the buffer is full.  The buffering behaviour can therefore be
+tuned to the application by setting the size of the buffer prior to use.
+
+This class is not designed for user derivation.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObexBufObject) : public CObexBaseObject
+	{
+public:
+	/**
+	Obex file buffering method.
+	
+	@publishedAll
+	@released
+	*/
+	enum TFileBuffering
+		{
+		/** Only the supplied buffer will be used to buffer file writes. */
+		ESingleBuffering,
+		/** The object will create a second buffer and perform double buffering. */
+		EDoubleBuffering
+		};
+
+public:
+	static IMPORT_C CObexBufObject* NewL(CBufBase* aDataBuf);
+	virtual IMPORT_C ~CObexBufObject();
+	IMPORT_C TInt WriteToFile(const TPtrC& aFileName);
+	
+	IMPORT_C void SetDataBufL(TObexBufferingDetails& aDetails);
+	IMPORT_C void SetDataBufL(CBufBase* aDataBuf);
+	IMPORT_C void SetDataBufL(const TPtrC& aFilename);
+	IMPORT_C void SetDataBufL(const TPtrC& aFilename, CBufBase* aDataBuf);
+	IMPORT_C void SetDataBufL(const TPtrC& aFilename, CBufBase& aDataBuf, const TFileBuffering aBufferingStrategy);
+	IMPORT_C CBufBase* DataBuf();
+	HBufC* FileName();
+
+private:
+	CObexBufObject();
+	void ConstructL(CBufBase* aDataBuf);
+	
+	void PrepareToSetBufferL();
+
+	void CopyFileL(const TDesC& aFilename);
+	TInt NewFileData(TInt aPos, TDes8& aDes);
+	void GetFileData(TInt aPos, TDes8& aDes);
+
+	// From CObexBaseObject
+	virtual void GetData(TInt aPos, TDes8& aDes);
+	virtual void NewData(TInt aPos, TDes8& aDes);
+	virtual TInt DataSize();
+	virtual void ResetData();
+
+	void CloseDataFile();
+	TInt OpenDataFile(const TDesC& aFilename);
+	void CloseFileServer();
+	TInt OpenFileServer();
+	TInt WriteBufferToFile(TBool aFinal);
+
+// Data
+private:
+	CBufBase* iBuf;
+	HBufC* iFilename;
+	RFs* iFileServ;
+	RFile* iFile;
+	TInt iBufOffset;
+	TInt iBuffered;
+	TInt iBufSegSize;
+
+// Added for double-buffering
+private:
+	// Owned
+	MObexFileWriter*	iWriter;
+	CBufBase*			iDoubleBuf;
+	};
+
+
+
+/**
+Wraps parameters which can affect the buffering method used by the
+CObexBufObject.
+This version provides a single memory buffer which holds the entire object.
+Subclasses will always use a memory buffer, but can override the way that
+Obex uses it.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexBufferingDetails)
+	{
+public:
+	/**
+	Versions (subclasses) of the buffering style object.
+	This enum should not be used outside the dll.
+	@internalComponent
+	*/
+	enum TVersion
+		{
+		EBasicBuffer,
+		EPureFile,
+		EFilenameBackedBuffer,
+		ERFileBackedBuffer,
+		ELastVersion
+		};
+	
+	IMPORT_C TObexBufferingDetails(CBufBase& aBuffer);
+	
+	TVersion Version();	// Return the version of this object
+	CBufBase* Buffer();
+
+protected:
+	TObexBufferingDetails(TVersion aVersion, CBufBase* aBuffer);
+
+private:
+	TVersion iVersion;
+	CBufBase* iBuffer;
+
+	// This data padding has been added to help prevent future binary compatibility breaks	
+	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+	TUint32     iPadding1; 
+	TUint32     iPadding2; 	
+	};
+
+
+/**
+Provides alternate behaviour for a CObexBufObject, allowing use of a file
+to hold the object in its entirety.  No memory buffer is used.  This is a
+special case option provided to cater for the MObexServerNotify interface
+which requires the use of CObexBufObject objects.  It is generally better to
+use a buffered variant.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexPureFileBuffer) : public TObexBufferingDetails
+	{
+public:
+	IMPORT_C TObexPureFileBuffer(const TPtrC& aFilename);
+	const TPtrC& Filename();
+
+private:
+	const TPtrC& iFilename;
+
+	// This data padding has been added to help prevent future binary compatibility breaks	
+	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+	TUint32     iPadding1; 
+	TUint32     iPadding2; 
+	};
+
+/**
+Provides alternate behaviour for a CObexBufObject, allowing use of a file
+to hold the object in its entirety.  Writes to this object are buffered through
+the supplied CBufBase derived object, which is never enlarged.  Once
+it is full, the data is flushed to the file.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexFilenameBackedBuffer) : public TObexBufferingDetails
+	{
+public:
+	IMPORT_C TObexFilenameBackedBuffer(CBufBase& aBuffer, const TPtrC& aFilename, CObexBufObject::TFileBuffering aBufferingStrategy);
+	const TPtrC& Filename();
+	CObexBufObject::TFileBuffering Strategy();
+	
+private:
+	const TPtrC& iFilename;
+	CObexBufObject::TFileBuffering iBufferingStrategy;
+
+	// This data padding has been added to help prevent future binary compatibility breaks	
+	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+	TUint32     iPadding1; 
+	TUint32     iPadding2; 	
+	};
+
+
+
+/**
+Provides alternate behaviour for a CObexBufObject, allowing use of a file
+to hold the object in its entirety.  Writes to this object are buffered through
+the supplied CBufBase derived object, which is never enlarged.  Once
+it is full, the data is flushed to the file.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexRFileBackedBuffer) : public TObexBufferingDetails
+	{
+public:
+	IMPORT_C TObexRFileBackedBuffer(CBufBase& aBuffer, RFile aFile, CObexBufObject::TFileBuffering aBufferingStrategy);
+	RFile File();
+	CObexBufObject::TFileBuffering Strategy();
+	
+private:
+	RFile iFile;
+	CObexBufObject::TFileBuffering iBufferingStrategy;
+
+	// This data padding has been added to help prevent future binary compatibility breaks	
+	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+	TUint32     iPadding1; 
+	TUint32     iPadding2; 
+	};
+
+
+
+/**
+Concrete OBEX object with NULL data representation. Use when only the 
+headers of an object are required, and the data (if any) can safely be 
+discarded.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObexNullObject) : public CObexBaseObject
+	{
+public:
+	IMPORT_C static CObexNullObject* NewL ();
+private:
+	// From CObexBaseObject
+	void ConstructL();
+	virtual void GetData (TInt aPos, TDes8& aDes);
+	virtual void NewData (TInt aPos, TDes8& aDes);
+	virtual TInt DataSize ();
+	virtual void ResetData ();
+	};
+
+#endif // __OBEXOBJECTS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexpanics.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,162 @@
+// 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 OBEX_PANICS_H
+#define OBEX_PANICS_H
+
+/**
+@file
+@publishedAll
+@released
+
+This file contains details of all OBEX and OBEX Transport panics which may be raised
+as a result programming error by the users of OBEX (e.g. Client or Server Application
+or a proprietry transport controller).
+
+Internal panic codes should not be raised due to user errors but would reflect
+internal Obex programming errors - see inc/obexfaults.h
+*/
+
+
+/**
+Category for Obex panics
+@see TObexPanicCode
+*/
+_LIT(KObexPanicCategory, "Obex");
+
+/**
+@publishedAll
+@released
+
+All Obex panics which may be raised as a result of a client (i.e. external) programming error.
+Internal Obex panics are errors listed in TObexFaultCode
+@see TObexFaultCode
+*/
+enum TObexPanicCode
+	{
+	/** A NULL value was supplied for the data buffer.  Note that this
+	pointer can refer to either a memory buffer or a pointer to a RFile object.
+ 	@see CObexBufObject
+ 	*/
+	ENullPointer					= 0,
+	
+	
+	/** The supplied buffer is of zero length.
+	@see CObexBufObject
+	*/
+	EEmptyBuffer					= 1,
+	
+	
+	/** The header is not of the requested type.
+	@see CObexHeader
+	*/
+	EHeaderAsBadType				= 2,
+	
+	
+	/** An unknown TFileBuffering value was supplied.
+ 	@see CObexBufObject
+ 	*/
+	EInvalidBufferStrategy			= 3,
+	
+	
+ 	/** The RFile object does not point to a valid (open) file.
+ 	@see CObexBufObject
+ 	*/
+ 	ENullFileHandle					= 4,
+ 	
+ 	
+ 	/** An unknown TObexBufferingDetails object was supplied to a buffer object.
+ 	@see CObexBufObject
+ 	*/
+ 	EInvalidBufferDetails			= 5,
+ 	
+ 	
+	/** A call has been made to CObexServer::RequestIndicationCallback when no
+	asynchronous request is outstanding.
+	@see MObexNotifyAsync
+	@see CObexServer
+	*/
+	ENoNotificationToComplete		= 6,
+
+
+	/** A call has been made to CObexServer::Start when an asynchronous request
+	is outstanding.
+	@see MObexNotifyAsync
+	@see CObexServer
+	*/
+	EChangeInterfaceDuringWait		= 7,
+
+
+
+ 	/** An invalid packet process event has been signalled.
+	*/
+	EBadPacketProcessEvent			= 8,
+
+
+	/** An event is available for signalling, but there is no observer set.
+	*/
+	ENoPacketProcessObserverSet		= 9,
+	
+	/** In CObexServer, a call has been made to RequestCompleteIndicationCallback(TObexResponse)
+	or RequestIndicationCallback(TObexResponse) with invalid response code or 
+    RequestCompleteIndicationCallback(TInt) with invalid Symbian error code
+	*/
+	EInvalidResponseCodeFromServerApp = 10,
+	
+	/** In CObexServer, RequestCompleteIndicationCallback has been called in response to Put/GetRequestIndication
+	or ReuqestIndicationCallback has been called in response to Put/GetComplete or SetPath Indication
+	*/
+	EInvalidResponseCallback = 11,
+
+	/** The last server response code has been requested prior to a response from the server.
+	*/
+	ENoResponseCodeToReturn			= 12,
+
+	/** Adding End of Body header when there is data in the object. 
+	*/
+	EAddingInvalidEoBHeader = 13,
+	
+	/** A user has requested to override the handling of a request
+	packet at an invalid time.
+	*/
+	EOverrideRequestHandlingInBadState = 14,
+	
+	/** A pointer must be null before constructing the object it points to.
+	*/
+	ENotNullPointer = 15,
+	};
+
+
+
+/** 
+The category for obex transport panics
+*/
+_LIT(KObexTransportPanicCat, "ObexTransPanics");
+
+/**
+Obex transport panics raised as a result of client programming error
+*/
+enum TObexTransportPanicCode
+	{
+	/**
+	The number of transport implementations for a given transport name is more than what is allowed.  
+	Check that there is not more than the allowed number of plugin resource files containing the same default
+	data and inteface uid.
+	*/
+ 	EInvalidNumberOfTransportImplementations	= 0,	
+	};
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexreadactivityobserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,48 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef OBEXREADACTIVITYOBSERVER_H
+#define OBEXREADACTIVITYOBSERVER_H
+
+#include <e32std.h>
+
+/**
+This mixin class must be inherited by any class interested in read activity notifications. 
+
+@publishedPartner
+@released
+*/
+
+class MObexReadActivityObserver
+	{
+public:
+
+	/** Indicates read activity.
+	This is guaranteed to be called when the transport completes the first 
+	transport read in an Obex operation (which may correspond to less than a 
+	complete Obex packet), and may be called at additional times before the 
+	operation is completed.
+	Note that the upcall behaviour is dependent on transport layer and 
+	version -- even if experiments show more frequent upcalls, the only 
+	behaviour which may be assumed is a single upcall per operation.
+	
+	@publishedPartner
+	@released
+	*/
+	virtual void MoraoReadActivity() {};
+	};
+
+#endif // OBEXREADACTIVITYOBSERVER_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,692 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @publishedAll
+ @released
+*/
+
+#ifndef __OBEXSERVER_H
+#define __OBEXSERVER_H
+
+#include <obextypes.h>
+#include <obexbase.h>
+
+class TObexTransportInfo;
+class CObexServerRequestPacketEngine;
+class CObexPacketSignaller;
+class MObexReadActivityObserver;
+
+/** OBEX server.
+
+CObexServer provides a framework for servicing OBEX requests from remote clients. 
+It is designed to be able to act as either a "default" application (in IrDA 
+terms, registering on the IrDA:OBEX IAS class), or as a application specific 
+server (registering itself on a private IAS class). 
+
+You implement service-specific behaviour by providing a MObexServerNotify 
+interface implementation to the server object. The server calls the interface's 
+functions to provide notification of server events, which specific implementations 
+can process (or ignore) as appropriate.
+
+This class is not designed for user derivation. 
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObexServer) : public CObex
+	{
+	// CObexServer is friends with the core Server State Machine class so
+	// that it can access the CObex::ControlledTransportDown() method
+	friend class CObexServerStateMachine;
+
+	// CObexServer is friends with the TObexServerStateObexConnecting class so
+	// that it can access the CObex::SetConnectState(TConnectState aNewState) method
+	friend class TObexServerStateObexConnecting;
+	
+	// CObexServer is friends with the Server Request Packet Engine so that
+	// it can NULL the iServerRequestPacketEngine pointer ready for another 
+	// extension interface 
+	friend class CObexServerRequestPacketEngine;
+		
+public:
+	/**
+	@publishedAll
+	@released
+	
+	The target header checking to apply to incoming connection requests.  Defaults to
+	EIfPresent.
+	@see CObexServer::SetTargetChecking
+	*/
+	enum TTargetChecking
+		{
+		ENoChecking,	/** Allow all target headers to connect. */
+		EIfPresent,		/** Only check target header in response to receiving one. Allows all clients
+							specifying an Inbox service to connect. */
+		EAlways,		/** Strict checking. Only allow connections if target header matches or no header
+							received and none expected. */
+		};
+
+	IMPORT_C static CObexServer* NewL(TObexProtocolInfo& aObexProtocolInfoPtr);
+	IMPORT_C static CObexServer* NewL(TObexProtocolInfo& aObexProtocolInfoPtr, TObexProtocolPolicy& aObexProtocolPolicy);
+	IMPORT_C static CObexServer* NewL(TObexTransportInfo& aObexTransportInfo);
+	~CObexServer();
+	IMPORT_C TInt Start(MObexServerNotify* aOwner);
+	IMPORT_C TInt Start(MObexServerNotifyAsync* aOwner);
+	IMPORT_C void Stop();
+	IMPORT_C TBool IsStarted();
+	IMPORT_C TOperation CurrentOperation() const;
+	void SetCurrentOperation(const TOperation aOperation);	// used internally by state machine
+	IMPORT_C void SetChallengeL(const TDesC& aPassword);
+	IMPORT_C void ResetChallenge();
+	IMPORT_C void UserPasswordL( const TDesC& aPassword); 
+	IMPORT_C void SetTargetChecking(TTargetChecking aChecking);
+	IMPORT_C TInt SetPutFinalResponseHeaders(CObexHeaderSet* aHeaderSet);
+	IMPORT_C TInt RequestIndicationCallback(CObexBaseObject* aObject);
+    IMPORT_C TInt RequestIndicationCallbackWithError(TObexResponse aResponseCode);
+    IMPORT_C TInt RequestIndicationCallbackWithError(TInt aErrorCode);
+    IMPORT_C TInt RequestCompleteIndicationCallback(TObexResponse aResponseCode);
+    IMPORT_C TInt RequestCompleteIndicationCallback(TInt aErrorCode);
+
+	IMPORT_C TInt PacketHeaders(CObexHeaderSet*& aHeaderSet);
+	IMPORT_C TInt PacketHeaders(CObexHeaderSet*& aHeaderSet, MObexHeaderCheck& aHeaderCheck);
+	IMPORT_C void SetReadActivityObserver(MObexReadActivityObserver* aObserver);
+
+	IMPORT_C TAny* ExtensionInterfaceL(TUid aUid);
+	IMPORT_C const TObexTransportInfo* TransportInfo() const;
+
+public:
+	// Called from CObexNotifyExtendServer
+	void SignalPacketProcessEvent(TInt aEvent);
+	
+	// Unexported functions used by the Server state machine
+	TBool CheckObjectForConnectionId(CObexBaseObject& aObject);
+	TBool CheckPacketForConnectionId(CObexPacket& aObject);
+
+private:
+	CObexServer();
+	void ConstructL(TObexTransportInfo& aObexTransportInfo);
+	TInt AcceptConnection();
+	// Implementation of CObex Events
+	virtual void OnPacketReceive(CObexPacket& aPacket);
+	virtual void OnError(TInt aError);
+	virtual void OnTransportUp();
+	virtual void OnTransportDown();
+
+public:
+	// These three functions need to be public so the Server state machine can use them
+	// However ParseConnectPacket cannot be moved as it is a virtual function (from CObex)
+	TInt PrepareConnectPacket(CObexPacket& aPacket);	
+	TInt PrepareErroredConnectPacket(CObexPacket& aPacket);
+	void SignalReadActivity();
+	TInt ParseConnectPacket(CObexPacket& aPacket);
+
+private:
+	TInt AddConnectionIDHeader(CObexPacket& aPacket);
+	TInt PrepareFinalChallResponse(CObexPacket& aPacket, TConnectState& aNextState);
+	void CheckTarget(TConnectState& aNextState, TInt& aRetVal);
+	void ResetConnectionID();
+	void SetConnectionID(TUint32 aConnectionID);
+	TUint32 ConnectionID();
+	void CheckServerAppResponseCode(TObexOpcode aOpcode, TObexResponse aResponse);
+	TInt DoPacketHeaders(CObexHeaderSet*& aHeaderSet, MObexHeaderCheck* aHeaderCheck);
+
+private:
+	MObexServerNotifyAsync* iOwner;
+	TBool iEnabled;
+	TBool iSpecDone;
+	TBool iTargetReceived;
+	TTargetChecking iTargetChecking;
+	TUint32 iConnectionID;
+	TBool iConnectionIdSet;
+	CObexHeader*	iHeader;
+	CObexServerStateMachine* iStateMachine;
+	CObexServerNotifySyncWrapper* iSyncWrapper;
+	CObexServerRequestPacketEngine* iServerRequestPacketEngine;
+	CObexPacketSignaller* iPacketProcessSignaller;
+	};
+
+
+/** OBEX synchronous server notification interface.
+
+Any service that provides OBEX server functionality must implement one of the two
+server observer classes -- this one or MObexServerNotifyAsync.
+
+The CObexServer object handles the protocol side of an OBEX server session, 
+while this class provides the server policy for a particular session.
+
+PUT and GET requests are handled synchronously, with the implementer returning a
+CObexBufObject which will be processed immediately.
+
+@publishedAll
+@released
+@see MObexServerNotifyAsync
+@see CObexServer
+*/
+class MObexServerNotify
+	{
+public:
+	/**
+	 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
+	 @param aInterface UID of the interface to return
+	 @param aObject the container for another interface as specified by aInterface
+	 */
+	IMPORT_C virtual void MOSN_ExtensionInterfaceL(TUid aInterface, void*& aObject);
+
+	/** Called if an OBEX protocol error occurs.
+	
+	It is only called for fatal errors that cause the OBEX connection to terminate. 
+	An error that does not terminate the connection, for example the server issuing 
+	a semantically valid, but unrecognised command, will not be indicated.
+	
+	@param aError Error code that describes the OBEX error. OBEX specific error 
+	codes are listed from KErrIrObexClientNoDevicesFound. 
+	
+	@publishedAll
+	@released
+	*/
+	virtual void ErrorIndication(TInt aError) =0;
+	
+	
+	
+	/** Called when the underlying transport connection is made from a remote 
+	client to the server.
+	
+	Note that this does not, however, indicate an OBEX connection has been successfully 
+	established.
+	
+	You can define any low-level connection policy here. It is also a good place 
+	to set up the local connection information (CObex::LocalInfo()), if any non-defaults 
+	are required. 
+
+	@publishedAll
+	@released
+	*/
+	virtual void TransportUpIndication() =0;
+	
+	
+
+	/** Called when the transport connection is dropped (by either party).
+	
+	It is called whether the OBEX connection was gracefully disconnected or not. 
+	The function is the definitive place for disconnection processing.
+	
+	@publishedAll
+	@released
+	*/
+	virtual void TransportDownIndication() =0;
+	
+	
+	
+	/** Called when an OBEX connection is made from a remote client.
+	
+	Override this function to provide any extra OBEX connection processing.
+	Despite this method returning a value, implementers cannot use this to
+	refuse the connection attempt.
+	
+	@param aRemoteInfo Connection information supplied by that remote machine
+	@param aInfo Further information about the requested connection (reserved)
+	@return Ignored
+	
+	@publishedAll
+	@released
+	*/
+	virtual TInt ObexConnectIndication(const TObexConnectInfo& aRemoteInfo, const TDesC8& aInfo) =0;
+
+
+
+	/** Called on a (graceful) OBEX disconnection by the client.
+	
+	Override this to provide any extra processing OBEX disconnection processing.
+	
+	Note that this indication will not be raised if the remote machine simply 
+	drops the transport connection. However, ErrorIndication() will be called 
+	if the disconnection is unexpected/ invalid (i.e. another operation was in 
+	progress at the time). In all cases, TransportDownIndication() will be called.
+	
+	@param aInfo Contains information about the disconnection (reserved) 
+	
+	@publishedAll
+	@released
+	*/
+	virtual void ObexDisconnectIndication(const TDesC8& aInfo) =0;
+
+
+
+	/** Called on receipt of the first packet of a (valid) put request. 
+	
+	It is called before any parsing of the packet is performed, simply to establish 
+	whether this server is interested in receiving objects at all.
+	
+	Note if the returned object cannot be initialised for receiving, ERespInternalError
+	is returned to the client.
+	
+	@return CObexBaseObject-derived object, which the object being put will be 
+	parsed into. If this is NULL, ERespForbidden is returned to the client. 
+	
+	@publishedAll
+	@released
+	*/
+	virtual CObexBufObject* PutRequestIndication() =0;
+
+
+
+	/** Called on receipt of every packet of an OBEX PUT operation.
+	
+	It will always be preceded by a PutRequestIndication(). The object returned 
+	by the request indication will be updated to reflect all the information received 
+	concerning the object which the client is sending, from packets up to and 
+	including the current one. 
+	
+	You can use this function to provide periodic user notification on the progress 
+	of the transfer (noting that the Length attribute may take an arbitrary number 
+	of packets to become non-zero, and the constraints on its accuracy). Due to 
+	the nature of OBEX operations, where any header attribute can be sent at any 
+	point in the transfer, this is also a good place to marshal the details of 
+	a received object, and possibly prompt for action on the received object (e.g. 
+	renaming on filename clashes).
+	
+	Note that this function could be hit quite heavily, in proportion to the size 
+	of the object transferred. Therefore more consideration should be given to 
+	the speed of execution of this function than that of the other indications.
+	
+	@return KErrNone instructs the server to allow the client to continue the put 
+	operation. Any other value cancels the operation with an appropriate OBEX 
+	server response code. 
+	
+	@publishedAll
+	@released
+	*/
+	virtual TInt PutPacketIndication() =0;
+
+
+
+	/** Called after the final put packet has been successfully received and parsed. 
+	
+	Note that there will not necessarily be a call to this function corresponding 
+	to each PutRequestIndication() as, if an error occurs while the put is being 
+	carried out, ErrorIndication() will be called instead.
+	
+	Before version 6.1, the return type was void.
+
+	@return KErrNoneinstructs the remote client that the put completed successfully. 
+	Any other value cancels the operation with an appropriate OBEX server response 
+	code.
+	
+	@publishedAll
+	@released
+	*/
+	virtual TInt PutCompleteIndication() =0;
+
+
+
+	/** Called when a full get request has been received from the client. 
+	
+	aRequestedObject holds all the details about the object the remote client 
+	has requested. Use this function to analyse the client's request, and return 
+	a pointer to the object to be returned to the client, or NULL to return no 
+	object. 
+	
+	If NULL is returned, the server will send ERespForbidden to the client; if 
+	an error occurs in returning the object, ERespInternalError is returned, otherwise 
+	the returned object is sent back to the client.
+	
+	@param aRequiredObject Details about the object the remote client has requested
+	@return Object to return to the client 
+	
+	@publishedAll
+	@released
+	*/
+	virtual CObexBufObject* GetRequestIndication(CObexBaseObject *aRequiredObject) =0;
+
+
+
+	/** Called for every packet of get reply sent by the server back to the client. 
+	
+	The function is only called while an object is being sent to the client, not 
+	while the client is providing its initial specification for the object it 
+	requires. 
+	
+	You can use this function to provide user notification on the object being 
+	sent, and its progress. As with PutPacketIndication(), you should consider 
+	that this function might get called often, especially for large objects and 
+	small OBEX packet sizes, so the speed of execution here is important.
+	
+	@return KErrNone to continue sending the object, or any other error code to 
+	cancel the operation 
+
+	@publishedAll
+	@released
+	*/
+	virtual TInt GetPacketIndication() =0;
+
+
+
+	/** Called when the final packet of the object has been returned to the client.
+	
+	Note like PutCompleteIndication(), this function might not be called for each 
+	GetRequestIndication(), if the operation is interrupted by an error.
+	
+	Before version 6.1, the return type was void.
+	
+	@return KErrNoneinstructs the remote client that the get completed successfully. 
+	Any other value cancels the operation with an appropriate OBEX server response 
+	code. 
+	
+	@publishedAll
+	@released
+	*/
+	virtual TInt GetCompleteIndication() =0;
+
+
+
+	/** Called when an OBEX SETPATH command is received by the server. 
+	
+	@param aPathInfo SETPATH command parameters
+	@param aInfo Not currently used
+	@return System wide error code indicating the success of the setpath command 
+	
+	@publishedAll
+	@released
+	*/
+	virtual TInt SetPathIndication(const CObex::TSetPathInfo& aPathInfo, const TDesC8& aInfo) =0;
+
+
+
+	/** Called when an abort packet is received from the client. 
+	
+	An OBEX abort command simply cancels the current operation, and does not necessarily 
+	have to cause the connection to be dropped. On return, a ERespSuccess packet 
+	is sent to the client. 
+	
+	@publishedAll
+	@released
+	*/
+	virtual void AbortIndication() =0;
+	};
+
+
+
+/** OBEX asynchronous server notification interface.
+
+Any service that provides OBEX server functionality must implement one of the two
+server observer classes -- this one or MObexServerNotify.
+
+The CObexServer object handles the protocol side of an OBEX server session, 
+while this class provides the server policy for a particular session.
+
+PUT and GET requests are handled asynchronously, with the upcall from the server
+being followed at some stage in the future by a call to CObexServer::RequestIndicationComplete
+to trigger processing.
+
+@publishedAll
+@released
+@see MObexServerNotify
+@see CObexServer
+*/
+class MObexServerNotifyAsync
+	{
+public:
+
+	/**
+ 	 Returns a null aObject if the extension is not implemented, or a pointer to another
+ 	 interface if it is.
+	 @param aInterface UID of the interface to return
+	 @param aObject the container for another interface as specified by aInterface
+	 */
+	IMPORT_C virtual void MOSNA_ExtensionInterfaceL(TUid aInterface, void*& aObject);		
+
+
+
+	/** Called if an OBEX protocol error occurs.
+	
+	It is only called for fatal errors that cause the OBEX connection to terminate. 
+	An error that does not terminate the connection, for example the server issuing 
+	a semantically valid, but unrecognised command, will not be indicated.
+	
+	@param aError Error code that describes the OBEX error. OBEX specific error 
+	codes are listed from KErrIrObexClientNoDevicesFound. 
+	
+	@publishedAll
+	@released
+	*/
+	virtual void ErrorIndication(TInt aError) =0;
+	
+
+	
+	/** Called when the underlying transport connection is made from a remote 
+	client to the server.
+	
+	Note that this does not, however, indicate an OBEX connection has been successfully 
+	established.
+	
+	You can define any low-level connection policy here. It is also a good place 
+	to set up the local connection information (CObex::LocalInfo()), if any non-defaults 
+	are required. 
+
+	@publishedAll
+	@released
+	*/
+	virtual void TransportUpIndication() =0;
+	
+	
+	
+	/** Called when the transport connection is dropped (by either party).
+	
+	It is called whether the OBEX connection was gracefully disconnected or not. 
+	The function is the definitive place for disconnection processing.
+	
+	@publishedAll
+	@released
+	*/
+	virtual void TransportDownIndication() =0;
+	
+	
+	
+	/** Called when an OBEX connection is made from a remote client.
+	
+	Override this function to provide any extra OBEX connection processing.
+	
+	@param aRemoteInfo Connection information supplied by that remote machine
+	@param aInfo Further information about the requested connection (reserved)
+
+	@publishedAll
+	@released
+	*/
+	virtual void ObexConnectIndication(const TObexConnectInfo& aRemoteInfo, const TDesC8& aInfo) =0;
+
+
+
+	/** Called on a (graceful) OBEX disconnection by the client.
+	
+	Override this to provide any extra processing OBEX disconnection processing.
+	
+	Note that this indication will not be raised if the remote machine simply
+	drops the transport connection. However, ErrorIndication() will be called 
+	if the disconnection is unexpected/ invalid (i.e. another operation was in 
+	progress at the time). In all cases, TransportDownIndication() will be called.
+	
+	@param aInfo Contains information about the disconnection (reserved) 
+	
+	@publishedAll
+	@released
+	*/
+	virtual void ObexDisconnectIndication(const TDesC8& aInfo) =0;
+
+
+
+	/** Called on receipt of the first packet of a (valid) put request. 
+	
+	It is called before any parsing of the packet is performed, simply to establish 
+	whether this server is interested in receiving objects at all.
+	
+	Following this notification, the server will wait for a call to
+	CObexServer::RequestIndicationCallback supplying a CObexBaseObject derived
+	object to receive into or a response code specifying the error.
+	
+	@publishedAll
+	@released
+	*/
+	virtual void PutRequestIndication() =0;
+
+
+
+	/** Called on receipt of every packet of an OBEX PUT operation.
+	
+	It will always be preceded by a PutRequestIndication(). The object returned 
+	by the request indication will be updated to reflect all the information received 
+	concerning the object which the client is sending, from packets up to and 
+	including the current one. 
+	
+	You can use this function to provide periodic user notification on the progress 
+	of the transfer (noting that the Length attribute may take an arbitrary number 
+	of packets to become non-zero, and the constraints on its accuracy). Due to 
+	the nature of OBEX operations, where any header attribute can be sent at any 
+	point in the transfer, this is also a good place to marshal the details of 
+	a received object, and possibly prompt for action on the received object (e.g. 
+	renaming on filename clashes).
+	
+	Note that this function could be hit quite heavily, in proportion to the size 
+	of the object transferred. Therefore more consideration should be given to 
+	the speed of execution of this function than that of the other indications.
+	
+	@return KErrNone instructs the server to allow the client to continue the put 
+	operation. Any other value cancels the operation with an appropriate OBEX 
+	server response code. 
+	
+	@publishedAll
+	@released
+	*/
+	virtual TInt PutPacketIndication() =0;
+
+
+
+	/** Called after the final put packet has been successfully received and parsed. 
+	
+	Note that there will not necessarily be a call to this function corresponding 
+	to each PutRequestIndication() as, if an error occurs while the put is being 
+	carried out, ErrorIndication() will be called instead.
+	
+	Following this notification, the server will wait for a call to
+	CObexServer::RequestCompleteIndicationCallback supplying a Obex response code.
+
+	@publishedAll
+	@released
+	*/
+	virtual void PutCompleteIndication() =0;
+
+
+
+	/** Called when a full get request has been received from the client. 
+	
+	aRequestedObject holds all the details about the object the remote client 
+	has requested. Use this function to analyse the client's request, and return 
+	a pointer to the object to be returned to the client, or NULL to return no 
+	object. 
+	
+	Following this notification, the server will wait for a call to
+	CObexServer::RequestIndicationCallback supplying a CObexBaseObject derived
+	object to send to the client or a response code specifying the error.
+
+	@param aRequiredObject Details about the object the remote client has requested
+	
+	@publishedAll
+	@released
+	*/
+	virtual void GetRequestIndication(CObexBaseObject* aRequiredObject) =0;
+
+
+
+	/** Called for every packet of get reply sent by the server back to the client. 
+	
+	The function is only called while an object is being sent to the client, not 
+	while the client is providing its initial specification for the object it 
+	requires. 
+	
+	You can use this function to provide user notification on the object being 
+	sent, and its progress. As with PutPacketIndication(), you should consider 
+	that this function might get called often, especially for large objects and 
+	small OBEX packet sizes, so the speed of execution here is important.
+	
+	@return KErrNone to continue sending the object, or any other error code to 
+	cancel the operation
+	
+	@publishedAll
+	@released
+	*/
+	virtual TInt GetPacketIndication() =0;
+
+
+
+	/** Called when the final packet of the object has been returned to the client.
+	
+	Note like PutCompleteIndication(), this function might not be called for each
+	GetRequestIndication(), if the operation is interrupted by an error.
+	
+	Following this notification, the server will wait for a call to
+	CObexServer::RequestCompleteIndicationCallback supplying a Obex response code.
+
+	@publishedAll
+	@released
+	*/
+	virtual void GetCompleteIndication() =0;
+
+
+
+	/** Called when an OBEX SETPATH command is received by the server. 
+	
+	Following this notification, the server will wait for a call to
+	CObexServer::RequestCompleteIndicationCallback supplying a Obex response code.
+	
+	@param aPathInfo SETPATH command parameters
+	@param aInfo Not currently used
+
+	@publishedAll
+	@released
+	*/
+	virtual void SetPathIndication(const CObex::TSetPathInfo& aPathInfo, const TDesC8& aInfo) =0;
+
+
+
+	/** Called when an abort packet is received from the client. 
+	
+	An OBEX abort command simply cancels the current operation, and does not necessarily 
+	have to cause the connection to be dropped. On return, a ERespSuccess packet 
+	is sent to the client. 
+	
+	@publishedAll
+	@released
+	*/
+	virtual void AbortIndication() =0;
+	
+	
+	
+	/** Cancel an asynchronous callback request (ie. PutRequest/GetRequest/PutComplete/GetComplete/SetPath 
+		notification).
+	
+	Note that ignoring this call will lead to a panic when the indication callback function
+	is called.
+
+	@publishedAll
+	@released
+	*/
+	virtual void CancelIndicationCallback() =0;
+	};
+
+
+#endif	// __OBEXSERVER_H
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obextypes.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,70 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @publishedAll
+ @released
+*/
+
+#ifndef __OBEXTYPES_H
+#define __OBEXTYPES_H
+
+#include <e32std.h>
+#include <e32des8.h>
+#include <e32des16.h>
+#include <utf.h> // Required for source compatability
+#include <obexconstants.h>
+
+typedef TUint16 TObexHeaderMask;
+typedef TUint8 TObexOpcode;
+typedef TBuf8<16> TNonce;
+
+class TObexProtocolInfo;
+class TObexIrProtocolInfo;
+class TObexBluetoothProtocolInfo;
+class TObexUsbProtocolInfo;
+class TObexUsbProtocolInfoV2;
+class TObexProcotolPolicy;
+struct TObexConnectionInfo;
+class TObexConnectInfo;
+
+class CObexPacket;
+class CObexHeader;
+class CObexUnderlyingHeader;
+class MObexHeaderCheck;
+class CObexHeaderSet;
+class CObexBaseObject;
+class CObexFileObject;
+class CObexBufObject;
+class CObexNullObject;
+class MObexNotify;
+class MObexAuthChallengeHandler;
+class CObexTransport;
+class CObexConnector;
+class TObexInternalHeader;
+class CObexAuthenticator;
+class CObex;
+class TObexSetPathData;
+class CObexClient;
+class MObexServerNotify;
+class CObexServer;
+class CObexServerStateMachine;
+class MObexServerNotify;
+class MObexServerNotifyAsync;
+class CObexServerNotifySyncWrapper;
+
+
+#endif // __OBEXTYPES_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/OBEX.CPP	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,962 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+*/
+
+
+#include <charconv.h>
+#include <utf.h>
+#include <obex.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obextransportinfo.h>
+#include <obexirtransportinfo.h>
+#include <obex/transport/obextransportcontrollerbase.h>
+#include <obex/internal/obexpacket.h>
+#include "logger.h"
+#include "obexsetpathdata.h"
+#include "OBEXUTIL.H"
+#include "authentication.h"
+#include <ecom/ecom.h>
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/**
+Constructor - set initial values and copy in protocol policy information
+@internalComponent
+*/
+CObex::CObex()
+	{
+#ifdef _DEBUG
+	CObexLog::Connect();
+#endif
+	FLOG(_L("Creating CObex"));
+	SetConnectState(EConnIdle);
+	}
+
+void CObex::ConstructL(TObexTransportInfo& aObexTransportInfo)
+	{
+	iTransportController = CObexTransportControllerBase::NewL(aObexTransportInfo);
+	iAuthEngine = CObexAuthenticator::NewL();
+	iSuppressedObexAuthElements = EObexNoSuppressedAuthElements;
+	}
+
+/** 
+Destructor. 
+*/
+CObex::~CObex()
+	{
+	
+	delete iTransportController;
+	delete iAuthEngine;
+	delete iChallPassword;
+	delete iRespPassword;
+	delete iRemoteUID;
+	delete iRemoteRealm;
+	delete iRxChallenge;
+	
+	// This must be done AFTER destroying the transport controller.
+	REComSession::FinalClose();
+
+	// iNotifyHandler is deleted in the derived classes where it is instantiated
+
+#ifdef _DEBUG
+	CObexLog::Close();
+#endif
+	}
+
+/** 
+Get the socket address of the remote device.
+
+This is the address of the device OBEX is connected to over an IrDA or Bluetooth 
+socket. 
+
+@param aAddr Socket address. 
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObex::RemoteAddr(TSockAddr& aAddr)
+	{
+	LOG_LINE
+	LOG_FUNC
+	
+	// iTransportController must be valid for all the CObex life cycle 
+	__ASSERT_DEBUG(iTransportController, IrOBEXUtil::Fault(ETransportControllerNotCreated));
+		
+	iTransportController->RemoteAddr(aAddr);
+	}
+
+/** 
+Sets the local Who field.
+
+This is used to identify the local end of the OBEX session when the OBEX connection 
+is made. If it is required, set it before establishing the connection.
+
+@param aInfo Who field
+@return KErrNone or KErrArgument if aInfo is empty  
+
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObex::SetLocalWho(const TDesC8& aInfo)
+	{ 
+	LOG_LINE
+	LOG_FUNC
+
+	if(aInfo.Length())
+		{ iLocalInfo.iWho.Copy(aInfo); return KErrNone;} 
+	else
+		return KErrArgument;
+	}
+
+/** 
+Indicates if the Server / Client is currently authenticating the OBEX
+connection.
+
+@return ETrue if the Server / Client is currently authenticating the OBEX connection otherwise EFalse.
+
+@publishedAll
+@released
+*/
+EXPORT_C TBool CObex::IsAuthenticating() const
+	{
+	return (ConnectState() >= EConnChallRxed && ConnectState() <= EWaitForUserInput);
+	}
+	
+
+/**
+@param aPassword Password to use in challenge response
+@internalComponent
+*/
+void CObex::PrepareChallResponseL(const TDesC& aPassword)
+	{
+
+	FLOG(_L("CObex::PrepareChallResponse\r\n"));
+	iOutgoingChallResp.Zero(); 
+	TRequestDigest response;
+	delete iRespPassword;
+	iRespPassword = NULL;
+	iRespPassword = HBufC8::NewL(aPassword.Length());
+	TPtr8 ptr = iRespPassword->Des();
+	CnvUtfConverter::ConvertFromUnicodeToUtf8(ptr, aPassword);
+	
+	iAuthEngine->GenerateResponseL(ptr, iIncomingNonce, response);
+	FLOG(_L("PrepareChallResponse: Digest response generated"));
+
+	FLOG(_L("PrepareChallResponse: Adding response hash"));
+	iOutgoingChallResp.Append(KObexRespTag); //0x00
+	iOutgoingChallResp.Append(KObexRespSize); //16
+	iOutgoingChallResp.Append(response);
+
+	//only reply with UserID if requested
+	if (iUserIDRequested )
+		{
+		FLOG(_L("PrepareChallResponse: User ID required, adding zero length field"));
+		iOutgoingChallResp.Append(KObexRespUserIDTag); //0x01
+		//Fixme, add in the size of the user ID
+		iOutgoingChallResp.Append(0); //assume no UserID size of 0
+		//any user ID would have to be inserted here
+		//iOutgoingChallResp.Append(userID); //Fixme what is the user ID?
+		}
+	
+	FLOG(_L("PrepareChallResponse: Adding nonce of challenge we're replying to"));
+	iOutgoingChallResp.Append(KObexRespNonceTag);
+	iOutgoingChallResp.Append(KObexNonceSize);
+	iOutgoingChallResp.Append(iIncomingNonce);
+
+	FLOG(_L(" PrepareChallResponse - complete response generated"));
+	}
+
+/**
+@internalComponent
+*/
+TInt CObex::GenerateChallenge(CObexPacket& aPacket)
+	{
+	TInt retValue = KErrNone;
+
+	FLOG(_L("CObex::GenerateChallenge\r\n"));
+	iOutgoingNonce.Zero();
+	iAuthEngine->GenerateNonce(iOutgoingNonce);
+	//now pack all the data together for the overall challenge
+	TBuf8<KObexChallHeaderSize> outGoingHeader; //this size assumes no Realm data
+	outGoingHeader.Zero();
+	outGoingHeader.Append(KObexChallNonceTag);
+	outGoingHeader.Append(KObexNonceSize);
+	outGoingHeader.Append(iOutgoingNonce);
+	
+	// Add authentication header only if the client has not disallowed it
+	if (!(iSuppressedObexAuthElements & EObexSuppressChallengeOptionsAuthElement))
+		{		
+		outGoingHeader.Append(KObexChallOptionsTag);
+		outGoingHeader.Append(1); //size is always 1
+		outGoingHeader.Append(0); //all options off
+		}
+		
+	// Add realm header only if the client has not disallowed it	
+	if (!(iSuppressedObexAuthElements & EObexSuppressRealmAuthElement))
+		{
+		outGoingHeader.Append(KObexChallRealmTag);
+		outGoingHeader.Append(0); //no realm so size = 0
+		}
+
+	TObexInternalHeader hdr;
+	hdr.Set(TObexInternalHeader::EAuthChallenge, (const_cast<TUint8*> (outGoingHeader.Ptr())), outGoingHeader.Size());
+	if(!aPacket.InsertData(hdr))
+		retValue = KErrOverflow;
+		
+	return (retValue);
+	}
+
+/**
+@internalComponent
+*/
+void CObex::ProcessChallResponseL(const TObexInternalHeader& hdr)
+	{
+	FLOG(_L("CObex::ProcessChallResponse"));
+	TBool retValue = ETrue;
+	TInt responseSize = hdr.HVSize();
+	TInt elementsLeft = responseSize;	//keep track of how many elements still to be removed
+
+	if ( responseSize > KChallResponseSize )
+		{
+		retValue = EFalse;
+		FLOG(_L("ProcessChallResponse - Response header too big FAILED"));
+		}
+	else if (responseSize < KMinChallResponseSize)
+		{ 
+		retValue = EFalse;
+		FLOG(_L("ProcessChallResponse - Response header too small FAILED"));
+		}
+
+	//get the response 
+	iIncomingChallResp.Zero();
+	iIncomingChallResp.Copy(hdr.HVByteSeq(), responseSize);
+	
+	//there is no reason to assume that the data is going to arrive
+	//in any particular order
+	TInt extractionPosn = 0;
+
+	//ensure space enough for the tag and size  
+	while ((extractionPosn <  (responseSize-1) ) && retValue)
+		{
+		switch (iIncomingChallResp[extractionPosn++])
+			{
+			case KObexRespTag:
+				{
+				elementsLeft--; //moved passed the tag
+				if ((iIncomingChallResp[extractionPosn++] == KObexRespSize)&&
+					(elementsLeft > KObexRespSize)) //must be greater to allow for size field
+					{
+					elementsLeft--; //moved passed the size
+					FLOG(_L("ProcessChallResponse - iIncoming Request Response extracted"));
+					iIncomingRequestDigest.Zero();
+					iIncomingRequestDigest.Append((TUint8*)iIncomingChallResp.Ptr() + extractionPosn, KObexRespSize);
+					extractionPosn += KObexRespSize;
+					elementsLeft -= KObexRespSize;
+					}
+				else
+					{
+					FLOG(_L("ProcessChallResponse - iIncoming Request Response extraction FAILED"));
+					retValue = EFalse;
+					}
+				}
+				break;
+			case KObexRespUserIDTag:
+				{
+				elementsLeft--; //moved passed the tag
+				TInt userIDSize = iIncomingChallResp[extractionPosn++];
+				if ( userIDSize > 0)
+					{
+					elementsLeft--; //moved passed the User ID size
+					if (( userIDSize > 0 )&&(userIDSize <= elementsLeft ))
+						{
+						elementsLeft -= userIDSize;
+						FLOG(_L("ProcessChallResponse - iIncoming ASCII UserID Extracted"));
+						delete iRemoteUID;
+						iRemoteUID = NULL;
+						iRemoteUID = HBufC::NewL(userIDSize); 
+						TPtrC8 ptr((TUint8*)iIncomingChallResp.Ptr() + extractionPosn, userIDSize);
+						TPtr ptrUID((TUint16*)iRemoteUID->Ptr(), userIDSize);
+						CnvUtfConverter::ConvertToUnicodeFromUtf8(ptrUID, ptr);
+						extractionPosn += userIDSize;
+						}
+					}
+				else
+					{
+					retValue = EFalse;
+					FLOG(_L("ProcessChallResponse - iIncoming UserID Extraction FAILED"));
+					}
+				}
+			break;
+			//don't bother extracting the Nonce as we do not support multiple Nonce replies
+			//the assumption is the reply received is for the Nonce we sent out
+			case KObexRespNonceTag:
+				{
+				FLOG(_L("ProcessChallResponse: extracting incoming nonce"));
+				elementsLeft--; //moved passed the tag
+				TInt nonceSize = iIncomingChallResp[extractionPosn++];
+				if ( nonceSize > 0 )
+					{
+					elementsLeft--; //moved passed size
+					if ( nonceSize <= elementsLeft )
+						{
+						FTRACE(
+						TPtrC8 incomingNonce(iIncomingChallResp.Ptr() + extractionPosn, nonceSize);
+						if (incomingNonce != iOutgoingNonce)
+							{
+							FLOG(_L("ProcessChallResponse: incoming nonce does not match our challenge. Continuing anyway."));
+							}
+						);
+						
+						elementsLeft -= nonceSize;
+						extractionPosn += nonceSize;
+						}
+					else
+						{
+						FLOG(_L("ProcessChallResponse - iIncoming Request Response extraction, bad nonce size FAILED"));
+						retValue = EFalse;
+						}
+					}
+				}
+				break;
+			default: 
+				{
+				FLOG(_L("ProcessChallResponse - iIncoming Request Response extraction,unknown tag type FAILED"));
+				retValue = EFalse;
+				}
+			break;
+			
+			}
+		TRAPD(err, iAuthEngine->ChallengeResponseL(*iChallPassword, iOutgoingNonce, iIncomingRequestDigest));
+		if ( err != KErrNone)
+			{
+			FLOG(_L("ProcessChallResponse - Responsed Denied"));
+			User::Leave(err);
+			}
+		}
+	if (!retValue )
+		User::Leave(KErrGeneral);
+	}
+
+/**
+@internalComponent
+*/
+void CObex::ProcessChallengeL(const TObexInternalHeader& hdr)
+	{
+	FLOG(_L("CObex::ProcessChallenge\n\r"));
+
+	//extract all the necessary data
+	TInt challengeSize = hdr.HVSize();
+	TInt extractionPosn = 0;
+	TInt elementsLeft = challengeSize;
+	TBool nonceExtracted = EFalse;
+
+	delete iRxChallenge;
+	iRxChallenge = NULL;
+	iRxChallenge = HBufC8::NewL(challengeSize);
+	iRxChallenge->Des().Copy(hdr.HVByteSeq(), challengeSize);
+	delete iRemoteRealm;
+	iRemoteRealm = NULL;
+
+
+
+	//can't make any assumptions about the order
+	//in which anything may arrive, so allow any old order
+	TBool exit = EFalse;
+	if ( challengeSize < (KObexNonceSize + 2))
+		{
+		FLOG(_L("CObex::ProcessChallenge incoming Challenge too small\n\r"));
+		User::Leave(KErrGeneral);
+		}
+
+	//must be space for Tag and size
+	while ((elementsLeft > 2) && (!exit))
+		{
+		switch (iRxChallenge->Des()[extractionPosn++])
+			{
+			case KObexChallNonceTag: //check the Nonce tag has arrived
+				{
+				elementsLeft--;  //passed the tag posn
+				if (( iRxChallenge->Des()[extractionPosn++] == KObexNonceSize )
+					&& (elementsLeft > KObexNonceSize))
+					{
+					FLOG(_L("CObex::ProcessChallenge incoming Nonce Extracted\n\r"));
+					iIncomingNonce.Zero();
+					//extract the Nonce data
+					TPtr8 ptr((TUint8*)iRxChallenge->Ptr() + extractionPosn 
+						,KObexNonceSize, KObexNonceSize);
+					iIncomingNonce.Append(ptr);
+					elementsLeft -= (KObexNonceSize + 1);
+					nonceExtracted = ETrue;
+					extractionPosn += KObexNonceSize;
+					}
+				else
+					{
+					FLOG(_L("CObex::ProcessChallenge Incorrect Nonce size\n\r"));
+					exit = ETrue;
+					}
+				}
+			break;
+			case KObexChallOptionsTag:
+				{
+				elementsLeft--;  //passed the tag posn
+				//check the options flag
+				iUserIDRequested = EFalse; 
+				if (( iRxChallenge->Des()[extractionPosn++] == KObexChallOptionSize )
+					&& (elementsLeft > KObexChallOptionSize))
+					{
+					//check if the user ID is required in the reply
+					if ( iRxChallenge->Des()[extractionPosn++] & KObexRequireUID )
+						{
+						//the userID has been requested so it MUST be sent back in the chall response
+						iUserIDRequested = ETrue;
+						FLOG(_L("CObex::ProcessChallenge User ID Requested\n\r"));
+						}
+					elementsLeft -= (KObexChallOptionSize + 1);
+
+					}
+				else
+					{
+					FLOG(_L("CObex::ProcessChallenge Incorrect Options size\n\r"));
+					exit = ETrue;
+					}
+				}
+				break;
+			case KObexChallRealmTag:
+				{
+				elementsLeft--;  //passed the tag posn
+				TInt size = iRxChallenge->Des()[ extractionPosn++ ];
+				elementsLeft--;
+				if ( (size > 0 ) && (size <= elementsLeft ) )
+					{
+					elementsLeft -= size;
+					size--; //remove the first byte
+					//check which format the data is in
+ 					TUint convertType=0;
+ 					switch(iRxChallenge->Des()[extractionPosn++])
+ 						{
+ 					case 0:
+ 						convertType=KCharacterSetIdentifierAscii;
+ 						break;
+ 					case 1:
+ 						convertType=KCharacterSetIdentifierIso88591;
+ 						break;
+ 					case 2:
+ 						convertType=KCharacterSetIdentifierIso88592;
+ 						break;
+ 					case 3:
+ 						convertType=KCharacterSetIdentifierIso88593;
+ 						break;
+ 					case 4:
+ 						convertType=KCharacterSetIdentifierIso88594;
+ 						break;
+ 					case 5:
+ 						convertType=KCharacterSetIdentifierIso88595;
+ 						break;
+ 					case 6:
+ 						convertType=KCharacterSetIdentifierIso88596;
+ 						break;
+ 					case 7:
+ 						convertType=KCharacterSetIdentifierIso88597;
+ 						break;
+ 					case 8:
+ 						convertType=KCharacterSetIdentifierIso88598;
+ 						break;
+ 					case 9:
+ 						convertType=KCharacterSetIdentifierIso88599;
+ 						break;
+ 					case 0xFF:
+ 						// Unicode, no conversion needed
+ 						break;
+ 					default:
+ 						User::Leave(KErrGeneral);
+ 						}
+ 
+ 					if(convertType)
+ 						{
+ 						RFs fs;
+ 						LEAVEIFERRORL(fs.Connect());
+ 						CleanupClosePushL(fs);
+ 						CCnvCharacterSetConverter* converter = CCnvCharacterSetConverter::NewLC();
+ 						if (converter->PrepareToConvertToOrFromL(convertType, fs) != CCnvCharacterSetConverter::EAvailable)
+ 							User::Leave(KErrGeneral);
+ 
+ 						iRemoteRealm = HBufC::NewL(size);
+ 						TPtr16 dest = iRemoteRealm->Des();
+ 						TInt state=CCnvCharacterSetConverter::KStateDefault;
+ 						TInt err = converter->ConvertToUnicode(dest, iRxChallenge->Mid(extractionPosn, size), state);
+ 						if (err < 0)
+ 							User::Leave(err);
+ 						CleanupStack::PopAndDestroy(2); // fs, converter
+   						}
+					else  //can only be unicode
+						{ //if unicode
+						FLOG(_L("CObex::ProcessChallenge incoming UNICODE Realm extracted\n\r"));
+						size = size/2; //if it's UNICODE then should be an even number
+						iRemoteRealm = HBufC::NewMaxL(size);
+ 						TPtr16 dest = iRemoteRealm->Des();
+						for ( TInt x = 0; x < size; x++ )
+							dest[x] = LittleEndian::Get16((TUint8*)iRxChallenge->Ptr() + extractionPosn + (2*x));
+						extractionPosn += size * 2;
+						}
+
+					}
+				else
+					{
+					FLOG(_L("CObex::ProcessChallenge Incorrect Realm size\n\r"));
+					exit = ETrue;
+					}
+				}
+				break;
+			default:
+				{
+				FLOG(_L("CObex::ProcessChallenge Unknown Tag type\n\r"));
+				exit = ETrue;
+				}
+				break;
+			}
+		}
+	if ( !nonceExtracted) //the nonce is mandatory so must exist
+		{
+		FLOG(_L("CObex::ProcessChallenge Nonce was not extracted\n\r"));
+		exit = ETrue;			
+		}
+	if ( exit )	
+		User::Leave(KErrGeneral);
+	}
+
+
+/** 
+Sets the authentication challenge handler.
+
+The caller must supply a MObexAuthChallengeHandler implementation to handle 
+calls from the Server/Client for a request for a password.
+
+@param aCallBack Authentication challenge handler  
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObex::SetCallBack(MObexAuthChallengeHandler& aCallBack)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iCallBack = &aCallBack;
+	}
+
+/**
+@internalTechnology
+
+This function is retained for backwards compatibility and should not be called.
+
+Calling this function has undefined behaviour.
+*/
+void CObex::Process(CObexPacket& aPacket)
+	{
+	NotifyProcess(aPacket);
+	}
+
+/**
+@internalTechnology
+
+This function is retained for backwards compatibility and should not be called.
+
+Calling this function has undefined behaviour.
+*/
+void CObex::Error(TInt aError) 
+	{
+	NotifyError(aError);
+	}
+
+/**
+@internalTechnology
+
+This function is retained for backwards compatibility and should not be called.
+
+Calling this function has undefined behaviour.
+*/
+void CObex::TransportUp() 
+	{
+	NotifyTransportUp();
+	}
+	
+/**
+@internalTechnology
+
+This function is retained for backwards compatibility and should not be called.
+Use ControlledTransportDown() or ForcedTransportDown() to disconnect the transport layer.
+Calling this function will result in an ETransportDownCalled panic.
+
+@panic ObexFault ETransportDownCalled
+@see ControlledTransportDown()
+@see ForcedTransportDown()
+*/
+void CObex::TransportDown(TBool)
+	{
+	IrOBEXUtil::Fault(ETransportDownCalled);
+	}
+
+
+void CObex::NotifyProcess(CObexPacket& aPacket)
+	{
+	LOG2(_L8("Packet Received, opcode: 0x%2X, Length: %d"), 
+					aPacket.Opcode(), aPacket.PacketSize());
+	FTRACE(aPacket.Dump());
+	OnPacketReceive(aPacket);
+	// The queuing of the next read packet varies between Server and Client
+	//     Client is done at the end of CObexClient::OnPacketReceive
+	//     Server is done once the write packet completes in CObexServer::SignalPacketProcessEvent
+	// This is because the Server may be mid-way through an asynchronous operation after OnPacketReceive
+	// so we have to keep the current read packet
+	if ((GetConnectState() == EWaitForUserInput )&&(iCallBack))
+		{
+		TRAPD(err, iCallBack->GetUserPasswordL(iRemoteRealm ? static_cast<TDesC&>(*iRemoteRealm) : KNullDesC()));
+		if ( err )
+			{
+			Error(err);
+			}
+		}
+	}
+
+void CObex::NotifyError(TInt aError)
+	{
+	LOG1(_L8("Error Called: %d"), aError);
+
+	// This call has been moved to before ForcedTransportDown(), because it
+	// needs to check whether the current operation is "disconnect" or
+	// not, and ForcedTransportDown() sets it to "idle".
+	OnError(aError);
+
+	if(iConnectState >= EConnTransport)
+		{
+		ForcedTransportDown();
+		}
+	}
+
+void CObex::NotifyTransportUp()
+	{
+	FLOG(_L("CObex::NotifyTransportUp\n\r"));
+	SetConnectState(EConnTransport);
+	OnTransportUp();
+	}
+
+void CObex::NotifyTransportDown(TBool)
+	{
+	IrOBEXUtil::Fault(ETransportDownCalled);
+	}
+
+/**
+This function forces the transport to be taken down 
+regardless of whether or not  the underlying transport can recover without 
+restarting obex applications
+However if the transport controller fails to bring the transport down, then only
+the obex connection is cancelled.  
+This is called in error conditions
+
+@see ControlledTransportDown()
+@internalComponent
+*/
+void CObex::ForcedTransportDown()
+	{
+	// iTransportController must be valid for all the CObex life cycle 
+	__ASSERT_DEBUG(iTransportController, IrOBEXUtil::Fault(ETransportControllerNotCreated));
+		
+	if (iTransportController->BringTransportDown())
+		{
+		SetConnectState(EConnIdle);
+		OnTransportDown();	
+		}
+	else 
+		{
+		//the transport failed to be taken down 
+		CancelObexConnection();
+		}
+	RemoteInfoCleanup();		
+	}
+	
+/**
+This function will  tear down the transport if the transport layer supports 
+transport reconnection on obex reconnection 
+This is called in conditions other than error conditions
+
+@see ForcedTransportDown()
+@internalComponent
+*/	
+void CObex::ControlledTransportDown()
+	{
+	// iTransportController must be valid for all the CObex life cycle 
+	__ASSERT_DEBUG(iTransportController, IrOBEXUtil::Fault(ETransportControllerNotCreated));
+	
+	TBool canBringTransportDown = iTransportController->IsTransportRestartable();
+	if  (canBringTransportDown)
+		{
+		ForcedTransportDown();
+		}  	 	
+	else
+  		{
+  		CancelObexConnection();
+  		RemoteInfoCleanup();
+   		}
+
+	}	
+
+/**
+General cleanup of iRemoteInfo
+@internalComponent
+*/
+void CObex::RemoteInfoCleanup()
+	{
+	// Some general cleanup here.
+	iRemoteInfo.iTargetHeader.SetLength(0);
+	iRemoteInfo.iWho.SetLength(0);
+	}
+
+/**
+Put into  transport connected state but cancel any outstanding transfers and operations
+@internalComponent
+*/
+void CObex::CancelObexConnection()
+	{
+	// iTransportController must be valid for all the CObex life cycle 
+	__ASSERT_DEBUG(iTransportController, IrOBEXUtil::Fault(ETransportControllerNotCreated));
+		
+	 iTransportController->CancelTransfers();
+   	SetConnectState(EConnTransport);
+   	iCurrentOperation = EOpIdle;
+	}
+
+/**
+Change the state of the authentication state machine
+@param aNewState New state
+@internalComponent
+*/
+void CObex::SetConnectState(TConnectState aNewState)
+	{
+	switch(iConnectState = aNewState)
+		{
+	case EConnIdle:
+		FLOG(_L("### Connection State EConnIdle\r\n"));
+		break;
+ 	case EConnTransport:
+		FLOG(_L("###### Connection State EConnTransport\r\n"));
+		break;
+	case ESimpleConnRequest:
+		FLOG(_L("######### Connection State ESimpleConnRequest\r\n"));
+		break;
+	case EConnObex:
+		FLOG(_L("######### Connection State EConnObex\r\n"));
+		break;
+	case EConnChallRxed:
+		FLOG(_L("######### Connection State EConnChallRxed\r\n"));
+		break;
+	case ESimpleConnChallIssued:
+		FLOG(_L("######### Connection State ESimpleConnChallIssued\r\n"));
+		break;
+	case EChallConnRequested:
+		FLOG(_L("######### Connection State EChallConnRequested\r\n"));
+		break;
+	case EChallConnChallIssued:
+		FLOG(_L("######### Connection State EChallConnChallIssued\r\n"));
+		break;
+	case EWaitForFinalResponse:
+		FLOG(_L("######### Connection State EWaitForFinalResponse\r\n"));
+		break;
+	case EFinalChallRxed:
+		FLOG(_L("######### Connection State EConnChallReIssued\r\n"));
+		break;
+	case EDropLink:
+		FLOG(_L("######### Connection State EDropLink\r\n"));
+		break;
+	default: 
+		break;
+		}
+	}
+	
+// CObex::TSetPathInfo
+/**
+Constructor. 
+
+This is the path information used in the SETPATH command.
+The variable iFlags is set to zero by default. The variable iConstants is always set to zero as this is a reserved 
+varaible. The path name is NOT present by default.
+
+@publishedAll
+@released
+*/
+EXPORT_C CObex::TSetPathInfo::TSetPathInfo() 
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iFlags = 0;
+	iConstants = 0;
+	iNamePresent = EFalse;
+	}
+
+/**
+@internalComponent
+*/
+CObex::TSetPathInfo::TSetPathInfo(const TObexSetPathData& aData)
+	: iFlags(aData.iFlags), iConstants(aData.iConstants), iNamePresent(EFalse)
+	{
+	}
+
+/**
+Returns true if the flags are set so that the receiver will backup a level before applying the path name
+
+@return ETrue if the flags are set so that the receiver will backup a level before applying the path name othewise EFalse.
+
+@publishedAll
+@released
+*/
+EXPORT_C TBool CObex::TSetPathInfo::Parent() const 
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return(iFlags & KObexSetPathParent);
+	}
+
+// CObex
+/**
+Returns ETrue if this CObex is connected at an OBEX level, merely having
+a transport connected does not satisfy this condition. I.e. the two devices
+must have completed the OBEX connection request/response . All other states
+return EFalse. This will be unreliable if either the server blindly 
+returns the client’s who header (always reporting ETrue), or if neither
+supply "who" headers (always reporting EFalse).
+
+@return ETrue if this CObex is connected at an OBEX level.  EFalse otherwise.
+@publishedAll
+@released
+*/
+EXPORT_C TBool CObex::IsConnected() const 
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return(GetConnectState() == EConnObex);
+	}
+
+/**	
+@return ETrue if the "who" header specified in the server’s connect response 
+		matched that of the client’s connect request, and both had a length greater 
+		than 0 (i.e. both specified a "who" field). Undefined if IsConnected() == EFalse. 
+
+@publishedAll
+@released
+*/
+EXPORT_C TBool CObex::IsStrictPeer() const 
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return((iLocalInfo.iWho.Length()>0) && (iLocalInfo.iWho==iRemoteInfo.iWho));
+	}
+
+/**
+Use this member to gain access to (and alter, if necessary) the 
+CObex::TConnectInfo structure which will be sent to the OBEX peer as part 
+of the connection process. Only alter the contents of this having read and 
+understood the purpose of the fields, as defined in the OBEX spec. Altering 
+this structure after a connection has been made will have no effect on the
+current session, but will be used for future connection attempts.
+
+@return The connect info which will be sent to the OBEX peer.
+@publishedAll
+@released
+*/
+EXPORT_C const TObexConnectInfo& CObex::LocalInfo() const 
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return(iLocalInfo);
+	}
+
+/**
+Use this member to read the details of the remote machine’s connection 
+information, as specified by it in during OBEX connection. This data can 
+not be altered, as this serves no purpose.
+The content of this structure is undefined when @see IsConnected () ==
+EFalse. 
+
+@return The connect info from the remote machine.
+@publishedAll
+@released
+*/
+EXPORT_C const TObexConnectInfo& CObex::RemoteInfo() const 
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return(iRemoteInfo);
+	}
+
+/**
+This function is in the protected scope of CObex and so is not externally usable
+@publishedAll
+@released
+*/
+EXPORT_C CObex::TConnectState CObex::ConnectState() const 
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	// This function is exported but protected, making it not much use
+	// Making it public, and exposing more information about the authentication
+	// state machine is undesirable, but a public function is required for other
+	// classes in the DLL. Thus another public, unexported function has been defined
+	// on to which this function chains.
+	return GetConnectState();
+	};
+
+/**
+Get the current state of the authentication state machine
+@internalComponent
+*/
+CObex::TConnectState CObex::GetConnectState() const 
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return iConnectState;
+	};
+	
+/**
+Must be called by an application that wishes to suppress the authentication or(not excusive) the realm of the authentication challenge 
+@param aSuppressedObexAuthElements enum TObexSuppressedAuthElements to indicate which header elements to surpress (if any)
+@panic KErrArgument if invalid value is passed in for enum
+@publishedAll
+@released
+*/
+EXPORT_C void CObex::SuppressAuthenticationHeaderElements(TObexSuppressedAuthElements aSuppressedObexAuthElements)
+	{
+	LOG_LINE
+	LOG_FUNC
+		
+	// If the value passed in is not a valid bitmask then panic
+	_LIT(panicText, "Invalid bitmask passed to CObex::SuppressAuthenticationHeaderElements");	
+	__ASSERT_ALWAYS((!(aSuppressedObexAuthElements > EObexSuppressAllAuthElements)), User::Panic(panicText, KErrArgument));
+		
+	iSuppressedObexAuthElements = aSuppressedObexAuthElements;
+	
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/OBEXUTIL.CPP	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,189 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+*/
+
+#include <e32std.h>
+#include <obextransportinfo.h>
+#include <obexirtransportinfo.h>
+#include <obexbttransportinfo.h>
+#include <obexusbtransportinfo.h>
+#include "obexcommon.h"
+#include "OBEXUTIL.H"
+#include "obexfaults.h"
+
+
+void IrOBEXUtil::Panic(TObexPanicCode aCode)
+	{
+	User::Panic(KObexPanicCategory, aCode);
+	}
+
+
+void IrOBEXUtil::Fault(TObexFaultCode aCode)
+	{
+	User::Panic(KObexFaultCategory, aCode);
+	}
+
+/**
+Converts aResp to an EPOC error number 
+*/
+TInt IrOBEXUtil::EpocError(TUint8 aResp)
+	{
+	switch (aResp)
+		{
+	case ERespContinue:
+	case ERespSuccess:
+	case ERespCreated:
+	case ERespAccepted:
+		return (KErrNone);
+	case ERespBadRequest:
+	case ERespUnauthorized:
+	case ERespForbidden:
+	case ERespNotAcceptable:
+	case ERespMethodNotAllowed:
+		return (KErrArgument);
+	case ERespNotFound:
+		return (KErrNotFound);
+	case ERespTimedOut:
+		return (KErrTimedOut);
+	case ERespConflict:
+		return (KErrInUse);
+	case ERespNotImplemented:
+		return (KErrNotSupported);
+	default:
+		return (KErrIrObexRespBase - aResp);
+		}
+	}
+
+/**
+Returns a TObexTransportInfo created from the received aObexProtocolInfoPtr and aObexProtocolPolicy
+to be used in the transport layer
+*/
+TObexTransportInfo* IrOBEXUtil::CreateTransportInfoL(TObexProtocolInfo& aObexProtocolInfoPtr, TObexProtocolPolicy& aObexProtocolPolicy)
+	{
+	TObexTransportInfo* transportInfo = NULL;
+
+	if ( aObexProtocolInfoPtr.iTransport == KObexIrTTPProtocol )
+		{
+		transportInfo = new(ELeave) TObexIrTransportInfo;
+		TObexIrProtocolInfo& irProtocolInfo = static_cast<TObexIrProtocolInfo&>(aObexProtocolInfoPtr);
+		static_cast<TObexIrTransportInfo*>(transportInfo)->iAddr  = irProtocolInfo.iAddr;
+		static_cast<TObexIrTransportInfo*>(transportInfo)->iClassName = irProtocolInfo.iClassName;
+		static_cast<TObexIrTransportInfo*>(transportInfo)->iAttributeName = irProtocolInfo.iAttributeName;		
+		}
+	else if ( aObexProtocolInfoPtr.iTransport == KObexIrTTPProtocolV2 )
+		{
+		transportInfo = new(ELeave) TObexIrV2TransportInfo;
+		TObexIrProtocolInfo& irProtocolInfo = static_cast<TObexIrProtocolInfo&>(aObexProtocolInfoPtr);
+		static_cast<TObexIrV2TransportInfo*>(transportInfo)->iAddr  = irProtocolInfo.iAddr;
+		static_cast<TObexIrV2TransportInfo*>(transportInfo)->iClassName = irProtocolInfo.iClassName;
+		static_cast<TObexIrV2TransportInfo*>(transportInfo)->iAttributeName = irProtocolInfo.iAttributeName;
+		static_cast<TObexIrV2TransportInfo*>(transportInfo)->iDiscoverySlots = irProtocolInfo.iDiscoverySlots;
+		static_cast<TObexIrV2TransportInfo*>(transportInfo)->iDiscoveryAttempts = irProtocolInfo.iDiscoveryAttempts;
+		}
+	else if ( aObexProtocolInfoPtr.iTransport == KObexRfcommProtocol )
+		{
+		transportInfo = new(ELeave) TObexBtTransportInfo;
+		TObexBluetoothProtocolInfo& btProtocolInfo = static_cast<TObexBluetoothProtocolInfo&>(aObexProtocolInfoPtr);
+		static_cast<TObexBtTransportInfo*>(transportInfo)->iAddr = btProtocolInfo.iAddr;
+		}
+#ifdef __WINS__
+	else if ( aObexProtocolInfoPtr.iTransport == KObexUsbProtocol || aObexProtocolInfoPtr.iTransport == KObexWin32UsbProtocol )
+#else
+	else if ( aObexProtocolInfoPtr.iTransport == KObexUsbProtocol)
+#endif
+		{
+		transportInfo = new(ELeave) TObexUsbTransportInfo();
+		TObexUsbProtocolInfo& usbTransportInfo = static_cast<TObexUsbProtocolInfo&>(aObexProtocolInfoPtr);
+		static_cast<TObexUsbTransportInfo*>(transportInfo)->iInterfaceStringDescriptor = usbTransportInfo.iInterfaceStringDescriptor;			
+		}
+	else if ( aObexProtocolInfoPtr.iTransport == KObexUsbProtocolV2 )
+		{
+		transportInfo = new(ELeave) TObexUsbV2TransportInfo();
+		TObexUsbProtocolInfoV2& usbV2TransportInfo = static_cast<TObexUsbProtocolInfoV2&>(aObexProtocolInfoPtr);
+		static_cast<TObexUsbV2TransportInfo*>(transportInfo)->iInterfaceStringDescriptor = usbV2TransportInfo.iInterfaceStringDescriptor;	
+		static_cast<TObexUsbV2TransportInfo*>(transportInfo)->iBandwidthPriority = usbV2TransportInfo.iBandwidthPriority;
+		static_cast<TObexUsbV2TransportInfo*>(transportInfo)->iDmaOnOutEndpoint = usbV2TransportInfo.iDmaOnOutEndpoint;
+		static_cast<TObexUsbV2TransportInfo*>(transportInfo)->iDmaOnInEndpoint = usbV2TransportInfo.iDmaOnInEndpoint;	
+		}
+		
+	__ASSERT_DEBUG(transportInfo, Fault(EUtilNoTransportInfo));
+	transportInfo->iTransportName = aObexProtocolInfoPtr.iTransport;
+	transportInfo->iReceiveMtu = aObexProtocolPolicy.ReceiveMtu();
+	transportInfo->iTransmitMtu = aObexProtocolPolicy.TransmitMtu();
+	transportInfo->iVersion = KObexTransportInfoVersion0;
+	return transportInfo;
+	}
+
+/**	
+Converts aErr to an obex response.
+
+@return aDefault if aErr == KErrNone, else the appriate obex response
+*/	
+TObexResponse IrOBEXUtil::ObexResponse (TInt aErr, TObexResponse aDefault)
+	{ 
+	switch (aErr)
+		{
+		case KErrNone:
+			return (aDefault);
+		case KErrNotFound:
+		case KErrPathNotFound:
+		case KErrUnknown:
+		case KErrBadName:
+			return (ERespNotFound);
+		case KErrNotSupported:
+			return (ERespNotImplemented);
+		case KErrAlreadyExists:
+		case KErrInUse:
+			return (ERespConflict);
+		case KErrAccessDenied:
+			return (ERespUnauthorized);
+		case KErrLocked:
+			return (ERespForbidden);
+		case KErrTimedOut:
+			return (ERespTimedOut);
+		default:
+			{ 
+			//check if it's one of the Symbian codes which has been set aside for 
+			//mapping to an official OBEX code
+			//unfortunately these are not continuous and exist in 4 discrete blocks
+			
+			if (( (aErr <= KErrIrObexRespSuccess ) && (aErr >= KErrIrObexRespPartialContent))
+				||( (aErr <=KErrIrObexRespMultipleChoices) && (aErr >= KErrIrObexRespUseProxy))
+				||( (aErr<=KErrIrObexRespBadRequest) && (aErr>=KErrIrObexRespHTTPVerNotSupp) )
+				||( (aErr <= KErrIrObexRespDatabaseFull) && (aErr >= KErrIrObexRespDatabaseLocked)))
+				{
+				
+				
+				TInt err = aErr * -1;
+	
+				err += KErrIrObexRespBase;
+
+				
+					
+				return ( static_cast<TObexResponse>(err) );
+
+				}
+			//in all other cases the error code isn't understood
+			return (ERespInternalError);
+			}
+		}
+	}
+
+//
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerOperationState.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,253 @@
+// 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 <obex.h>
+#include <obex/internal/obexinternalheader.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+*/
+
+/**
+Called by the state machine when it has moved into the state
+Default action - do nothing and return no error
+@param aContext Reference to state machine object
+*/
+void TObexServerOperationState::Entry(CObexServerStateMachine& /*aContext*/)
+	{
+	}
+
+/**
+Connection packet to be processed
+Default action - fault (event should not happen for this state)
+@param aContext Reference to state machine object
+@param aPacket Connect packet
+*/
+void TObexServerOperationState::Connect(CObexServerStateMachine& /*aContext*/, CObexPacket& /*aPacket*/)
+	{
+	IrOBEXUtil::Fault(EConnectInBadState);
+	}
+
+/**
+Disconnect packet to be processed
+Default action - fault (event should not happen for this state)
+@param aContext Reference to state machine object
+@param aPacket Disconnect packet
+*/
+void TObexServerOperationState::Disconnect(CObexServerStateMachine& /*aContext*/, CObexPacket& /*aPacket*/)
+	{
+	IrOBEXUtil::Fault(EDisconnectInBadState);
+	}
+
+/**
+Put packet to be processed
+Default action - fault (event should not happen for this state)
+@param aContext Reference to state machine object
+@param aPacket Put packet
+*/
+void TObexServerOperationState::Put(CObexServerStateMachine& /*aContext*/, CObexPacket& /*aPacket*/)
+	{
+	IrOBEXUtil::Fault(EPutInBadState);
+	}
+
+/**
+Get packet to be processed
+Default action - fault (event should not happen for this state)
+@param aContext Reference to state machine object
+@param aPacket Get packet
+*/
+void TObexServerOperationState::Get(CObexServerStateMachine& /*aContext*/, CObexPacket& /*aPacket*/)
+	{
+	IrOBEXUtil::Fault(EGetInBadState);
+	}
+
+/**
+SetPath packet to be processed
+Default action - fault (event should not happen for this state)
+@param aContext Reference to state machine object
+@param aPacket SetPath packet
+*/
+void TObexServerOperationState::SetPath(CObexServerStateMachine& /*aContext*/, CObexPacket& /*aPacket*/)
+	{
+	IrOBEXUtil::Fault(ESetPathInBadState);
+	}
+
+/**
+Abort request to be processed
+Default action - fault (event should not happen for this state)
+@param aContext Reference to state machine object
+*/
+void TObexServerOperationState::Abort(CObexServerStateMachine& /*aContext*/)
+	{
+	IrOBEXUtil::Fault(EAbortInBadState);
+	}
+
+/**
+Transport up notification
+Default action - do nothing or fault (event should not happen for this state)
+@param aContext Reference to state machine object
+*/
+void TObexServerOperationState::TransportUp(CObexServerStateMachine& /*aContext*/)
+	{
+	__ASSERT_DEBUG(EFalse, IrOBEXUtil::Fault(ETransportUpInBadState));
+	}
+
+/**
+Server Start notification
+Default action - do nothing and return no error
+@param aContext Reference to state machine object
+*/
+void TObexServerOperationState::Start(CObexServerStateMachine& /*aContext*/)
+	{
+	}
+
+/**
+Reset notification - state machine should go back to the initial (disconnected) state
+Default action - change to Disconnected state
+@param aContext Reference to state machine object
+*/
+void TObexServerOperationState::Reset(CObexServerStateMachine& aContext)
+	{
+	aContext.ChangeState(CObexServerStateMachine::EDisconnected);
+	}
+
+/**
+Asynchronous notification complete - the Application has return an object for the current operation
+Default action - panic as there is no operation waiting for a notification
+@param aContext Reference to state machine object
+@param aObject Pointer to object returned from the Application
+@panic ENoNotificationToComplete
+*/
+void TObexServerOperationState::RequestNotificationCompleted(CObexServerStateMachine& /*aContext*/, CObexBaseObject* /*aObject*/)
+	{
+	IrOBEXUtil::Panic(ENoNotificationToComplete);
+	}
+	
+/**
+Asynchronous notification complete - the Application has return an object for the current operation
+Default action - panic as there is no operation waiting for a notification
+@param aContext Reference to state machine object
+@param aObject Pointer to object returned from the Application
+@panic ENoNotificationToComplete
+*/	
+void TObexServerOperationState::RequestNotificationCompleted(CObexServerStateMachine& /*aContext*/, TObexResponse /*aAppResponse*/)
+	{
+	IrOBEXUtil::Panic(ENoNotificationToComplete);
+	}
+
+/**
+Asynchronous notification complete - the Application has return an object for the current operation
+Default action - panic as there is no operation waiting for a notification
+@param aContext Reference to state machine object
+@param aObject Pointer to object returned from the Application
+@panic ENoNotificationToComplete
+*/	
+void TObexServerOperationState::RequestCompleteNotificationCompleted(CObexServerStateMachine& /*aContext*/, TObexResponse /*aAppResponse*/)
+	{
+	IrOBEXUtil::Panic(ENoNotificationToComplete);
+	}
+
+
+/**
+Connection notification - an OBEX connection has been made
+Default action - panic. This should not be passed to the state machine in this state.
+@param aContext Reference to state machine object
+*/
+void TObexServerOperationState::ConnectionComplete(CObexServerStateMachine& /*aContext*/)
+	{
+	IrOBEXUtil::Fault(EConnectionCompleteInBadState);
+	}
+
+/**
+A user has requested to override the handling of a request packet.
+@param aContext Reference to state machine object
+@param aResponse Response code to send to Obex Client (this must not be a success code)
+*/	
+void TObexServerOperationState::OverrideRequestHandling(CObexServerStateMachine& /*aContext*/, TObexResponse /*aResponse*/)
+	{
+	IrOBEXUtil::Panic(EOverrideRequestHandlingInBadState);
+	}
+
+// Utility functions - common operations performed by states
+
+/**
+Check disconnect packet for the correct connection ID (if required) and disconnect the Client
+If the check is not sucessful, return to the Idle state if there is an OBEX connection
+or the TransportConnected state otherwise
+@param aContext Reference to state machine object
+@param aPacket Disconnect packet
+*/
+/*static*/ void TObexServerOperationState::PerformDisconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+	{
+	FLOG(_L("OnPacketReceive DisConnect OP code\r\n"));
+	aContext.Owner().SetCurrentOperation(CObex::EOpDisconnect);
+
+	// Check for connection ID before performing disconnect
+	if (aContext.Owner().CheckPacketForConnectionId(aPacket))
+		{
+		aContext.Transport().Send(ERespSuccess);
+		aContext.ChangeState(CObexServerStateMachine::EDisconnecting);
+		}
+	else
+		{
+		// Incorrect connection ID - abandon current operation
+		aContext.Transport().Send(ERespServiceUnavailable);
+		// Target states depends on whether there is a current OBEX connection
+		if (aContext.Owner().GetConnectState() == CObex::EConnObex)
+			{
+			aContext.ChangeState(CObexServerStateMachine::EReady);
+			}
+		else
+			{
+			aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+			}
+		}
+	}
+
+/**
+End the current operation, sending the given response code to the Client and moving to the Idle state
+@panic ObexFault ERespondAndEndOpWithoutObexConnection if there is no OBEX connection
+@param aContext Reference to state machine object
+@param aResponseCode Response code to send to the Client
+*/
+/*static*/ void TObexServerOperationState::RespondAndEndOperation(CObexServerStateMachine& aContext, TObexResponse aResponseCode)
+	{
+	// This function assumes that there is an OBEX connection, so it goes back to EReady - the assert checks this
+	__ASSERT_DEBUG((aContext.Owner().GetConnectState() == CObex::EConnObex),IrOBEXUtil::Fault(ERespondAndEndOpWithoutObexConnection));
+
+	aContext.Transport().Send(aResponseCode);
+	aContext.ChangeState(CObexServerStateMachine::EReady);
+	}
+	
+TBool TObexServerOperationState::ValidResponse(TObexResponse /*aResponseCode*/)
+	{
+	return EFalse;
+	}
+
+void TObexServerOperationState::WriteComplete(CObexServerStateMachine& /*aContext*/)
+	{
+	}
+
+/**
+Indicates that a new obex packet is being read. Do nothing in default state.
+*/
+void TObexServerOperationState::ReadActivityDetected(CObexServerStateMachine& /*aContext*/)
+	{
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateDisconnected.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#include <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+Disconnected State
+This is the ground state for the machine: transport is disconnected, operation is EOpIdle
+Machine will move to TransportConnnected state on receiving a TransportUp
+*/
+
+TObexServerStateDisconnected::TObexServerStateDisconnected()
+	{
+#ifdef __FLOG_ACTIVE
+	_LIT8(KName, "Disconnected");
+	iName = KName;
+#endif
+	}
+
+void TObexServerStateDisconnected::Entry(CObexServerStateMachine& aContext)
+	{
+	aContext.Owner().SetCurrentOperation(CObex::EOpIdle);
+	}
+
+void TObexServerStateDisconnected::TransportUp(CObexServerStateMachine& aContext)
+	{
+	aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+	}
+
+void TObexServerStateDisconnected::Reset(CObexServerStateMachine& /*aContext*/)
+	{
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateDisconnecting.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,92 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex.h>
+#include "obexserverstatemachine.h"
+
+#if ( defined __FLOG_ACTIVE && defined __LOG_FUNCTIONS__ )
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/**
+@file
+@internalComponent
+
+Disconnecting State
+In this state, the server has received a (correctly-addressed) disconnect 
+request from the client, and placed an asynchronous request on the transport 
+to ACK it.
+This state is interested in the completion of that send request so it can (a) 
+complete the client's notifications, (b) move to 'transport connected' state 
+and (c) pull down the transport.
+*/
+
+TObexServerStateDisconnecting::TObexServerStateDisconnecting()
+	{
+#ifdef __FLOG_ACTIVE
+	_LIT8(KName, "Disconnecting");
+	iName = KName;
+#endif
+	}
+
+void TObexServerStateDisconnecting::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexBadEvent);
+	}
+
+void TObexServerStateDisconnecting::Disconnect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexBadEvent);
+	}
+
+void TObexServerStateDisconnecting::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexBadEvent);
+	}
+
+void TObexServerStateDisconnecting::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexBadEvent);
+	}
+
+void TObexServerStateDisconnecting::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexBadEvent);
+	}
+
+void TObexServerStateDisconnecting::Abort(CObexServerStateMachine& aContext)
+	{
+	aContext.Owner().Error(KErrIrObexBadEvent);
+	}
+	
+void TObexServerStateDisconnecting::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse /*aResponse*/)
+	{
+	aContext.Owner().Error(KErrIrObexBadEvent);
+	}
+
+void TObexServerStateDisconnecting::WriteComplete(CObexServerStateMachine& aContext)
+	{
+	LOG_FUNC
+
+	aContext.Notification().ObexDisconnectIndication(KNullDesC8);
+	// ControlledTransportDown() may raise a TransportDown event immediately, 
+	// re-entering the state machine, so we need to be in the correct state 
+	// (TransportConnected) before the call.
+	// Also need to keep current operation == EOpDisconnect until transport is 
+	// happy (which is done in CObex) so ETransportConnected does not set 
+	// iCurrentOperation to EOpIdle.
+	aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+	aContext.ControlledTransportDown();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateGetOpFinal.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#include <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+Final Get Operation Receive State
+Waiting for reply from server app to an async notification GetCompleteIndication
+
+Any OBEX operation will cause a Protocol Error
+Chaging the MObexServerNotifyAsync via CObexServer::Start() will cause a Panic
+A Reset event (Protocol Error, Server Stop, Transport Down) will cancel the notification and move the machine to Disconnected
+The NotificationComplete event send the response back to the client and move the state machine to Ready
+*/
+
+TObexServerStateGetOpFinal::TObexServerStateGetOpFinal()
+	{
+#ifdef __FLOG_ACTIVE
+	_LIT8(KName, "GetOpFinal");
+	iName = KName;
+#endif
+	}
+
+void TObexServerStateGetOpFinal::Entry(CObexServerStateMachine& aContext)
+	{
+	aContext.Notification().GetCompleteIndication();
+	}
+
+void TObexServerStateGetOpFinal::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateGetOpFinal::Disconnect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateGetOpFinal::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateGetOpFinal::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateGetOpFinal::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateGetOpFinal::Abort(CObexServerStateMachine& aContext)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateGetOpFinal::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse /*aResponse*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateGetOpFinal::Reset(CObexServerStateMachine& aContext)
+	{
+	// Cancel notification - if it has not already been activated
+	if (!aContext.IsCallBackActive())
+		{
+		aContext.Notification().CancelIndicationCallback();
+		}
+	aContext.CancelCallBack();
+	aContext.ChangeState(CObexServerStateMachine::EDisconnected);
+	}
+
+void TObexServerStateGetOpFinal::Start(CObexServerStateMachine& /*aContext*/)
+	{
+	// Panic - trying to change interface during wait
+	IrOBEXUtil::Panic(EChangeInterfaceDuringWait);
+	}
+
+void TObexServerStateGetOpFinal::RequestCompleteNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse)
+	{
+	aContext.SetAppResponse(aAppResponse);
+	aContext.CallBack(TObexServerStateGetOpFinal::ProcessNotification);
+	}
+	
+TInt TObexServerStateGetOpFinal::ProcessNotification(TAny* aPtr)
+	{
+	CObexServerStateMachine& context = *static_cast<CObexServerStateMachine*>(aPtr);
+
+	context.Transport().SendPacket().SetOpcode(context.AppResponse());
+	context.Transport().SendPacket().SetFinal();
+	context.Transport().Send();
+	
+	context.ChangeState(CObexServerStateMachine::EReady);
+	return KErrNone;
+	}
+
+TBool TObexServerStateGetOpFinal::ValidResponse(TObexResponse aResponseCode)
+	{
+	return (aResponseCode>0 && aResponseCode<=255 && aResponseCode != ERespContinue);
+	}
+	
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateGetOpReceiveSpecification.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,107 @@
+// 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 <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+GET Operation Receive Specification State
+This state receives the specification object from the client and transfers to GetOpWaitForUser once the object is received
+A GET, DISCONNECT or ABORT will be processed
+Any other OBEX operation will be answered with an OBEX error code
+*/
+
+TObexServerStateGetOpReceiveSpecification::TObexServerStateGetOpReceiveSpecification()
+	{
+#ifdef __FLOG_ACTIVE
+	_LIT8(KName, "GetOpReceiveSpecification");
+	iName = KName;
+#endif
+	}
+
+void TObexServerStateGetOpReceiveSpecification::Entry(CObexServerStateMachine& aContext)
+	{
+	// Reset specification object
+	if(aContext.SpecObject()->InitReceive() != KErrNone)
+		{
+		aContext.Transport().Send(ERespInternalError);
+		return;
+		}
+	aContext.Owner().SetCurrentOperation(CObex::EOpGet);
+	// Chain on to Get to start receiving specification
+	Get(aContext, aContext.LastReceivedPacket());
+	}
+
+void TObexServerStateGetOpReceiveSpecification::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Send ERespConflict and return to Ready
+	RespondAndEndOperation(aContext, ERespConflict);
+	}
+
+void TObexServerStateGetOpReceiveSpecification::Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+	{
+	// Process disconnect
+	PerformDisconnect(aContext, aPacket);
+	}
+
+void TObexServerStateGetOpReceiveSpecification::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Send ERespBadRequest and return to Ready
+	RespondAndEndOperation(aContext, ERespBadRequest);
+	}
+
+void TObexServerStateGetOpReceiveSpecification::Get(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+	{
+	// Process packet and see if specification is complete
+	// Packet contains more headers describing the object to be 'got'
+	if(aContext.SpecObject()->ParseNextReceivePacket(aPacket) == CObexBaseObject::EError)
+		{
+		aContext.Transport().Send(aContext.SpecObject()->GetLastError());
+		aContext.ChangeState(CObexServerStateMachine::EReady);
+		return;
+		}
+
+	if(aPacket.IsFinal())
+		{// Time to turn around and start sending our reply
+		aContext.ChangeState(CObexServerStateMachine::EGetOpWaitForUser);
+		}
+	else
+		{
+		aContext.Transport().Send(ERespContinue);
+		}
+	}
+
+void TObexServerStateGetOpReceiveSpecification::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Send ERespConflict and return to Ready
+	RespondAndEndOperation(aContext, ERespConflict);
+	}
+
+void TObexServerStateGetOpReceiveSpecification::Abort(CObexServerStateMachine& aContext)
+	{
+	// Send ERespSuccess and return to Ready
+	aContext.Notification().AbortIndication();
+	RespondAndEndOperation(aContext, ERespSuccess);
+	}
+	
+void TObexServerStateGetOpReceiveSpecification::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse)
+	{
+	// Send server app response and return to Ready
+	RespondAndEndOperation(aContext, aResponse);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateGetOpSendObject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#include <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+GET Operation Send State
+This state sends the object to the client and transfers to Ready once the exchange is finished
+A GET, DISCONNECT or ABORT will be processed
+Any other OBEX operation will be answered with an OBEX error code
+*/
+
+TObexServerStateGetOpSendObject::TObexServerStateGetOpSendObject()
+	{
+#ifdef __FLOG_ACTIVE
+	_LIT8(KName, "GetOpSendObject");
+	iName = KName;
+#endif
+	}
+
+void TObexServerStateGetOpSendObject::Entry(CObexServerStateMachine& aContext)
+	{
+	// Chain on to Get() to start sending object
+	Get(aContext, aContext.LastReceivedPacket());
+	}
+
+void TObexServerStateGetOpSendObject::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Send ERespConflict and return to Ready
+	RespondAndEndOperation(aContext, ERespConflict);
+	}
+
+void TObexServerStateGetOpSendObject::Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+	{
+	// Process disconnect
+	PerformDisconnect(aContext, aPacket);
+	}
+
+void TObexServerStateGetOpSendObject::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Send ERespBadRequest and return to Ready
+	RespondAndEndOperation(aContext, ERespBadRequest);
+	}
+
+void TObexServerStateGetOpSendObject::Get(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+	{
+	if(!aPacket.IsFinal())
+		{
+		// Raising a Protocol Error will cause a Reset event resulting in a move to Disconnected.
+		// So any code after this call will potentially be executed in a different state
+		aContext.Owner().Error(KErrCommsOverrun);
+		return;
+		}
+
+	// This section prepares the next packet to send, if an error is detected or it is the final packet
+	// the machine is moved to EReady.
+	TInt err = KErrGeneral;
+	if(aContext.TransObject()->PrepareNextSendPacket(aContext.Transport().SendPacket()) == CObexBaseObject::EError ||
+		(err = aContext.Notification().GetPacketIndication()) != KErrNone)
+		{
+		aContext.Transport().SendPacket().Init(IrOBEXUtil::ObexResponse(err, ERespInternalError));
+		aContext.ChangeState(CObexServerStateMachine::EReady);
+		}
+	else if(aContext.Transport().SendPacket().IsFinal())
+		{// This is the last packet of the object being returned to client
+		aContext.ChangeState(CObexServerStateMachine::EGetOpFinal);
+		return;	
+		}
+	// Send the resultant packet
+	aContext.Transport().SendPacket().SetFinal();
+	aContext.Transport().Send();
+	}
+
+void TObexServerStateGetOpSendObject::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Send ERespConflict and return to Ready
+	RespondAndEndOperation(aContext, ERespConflict);
+	}
+
+void TObexServerStateGetOpSendObject::Abort(CObexServerStateMachine& aContext)
+	{
+	// Send ERespSuccess and return to Ready
+	aContext.Notification().AbortIndication();
+	RespondAndEndOperation(aContext, ERespSuccess);
+	}
+	
+void TObexServerStateGetOpSendObject::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse)
+	{
+	// Send server app response and return to Ready
+	RespondAndEndOperation(aContext, aResponse);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateGetOpWaitForUser.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,175 @@
+// 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 <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+GET Operation Wait State
+This state issues the Get indication to the Application on entry and then waits for the response.
+
+Any OBEX operation will be cause a Protocol Error
+Chaging the MObexServerNotifyAsync via CObexServer::Start() will cause a Panic
+A Reset event (Protocol Error, Server Stop, Transport Down) will cancel the notification and move the machine to Disconnected
+The NotificationComplete event will queue a async one-shot to process the returned object, moving the machine to GetOpSendObject
+*/
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KGetWaitCmpt, "getwait");
+
+#define GETWAIT_LOG(str) CObexLog::Write(KGetWaitCmpt, str)
+#else
+#define GETWAIT_LOG(str)
+#endif
+
+
+TObexServerStateGetOpWaitForUser::TObexServerStateGetOpWaitForUser()
+	{
+#ifdef __FLOG_ACTIVE
+	_LIT8(KName, "GetOpWaitForUser");
+	iName = KName;
+#endif
+	}
+
+void TObexServerStateGetOpWaitForUser::Entry(CObexServerStateMachine& aContext)
+	{
+	// Send notification to the Application
+	aContext.SetTransObject(NULL);
+	
+	GETWAIT_LOG(_L8("Upcalling..."));
+	aContext.Notification().GetRequestIndication(aContext.SpecObject());
+	}
+
+void TObexServerStateGetOpWaitForUser::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Raise Protocol Error (which will cause a Reset and cancel the notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateGetOpWaitForUser::Disconnect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Raise Protocol Error (which will cause a Reset and cancel the notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateGetOpWaitForUser::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Raise Protocol Error (which will cause a Reset and cancel the notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateGetOpWaitForUser::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Raise Protocol Error (which will cause a Reset and cancel the notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateGetOpWaitForUser::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Raise Protocol Error (which will cause a Reset and cancel the notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateGetOpWaitForUser::Abort(CObexServerStateMachine& aContext)
+	{
+	// Raise Protocol Error (which will cause a Reset and cancel the notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+	
+void TObexServerStateGetOpWaitForUser::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse /*aResponse*/)
+	{
+	// Raise Protocol Error (which will cause a Reset and cancel the notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateGetOpWaitForUser::Start(CObexServerStateMachine& /*aContext*/)
+	{
+	// Panic - trying to change interface during wait
+	IrOBEXUtil::Panic(EChangeInterfaceDuringWait);
+	}
+
+void TObexServerStateGetOpWaitForUser::Reset(CObexServerStateMachine& aContext)
+	{
+	// Cancel notification - if it has not already been activated
+	if (!aContext.IsCallBackActive())
+		{
+		aContext.Notification().CancelIndicationCallback();
+		}
+	aContext.CancelCallBack();
+	aContext.ChangeState(CObexServerStateMachine::EDisconnected);
+	}
+
+void TObexServerStateGetOpWaitForUser::RequestNotificationCompleted(CObexServerStateMachine& aContext, CObexBaseObject* aObject)
+	{
+	aContext.SetTransObject(aObject);
+	aContext.CallBack(TObexServerStateGetOpWaitForUser::ProcessNotification);
+	}
+
+void TObexServerStateGetOpWaitForUser::RequestNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse)
+	{
+	aContext.SetAppResponse(aAppResponse);
+	aContext.CallBack(TObexServerStateGetOpWaitForUser::ProcessErrorNotification);	
+	}
+
+/*static*/ TInt TObexServerStateGetOpWaitForUser::ProcessNotification(TAny* aPtr)
+	{
+	// Get hold of the Context and the returned object
+	CObexServerStateMachine& context = *static_cast<CObexServerStateMachine*>(aPtr);
+	
+	GETWAIT_LOG(_L8("Process notification"));
+	CObexBaseObject* object = context.TransObject();
+	
+	//Check and initialise object, move to GetOpSendObject
+	if (!object)
+		{
+		RespondAndEndOperation(context, ERespForbidden);
+		}
+	else if (object->InitSend(ERespContinue) != KErrNone)
+		{
+		RespondAndEndOperation(context, ERespInternalError);
+		}
+	else
+		{
+		//ConnectionID is compulsory if Target header was used at connection
+		if ( context.Owner().CheckObjectForConnectionId(*(context.SpecObject())))
+			{
+			context.ChangeState(CObexServerStateMachine::EGetOpSendObject);
+			}
+		else  //connectionID was incorrect or not received
+			{
+			context.Transport().Send(ERespServiceUnavailable); 
+			}
+		}
+	return KErrNone;
+	}
+
+/*static*/ TInt TObexServerStateGetOpWaitForUser::ProcessErrorNotification(TAny* aPtr)
+	{
+	// Get hold of the Context and the returned object
+	CObexServerStateMachine& context = *static_cast<CObexServerStateMachine*>(aPtr);
+	
+	RespondAndEndOperation(context, context.AppResponse());
+	
+	return KErrNone;
+	}
+
+TBool TObexServerStateGetOpWaitForUser::ValidResponse(TObexResponse aResponseCode)
+	{
+	return (aResponseCode>0 && aResponseCode<=255 &&  aResponseCode != ERespContinue && 
+	   aResponseCode != ERespSuccess  && aResponseCode != ERespCreated  && aResponseCode != ERespAccepted);  
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateObexConnecting.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,178 @@
+// 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 <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+OBEX Connecting State
+This state is entered during an OBEX connection attempt. The authentication state machine is
+invoked via ParseConnectPacket and PrepareConnect packet.
+A successful CONNECT will move the machine to Ready.
+A CONNECT requiring a user password will move the machine to WaitForUserPassword
+Other CONNECT results may stay in this state or move the machine to TransportConnected
+A DISCONNECT will be processed
+An ABORT will cause a Protocol Error
+Any other OBEX operation will be answered with an OBEX error code
+*/
+
+TObexServerStateObexConnecting::TObexServerStateObexConnecting()
+	{
+#ifdef __FLOG_ACTIVE
+	_LIT8(KName, "ObexConnecting");
+	iName = KName;
+#endif
+	}
+
+void TObexServerStateObexConnecting::Entry(CObexServerStateMachine& aContext)
+	{
+	// Reset the Connect State Machine
+	aContext.Owner().SetConnectState(CObex::EConnTransport);
+	// Chain on to Connect to process packet
+	Connect(aContext, aContext.LastReceivedPacket());
+	}
+
+void TObexServerStateObexConnecting::Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+	{
+	// Process connect packet
+	// This will return KErrNone if the packet is OK
+	//                  a positive number if an OBEX error should be returned to the Client
+	//				    a negative number if a Symbian error should be raised (as a Protocol Error)
+	TInt parseConnectResult = aContext.Owner().ParseConnectPacket(aPacket);
+	if (parseConnectResult == KErrNone)
+		{
+		FLOG(_L("OnPacketReceive ParseConnectPacket succesfull\r\n"));
+		aContext.Transport().SendPacket().Init(CObex::EOpConnect); 
+		// PrepareConnectPacket will check the present state and request
+		// Auth, or check Auth as necessary and will return:
+		//		An error & connect state set to EWaitForUserInput if a User Password is required  
+		//		No error and connect state set to EConnObex if the connection was successful
+		//		Connect state set to EConnTransport if there is an error packet to send back to the client
+		//		Other connect states will return a packet to send and stay in the current state
+		TInt err = aContext.Owner().PrepareConnectPacket(aContext.Transport().SendPacket());
+		if ((err == KErrNone)	|| (aContext.Owner().GetConnectState() == CObex::EConnTransport)
+								|| (aContext.Owner().GetConnectState() == CObex::EWaitForUserInput))
+			{
+			FLOG(_L("OnPacketReceive PrepareConnectPacket SUCCESS\r\n"));
+			// If not waiting for user input, send the resultant packet
+			if ( aContext.Owner().GetConnectState() != CObex::EWaitForUserInput )
+				{
+				aContext.Transport().SendPacket().SetFinal();
+				aContext.Transport().Send();
+				}
+			// Move this (operation) state machine according to result of authentication state machine
+			switch (aContext.Owner().GetConnectState())
+				{
+				case CObex::EConnTransport:
+					aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+					break;
+				case CObex::EConnObex:
+					aContext.ChangeState(CObexServerStateMachine::EReady);
+					break;
+				case CObex::EWaitForUserInput:
+					aContext.ChangeState(CObexServerStateMachine::EWaitForUserPassword);
+					break;
+				}
+			}
+		else 
+			{
+			FTRACE( if (err)
+						{
+						FPrint(_L("OnPacketReceive PrepareConnectPacket FAILED"));
+						}
+					else
+						{
+						FPrint(_L("OnPacketReceive PrepareConnectPacket OK but state is %d"), aContext.Owner().GetConnectState());
+						}
+					);
+			// Raising a Protocol Error will cause a Reset event resulting in a move to Disconnected.
+			// So any code after this call will potentially be executed in a different state.
+			aContext.Owner().Error(err);
+			}
+		}
+	else if (parseConnectResult > 0) // so it's an OBEX error code
+		{
+		FLOG(_L("OnPacketReceive ParseConnectPacket FAILED (OBEX error)\r\n"));
+		
+		aContext.Transport().SendPacket().Init(parseConnectResult); 
+		TInt rsp = aContext.Owner().PrepareErroredConnectPacket(aContext.Transport().SendPacket());
+		if (rsp == KErrNone)	
+   			{
+			aContext.Transport().SendPacket().SetFinal();
+			aContext.Transport().Send();
+			aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+			}			
+		else
+			{
+			aContext.Owner().Error(rsp);	
+			}
+		}
+	else // parseConnectResult < 0 so it's a Symbian error code
+		{
+		FLOG(_L("OnPacketReceive ParseConnectPacket FAILED (Symbian error)\r\n"));
+		// Raising a Protocol Error will cause a Reset event resulting in a move to Disconnected.
+		// So any code after this call will potentially be executed in a different state.
+		aContext.Owner().Error(KErrAbort);
+		}
+	}
+
+void TObexServerStateObexConnecting::Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+	{
+	// Process disconnect
+	PerformDisconnect(aContext, aPacket);
+	}
+
+void TObexServerStateObexConnecting::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Send ERespBadRequest and return to ETransportConnected
+	aContext.Transport().Send(ERespBadRequest);
+	aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+	}
+
+void TObexServerStateObexConnecting::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Send ERespConflict and return to ETransportConnected
+	aContext.Transport().Send(ERespConflict);
+	aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+	}
+
+void TObexServerStateObexConnecting::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Send ERespConflict and return to ETransportConnected
+	aContext.Transport().Send(ERespConflict);
+	aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+	}
+
+void TObexServerStateObexConnecting::Abort(CObexServerStateMachine& aContext)
+	{
+	// Send ERespSuccess
+	// Any other response would, according to the spec,
+	// require the Obex client to bring down the transport.
+	// Our attempt is to be resilient if an 'Abort'
+	// is sent erroneously whilst we are in this state.
+	aContext.Transport().Send(ERespSuccess);
+	aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+	}
+	
+void TObexServerStateObexConnecting::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse)
+	{
+	// Send the server applications response and return to Transport Connected
+	aContext.Transport().Send(aResponse);
+	aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStatePutOpFinal.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,169 @@
+// 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 <obex.h>
+#include <obex/internal/obexinternalheader.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+Final PUT Operation Receive State
+Waiting for reply from server app to an async notification PutCompleteIndication
+
+Any OBEX operation will cause a Protocol Error
+Chaging the MObexServerNotifyAsync via CObexServer::Start() will cause a Panic
+A Reset event (Protocol Error, Server Stop, Transport Down) will cancel the notification and move the machine to Disconnected
+The NotificationComplete event send the response back to the client and mvoe the state machine to Ready
+*/
+
+TObexServerStatePutOpFinal::TObexServerStatePutOpFinal()
+	{
+#ifdef __FLOG_ACTIVE
+	_LIT8(KName, "PutOpFinalPut");
+	iName = KName;
+#endif
+	}
+
+void TObexServerStatePutOpFinal::Entry(CObexServerStateMachine& aContext)
+	{
+	// Chain on to Put() to start receiving object
+	//return Put(aContext, aContext.LastReceivedPacket());
+	aContext.Notification().PutCompleteIndication();
+	}
+
+void TObexServerStatePutOpFinal::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStatePutOpFinal::Disconnect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStatePutOpFinal::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStatePutOpFinal::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStatePutOpFinal::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStatePutOpFinal::Abort(CObexServerStateMachine& aContext)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+	
+void TObexServerStatePutOpFinal::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse /*aResponse*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStatePutOpFinal::Start(CObexServerStateMachine& /*aContext*/)
+	{
+	// Panic - trying to change interface during wait
+	IrOBEXUtil::Panic(EChangeInterfaceDuringWait);
+	}
+
+// Utility function to handle the optional header set to send at the completion of the Put
+void TObexServerStatePutOpFinal::PrepareFinalResponseHeaderSet(CObexHeader* aHeader, CObexHeaderSet& aHeaderSet, CObexPacket& aPacket)
+	{
+	//	We have some additional headers to send, on a best effort
+	//	basis...
+	TObexInternalHeader intHeader;
+	aHeaderSet.First();
+	TBool insertedOK=ETrue;
+
+	while(insertedOK && (aHeaderSet.This(aHeader)==KErrNone))
+		{
+		switch(aHeader->Type())
+			{
+		case CObexHeader::EUnicode:
+			intHeader.Set(aHeader->HI(), aHeader->AsUnicode());
+			break;
+			
+		case CObexHeader::EByteSeq:
+			intHeader.Set(aHeader->HI(), (const_cast<TUint8*> ((aHeader->AsByteSeq()).Ptr())), (aHeader->AsByteSeq()).Size());
+			break;
+			
+		case CObexHeader::EByte:
+			intHeader.Set(aHeader->HI(), aHeader->AsByte());
+			break;
+			
+		case CObexHeader::EFourByte:
+			intHeader.Set(aHeader->HI(), aHeader->AsFourByte());
+			break;
+			}
+
+		insertedOK=aPacket.InsertData(intHeader); 
+							
+		(void)aHeaderSet.Next();
+		}
+	}
+	
+void TObexServerStatePutOpFinal::Reset(CObexServerStateMachine& aContext)
+	{
+	// Cancel notification - if it has not already been activated
+	if (!aContext.IsCallBackActive())
+		{
+		aContext.Notification().CancelIndicationCallback();
+		}
+	aContext.CancelCallBack();
+	aContext.ChangeState(CObexServerStateMachine::EDisconnected);
+	}
+	
+void TObexServerStatePutOpFinal::RequestCompleteNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse)
+	{
+	aContext.SetAppResponse(aAppResponse);
+	aContext.CallBack(TObexServerStatePutOpFinal::ProcessNotification);
+	}
+	
+TInt TObexServerStatePutOpFinal::ProcessNotification(TAny* aPtr)
+	{
+	CObexServerStateMachine& context = *static_cast<CObexServerStateMachine*>(aPtr);
+	
+	context.Transport().SendPacket().Init(context.AppResponse());
+	context.Transport().SendPacket().SetFinal();	//	Because it is
+	
+	// Check for additional headers to send
+	if(context.PutFinalResponseHeaderSet())
+		{
+		PrepareFinalResponseHeaderSet(	context.GetHeader(),
+						*(context.PutFinalResponseHeaderSet()),
+						context.Transport().SendPacket());
+		// delete the headers now they've been used
+		context.SetPutFinalResponseHeaderSet(NULL);
+		}
+	
+	context.Transport().Send();
+	context.ChangeState(CObexServerStateMachine::EReady);
+	
+	return KErrNone;
+	}
+
+TBool TObexServerStatePutOpFinal::ValidResponse(TObexResponse aResponseCode)
+	{
+	return (aResponseCode>0 && aResponseCode<=255 && aResponseCode != ERespContinue);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStatePutOpReceiveObject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#include <obex.h>
+#include <obex/internal/obexinternalheader.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+PUT Operation Receive State
+This state receive the object from the client and transfers to Ready once the exchange is finished
+A PUT, DISCONNECT or ABORT will be processed
+Any other OBEX operation will be answered with an OBEX error code
+*/
+
+TObexServerStatePutOpReceiveObject::TObexServerStatePutOpReceiveObject()
+	{
+#ifdef __FLOG_ACTIVE
+	_LIT8(KName, "PutOpReceiveObject");
+	iName = KName;
+#endif
+	}
+
+void TObexServerStatePutOpReceiveObject::Entry(CObexServerStateMachine& aContext)
+	{
+	// Chain on to Put() to start receiving object
+	Put(aContext, aContext.LastReceivedPacket());
+	}
+
+void TObexServerStatePutOpReceiveObject::Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+	{
+	// Process disconnect
+	PerformDisconnect(aContext, aPacket);
+	}
+
+void TObexServerStatePutOpReceiveObject::Put(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+	{
+	//Initialise 'err' to KErrNone:
+	//if ParseNextReceivePacket returns an error, we want 
+	//IrOBEXUtil::ObexResponse to return that error unchanged
+	//See: IrOBEXUtil::ObexResponse
+	TInt err = KErrNone; 
+
+	// Process Put packet into receive object
+	if(aContext.TransObject()->ParseNextReceivePacket(aPacket) == CObexBaseObject::EError 
+		||(err = aContext.Notification().PutPacketIndication()) != KErrNone)
+		{// Error in receive
+		aContext.Transport().Send(IrOBEXUtil::ObexResponse(err, aContext.TransObject()->GetLastError()));
+		aContext.Notification().ErrorIndication(KErrGeneral);
+		aContext.ChangeState(CObexServerStateMachine::EReady);
+		}
+
+	//ConnectionID is compulsory if Target header was used at connection
+	else if ( aContext.Owner().CheckObjectForConnectionId(*(aContext.TransObject())))
+		{
+		if(aPacket.IsFinal())
+			{// Successfully received
+			aContext.ChangeState(CObexServerStateMachine::EPutOpFinal);
+			}
+		else // not final packet
+			{
+			aContext.Transport().Send(ERespContinue);
+			}
+		}
+	else
+		{
+		aContext.Transport().Send(ERespServiceUnavailable); //connectionID was incorrect or not received
+		}
+	}
+
+
+void TObexServerStatePutOpReceiveObject::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Send ERespConflict and return to Ready
+	RespondAndEndOperation(aContext, ERespConflict);
+	}
+
+void TObexServerStatePutOpReceiveObject::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Send ERespConflict and return to Ready
+	RespondAndEndOperation(aContext, ERespConflict);
+	}
+
+void TObexServerStatePutOpReceiveObject::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Send ERespConflict and return to Ready
+	RespondAndEndOperation(aContext, ERespConflict);
+	}
+
+void TObexServerStatePutOpReceiveObject::Abort(CObexServerStateMachine& aContext)
+	{
+	// Send ERespSuccess and return to Ready
+	aContext.Notification().AbortIndication();
+	RespondAndEndOperation(aContext, ERespSuccess);
+	}
+	
+void TObexServerStatePutOpReceiveObject::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse)
+	{
+	// Send server app response and return to Ready
+	RespondAndEndOperation(aContext, aResponse);
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStatePutOpWaitForUser.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#include <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+PUT Operation Wait State
+This state issues the Put indication to the Application on entry and then waits for the response.
+
+Any OBEX operation will be cause a Protocol Error
+Chaging the MObexServerNotifyAsync via CObexServer::Start() will cause a Panic
+A Reset event (Protocol Error, Server Stop, Transport Down) will cancel the notification and move the machine to Disconnected
+The NotificationComplete event will queue a async one-shot to process the returned object, moving the machine to PutOpReceiveObject
+*/
+
+TObexServerStatePutOpWaitForUser::TObexServerStatePutOpWaitForUser()
+	{
+#ifdef __FLOG_ACTIVE
+	_LIT8(KName, "PutOpWaitForUser");
+	iName = KName;
+#endif
+	}
+
+void TObexServerStatePutOpWaitForUser::Entry(CObexServerStateMachine& aContext)
+	{
+	// Send notification to the Application
+	aContext.SetTransObject(NULL);
+	
+	aContext.Notification().PutRequestIndication();
+	}
+
+void TObexServerStatePutOpWaitForUser::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Raise Protocol Error (which will cause a Reset and cancel the notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStatePutOpWaitForUser::Disconnect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Raise Protocol Error (which will cause a Reset and cancel the notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStatePutOpWaitForUser::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Raise Protocol Error (which will cause a Reset and cancel the notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStatePutOpWaitForUser::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Raise Protocol Error (which will cause a Reset and cancel the notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStatePutOpWaitForUser::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Raise Protocol Error (which will cause a Reset and cancel the notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStatePutOpWaitForUser::Abort(CObexServerStateMachine& aContext)
+	{
+	// Raise Protocol Error (which will cause a Reset and cancel the notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+	
+void TObexServerStatePutOpWaitForUser::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse /*aResponse*/)
+	{
+	// Raise Protocol Error (which will cause a Reset and cancel the notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStatePutOpWaitForUser::Start(CObexServerStateMachine& /*aContext*/)
+	{
+	// Panic - trying to change interface during wait
+	IrOBEXUtil::Panic(EChangeInterfaceDuringWait);
+	}
+
+void TObexServerStatePutOpWaitForUser::Reset(CObexServerStateMachine& aContext)
+	{
+	// Cancel notification - if it has not already been activated
+	if (!aContext.IsCallBackActive())
+		{
+		aContext.Notification().CancelIndicationCallback();
+		}
+	aContext.CancelCallBack();
+	aContext.ChangeState(CObexServerStateMachine::EDisconnected);
+	}
+
+void TObexServerStatePutOpWaitForUser::RequestNotificationCompleted(CObexServerStateMachine& aContext, CObexBaseObject* aObject)
+	{
+	aContext.SetTransObject(aObject);
+	aContext.CallBack(TObexServerStatePutOpWaitForUser::ProcessNotification);
+	}
+
+void TObexServerStatePutOpWaitForUser::RequestNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse)
+	{
+	aContext.SetAppResponse(aAppResponse);
+	aContext.CallBack(TObexServerStatePutOpWaitForUser::ProcessErrorNotification);
+	}
+
+/*static*/ TInt TObexServerStatePutOpWaitForUser::ProcessNotification(TAny* aPtr)
+	{
+	// Get hold of the Context and the returned object
+	CObexServerStateMachine& context = *static_cast<CObexServerStateMachine*>(aPtr);
+	
+	CObexBaseObject* object = context.TransObject();
+	
+	//Check and initialise object, move to PutOpReceiveObject
+	if(!object)
+		{
+		RespondAndEndOperation(context, ERespForbidden);
+		}
+	else if (object->InitReceive() != KErrNone)
+		{
+		RespondAndEndOperation(context, ERespInternalError);
+		}
+	else
+		{
+		context.Owner().SetCurrentOperation(CObex::EOpPut);
+		context.ChangeState(CObexServerStateMachine::EPutOpReceiveObject);
+		}
+	
+	return KErrNone;
+	}
+
+/*static*/ TInt TObexServerStatePutOpWaitForUser::ProcessErrorNotification(TAny* aPtr)
+	{
+	// Get hold of the Context and the returned object
+	CObexServerStateMachine& context = *static_cast<CObexServerStateMachine*>(aPtr);
+	
+	RespondAndEndOperation(context, context.AppResponse());
+	
+	return KErrNone;
+	}
+
+TBool TObexServerStatePutOpWaitForUser::ValidResponse(TObexResponse aResponseCode)
+	{
+	return (aResponseCode>0 && aResponseCode<=255 &&  aResponseCode != ERespContinue && 
+	   aResponseCode != ERespSuccess  && aResponseCode != ERespCreated  && aResponseCode != ERespAccepted);  
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateReady.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,95 @@
+// 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 <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+OBEX Ready State
+This is the default state when there is an OBEX connection but no current operation.
+A CONNECT will be answered with an OBEX error code
+A GET will move the machine to GetOpReceiveSpecification
+A PUT will move the machine to PutOpWaitForUser
+A SETPATH will move the machine to SetPathOp
+A DISCONNECT or ABORT will be processed
+*/
+
+TObexServerStateReady::TObexServerStateReady()
+	{
+#ifdef __FLOG_ACTIVE
+	_LIT8(KName, "Ready");
+	iName = KName;
+#endif
+	}
+
+void TObexServerStateReady::Entry(CObexServerStateMachine& aContext)
+	{
+	aContext.Owner().SetCurrentOperation(CObex::EOpIdle);
+	}
+
+void TObexServerStateReady::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Send ERespConflict
+	aContext.Transport().Send(ERespConflict);
+	}
+
+void TObexServerStateReady::Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+	{
+	// Process disconnect
+	PerformDisconnect(aContext, aPacket);
+	}
+
+void TObexServerStateReady::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.ChangeState(CObexServerStateMachine::EPutOpWaitForUser);
+	}
+
+void TObexServerStateReady::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.ChangeState(CObexServerStateMachine::EGetOpReceiveSpecification);
+	}
+
+void TObexServerStateReady::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.ChangeState(CObexServerStateMachine::ESetPathOp);
+	}
+
+void TObexServerStateReady::Abort(CObexServerStateMachine& aContext)
+	{
+	// Send ERespSuccess
+	// Report that we're re-synced
+	aContext.Transport().Send(ERespSuccess);
+	}
+	
+void TObexServerStateReady::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse)
+	{
+	// Send response and remain in Ready state
+	aContext.Transport().Send(aResponse);
+	}
+
+
+void TObexServerStateReady::ReadActivityDetected(CObexServerStateMachine& aContext)
+	/*
+	Indicates that a new obex packet is being read. 
+	This should only need to be passed up to the user 
+	if we are in 'Ready' state.
+	*/
+	{
+	aContext.Owner().SignalReadActivity();
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateSetPathOp.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,162 @@
+// 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 <obex.h>
+#include <obex/internal/obexinternalheader.h>
+#include "obexserverstatemachine.h"
+#include "obexsetpathdata.h"
+
+/**
+@file
+@internalComponent
+
+SETPATH Operation State
+This state processes the SetPath operation, the SetPathIndication is asynchronous.
+So the state has to wait for RequestCompleteIndicationCallback before sending 
+response and transition to the ready state. 
+*/
+
+TObexServerStateSetPathOp::TObexServerStateSetPathOp()
+	{
+#ifdef __FLOG_ACTIVE
+	_LIT8(KName, "SetPathOp");
+	iName = KName;
+#endif
+	}
+
+void TObexServerStateSetPathOp::Entry(CObexServerStateMachine& aContext)
+	{
+	TObexSetPathData data;
+	TBool authChallengePresent = EFalse;
+	CObexPacket& aPacket = aContext.LastReceivedPacket();
+
+	if(!aPacket.ExtractData(data))
+		{
+		aContext.Transport().Send(ERespBadRequest);
+		aContext.ChangeState(CObexServerStateMachine::EReady);
+		return;
+		}
+	TInt packetSize = aPacket.PacketSize();
+	// Check Connection ID
+	if (aContext.Owner().CheckPacketForConnectionId(aPacket))
+		{
+		CObex::TSetPathInfo info(data);
+
+		// Search for any name headers
+		TObexInternalHeader header;
+		while(aPacket.ExtractData(header))
+			{
+			if(!info.iNamePresent && header.HI() == TObexInternalHeader::EName && header.GetHVText(info.iName) == KErrNone)
+				{
+				info.iNamePresent = ETrue;
+				}
+			if (header.HI() == TObexInternalHeader::EAuthChallenge)
+				{
+				authChallengePresent = ETrue;	
+				}
+			}
+		if (authChallengePresent) // Auth challenge is present, send unauthorized response
+			{
+			aContext.Transport().Send(ERespUnauthorized);
+			aContext.ChangeState(CObexServerStateMachine::EReady);
+			}
+		else 
+			{
+			//There is no need to add a new state to wait for the RequestCompleteIndicationCallback because there is 
+			//no other actions required for SetPath. So just wait in this state.
+			aContext.Notification().SetPathIndication(info, KNullDesC8);
+			}
+		
+		}
+	else //bad or missing ConnectionID
+		{
+		aContext.Transport().Send(ERespServiceUnavailable);
+		aContext.ChangeState(CObexServerStateMachine::EReady);
+		}
+	}
+
+void TObexServerStateSetPathOp::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateSetPathOp::Disconnect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateSetPathOp::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateSetPathOp::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateSetPathOp::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateSetPathOp::Abort(CObexServerStateMachine& aContext)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+	
+void TObexServerStateSetPathOp::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse /*aResponse*/)
+	{
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateSetPathOp::Start(CObexServerStateMachine& /*aContext*/)
+	{
+	// Panic - trying to change interface during wait
+	IrOBEXUtil::Panic(EChangeInterfaceDuringWait);
+	}
+
+void TObexServerStateSetPathOp::Reset(CObexServerStateMachine& aContext)
+	{
+	// Cancel notification - if it has not already been activated
+	if (!aContext.IsCallBackActive())
+		{
+		aContext.Notification().CancelIndicationCallback();
+		}
+	aContext.CancelCallBack();
+	aContext.ChangeState(CObexServerStateMachine::EDisconnected);
+	}
+
+void TObexServerStateSetPathOp::RequestCompleteNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse)
+	{
+	aContext.SetAppResponse(aAppResponse);
+	aContext.CallBack(TObexServerStateSetPathOp::ProcessNotification);
+	}
+	
+TInt TObexServerStateSetPathOp::ProcessNotification(TAny* aPtr)
+	{
+	CObexServerStateMachine& context = *static_cast<CObexServerStateMachine*>(aPtr);
+
+	context.Transport().Send(context.AppResponse());
+	context.ChangeState(CObexServerStateMachine::EReady);
+	
+	return KErrNone;
+	}
+
+TBool TObexServerStateSetPathOp::ValidResponse(TObexResponse aResponseCode)
+	{
+	return (aResponseCode>0 && aResponseCode<=255 && aResponseCode != ERespContinue);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateTransportConnected.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#include <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+Transport Connected State
+This is the state where there is a transport connect, but no OBEX connection.
+A CONNECT will move the machine to ObexConnecting
+A DISCONNECT will be processed
+An ABORT will cause a Protocol Error
+Any other OBEX operation will be answered with an OBEX error code
+*/
+
+TObexServerStateTransportConnected::TObexServerStateTransportConnected()
+	{
+#ifdef __FLOG_ACTIVE
+	_LIT8(KName, "TransportConnected");
+	iName = KName;
+#endif
+	}
+
+void TObexServerStateTransportConnected::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	aContext.ChangeState(CObexServerStateMachine::EObexConnecting);
+	}
+
+void TObexServerStateTransportConnected::Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+	{
+	// Process disconnect
+	PerformDisconnect(aContext, aPacket);
+	}
+
+void TObexServerStateTransportConnected::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Send ERespBadRequest
+	aContext.Transport().Send(ERespBadRequest);
+	}
+
+void TObexServerStateTransportConnected::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Send ERespConflict
+	aContext.Transport().Send(ERespConflict);
+	}
+
+void TObexServerStateTransportConnected::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Send ERespConflict
+	aContext.Transport().Send(ERespConflict);
+	}
+
+void TObexServerStateTransportConnected::Abort(CObexServerStateMachine& aContext)
+	{
+	// Send ERespSuccess
+	// Any other response would, according to the spec,
+	// require the Obex client to bring down the transport.
+	// Our attempt is to be resilient if an 'Abort'
+	// is sent erroneously whilst we are in this state.
+	aContext.Transport().Send(ERespSuccess);
+	}
+
+void TObexServerStateTransportConnected::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse)
+	{
+	aContext.Transport().Send(aResponse);
+	// no need to change state, it's just as if the packet never arrived.
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateWaitForUserPassword.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,92 @@
+// 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 <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+CONNECT Operation Wait State
+This waits for the authentication state machine to receive a password from the user (CObexServer::UserPasswordL) which is indicated by ConnectionComplete
+
+Any OBEX operation will be cause a Protocol Error (which will then cause a reset event)
+Changing the MObexServerNotifyAsync via CObexServer::Start() will cause a Panic
+A Reset event (Protocol Error, Server Stop, Transport Down) will cause a transition to Disconnected
+*/
+
+TObexServerStateWaitForUserPassword::TObexServerStateWaitForUserPassword()
+	{
+#ifdef __FLOG_ACTIVE
+	_LIT8(KName, "WaitForUserPassword");
+	iName = KName;
+#endif
+	}
+
+void TObexServerStateWaitForUserPassword::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Raise Protocol Error (no way to cancel the password request notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateWaitForUserPassword::Disconnect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Raise Protocol Error (no way to cancel the password request notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateWaitForUserPassword::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Raise Protocol Error (no way to cancel the password request notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateWaitForUserPassword::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Raise Protocol Error (no way to cancel the password request notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateWaitForUserPassword::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+	{
+	// Raise Protocol Error (no way to cancel the password request notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateWaitForUserPassword::Abort(CObexServerStateMachine& aContext)
+	{
+	// Raise Protocol Error (no way to cancel the password request notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+	
+void TObexServerStateWaitForUserPassword::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse /*aResponse*/)
+	{
+	// Raise Protocol Error (no way to cancel the password request notification)
+	aContext.Owner().Error(KErrIrObexPacketDuringWait);
+	}
+
+void TObexServerStateWaitForUserPassword::Start(CObexServerStateMachine& /*aContext*/)
+	{
+	// Panic - trying to change interface during wait
+	IrOBEXUtil::Panic(EChangeInterfaceDuringWait);
+	}
+
+void TObexServerStateWaitForUserPassword::ConnectionComplete(CObexServerStateMachine& aContext)
+	{
+	// Move to Ready
+	aContext.ChangeState(CObexServerStateMachine::EReady);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/authentication.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,97 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+*/
+
+#include <hash.h>
+#include <e32math.h>
+#include <obex.h>
+#include "authentication.h"
+
+_LIT8(KColonCharacter, ":");
+
+CObexAuthenticator* CObexAuthenticator::NewL()
+	{
+	CObexAuthenticator* s = new(ELeave) CObexAuthenticator;
+	CleanupStack::PushL(s);
+	s->ConstructL();
+	CleanupStack::Pop();
+	return s;
+	}
+
+void CObexAuthenticator::ConstructL()
+	{
+	iMD5 = CMD5::NewL();
+	}
+
+CObexAuthenticator::CObexAuthenticator()
+	{
+	TTime time;
+	time.UniversalTime();
+	iSeed = time.Int64();
+	}
+
+CObexAuthenticator::~CObexAuthenticator()
+	{
+	delete iMD5;
+	}
+
+TInt CObexAuthenticator::GenerateNonce(TDes8& aNonce)
+	{
+	TTime time;
+	time.UniversalTime();
+
+	TInt64 randomNumber = Math::Rand(iSeed);
+	randomNumber <<= 32;
+	randomNumber += Math::Rand(iSeed);
+
+	TBuf8<33> key;
+	key.Zero();
+	key.AppendNum(time.Int64(), EHex);
+	key.Append(_L8(":"));
+	key.AppendNum(randomNumber, EHex);
+	
+	iMD5->Reset();
+	aNonce.Append(iMD5->Hash(key));
+	return KErrNone;
+	}
+
+void CObexAuthenticator::GenerateResponseL(const TDesC8& aPasswd, const TNonce& aNonce, TRequestDigest& aRequestDigest)
+	{
+	//work out the length of buffer we need
+	TInt buflen = aNonce.Length() + KColonCharacter().Length() + aPasswd.Length();
+	HBufC8* buf = HBufC8::NewLC(buflen);
+	TPtr8 ptr = buf->Des();
+	ptr.Zero();
+	ptr.Append(aNonce);
+	ptr.Append(KColonCharacter);
+	ptr.Append(aPasswd);
+	iMD5->Reset();
+	aRequestDigest.Append(iMD5->Hash(*buf));
+
+	CleanupStack::PopAndDestroy();//buf
+	}
+
+void CObexAuthenticator::ChallengeResponseL(const TDesC8& aPasswd, const TNonce& aNonce, const TRequestDigest& aRequestDigest)
+	{
+	TRequestDigest digest;
+	digest.Zero();
+	GenerateResponseL(aPasswd, aNonce, digest);
+	if (digest != aRequestDigest)
+		User::Leave(KErrAccessDenied);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexasyncfilewriter.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,280 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+*/
+
+#include <f32file.h>
+#include "obexasyncfilewriter.h"
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+//
+// Panic category for CObexAsyncFileWriter
+//
+_LIT(KObexAsyncFileWriterPanic, "Obex-AFW");
+
+/**
+Panic codes for CObexAsyncFileWriter
+
+@internalComponent
+@released
+*/
+enum TAsyncObexFileWriterPanic
+	{
+	/** Null buffer pointer */
+	ENullBufferPointer
+	};
+
+//
+// Implementation of CObexAsyncFileWriter
+//
+
+/**
+Factory function
+
+Note that we return a pointer to the interface class, so
+that this class can only be used through this interface.
+This class in an implementation of a strategy as part of
+a Strategy pattern.  CObexSyncFileWriter provides an
+alternative strategy implementation, with CObexBufObject
+as the context for these strategies.
+
+@see MObexFileWriter
+@see CObexSyncFileWriter
+@see CObexBufObject
+
+@internalComponent
+@released
+
+@param aFile The file we're writing to
+@return An MObexFileWriter for writing to file
+*/
+MObexFileWriter* CObexAsyncFileWriter::NewL(RFile& aFile)
+	{
+	CObexAsyncFileWriter* self = new(ELeave) CObexAsyncFileWriter(aFile);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+Constructor
+
+@internalComponent
+@released
+
+@param aFile The file we're writing to
+*/
+CObexAsyncFileWriter::CObexAsyncFileWriter(RFile& aFile)
+	: CActive(EPriorityStandard), iFile(aFile), iBufPtr(NULL, 0)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+/**
+2nd phase constructor
+
+@internalComponent
+@released
+*/	
+void CObexAsyncFileWriter::ConstructL()
+	{
+	}
+
+/**
+AO cancellation
+
+@internalComponent
+@released
+*/
+void CObexAsyncFileWriter::DoCancel()
+	{
+	iFile.Flush();
+	}
+
+/**
+AO request completion
+
+@internalComponent
+@released
+*/
+void CObexAsyncFileWriter::RunL()
+	{
+	// Just ignore completions; the status is picked up next time
+	// a service function is called
+	}
+
+/**
+Normal asynchronous write to file
+
+@internalComponent
+@released
+
+@param aPos The file position
+@param aBuf The buffer we're to write. We use this buffer by copying the pointer
+            and return the buffer we previously wrote to the caller by updating
+            the pointer.  If an error occurs, the buffers are not swapped and
+            the pointer is not updated.  Note that this class never owns any
+            buffers and that passing a buffer to this function does not imply a
+            transfer of ownership.
+@return Symbian OS error code
+*/
+TInt CObexAsyncFileWriter::Write(TInt aPos, CBufBase*& aBuf)
+	{
+	__ASSERT_ALWAYS(aBuf, PANIC(KObexAsyncFileWriterPanic, ENullBufferPointer));
+
+	// If last write to file has not completed...
+	if (IsActive())
+		{
+		// wait for it to complete
+		User::WaitForRequest(iStatus);
+		
+		// if we had an error on the last write
+		if (iStatus.Int())
+			{
+			// Signal ourselves again with the error
+			TRequestStatus* status = &iStatus;
+			User::RequestComplete(status, iStatus.Int());
+			// and then de-activate ourselves by cancelling
+			Cancel();
+			}
+		// if we didn't have an error on the last write,
+		// we've consumed the completion of the write and
+		// hence are still active
+		}
+
+	if (!iStatus.Int())
+	// if the last write completed successfully...
+		{
+		// Swap our and the caller's pointers to show we
+		// have swapped which buffers we are using.  Note
+		// that the ownership of the buffers is not changed
+		// by this and the caller must deallocate any buffers
+		// it owns which are passed to this function.
+		CBufBase* buf = iBuffer;
+		iBuffer = aBuf;
+		aBuf = buf;
+
+		// Set up the descriptor to be passed to the file write
+		iBufPtr.Set(iBuffer->Ptr(0));
+
+		// We'll need to be active to service another write
+		if (!IsActive())
+			{
+			SetActive();
+			}
+
+		// kick off writing the next block
+		iFile.Write(aPos, iBufPtr, iStatus);
+
+		// and we're happy...
+		return KErrNone;
+		}
+	else
+	// the last write did not complete successfully
+		{
+		// Signal Obex error
+		return iStatus.Int();
+		}
+
+	}
+	
+/**
+Final, synchronous write to file
+
+@internalComponent
+@released
+
+@param aPos The file position
+@param aBuf The buffer we're to write. We use this buffer by copying the pointer
+            and return the buffer we previously wrote to the caller by updating
+            the pointer.  If an error occurs, the buffers are not swapped and
+            the pointer is not updated.  Note that this class never owns any
+            buffers and that passing a buffer to this function does not imply a
+            transfer of ownership.
+@param aLength The amount of the buffer to write
+@return Symbian OS error code
+*/
+TInt CObexAsyncFileWriter::FinalWrite(TInt aPos, CBufBase*& aBuf, TInt aLength)
+	{
+	__ASSERT_ALWAYS(aBuf, PANIC(KObexAsyncFileWriterPanic, ENullBufferPointer));
+
+	// If last write to file has not completed...
+	if (IsActive())
+		{
+		// wait for it to complete
+		User::WaitForRequest(iStatus);
+		
+		// Signal ourselves again with the request status
+		TRequestStatus* status = &iStatus;
+		User::RequestComplete(status, iStatus.Int());
+
+		// and then de-activate ourselves by cancelling
+		Cancel();
+		}
+
+	// if the last write completed successfully...
+	if (!iStatus.Int())
+		{
+		// Swap our and the caller's pointers to show we
+		// have swapped which buffers we are using.  Note
+		// that the ownership of the buffers is not changed
+		// by this and the caller must deallocate any buffers
+		// it owns which are passed to this function.
+		CBufBase* buf = iBuffer;
+		iBuffer = aBuf;
+		aBuf = buf;
+
+		// Set up the descriptor to be passed to the file write
+		iBufPtr.Set(iBuffer->Ptr(0));
+		iBufPtr.SetLength(aLength);
+		
+		// write the final block and return the error
+		TInt err = iFile.Write(aPos, iBufPtr);
+		if (err == KErrNone)
+			{
+			//flush the buffer, commit the write
+			return iFile.Flush();
+			}
+		else
+			{
+			return err;
+			}
+		}
+	else
+	// the last write did not complete successfully
+		{	
+		// Signal Obex error
+		return iStatus.Int();
+		}
+	}
+
+/**
+Destructor
+
+@internalComponent
+@released
+*/
+CObexAsyncFileWriter::~CObexAsyncFileWriter()
+	{
+	Cancel();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexauthchallengehandler.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+ @file
+ @publishedAll
+*/
+
+#include <obexbase.h>
+
+/**
+This virtual function allows the M- classes to be extended in future in a binary
+compatible way by providing a method that clients can override in future to
+allow extra callbacks to be made via aObject.
+*/	
+EXPORT_C void MObexAuthChallengeHandler::MOACH_ExtensionInterfaceL(TUid /*aInterface*/, void*& aObject)
+	{
+	aObject = NULL;
+	}
+
+// EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexclient.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1486 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+*/
+
+#include <charconv.h>
+#include <utf.h>
+#include <obex.h>
+#include <obextransportinfo.h>
+#include <obex/transport/obextransportcontrollerbase.h>
+#include <obex/internal/obextransportconstants.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obex/internal/obexpacket.h>
+#include "logger.h"
+#include "obexsetpathdata.h"
+#include "OBEXUTIL.H"
+#include "obexheaderutil.h"
+#include "authentication.h"
+#include "obexpacketsignaller.h"
+#include "obexpackettimer.h"
+#include "obexnotifyhandlerclient.h"
+#include "obexerrorengine.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+// Constant used to identify if the last received response code field
+// has been populated (i.e., if the first response has been received
+// from the OBEX server).  The response code field is only 7 bits (+ the
+// 'final bit') so the use of this 16 bit number will ensure the value
+// for KUnpopulatedResponseCode never overlaps with an actual code.
+const static TUint16 KUnpopulatedResponseCode = 0xffff;
+
+// For debug builds check that when an underlying error is set
+// it has not already been set since the start of the client operation
+// and check that a last error has been set when the operation completes.
+#define SET_LAST_ERROR(_error) __ASSERT_DEBUG(!iIsLastErrorSet, IrOBEXUtil::Fault(ELastErrorSetTwice)); iErrorEngine->SetLastError(CObexErrorEngine::_error); iIsLastErrorSet = ETrue
+#define CHECK_LAST_ERROR_IS_SET __ASSERT_DEBUG(iIsLastErrorSet, IrOBEXUtil::Fault(ELastErrorNotSet)); iIsLastErrorSet = EFalse
+
+
+// Constructor - set initial values
+CObexClient::CObexClient() : CObex()
+	{
+	iCurrentOperation = EOpIdle;
+	iConnectionID = KConnIDInvalid;
+	iLastReceivedResponseOpcode = static_cast<TObexResponse>(KUnpopulatedResponseCode);
+	}
+
+void CObexClient::ConstructL(TObexTransportInfo& aObexTransportInfo)
+	{
+	CObex::ConstructL(aObexTransportInfo);
+	iNotifyHandler = new(ELeave)CObexNotifyHandlerClient(*this);
+	iTransportController->SetOwner(*iNotifyHandler);
+
+	//	iHeaderSet is used to store headers received in Put Response
+	iHeaderSet = CObexHeaderSet::NewL();
+	iHeader = CObexHeader::NewL();
+	iPacketProcessSignaller = CObexPacketSignaller::NewL();
+	iErrorEngine = CObexErrorEngine::NewL();
+	iPacketTimer = CObexPacketTimer::NewL(*this);
+	}
+
+/** Destructor. 
+	
+@publishedAll
+@released
+*/
+EXPORT_C CObexClient::~CObexClient()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	Error(KErrCompletion);
+	delete iHeader;
+	delete iHeaderSet;
+	delete iPacketProcessSignaller;
+	delete iNotifyHandler;
+	delete iErrorEngine;
+	delete iPacketTimer;
+	}
+
+/** A call back from the the service with the password required for use with generating 
+the challenge response. 
+
+@param aPassword Password
+
+@leave KErrNotReady if this function is not called from a MObexAuthChallengeHandler::GetUserPasswordL callback.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::UserPasswordL(const TDesC& aPassword)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	//now have a password, get a nonce, and get it hashed then reply
+	FLOG(_L("CObexClient::UserPasswordL\n\r"));
+	if (GetConnectState() == EWaitForUserInput)
+		{
+		PrepareChallResponseL( aPassword); 
+
+		TObexInternalHeader hdr;
+		hdr.Set(TObexInternalHeader::EAuthResponse, CONST_CAST(TUint8*, iOutgoingChallResp.Ptr()), iOutgoingChallResp.Size());
+		FLOG(_L("CObexClient::UserPasswordL EAuth heaqder added\n\r")); 
+		if(iTransportController->SendPacket().InsertData(hdr))
+			{
+			SetConnectState(EWaitForFinalResponse);
+			iTransportController->SendPacket().SetFinal();
+			SendRequestPacket();
+			FLOG(_L("CObexClient::UserPasswordL packet sent\n\r")); 
+
+			}
+		else
+			{
+			LEAVEIFERRORL(KErrGeneral);
+			}
+		}
+	else
+		{
+		LEAVEIFERRORL(KErrNotReady);
+		}
+	}
+
+/** Allocates and constructs a new OBEX client object.
+
+The received protocol information object, aObexProtocolInfoPtr, specifies the transport protocol to use:
+For the standard transports the following are used, TObexIrProtocolInfo for IrDA, TObexBluetoothProtocolInfo 
+for Bluetooth, TObexUsbProtocolInfo for USB.
+
+@param aObexProtocolInfoPtr Protocol information object describing the transport to use
+@return New OBEX client object 
+	
+@publishedAll
+@released
+*/
+EXPORT_C CObexClient* CObexClient::NewL(TObexProtocolInfo& aObexProtocolInfoPtr)
+	{
+	LOG_LINE
+	LOG_STATIC_FUNC_ENTRY
+
+	TObexProtocolPolicy defaultProtocolPolicy;	// no packet sizing policy specified, so use default	
+	TObexTransportInfo*  transportInfo = IrOBEXUtil::CreateTransportInfoL(aObexProtocolInfoPtr, defaultProtocolPolicy);
+	CleanupStack::PushL(transportInfo);
+	CObexClient* client = CObexClient::NewL(*transportInfo);
+	CleanupStack::PopAndDestroy(transportInfo);
+	return client;
+	}
+
+/** Allocates and constructs a new OBEX client object with packet sizing information.
+
+The received protocol information object, aObexProtocolInfoPtr, specifies the transport protocol to use:
+For the standard transports the following are used, TObexIrProtocolInfo for IrDA, TObexBluetoothProtocolInfo 
+for Bluetooth, TObexUsbProtocolInfo for USB.
+
+The aObexProtocolPolicy parameter specifies the packet sizing policy for this OBEX object.
+
+@param aObexProtocolInfoPtr Protocol information object describing the transport to use
+@param aObexProtocolPolicy Protocol policy object specifying the packet sizes to use
+@return New OBEX client object 
+	
+@publishedAll
+@released
+*/
+EXPORT_C  CObexClient* CObexClient::NewL(TObexProtocolInfo& aObexProtocolInfoPtr, TObexProtocolPolicy& aObexProtocolPolicy)
+	{
+	LOG_LINE
+	LOG_STATIC_FUNC_ENTRY
+
+	TObexTransportInfo*  transportInfo = IrOBEXUtil::CreateTransportInfoL(aObexProtocolInfoPtr, aObexProtocolPolicy);
+	CleanupStack::PushL(transportInfo);
+	CObexClient* client = CObexClient::NewL(*transportInfo);
+	CleanupStack::PopAndDestroy(transportInfo);
+	return client;
+	}
+
+/** Allocates and constructs a new OBEX client object with packet sizing information.
+
+The received transport information object, aObexTransportInfo, specifies the transport protocol packet sizes to use:
+For the standard transports the following are used, TObexIrProtocolInfo for IrDA, TObexBluetoothProtocolInfo 
+for Bluetooth, TObexUsbProtocolInfo for USB.
+
+@param aObexTransportInfo  Transport information object describing the transport and packet sizes to use
+@return New OBEX client object 
+
+@capability WriteDeviceData If the TObexIrV3TransportInfo is passed as the argument
+                            and the associated name is valid.
+	
+@publishedAll
+@released
+*/
+EXPORT_C  CObexClient* CObexClient::NewL(TObexTransportInfo& aObexTransportInfo)
+	{
+	LOG_LINE
+	LOG_STATIC_FUNC_ENTRY
+
+	CObexClient* self = new(ELeave) CObexClient();
+	CleanupStack::PushL(self);
+	self->ConstructL(aObexTransportInfo);
+	CleanupStack::Pop(self);
+	return(self);
+	}
+
+/** OBEX CONNECT operation to any available remote machine, specifying an object 
+to pass.
+
+@param aObject OBEX object to pass to the remote machine
+@param aStatus Asynchronous status word. On completion, KErrNone if it was 
+successful, or a system-wide error code 	
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::Connect(CObexBaseObject& aObject, TRequestStatus& aStatus)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if(!AlreadyActive(aStatus))
+		{
+		FLOG(_L("CObexClient::Connect no password but some header data\r\n"));
+		EmptyHeaderSet();
+		iChallenge = EFalse;
+		OBEX_TRAP(Error, ClientCommandL(EOpConnect, static_cast<TAny*>(&aObject), aStatus));
+		}
+	}
+
+/** OBEX CONNECT operation to any available remote machine, specifying an object 
+to pass and a password.
+
+@param aObject OBEX object to pass to the remote machine
+@param aPassword Password to access remote machine
+@param aStatus Asynchronous status word. On completion, KErrNone if it was 
+successful, or a system-wide error code 
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::ConnectL(CObexBaseObject& aObject, const TDesC& aPassword, 
+								   TRequestStatus& aStatus)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if(!AlreadyActive(aStatus))
+		{
+		FLOG(_L("CObexClient::Connect with password and some header info\r\n"));
+		EmptyHeaderSet();
+		delete iChallPassword;
+		iChallPassword = NULL;
+		iChallPassword = HBufC8::NewL(aPassword.Size());
+		TPtr8 ptr = iChallPassword->Des();
+		CnvUtfConverter::ConvertFromUnicodeToUtf8(ptr, aPassword);
+		iChallenge = ETrue;
+		OBEX_TRAP(Error, ClientCommandL(EOpConnect, static_cast<TAny*>(&aObject), aStatus));
+		}
+	}
+
+
+/** OBEX CONNECT operation to any available remote machine, specifying a password.
+
+@param aPassword Password to access remote machine
+@param aStatus On completion, KErrNone if it was successful, or a system-wide 
+error code 
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::ConnectL(const TDesC& aPassword, TRequestStatus& aStatus)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if(!AlreadyActive(aStatus))
+		{
+		FLOG(_L("CObexClient::Connect with password but no header info\r\n"));
+		EmptyHeaderSet();
+		delete iChallPassword;
+		iChallPassword = NULL;
+		iChallPassword = HBufC8::NewL(aPassword.Length());
+		TPtr8 ptr = iChallPassword->Des();
+		CnvUtfConverter::ConvertFromUnicodeToUtf8(ptr, aPassword);
+		iChallenge = ETrue;
+		OBEX_TRAP(Error, ClientCommandL(EOpConnect, NULL, aStatus));
+		}
+	}
+
+/** OBEX CONNECT operation to any available remote machine.
+
+@param aStatus Asynchronous status word. On completion, KErrNone if it was 
+successful, or a system-wide error code 
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::Connect(TRequestStatus& aStatus)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if(!AlreadyActive(aStatus))
+		{
+		FLOG(_L("\tno password no header"));
+		EmptyHeaderSet();
+		iChallenge = EFalse;
+		OBEX_TRAP(Error, ClientCommandL(EOpConnect, NULL, aStatus));
+		}
+	}
+
+/** OBEX DISCONNECT operation.
+
+This terminates the OBEX connection, and closes the transport on receiving 
+any response from the server. 
+
+@param aStatus Asynchronous status word. On completion, KErrNone on normal 
+disconnection, or KErrDisconnected if the server dropped the transport before 
+sending an OBEX response (which is valid behaviour). 
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::Disconnect(TRequestStatus& aStatus)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if(!AlreadyActive(aStatus))
+		{
+		FLOG(_L("CObexClient::Disconnect\r\n"));
+		EmptyHeaderSet();
+		OBEX_TRAP (Error, ClientCommandL(EOpDisconnect, NULL, aStatus));
+		}
+	}
+
+/** OBEX PUT operation.
+
+Any valid header that is also present in aObject’s header mask will be sent 
+to the server, along with the object body specified by the implementation 
+of aObject. 
+
+@param aObject OBEX object to put
+@param aStatus Asynchronous status word. On completion, KErrNone if the server 
+accepted the object and received it fully, or the appropriate file error if 
+the data file could not be opened 
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::Put(CObexBaseObject& aObject, TRequestStatus& aStatus)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if(!AlreadyActive(aStatus))
+		{
+		FLOG(_L("\tnot already active"));
+		EmptyHeaderSet();
+		OBEX_TRAP(Error, ClientCommandL(EOpPut, static_cast<TAny*>(&aObject), aStatus));
+		}
+	}
+
+/** OBEX GET operation.
+
+The caller specifies in aObject the headers to send to the server to specify 
+the object to get: normally just a name is expected. If the server can serve 
+the request, the object it returns will be loaded into aObject on completion. 
+All headers returned by the server that are also allowed by the object’s 
+header mask will be loaded into the relevant attributes of aObject. Any object 
+body is stored according to the implementation type of the CObexBaseObject 
+passed.
+
+@param aObject OBEX object to get; on completion, the retrieved object
+@param aStatus Asynchronous status word. On completion, KErrNone if the server 
+passed back an OBEX object, or the appropriate file error if the data file 
+could not be opened 
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::Get(CObexBaseObject& aObject, TRequestStatus& aStatus)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if(!AlreadyActive(aStatus))
+		{
+		FLOG(_L("CObexClient::Get\r\n"));
+		EmptyHeaderSet();
+		OBEX_TRAP(Error, ClientCommandL(EOpGet, static_cast<TAny*>(&aObject), aStatus));
+		}
+	}
+
+/** OBEX SETPATH operation.
+
+This changes the remote device's current path. 
+
+@param aPathInfo Information to send in the SETPATH command. If you do not 
+which to send a name, make sure CObex::TSetPathInfo::iNamePresent is set to 
+false.
+@param aStatus Asynchronous status word. On completion, KErrNone if successful, 
+or a system-wide error code 
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::SetPath(TSetPathInfo& aPathInfo, TRequestStatus& aStatus)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if(!AlreadyActive(aStatus))
+		{
+		FLOG(_L("CObexClient::SetPath\r\n"));
+		EmptyHeaderSet();
+		OBEX_TRAP(Error, ClientCommandL(EOpSetPath, static_cast<TAny*>(&aPathInfo), aStatus));
+		}
+	}
+
+/** OBEX ABORT operation.
+
+The function sends the OBEX abort command to the remote machine if a multi-packet 
+operation (i.e. PUT or GET) is in progress. An operation in progress will 
+complete with KErrAbort. 
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::Abort()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if(iPendingRequest &&(iCurrentOperation == EOpPut 
+							|| iCurrentOperation == EOpGet || iCurrentOperation == EOpGetResponse))
+		{
+		// We have two phase abort, async. abort request, followed by async. response
+		// To achive this without extra members we use extra operations in TOperation
+		// EOpAbortNoFBit for the asynchronous request
+		// EOpAbort for waiting for the response
+		iCurrentOperation = EOpAbortNoFBit;
+		}
+	}
+
+/**
+This function can be called following the successful completion of a Put,
+and will return a reference to a CObexHeaderSet containing all the headers
+that were contained in the final Put response packet returned from the 
+peer Obex server.
+
+The headers in the header set will be deleted by any subsequent call to 
+CObexClient functions that trigger Obex commands (ie. Connect, Disconnect, 
+Put, Get, SetPath).
+
+The reference should not be retained beyond the end of the lifetime of the
+CObexClient object.
+
+@publishedAll
+@released
+
+@return const reference to a Headerset containing headers returned in final
+Put response packet.
+*/
+EXPORT_C const CObexHeaderSet& CObexClient::GetPutFinalResponseHeaders()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return *iHeaderSet;
+	}
+
+/** Sets a final packet observer.
+
+This replaces any previous observer.  The observer will receive a callback
+when a final packet for a put or get request begins to be sent and 
+another when the send completes.  Although the start and finish callbacks
+are guaranteed to be in order, no guarantees are made about the ordering
+with respect to the completion of the put or get request.
+
+This does not transfer ownership.
+
+@publishedAll
+@released
+@param aObserver The observer to receive packet process events.  This may
+				 be NULL.
+*/
+EXPORT_C void CObexClient::SetFinalPacketObserver(MObexFinalPacketObserver* aObserver)
+	{
+	iPacketProcessSignaller->SetFinalPacketObserver(aObserver);
+	}
+
+/** Get last server response code
+This method returns the last received OBEX response code.
+The method must not be called prior to a response notification being received by the
+client application.  If the method is called a panic will be raised. 
+
+@return The last received OBEX response code.
+@panic ENoResponseCodeToReturn   Panics if the method is called prior to a response being received from the OBEX server.  
+@publishedAll
+@released
+*/
+EXPORT_C TObexResponse CObexClient::LastServerResponseCode() const
+	{	
+	LOG_LINE
+	LOG_FUNC
+	// If the last received response code has not been set (i.e., no response has been received) then panic
+	// the client.
+	__ASSERT_ALWAYS(iLastReceivedResponseOpcode != KUnpopulatedResponseCode, IrOBEXUtil::Panic(ENoResponseCodeToReturn));
+	return iLastReceivedResponseOpcode;
+	}
+
+/** Sets the Command Idle Time-out.
+
+This function sets the timer period to be observed during the progress of
+all OBEX commands. If the OBEX server does not respond within the set period
+the current OBEX command will be completed with an error of KErrIrObexRespTimedOut
+and the transport will be disconnected. 
+
+Setting a time-out value of 0, all OBEX commands will be allowed to continue
+indefinitely.
+
+@param aTimeOut The time-out period in Microseconds.
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::SetCommandTimeOut(TTimeIntervalMicroSeconds32 aTimeOut)
+	{
+	LOG_LINE
+	LOG_FUNC	
+	iCmdTimeOutDuration = aTimeOut;	
+	}
+
+TBool CObexClient::AlreadyActive(TRequestStatus& aStatus)
+//can't do more than one request at atime
+	{
+	if(iPendingRequest)
+		{
+		TRequestStatus* tempStatus = &aStatus;
+		User::RequestComplete(tempStatus,KErrAccessDenied);
+		return ETrue;
+		}
+	return EFalse;
+	}
+
+void CObexClient::ResetConnectionID()
+	{
+	iConnectionID = KConnIDInvalid;
+	iConnectionIdSet = EFalse;
+	}
+			
+void CObexClient::SetConnectionID(TUint32 aConnectionID)
+	{
+	iConnectionID = aConnectionID;
+	iConnectionIdSet = ETrue;
+	}
+	
+void CObexClient::ClientCommandL(TOperation aOp, TAny* aParam, TRequestStatus& aStatus)
+	{
+	LOG_LINE
+	LOG_FUNC
+	
+	// Note: Function Calls to this method must be enclosed with an if statement utilising
+	// 		 CObexClient::AlreadyActive
+
+	SetRequest(aStatus, aOp);
+	if(aOp != EOpConnect &&(GetConnectState() != EConnObex || iTransportController == NULL))
+		{
+		SET_LAST_ERROR(EDisconnected);
+		LEAVEIFERRORL(KErrDisconnected);
+		}
+
+	switch(aOp)
+		{
+	case EOpConnect:
+		{
+		switch(GetConnectState())
+			{
+		case EConnIdle:
+			{
+			// Don t start the Packet timer, It will be done once the Transport is up(see :onTransportUp)
+			ResetConnectionID(); //set connection ID to invalid and flag to EFalse
+			iCurrentObject = static_cast<CObexBaseObject*>(aParam);
+			TRAPD(err, iTransportController->ConnectL());
+			if (err != KErrNone)
+				{
+				SET_LAST_ERROR(ETransportUpFailed);
+				LEAVEIFERRORL(err);
+				}
+			}
+ 			break;
+		case EConnTransport:
+			iCurrentObject = static_cast<CObexBaseObject*>(aParam);
+			//Transport is already connected just do the connection
+			//Previously TransportUp was called.  However the transport is already connected
+			//thus the only required actions are the following.  
+			OnTransportUp();
+			iTransportController->Receive();
+			break;
+		default:
+			SET_LAST_ERROR(EAlreadyConnected);
+			CompleteRequest(KErrAlreadyExists);
+			}
+		}
+		break;
+	case EOpDisconnect:
+		{
+		iTransportController->SendPacket().Init(TUint8(EOpDisconnect));
+		iTransportController->SendPacket().SetFinal();
+
+		// Insert the ConnectionID if necessary
+		if (iConnectionIdSet)
+			{
+						 
+			TObexInternalHeader connectionID; 
+			connectionID.Set(TObexInternalHeader::EConnectionID, iConnectionID);
+			 
+			if(!iTransportController->SendPacket().InsertData(connectionID))
+				{
+				LEAVEIFERRORL(KErrOverflow);
+				}
+			}
+		SendRequestPacket();
+		}
+		break;
+	case EOpPut:
+	case EOpGet:
+	// The Put and Get "request" state machines are identical
+	// and live inside the object streamer.
+		{
+		//
+		// For 'Get' the params are what to 'Get' and where to put it
+		// For 'Put' the params are what to put
+		// Either way we need to send a request based on the params
+		iCurrentObject = static_cast<CObexBaseObject*>(aParam);
+
+		// Initialise the object ready for sending
+		TInt err = iCurrentObject->InitSend(TObexOpcode(aOp));
+		if (err != KErrNone)
+			{
+			SET_LAST_ERROR(ECannotInitialiseObject);
+			LEAVEIFERRORL(err);
+			}
+
+		//if a ConnectionID was added then it's important to add the Connection ID
+		//header here, allow it to be processed by PrepareNextSendPacket
+		if ( iConnectionIdSet )
+			{
+			FLOG(_L("\tiConnectionIdSet is true"));
+			TRAPD(err, iCurrentObject->SetConnectionIdL(iConnectionID));
+			if (err != KErrNone)
+				{
+				SET_LAST_ERROR(ECannotSetConnectionId);
+				LEAVEIFERRORL(err);
+				}
+			}
+
+		// If we can...
+		if(iCurrentObject->PrepareNextSendPacket(iTransportController->SendPacket()) != CObexBaseObject::EError)
+			{	
+			iTransportController->SendPacket().AddPacketProcessEvents(EObexFinalPacketStarted | EObexFinalPacketFinished);
+					
+			// ...send the first request packet
+			FLOG(_L("\tsending first request packet..."));
+			SendRequestPacket();
+			}
+		else
+			{
+			FLOG(_L("\tleaving..."));
+			SET_LAST_ERROR(ECannotPreparePacket);
+			LEAVEIFERRORL(KErrGeneral);
+			}
+		}
+		break;
+
+	case EOpSetPath:
+		{// Build up a setinfo packet and send it.
+		TSetPathInfo* info = static_cast<TSetPathInfo*>(aParam);
+
+		iTransportController->SendPacket().Init(TUint8(aOp)); 
+		iTransportController->SendPacket().SetFinal();
+
+		TObexSetPathData data;
+		data.iFlags = info->iFlags;
+		data.iConstants = info->iConstants;
+		if(!iTransportController->SendPacket().InsertData(data))
+			{
+			LEAVEIFERRORL(KErrOverflow);
+			}
+
+		//insert the ConnectionID if necessary
+		if ( iConnectionIdSet )
+			{ 
+			
+			TObexInternalHeader connectionID;
+			connectionID.Set(TObexInternalHeader::EConnectionID, iConnectionID); 
+			
+			if(!iTransportController->SendPacket().InsertData(connectionID))
+				{
+				LEAVEIFERRORL(KErrOverflow);
+				}
+			}
+		if(info->iNamePresent)
+			{
+			TObexInternalHeader name;
+			name.Set(TObexInternalHeader::EName, info->iName);
+			if(!iTransportController->SendPacket().InsertData(name))
+				{
+				LEAVEIFERRORL(KErrOverflow);
+				}
+			}
+		SendRequestPacket();
+		break;
+		}
+	default:
+		IrOBEXUtil::Fault(EClientCommandOpUnrecognised);
+		}
+
+	}
+
+void CObexClient::OnPacketReceive(CObexPacket& aPacket)
+	{
+	LOG_LINE
+	LOG_FUNC
+	
+	//Cancel the timer
+	if (iPacketTimer->IsActive())
+		{
+		iPacketTimer->Cancel();
+		}
+	
+	// Store the response code including the 'final bit'.
+	iLastReceivedResponseOpcode = static_cast<TObexResponse>(aPacket.Opcode() | (aPacket.IsFinal() ? KObexPacketFinalBit : 0));
+	
+	if(iTransportController->IsWriteActive())
+		{
+		FLOG(_L("OnPacketReceive received request whilst writing... dropping connection\r\n"));
+		SET_LAST_ERROR(EResponseWhileWriting);
+		CompleteRequest(KErrNone);
+		ControlledTransportDown();
+		return;
+		}
+
+	// Initialise the send packet to ensure that we do not
+	// accidentally send the same packet as last time!
+	iTransportController->SendPacket().Init(0);
+
+	switch(iCurrentOperation)
+		{
+	case EOpConnect:
+		{
+		FLOG(_L("CObexClient::OnPacketReceive Connect OpCode\r\n"));
+		if(ParseConnectPacket(aPacket) == KErrNone)
+			{
+			FLOG(_L("OnPacketReceive Connect Packet parsed \r\n"));
+
+			//the request is only completed if now connected
+			if(GetConnectState() == EConnObex)
+				{
+				SET_LAST_ERROR(ENoError);
+				CompleteRequest(KErrNone);
+				}
+			else //otherwise still some outstanding issues
+				{
+				iTransportController->SendPacket().Init(EOpConnect); 
+				TInt err = PrepareConnectPacket(iTransportController->SendPacket());
+				if( err == KErrNone )
+					{
+					FLOG(_L("OnPacketReceive PrepareConnectPacket SUCCESS\r\n"));
+
+					iTransportController->SendPacket().SetFinal();
+					SendRequestPacket();
+					}
+				else if ( GetConnectState() != EWaitForUserInput )
+					{
+					FLOG(_L("OnPacketReceive PrepareConnectPacket FAILED\r\n"));
+					// Last underlying error already set in PrepareConnectPacket().
+					Error(err);
+					}
+				}
+			}
+		else
+			{
+			FLOG(_L("OnPacketReceive Connect Packet Parse FAILED\r\n"));
+			// Last underlying error already set in ParseConnectPacket().
+			Error(KErrAbort);
+			}
+		}
+		break;
+	case EOpDisconnect:
+		{
+		FLOG(_L("CObexClient::OnPacketReceive DisConnect OpCode\r\n"));
+		switch (aPacket.Opcode())
+			{
+			case ERespSuccess:
+				{
+				SET_LAST_ERROR(ENoError);
+				CompleteRequest(KErrNone);
+				}
+				break;
+			case ERespServiceUnavailable:
+				{
+				SET_LAST_ERROR(EBadConnectionId);
+				CompleteRequest(KErrDisconnected);
+				}
+				break;
+			default:
+				{
+				SET_LAST_ERROR(EErrorResponseFromServer);
+				CompleteRequest(KErrDisconnected);
+				}
+			}
+		
+		ControlledTransportDown(); // Bring down the transport anyway, otherwise we could end up in a situation where we can't
+		}
+		break;
+	case EOpPut:
+		{
+		FLOG(_L("CObexClient::OnPacketReceive Put OpCode\r\n"));
+		if(!aPacket.IsFinal())
+			{// Multipacket responses not allowed.
+			SET_LAST_ERROR(EMultipacketResponse);
+			Error(KErrCommsOverrun);	
+			break;
+			}
+		if(aPacket.Opcode() != ERespContinue 
+			&& aPacket.Opcode() != ERespSuccess
+			&& aPacket.Opcode() != ERespPartialContent)
+			{// Server has returned an OBEX error response. Deal with it...
+			TInt err = IrOBEXUtil::EpocError(aPacket.Opcode());
+			LOG1(_L8("Put error: %d"), err);
+			SET_LAST_ERROR(EErrorResponseFromServer);
+			CompleteRequest(err);
+			break;
+			}
+
+		{
+		CObexBaseObject::TProgress progress = 
+			iCurrentObject->PrepareNextSendPacket(iTransportController->SendPacket());
+		iTransportController->SendPacket().AddPacketProcessEvents(EObexFinalPacketStarted | EObexFinalPacketFinished);
+
+		// Work around for a problem both with some DoCoMo phones and Windows 2000:
+		// Their server sends "Success" when it should actually send "Continue",
+		// so we accept either here.
+		if (((progress == CObexBaseObject::EContinue || progress == CObexBaseObject::ELastPacket)
+			&& (aPacket.Opcode () == ERespContinue || aPacket.Opcode () == ERespSuccess))||
+			(progress == CObexBaseObject::EComplete 
+			&& (aPacket.Opcode() == ERespContinue )))
+			{// More stuff to send.
+			SendRequestPacket();
+			}
+		else if(progress == CObexBaseObject::EComplete 
+			     && (aPacket.Opcode() == ERespSuccess || aPacket.Opcode() == ERespPartialContent ))
+			{// We've completed okay.
+			//	There may be headers to extract from this final put response
+			TObexInternalHeader header;
+
+			while(aPacket.ExtractData(header))
+				{
+				FLOG(_L("OnPacketReceive Extracting header from final Put Response"));
+				TInt err=IrOBEXHeaderUtil::ParseHeader(header, *iHeaderSet);
+				if(err != KErrNone)
+					{
+					SET_LAST_ERROR(ECannotExtractFinalPutHeader);
+					Error(err);
+					}
+				}
+			TInt err = IrOBEXUtil::EpocError(aPacket.Opcode());
+			if (err == KErrNone)
+				{
+				SET_LAST_ERROR(ENoError);
+				}
+			else
+				{
+				SET_LAST_ERROR(EErrorResponseFromServer);
+				}
+			CompleteRequest(err);
+			}
+		else
+			{// We're out of sync with server. Give up.
+			SET_LAST_ERROR(EPutOutOfSync);
+			Error(KErrGeneral);
+			}
+		}
+		break;
+		}
+	case EOpGet:
+		{
+		FLOG(_L("CObexClient::OnPacketReceive Get OpCode\r\n"));
+		if(!aPacket.IsFinal())
+			{
+			SET_LAST_ERROR(EMultipacketResponse);
+			Error(KErrCommsOverrun); //??? WTF? Comms overrun?
+			break;
+			}
+
+		// There's only two valid responses to a 'Get' Request...
+		TUint8 respCode = aPacket.Opcode();
+		if( respCode != ERespContinue &&
+			respCode != ERespSuccess )
+			// ... and if we didn't get one of them...
+			{
+			// ...there's not much else we can do
+			SET_LAST_ERROR(EErrorResponseFromServer);
+			CompleteRequest(IrOBEXUtil::EpocError(respCode));
+			break;
+			}
+
+		// Now we know the response was probably valid, see if we need 
+		// to send another request packet
+		CObexBaseObject::TProgress progress;
+		progress = iCurrentObject->PrepareNextSendPacket(iTransportController->SendPacket());
+		
+		if( progress != CObexBaseObject::EComplete &&
+		    progress != CObexBaseObject::ELastPacket)
+			// We're not done sending the request yet. 
+			{
+			// So we'd better not have got a 'Success' from the remote end
+			if( progress == CObexBaseObject::EContinue &&
+				respCode == ERespContinue)
+				{
+				iTransportController->SendPacket().AddPacketProcessEvents(EObexFinalPacketStarted | EObexFinalPacketFinished);
+				
+				// Not finished sending the request yet, so send the next packet
+				SendRequestPacket();
+				}
+			else
+				{
+				// Something went wrong - can't continue.
+				SET_LAST_ERROR(EGetPrematureSuccess);
+				CompleteRequest(KErrGeneral);
+				}
+
+			// We're done with this packet
+			break;
+			}
+
+		// Still here? We MUST have got an EComplete from the sending state 
+		// machine. That means that the response we're handling RIGHT NOW is 
+		// the first packet of the thing we are 'Get'ting.
+
+		// Must initialise the object to receive the data from the server
+		iCurrentObject->InitReceive();
+		// Change state so we handle the next response properly
+		iCurrentOperation = EOpGetResponse;
+		}
+		// ** NB ** NO BREAK - DROP THROUGH TO HANDLE THE RESPONSE
+	case EOpGetResponse:
+	// Expecting a possibly multi-packet 'Get' response
+		{
+		FLOG(_L("CObexClient::OnPacketReceive GetResponse OpCode"));
+
+		if(iCurrentObject->ParseNextReceivePacket(aPacket) == CObexBaseObject::EError)
+			{
+			SET_LAST_ERROR(EGetResponseParseError);
+			Error(KErrGeneral);
+			break;
+			}
+		if(aPacket.Opcode() == ERespContinue)
+			{
+			// Send a blank 'Get' request to solicit the next bit of the response
+			SendRequestPacket(EOpGet);
+			FTRACE(iTransportController->SendPacket().Dump());
+			}
+		else
+			{
+			// Got all of the response, give it to the user
+			if (aPacket.Opcode() == ERespSuccess)
+				{
+				SET_LAST_ERROR(ENoError);
+				}
+			else
+				{
+				SET_LAST_ERROR(EErrorResponseFromServer);
+				}
+			CompleteRequest(IrOBEXUtil::EpocError(aPacket.Opcode()));
+			}
+		}
+		break;
+	case EOpSetPath:
+		FLOG(_L("CObexClient::OnPacketReceive Set Path OpCode\r\n"));
+		if (aPacket.Opcode() == ERespSuccess)
+			{
+			SET_LAST_ERROR(ENoError);
+			}
+		else
+			{
+			SET_LAST_ERROR(EErrorResponseFromServer);
+			}
+		CompleteRequest(IrOBEXUtil::EpocError(aPacket.Opcode()));
+		break;
+	case EOpAbortNoFBit:
+		FLOG(_L("CObexClient::OnPacketReceive Abort NoFBit OpCode\r\n"));
+		SendRequestPacket(EOpAbort);
+		iCurrentOperation = EOpAbort;
+		break;
+	case EOpAbort:
+		{
+		FLOG(_L("CObexClient::OnPacketReceive Abort OpCode\r\n"));
+
+		SET_LAST_ERROR(EAborted);
+		if(aPacket.IsFinal() && aPacket.Opcode() == ERespSuccess)
+			{// Just complete the put/get with code aborted
+			CompleteRequest(KErrAbort);
+			}
+		else
+			{// Report an error while aborting -> causes a disconnect
+			Error(KErrAbort);
+			}
+		}
+		break;
+	default:
+//		FPrint(_L("CObexClient::OnPacketReceive unknown opcode 0x%X!"),
+//			iCurrentOperation);
+		break;
+		}
+
+	// Client has finished with the read packet so queue the next read (if necessary)
+	if(iConnectState >= EConnTransport)
+		{
+		iTransportController->Receive();
+		}
+
+	}
+
+TInt CObexClient::ParseConnectPacket(CObexPacket& aPacket)
+	{
+	TInt retValue = KErrNone;
+	TConnectState nextState = EDropLink;
+
+	if(!iTransportController || !iTransportController->ExtractRemoteConnectInfo(aPacket, iRemoteInfo.iVersion, iRemoteInfo.iFlags))
+		{
+		FLOG(_L("CObexClient::ParseConnectPacket Extract Remote Info FAILED\r\n"));
+		SET_LAST_ERROR(ECannotExtractConnectInfo);
+		return KErrGeneral;
+		}
+	FLOG(_L("CObexClient::ParseConnectPacket Extract Remote Info Success\r\n"));
+
+	TObexInternalHeader hdr;
+
+	if ( aPacket.Opcode() == ERespSuccess )
+		{
+		FLOG(_L("ParseConnectPacket ERespSuccess Opcode\r\n"));
+
+		//if a simple connect was originally requested
+		//then a simple ERespSuccess without any headers is enough
+		if ( GetConnectState() == ESimpleConnRequest )
+			nextState = EConnObex;
+		//if responding to a chall from the server
+		if (( GetConnectState() == EWaitForFinalResponse)&&(!iChallenge)) 
+			nextState = EConnObex;
+		while(aPacket.ExtractData(hdr))
+			{
+			switch(hdr.HI()) 
+				{
+				case TObexInternalHeader::EWho:
+					{
+					FLOG(_L("ParseConnectPacket Extracting EWHO header\r\n"));
+					iRemoteInfo.iWho.Copy(hdr.HVByteSeq(), hdr.HVSize() > iRemoteInfo.iWho.MaxSize() ? iRemoteInfo.iWho.MaxSize() : hdr.HVSize());
+					}
+				break;
+				case TObexInternalHeader::EConnectionID:
+					{
+					FLOG(_L("ParseConnectPacket Extracting EConnectionID header\r\n"));
+
+					TUint32 newConnectionID = ((hdr.HVByteSeq()[0] << 24) + (hdr.HVByteSeq()[1] << 16) + (hdr.HVByteSeq()[2] << 8) + (hdr.HVByteSeq()[3]));
+					SetConnectionID(newConnectionID);
+					
+					if ( GetConnectState() == ESimpleConnRequest )
+						{
+						nextState = EConnObex;
+						}
+					}		
+					break;
+				case TObexInternalHeader::EAuthResponse: 
+					{
+					if (iChallenge)
+						{
+						FLOG(_L("ParseConnectPacket Extracting EAuthResponse header\r\n"));
+						//extract the response into it's constituent parts
+						TRAPD(err, ProcessChallResponseL(hdr));
+						if ( err == KErrNone )
+							{
+							FLOG(_L("ParseConnectPacket ProcessChallResponse Success\r\n"));
+	
+							if ((GetConnectState() == EChallConnRequested) || ( GetConnectState() == EWaitForFinalResponse))
+								{
+								nextState = EConnObex;
+								}
+							else
+								{
+								SET_LAST_ERROR(EUnexpectedChallengeResponse);
+								nextState = EDropLink;
+								retValue = KErrGeneral;
+								}
+							}
+						else
+							{
+							FLOG(_L("ParseConnectPacket ProcessChallResponse FAILED\r\n"));
+							SET_LAST_ERROR(ECannotProcessChallenge);
+							nextState = EDropLink;
+							retValue = KErrGeneral;
+							}
+						}
+					else
+						{
+						// if no challenge was issued, then receiving a challenge response means the peer is badly
+						// behaved. For this case we simply ignore the header, anything else would be too drastic.
+						FLOG(_L("ParseConnectPacket Chall Response received when no Chall issued\r\n"));
+						}
+					}	
+					break;
+				default:
+					break;
+				}//end switch
+			}//end while		
+		}
+	else if (aPacket.Opcode() == ERespUnauthorized )
+		{
+		FLOG(_L("ParseConnectPacket ERespUnauthorized Opcode\r\n"));
+		// Only valid header here is AuthChallenge, if it's absent then authentication failed.
+		TBool challengeAbsent = ETrue;
+		while(aPacket.ExtractData(hdr))
+			{
+			switch(hdr.HI()) 
+				{
+				case TObexInternalHeader::EAuthChallenge: 
+					{
+					FLOG(_L("ParseConnectPacket Extracting EAuthChallenge header\r\n"));
+					challengeAbsent = EFalse;
+					TRAPD(err, ProcessChallengeL(hdr));
+					if ( !err )
+						{
+						nextState = EConnChallRxed;
+						retValue = KErrNone;
+						}
+					else
+						{
+						SET_LAST_ERROR(ECannotProcessChallenge);
+						retValue = KErrGeneral;
+						}
+#ifdef TEST_CLIENT_CHANGES_ITS_MIND_ABOUT_CHALLENGE
+						//this will force the client to challenge the server
+						//even if it didn't challenge initially
+						//this is not standard behaviour for our client
+						//but the server must be capable of handling this situation
+						iChallenge = ETrue;
+#endif
+					}
+					break;
+				default:
+				break;
+				}//end switch
+			}//end while		
+
+		if (challengeAbsent)
+			{
+			SET_LAST_ERROR(EChallengeAbsent);
+			retValue = KErrGeneral;
+			}
+		}
+	else
+		{
+		FLOG(_L("ParseConnectPacket Unknown Opcode Opcode\r\n"));
+		SET_LAST_ERROR(EBadOpcodeInConnectPacket);
+		retValue = KErrGeneral;
+		}
+
+
+	SetConnectState(nextState);
+	return(retValue);
+	}
+
+void CObexClient::OnError(TInt aError)
+	{
+	LOG1(_L8("CObexClient::OnError(%d)"), aError);
+	CompleteRequest(aError);
+
+	// Don't reset the Obex link for a normal disconnection, as
+	// technically there is no real error requiring such drastic
+	// action.  In the case of USB, stalling the IN endpoint will
+	// cause another round of alternate interface changes which
+	// appears to confuse either Obex or the USB connector.
+
+	// In other words the error KErrDisconnected occurs as a
+	// result of the transport coming down, so there's no need to
+	// signal a transport error in this case.
+
+	// If this is called during construction, iTransportController could be NULL
+	if(aError!=KErrDisconnected && iTransportController)
+		{
+		iTransportController->SignalTransportError();
+		}
+	}
+
+
+
+TInt CObexClient::PrepareConnectPacket(CObexPacket& aPacket)
+	{
+	TInt retValue = KErrNone;
+	TConnectState nextState = EDropLink;
+
+	if (!iTransportController->InsertLocalConnectInfo(aPacket, iLocalInfo.iVersion, iLocalInfo.iFlags))
+		{
+		FLOG(_L("CObexClient::PrepareConnectPacket local data insertion FAILED\r\n"));
+		SET_LAST_ERROR(ECannotInsertConnectInfo);
+		return(KErrGeneral);
+		}
+	FLOG(_L("CObexClient::PrepareConnectPacket local data inserted Succesfully\r\n"));
+
+	//iCurrentObject could be NULL if Connect with no headers was requested
+	if ( iCurrentObject )
+		iCurrentObject->PrepareConnectionHeader(iTransportController->SendPacket());
+
+
+	if (( iChallenge )&&(!retValue))	//if a challenge is to be sent
+		{
+		FLOG(_L("PrepareConnectPacket Generating challenge\r\n"));
+
+		retValue = GenerateChallenge(aPacket);
+		if ( retValue == KErrNone) 
+			{
+			nextState = EChallConnRequested;
+			}
+		else
+			{
+			nextState = EDropLink;
+			}
+		}
+	
+	
+	//check the state of the connect instruction
+	if ( GetConnectState() == EConnTransport ) //first time round the loop
+		{
+		//it's going to be a simple challenge unless
+		//it's already been decides it's a EChallConnRequested
+		if ( nextState == EDropLink )
+			nextState = ESimpleConnRequest; 
+		}
+	else if (GetConnectState() == EConnChallRxed)
+		{							
+		if (iCallBack )
+			{
+			FLOG(_L("PrepareConnectPacket requesting password from user\r\n"));
+
+			//ask the user for a password
+			//the callback does happens in the method OnPacketReceive()
+			nextState = EWaitForUserInput;
+			retValue = KErrGeneral; //mustn't send yet wait for reply from user
+			}
+		else
+			{
+			FLOG(_L("PrepareConnectPacket chall rxed but can't ask for password dropping link\r\n"));
+			SET_LAST_ERROR(EChallengeRejected);
+			retValue = KErrIrObexConnectChallRejected;
+			nextState = EDropLink;
+			}
+		}					//or drop the link
+	else
+		{
+		FLOG(_L("PrepareConnectPacket unknown connect state\r\n"));
+		SET_LAST_ERROR(EPrepareConnectPacketIncorrectState);
+		retValue = KErrGeneral;
+		nextState = EDropLink;
+		}
+	SetConnectState(nextState);
+
+	return(retValue);
+	}
+
+void CObexClient::OnTransportUp()
+	{
+	FLOG(_L("CObexClient::OnTransportUp\r\n"));
+	ResetConnectionID();
+
+	iTransportController->SendPacket().Init(EOpConnect); 
+	if (PrepareConnectPacket(iTransportController->SendPacket()) == KErrNone)
+		{
+		FLOG(_L("OnTransportUp PrepareConnectPacket Succesfull\r\n"));
+
+		iTransportController->SendPacket().SetFinal();
+		FTRACE(iTransportController->SendPacket().Dump());
+		SendRequestPacket();
+		}
+	}
+
+void CObexClient::OnTransportDown()
+	{
+	LOG_LINE
+	LOG_FUNC
+	
+	// Cancel the timer
+	if (iPacketTimer->IsActive())
+		{
+		iPacketTimer->Cancel();
+		}
+	// If there's an outstanding request, an error has occured
+	// But don't do anything if an error has already been set (due to e.g. packet timer timeout)
+	if(iPendingRequest && !iIsLastErrorSet)
+		{
+		SET_LAST_ERROR(EOpOutstandingOnTransportDown);
+		Error(KErrIrObexClientPutPeerAborted); //extended error for IrObex,("Other IR device aborted the transfer")
+		}
+	}
+
+/** Signals an event has ocurred.
+
+@released
+@internalComponent
+@param aEvent The event that has ocurred (TObexPacketProcessEvent)
+*/
+void CObexClient::SignalPacketProcessEvent(TInt aEvent)
+	{
+	if(aEvent & KObexPacketSignallerInterestingClientEvents)
+		{
+		// Currently all notifications are related to writes, so only need to
+		// clear events from the SendPacket.
+		iTransportController->SendPacket().RemovePacketProcessEvents(aEvent);
+
+		iPacketProcessSignaller->Signal(static_cast<TObexPacketProcessEvent>(aEvent));
+		}
+	}
+
+void CObexClient::SetRequest(TRequestStatus& aStatus, TOperation aOperation)
+	{
+	aStatus = KRequestPending;
+	iPendingRequest = &aStatus;
+	iCurrentOperation = aOperation;
+	}
+
+void CObexClient::CompleteRequest(const TInt aCompletion)
+	{
+	LOG_LINE
+	LOG_FUNC
+	
+	if(iPendingRequest)
+		{
+		// Some errors, particularly IR, only come up through OnError().
+		// Thus the setting of underlying error happens here.
+		switch (aCompletion)
+			{
+			case KErrIrObexRespTimedOut:
+				{
+				SET_LAST_ERROR(EResponseTimeout);
+				}
+				break;
+			case KErrDisconnected:
+				{
+				// There are at least two ways of getting here.
+				// The first is disruption to the transport (e.g. IrDA beam blocked)
+				// and the second is attempting an operation other than connect when
+				// there is no connection (see CObexClient::ClientCommandL()).
+				// We don't want to set the last error twice in the second case,
+				// so check that the last error is not set before setting it here.
+				if (!iIsLastErrorSet)
+					{
+					SET_LAST_ERROR(EOpOutstandingOnTransportDown);
+					}
+				}
+				break;
+			case KErrCompletion:
+				{
+				// This is an error from the destructor.
+				// Operation is complete, successfully or otherwise.
+				// Since the operation is still outstanding and the interruption
+				// was initiated locally, the operation is effectively aborted.
+				SET_LAST_ERROR(EAborted);
+				}
+				break;
+			case KErrNotReady:
+				{
+				// This error occurs when the BT link times out.
+				SET_LAST_ERROR(EOpOutstandingOnTransportDown);
+				}
+				break;
+			case KErrCouldNotConnect:
+				{
+				// BT could not connect.
+				SET_LAST_ERROR(EOpOutstandingOnTransportDown);
+				}
+				break;
+			case KErrGeneral:
+				{
+				// Since Obex also uses this error elsewhere, only set a last error
+				// if none has been set previously.
+				if (!iIsLastErrorSet)
+					{
+					SET_LAST_ERROR(EOpOutstandingOnTransportDown);
+					}
+				}
+				break;
+			default:
+				{
+				// If an error has not yet been set, then set the last error as appropriate.
+				if (!iIsLastErrorSet)
+					{
+					// For all other errors.
+					SET_LAST_ERROR(EOpOutstandingOnTransportDown);
+					}
+				}
+			}
+		CHECK_LAST_ERROR_IS_SET;
+		User::RequestComplete(iPendingRequest, aCompletion);// Sets iPendingRequest = NULL
+		}
+	iPendingRequest=NULL;
+	iCurrentOperation = EOpIdle;
+	
+	if (iPacketTimer)
+		{
+		iPacketTimer->Cancel();
+		}
+	}
+
+void CObexClient::EmptyHeaderSet()
+	{
+	LOG_LINE
+	LOG_FUNC
+	
+	iHeaderSet->First();
+	while(iHeaderSet->This(iHeader) == KErrNone)
+		{
+		iHeaderSet->DeleteCurrentHeader();
+		}
+	}
+	
+void CObexClient::TimeOutCompletion()
+	{
+	LOG_LINE
+	LOG_FUNC
+	
+	CompleteRequest(KErrIrObexRespTimedOut);
+	// Disconnect transport to prevent the client entering an invalid state
+	ForcedTransportDown();
+	}
+
+void CObexClient::SendRequestPacket()
+	{
+	//Send the request.
+	iTransportController->Send();
+	
+	//Set the Timer.
+	iPacketTimer->SetTimer(iCmdTimeOutDuration);
+	}
+
+void CObexClient::SendRequestPacket(TObexOpcode aObexOpcode)
+	{
+	//Send the request.
+	iTransportController->Send(aObexOpcode);
+	
+	//Set the Timer.
+	iPacketTimer->SetTimer(iCmdTimeOutDuration);
+	}
+
+/**
+Provides additional interfaces for CObexClient.
+
+@param aUid The UID of the interface that is required.
+@return A pointer to an instance implementing the interface represented by aUid.
+*/
+EXPORT_C TAny* CObexClient::ExtensionInterface(TUid aUid)
+	{
+	TAny* ret = NULL;
+
+	if (aUid == KObexClientErrorResolverInterface)
+		{
+		ret = static_cast<MObexClientErrorResolver*>(iErrorEngine);
+		}
+
+	return ret;
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexconstants.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,175 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obexconstants.h>
+#include "obexconstantsinternal.h"
+#include <obex/internal/obexinternalconstants.h>
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/**
+@file
+@internalComponent
+*/
+
+/**
+Sets up class with default values
+@publishedAll
+@released
+*/
+EXPORT_C TObexProtocolPolicy::TObexProtocolPolicy ()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	// Default set-up for version 0
+	// This is set for backwards compatibility, so change with caution!
+	iVersion = 0;
+	iReceiveMtu = KObexPacketDefaultSize;
+	iTransmitMtu = KObexPacketDefaultSize;
+	}
+
+/**
+Sets the maximum size of the receive packet buffer for the policy.
+For the IrDA transport, if the new receive buffer size is different to
+KObexPacketDefaultSize the receive packet size is set to equal the new
+buffer size.  Otherwise the packet size is set to the protocol defined limit.
+@param aReceiveMtu The new buffer size
+@return KErrNone on success. KErrArgument if the packet size is not supported
+@publishedAll
+@released
+*/
+EXPORT_C TInt TObexProtocolPolicy::SetReceiveMtu ( TUint16 aReceiveMtu )
+	{
+	LOG_LINE
+	LOG_FUNC
+	LOG1(_L8("\taReceiveMtu = %d"), aReceiveMtu);
+
+	// Can't set size greater than the maximum, so only check if it's too small
+	if ( aReceiveMtu >= KObexPacketMinSize )
+		iReceiveMtu = aReceiveMtu;
+	
+	TInt ret = ( iReceiveMtu == aReceiveMtu ) ? KErrNone : KErrArgument;	
+	LOG1(_L8("\tret = %d"), ret);
+	return ret;
+	}
+
+/**
+Sets the maximum size of the transmit packet buffer for the policy
+@param aTransmitMtu The new buffer size
+@return KErrNone on success. KErrArgument if the packet size is not supported
+@publishedAll
+@released
+*/
+EXPORT_C TInt TObexProtocolPolicy::SetTransmitMtu ( TUint16 aTransmitMtu )
+	{
+	LOG_LINE
+	LOG_FUNC
+	LOG1(_L8("\taTransmitMtu = %d"), aTransmitMtu);
+
+	// Can't set size greater than the maximum, so only check if it's too small
+	if ( aTransmitMtu >= KObexPacketMinSize )
+		iTransmitMtu = aTransmitMtu;
+
+	TInt ret = ( iTransmitMtu == aTransmitMtu ) ? KErrNone : KErrArgument;
+	LOG1(_L8("\tret = %d"), ret);
+	return ret;
+	}
+
+/**
+Gets the version of the protocol policy format that this class supports
+@return Protocol policy version
+@publishedAll
+@released
+*/
+EXPORT_C TUint16 TObexProtocolPolicy::Version () const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	LOG1(_L8("\tiVersion = %d"), iVersion);
+	return iVersion;
+	}
+
+/**
+Gets the policy's receive packet buffer size
+@return Receive packet buffer size
+@publishedAll
+@released
+*/
+EXPORT_C TUint16 TObexProtocolPolicy::ReceiveMtu () const
+	{
+	LOG_LINE
+	LOG_FUNC
+	   
+	LOG1(_L8("\tiReceiveMtu = %d"), iReceiveMtu);
+	return iReceiveMtu;
+	}
+
+/**
+Gets the policy's transmit packet buffer size
+@return Transmit packet buffer size
+@publishedAll
+@released
+*/
+EXPORT_C TUint16 TObexProtocolPolicy::TransmitMtu () const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	LOG1(_L8("\tiTransmitMtu = %d"), iTransmitMtu);
+	return iTransmitMtu;
+	}
+
+// TObexConnectInfo
+/**
+@publishedAll
+@released
+*/
+EXPORT_C TObexConnectInfo::TObexConnectInfo() 
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iVersion = KObexVersion;
+	iFlags = 0;
+	}
+
+/**
+@publishedAll
+@released
+*/
+EXPORT_C TUint8 TObexConnectInfo::VersionMajor() const 
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return(STATIC_CAST(TUint8,(iVersion & 0xF0) >> 4));
+	}
+
+/**
+@publishedAll
+@released
+*/
+EXPORT_C TUint8 TObexConnectInfo::VersionMinor() const 
+	{ 
+	LOG_LINE
+	LOG_FUNC
+
+	return(STATIC_CAST(TUint8,(iVersion & 0x0F)));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexerrorengine.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "obexerrorengine.h"
+#include "OBEXUTIL.H"
+
+CObexErrorEngine* CObexErrorEngine::NewL()
+	{
+	CObexErrorEngine* self = new (ELeave) CObexErrorEngine;
+	return self;
+	}
+
+CObexErrorEngine::CObexErrorEngine()
+	{
+	iLastError = ENoError;
+	}
+
+/**
+Function used to retreive an extended error code for the last completed client operation.
+
+@param aErrorSet The set of errors that the resolved error will lie within.
+@return An extended error code that lies within the error set specified.
+*/
+TUint CObexErrorEngine::LastError(TObexClientErrorResolutionSetType aErrorSet) const
+	{
+	TUint ret = 0;
+
+	if (aErrorSet == EObexClientBasicErrorResolutionSet)
+		{
+		switch (iLastError)
+			{
+			case ENoError:
+				{
+				ret = EObexRequestAccepted;
+				}
+				break;
+
+			case EAlreadyConnected:
+			case EChallengeRejected:
+			case EChallengeAbsent:
+			case EBadConnectionId:
+			case EErrorResponseFromServer:
+				{
+				ret = EObexRequestNotAccepted;
+				}
+				break;
+
+			case EResponseTimeout:
+				{
+				ret = EObexRequestTimeout;
+				}
+				break;
+
+			case ECannotInsertConnectInfo:
+			case EPrepareConnectPacketIncorrectState:
+			case EResponseWhileWriting:
+			case ECannotExtractConnectInfo:
+			case ECannotProcessChallenge:
+			case EUnexpectedChallengeResponse:
+			case EBadOpcodeInConnectPacket:
+			case EAborted:
+			case ECannotInitialiseObject:
+			case ECannotSetConnectionId:
+			case ECannotPreparePacket:
+			case EMultipacketResponse:
+			case ECannotExtractFinalPutHeader:
+			case EPutOutOfSync:
+			case EGetPrematureSuccess:
+			case EGetResponseParseError:
+				{
+				ret = EObexRequestLocalInterruption;
+				}
+				break;
+
+			case ETransportUpFailed:
+			case EOpOutstandingOnTransportDown:
+			case EDisconnected:
+				{
+				ret = EObexRequestLinkInterruption;
+				}
+				break;
+
+			default:
+				{
+				IrOBEXUtil::Fault(EUnderlyingErrorUnrecognised);
+				}
+			}
+		}
+	else
+		{
+		IrOBEXUtil::Fault(EErrorSetUnrecognised);
+		}
+
+	return ret;
+	}
+
+void CObexErrorEngine::SetLastError(TObexClientUnderlyingError aError)
+	{
+	iLastError = aError;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexfilewriter.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,31 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+*/
+
+#include "obexfilewriter.h"
+
+/**
+Destructor
+*/
+MObexFileWriter::~MObexFileWriter()
+	{
+	}
+
+//
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexheader.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,678 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+*/
+
+#include <obexheaders.h>
+#include <obexconstants.h>
+#include "obexunderlyingheader.h"
+#include "OBEXUTIL.H"
+#include "logger.h"
+
+#define BAD_HEADER_ACTION IrOBEXUtil::Panic(EHeaderAsBadType)
+
+#if ( defined __FLOG_ACTIVE && defined __LOG_FUNCTIONS__ )
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/**
+Standard constructor
+
+@internalComponent
+ */
+CRefCounted::CRefCounted()
+	{
+	iCount = 0;
+	}
+	
+/**
+Increments the object's reference count.
+
+@internalComponent
+*/
+void CRefCounted::Open() const
+	{
+	iCount++;
+	}
+
+/**
+Decrements the object's reference count and deletes the object when count goes to zero.
+
+@internalComponent
+*/
+void CRefCounted::Close() const
+	{
+	iCount--;
+	if (iCount == 0) 
+		{
+		delete this;
+		}
+	}
+
+/**
+@panic ObexFault ERefCountNonZero Panics if there are still references to this object or if the reference count is negative.
+
+@internalComponent
+*/
+CRefCounted::~CRefCounted()
+	{
+	__ASSERT_ALWAYS(iCount == 0, IrOBEXUtil::Fault(ERefCountNonZero));
+	}
+
+EXPORT_C CObexHeader* CObexHeader::NewL()
+	{
+	LOG_LINE
+	LOG_STATIC_FUNC_ENTRY
+
+	CObexHeader* self = new(ELeave) CObexHeader();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+Return a pointer to a copy of this object.  This must be used instead
+of merely copying the pointer to the initial CObexHeader object as
+reference counting is used to keep track of instances of the header.
+The underlying data is not cloned, so any change to the data pointed to
+by this pointer could change the underlying data.
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexHeader* CObexHeader::CopyL() const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	CObexHeader* copy = new(ELeave) CObexHeader(iHeader);
+	copy->iHeader->Open();
+	return copy;
+	}
+
+/**
+@internalComponent
+Standard constructor.
+
+@see CObexHeaderSet
+*/
+CObexHeader::CObexHeader()
+	{
+	}
+
+/**
+Standard constructor, taking a pointer to an underlying object.
+
+@internalComponent
+*/
+CObexHeader::CObexHeader(CObexUnderlyingHeader* aHeader)
+	: iHeader(aHeader)
+	{
+	}
+	
+/**
+Sets this object to use the same underlying header as the parameter.
+This performs essentially the same function as the CopyL() function,
+but does not allocate a new object.
+The underlying data is not cloned, so any change to the data pointed to
+by this pointer could change the underlying data.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeader::Set(CObexHeader* aHeader)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	Reset();
+	iHeader = aHeader->iHeader;
+	iHeader->Open();
+	}
+
+/**
+Resets the contents of this header, discarding the underlying data.
+This is only called by the last instance of the header.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeader::Reset()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iHeader->Close();
+	iHeader = 0;
+	}
+
+/**
+Phase two constructor.
+Create the underlying header object.  This is reference counted
+so ownership passes to itself.
+
+@internalComponent
+*/
+void CObexHeader::ConstructL()
+	{
+	iHeader = CObexUnderlyingHeader::NewL();
+	iHeader->Open();
+	}
+
+/**
+Standard destructor.
+
+@publishedAll
+@released
+*/
+CObexHeader::~CObexHeader()
+	{
+	if (iHeader != 0)
+		{
+		iHeader->Close();
+		}
+	}
+
+/**
+Resets and destroys all header attributes.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeader::ResetContents()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iHeader->ResetContents();
+	}
+
+/**
+Sets the attibutes of this header.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeader::SetAttributes(TUint16 aAttr)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iHeader->SetAttributes(aAttr);
+	}
+
+/**
+Return the attibute set currently in force.
+
+@publishedAll
+@released
+*/
+EXPORT_C TUint16 CObexHeader::Attributes() const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return iHeader->Attributes();
+	}
+
+/**
+Return the type of this header.
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexHeader::THeaderType CObexHeader::Type() const
+
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return iHeader->Type();
+	}
+
+/**
+Returns the header identifier.
+
+@publishedAll
+@released
+*/
+EXPORT_C TUint8 CObexHeader::HI() const
+	{
+	// Don't log this function as it's too verbose.
+	//LOG_LINE
+	//LOG_FUNC
+
+	return iHeader->HI();
+	}
+
+/**
+Returns this header as a byte value.
+@return The value of this header.
+@panic Obex EHeaderAsBadType Panics builds if header is of incorrect type.
+
+@publishedAll
+@released
+*/
+EXPORT_C TUint8 CObexHeader::AsByte() const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return iHeader->AsByte();
+	}
+
+/**
+Returns this header as a four-byte value.
+@return The value of this header.
+@panic Obex EHeaderAsBadType Panics if header is of incorrect type.
+
+@publishedAll
+@released
+*/
+EXPORT_C TUint32 CObexHeader::AsFourByte() const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return iHeader->AsFourByte();
+	}
+
+/**
+Returns this header as a byte sequence.
+@return The value of this header.
+@panic Obex EHeaderAsBadType Panics if header is of incorrect type.
+
+@publishedAll
+@released
+*/
+EXPORT_C const TDesC8& CObexHeader::AsByteSeq() const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return iHeader->AsByteSeq();
+	}
+
+/**
+Returns this header as an Unicode string.
+@return The value of this header.
+@panic Obex EHeaderAsBadType Panics in debug builds if header is of incorrect type.
+
+@publishedAll
+@released
+*/
+EXPORT_C const TDesC16& CObexHeader::AsUnicode() const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return iHeader->AsUnicode();
+	}
+
+/**
+Sets this header to represent a byte value.
+Forces header type to be a byte (which may therefore change the HI
+value).
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeader::SetByte(const TUint8 aHI, const TUint8 aByte)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iHeader->SetByte(aHI, aByte);
+	}
+	
+/**
+Sets this header to represent a four-byte value.
+Forces header type to be a four-byte (which may therefore change
+the HI value).
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeader::SetFourByte(const TUint8 aHI, const TUint32 aFourByte)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iHeader->SetFourByte(aHI, aFourByte);
+	}
+	
+/**
+Sets this header to represent a byte sequence.
+Forces header type to be a byte sequence (which may therefore change
+the HI value).
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeader::SetByteSeqL(const TUint8 aHI, const TDesC8& aByteSeq)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iHeader->SetByteSeqL(aHI, aByteSeq);
+	}
+
+/**
+Forces header type to be a byte (which may therefore change the HI
+value).
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeader::SetUnicodeL(const TUint8 aHI, const TDesC16& aUnicode)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iHeader->SetUnicodeL(aHI, aUnicode);
+	}
+
+/**
+@return The encoded size of this header in bytes, including the 
+HI byte and the HV body.
+
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexHeader::EncodedSize() const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return iHeader->EncodedSize();
+	}
+
+// ----------------------------------------------------------------------
+// Now the real code.  CObexHeader is just a facade, passing requests on
+// to an underlying reference counted object.  This is where the real
+// work goes on.
+// ----------------------------------------------------------------------
+
+/**
+@internalComponent
+NewL method
+*/
+CObexUnderlyingHeader* CObexUnderlyingHeader::NewL()
+	{
+	CObexUnderlyingHeader* self = new(ELeave) CObexUnderlyingHeader();
+	return self;
+	}
+	
+/**
+@internalComponent
+Standard constructor.
+*/
+CObexUnderlyingHeader::CObexUnderlyingHeader()
+	{
+	}
+
+/**
+@internalComponent
+Standard destructor.
+*/
+CObexUnderlyingHeader::~CObexUnderlyingHeader()
+	{
+	ResetContents();
+	}
+
+/**
+@internalComponent
+Resets and destroys all header attributes.
+*/
+void CObexUnderlyingHeader::ResetContents()
+	{
+	// If a byte sequence or Unicode string header, destroy
+	// the underlying HBufC.
+	switch (Type())
+		{
+		case CObexHeader::EByteSeq:
+			delete iHV.iByteSeq;
+			break;
+		
+		case CObexHeader::EUnicode:
+			delete iHV.iUnicode;
+			break;
+		
+		default:
+			// Not a pointer, nothing required
+			{}
+		}
+
+	iAttributes = 0;
+	iHI = 0;
+	// Resetting the fourbyte data, will explicitly reset all the data
+	// stored in the union (so no need to reset unicode, byte, byteseq)
+	iHV.iFourByte = 0;
+	}
+
+/**
+@internalComponent
+Sets the attibutes of this header.
+*/
+void CObexUnderlyingHeader::SetAttributes(TUint16 aAttr)
+	{
+	iAttributes = aAttr;
+	}
+
+/**
+@internalComponent
+Return the attibute set currently in force.
+*/
+TUint16 CObexUnderlyingHeader::Attributes() const
+	{
+	return iAttributes;
+	}
+
+/**
+@internalComponent
+Return the type of this header.
+*/
+CObexHeader::THeaderType CObexUnderlyingHeader::Type() const
+	{
+	// Call the internal inline.  Just in case the header representation
+	// changes!
+	return static_cast<CObexHeader::THeaderType>(ObexHeaderType(iHI));
+	}
+
+/**
+@internalComponent
+Returns the header identifier.
+*/
+TUint8 CObexUnderlyingHeader::HI() const
+	{
+	return iHI;
+	}
+
+/**
+@internalComponent
+Returns this header as a byte value.
+@return The value of this header.
+@leave KErrNotSupported (release builds only) if this header is of
+incorrect type.
+@panic Obex EHeaderAsBadType Panics in debug builds if header is of incorrect type.
+*/
+TUint8 CObexUnderlyingHeader::AsByte() const
+	{
+	__ASSERT_ALWAYS((ObexHeaderType(iHI) == CObexHeader::EByte), BAD_HEADER_ACTION);
+	
+	return iHV.iByte;
+	}
+
+/**
+@internalComponent
+Returns this header as a four-byte value.
+@return The value of this header.
+@leave KErrNotSupported (release builds only) if this header is of
+incorrect type.
+@panic Obex EHeaderAsBadType Panics in debug builds if header is of incorrect type.
+*/
+TUint32 CObexUnderlyingHeader::AsFourByte() const
+	{
+	__ASSERT_ALWAYS((ObexHeaderType(iHI) == CObexHeader::EFourByte), BAD_HEADER_ACTION);
+	
+	return iHV.iFourByte;
+	}
+
+/**
+@internalComponent
+Returns this header as a byte sequence.
+@return The value of this header.
+@leave KErrNotSupported (release builds only) if this header is of
+incorrect type.
+@panic Obex EHeaderAsBadType Panics in debug builds if header is of incorrect type.
+*/
+const TDesC8& CObexUnderlyingHeader::AsByteSeq() const
+	{
+	__ASSERT_ALWAYS((ObexHeaderType(iHI) == CObexHeader::EByteSeq), BAD_HEADER_ACTION);
+	
+	if (iHV.iByteSeq)
+		return *(iHV.iByteSeq);
+	else
+		return KNullDesC8();
+	}
+
+/**
+@internalComponent
+Returns this header as an Unicode string.
+@return The value of this header.
+@leave KErrNotSupported (release builds only) if this header is of
+incorrect type.
+@panic Obex EHeaderAsBadType Panics in debug builds if header is of incorrect type.
+*/
+const TDesC16& CObexUnderlyingHeader::AsUnicode() const
+	{
+	__ASSERT_ALWAYS((ObexHeaderType(iHI) == CObexHeader::EUnicode), BAD_HEADER_ACTION);
+	
+	if (iHV.iUnicode)
+		return *(iHV.iUnicode);
+	else
+		return KNullDesC16();
+	}
+
+/**
+@internalComponent
+Sets this header to represent a byte value.
+Forces header type to be a byte (which may therefore change the HI
+value).
+*/
+void CObexUnderlyingHeader::SetByte(const TUint8 aHI, const TUint8 aByte)
+	{
+	__ASSERT_ALWAYS((ObexHeaderType(aHI) == CObexHeader::EByte), BAD_HEADER_ACTION);
+
+	if ((iHI & KObexHeaderTypeMask) != (aHI & KObexHeaderTypeMask))
+		ResetContents();
+	
+	iHI = aHI;
+	iHV.iByte = aByte;
+	}
+	
+/**
+@internalComponent
+Sets this header to represent a four-byte value.
+Forces header type to be a four-byte (which may therefore change
+the HI value).
+*/
+void CObexUnderlyingHeader::SetFourByte(const TUint8 aHI, const TUint32 aFourByte)
+	{
+	__ASSERT_ALWAYS((ObexHeaderType(aHI) == CObexHeader::EFourByte), BAD_HEADER_ACTION);
+
+	if ((iHI & KObexHeaderTypeMask) != (aHI & KObexHeaderTypeMask))
+		ResetContents();
+
+	iHI = aHI;
+	iHV.iFourByte = aFourByte;
+	}
+	
+/**
+@internalComponent
+Sets this header to represent a byte sequence.
+Forces header type to be a byte sequence (which may therefore change
+the HI value).
+*/
+void CObexUnderlyingHeader::SetByteSeqL(const TUint8 aHI, const TDesC8& aByteSeq)
+	{
+	__ASSERT_ALWAYS((ObexHeaderType(aHI) == CObexHeader::EByteSeq), BAD_HEADER_ACTION);
+
+	HBufC8* tmp = aByteSeq.AllocL();
+	if ((iHI & KObexHeaderTypeMask) != (aHI & KObexHeaderTypeMask))
+		ResetContents();
+
+	iHI = aHI;
+	delete iHV.iByteSeq;
+	iHV.iByteSeq = tmp;
+	}
+
+/**
+@internalComponent
+Sets this header to represent a byte value.
+Forces header type to be a byte (which may therefore change the HI
+value).
+*/
+void CObexUnderlyingHeader::SetUnicodeL(const TUint8 aHI, const TDesC16& aUnicode)
+	{
+	__ASSERT_ALWAYS((ObexHeaderType(aHI) == CObexHeader::EUnicode), BAD_HEADER_ACTION);
+
+	HBufC16* tmp = aUnicode.AllocL();
+	if ((iHI & KObexHeaderTypeMask) != (aHI & KObexHeaderTypeMask))
+		ResetContents();
+
+	iHI = aHI;
+	delete iHV.iUnicode;
+	iHV.iUnicode = tmp;
+	}
+
+TInt CObexUnderlyingHeader::EncodedSize() const
+	{
+	const TInt KHIByteSize=1;
+	const TInt KLengthEncoding=2;
+	const TInt KOneByteHeaderEncodedSize=1+KHIByteSize;
+	const TInt KFourByteHeaderEncodedSize=4+KHIByteSize;
+
+	TInt encodedSize=0;
+
+	switch(Type())
+		{
+
+	case CObexHeader::EUnicode:
+		encodedSize=KHIByteSize+KLengthEncoding+AsUnicode().Size();
+		if(AsUnicode().Size()>0)
+			encodedSize+=2; //	Two extra byes for null terminator
+		break;
+		
+	case CObexHeader::EByteSeq:
+		encodedSize=KHIByteSize+KLengthEncoding+AsByteSeq().Size();
+		break;
+
+	case CObexHeader::EByte:
+		encodedSize=KOneByteHeaderEncodedSize;
+		break;
+
+	case CObexHeader::EFourByte:
+		encodedSize=KFourByteHeaderEncodedSize;
+		break;
+
+		}
+		
+	return encodedSize;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexheaderset.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,467 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+*/
+
+#include <obexheaders.h>
+#include "OBEXUTIL.H"
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/**
+Called in response to First() being called on the iterator object.
+The default implementation does nothing---some implementations may
+wish to reset state variables.
+
+@publishedAll
+@released
+*/
+EXPORT_C void MObexHeaderCheck::Reset()
+	{
+	LOG_LINE
+	LOG_FUNC
+	}
+
+/**
+This virtual function allows the M- classes to be extended in future in a binary
+compatible way by providing a method that clients can override in future to
+allow extra callbacks to be made via aObject.
+*/	
+EXPORT_C void MObexHeaderCheck::MOHC_ExtensionInterfaceL(TUid /*aInterface*/, void*& aObject)
+	{
+	aObject = NULL;
+	}
+	
+/**
+@return ETrue if this header is the requested one.
+
+@publishedAll
+@released
+*/
+EXPORT_C TBool TObexMatchHeader::Interested(TUint8 aHI)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return (aHI == iHI);
+	}
+
+/**
+Sets the header identifier required.
+@code : iHI = aHI;
+@publishedAll
+@released
+*/
+EXPORT_C void TObexMatchHeader::SetHeader(TUint8 aHI)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iHI = aHI;
+	}
+
+/**
+@return ETrue if this header is of the requested type.
+@publishedAll
+@released
+*/
+EXPORT_C TBool TObexMatchHeaderType::Interested(TUint8 aHI)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return (ObexHeaderType(aHI) == iType);
+	}
+
+/**
+Set the header type required.
+@code : iType = aType;
+@publishedAll
+@released
+*/
+EXPORT_C void TObexMatchHeaderType::SetType(CObexHeader::THeaderType aType)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iType = aType;
+	}
+
+/**
+Creates an empty CObexHeaderSet object.
+@publishedAll
+@released
+*/
+EXPORT_C CObexHeaderSet* CObexHeaderSet::NewL()
+	{
+	LOG_LINE
+	LOG_STATIC_FUNC_ENTRY
+
+	CObexHeaderSet* self = new(ELeave) CObexHeaderSet();
+	return self;
+	}
+
+/**
+Copies an existing CObexHeaderSet to populate a new object.
+@return A new CObexHeaderSet object populated with the headers.
+		This method returns ownership of the new object.
+@publishedAll
+@released
+*/
+EXPORT_C CObexHeaderSet* CObexHeaderSet::CopyL()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	CObexHeaderSet* newHeaderSet = new(ELeave) CObexHeaderSet();
+	CleanupStack::PushL(newHeaderSet);
+	
+	TInt maxHeader = iHeaders.Count();
+	for (TInt pos = 0; pos < maxHeader; pos++)
+		{
+		CObexHeader* newHeader = iHeaders[pos]->CopyL();
+		CleanupStack::PushL(newHeader);
+		LEAVEIFERRORL(newHeaderSet->iHeaders.Append(newHeader));
+		CleanupStack::Pop(newHeader);
+		}
+	
+	CleanupStack::Pop(newHeaderSet);
+	return newHeaderSet;
+	}
+	
+/**
+Copies interesting headers from an existing CObexHeaderSet to populate a new object.
+@param aHeaderCheck The object to use to filter headers of interest.
+@return A new CObexHeaderSet object with the desired headers.
+		This method returns ownership of the new object.
+@publishedAll
+@released
+*/	
+EXPORT_C CObexHeaderSet* CObexHeaderSet::CopyL(MObexHeaderCheck& aHeaderCheck)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	CObexHeaderSet* newHeaderSet = new(ELeave) CObexHeaderSet();
+	CleanupStack::PushL(newHeaderSet);
+	
+	aHeaderCheck.Reset();
+	
+	TInt maxHeader = iHeaders.Count();
+	for (TInt pos = 0; pos < maxHeader; pos++)
+		{
+		CObexHeader* header = iHeaders[pos];
+		
+		if (aHeaderCheck.Interested(header->HI()))
+			{
+			CObexHeader* newHeader = header->CopyL();
+			CleanupStack::PushL(newHeader);
+			LEAVEIFERRORL(newHeaderSet->iHeaders.Append(newHeader));
+			CleanupStack::Pop(newHeader);
+			}
+		}
+	
+	CleanupStack::Pop(newHeaderSet);
+	return newHeaderSet;
+	}
+
+/**
+Constructor
+*/
+CObexHeaderSet::CObexHeaderSet()
+	{
+	}
+
+/**
+Destructor
+This method deletes each individual item that the pointer array 
+points at.
+
+@internalComponent
+*/
+CObexHeaderSet::~CObexHeaderSet()
+	{
+	iHeaders.ResetAndDestroy();
+	}
+
+/**
+Adds a header to the set.
+@param aHeader pointer to the header to be added.  Ownership is transferred on a
+		successful addition.
+@return A standard error code giving the results of the insertion.
+
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexHeaderSet::AddHeader(CObexHeader* aHeader)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	TInt ret = iHeaders.Append(aHeader);
+	
+	return ret;
+	}
+
+/**
+Deletes the current header from the headerset.
+
+@publishedAll
+@released
+ */
+EXPORT_C void CObexHeaderSet::DeleteCurrentHeader()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if ((iPos >= 0) && (iPos < iHeaders.Count()))
+		{
+		delete iHeaders[iPos];
+		iHeaders.Remove(iPos);
+		}
+
+	First();
+	}
+
+/**
+Sets a header mask.  Functions will only return values which the
+mask claims are interesting.  The only 'accessor' functions which
+ignore this mask are the NewL overloads which copy an existing
+header set.
+
+The object defaults to a mask where all headers are considered
+interesting.  Passing in a null parameter reverts to this behaviour.
+
+@param aMask The mask to use.
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeaderSet::SetMask(MObexHeaderCheck* aMask)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iMask = aMask;
+	First();
+	}
+
+/**
+Removes from this header set any headers which the mask claims are
+not interesting.  The position of the iterator is reset to the first
+remaining header.
+The mask will get reset to zero at the end of this method.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeaderSet::DeleteMasked()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	First();
+
+	if (!iMask)
+		{
+		return;
+		}
+	
+	TInt count = iHeaders.Count();
+	for (TInt pos = 0; pos < count; /*no iterative step*/)
+		{
+		TUint8 hi = iHeaders[pos]->HI();
+		if (!iMask->Interested(hi))
+			{
+			delete iHeaders[pos];
+			iHeaders.Remove(pos);
+			//do not increment pos as old [pos+1] element is now stored in [pos]
+			count--;
+			}
+		else
+			{
+			pos++;
+			}
+		}
+	
+	iMask = 0;
+	
+	First();
+	}
+
+/**
+Resets the mask, then advances the iterator to the first interesting header.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeaderSet::First() const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iPos = 0;
+
+	if (iMask)
+		{
+		iMask->Reset();
+		}
+	
+	if (Next(0) == KErrNotFound)
+		{
+		iPos = -1;
+		}
+	}
+
+/**
+Links the supplied header to the same underlying header that is used by the 
+iterator's current header.
+@param aHeader The header object to populate.
+@return KErrNotFound if the iterator is not currently pointing to a valid
+		header.
+@publishedAll
+@released	
+*/
+EXPORT_C TInt CObexHeaderSet::This(CObexHeader* aHeader) const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if (iPos < 0)
+		{
+		return KErrNotFound;
+		}
+	
+	aHeader->Set(iHeaders[iPos]);
+	return KErrNone;
+	}
+
+/**
+Advances the iterator to the next interesting header, skipping over the current header before
+starting to search.
+@return KErrNotFound if there are no more interesting headers in the set.
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexHeaderSet::Next() const
+	{
+	return Next(1);
+	}
+
+/**
+Advances the iterator to the next interesting header, skipping over aSkip headers before
+starting to search.
+@param aSkip The minimum number of headers to move on from the current position, 
+independant of whether a mask has been set or not.
+A value of zero therefore makes Next() essentially a no-op but presents the current
+header to the header filter again.
+@return KErrNotFound if there are no more interesting headers in the set.
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexHeaderSet::Next(TInt aSkip) const
+	{
+	// Don't log this function as it's too verbose.
+	//LOG_LINE
+	//LOG_FUNC
+
+	iPos += aSkip;
+	TInt count = iHeaders.Count();
+	
+	if (iMask)
+		{
+		for (; iPos < count; iPos++)
+			{
+			TUint8 hi = iHeaders[iPos]->HI();
+			if (iMask->Interested(hi))
+				break;
+			}
+		}
+
+	if (iPos >= count)
+		{
+		iPos = -1;
+		}
+	
+	return (iPos < 0) ? KErrNotFound : KErrNone;
+	}
+
+/**
+Returns the total number of headers in this set, ie. ignores the mask.
+@return Count of the total number of headers (masked and unmasked) in this set.
+@released
+*/
+EXPORT_C TInt CObexHeaderSet::Count() const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return iHeaders.Count();
+	}
+
+/**
+Returns the first instance of the header with the required HI value
+by inserting it into the supplied CObexHeader object.  This uses the
+standard iterator functionality, so is limited by the current mask, and
+starts from the current iterator position.
+@param aHI The header to search for.  Consult the Obex specification for values.
+@param aHeader The header object to populate.
+@return KErrNotFound if the header was not present.
+*/
+EXPORT_C TInt CObexHeaderSet::Find(TUint8 aHI, CObexHeader& aHeader) const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+    if (iPos >= iHeaders.Count()) 
+        {
+        // Already searched all available headers
+        return KErrNotFound;
+        }
+    
+    if (iPos >= 0)
+    	{
+		TUint8 hi = iHeaders[iPos]->HI();
+		TInt err = KErrNone;
+		while ((err == KErrNone) &&
+			   (hi != aHI))
+			{
+			err = Next();
+			if (err == KErrNone)
+				{
+				hi = iHeaders[iPos]->HI();
+				}
+			}
+		
+		if (hi == aHI)
+			{
+			aHeader.Set(iHeaders[iPos]);
+			return KErrNone;
+			}
+		else
+			{
+			return KErrNotFound;
+			}
+		}
+	else
+		{
+		return KErrNotFound;
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexheaderutil.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,209 @@
+// 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
+ @internalComponent
+*/
+
+#include <obex/internal/obexinternalheader.h>
+#include <obexheaders.h>
+#include "obexheaderutil.h"
+
+/**
+This function wraps the potential leaving CreateAndSetUnicodeHeaderL function in a
+handy TRAP, because all the functions that call it are non-leavers.
+
+@param aHI is the Header Information byte for this new header (2 MSBits should indicate a Unicode header)
+@param aUnicode is the Header Value for this new header
+
+@return A pointer to a new CObexHeader, or NULL if the construction failed.
+*/
+CObexHeader* IrOBEXHeaderUtil::CreateAndSetUnicodeHeader(const TUint8 aHI, const TDesC16& aUnicode)
+	{
+	CObexHeader* header = NULL;
+	TRAP_IGNORE(header = CreateAndSetUnicodeHeaderL(aHI, aUnicode));
+	return header;
+	}
+
+/**
+Creates a new Unicode header, with value as specified by aHI and aUnicode. This function will
+leave if construction of the header fails.
+
+@param aHI is the Header Information byte for this new header (2 MSBits should indicate a Unicode header)
+@param aUnicode is the Header Value for this new header
+
+@return A pointer to a new CObexHeader.
+*/	
+CObexHeader* IrOBEXHeaderUtil::CreateAndSetUnicodeHeaderL(const TUint8 aHI, const TDesC16& aUnicode)
+	{
+	CObexHeader* header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetUnicodeL(aHI, aUnicode);
+	CleanupStack::Pop(header);
+	return header;
+	}
+
+/**
+This function wraps the potential leaving CreateAndSetByteSeqHeaderL function in a 
+handy TRAP, because all the functions that call it are non-leavers.
+
+@param aHI is the Header Information byte for this new header (2 MSBits should indicate a Unicode header)
+@param aByteSeq is the Header Value for this new header
+
+@return A pointer to a new CObexHeader, or NULL if the construction failed.
+*/	
+CObexHeader* IrOBEXHeaderUtil::CreateAndSetByteSeqHeader(const TUint8 aHI, const TDesC8& aByteSeq)
+	{
+	CObexHeader* header = NULL;
+	TRAP_IGNORE(header = CreateAndSetByteSeqHeaderL(aHI, aByteSeq));
+	return header;
+	}
+
+/**
+Creates a new Byte Sequence header, with value as specified by aHI and aByteSeq. This function will
+leave if construction of the header fails.
+
+@param aHI is the Header Information byte for this new header (2 MSBits should indicate a Unicode header)
+@param aByteSeq is the Header Value for this new header
+
+@return A pointer to a new CObexHeader.
+*/
+CObexHeader* IrOBEXHeaderUtil::CreateAndSetByteSeqHeaderL(const TUint8 aHI, const TDesC8& aByteSeq)
+	{
+	CObexHeader* header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByteSeqL(aHI, aByteSeq);
+	CleanupStack::Pop(header);
+	return header;
+	}
+
+TInt IrOBEXHeaderUtil::ParseHeader(TObexInternalHeader& aHeader, CObexHeaderSet& aHeaderSet)
+	{
+	TUint headerType = aHeader.HIType();
+
+	switch (headerType)
+		{
+	case (TObexInternalHeader::EUnicode) :
+		{
+		HBufC* newHeader = HBufC::New(aHeader.HVSize());
+		if (!newHeader)
+			{
+			return KErrNoMemory;
+			}
+		//else
+		TPtr ptr(newHeader->Des()); 
+		
+		if(aHeader.GetHVText(ptr) == KErrNone) 
+			{
+			CObexHeader* unicodeHeader = NULL;
+			
+			unicodeHeader = IrOBEXHeaderUtil::CreateAndSetUnicodeHeader(aHeader.HI(), *newHeader);
+
+			if (!unicodeHeader)
+				{
+				delete newHeader;
+				newHeader = NULL;
+				return KErrNoMemory;
+				}
+
+			//Transfer ownership of pointer to CObexHeaderSet
+			if (aHeaderSet.AddHeader(unicodeHeader) != KErrNone)
+				{
+				delete newHeader;
+				newHeader = NULL;
+				delete unicodeHeader;
+				unicodeHeader = NULL;
+				return KErrNoMemory;
+				}
+			}
+		delete newHeader;
+		newHeader = NULL;
+		
+		break;
+		}
+
+	case (TObexInternalHeader::EByteSeq) :
+		{
+		TPtrC8 src(aHeader.HVByteSeq(), aHeader.HVSize());
+
+		CObexHeader* byteseqHeader = NULL;
+
+		byteseqHeader = IrOBEXHeaderUtil::CreateAndSetByteSeqHeader(aHeader.HI(), src);
+		if (!byteseqHeader)
+			{
+			return KErrNoMemory;
+			}
+
+		//Transfer ownership of pointer to CObexHeaderSet
+		if (aHeaderSet.AddHeader(byteseqHeader) != KErrNone)
+			{
+			delete byteseqHeader;
+			byteseqHeader = NULL;
+			return KErrNoMemory;
+			}
+
+		break;
+		}
+
+	case (TObexInternalHeader::E1Byte) :
+		{
+		CObexHeader* byteHeader = NULL;
+		TRAPD(err, byteHeader=CObexHeader::NewL());
+		if (err)
+			{
+			return err;
+			}
+			
+		byteHeader->SetByte(aHeader.HI(), (static_cast<TUint8>(aHeader.HVInt())));
+		//Transfer ownership of pointer to CObexHeaderSet
+		if(aHeaderSet.AddHeader(byteHeader) != KErrNone)
+			{
+			delete byteHeader;
+			byteHeader = NULL;
+			return KErrNoMemory;
+			}
+		break;
+		}
+
+	case (TObexInternalHeader::E4Byte) :
+		{
+		CObexHeader* fourByteHeader = NULL;
+		TRAPD(err, fourByteHeader = CObexHeader::NewL());
+		if (err)
+			{
+			return err;
+			}
+			
+		fourByteHeader->SetFourByte(aHeader.HI(), aHeader.HVInt());
+		//Transfer ownership of pointer to CObexHeaderSet
+		if(aHeaderSet.AddHeader(fourByteHeader) != KErrNone)
+			{
+			delete fourByteHeader;
+			fourByteHeader = NULL;
+			return KErrNoMemory;
+			}
+		break;
+		}
+
+	default :
+		{
+		break;
+		}
+		
+		}	//	End of switch
+		
+	return KErrNone;
+	}	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexnotifyhandlerbase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,66 @@
+// 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 <obexbase.h>
+#include "obexnotifyhandlerbase.h"
+
+/**
+@file
+@released
+@internalComponent
+*/
+
+/** Constructor.
+
+@param aObex The object to pass notifications to.
+*/
+CObexNotifyHandlerBase::CObexNotifyHandlerBase(CObex& aObex)
+	: iObex(aObex)
+	{
+	}
+
+/** Passes on Process notification.
+
+@param aPacket The packet to pass on to the CObex that will 
+			   handle this notification.
+*/
+void CObexNotifyHandlerBase::Process(CObexPacket& aPacket)
+	{
+	iObex.NotifyProcess(aPacket);
+	}
+
+/** Passes on Error notification.
+
+@param aError The error to pass on to the CObex that will 
+			  handle this notification.
+*/
+void CObexNotifyHandlerBase::Error(TInt aError)
+	{
+	iObex.NotifyError(aError);
+	}
+
+/** Passes on TransportUp notification.
+*/	
+void CObexNotifyHandlerBase::TransportUp()
+	{
+	iObex.NotifyTransportUp();
+	}
+
+/** Passes on TransportDown notification.
+*/	
+void CObexNotifyHandlerBase::TransportDown(TBool aForceTransportDeletion)
+	{
+	iObex.NotifyTransportDown(aForceTransportDeletion);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexnotifyhandlerclient.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+ @file
+ @released
+ @internalComponent
+*/
+
+#include "obexnotifyhandlerclient.h"
+
+/** Constructor.
+
+@param aObex The CObexClient to pass notifications onto.
+*/
+CObexNotifyHandlerClient::CObexNotifyHandlerClient(CObexClient& aObex)
+	: CObexNotifyHandlerBase(aObex)
+	{
+	}
+
+/** Signals that a packet process event has occurred.
+
+@param aEvent The event that has occurred.
+*/
+void CObexNotifyHandlerClient::SignalPacketProcessEvent(TObexPacketProcessEvent aEvent)
+	{
+	(static_cast<CObexClient&>(iObex)).SignalPacketProcessEvent(aEvent);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexnotifyhandlerserver.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+ @file
+ @released
+ @internalComponent
+*/
+
+#include "obexnotifyhandlerserver.h"
+
+/** Constructor.
+
+@param aObex The CObexServer to pass notifications onto.
+*/
+CObexNotifyHandlerServer::CObexNotifyHandlerServer(CObexServer& aObex)
+	: CObexNotifyHandlerBase(aObex)
+	{
+	}
+
+/** Signals that a packet process event has occurred.
+
+@param aEvent The event that has occurred.
+*/
+void CObexNotifyHandlerServer::SignalPacketProcessEvent(TObexPacketProcessEvent aEvent)
+	{
+	(static_cast<CObexServer&>(iObex)).SignalPacketProcessEvent(aEvent);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexobjectexpandedbaseobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,2361 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+*/
+
+#include <obex.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obex/internal/obexpacket.h>
+#include "logger.h"
+#include "OBEXUTIL.H"
+#include "obexheaderutil.h"
+
+IF_FLOGGING(_LIT8(KLogComponent, "obex");)
+
+/**
+Default constructor for ObexObjects
+@internalComponent
+*/
+CObexBaseObject::CObexBaseObject()
+	{
+	ResetHeaders();
+	}
+
+/** 
+Destructor. 
+*/
+CObexBaseObject::~CObexBaseObject()
+	{
+	FLOG(_L("CObexBaseObject Destructor\r\n"));
+	ResetHeaders();
+	if (iObexHeader)
+		{
+		delete iObexHeader;
+		}
+	
+	delete iHeaderSet;
+	}
+
+/**
+Sets header mask to 1's (include all), but valid mask to 0's (none valid).
+Also reset progress indicators to avoid any un-initialised transfer attempts
+@internalComponent
+*/
+void CObexBaseObject::ResetHeaders()
+	{
+	iHeaderMask = 0xFFFF;
+	iValidHeaders = 0x0000;
+	iSendProgress = EError;
+	iRecvProgress = EError;
+	iRecvBytes = 0;
+	
+	if (iHttp)
+		{
+		iHttp->ResetAndDestroy();
+		delete iHttp;
+		iHttp = NULL;
+		}
+
+	// Here iHeaderSet can be NULL. This method is called in 
+	// CObexBaseObject::CObexBaseObject() that is called before the 
+	// derived class ConstructL() method. iHeaderSet is constructed in 
+	// CreateHeaderStorageDataL() called from ConstructL(). 
+	// So, in the constructor it is always NULL.
+	// This method is also called in CObexBaseObject::Reset() where iHeaderSet
+	// will be valid.
+	
+	if (iHeaderSet)
+		{
+		iHeaderSet->SetMask(NULL);
+		while (iHeaderSet->Count())
+			{
+			iHeaderSet->DeleteCurrentHeader();
+			}
+		}
+	}
+
+/**
+@internalComponent
+*/
+void CObexBaseObject::CreateHeaderStorageDataL()
+	{
+	__ASSERT_DEBUG(!iHeaderSet, IrOBEXUtil::Panic(ENotNullPointer));	
+	iHeaderSet = CObexHeaderSet::NewL();
+
+	if (iObexHeader == NULL)
+		{
+		iObexHeader = CObexHeader::NewL();
+		}
+	}
+
+/**
+Set the connection id.
+This method will check the headerset for a connectionId header. If one if located,
+then this will be modified for the new HV value. If not, a new connectionId header
+will be added.
+
+@param aFourByte The connectionID to be set
+@internalComponent
+*/
+void CObexBaseObject::SetConnectionIdL(TUint32 aFourByte)
+	{
+	FLOG(_L(">>CObexBaseObject::SetConnectionIdL"));
+	
+	__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+	
+	//reset the mask so all headers are searched
+	//NB. SetMask sets the iterator at the start of the headerset
+	iHeaderSet->SetMask(NULL);
+
+	if (iHeaderSet->Find(TObexInternalHeader::EConnectionID, *iObexHeader) == KErrNone)
+		{
+		iHeaderSet->DeleteCurrentHeader();
+		}
+
+    CObexHeader* header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetFourByte(TObexInternalHeader::EConnectionID, aFourByte);
+
+	//Transfer ownership of pointer to CObexHeaderSet
+	LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+	CleanupStack::Pop(header);
+		
+	iValidHeaders |= KObexHdrConnectionID;
+	iHeaderMask |= KObexHdrConnectionID;
+
+	FLOG(_L("<<CObexBaseObject::SetConnectionIdL"));
+	}
+
+/**
+Returns the connection ID.
+
+@return	Returns KConnIDInvalid if no connectionID is set.
+@internalComponent
+*/
+TUint32 CObexBaseObject::ConnectionID()
+	{
+	if (iValidHeaders & KObexHdrConnectionID)
+		{
+		__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+		
+		//reset the mask so all headers are searched
+		//NB. SetMask sets the iterator at the start of the headerset
+		iHeaderSet->SetMask(NULL);
+
+		if (iHeaderSet->Find(TObexInternalHeader::EConnectionID, *iObexHeader) == KErrNone)
+			{
+			return (iObexHeader->AsFourByte());
+			}
+		else
+			{
+			return KConnIDInvalid;
+			}
+		}
+	else
+		{
+		return KConnIDInvalid;
+		}
+	}
+
+/** 
+Sets the Name attribute of the object.
+
+The Name is used to identify the object to the remote machine (or to identify 
+a received object). Note that in general, this is quite distinct from the 
+CObexFileObject::DataFile() attribute, which specifies where the body of the 
+object is stored. 
+
+@param aDesc Name attribute 
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::SetNameL (const TDesC& aDesc)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+	
+	//reset the mask so all headers are searched
+	//NB. SetMask sets the iterator at the start of the headerset
+	iHeaderSet->SetMask(NULL);
+
+	if (iHeaderSet->Find(TObexInternalHeader::EName, *iObexHeader) == KErrNone)
+		{
+		iHeaderSet->DeleteCurrentHeader();
+		}
+
+    CObexHeader* header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetUnicodeL(TObexInternalHeader::EName, aDesc);
+	//Transfer ownership of pointer to CObexHeaderSet
+	LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+	CleanupStack::Pop(header);
+	
+	iValidHeaders |= KObexHdrName;
+	}
+
+/** 
+Sets the Type attribute of the object. 
+
+This should be in the form of a valid IANA media type (see http://www.iana.org/assignments/media-types/index.html).
+
+@param aDesc Type attribute 
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::SetTypeL (const TDesC8& aDesc)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	TInt len = aDesc.Length();
+	// make sure length does not include any null terms
+	while(len && aDesc[len - 1] == 0)
+		{
+		--len;
+		};
+	TPtrC8 src = aDesc.Left(len);
+
+	//leave room for exactly one null term
+	HBufC8* buf = HBufC8::NewL(src.Length() + 1);
+	CleanupStack::PushL(buf);
+	TPtr8 type(buf->Des());
+	type.Copy(src);
+	type.Append(0);
+
+	__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+	
+	//reset the mask so all headers are searched
+	//NB. SetMask sets the iterator at the start of the headerset
+	iHeaderSet->SetMask(NULL);
+
+	if (iHeaderSet->Find(TObexInternalHeader::EType, *iObexHeader) == KErrNone)
+		{
+		iHeaderSet->DeleteCurrentHeader();
+		}
+
+    CObexHeader* header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByteSeqL(TObexInternalHeader::EType, type);
+
+	//Transfer ownership of pointer to CObexHeaderSet
+	LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+	CleanupStack::Pop(header);
+
+	CleanupStack::PopAndDestroy(buf);
+
+	iValidHeaders |= KObexHdrType;
+
+	}
+
+/** 
+Sets the Length attribute of the object, in bytes. 
+
+Note that this does not necessarily have to match the exact size of the body 
+data, but is used to give an indication of the size to the receiving end.
+
+@param aLength Length attribute of the object 
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::SetLengthL (const TUint32 aLength)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+	
+	//reset the mask so all headers are searched
+	//NB. SetMask sets the iterator at the start of the headerset
+	iHeaderSet->SetMask(NULL);
+
+	if (iHeaderSet->Find(TObexInternalHeader::ELength, *iObexHeader) == KErrNone)
+		{
+		iHeaderSet->DeleteCurrentHeader();
+		}
+
+    CObexHeader* header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetFourByte(TObexInternalHeader::ELength, aLength);
+	//Transfer ownership of pointer to CObexHeaderSet
+	LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+	CleanupStack::Pop(header);
+
+	iValidHeaders |= KObexHdrLength;
+	}
+
+/** 
+Sets the Time attribute of the object (stored in UTC).
+
+@param aLocalTime Time attribute in local time
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::SetTimeL (const TTime aLocalTime)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	// Convert local time to UTC
+	TTime utcTime(aLocalTime);
+	utcTime -= User::UTCOffset();
+	SetUtcTimeL(utcTime);
+	}
+
+/** 
+Sets the Time attribute of the object (stored in UTC).
+
+@param aUtcTime Time attribute in local time
+*/
+void CObexBaseObject::SetUtcTimeL (const TTime aUtcTime)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	TBuf<16> timebuf;
+	aUtcTime.FormatL(timebuf, _L("%F%Y%M%DT%H%T%SZ"));
+	TBuf8<16> narrowBuf;
+	narrowBuf.Copy(timebuf);
+	SetTimeHeaderL(narrowBuf);
+
+	iValidHeaders |= KObexHdrTime;
+	}
+
+/**
+Add a descriptor as the one and only Time header in an object.
+
+@param aTimeDes A narrow descriptor which will be stored in the object.
+*/
+void CObexBaseObject::SetTimeHeaderL(const TDesC8& aTimeDes)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+	
+	//reset the mask so all headers are searched
+	//NB. SetMask sets the iterator at the start of the headerset
+	iHeaderSet->SetMask(NULL);
+
+	if (iHeaderSet->Find(TObexInternalHeader::ETime, *iObexHeader) == KErrNone)
+		{
+		iHeaderSet->DeleteCurrentHeader();
+		}
+	
+	CObexHeader* header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByteSeqL(TObexInternalHeader::ETime, aTimeDes);
+
+	//Transfer ownership of pointer to CObexHeaderSet
+	LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+	CleanupStack::Pop(header);
+	}
+
+/** 
+Sets the Description attribute of the object. 
+
+This is currently the easiest way to send proprietary information along with 
+an object.
+
+@param aDesc Description attribute 
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::SetDescriptionL (const TDesC& aDesc)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+	
+	//reset the mask so all headers are searched
+	//NB. SetMask sets the iterator at the start of the headerset
+	iHeaderSet->SetMask(NULL);
+
+	if (iHeaderSet->Find(TObexInternalHeader::EDescription, *iObexHeader) == KErrNone)
+		{
+		iHeaderSet->DeleteCurrentHeader();
+		}
+
+    CObexHeader* header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetUnicodeL(TObexInternalHeader::EDescription, aDesc);
+	//Transfer ownership of pointer to CObexHeaderSet
+	LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+	CleanupStack::Pop(header);
+
+	iValidHeaders |= KObexHdrDescription;
+	}
+
+/**	
+Sets the Application Parameters attribute of the object.
+
+  This is expected to be of the format Tag-Length-Value, but this is not enforced.
+  
+@param aDesc Application Parameters attribute 
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::SetAppParamL (const TDesC8& aDesc)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	FLOG(_L("CObexBaseObject::SetAppParamL"));
+
+	__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+	
+	//reset the mask so all headers are searched
+	//NB. SetMask sets the iterator at the start of the headerset
+	iHeaderSet->SetMask(NULL);
+
+	if (iHeaderSet->Find(TObexInternalHeader::EAppParam, *iObexHeader) == KErrNone)
+		{
+		iHeaderSet->DeleteCurrentHeader();
+		}
+	CObexHeader* header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByteSeqL(TObexInternalHeader::EAppParam, aDesc);
+	//Transfer ownership of pointer to CObexHeaderSet
+	LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+	CleanupStack::Pop(header);
+	
+	iValidHeaders |= KObexHdrAppParam;
+	}
+
+/** 
+Sets the Target attribute of the object.
+
+Generally, this will only have any useful meaning if the session Who attribute 
+of the remote machine is recognised, and particularly, when connected to a 
+strict peer (see CObex::IsStrictPeer()).
+
+@param aDesc Target attribute 
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::SetTargetL (const TDesC8& aDesc)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+	
+	//reset the mask so all headers are searched
+	//NB. SetMask sets the iterator at the start of the headerset
+	iHeaderSet->SetMask(NULL);
+
+	if (iHeaderSet->Find(TObexInternalHeader::ETarget, *iObexHeader) == KErrNone)
+		{
+		iHeaderSet->DeleteCurrentHeader();
+		}
+
+	CObexHeader* header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByteSeqL(TObexInternalHeader::ETarget, aDesc);
+	//Transfer ownership of pointer to CObexHeaderSet
+	LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+	CleanupStack::Pop(header);
+
+	iValidHeaders |= KObexHdrTarget;
+	}
+
+/** 
+Add an Http header.
+
+@param aDesc HTTP header to be added to the object's collection of HTTP headers 
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::AddHttpL (const TDesC8& aDesc)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+    CObexHeader* header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByteSeqL(TObexInternalHeader::EHttp, aDesc);
+	
+	__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+	
+	//Transfer ownership of pointer to CObexHeaderSet
+	LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+	CleanupStack::Pop(header);
+
+	if (!iHttp)
+		{
+		iHttp = new(ELeave) RPointerArray<HBufC8>(2);
+		}
+	
+	HBufC8* buf = aDesc.AllocLC();
+	LEAVEIFERRORL(iHttp->Append(buf));
+	CleanupStack::Pop(buf);
+	
+	iValidHeaders |= KObexHdrHttp;  
+	}
+
+/**
+Adds a CObexHeader into the CObexHeaderSet
+
+@param aHeader A Pointer to a CObexHeader to be added to the CObexHeaderSet
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::AddHeaderL(CObexHeader& aHeader)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if (aHeader.HI() == TObexInternalHeader::EHttp)
+		{
+		// Add the HTTP header into the iHttp array to keep old and new
+		// http header storage consistent.
+		//
+		if (!iHttp)
+			{
+			iHttp = new(ELeave) RPointerArray<HBufC8>(2);
+			}
+	
+		HBufC8* buf = (aHeader.AsByteSeq()).AllocLC();
+		LEAVEIFERRORL(iHttp->Append(buf));
+		CleanupStack::Pop();
+	
+		iValidHeaders |= KObexHdrHttp;  
+		}
+
+	__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+	
+	//Transfer ownership of pointer to CObexHeaderSet
+	LEAVEIFERRORL(iHeaderSet->AddHeader(&aHeader));
+
+	switch (aHeader.HI())
+		{
+	case (TObexInternalHeader::EName) :
+		{
+		iValidHeaders |= KObexHdrName;  
+		break;
+		}
+	case (TObexInternalHeader::EType) :
+		{
+		iValidHeaders |= KObexHdrType;  
+		break;
+		}
+	case (TObexInternalHeader::ETime) :
+		{
+		iValidHeaders |= KObexHdrTime;  
+		break;
+		}
+	case (TObexInternalHeader::EConnectionID) :
+		{
+		iValidHeaders |= KObexHdrConnectionID;  
+		break;
+		}
+	case (TObexInternalHeader::ELength) :
+		{
+		iValidHeaders |= KObexHdrLength;  
+		break;
+		}
+	case (TObexInternalHeader::EDescription) :
+		{
+		iValidHeaders |= KObexHdrDescription;  
+		break;
+		}
+	case (TObexInternalHeader::ECount) :
+		{
+		iValidHeaders |= KObexHdrCount;  
+		break;
+		}
+	case (TObexInternalHeader::EAppParam) :
+		{
+		iValidHeaders |= KObexHdrAppParam;  
+		break;
+		}
+	case (TObexInternalHeader::ETarget) :
+		{
+		iValidHeaders |= KObexHdrTarget;  
+		break;
+		}
+	case (TObexInternalHeader::ECreatorID) :
+		{
+		iValidHeaders |= KObexHdrCreatorID;  
+		break;
+		}
+	case (TObexInternalHeader::EWanUUID) :
+		{
+		iValidHeaders |= KObexHdrWanUUID;  
+		break;
+		}
+	case (TObexInternalHeader::EObjectClass) :
+		{
+		iValidHeaders |= KObexHdrObjectClass;  
+		break;
+		}
+	case (TObexInternalHeader::EEndOfBody) :
+		{
+		__ASSERT_ALWAYS(DataSize() == 0, IrOBEXUtil::Panic(EAddingInvalidEoBHeader));
+		iValidHeaders |= KObexHdrEndOfBody;
+		break;
+		}
+	default : 
+		{
+		if ((aHeader.HI() & 0x30) != 0)
+			{
+			iValidHeaders |= KObexHdrUserDefined;  
+			}
+		break;
+		}
+	}
+	}
+
+/** 
+Resets the object, to make it represent nothing. 
+
+Call this before setting a CObexObject to represent a new object. 
+	
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::Reset()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	ResetHeaders();
+	ResetData();
+	}
+
+/**
+Makes a first level guess at setting the mime type from the
+file extension.
+
+This API is deprecated and may be removed at any time. For any production 
+applications, the versit and the Application architecture (see 
+RApaLsSession::RecognizeData) provide far more flexibilty and robustness.
+
+@deprecated 6.1
+@internalComponent
+*/
+void CObexBaseObject::GuessTypeFromExtL(const TDesC& aExt)
+	{
+	_LIT(KVcfType, ".vcf");
+	_LIT(KVcsType, ".vcs");
+	_LIT(KTxtType, ".txt");
+	_LIT8(KVcard, "text/x-vCard");
+	_LIT8(KVcalendar, "text/x-vCalendar");
+	_LIT8(KTextPlain, "text/plain");
+	
+	iValidHeaders &= ~KObexHdrType;	// Default, if no others match
+	if(!aExt.CompareC(KVcfType))
+		{
+		SetTypeL(KVcard);
+		return;
+		}
+    if(!aExt.CompareC(KVcsType))
+		{ 
+        SetTypeL(KVcalendar);
+        return;
+        }
+	if(!aExt.CompareC(KTxtType))
+		{
+		SetTypeL(KTextPlain);
+		return;
+		}
+	}
+
+/** 
+Gets the object's Name attribute.
+
+@return Object's Name attribute or KNullDesC if it has not been set 
+	
+@publishedAll
+@released
+*/
+EXPORT_C const TDesC& CObexBaseObject::Name()	
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if (iValidHeaders & KObexHdrName)
+		{
+		__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+		
+		//reset the mask so all headers are searched
+		//NB. SetMask sets the iterator at the start of the headerset
+		iHeaderSet->SetMask(NULL);
+
+		// search for a Name header in the headerset
+		if (iHeaderSet->Find(TObexInternalHeader::EName, *iObexHeader) == KErrNone)
+			{
+			//header is found so return the HV as Unicode
+			return (iObexHeader->AsUnicode());
+			}
+		else
+			{
+			return (KNullDesC);
+			}
+		}
+	else
+		{
+		return (KNullDesC);
+		}
+	}
+
+/** 
+Gets the object's Type attribute.
+
+@return Object's Type attribute or KNullDesC8 if it has not been set 
+	
+@publishedAll
+@released
+*/
+EXPORT_C const TDesC8& CObexBaseObject::Type()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if (iValidHeaders & KObexHdrType)
+		{
+		__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+		
+		//reset the mask so all headers are searched
+		//NB. SetMask sets the iterator at the start of the headerset
+		iHeaderSet->SetMask(NULL);
+
+		// search for a Type header in the headerset
+		if (iHeaderSet->Find(TObexInternalHeader::EType, *iObexHeader) == KErrNone)
+			{
+			//header is found so return the HV as ByteSequence
+			return (iObexHeader->AsByteSeq());
+			}
+		else
+			{
+			return (KNullDesC8);
+			}
+		}
+	else
+		{
+		return (KNullDesC8);
+		}
+	}
+
+/** 
+Gets the object's Length attribute.
+
+Note this might not match the size of the file (if any) to transfer.
+
+@return Object's Length attribute or 0 if it has not been set 
+	
+@publishedAll
+@released
+*/
+EXPORT_C TUint32 CObexBaseObject::Length()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if (iValidHeaders & KObexHdrLength)
+		{
+		__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+		
+		//reset the mask so all headers are searched
+		//NB. SetMask sets the iterator at the start of the headerset
+		iHeaderSet->SetMask(NULL);
+
+		// search for a Length header in the headerset
+		if (iHeaderSet->Find(TObexInternalHeader::ELength, *iObexHeader) == KErrNone)
+			{
+			//header is found so return the HV as FourByte
+			return (iObexHeader->AsFourByte());
+			}
+		else
+			{
+			return (0);
+			}
+		}
+	else
+		{
+		return (0);
+		}
+	}
+	
+/**
+Firstly updates the iHttp list, ensuring that the entries are 
+the same as those HTTP headers within the header set.
+(The iHttp list could have contained old headers that were removed from
+the headerset using the DeleteMasked operation)
+Returns a pointer to the Http header array or null if no headers defined.
+@return	A pointer to the Http header array or null if no headers defined 
+	
+@publishedAll
+@released
+**/
+EXPORT_C const RPointerArray<HBufC8>* CObexBaseObject::Http() const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	// if there are headers in the iHttp list
+	if (iHttp && (iHttp->Count()))
+		{
+		
+		TInt httpCount = 0;
+
+		__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+		
+		//reset the mask so all headers are searched
+		//NB. SetMask sets the iterator at the start of the headerset
+		iHeaderSet->SetMask(NULL);
+
+		TInt err = iHeaderSet->Find(TObexInternalHeader::EHttp, *iObexHeader);
+		while (err == KErrNone)
+			{
+			httpCount++;
+			err = iHeaderSet->Next();
+			if (!err)
+				{
+		 		err = iHeaderSet->Find(TObexInternalHeader::EHttp, *iObexHeader);
+		 		}
+			}	
+			
+		// check if number of HTTP in iHttp equals number in header set
+		// NB. if equal then they must be the same headers due to the way that the
+		// addition of HTTP headers has been implemented (ie. both AddHttpL and 
+		// AddHeader for Http, will update the iHTTP list, as well as HeaderSet)
+		//
+		if (httpCount != (iHttp->Count()))
+			{
+			// reset the header iterator to the start of the headerset
+			iHeaderSet->First();
+
+			TInt arrayIndex = 0;
+			
+			// search for an Http header in the headerset
+		 	err = iHeaderSet->Find(TObexInternalHeader::EHttp, *iObexHeader);
+
+			while (err == KErrNone)
+				{
+				//delete items from the iHttp list until an HTTP header with the same HV value
+				//as the HTTP header in the headerset has been located.
+				while ((iObexHeader->AsByteSeq()) != (((*iHttp)[arrayIndex])->Des()))
+					{
+					delete (*iHttp)[arrayIndex];
+					(*iHttp).Remove(arrayIndex);
+					}
+				
+				arrayIndex++;
+				
+				// search for an Http header in the headerset
+				iHeaderSet->Next();
+			 	err = iHeaderSet->Find(TObexInternalHeader::EHttp, *iObexHeader);
+				}
+
+			// if the number of HTTP headers in the headerset is different to the iHTTP count
+			// then there must be some remaining headers at the end of the list, so remove 
+			// them
+			while (httpCount < (iHttp->Count()))
+				{
+				delete (*iHttp)[arrayIndex];
+				(*iHttp).Remove(arrayIndex);
+				}
+			}
+
+		// if there are no elements in the iHttp list, delete the list and return NULL			
+		if (iHttp->Count() == 0)
+			{
+			if (iHttp)
+				{
+				iHttp->ResetAndDestroy();
+				delete iHttp;
+				iHttp = NULL;
+				}
+	
+			return NULL;
+			}
+		else
+			{
+			//return the iHttp pointer
+			return iHttp;
+			}
+		}
+	else //iHttp && iHttp->Count
+		{
+		return NULL;
+		}
+	}
+	
+/**
+Take time string specified in ISO8601 format and convert to a TTime
+@param aTime Time descriptor in ISO8601 format
+@param aResult Object to place resultant local time. Set to 0 if conversion fails.
+*/
+void ParseISO8601Time(const TDesC& aTimeDes, TTime& aResult)
+	{
+	LOG_STATIC_FUNC_ENTRY
+	FLOG(_L8("Parsing ISO 8601 format time"));
+	
+	TInt yr, mn, dy, hr, mi, sc;
+	TLex lex(aTimeDes);
+	aResult = 0; // return TTime(0) by default
+ 
+	// Get date components
+	TUint num;
+	if (lex.Val(num) != KErrNone)
+		{
+		FLOG(_L8("Date not found"));
+		return;
+		}
+
+	dy = num % 100;
+	num /= 100;
+	mn = num % 100;
+	num /= 100;
+	yr = num;
+
+	if (lex.Get() != 'T')
+		{
+		FLOG(_L8("Char 'T' not found"));
+		return;
+		}
+	
+	// Get time components
+	if (lex.Val(num) != KErrNone)
+		{
+		FLOG(_L8("Time not found"));
+		return;
+		}
+	sc = num % 100;
+	num /= 100;
+	mi = num % 100;
+	num /= 100;
+	hr = num;
+ 
+	// Convert components into a TTime
+	TDateTime dt;
+	if (dt.Set(yr,TMonth(mn-1),(dy-1),hr,mi,sc,0) != KErrNone) // day and month are zero based in TDateTime::Set
+		{
+		FLOG(_L8("Failed to convert time"));
+		return;
+		}
+	aResult = dt;
+
+	// If time is in UTC, convert to local time
+	if (lex.Get() == 'Z')
+		{
+		aResult += User::UTCOffset(); // includes any daylight saving correction
+		}
+	}
+
+/**
+Returns the time attribute of the object in local time.
+Returns TTime (0) if no valid time has been set.
+
+@return Object's Time attribute in local time or TTime(0) if it has not been set 
+	
+@publishedAll
+@released
+**/
+EXPORT_C const TTime CObexBaseObject::Time()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	TTime newTime = TTime(0);
+	
+	if (iValidHeaders & KObexHdrTime)
+		{
+		__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+		
+		//reset the mask so all headers are searched
+		//NB. SetMask sets the iterator at the start of the headerset
+		iHeaderSet->SetMask(NULL);
+
+		if (iHeaderSet->Find(TObexInternalHeader::ETime, *iObexHeader) == KErrNone)
+			{
+			TBuf16<16> localbuf;
+			localbuf.Copy(iObexHeader->AsByteSeq());
+
+			ParseISO8601Time(localbuf, newTime);
+			}
+		}
+	return newTime;
+	}
+
+/** 
+Gets the object's Description attribute.
+
+@return Object's Name attribute or KNullDesC if it has not been set 
+	
+@publishedAll
+@released
+*/
+EXPORT_C const TDesC& CObexBaseObject::Description()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if (iValidHeaders & KObexHdrDescription)
+		{
+		__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+		
+		//reset the mask so all headers are searched
+		//NB. SetMask sets the iterator at the start of the headerset
+		iHeaderSet->SetMask(NULL);
+
+		// search for a Description header in the headerset
+		if (iHeaderSet->Find(TObexInternalHeader::EDescription, *iObexHeader) == KErrNone)
+			{
+			//header is found so return the HV as Unicode
+			return (iObexHeader->AsUnicode());
+			}
+		else
+			{
+			return (KNullDesC);
+			}
+		}
+	else
+		{
+		return (KNullDesC);
+		}
+	}
+
+/**	
+Gets the object's Application Parameters attribute
+
+This function does not parse the Application Parameters attribute into the 
+expected Tag-Length-Value format.
+
+@return Object's Application Parameters attribute, or KNullDesC8 if none has been set 
+	
+@publishedAll
+@released
+*/
+EXPORT_C const TDesC8& CObexBaseObject::AppParam() const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if (iValidHeaders & KObexHdrAppParam)
+		{
+		__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+		
+		//reset the mask so all headers are searched
+		//NB. SetMask sets the iterator at the start of the headerset
+		iHeaderSet->SetMask(NULL);
+
+		// search for a AppParam header in the headerset
+		if (iHeaderSet->Find(TObexInternalHeader::EAppParam, *iObexHeader) == KErrNone)
+			{
+			//header is found so return the HV as ByteSeq
+			return (iObexHeader->AsByteSeq());
+			}
+		else
+			{
+			return (KNullDesC8);
+			}
+		}
+	else
+		{
+		return (KNullDesC8);
+		}
+	}
+
+/** 
+Gets the object's Target attribute.
+
+@return Object's Target attribute or KNullDesC8 if it has not been set 
+	
+@publishedAll
+@released
+*/
+EXPORT_C const TDesC8& CObexBaseObject::Target()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if (iValidHeaders & KObexHdrTarget)
+		{
+		__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+		
+		//reset the mask so all headers are searched
+		//NB. SetMask sets the iterator at the start of the headerset
+		iHeaderSet->SetMask(NULL);
+
+		// search for a Target header in the headerset
+		if (iHeaderSet->Find(TObexInternalHeader::ETarget, *iObexHeader) == KErrNone)
+			{
+			//header is found so return the HV as ByteSeq
+			return (iObexHeader->AsByteSeq());
+			}
+		else
+			{
+			return (KNullDesC8);
+			}
+		}
+	else
+		{
+		return (KNullDesC8);
+		}
+	}
+
+/**
+@publishedAll
+@released
+@return A const reference to the HeaderSet object used by this object.
+@see CObexHeaderSet
+*/
+EXPORT_C const CObexHeaderSet& CObexBaseObject::HeaderSet() const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return *iHeaderSet;
+	}
+	
+/**
+@publishedAll
+@released
+@return A reference to the HeaderSet object used by this object.
+@see CObexHeaderSet
+*/
+EXPORT_C CObexHeaderSet& CObexBaseObject::HeaderSet()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return *iHeaderSet;
+	}
+
+/**
+Prepare the object for sending. Each packet sent will contain aOpcode.
+	
+@param aOpcode
+@return KErrNone
+@internalComponent
+*/
+TInt CObexBaseObject::InitSend(TObexOpcode aOpcode)
+	{
+	FLOG(_L("CObexBaseObject::InitSend"));
+	
+	iSendHeaders = 0;
+	iSendBytes = 0;
+	iSendOpcode = aOpcode;
+	iSendProgress = EContinue;
+
+	return KErrNone;
+	}
+
+/**
+Fill up the Connect command with the appropriate headers.
+
+@param aPacket The packet to be filled
+@internalComponent
+*/
+void CObexBaseObject::PrepareConnectionHeader(CObexPacket &aPacket)
+	{
+	FLOG(_L("CObexBaseObject::PrepareConnectionHeader\r\n"));
+	TObexInternalHeader header;
+	
+	TObexHeaderMask remaininghdr = static_cast<TObexHeaderMask>(iValidHeaders & iHeaderMask);
+	if(remaininghdr)
+		{// ...there are some valid, unsent headers left to send.
+		//the Target header should be sent first
+		if(remaininghdr & KObexHdrTarget) 
+			{
+			FLOG(_L("PrepareConnectionHeader - Preparing Target Header\r\n"));
+
+			if ( Target() != KNullDesC8 )
+				{
+				header.Set(TObexInternalHeader::ETarget, (const_cast<TUint8*>(Target().Ptr())), Target().Size());
+
+				if(aPacket.InsertData(header)) 
+					{
+					iSendHeaders |= KObexHdrTarget;
+					iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+					}
+				}
+			}
+		}
+	}
+
+/**
+Fill up aPacket with whatever is left to be sent of the object.
+Trys to get attribute headers out asap,
+and tacks as much of the data part of the object onto the end of each 
+packet as will fit. Returned value goes to EComplete on the call *after* 
+the final packet has been written(i.e. indicates nothing left to do).
+
+@param aPacket The packet to be filled
+@return Progress in writing out the object
+@internalComponent
+*/
+CObexBaseObject::TProgress CObexBaseObject::PrepareNextSendPacket(CObexPacket &aPacket)
+	{
+	FLOG(_L("CObexBaseObject::PrepareNextSendPacket\r\n"));
+	
+	// iHeaderSet is often dereferenced in this method. So it worth to check it
+	// at the beginning
+	
+	__ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+	
+	if(iSendProgress == ELastPacket)
+		{
+		/*
+		If the state was 'ELastPacket' as a result of the 
+		last call to this method, then the last packet will
+		now have been sent!
+		*/
+		iSendProgress = EComplete;
+		}
+		
+	if(iSendProgress != EContinue)
+		{
+		FLOG(_L("PrepareNextSendPacket - immediate exit\r\n"));
+		return(iSendProgress);
+		}
+		
+	TObexInternalHeader header;
+	aPacket.Init(iSendOpcode); 
+	TInt startspace = aPacket.RemainingInsertSpace();
+
+	TObexHeaderMask remaininghdr = static_cast<TObexHeaderMask>(~iSendHeaders & iValidHeaders & iHeaderMask);
+	TBool suppressDataHeader = EFalse;
+	TBool firstHeader = ETrue;
+	if(remaininghdr)
+		{// ...there are some valid, unsent headers left to send.
+		if(remaininghdr & KObexHdrTarget) 
+			{
+			FLOG(_L("PrepareConnectionHeader - Preparing Target Header\r\n"));
+
+			header.Set(TObexInternalHeader::ETarget, (const_cast<TUint8*> (Target().Ptr())), Target().Size());
+			if(aPacket.InsertData(header)) 
+				{
+				iSendHeaders |= KObexHdrTarget;
+				iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+				//set that a header has been added to this current packet
+				firstHeader = EFalse;
+				}
+			}
+			
+		if (remaininghdr & KObexHdrConnectionID)
+			{
+			FLOG(_L("PrepareNextSendPacket - preparing EConnectionID header\r\n"));
+
+			TUint32 connID = ConnectionID();
+			if ( connID != KConnIDInvalid )
+				{
+
+				TUint32 newConnectionID = connID;
+              	header.Set(TObexInternalHeader::EConnectionID, newConnectionID);
+              	
+				if(aPacket.InsertData(header)) 
+					{
+					iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+					iSendHeaders |= KObexHdrConnectionID;
+					//set that a header has been added to this current packet
+					firstHeader = EFalse;
+					}
+				}
+			else
+				{
+				iValidHeaders &= ~KObexHdrConnectionID;
+				}
+			}
+
+		if(remaininghdr & KObexHdrName) 
+			{ 
+			FLOG(_L("PrepareNextSendPacket - preparing EName header\r\n"));
+
+			header.Set(TObexInternalHeader::EName, Name());
+			if(aPacket.InsertData(header)) 
+				{
+				iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+				iSendHeaders |= KObexHdrName;
+				//set that a header has been added to this current packet
+				firstHeader = EFalse;
+				}
+			}
+
+		if(remaininghdr & KObexHdrLength) 
+			{ 
+			FLOG(_L("PrepareNextSendPacket - preparing ELength header\r\n"));
+
+			header.Set(TObexInternalHeader::ELength, Length()); 
+			if(aPacket.InsertData(header)) 
+				{
+				iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+				iSendHeaders |= KObexHdrLength;
+				//set that a header has been added to this current packet
+				firstHeader = EFalse;
+				}
+			}
+		if(remaininghdr & KObexHdrType) 
+			{ 
+			FLOG(_L("PrepareNextSendPacket - preparing EType header\r\n"));
+
+			header.Set(TObexInternalHeader::EType, (const_cast<TUint8*> (Type().Ptr())), Type().Size());
+					
+			if(aPacket.InsertData(header)) 
+				{
+				iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+				iSendHeaders |= KObexHdrType;
+				//set that a header has been added to this current packet
+				firstHeader = EFalse;
+				}
+			}
+			
+		if(remaininghdr & KObexHdrDescription) 
+			{ 
+			FLOG(_L("PrepareNextSendPacket - preparing EDescription header\r\n"));
+
+			header.Set(TObexInternalHeader::EDescription, Description()); 
+			if(aPacket.InsertData(header)) 
+				{
+				iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+				iSendHeaders |= KObexHdrDescription;
+				//set that a header has been added to this current packet
+				firstHeader = EFalse;
+				}
+			}
+		if(remaininghdr & KObexHdrCount) 
+			{
+			FLOG(_L("PrepareNextSendPacket - preparing ECount header\r\n"));
+
+			if (iValidHeaders & KObexHdrCount)
+				{
+				//reset the mask so all headers are searched
+				//NB. SetMask sets the iterator at the start of the headerset
+				iHeaderSet->SetMask(NULL);
+
+				if (iHeaderSet->Find(TObexInternalHeader::ECount, *iObexHeader) == KErrNone)
+					{
+
+					TUint32 newCount = iObexHeader->AsFourByte();
+					header.Set(TObexInternalHeader::ECount, newCount);
+						
+					if(aPacket.InsertData(header)) 
+						{
+						iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+						iSendHeaders |= KObexHdrCount;
+						//set that a header has been added to this current packet
+						firstHeader = EFalse;
+						}
+					}
+				else
+					{
+					iValidHeaders &= ~KObexHdrCount;
+					}
+				}
+			else
+				{
+				iValidHeaders &= ~KObexHdrCount;
+				}
+			}
+		if (remaininghdr & KObexHdrAppParam)
+			{
+			FLOG(_L("PrepareNextSendPacket - preparing EAppParam header\r\n"));
+
+			header.Set(TObexInternalHeader::EAppParam, (const_cast<TUint8*> (AppParam().Ptr())), AppParam().Size());
+
+			if (aPacket.InsertData(header))
+				{
+				iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+				iSendHeaders |= KObexHdrAppParam;
+				//set that a header has been added to this current packet
+				firstHeader = EFalse;
+				}
+			}
+		
+		if (remaininghdr & KObexHdrHttp)
+			{
+			//no need to check iValidHeaders as if it is false then remaininghdr would be too.
+
+			//reset the mask so all headers are searched
+			//NB. SetMask sets the iterator at the start of the headerset
+			iHeaderSet->SetMask(NULL);
+
+			TBool headerFound = EFalse;
+			TUint headerFoundCount = 0;
+			TUint headerHandledCount = 0;
+			
+			TInt err = iHeaderSet->Find(TObexInternalHeader::EHttp, *iObexHeader);
+
+			while (err == KErrNone)
+				{
+				headerFoundCount++;
+				
+				if ( (!(iObexHeader->Attributes() & CObexHeader::ESent)) &&
+					 (!(iObexHeader->Attributes() & CObexHeader::ESuppressed)) )
+					{
+					//Unsent and Unsuppressed Http header had been found
+					headerFound = ETrue;
+
+					header.Set(TObexInternalHeader::EHttp, (const_cast<TUint8*> ((iObexHeader->AsByteSeq()).Ptr())), (iObexHeader->AsByteSeq()).Size());
+				
+					if(aPacket.InsertData(header)) 
+						{
+						iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+						headerHandledCount++;
+		
+						//set that a header has been added to this current packet
+						firstHeader = EFalse;
+						}
+					else if (firstHeader)
+						{
+						// Had problems inserting the first HTTP header, Set it to suppressed.
+						// (this is also the first header in the packet, so we had the full
+						// packet size available)
+						iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESuppressed));
+						headerHandledCount++;
+						}
+					}
+				else
+					{
+					//Header has previously been sent/suppressed
+					headerHandledCount++;
+					}
+
+				iHeaderSet->Next();
+				err = iHeaderSet->Find(TObexInternalHeader::EHttp, *iObexHeader);
+				}
+		
+			if (headerFoundCount == headerHandledCount)
+				{
+				//All HTTP headers have been sent (or suppressed)
+				iSendHeaders |= KObexHdrHttp;
+				}
+			
+			// an unsent http header cannot be found in headerset so set flag to invalid
+			if (headerFound == EFalse)
+				{
+				iValidHeaders &= ~KObexHdrHttp;
+				}
+			}
+
+		if(remaininghdr & KObexHdrCreatorID) 
+			{
+			FLOG(_L("PrepareNextSendPacket - preparing ECreatorID header\r\n"));
+
+			if (iValidHeaders & KObexHdrCreatorID)
+				{
+				//reset the mask so all headers are searched
+				//NB. SetMask sets the iterator at the start of the headerset
+				iHeaderSet->SetMask(NULL);
+
+				if (iHeaderSet->Find(TObexInternalHeader::ECreatorID, *iObexHeader) == KErrNone)
+					{
+					header.Set(TObexInternalHeader::ECreatorID, iObexHeader->AsFourByte());
+					if(aPacket.InsertData(header)) 
+						{
+						iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+						iSendHeaders |= KObexHdrCreatorID;
+						//set that a header has been added to this current packet
+						firstHeader = EFalse;
+						}
+					}
+				else
+					{
+					iValidHeaders &= ~KObexHdrCreatorID;
+					}
+				}
+			else
+				{
+				iValidHeaders &= ~KObexHdrCreatorID;
+				}
+			}
+
+		if(remaininghdr & KObexHdrWanUUID) 
+			{
+			FLOG(_L("PrepareNextSendPacket - preparing EWanUUID header\r\n"));
+			if (iValidHeaders & KObexHdrWanUUID)
+				{
+				//reset the mask so all headers are searched
+				//NB. SetMask sets the iterator at the start of the headerset
+				iHeaderSet->SetMask(NULL);
+
+				if (iHeaderSet->Find(TObexInternalHeader::EWanUUID, *iObexHeader) == KErrNone)
+					{
+					header.Set(TObexInternalHeader::EWanUUID, (const_cast<TUint8*> ((iObexHeader->AsByteSeq()).Ptr())), (iObexHeader->AsByteSeq()).Size());
+					if(aPacket.InsertData(header)) 
+						{
+						iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+						iSendHeaders |= KObexHdrWanUUID;
+						//set that a header has been added to this current packet
+						firstHeader = EFalse;
+						}
+					}
+				else
+					{
+					iValidHeaders &= ~KObexHdrWanUUID;
+					}
+				}
+			else
+				{
+				iValidHeaders &= ~KObexHdrWanUUID;
+				}
+			}
+
+		if(remaininghdr & KObexHdrObjectClass) 
+			{
+			FLOG(_L("PrepareNextSendPacket - preparing EObjectClass header\r\n"));
+			if (iValidHeaders & KObexHdrObjectClass)
+				{
+				//reset the mask so all headers are searched
+				//NB. SetMask sets the iterator at the start of the headerset
+				iHeaderSet->SetMask(NULL);
+
+				if (iHeaderSet->Find(TObexInternalHeader::EObjectClass, *iObexHeader) == KErrNone)
+					{
+					header.Set(TObexInternalHeader::EObjectClass, (const_cast<TUint8*> ((iObexHeader->AsByteSeq()).Ptr())), (iObexHeader->AsByteSeq()).Size());
+					if(aPacket.InsertData(header)) 
+						{
+						iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+						iSendHeaders |= KObexHdrObjectClass;
+						//set that a header has been added to this current packet
+						firstHeader = EFalse;
+						}
+					}
+				else
+					{
+					iValidHeaders &= ~KObexHdrObjectClass;
+					}
+				}
+			else
+				{
+				iValidHeaders &= ~KObexHdrObjectClass;
+				}				
+			}
+		if (remaininghdr & KObexHdrUserDefined)
+			{
+			TBool headerFound = EFalse;
+			TUint headerFoundCount = 0;
+			TUint headerSentCount = 0;
+			TInt err = 0;
+			
+			//reset the mask so all headers are searched
+			//NB. SetMask sets the iterator at the start of the headerset
+			iHeaderSet->SetMask(NULL);
+			
+			for (TUint8 headerTypeIndex = TObexInternalHeader::EUnicode; 
+							headerTypeIndex <= TObexInternalHeader::E4Byte;)
+				// NB. iterative step not included in this for loop, this is done at the end 
+				//of the for loop: moves headerTypeIndex to the next type
+				{
+									
+				for (TUint8 headerNameIndex = KObexUserDefinedHdrAddrMin; 
+							headerNameIndex <= KObexUserDefinedHdrAddrMax; headerNameIndex++)
+					{
+					TUint8 localHI = static_cast<TUint8>(headerTypeIndex | headerNameIndex);
+			
+					iHeaderSet->First();
+						
+					err = iHeaderSet->Find(localHI, *iObexHeader);
+
+					if (err == KErrNone)
+						{
+						headerFoundCount++;
+							
+						if ((iObexHeader->Attributes() & CObexHeader::ESent) == 0)
+							{
+							headerFound = ETrue;
+
+							switch (headerTypeIndex)
+								{
+								case (TObexInternalHeader::EUnicode) : 
+								{
+								header.Set(localHI, iObexHeader->AsUnicode());
+								if(aPacket.InsertData(header)) 
+									{
+									iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+									headerSentCount++;
+									//set that a header has been added to this current packet
+									firstHeader = EFalse;
+									}
+
+								break;
+								}
+								case (TObexInternalHeader::EByteSeq) : 
+								{
+								header.Set(localHI, (const_cast<TUint8*> ((iObexHeader->AsByteSeq()).Ptr())), (iObexHeader->AsByteSeq()).Size());
+		
+								if(aPacket.InsertData(header)) 
+									{
+									iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+									headerSentCount++;
+									//set that a header has been added to this current packet
+									firstHeader = EFalse;
+									}
+								break;
+								}
+								case (TObexInternalHeader::E1Byte) : 
+								{
+								header.Set(localHI, iObexHeader->AsByte());
+								if(aPacket.InsertData(header)) 
+									{
+									iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+									headerSentCount++;
+									//set that a header has been added to this current packet
+									firstHeader = EFalse;
+									}
+								break;
+								}
+								case (TObexInternalHeader::E4Byte) : 
+								{
+								header.Set(localHI, iObexHeader->AsFourByte());
+								if(aPacket.InsertData(header)) 
+									{
+									iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+									headerSentCount++;
+									//set that a header has been added to this current packet
+									firstHeader = EFalse;
+									}
+								break;
+								}
+								default  : 
+								{
+								break;
+								}
+								}
+							}
+						else	
+							{	
+							//header has been previously sent.
+							headerSentCount++;
+							}
+						}// header not found in headerset	
+
+					} //for loop: user defined header 'name' addresses
+						
+	 			// set the header type to the next
+	 			//
+				switch (headerTypeIndex)
+					{
+					case (TObexInternalHeader::EUnicode) :
+						{
+						headerTypeIndex = TObexInternalHeader::EByteSeq;
+						break;	
+						}
+					case (TObexInternalHeader::EByteSeq) :
+						{
+						headerTypeIndex = TObexInternalHeader::E1Byte;
+						break;
+						}
+					case (TObexInternalHeader::E1Byte) :
+						{
+						headerTypeIndex = TObexInternalHeader::E4Byte;
+						break;
+						}
+					case (TObexInternalHeader::E4Byte) :
+						{
+						headerTypeIndex++; // incrementing this past E4Byte will cause for loop to exit
+						break;
+						}
+					default : {break;}
+						}
+				}//for loop: user defined header 'type' addresses
+		
+			if (headerFoundCount == headerSentCount)
+				{
+				//All User defined headers have been sent
+				iSendHeaders |= KObexHdrUserDefined;
+				}
+					
+			// an unsent user defined header cannot be found in headerset so set flag to invalid
+			if (headerFound == EFalse)
+				{
+				iValidHeaders &= ~KObexHdrUserDefined;
+				}
+			}
+
+		if(remaininghdr & KObexHdrTime)
+			{// Must be last, due to Windows 2000 parse bug (see defect v3 EDNJKIN-4N4G7K)
+			if (iValidHeaders & KObexHdrTime)
+				{
+				FLOG(_L("PrepareNextSendPacket - preparing ETime header\r\n"));
+				//reset the mask so all headers are searched
+				//NB. SetMask sets the iterator at the start of the headerset
+				iHeaderSet->SetMask(NULL);
+
+				if (iHeaderSet->Find(TObexInternalHeader::ETime, *iObexHeader) == KErrNone)
+					{
+					header.Set(TObexInternalHeader::ETime, (const_cast<TUint8*> ((iObexHeader->AsByteSeq()).Ptr())), (iObexHeader->AsByteSeq()).Size());
+					if(aPacket.InsertData(header)) 
+						{
+						//set that a header has been added to this current packet
+						iSendHeaders |= KObexHdrTime;
+						iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+						suppressDataHeader = ETrue; // Win2000 Bug work-aroung
+						firstHeader = EFalse;
+						}
+					}
+				else
+					{
+					iValidHeaders &= ~KObexHdrTime;
+					}
+				}
+			else
+				{
+				iValidHeaders &= ~KObexHdrTime;
+				}
+			}
+		
+		remaininghdr = STATIC_CAST(TObexHeaderMask, ~iSendHeaders & iValidHeaders & iHeaderMask);
+		
+		// Only add EoB if there is no other remaining headers
+		if (remaininghdr == KObexHdrEndOfBody)
+			{
+			//EoB can only be added in Empty objects.
+			__ASSERT_ALWAYS(DataSize() == 0, IrOBEXUtil::Panic(EAddingInvalidEoBHeader));
+			header.SetHI(TObexInternalHeader::EEndOfBody);
+				
+			if(aPacket.InsertData(header)) 
+				{
+				iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+				iSendHeaders |= KObexHdrEndOfBody;
+				//set that a header has been added to this current packet
+				firstHeader = EFalse;
+				}
+			else if(aPacket.RemainingInsertSpace() != startspace) //something has been added
+				{
+				//There is no enough space for EOB this round, try again next time
+				return EContinue;			
+				}
+			//else if nothing has been added, EError will be returned
+			remaininghdr = STATIC_CAST(TObexHeaderMask, ~iSendHeaders & iValidHeaders & iHeaderMask); 
+			}
+		}
+	
+	TInt dataspace = aPacket.RemainingInsertSpace() - KObexHeaderHILongSize;
+	TInt remainingdata = DataSize() - iSendBytes;
+	if(dataspace > 0 && remainingdata > 0 && !suppressDataHeader)
+		{// ...there's some room for data and we haven't sent it all, and we're allowed to add some
+		FLOG(_L("PrepareNextSendPacket - preparing some additional data\r\n"));
+		TPtr8 bufptr(NULL, 0);
+		if(remainingdata <= dataspace)
+			{
+			header.SetDeferred(TObexInternalHeader::EEndOfBody, &bufptr, remainingdata, remainingdata);
+			}
+		else
+			{
+			header.SetDeferred(TObexInternalHeader::EBody, &bufptr, 1, remainingdata - 1);
+			}
+		if(!aPacket.InsertData(header))
+			{
+			return(iSendProgress = EError);
+			}
+		else
+			{// Data header inserted, now load it up with data...
+			GetData(iSendBytes, bufptr);
+			if(bufptr.Length() < bufptr.MaxLength())
+				return(iSendProgress = EError);
+			iSendBytes += bufptr.Length();
+			remainingdata -= bufptr.Length();
+			}
+		}
+
+	if(!(remaininghdr || remainingdata > 0))
+		{// Check whether all(valid) headers and data will have been sent
+		iSendProgress = ELastPacket;
+	
+		FLOG(_L("PrepareNextSendPacket - All headers packaged setting Final Bit\r\n"));
+		aPacket.SetFinal();
+		}
+	else if(aPacket.RemainingInsertSpace() == startspace)
+		{
+		// There are pending header or data but we inserted nothing! 
+		// Some header isn't fitting into the packets provided. 
+		FLOG(_L("PrepareNextSendPacket - nothing was actually inserted\r\n"));
+		iSendProgress = EError;
+		}
+
+	return(iSendProgress);
+	}
+
+/**
+Prepare the object for receiving into.
+@internalComponent
+*/
+TInt CObexBaseObject::InitReceive()
+	{
+	FLOG(_L("CObexBaseObject::InitReceive\r\n"));
+
+	// Always clear the object out before allowing it to receive anything
+	Reset();
+	iRecvBytes = 0;
+	iRecvProgress = EContinue;
+	return(KErrNone);
+	}
+
+/**
+Parse the passed packet, consuming headers into this object as appropriate.
+The returned progress can not be relied upon to indicate completion, because
+that is actually signalled at a diferent level, depending on the source of
+the packet(final bit or server complete response). Returning EComplete 
+simply indicates that all of the object body has been received.
+
+@param aPacket The packet to extract the headers from
+
+@return The progress of header extraction
+@internalComponent
+*/
+CObexBaseObject::TProgress CObexBaseObject::ParseNextReceivePacket(CObexPacket &aPacket)
+	{
+	iLastError = ERespInternalError;
+	FLOG(_L("CObexBaseObject::ParseNextReceivePacket\r\n"));
+	
+	if(iRecvProgress != EContinue && iRecvProgress != EComplete)
+		{
+		FLOG(_L("CObexBaseObject::ParseNextReceivePacket Error!!! Exiting\r\n"));
+		return(iSendProgress);
+		}
+	TObexInternalHeader header;
+
+	while(aPacket.ExtractData(header))
+		{
+		switch(header.HI())
+			{
+		case TObexInternalHeader::EConnectionID:
+			{
+			if ( iHeaderMask & KObexHdrConnectionID )
+				{
+				FLOG(_L("ParseNextReceivePacket extracting CONNECTIONID\r\n"));
+
+				iValidHeaders &= ~KObexHdrConnectionID;
+
+			 	TRAPD(err, SetConnectionIdL(header.HVInt()));
+
+				if (err)
+					{
+					return EError;
+					}
+				}
+			}
+			break;
+		case TObexInternalHeader::EAppParam:
+			{
+			if ( iHeaderMask & KObexHdrAppParam )
+				{
+				FLOG(_L("ParseNextReceivePacket extracting APPPARAM\r\n"));
+				iValidHeaders &= ~KObexHdrAppParam;
+
+		
+				TPtrC8 src(header.HVByteSeq(), header.HVSize());
+				TRAPD(err, SetAppParamL(src));
+				if (err)
+					{
+					return EError;
+					}
+					
+				iValidHeaders |= KObexHdrAppParam; 
+				}
+			}
+			break;
+		case TObexInternalHeader::EHttp:
+			{
+			FLOG(_L("ParseNextReceivePacket extracting Http\r\n"));
+			
+			TPtrC8 src(header.HVByteSeq(), header.HVSize());
+			
+			TRAPD(err, AddHttpL(src));
+			
+			if (err)
+				{
+				return EError;
+				}
+			}
+			break;
+		case TObexInternalHeader::EName:
+			{
+			if(iHeaderMask & KObexHdrName) 
+				{ 
+				FLOG(_L("ParseNextReceivePacket Extracting NAME"));
+				iValidHeaders &= ~KObexHdrName;
+
+				HBufC* newHeader = HBufC::New(header.HVSize());
+				if (!newHeader)
+					{
+					return EError;
+					}
+				//else
+				TPtr ptr(newHeader->Des()); 
+				
+				TInt err = KErrNone;
+				
+				if(header.GetHVText(ptr) == KErrNone) 
+					{
+					TRAP(err, SetNameL(*newHeader));
+					}
+				delete newHeader;
+				newHeader = NULL;
+				
+				if (err)
+					{
+					return EError;
+					}
+				}
+				
+			}
+			break;
+		case TObexInternalHeader::EType:
+			{
+			if(iHeaderMask & KObexHdrType) 
+				{ 
+				FLOG(_L("ParseNextReceivePacket extracting TYPE\r\n"));
+				iValidHeaders &= ~KObexHdrType;
+
+				TPtrC8 src(header.HVByteSeq(), header.HVSize());
+				// use SetTypeL(), to ensure null terms are handled correctly
+				TRAPD(err, SetTypeL(src));
+				if (err)
+					{
+					return EError;
+					}
+
+				FLOG(_L("ParseNextReceivePacket extracting TYPE\r\n"));
+				}
+			}
+			break;
+		case TObexInternalHeader::ELength:
+			{
+			if(iHeaderMask & KObexHdrLength)
+				{
+				FLOG(_L("ParseNextReceivePacket extracting LENGTH\r\n"));
+				TRAPD(err, SetLengthL(header.HVInt()));
+
+				if (err)
+					{
+					return EError;
+					}
+
+				iValidHeaders |= KObexHdrLength;
+				}
+			}
+			break;
+		case TObexInternalHeader::ETime:// Time is ISO 8601 format byte sequence.
+			{
+			if(iHeaderMask & KObexHdrTime)
+				{
+				FLOG(_L("ParseNextReceivePacket extracting TIME in ISO 8601 format\r\n"));
+				TInt err = KErrGeneral;
+				TTime time;
+				
+				// Use Win2k's incorrect TIME format header to calculate the size required.
+				// 2k inserts incorrect padding and uses Unicode format.  Allow a little extra
+				// just in case.  (Currently this should be 48 bytes)
+				static const TInt KMaxTIMESize = sizeof("yyyy.mm.ddThh:mm:ssZ") * 2 + 6;
+				TBuf<KMaxTIMESize> timebuf;
+				
+				if(header.GetHVText(timebuf) == KErrNone && timebuf.LocateF('t') >= 0)
+					{
+					// Win2k sends an invalid TIME header, inserting unicode into a ByteSeq
+					// header, and inserting . and : characters between fields.  So copy char
+					// by char, ignoring invalid characters.
+					TBuf8<16> narrowTime;
+#ifdef _DEBUG
+					TBool changed = EFalse;
+#endif
+					for (TInt copyByte = 0; copyByte <= timebuf.Length()-1; copyByte++)
+						{
+						TChar chr(timebuf[copyByte]);
+						if (chr && (chr != 0x2e /* . */) && (chr != 0x3a /* : */))
+							{
+							if (narrowTime.Length() < narrowTime.MaxLength())
+								{
+								narrowTime.Append(chr);
+								}
+							}
+#ifdef _DEBUG
+						else
+							{
+							changed = ETrue;
+							}
+#endif
+						}
+					
+					// As we've mangled the header, output a log entry just in case...
+					FTRACE(if (changed) FLOG(_L(" - Windows non-compliant time header detected and converted")));
+
+					TRAP(err, SetTimeHeaderL(narrowTime));
+					}
+
+				if(err)
+					{
+					// Adding TIME header to object failed (out of memory?).
+					FLOG(_L("ParseNextReceivePacket extracting TIME in ISO 8601 format failed"));
+
+					// if adding TIME header to object failed, the header is ignored and the packet accepted
+					iValidHeaders &= ~KObexHdrTime;
+					}
+				else
+					{
+					// Adding TIME header succeeded, make a note.
+					iValidHeaders |= KObexHdrTime;
+					}
+				}
+			}
+			break;
+		case KFourByteTimeHeaderAddress : // Time is no. of secs since 1/1/1970
+			if (iHeaderMask & KObexHdrTime)
+				{
+				FLOG(_L("ParseNextReceivePacket extracting TIME in secs since 1/1/1970"));
+				TTimeIntervalSeconds secs = header.HVInt();
+				TRAPD(err, SetTimeL(TTime(TDateTime(1970, EJanuary, 0, 0, 0, 0, 0)) + secs));
+			
+				if(err)
+					{
+					return EError;
+					}
+
+				iValidHeaders |= KObexHdrTime;
+				}
+			break;
+		case TObexInternalHeader::EDescription:
+			{
+			if(iHeaderMask & KObexHdrDescription) 
+				{ 
+				FLOG(_L("ParseNextReceivePacket extracting DESCRIPTION\r\n"));
+				iValidHeaders &= ~KObexHdrDescription;
+
+				HBufC* newHeader = HBufC::New(header.HVSize());
+				if (!newHeader)
+					{
+					return EError;
+					}
+				//else
+				TPtr ptr(newHeader->Des()); 
+
+				TInt err = KErrNone;
+				
+				if(header.GetHVText(ptr) == KErrNone) 
+					{
+					TRAP(err, SetDescriptionL(*newHeader));
+					}
+				delete newHeader;
+				newHeader = NULL;
+				
+				if (err)
+					{
+					return EError;
+					}
+				}
+			}
+			break;
+		case TObexInternalHeader::ECount:
+			{
+			if(iHeaderMask & KObexHdrCount) 
+				{ 
+				FLOG(_L("ParseNextReceivePacket extracting Count\r\n"));
+
+				CObexHeader* newHeader = NULL;
+				TRAPD( err, newHeader = CObexHeader::NewL());
+				if (err)
+					{
+					return EError;
+					}
+				newHeader->SetFourByte(TObexInternalHeader::ECount, header.HVInt());
+
+				//Transfer ownership of pointer to CObexHeaderSet
+				err = iHeaderSet->AddHeader(newHeader);
+				if (err)
+					{
+					delete newHeader;
+					newHeader = NULL;
+					return EError;
+					}
+				iValidHeaders |= KObexHdrCount;
+				}
+			}
+			break;
+		case TObexInternalHeader::ETarget:
+			{
+			if(iHeaderMask & KObexHdrTarget) 
+				{ 
+				FLOG(_L("ParseNextReceivePacket extracting TARGET\r\n"));
+				iValidHeaders &= ~KObexHdrTarget;
+
+				TPtrC8 src(header.HVByteSeq(), header.HVSize());
+				TRAPD(err, SetTargetL(src));
+				if (err)
+					{
+					return EError;
+					}
+				}
+			}
+			break;
+		case TObexInternalHeader::ECreatorID:
+			{
+			if(iHeaderMask & KObexHdrCreatorID) 
+				{
+				FLOG(_L("ParseNextReceivePacket Extracting CreatorID header"));
+
+				CObexHeader* fourByteHeader = NULL;
+				TRAPD( err, fourByteHeader = CObexHeader::NewL());
+				if (err)
+					{
+					return EError;
+					}
+				fourByteHeader->SetFourByte(TObexInternalHeader::ECreatorID, header.HVInt());
+				//Transfer ownership of pointer to CObexHeaderSet
+				err = iHeaderSet->AddHeader(fourByteHeader);
+				if (err)
+					{
+					delete fourByteHeader;
+					fourByteHeader = NULL;
+					return EError;
+					}
+				iValidHeaders |= KObexHdrCreatorID;
+				}
+			}
+			break;
+		case TObexInternalHeader::EWanUUID:
+			{
+			if(iHeaderMask & KObexHdrWanUUID) 
+				{
+				FLOG(_L("ParseNextReceivePacket Extracting WanUUID header"));					
+				TPtrC8 src(header.HVByteSeq(), header.HVSize());
+	
+				CObexHeader* byteseqHeader = NULL;
+
+				byteseqHeader = IrOBEXHeaderUtil::CreateAndSetByteSeqHeader(TObexInternalHeader::EWanUUID, src);
+				if (!byteseqHeader)
+					{
+					return EError;
+					}
+
+				//Transfer ownership of pointer to CObexHeaderSet
+				TInt err = iHeaderSet->AddHeader(byteseqHeader);
+				if (err)
+					{
+					delete byteseqHeader;
+					byteseqHeader = NULL;
+					return EError;
+					}
+
+				iValidHeaders |= KObexHdrWanUUID;
+				}
+			}
+			break;
+		case TObexInternalHeader::EObjectClass:
+			{
+			if(iHeaderMask & KObexHdrObjectClass) 
+				{
+				FLOG(_L("ParseNextReceivePacket Extracting WanUUID header"));					
+				TPtrC8 src(header.HVByteSeq(), header.HVSize());
+	
+				CObexHeader* byteseqHeader = NULL;
+
+				byteseqHeader = IrOBEXHeaderUtil::CreateAndSetByteSeqHeader(TObexInternalHeader::EObjectClass, src);
+				if (!byteseqHeader)
+					{
+					return EError;
+					}
+
+				//Transfer ownership of pointer to CObexHeaderSet
+				TInt err = iHeaderSet->AddHeader(byteseqHeader);
+				if (err)
+					{
+					delete byteseqHeader;
+					byteseqHeader = NULL;
+					return EError;
+					}
+
+				iValidHeaders |= KObexHdrObjectClass;
+				}
+			}
+			break;
+ 		case TObexInternalHeader::EBody:
+ 			iValidHeaders |= KObexHdrBody;
+ 			//Fall-through
+		case TObexInternalHeader::EEndOfBody:
+			{
+			FLOG(_L("ParseNextReceivePacket extracting BODY\r\n"));
+			TPtr8 ptr(header.HVByteSeq(), header.HVSize(), header.HVSize());
+
+			if(header.HI() == TObexInternalHeader::EEndOfBody)
+				{// Body finished, there _could_ still be more headers, however...
+				iValidHeaders |= KObexHdrEndOfBody;
+				FLOG(_L("ParseNextReceivePacket extracting ENDOFBODY\r\n"));
+				iRecvProgress = EComplete;
+				}
+
+			NewData(iRecvBytes, ptr);
+			if(ptr.Length() < header.HVSize())
+				{
+				return(iRecvProgress = EError);
+				}
+			iRecvBytes += ptr.Length();
+			}
+			break;
+		case TObexInternalHeader::EAuthChallenge:
+			{
+			iLastError = ERespUnauthorized;
+			return EError;
+			}
+		default:
+			{
+			// Non Standard header received so check for user defined header
+			// NB. All user defined headers are in range 0x30..0x3F
+
+			if ((iHeaderMask & KObexHdrUserDefined) &&
+			    ((header.HI() & 0x30) != 0))
+				{
+				FLOG(_L("ParseNextReceivePacket Extracting User Defined Unicode header"));
+				if( IrOBEXHeaderUtil::ParseHeader(header, *iHeaderSet) == KErrNone)
+					{
+					iValidHeaders |= KObexHdrUserDefined;
+					}
+				else
+					{
+					return EError;
+					}
+				}
+			
+			}	//	End of default
+				
+			}	//	End of header type switch
+		}	//	End of while
+
+	return(iRecvProgress);
+	}
+
+/**
+Returns the Obex Error response code from the last call to CObexBaseObject::ParseNextReceivePacket
+
+@return The Obex Response code
+@internalComponent
+*/
+
+TObexResponse CObexBaseObject::GetLastError() const
+	{
+	return iLastError;
+	}
+
+/**
+Sets the header mask. aHeaderMask is built up by bit-wise ‘or’ing any of 
+the KObexHdr... constants.
+For example, if it is set to KObexHdrName | KObexHdrLength, only 
+these two headers will be specified in transfer operations with the remote 
+machine, even if there are other valid attributes which could be used. In 
+effect, this mask is bit-wise ‘and’ed with the "valid headers" mask when 
+determining which headers are valid for the purposes of transfers.
+
+@param aHeaderMask: the header mask to be set
+
+@publishedAll
+@released
+**/
+EXPORT_C void CObexBaseObject::SetHeaderMask(const TObexHeaderMask aHeaderMask)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iHeaderMask=aHeaderMask;
+	}
+
+/**
+Returns the number of bytes of the body of the object transferred so far 
+while sending this object.
+
+@return The number of bytes sent
+
+@publishedAll
+@released
+**/
+EXPORT_C TInt CObexBaseObject::BytesSent()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return(iSendBytes);
+	}
+
+/**
+Returns the number of bytes of the body of the object transferred while 
+receiving an object.
+
+@return The number of bytes received
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexBaseObject::BytesReceived()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return(iRecvBytes);
+	}
+
+/**
+Returns the currently set header mask. This defaults to 0xFF (i.e. allow 
+everything) when Reset () or InitFromFileL is called. This does not specify 
+which headers currently contain valid data--merely which headers will be 
+transferred if they do contain valid data.
+
+@return The currently set header mask
+@publishedAll
+@released
+*/
+EXPORT_C TObexHeaderMask CObexBaseObject::HeaderMask()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return iHeaderMask;
+	}
+
+/**
+Returns the current valid header mask. This allows inspection of the current
+set of valid headers, particularly useful for determining whether a put
+object contained a body header (important for deleting files as part of file
+transfer).
+
+@return The current valid header mask
+@publishedAll
+@released
+*/
+EXPORT_C TObexHeaderMask CObexBaseObject::ValidHeaders()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return iValidHeaders;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexobjects.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1271 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+*/
+
+#include <obex.h>
+#include <obexpanics.h>
+#include "logger.h"
+#include "OBEXUTIL.H"
+#include "obexasyncfilewriter.h"
+#include "obexsyncfilewriter.h"
+#include "obexfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/** Creates a new CObexFileObject object.
+Static file object factory. returns a new CObexFileObject, set up to use a 
+temporary file  to store received data into "on the fly". If used for 
+sourcing an object to send a "NULL" object(body length 0) will be sent.
+@return Instance of CObexFileObject 
+	
+@publishedAll
+@released
+*/
+EXPORT_C CObexFileObject* CObexFileObject::NewL()
+	{
+	LOG_LINE
+	LOG_STATIC_FUNC_ENTRY
+
+	CObexFileObject* self = new(ELeave) CObexFileObject;
+	CleanupStack::PushL(self);
+	self->ConstructL(TPtrC(NULL, 0));
+	CleanupStack::Pop();
+	return(self);
+	}
+
+/** Creates a new CObexFileObject object.
+Static file object factory. returns a new CObexFileObject, set up to use
+aDataFile as its data file, or will create a temp file if aDataFile is not
+a valid file name. If used for sourcing an object to send, and no valid data
+file is set, a "NULL" object(body length 0) will be sent.
+@param aDataFile Filename to configure this object to use
+@return Instance of CObexFileObject 
+	
+@publishedAll
+@released
+*/
+EXPORT_C CObexFileObject* CObexFileObject::NewL(const TDesC &aDataFile)
+	{
+	LOG_LINE
+	LOG_STATIC_FUNC_ENTRY
+
+	CObexFileObject* self = new(ELeave) CObexFileObject;
+	CleanupStack::PushL(self);
+	self->ConstructL(aDataFile);
+	CleanupStack::Pop();
+	return(self);
+	}
+
+/** Destructor. 
+	
+@publishedAll
+@released
+*/
+EXPORT_C CObexFileObject::~CObexFileObject()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	ResetData();
+	iFs.Close();
+	}
+
+/**
+Sets the name of a file which holds the data to be used as the objects body.
+Leaves if the file does not exist, or can not be opened for writing.
+
+@param aDesc Filename to configure this object to use
+*/
+void CObexFileObject::SetDataFileL(const TDesC& aDesc)// does this need to be exported????
+	{
+	ResetData();
+	if(aDesc.Length() == 0)
+		return;
+	TInt err = iDataFile.SetNoWild(aDesc, NULL, NULL);
+	if(err == KErrNone) //try and open for read/write
+ 		err = iFile.Open(iFs, iDataFile.FullName(), EFileWrite  | EFileShareExclusive);
+ 	if(err != KErrNone)
+		{			//can't open it for write so open it for read
+		err = iFile.Open(iFs, iDataFile.FullName(), EFileRead  | EFileShareReadersOnly);
+		if(err != KErrNone)
+			{
+			iDataFile.SetNoWild(KNullDesC, NULL, NULL);
+			iFile.Close();	// Manually close file
+			User::Leave(err);
+			}
+		}
+	}
+
+/** 
+Get the name of the file representing the object body.
+
+@return	the full path and name of the file representing the object body.
+		Null descriptor	if no valid data file has been set, or if Reset()
+		has been called on the object since a file was last set.
+*/
+const TDesC& CObexFileObject::DataFile()
+	{
+	return iDataFile.FullName();
+	}
+
+TInt CObexFileObject::RenameFile(const TDesC& aDesC)
+	{
+	iFile.SetAtt(0,KEntryAttHidden);// - dont check return code - if it fails it fails
+	return(iFile.Rename(aDesC));
+	}
+
+void CObexFileObject::SetTempFilePath(const TDesC& aPath)
+	{
+	iTempFilePath = aPath;
+	}
+
+void CObexFileObject::QueryTempFilePath(TDes& aPath)
+	{
+	aPath = iTempFilePath;
+	}
+
+/**
+Constructs this object.
+
+@param aDataFile The file to use for the object's data part.
+*/
+void CObexFileObject::ConstructL(const TDesC &aDataFile)
+	{
+	CreateHeaderStorageDataL();
+	LEAVEIFERRORL(iFs.Connect());
+	SetDataFileL(aDataFile);
+	iTempFilePath = KNullDesC; 
+	}
+
+/** Initialises this object from the specified file. 
+
+The function attempts to set attribute values for the object as follows:
+
+Length:set to the length of the file
+
+Name:taken from the name portion of the path in aFile
+
+Time:taken from the modification time of the file
+
+Type:set appropriately if the file extension is .vcf (VCard), .vcs (Vcalendar), 
+or .txt.
+
+@param aFile Body data file 	
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexFileObject::InitFromFileL(const TDesC& aFile)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	Reset();
+	SetDataFileL(aFile);
+		
+
+	SetNameL(iDataFile.NameAndExt());
+	GuessTypeFromExtL(iDataFile.Ext());
+	
+	TInt length;
+	if(iFile.Size(length) == KErrNone)
+		{
+		SetLengthL(length);
+		}
+	
+	TTime time;
+	if(iFile.Modified(time) == KErrNone)
+		{
+		SetUtcTimeL(time);
+		}
+	}
+
+
+/**
+Virtual pure function form the base object. Tries to fill aDes with data 
+starting from aPos byte offset. returns null descriptor if no data file is 
+set. 
+@param aPos Position (reliative to start of object) to start extracting data from
+@param aDes Descriptor to fill
+*/
+void CObexFileObject::GetData(TInt aPos, TDes8& aDes)
+	{
+	if(iDataFile.NameOrExtPresent() && iFile.Read(aPos, aDes) == KErrNone)
+		return;
+	aDes.SetLength(0);
+	}
+
+/**
+Virtual pure function overload. inserts aDes into the data file at location 
+aPos 
+@param aPos Position (reliative to start of object) to start inserting data from
+@param aDes Descriptor to insert
+*/
+void CObexFileObject::NewData(TInt aPos, TDes8& aDes)
+	{
+//	iTempFilePath.SetLength(0);
+	if(!iDataFile.NameOrExtPresent())
+		{
+		ResetData();
+		TFileName fname;
+		TInt err = iFile.Temp(iFs, iTempFilePath, fname, EFileWrite | EFileShareExclusive);
+		if(err == KErrNone)
+			err = iFs.Parse(fname, iDataFile.Path(), iDataFile);
+		if(err != KErrNone)
+			{
+			ResetData();
+			iFs.Delete(fname);
+			aDes.SetLength(0);
+			return;
+			}
+		iFile.SetAtt(KEntryAttHidden,0);// dont check return code - if it fails it fails
+		}
+	if(iFile.Write(aPos, aDes) != KErrNone)
+		aDes.SetLength(0);
+	}
+
+/**
+@return number of bytes in the data file (0 if no file is set)
+*/
+TInt CObexFileObject::DataSize()
+	{
+	if(!iDataFile.NameOrExtPresent())
+		return(0);
+	TInt size = 0;
+	iFile.Size(size);
+	return(size);
+	}
+
+/**
+Set object back to a null file.
+*/
+void CObexFileObject::ResetData()
+	{
+	iFile.Close();
+	iDataFile.Set(KNullDesC, NULL, NULL);
+	}
+
+//
+// class CObexBufObject
+//
+
+/**
+Allocates and constructs a new OBEX dynamic buffer object, specifying a buffer.
+
+@param aDataBuf The buffer for the body of the object. This must be set either
+	   by this constructor or by calling SetDataBufL() before using the object.
+@return New OBEX dynamic buffer object 
+	
+@publishedAll
+@released
+*/
+EXPORT_C CObexBufObject* CObexBufObject::NewL(CBufBase* aDataBuf)
+	{
+	LOG_LINE
+	LOG_STATIC_FUNC_ENTRY
+
+	CObexBufObject* self = new(ELeave) CObexBufObject;
+	CleanupStack::PushL(self);
+	self->ConstructL(aDataBuf);
+	CleanupStack::Pop();
+	return(self);
+	}
+
+/** Destructor. 
+	
+@publishedAll
+@released
+*/
+EXPORT_C CObexBufObject::~CObexBufObject()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	delete iWriter;
+	
+	CloseDataFile();
+	CloseFileServer();
+
+	delete iFilename;
+	
+	delete iDoubleBuf;
+	}
+
+/** Writes contents of object to a file
+@param aFileName Target file
+@return a Symbian OS error code if file write fails. 
+	
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexBufObject::WriteToFile(const TPtrC& aFileName)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	TInt ret = KErrNone;
+	TRAP(ret, CopyFileL(aFileName));
+	return ret;
+	}
+
+
+NONSHARABLE_CLASS(TFileDetails)
+	{
+public:
+	TFileDetails(RFile& aFile, RFs& aFs, const TDesC& aFilename);
+	inline RFile* File();
+	inline RFs* FileServ();
+	inline const TDesC* Filename();
+
+private:
+	RFile* iFile;
+	RFs* iFileServ;
+	const TDesC* iFilename;
+	};
+
+
+TFileDetails::TFileDetails(RFile& aFile, RFs& aFs, const TDesC& aFilename)
+	: iFile(&aFile), iFileServ(&aFs), iFilename(&aFilename)
+	{}
+
+RFile* TFileDetails::File()
+	{ return iFile; }
+
+RFs* TFileDetails::FileServ()
+	{ return iFileServ; }
+
+const TDesC* TFileDetails::Filename()
+	{ return iFilename; }
+
+
+void DoCloseDeleteFile(TAny* aAny)
+// This function does not check for errors. Since we're closing down, not much
+// that we could do!
+	{
+	TFileDetails* fileDetails = reinterpret_cast<TFileDetails*>(aAny);
+	if (fileDetails)
+		{
+		fileDetails->File()->Close();
+		fileDetails->FileServ()->Delete(*(fileDetails->Filename()));
+		}
+	}
+
+
+// Writes object data to specified file.  Called from WriteToFile, exists to simplify
+// error handling as this function can leave.  Leaves are trapped in the caller.
+void CObexBufObject::CopyFileL(const TDesC& aFilename)
+	{
+	// Open persistent connection to fileserver if don't currently
+	// have one
+	LEAVEIFERRORL(OpenFileServer());
+
+	RFile writeFile;
+	LEAVEIFERRORL(writeFile.Create(*iFileServ, aFilename, EFileWrite  | EFileShareExclusive));
+
+	TFileDetails writeFileDetails(writeFile, *iFileServ, aFilename);
+	CleanupStack::PushL(TCleanupItem(DoCloseDeleteFile, &writeFileDetails));
+
+	// Now have three situations to worry about.  May have a file, in which
+	// case we need to copy data to the target file.  If there's a buffer for
+	// writes to this file, need to flush it first.
+	// Then may be using a memory buffer, in which case we just need to save
+	// the data.
+	if (iFile)
+		{
+		if (iBuf)
+			{
+			LEAVEIFERRORL(WriteBufferToFile(ETrue));
+			iBufOffset += iBuffered;
+			}
+
+		TInt dataSize = DataSize();
+		TInt bufSize = Min<TInt>(dataSize, 1024);
+			// Expands to TInt bufSize = (dataSize > 1024) ? 1024 : dataSize;
+		HBufC8* buffer = HBufC8::NewMaxLC(bufSize);
+
+		TInt written = 0;
+		TPtr8 ptr = buffer->Des();
+
+		while (written < dataSize)
+			{
+			LEAVEIFERRORL(iFile->Read(written, ptr));
+			LEAVEIFERRORL(writeFile.Write(written, ptr));
+			written += ptr.Length();
+			}
+
+		CleanupStack::PopAndDestroy(buffer); 
+		}
+	else
+		{
+		TInt segmentSize = iBuf->Ptr(0).Size();
+		TInt written = 0;
+		while (written < BytesReceived())
+			{
+			LEAVEIFERRORL(writeFile.Write(written, iBuf->Ptr(written)));
+		    written += segmentSize;
+			}
+		}
+
+	CleanupStack::Pop(); // file
+	writeFile.Close();
+	}
+
+
+/**
+Build a TObexBufferingDetails object.
+@param aBuffer The CBufBase derived object for Obex to use as a data store.
+	   This object will be resized as appropriate to hold the entire Obex object.
+
+@publishedAll
+@released
+*/
+EXPORT_C TObexBufferingDetails::TObexBufferingDetails(CBufBase& aBuffer)
+	: iVersion(EBasicBuffer), iBuffer(&aBuffer) 
+	{
+	LOG_LINE
+	LOG_FUNC
+	}
+
+
+/**
+Build a TObexBufferingDetails object, setting the version appropriately.
+@param aVersion Version number to insert.
+@param aBuffer The buffer object to use.
+
+@internalComponent
+*/
+TObexBufferingDetails::TObexBufferingDetails(TVersion aVersion, CBufBase* aBuffer)
+	: iVersion(aVersion), iBuffer(aBuffer)
+	{
+	__ASSERT_DEBUG(aVersion < ELastVersion, IrOBEXUtil::Fault(EBadBufferDetailsVersion));
+	}
+
+/**
+Return the version of this object
+@internalComponent
+*/
+TObexBufferingDetails::TVersion TObexBufferingDetails::Version()
+ 	{
+ 	return iVersion;
+ 	}
+
+
+/**
+Basic getter.
+@internalComponent
+*/
+CBufBase* TObexBufferingDetails::Buffer()
+	{
+	return iBuffer;
+	}
+
+
+/**
+Build a variant of TObexBufferingDetails which instructs the CObexBufObject
+to use a file as the only data store.  This is a special case option provided
+to cater for the MObexServerNotify interface which requires the use of
+CObexBufObject objects.  It is generally better to use a buffered variant.
+If the file cannot be opened for read/write access it will be opened in read
+only mode.  In this situation, attempts to store data in this object will cause
+an Obex error to be signalled in response to the Obex packet which carried the
+body data.
+
+@param aFilename The file to link the object to.
+
+@publishedAll
+@released
+*/
+EXPORT_C TObexPureFileBuffer::TObexPureFileBuffer(const TPtrC& aFilename)
+	: TObexBufferingDetails(EPureFile, NULL), iFilename(aFilename)
+	{
+	LOG_LINE
+	LOG_FUNC
+	}
+
+
+/**
+Basic getter.
+@internalComponent
+*/
+const TPtrC& TObexPureFileBuffer::Filename()
+	{
+	return iFilename;
+	}
+
+
+/**
+Build a variant of TObexBufferingDetails which instructs the CObexBufObject
+to use a file as the main data store, buffering writes to this in chunks.
+Writes are buffered into the supplied CBufBase derived object, which is not
+resized.  Once it is full, the data contained is written to file.
+Double buffering can be specified by setting aBufferingStrategy appropriately.
+If the file cannot be opened for read/write access it will be opened in read
+only mode.  In this situation, attempts to store data in this object will cause
+an Obex error to be signalled in response to the Obex packet which carried the
+body data.
+
+@param aBuffer The buffer to use as a temporary store.  This is ignored when
+	   reading from the file.
+@param aFilename The filename to use to permanently store the object.
+@param aBufferingStrategy Use double or single buffering.
+@publishedAll
+@released
+*/
+EXPORT_C TObexFilenameBackedBuffer::TObexFilenameBackedBuffer(CBufBase& aBuffer, const TPtrC& aFilename, CObexBufObject::TFileBuffering aBufferingStrategy)
+	: TObexBufferingDetails(EFilenameBackedBuffer, &aBuffer),
+	  iFilename(aFilename),
+	  iBufferingStrategy(aBufferingStrategy)
+	{
+	LOG_LINE
+	LOG_FUNC
+	}
+
+
+/**
+Basic getter.
+@internalComponent
+*/
+const TPtrC& TObexFilenameBackedBuffer::Filename()
+	{
+	return iFilename;
+	}
+
+
+/**
+Basic getter.
+@internalComponent
+*/
+CObexBufObject::TFileBuffering TObexFilenameBackedBuffer::Strategy()
+	{
+	return iBufferingStrategy;
+	}
+
+
+/**
+Build a variant of TObexBufferingDetails which instructs the CObexBufObject
+to use a file as the main data store, buffering writes to this in chunks.
+Writes are buffered into the supplied CBufBase derived object, which is not
+resized.  Once it is full, the data contained is written to file.
+Double buffering can be specified by setting aBufferingStrategy appropriately.
+If the file is opened in read only mode, attempts to store data in this object
+will cause an Obex error to be signalled in response to the Obex packet which
+body data.
+
+@param aBuffer The buffer to use as a temporary store.  This is ignored when
+	   reading from the file.
+@param aFile An RFile object pointing to the file, opened in an appropriate
+	   access mode.Note, Obex is responsible for closing the file, and a panic will
+	   result if an attempt is made to close the file from outside of Obex.
+@param aBufferingStrategy Use double or single buffering.
+@publishedAll
+@released
+*/
+EXPORT_C TObexRFileBackedBuffer::TObexRFileBackedBuffer(CBufBase& aBuffer, RFile aFile, CObexBufObject::TFileBuffering aBufferingStrategy)
+	: TObexBufferingDetails(ERFileBackedBuffer, &aBuffer),
+	  iFile(aFile),
+	  iBufferingStrategy(aBufferingStrategy)
+	{
+	LOG_LINE
+	LOG_FUNC
+	}
+
+
+/**
+Basic getter.
+@internalComponent
+*/
+RFile TObexRFileBackedBuffer::File()
+	{
+	return iFile;
+	}
+
+
+/**
+Basic getter.
+@internalComponent
+*/
+CObexBufObject::TFileBuffering TObexRFileBackedBuffer::Strategy()
+	{
+	return iBufferingStrategy;
+	}
+
+
+/**
+Set the data buffers as specified in the supplied TObexBufferingDetails object.
+@param aDetails The buffering techniques to use.  This only has to persist
+		over the duration of the call to SetDataBufL, once this has returned it can
+		be allowed to go out of scope.
+
+@panic Obex ENullFileHandle TObexPanicCode::ENullFileHandle The RFile object does not point
+to a valid (open) file.
+@panic Obex EEmptyBuffer TObexPanicCode::EEmptyBuffer The supplied buffer is of zero length.
+@panic Obex EInvalidBufferDetails TObexPanicCode::EInvalidBufferDetails An unknown TObexBufferingDetails
+object was supplied
+@panic Obex EInvalidBufferStrategy TObexPanicCode::EInvalidBufferStrategy An unknown TFileBuffering
+value was supplied.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBufObject::SetDataBufL(TObexBufferingDetails& aDetails)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	PrepareToSetBufferL();
+	
+	iBuf = aDetails.Buffer();
+	if (iBuf)
+		{
+		iBufSegSize = iBuf->Ptr(0).Size();
+		}
+	
+	TBool initFile = EFalse;
+	TBool initFileServer = EFalse;
+	TBool initFileWriter = EFalse;
+	TFileBuffering bufferingStrategy = ESingleBuffering;
+	
+	switch (aDetails.Version())
+		{
+		case TObexBufferingDetails::EBasicBuffer:
+			{
+			// All required details already set.
+			break;
+			}
+		
+		case TObexBufferingDetails::EPureFile:
+			{
+			TObexPureFileBuffer& detail = static_cast<TObexPureFileBuffer&>(aDetails);
+			iFilename = detail.Filename().AllocL();
+			
+			initFileServer = ETrue;
+			initFile = ETrue;
+			break;
+			}
+		
+		case TObexBufferingDetails::EFilenameBackedBuffer:
+			{
+			__ASSERT_ALWAYS(iBuf, IrOBEXUtil::Panic(ENullPointer));
+			__ASSERT_ALWAYS(iBuf->Size(), IrOBEXUtil::Panic(EEmptyBuffer));
+			
+			TObexFilenameBackedBuffer& detail = static_cast<TObexFilenameBackedBuffer&>(aDetails);
+			
+			iFilename = detail.Filename().AllocL();
+			bufferingStrategy = detail.Strategy();
+			
+			initFileServer = ETrue;
+			initFile = ETrue;
+			initFileWriter = ETrue;
+			break;
+			}
+			
+		case TObexBufferingDetails::ERFileBackedBuffer:
+			{
+			__ASSERT_ALWAYS(iBuf, IrOBEXUtil::Panic(ENullPointer));
+			__ASSERT_ALWAYS(iBuf->Size(), IrOBEXUtil::Panic(EEmptyBuffer));
+			
+			TObexRFileBackedBuffer& detail = static_cast<TObexRFileBackedBuffer&>(aDetails);
+			__ASSERT_ALWAYS(detail.File().SubSessionHandle(), IrOBEXUtil::Panic(ENullFileHandle));
+			
+			iFile =  new(ELeave) RFile(detail.File());
+			bufferingStrategy = detail.Strategy();
+			
+			initFileServer = ETrue;
+			initFileWriter = ETrue;
+			break;
+			}
+		
+		default:
+			{
+			IrOBEXUtil::Panic(EInvalidBufferDetails);
+			}
+		}
+		
+	if (initFileServer)
+		{
+		LEAVEIFERRORL(OpenFileServer());
+		}
+	
+	if (initFile)
+		{
+		LEAVEIFERRORL(OpenDataFile(*iFilename));
+		}
+	
+	if (initFileWriter)
+		{
+		switch (bufferingStrategy)
+			{
+			case ESingleBuffering:
+				iWriter = CObexSyncFileWriter::NewL(*iFile);
+				break;
+				
+			case EDoubleBuffering:
+				iWriter = CObexAsyncFileWriter::NewL(*iFile);
+				iDoubleBuf = CBufFlat::NewL(iBufSegSize);
+				iDoubleBuf->ResizeL(iBufSegSize);
+				break;
+
+			default:
+				IrOBEXUtil::Panic(EInvalidBufferStrategy);
+				break;
+			}
+		}
+	}
+
+
+/**
+Delete all owned resources in preparation for getting new settings.
+@internalComponent
+*/
+void CObexBufObject::PrepareToSetBufferL()
+	{
+	// Flush file buffer, if any.
+	if (iFile && iBuf)
+		{
+		LEAVEIFERRORL(WriteBufferToFile(ETrue));
+		iBufOffset = 0;
+		}
+
+	// The writer must be deleted at the same time as or before the file
+	// otherwise the writer will have an invalid file handle
+	delete iWriter;
+	iWriter = NULL;
+
+	CloseDataFile();
+	
+	delete iFilename;
+	iFilename = NULL;
+
+	delete iDoubleBuf;
+	iDoubleBuf = NULL;
+	
+	iBuf = NULL;
+	}
+
+
+/**
+Sets a buffer to use the object body data.
+
+Note that the function can leave.
+
+@param aDataBuf The buffer for the body of the object.
+@panic Obex ENullPointer TObexPanicCode::ENullPointer A NULL value was supplied for the
+data buffer.
+ 	
+@publishedAll
+@deprecated
+*/
+EXPORT_C void CObexBufObject::SetDataBufL(CBufBase* aDataBuf)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	__ASSERT_ALWAYS(aDataBuf, IrOBEXUtil::Panic(ENullPointer));
+	TObexBufferingDetails details(*aDataBuf);
+	SetDataBufL(details);
+	}
+
+
+/**
+Set object to use aFilename as its data area.  Leaves if unable to open file. 
+
+@param aFilename The filename to link the object to.
+
+@publishedAll
+@deprecated
+*/
+EXPORT_C void CObexBufObject::SetDataBufL(const TPtrC& aFilename)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	TObexPureFileBuffer details(aFilename);
+	SetDataBufL(details);
+	}
+
+
+/**
+Set object to use aFilename as its data area.  Leaves if unable to open file.
+Buffers data into aDataBuf before writing to file.  Will not grow the memory buffer,
+so user can tune buffering behaviour when calling function.
+
+@param aFilename The filename to link the object to.
+@param aDataBuf The buffer for the body of the object.
+@panic Obex ENullPointer TObexPanicCode::ENullPointer A NULL value was supplied for the
+data buffer.
+@panic Obex EEmptyBuffer TObexPanicCode::EEmptyBuffer The supplied buffer is of zero length.
+
+@publishedAll
+@deprecated
+*/
+EXPORT_C void CObexBufObject::SetDataBufL(const TPtrC& aFilename, CBufBase* aDataBuf)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	__ASSERT_ALWAYS(aDataBuf, IrOBEXUtil::Panic(ENullPointer));
+	TObexFilenameBackedBuffer details(*aDataBuf, aFilename, ESingleBuffering);
+	SetDataBufL(details);
+	}
+
+
+/**
+Set object to write to file, using buffering and the specified
+buffering strategy. Note the size of the buffer passed to this
+function will determine the size of the second buffer if double
+buffering is employed.
+
+@param aFilename The file to link the object to.
+@param aDataBuf A buffer to use.
+@param aBufferingStrategy The buffering strategy to employ.
+@panic Obex EEmptyBuffer TObexPanicCode::EEmptyBuffer The supplied buffer is of zero length.
+@panic Obex EInvalidBufferStrategy TObexPanicCode::EInvalidBufferStrategy An unknown TFileBuffering
+
+@publishedAll
+@deprecated
+*/
+EXPORT_C void CObexBufObject::SetDataBufL(const TPtrC& aFilename, CBufBase& aDataBuf, const TFileBuffering aBufferingStrategy)
+ 	{
+	LOG_LINE
+	LOG_FUNC
+
+ 	TObexFilenameBackedBuffer details(aDataBuf, aFilename, aBufferingStrategy);
+ 	SetDataBufL(details);	
+ 	}
+
+
+/**
+Gets the buffer.
+
+@return The buffer for the body of the object. 
+
+@publishedAll
+@released
+*/
+EXPORT_C CBufBase* CObexBufObject::DataBuf()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return(iBuf);
+	}
+
+
+/**
+Returns a pointer to the HBuf holding the filename this object is using.
+May return a null pointer.
+@return iFilename The file name.
+@internalComponent
+*/
+HBufC* CObexBufObject::FileName()
+	{
+	return(iFilename);
+	}
+
+
+CObexBufObject::CObexBufObject()
+	{
+	}
+
+void CObexBufObject::ConstructL(CBufBase* aDataBuf)
+	{
+	CreateHeaderStorageDataL();
+	if (aDataBuf)
+		SetDataBufL(aDataBuf);
+	}
+
+/**
+Reads aDes (up to MaxLength) from aPos offset into the buffer
+
+@param aPos The offset into the buffer to read from
+@param aDes The descriptor to read from
+*/
+void CObexBufObject::GetData(TInt aPos, TDes8& aDes)
+	{
+	__ASSERT_ALWAYS((iBuf || iFile), IrOBEXUtil::Panic(ENullPointer));
+
+	if (iFile)
+		{
+		GetFileData(aPos, aDes);
+		}
+	else
+		{
+		iBuf->Read(aPos, aDes);
+		}
+	}
+
+void CObexBufObject::GetFileData(TInt aPos, TDes8& aDes)
+	{
+	if(iFile->Read(aPos, aDes) == KErrNone)
+		return;
+	aDes.SetLength(0);
+	}
+
+/**
+Writes aDes into the buffer at aPos offset, growing the buffer if necessary
+*/
+void CObexBufObject::NewData(TInt aPos, TDes8& aDes)
+	{
+	// Three possible cases here.  Can either be receiving into a memory
+	// buffer (old behaviour), receiving directly into a file or buffering
+	// file writes into a fixed size buffer.
+
+	// Should always have at least one of iBuf or iFile set.
+	__ASSERT_ALWAYS((iBuf || iFile), IrOBEXUtil::Panic(ENullPointer));
+
+	if (iFile)
+		{
+		TInt err = NewFileData(aPos, aDes);
+		if (err != KErrNone)
+			{
+			LOG1(_L8("Couldn't write data to file (error %d)"), err);
+			aDes.SetLength(0);
+			return;
+			}
+		}
+	else
+		{
+		if(iBuf->Size() < aPos + aDes.Size())
+			{// Buffer needs to grow. Try to guess how big it needs to be.
+			TInt reqsz = aPos + aDes.Size();
+			if((TInt)Length() > reqsz)
+				reqsz = Length();
+			TRAPD(err, iBuf->ResizeL(reqsz));
+			if(err != KErrNone)
+				{// OOM, probably.
+				LOG2(_L8("Couldn't resize buffer object to %d bytes (error %d)"),
+					reqsz, err);
+				iBuf->Compress();
+				aDes.SetLength(0);
+				return;
+				}
+			}
+		iBuf->Write(aPos, aDes);
+		}
+	}
+
+
+/**
+Write new data into a file
+
+We write data out to the file in chunks of iBufSegSize,
+the (segment) size of the buffer.  A packet of data is
+passed to this method in aDes.  aDes may or may not take
+us past the the end of the buffer.  If it does, then we
+write out the buffer then continue filling it up with
+the rest of aDes.  We repeat this until we have used up
+all of aDes.  iBufOffset is the last write position in
+the file. remaining is the amount of data in aDes yet to
+be processed, written is the amount of data in aDes that
+has been processed.  iBuffered is the amount of data in
+iBuf and spare is the amount of free space in the buffer.
+
+@code
+                               aDes.Length()
+                        <---------------------->
+ ------------------------------------------------------------------------
+| ...      |xxxxxxxxxxxx|\\\\\\\\\\|//|*************|  ...      |
+| ...      |xxxxxxxxxxxx|\\\\\\\\\\|//|*************|  ...      |
+ ------------------------------------------------------------------------
+0 ...  iBufOffset     aPos                                      ...  this.Length()
+
+                           written    remaining
+                         <---------><----------->
+
+                    iBuffered                 spare
+            <----------------------><------------------------>
+
+                              iBufSegSize
+            <------------------------------------------------>
+
+ Key:
+      xxx = data already in buffer
+      \\\ = processed data from aDes, copied into iBuf
+      // = unprocessed data from aDes, not yet copied into iBuf
+      *** = free space in iBuf
+@endcode
+
+If there is more data remaining than there is spare space in
+the buffer, then the buffer is filled and written to disk and
+the remainer of the data is then used to continue filling the
+buffer.
+
+@param aPos The position at which aDes is to be written into the file.
+@param aDes The data to write to the file.
+@return Symbian OS error code
+*/
+TInt CObexBufObject::NewFileData(TInt aPos, TDes8& aDes)
+	{
+	// We have a memory buffer to (hopefully) speed file writes.
+	if (iBuf)
+		{
+		TInt err = KErrNone;
+
+		// If moving to earlier position in object, write out buffer
+		if (iBuffered && (aPos <  iBufOffset))
+			{
+			err = WriteBufferToFile(EFalse);
+			if (err) return err;
+			}
+
+		TInt written = 0;
+		TInt remaining;
+		
+		// Calculate the amount of data still to be processed and
+		// continue whilst there is still data to process
+		while ((remaining = (aDes.Length() - written)) > 0)
+			{
+			// Buffer full, write to file
+			if (iBuffered == iBufSegSize)
+				{
+				err = WriteBufferToFile(EFalse);
+				if (err) return err;
+				}
+
+			// Buffer empty, update buffer base
+			if (iBuffered == 0)
+				{
+				iBufOffset = aPos + written;
+				}
+
+			// Calculate the remaining space in the buffer (spare) and
+			// hence the amount of data we can process (length)
+			TInt spare = iBufSegSize - iBuffered;
+			TInt length = (spare > remaining) ? remaining : spare;
+
+			// Copy amount of data to be procesed (length) from the
+			// unprocessed portion of the packet (aDes.Right(remaining))
+			// into the buffer.
+			iBuf->Write(iBuffered, aDes.Right(remaining), length);
+
+			// Update variables to reflect newly processed data
+			written += length;
+			iBuffered += length;
+			}
+
+		// Is this the final packet?
+		const TBool finalPacket = (ValidHeaders() & KObexHdrEndOfBody);
+
+		// Flush buffer to file if we're done and there's data left
+		if (finalPacket && iBuffered)
+			{
+			err = WriteBufferToFile(ETrue);
+			iBufOffset = 0;
+
+			if (err) return err;
+			}
+		}
+	else
+	// Just write directly to the file
+		{
+		return iFile->Write(aPos, aDes);
+		}
+	
+	return KErrNone;
+	}
+
+
+TInt CObexBufObject::DataSize()
+	{
+	__ASSERT_ALWAYS((iBuf || iFile), IrOBEXUtil::Panic(ENullPointer));
+	if (iFile)
+		{
+		// Flush file buffer, if any.
+		if (iBuf)
+			{
+			(void) WriteBufferToFile(ETrue);
+			}
+		// Get file size
+		TInt size;
+		iFile->Size(size);
+		return size;
+		}
+	else
+		{
+		return (iBuf->Size());
+		}
+	}
+
+void CObexBufObject::ResetData()
+	{
+	__ASSERT_ALWAYS((iBuf || iFile), IrOBEXUtil::Panic(ENullPointer));
+	if (iFile)
+		{
+		iFile->SetSize(0);
+		if (iBuf)
+			{
+			iBufOffset = 0;
+			iBuffered  = 0;
+			}
+		}
+	else
+		{
+		iBuf->Reset();
+		}
+	}
+
+
+TInt CObexBufObject::OpenDataFile(const TDesC& aFilename)
+	{
+	TInt err = KErrNotReady;
+
+	if (!iFile)
+		{
+		iFile = new RFile;
+		if (!iFile) return KErrNoMemory;
+		
+		//Try and open the file for read/write
+		err = iFile->Open(*iFileServ, aFilename, EFileWrite | EFileShareExclusive);
+		if (err != KErrNone)
+			{
+			//Try and open file for read only	
+			err = iFile->Open(*iFileServ, aFilename, EFileRead  | EFileShareReadersOnly);
+			if(err == KErrNotFound)
+				{
+				err = iFile->Create(*iFileServ, aFilename, EFileWrite | EFileShareExclusive);
+				}
+			}
+
+		if (err)
+			{
+			delete iFile;
+			iFile = 0;
+			}
+		}
+	
+	return err;
+	}
+
+
+void CObexBufObject::CloseDataFile()
+	{
+	if (iFile)
+		{
+		iFile->Close();
+		delete iFile;
+		iFile = 0;
+		}
+	}
+
+TInt CObexBufObject::OpenFileServer()
+	{
+	TInt err = KErrNone;
+
+	if (!iFileServ)
+		{
+		iFileServ = new RFs;
+		if (!iFileServ) return KErrNoMemory;
+
+		err = iFileServ->Connect();
+		if (err)
+			{
+			delete iFileServ;
+			iFileServ = 0;
+			}
+		}
+	return err;
+	}
+
+void CObexBufObject::CloseFileServer()
+	{
+	if (iFileServ)
+		{
+		iFileServ->Close();
+		delete iFileServ;
+		iFileServ = 0;
+		}
+	}
+
+TInt CObexBufObject::WriteBufferToFile(TBool aFinal)
+	{
+	TInt err = KErrNone;
+	
+	if (aFinal)
+		{
+		err = iWriter->FinalWrite(iBufOffset, iBuf, iBuffered);
+		}
+	else
+		{
+		err = iWriter->Write(iBufOffset, iBuf);
+		}
+	
+	if (!iBuf && iDoubleBuf)
+		{
+		iBuf = iDoubleBuf;
+		}
+
+	iBuffered  = 0;
+
+	return err;
+	}
+
+//
+// class CObexNullObject
+//
+void CObexNullObject::ConstructL()
+	{
+	CreateHeaderStorageDataL();
+	}
+
+/** Allocates and constructs a new null object.
+
+@return New null object 
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexNullObject* CObexNullObject::NewL()
+	{
+	LOG_LINE
+	LOG_STATIC_FUNC_ENTRY
+
+	CObexNullObject* self = new(ELeave) CObexNullObject;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return(self);
+	}
+
+/**
+To return "NULL" data, we simply set aDes.Size = 0
+*/
+void CObexNullObject::GetData(TInt /*aPos*/, TDes8& aDes)
+	{
+	aDes.SetLength(0);
+	return;
+	}
+
+/**
+In order to appear to consume the data, we don't set aDes.Size = 0
+*/
+void CObexNullObject::NewData(TInt /*aPos*/, TDes8& /*aDes*/)
+	{
+	return;
+	}
+
+TInt CObexNullObject::DataSize()
+	{
+	return(0);
+	}
+
+void CObexNullObject::ResetData()
+	{
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexpacketsignaller.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,221 @@
+// 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
+ @released
+ @internalComponent
+*/
+
+#include <obexfinalpacketobserver.h>
+#include "logger.h"
+#include "obexpacketsignaller.h"
+#include "OBEXUTIL.H"
+#include "obexfaults.h"
+#include "obexclient.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/** Constructor.
+This Active Object has a priority of EPriorityHigh + 1. This is to ensure 
+that, when a final packet is sent, the RunLs are executed in the following order:
+1/ signaller (EObexFinalPacketStarted)
+2/ activeRW (the final packet actually being sent)
+3/ signaller (EObexFinalPacketFinished)
+The priority chosen is EPriorityHigh + 1 because the priorities of the 
+transport controllers' writer (CActiveRW) AOs tends to be EPriorityHigh. 
+As long as this is the case, our guarantee holds. Our documentation says that 
+new licensee transport controllers must have writers with priorities that 
+continue to support this guarantee.
+*/
+CObexPacketSignaller::CObexPacketSignaller() : CActive(CActive::EPriorityHigh + 1)
+	{
+	}
+	
+/** Factory function.
+
+@return A fully constructed CObexPacketSignaller.
+*/
+CObexPacketSignaller* CObexPacketSignaller::NewL()
+	{
+	CObexPacketSignaller* signaller = new(ELeave)CObexPacketSignaller();
+	return signaller;
+	}
+
+/** Destructor.
+*/	
+CObexPacketSignaller::~CObexPacketSignaller()
+	{
+	Cancel();
+	}
+	
+/** Sets observer to be notified of packet process events.
+
+This clears any events that are currently outstanding.
+
+@param aObserver The observer to receive events.  May be set to NULL.
+*/
+void CObexPacketSignaller::SetFinalPacketObserver(MObexFinalPacketObserver* aObserver)
+	{
+	LOG1(_L8("CObexPacketSignaller::SetObserver(0x%x)"), aObserver);
+	
+	// Clear outstanding events for the final packet observer
+	// If there's an outstanding final packet event this means 
+	// it won't get signalled.
+	iOutstandingEvents &= ~(EObexFinalPacketStarted | EObexFinalPacketFinished);
+	
+	// Add or remove from scheduler if necessary
+	if(!iFinalPacketObserver &&!iReadActivityObserver && aObserver)
+		{
+		CActiveScheduler::Add(this);
+		}
+	else if(iFinalPacketObserver && !iReadActivityObserver && !aObserver)
+		{
+		Deque();
+		}
+	
+	iFinalPacketObserver = aObserver;
+	}
+	
+void CObexPacketSignaller::SetReadActivityObserver(MObexReadActivityObserver* aObserver)
+	{
+	LOG1(_L8("CObexPacketSignaller::SetObserver(0x%x)"), aObserver);
+	
+	// Clear outstanding events for the read activity observer
+	// If there's an outstanding read activity event this means 
+	// it won't get signalled.
+	iOutstandingEvents &= ~EObexReadActivityDetected;
+	
+	//UpdateScheduler();
+	// Add or remove from scheduler if necessary
+	if(!iFinalPacketObserver &&!iReadActivityObserver && aObserver)
+		{
+		CActiveScheduler::Add(this);
+		}
+	else if(iReadActivityObserver && !iFinalPacketObserver && !aObserver)
+		{
+		Deque();
+		}
+	
+	iReadActivityObserver = aObserver;
+	}
+
+	
+/** Signal that an event has occurred.
+
+@param aEvent The event that has occurred.
+*/	
+void CObexPacketSignaller::Signal(TObexPacketProcessEvent aEvent)
+	{
+	LOG1(_L8("CObexPacketSignaller::Signal(%d)"), aEvent);
+	__ASSERT_DEBUG((aEvent != 0), IrOBEXUtil::Panic(EBadPacketProcessEvent));
+
+	TBool appropriateObserver = EFalse;
+	switch(aEvent)
+		{
+		case EObexFinalPacketStarted:
+		case EObexFinalPacketFinished:
+			{
+			if(iFinalPacketObserver)
+				{
+				appropriateObserver = ETrue;
+				}
+			}
+			break;
+		case EObexReadActivityDetected:
+			{
+			if(iReadActivityObserver)
+				{
+				appropriateObserver = ETrue;
+				}
+			}
+			break;
+		default:
+		    break; //drop - not for us
+		}
+
+	if(appropriateObserver)
+		{
+		iOutstandingEvents |= aEvent;
+		
+		if(!IsActive())
+			{
+			SetActive();
+			TRequestStatus* status = &iStatus;
+			User::RequestComplete(status, KErrNone);
+			}
+		}
+	}
+	
+/** Active object completion function.
+*/
+void CObexPacketSignaller::RunL()
+	{
+	LOG1(_L8("CObexPacketSignaller::RunL() with iOutstandingEvents %d"), iOutstandingEvents);
+
+	__ASSERT_DEBUG(iFinalPacketObserver || !(iOutstandingEvents  & (EObexFinalPacketStarted | EObexFinalPacketFinished)), 
+				  IrOBEXUtil::Panic(ENoPacketProcessObserverSet));
+	__ASSERT_DEBUG(iReadActivityObserver || !(iOutstandingEvents & EObexReadActivityDetected), 
+				  IrOBEXUtil::Panic(ENoPacketProcessObserverSet));
+	// Signal each event in order
+	// Should be safe against an observer becoming
+	// unset as if it is unset then associated outstanding events are
+	// cleared.
+	if(iOutstandingEvents & EObexFinalPacketStarted)
+		{
+		iOutstandingEvents &= ~EObexFinalPacketStarted;
+		if(iFinalPacketObserver!=NULL)
+			{
+			iFinalPacketObserver->MofpoFinalPacketStarted();
+			}
+		}
+		
+	if(iOutstandingEvents & EObexFinalPacketFinished)
+		{
+		iOutstandingEvents &= ~EObexFinalPacketFinished;
+		if(iFinalPacketObserver!=NULL)
+			{
+			iFinalPacketObserver->MofpoFinalPacketFinished();
+			}
+		}
+	
+	if(iOutstandingEvents & EObexReadActivityDetected)
+		{
+		iOutstandingEvents &= ~EObexReadActivityDetected;
+		if(iReadActivityObserver!=NULL)
+			{
+			iReadActivityObserver->MoraoReadActivity();
+			}
+		}
+	
+	// If we've been signalled as a result of client's notification
+	// handling events may be outstanding...
+	if(iOutstandingEvents)
+		{
+		SetActive();
+		TRequestStatus* status = &iStatus;
+		User::RequestComplete(status, KErrNone);	
+		}
+	}
+	
+/** From CActive.
+*/	
+void CObexPacketSignaller::DoCancel()
+	{
+	iOutstandingEvents = 0;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexpackettimer.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+ @file
+ @released
+ @internalComponent
+*/
+
+#include "obexpackettimer.h"
+#include "obexclient.h"
+
+
+/*
+ * CObexPacketTimer. Will RunL if the remote obex server has not send any packet for a certain time.
+ * Duration is set by CObexClient::SetCommandTimeout
+ */
+
+CObexPacketTimer::CObexPacketTimer(CObexClient& aObexClient) 
+	: CTimer(CActive::EPriorityStandard), iObexClient(aObexClient)
+	{
+	CActiveScheduler::Add(this);		
+	}
+
+CObexPacketTimer* CObexPacketTimer::NewL(CObexClient& aObexClient)
+	{
+	CObexPacketTimer* timer = new(ELeave)CObexPacketTimer(aObexClient);
+	CleanupStack::PushL(timer);
+	timer->ConstructL();
+	CleanupStack::Pop(timer);
+	return timer;
+	}
+
+CObexPacketTimer::~CObexPacketTimer()
+	{
+	Cancel();
+	}
+	
+void CObexPacketTimer::RunL()
+	{
+	if(iStatus==KErrNone)
+		{
+		//Timeout 
+ 		iObexClient.TimeOutCompletion();
+		}
+	}
+
+void CObexPacketTimer::SetTimer(TTimeIntervalMicroSeconds32 anInterval)
+	{
+	//Check if a timeout should be started on the request packet.
+	if(anInterval.Int()>KLowestPossibleTimerValue)
+		{
+		Cancel();
+
+		After(anInterval);
+		}
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexserver.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1588 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+*/
+
+#include <charconv.h>
+#include <utf.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obextransportinfo.h>
+#include <obex.h>
+#include <obex/internal/obexpacket.h>
+#include <obex/transport/obextransportcontrollerbase.h>
+#include <obex/internal/obextransportconstants.h>
+#include <obex/extensionapis/mobexserverrequestpacketnotify.h>
+#include <obex/internal/mobexserverrequestpacketnotifyregister.h>
+#include "logger.h"
+#include "obexsetpathdata.h"
+#include "OBEXUTIL.H"
+#include "authentication.h"
+#include "obexnotifyhandlerserver.h"
+#include "obexserverstatemachine.h"
+#include "obexservernotifysyncwrapper.h"
+#include "obexheaderutil.h"
+#include "obexserverrequestpacketengine.h"
+#include "obexpacketsignaller.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/**
+Constructor - set initial values 
+@internalTechnology
+*/
+CObexServer::CObexServer() : CObex()
+	{
+	iCurrentOperation = EOpIdle;
+	iEnabled = EFalse;
+
+	//the connectionID is fixed at the moment
+	ResetConnectionID();
+	SetConnectionID(0xc30fa596);
+
+	iTargetChecking = EIfPresent;
+	}
+
+void CObexServer::ConstructL(TObexTransportInfo& aObexTransportInfo)
+	{
+	CObex::ConstructL(aObexTransportInfo);
+	iNotifyHandler = new(ELeave)CObexNotifyHandlerServer(*this);
+	iTransportController->SetOwner(*iNotifyHandler);
+
+	iHeader = CObexHeader::NewL();
+	iStateMachine = CObexServerStateMachine::NewL(*this, *iTransportController);
+	iSyncWrapper = CObexServerNotifySyncWrapper::NewL(*this, *iStateMachine);
+	iPacketProcessSignaller = CObexPacketSignaller::NewL();
+	}
+
+/**
+Destructor. 
+*/
+CObexServer::~CObexServer()
+	{
+	FLOG(_L("CObexServer Destructor\r\n"));
+	Stop();
+	
+	delete iPacketProcessSignaller;
+	delete iSyncWrapper;
+	delete iStateMachine;
+	delete iHeader;
+	delete iNotifyHandler;
+	delete iServerRequestPacketEngine;
+	}
+
+void CObexServer::ResetConnectionID()
+	{
+	iConnectionID = KConnIDInvalid;
+	iConnectionIdSet = EFalse;
+	}
+
+void CObexServer::SetConnectionID(TUint32 aConnectionID)
+	{
+	iConnectionID = aConnectionID;
+	iConnectionIdSet = ETrue;
+	}
+
+TUint32 CObexServer::ConnectionID()
+	{
+	return (iConnectionID);
+	}
+
+TInt CObexServer::PrepareFinalChallResponse(CObexPacket& aPacket, TConnectState& aNextState)
+	{
+
+	FLOG(_L("CObexServer::PrepareFinalChallResponse\r\n"));
+
+	aPacket.SetOpcode(ERespSuccess); 
+
+	TInt retValue = AddConnectionIDHeader(aPacket);	
+	if (retValue == KErrNone)
+		{
+		FLOG(_L("PrepareFinalChallResponse ConnectionID header Added\r\n"));
+		if (iCallBack)
+			{
+			FLOG(_L("PrepareFinalChallResponse Requesting User Password\r\n"));
+
+			//the actual asking of the password happens later in the method OnPacketReceive
+			//wait for the reply
+			aNextState = EWaitForUserInput;
+			retValue = KErrGeneral; //mustn't send yet wait for reply from user
+			}
+		else //else can't Auth challenge so drop link
+			{
+			FLOG(_L("PrepareFinalChallResponse Can't request User Password for Chall dropping link\r\n"));
+
+			retValue = KErrIrObexConnectChallRejected;
+			aNextState = EConnTransport;
+			aPacket.SetOpcode(ERespNotImplemented);
+			}
+		}
+	else
+		{
+		aNextState = EDropLink;
+		}
+	return (retValue);
+	}
+
+
+/** A call back from the the service with the password required for use with generating 
+the challenge response. 
+
+@param aPassword Password
+
+@leave KErrNotReady if this function is not called from a MObexAuthChallengeHandler::GetUserPasswordL callback.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexServer::UserPasswordL(const TDesC& aPassword)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	//now have a password, get a nonce, and get it hashed then reply
+	if (GetConnectState() == EWaitForUserInput)
+		{
+		FLOG(_L("CObexServer::UserPasswordL\r\n"));
+		PrepareChallResponseL(aPassword);
+		FLOG(_L("UserPasswordL - PrepareChallResponse Success\r\n"));
+
+		TObexInternalHeader hdr;
+		hdr.Set(TObexInternalHeader::EAuthResponse, (const_cast<TUint8*> (iOutgoingChallResp.Ptr())), iOutgoingChallResp.Size());
+		if(iTransportController->SendPacket().InsertData(hdr))
+			{
+			FLOG(_L("UserPasswordL Inserting EAuthResponse Header\r\n"));
+
+			SetConnectState(EConnObex); //all finished
+			iTransportController->SendPacket().SetFinal();
+			iTransportController->Send();
+			//inform the client that the connection was succesfull
+			iOwner->ObexConnectIndication(iRemoteInfo, TPtr8(NULL, 0));
+			iStateMachine->ConnectionComplete();
+			}
+		else
+			{
+			User::Leave(KErrGeneral);
+			}
+		}
+	else
+		{
+		User::Leave(KErrNotReady);
+		}
+	}
+
+
+TInt CObexServer::AddConnectionIDHeader(CObexPacket& aPacket)
+	{
+	TInt retValue = KErrNone;
+	//if the Target header was used for the connection
+	//then reply with ConnectionID and Who headers
+	if(iTargetReceived)
+		{
+		//this solution can only handle one connection at a time therefore
+		//can safely use the same connection ID repeatedly
+		//when used the ConnectionID must be first
+		TObexInternalHeader hdr;
+		FLOG(_L("CObexServer::AddConnectionIDHeader Inserting EConnectionID Header\r\n"));
+ 
+ 		hdr.Set(TObexInternalHeader::EConnectionID, iConnectionID);
+		
+		if(aPacket.InsertData(hdr))
+			{ 
+			// Connection ID header inserted correctly
+			// Now set a WHO header.
+			// This logic is a bit backwards due to problems with the 'no target header checking'
+			// state.  Instead of inserting our local Who header, we copy the Target header back.
+			// This works in the checking states because we drop any connection where the local
+			// Who is not identical to the Target header received.
+			// When not checking targets, this may mean that the client gets connected to a server
+			// which knows nothing about the service, yet thinks it is talking to a strict peer.
+			// However the server wouldn't understand what was going on anyway, so we're not really
+			// in a worse state than we would be if we did something more fancy.  Ultimately the
+			// application must drop the connection---probably by deleting the Obex server or
+			// returning errors to all attempted operations.
+			
+			FLOG(_L("CObexServer::AddConnectionIDHeader Inserting EWho Header\r\n"));
+
+			hdr.Set(TObexInternalHeader::EWho, (const_cast<TUint8*> (iRemoteInfo.iTargetHeader.Ptr())), 
+																iRemoteInfo.iTargetHeader.Size());
+			if(!aPacket.InsertData(hdr))
+				{
+				retValue = KErrGeneral;
+				}
+			}
+		else
+			{
+			retValue = KErrGeneral;
+			}
+		}
+	return (retValue);
+	}
+
+/**
+Allocates and constructs a new OBEX server object.
+
+The received protocol information object, aObexProtocolInfoPtr, specifies the 
+transport protocol to use:
+For the standard transports the following are used, TObexIrProtocolInfo for 
+IrDA, TObexBluetoothProtocolInfo for Bluetooth, TObexUsbProtocolInfo for USB.
+
+@param aObexProtocolInfoPtr Protocol information object describing the 
+transport to use
+@return New OBEX server object 
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexServer* CObexServer::NewL(TObexProtocolInfo& aObexProtocolInfoPtr)
+	{
+	LOG_LINE
+	LOG_STATIC_FUNC_ENTRY
+
+	TObexProtocolPolicy defaultProtocolPolicy;	// no packet sizing policy specified, so use default		
+	TObexTransportInfo* transportInfo = IrOBEXUtil::CreateTransportInfoL(aObexProtocolInfoPtr, defaultProtocolPolicy);
+	CleanupStack::PushL(transportInfo);
+	CObexServer* server = CObexServer::NewL(*transportInfo);
+	CleanupStack::PopAndDestroy(transportInfo);
+	return server;
+	}
+
+/**
+Allocates and constructs a new OBEX server object with packet sizing 
+information.
+
+The received protocol information object, aObexProtocolInfoPtr, specifies the 
+transport protocol to use:
+For the standard transports the following are used, TObexIrProtocolInfo for 
+IrDA, TObexBluetoothProtocolInfo for Bluetooth, TObexUsbProtocolInfo for USB.
+
+The aObexProtocolPolicy parameter specifies the packet sizing policy for this 
+OBEX object.
+
+@param aObexProtocolInfoPtr Protocol information object describing the 
+transport to use
+@param aObexProtocolPolicy Protocol policy object specifying the packet sizes 
+to use
+@return New OBEX server object 
+	
+@publishedAll
+@released
+*/
+EXPORT_C CObexServer* CObexServer::NewL(TObexProtocolInfo& aObexProtocolInfoPtr, 
+										TObexProtocolPolicy& aObexProtocolPolicy)
+	{
+	LOG_LINE
+	LOG_STATIC_FUNC_ENTRY
+
+	TObexTransportInfo* transportInfo = IrOBEXUtil::CreateTransportInfoL(aObexProtocolInfoPtr, aObexProtocolPolicy);	
+	CleanupStack::PushL(transportInfo);
+	CObexServer* server =  CObexServer::NewL(*transportInfo);
+	CleanupStack::PopAndDestroy(transportInfo);
+	return server;
+	}
+
+/** 
+Allocates and constructs a new OBEX server object with packet sizing 
+information.
+
+The received transport information object, aObexTransportInfo, specifies the 
+transport protocol and packet sizes to use:
+For the standard transports the following are used, TObexIrProtocolInfo for 
+IrDA, TObexBluetoothProtocolInfo for Bluetooth, TObexUsbProtocolInfo for USB.
+
+@param aObexTransportInfo  Transport information object describing the 
+transport and packet sizes  to use
+@return New OBEX server object 
+
+@capability WriteDeviceData If the TObexIrV3TransportInfo is passed as the argument
+                            and the associated name is valid.
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexServer* CObexServer::NewL(TObexTransportInfo& aObexTransportInfo)
+	{
+	LOG_LINE
+	LOG_STATIC_FUNC_ENTRY
+
+	CObexServer* self = new(ELeave) CObexServer();
+	CleanupStack::PushL(self);
+	self->ConstructL(aObexTransportInfo);
+	CleanupStack::Pop(self);
+	return(self);
+	}
+
+/** Starts the server, specifying a synchronous notification interface.
+
+If the server is already started, no state changes occur (i.e. any connections/operations 
+in progress are not interrupted), but the notifications will be sent to aOwner. 
+This allows "child" servers to take over ownership of existing connections. 
+
+Details of this function behaviour depend on the transport specified when 
+constructed: in general a listener socket is created, its port number registered 
+as appropriate, and an accept queued.
+
+@param aOwner Server notification interface
+@return KErrArgument if parameter is NULL, KErrAlreadyExists if server has already
+been started (but notification object will still be updated), otherwise a system wide
+error code 
+@panic OBEX EChangeInterfaceDuringWait when attempting to change the interface at an inappropriate time.
+
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexServer::Start(MObexServerNotify* aOwner)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if(aOwner == NULL)
+		{
+		return(KErrArgument);
+		}
+	
+	// Pass this synchronous interface to the synchronous wrapper
+	// and pass the synchronous wrapper on to the asynchronous Start()
+	iSyncWrapper->SetNotifier(aOwner);
+	return Start(iSyncWrapper);
+	}
+
+
+/** Starts the server, specifying an asynchronous notification interface.
+
+If the server is already started, no state changes occur (i.e. any connections/operations 
+in progress are not interrupted), but the notifications will be sent to aOwner. 
+This allows "child" servers to take over ownership of existing connections. 
+
+Details of this function behaviour depend on the transport specified when 
+constructed: in general a listener socket is created, its port number registered 
+as appropriate, and an accept queued.
+
+@param aOwner Server notification interface
+@return KErrArgument if parameter is NULL, KErrAlreadyExists if server has already
+been started (but notification object will still be updated), otherwise a system wide
+error code 
+@panic OBEX EChangeInterfaceDuringWait when attempting to change the interface at an inappropriate time.
+
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexServer::Start(MObexServerNotifyAsync* aOwner)
+	{
+	if(aOwner == NULL)
+		{
+		return(KErrArgument);
+		}
+
+	iOwner = aOwner;											
+
+	iStateMachine->Start(*iOwner);
+	if(iEnabled)
+		{
+		return(KErrAlreadyExists);
+		}
+	iEnabled = ETrue;
+	return(AcceptConnection());
+	}
+	
+
+/** Disconnects any transfer in progress and disables further connections. 
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexServer::Stop()
+	{// Cancel and Disable accepts, and bring and transport down.
+	LOG_LINE
+	LOG_FUNC
+
+	if(!iEnabled)
+		{
+		return;
+		}
+	iEnabled = EFalse;
+	ControlledTransportDown();
+	
+	// just check that iTransportController is still valid here (that is what we
+	// aspect to be)
+	__ASSERT_DEBUG(iTransportController, IrOBEXUtil::Fault(ETransportControllerNotCreated));
+	
+	iTransportController->CancelAccept();
+	iStateMachine->Stop();
+	iOwner = NULL;
+	iSyncWrapper->SetNotifier(NULL);
+	}
+
+TInt CObexServer::AcceptConnection()
+	{
+	if(iEnabled && iOwner)
+		{
+		iCurrentOperation = EOpIdle;
+		TRAPD(err, iTransportController->AcceptConnectionL());
+		if(err != KErrNone)
+			{
+			iEnabled = EFalse;
+			}
+		return(err);
+		}
+	else
+		{
+		return(KErrNone);
+		}
+	}
+
+
+
+/** Sets a password required to access the server.
+
+When a password is set, a client must specify it to access the server.
+
+@param aPassword Password 
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexServer::SetChallengeL(const TDesC& aPassword)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	delete iChallPassword;
+	iChallPassword = NULL;
+	iChallPassword = HBufC8::NewL(aPassword.Length());
+	TPtr8 ptr = iChallPassword->Des();
+	CnvUtfConverter::ConvertFromUnicodeToUtf8(ptr, aPassword);
+	iChallenge = ETrue;
+	}
+
+/** Resets the password.
+
+After this call, a client does not need to provide a password to access the 
+server. 
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexServer::ResetChallenge()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	delete iChallPassword;
+	iChallPassword = NULL;
+	iChallenge = EFalse;
+	}
+
+/**	
+Specifies target header checking behaviour.
+	
+Supports three behaviours---never check, always check, and check only if a target
+header has been sent.  The default behaviour is to only check when a target header
+has been sent.
+	
+No checking allows a form of multiplexing to be used, where one server object may
+respond to multiple target headers.  The behaviour desired by the client can be
+determined by examining the target header specified in the Connect.
+	
+@param aChecking The desired level of target header checking.
+@publishedAll
+@released
+*/
+EXPORT_C void CObexServer::SetTargetChecking(TTargetChecking aChecking)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iTargetChecking = aChecking;
+	}
+
+
+/**
+Prepare next packet for the connection attempt
+ConnectionID and Who headers are Mandatory if the Target header was used in the connection from
+@param aPacket Packet to fill
+@internalComponent
+*/
+TInt CObexServer::PrepareConnectPacket(CObexPacket& aPacket) 
+	{
+	FLOG(_L("CObexServer::PrepareConnectPacket\r\n"));
+	TInt retValue = KErrNone;
+	TConnectState nextState = GetConnectState();
+
+	if(!iTransportController->InsertLocalConnectInfo(aPacket, iLocalInfo.iVersion, iLocalInfo.iFlags))
+		{
+		FLOG(_L("PrepareConnectPacket Local data insertion FAILED\r\n"));
+		return(KErrGeneral);
+		}
+	FLOG(_L("PrepareConnectPacket Local data inserted\r\n"));
+
+	if(GetConnectState() == ESimpleConnRequest)	//no Auth requested by the Client
+		{
+		FLOG(_L("PrepareConnectPacket GetConnectState() == ESimpleConnRequest\r\n"));
+		//if the Server must challenge
+		if(iChallenge) 
+			{
+			FLOG(_L("PrepareConnectPacket Challenge Required\r\n"));
+
+			aPacket.SetOpcode(ERespUnauthorized);  
+			retValue = GenerateChallenge(aPacket);
+			if ( retValue == KErrNone ) 
+				{
+				FLOG(_L("PrepareConnectPacket Challenge generated\r\n"));
+				nextState = ESimpleConnChallIssued;
+				}
+			else
+				{
+				FLOG(_L("PrepareConnectPacket Challenge generation FAILED\r\n"));
+				nextState = EConnTransport;
+				aPacket.SetOpcode(ERespInternalError);
+				}
+			}
+		else //don't require Authentication
+			{
+			FLOG(_L("PrepareConnectPacket No Challenge Required\r\n"));
+
+			aPacket.SetOpcode(ERespSuccess); 
+			//if the Target header was used for the connection
+			//if so then reply with ConnectionID and Who headers
+			if ((retValue = AddConnectionIDHeader(aPacket)) == KErrNone)
+				{
+				FLOG(_L("PrepareConnectPacket ConnectionID Inserted\r\n"));
+				nextState = EConnObex;
+				}
+			else
+				{
+				nextState = EDropLink;
+				FLOG(_L("PrepareConnectPacket ConnectionID Insertion FAILED\r\n"));
+				}
+			}
+		} //end if(GetConnectState() == ESimpleConnRequest) 
+	else if (GetConnectState() == EChallConnRequested)
+		{
+		FLOG(_L("PrepareConnectPacket GetConnectState() == EChallConnRequested\r\n"));
+
+		//if the Server must challenge
+		if(iChallenge) 
+			{
+			FLOG(_L("PrepareConnectPacket Challenge required\r\n"));
+			aPacket.SetOpcode(ERespUnauthorized); 
+			retValue = GenerateChallenge(aPacket);
+			if ( retValue == KErrNone ) 
+				{
+				FLOG(_L("PrepareConnectPacket Challenge Generated\r\n"));
+				nextState = EChallConnChallIssued; //chall answered with another chall
+				}
+			else
+				{
+				FLOG(_L("PrepareConnectPacket Challenge Generation FAILED\r\n"));
+				nextState = EConnTransport;
+				aPacket.SetOpcode(ERespInternalError);
+				}
+			}
+		else //don't require Authentication
+			{ //the response would already have been verified in ParseConnectPacket() 
+			//get password from user, prepare a response to the challenge
+			FLOG(_L("PrepareConnectPacket Challenge Not Required\r\n"));
+			retValue = PrepareFinalChallResponse(aPacket, nextState);
+			}
+		} //end else if GetConnectState() == EChallConnRequested
+	else if (GetConnectState() == EFinalChallRxed)
+		{	//
+		retValue = PrepareFinalChallResponse(aPacket, nextState);
+		}
+	else if ( GetConnectState() == EFinalResponseReceived )
+		{ //the response had to be OK otherwise would never have gotten this far
+		aPacket.SetOpcode(ERespSuccess); 
+		//if the Target header was used for the connection
+		//if so then reply with ConnectionID and Who headers
+		if ((retValue = AddConnectionIDHeader(aPacket)) == KErrNone)
+			{
+			nextState = EConnObex;
+			FLOG(_L("PrepareConnectPacket ConnectionID header Added\r\n"));
+			}
+		else
+			{
+			nextState = EDropLink;
+			FLOG(_L("PrepareConnectPacket ConnectionID header Addition FAILED\r\n"));
+			}
+		}
+	else //it's all gone wrong
+		{
+		FLOG(_L("PrepareConnectPacket complete failure, bad state\r\n"));
+
+		//break connection, inform user
+		nextState = EConnTransport;
+		aPacket.SetOpcode(ERespInternalError);
+		retValue = KErrGeneral;
+		}
+	//if the Server is now connected inform the client
+	if ( nextState == EConnObex)
+		iOwner->ObexConnectIndication(iRemoteInfo, TPtr8(NULL, 0));
+
+	SetConnectState(nextState);
+	return(retValue);
+	}
+/**
+Prepare next packet for an  invalid connection attempt (i.e. the ParseConnectPacket failed).
+A fail response (to a connect request)  includes the version, flags, and packet size information.
+
+@param aPacket Packet to fill
+@internalComponent
+*/
+TInt CObexServer::PrepareErroredConnectPacket(CObexPacket& aPacket)
+	{
+	FLOG(_L("CObexServer::PrepareErroredConnectPacket\r\n"));
+	
+	if ( !iTransportController->InsertLocalConnectInfo(aPacket, iLocalInfo.iVersion, iLocalInfo.iFlags))
+		{
+		FLOG(_L("PrepareConnectPacket Local data insertion FAILED\r\n"));
+		return(KErrGeneral);
+		}	
+	return KErrNone;
+	}
+
+void CObexServer::SignalReadActivity()
+	{
+	iPacketProcessSignaller->Signal(EObexReadActivityDetected);
+	}
+	
+void CObexServer::CheckTarget(TConnectState& aNextState, TInt& aRetVal)
+	{
+	FLOG(_L("Local Who:\r\n"));
+	LOGHEXDESC(iLocalInfo.iWho);
+	FLOG(_L("Target:\r\n"));
+	LOGHEXDESC(iRemoteInfo.iTargetHeader);
+	
+	// Workaround for bug with PocketPC 2002---if target header is sixteen bytes of zeros, connect anyway.
+	_LIT8(KZeroTarget, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00");
+
+	// Allow connection iff:
+	//    PocketPC attempting to connect to inbox (Sixteen bytes of zeros), when no LocalWho
+	// or Target header matches LocalWho (includes Inbox connections)
+	
+	if (!(	// Negate as block below discards connection
+		    ((iLocalInfo.iWho == KNullDesC8) && (iRemoteInfo.iTargetHeader == KZeroTarget))
+		 || ( iLocalInfo.iWho == iRemoteInfo.iTargetHeader)
+	   ))
+		{
+		FLOG(_L("ParseConnectPacket ETarget header doesn't match local iWho, dropping link\r\n"));
+		aNextState = EConnTransport;
+		aRetVal = ERespNotFound;
+		}
+	}
+
+
+//if the Target header is sent then it must match the local iWho field
+TInt CObexServer::ParseConnectPacket(CObexPacket& aPacket)
+	{
+	TConnectState nextState = GetConnectState(); //must change otherwise it's all wrong
+	TBool challReceivedOK = EFalse; //authentication challenge received from client 
+									//after server has issued its own authentication challenge.
+	TBool respReceivedOK = EFalse;  //authentication received from client 
+									//after server has issued its own authentication challenge.
+	FLOG(_L("CObexServer::ParseConnectPacket\r\n"));
+
+	if(!iTransportController->ExtractRemoteConnectInfo(aPacket, iRemoteInfo.iVersion, iRemoteInfo.iFlags))
+		{
+		FLOG(_L("ParseConnectPacket remote connect info extraction FAILED\r\n"));
+		return KErrGeneral;
+		}
+	FLOG(_L("ParseConnectPacket remote connect info extracted\r\n"));
+
+	TObexInternalHeader hdr;
+  	iTargetReceived = EFalse; //if target received then must reply with ConnectionID
+
+	//if the present state is EConnTransport then no headers are actually
+	//required, a simple connect is sufficient
+	if(GetConnectState() == EConnTransport)
+		{
+		nextState = ESimpleConnRequest;
+		}
+
+	TInt retVal = KErrNone;
+	TBool authAttempted = EFalse;
+	
+	while (aPacket.ExtractData(hdr) && (nextState != EDropLink) && (nextState != EConnTransport))
+		{
+		switch(hdr.HI())
+			{
+			case TObexInternalHeader::ETarget:
+				{
+				FLOG(_L("ParseConnectPacket extracting ETarget header\r\n"));
+				iTargetReceived = ETrue;
+				//copy the target header into iRemoteInfo for the user
+				iRemoteInfo.iTargetHeader.Copy(hdr.HVByteSeq(), hdr.HVSize() > iRemoteInfo.iTargetHeader.MaxSize() ? iRemoteInfo.iTargetHeader.MaxSize() : hdr.HVSize());
+
+				if (iTargetChecking == EIfPresent)
+					{
+					FLOG(_L("EIfPresent target header checking..."));
+					CheckTarget(nextState, retVal);
+					}
+				}
+				break;
+			case TObexInternalHeader::EAuthChallenge:
+				{
+				FLOG(_L("ParseConnectPacket EAuthChallenge Header received processing\r\n"));
+				authAttempted = ETrue;
+				TRAPD(err, ProcessChallengeL(hdr));
+				if (!err)
+					{
+					FLOG(_L("ParseConnectPacket Processing Chall SUCCESS\r\n"));
+					if (GetConnectState() == EConnTransport)
+						{
+						nextState = EChallConnRequested;
+						}
+					else if ((GetConnectState() == ESimpleConnChallIssued) || (GetConnectState() == EChallConnChallIssued))
+						{
+						challReceivedOK = ETrue; //the response must be verified first
+						nextState = EFinalChallRxed;
+						}
+					else
+						{
+						nextState = EConnTransport;
+						retVal = ERespInternalError;
+						}
+					}
+				else
+					{
+					FLOG(_L("ParseConnectPacket Processing Chall FAILED\r\n"));
+
+					nextState = EConnTransport;
+					retVal = ERespInternalError;
+					}
+				}
+				break;
+			case TObexInternalHeader::EAuthResponse:
+				{
+				if (iChallenge)
+					//else there is no challenge password to check against!
+					{
+					FLOG(_L("ParseConnectPacket EAuthResponse Header received processing\r\n"));
+					authAttempted = ETrue;
+					TRAPD(err, ProcessChallResponseL(hdr));
+					if (err == KErrNone)
+						{
+						FLOG(_L("ParseConnectPacket Processing Chall Response SUCCESS\r\n"));
+						if (GetConnectState() == ESimpleConnChallIssued)
+							{
+							respReceivedOK =ETrue;
+							if (challReceivedOK) //was a new challenge issued by the Client?
+								{
+								nextState = EFinalChallRxed; //must respond to chall
+								}
+							else
+								{
+								nextState = EFinalResponseReceived; //everything is OK send Success
+								}
+							}
+						else if (GetConnectState() == EChallConnChallIssued)
+							{
+							respReceivedOK =ETrue;
+							if (challReceivedOK) //was a new challenge issued by the Client?
+								{
+								nextState = EFinalChallRxed; //must respond to chall
+								}
+							else
+								{
+								//If we do not later in the packet see a challenge,
+								//(in which case this 'nextState' value will be overwritten),
+								//the client will have come back WITHOUT re-issuing 
+								//either his original challenge or a new one.
+								//Treat as if client had never issued a challenge. 
+								//This sequence has been observed in FOMA phones.
+								nextState = EFinalResponseReceived; 
+								}
+							}
+						else
+							{
+							nextState = EConnTransport;
+							retVal = ERespInternalError;
+							}
+						}
+					else if (err == KErrAccessDenied)
+						{
+						nextState = EConnTransport;
+						retVal = ERespUnauthorized;
+						FLOG(_L("ParseConnectPacket Processing Chall Response FAILED with Access Denied\r\n"));
+						}
+					else
+						{
+						nextState = EConnTransport;
+						retVal = ERespInternalError;
+						FLOG(_L("ParseConnectPacket Processing Chall Response FAILED\r\n"));
+						}
+					}
+				else
+					{
+					// if no challenge was issued, then receiving a challenge response means the peer is badly
+					// behaved. For this case we simply ignore the header, anything else would be too drastic.
+					FLOG(_L("ParseConnectPacket Chall Response received when no Chall issued\r\n"));
+					}
+				}
+				break;
+		default:
+			break;
+			}
+		}
+		
+	if (((GetConnectState() == ESimpleConnChallIssued) || (GetConnectState() == EChallConnChallIssued)) && !respReceivedOK)
+		// Client's connect packet should have contained an authentication response.
+		// Treat as if we had rejected an authentication response.
+		{
+		nextState = EConnTransport;
+		retVal = ERespUnauthorized;
+		}
+		
+	if (iTargetChecking == EAlways)
+		{
+		FLOG(_L("EAlways target header checking..."));
+		CheckTarget(nextState, retVal);
+		}
+
+	if (!authAttempted && (GetConnectState() == ESimpleConnChallIssued))
+		nextState = ESimpleConnRequest;
+
+	SetConnectState(nextState);
+	
+	return retVal;
+	}
+
+
+/** 
+Check, if required, the object connection ID.
+
+@return ETrue if it was not necessary to receive the ConnectionID or
+		if it was necessary and was correctly received. Otherwise 
+		EFalse.
+@internalComponent
+*/
+TBool CObexServer::CheckObjectForConnectionId(CObexBaseObject& aObject)
+	{
+	TBool retValue = ETrue;
+
+	if( iTargetReceived )
+		{
+		retValue = EFalse;
+		if (aObject.iValidHeaders & KObexHdrConnectionID )
+			{
+			TUint32 connID = aObject.ConnectionID();
+			if (iConnectionIdSet && (iConnectionID == connID))
+				{
+				retValue = ETrue;
+				}
+			}
+		}
+	return (retValue);
+	}
+
+/**
+Check, if required, that the packet connection ID matches that of the Server's current connection
+@return ETrue if the connection ID matches or if Target was not used in the original connection
+@return EFalse if Target was not used in the original connection and the connection ID was not found
+@internalComponent
+*/
+TBool CObexServer::CheckPacketForConnectionId(CObexPacket& aPacket)
+	{
+	// Connection ID check is compulsory if Target was used in the original connection
+	if (!iTargetReceived)
+		{
+		return ETrue;
+		}
+
+	// Search for ConnectionID
+	// ConnectionID should be the first header, but we check all of them just in case
+	TObexInternalHeader header;
+	while (aPacket.ExtractData(header))
+		{
+		if (header.HI() == TObexInternalHeader::EConnectionID)
+			{
+			TUint32 newConnectionID = (header.HVByteSeq()[0] << 24) + (header.HVByteSeq()[1] << 16)
+						+ (header.HVByteSeq()[2] << 8)  + (header.HVByteSeq()[3]);
+
+			if (ConnectionID() == newConnectionID)
+				{
+				return ETrue;
+				}
+			}
+		}
+
+	// Target was used in original connection and could not find Connection ID
+	return EFalse;
+	}
+
+void CObexServer::OnPacketReceive(CObexPacket& aPacket)
+	{
+	FLOG(_L("CObexServer::OnPacketReceive\r\n"));
+	MObexServerRequestPacketNotify* packetNotify = NULL;
+	if (iServerRequestPacketEngine)
+		{
+		packetNotify = iServerRequestPacketEngine->RequestPacketNotify();		
+		}
+	// If a packet notify has been registered then we should tell it 
+	// about each request packet we receive.
+	if (packetNotify)
+		{
+		TObexResponse response;
+		TBool normalOperation = ETrue;
+		
+		// Rebuild full OBEX opcode to pass to observer
+		TObexOpcode opcode = aPacket.Opcode() | (aPacket.IsFinal() ? KObexPacketFinalBit : 0);
+		
+		switch (aPacket.Opcode())
+			{
+		case CObex::EOpConnect:
+				{
+				TObexConnectInfo connectInfo;
+				if (!iStateMachine->Transport().ExtractRemoteConnectInfo(aPacket, connectInfo.iVersion, connectInfo.iFlags))
+					{
+					// If the packet cannot be parsed correctly at this stage it is very malformed
+					// and so we should abort processing it for the server app, and defer handling
+					// the error to the state machine.
+					break;
+					}
+				
+				TObexInternalHeader header;
+				// Call ExtractData() until it returns 0 bytes read - then we know the extract
+				// point will have been reset so the CObexPacket can be parsed again in the 
+				// future.  For this reason do not attempt to optimise this loop.
+				while (aPacket.ExtractData(header))
+					{
+					switch (header.HI())
+						{
+					case TObexInternalHeader::ETarget:
+						 // Only take the first Target header found
+						 if (connectInfo.iTargetHeader.Length() == 0)
+							{
+							TInt size = header.HVSize() > connectInfo.iTargetHeader.MaxSize() ? connectInfo.iTargetHeader.MaxSize() : header.HVSize();
+							connectInfo.iTargetHeader.Copy(header.HVByteSeq(), size);
+							}
+						break;
+					case TObexInternalHeader::EWho:
+						 // Return the first Who header in packet
+						 if (connectInfo.iWho.Length() == 0)
+							{
+							TInt size = header.HVSize() > connectInfo.iWho.MaxSize() ? connectInfo.iWho.MaxSize() : header.HVSize();
+							connectInfo.iWho.Copy(header.HVByteSeq(), size);
+							}
+						break;
+					default:
+						break;
+						}
+					}
+				
+				normalOperation = packetNotify->RequestPacket(opcode, connectInfo, response);
+				}
+			break;
+		case CObex::EOpSetPath:
+				{
+				TObexSetPathData data;
+	
+				if (!aPacket.ExtractData(data))
+					{
+					// If the packet cannot be parsed correctly at this stage it is very malformed
+					// and so we should abort processing it for the server app, and defer handling
+					// the error to the state machine.
+					break;
+					}
+				CObex::TSetPathInfo info(data);
+					
+				TObexInternalHeader header;
+				// Call ExtractData() until it returns 0 bytes read - then we know the extract
+				// point will have been reset so the CObexPacket can be parsed again in the 
+				// future.  For this reason do not attempt to optimise this loop.
+				while(aPacket.ExtractData(header))
+					{
+					// Take the first name header we find.
+					if(!info.iNamePresent && header.HI() == TObexInternalHeader::EName && header.GetHVText(info.iName) == KErrNone)
+						{
+						info.iNamePresent = ETrue;
+						}
+					}
+	
+				normalOperation = packetNotify->RequestPacket(opcode, info, response);
+				}
+			break;	
+		case CObex::EOpDisconnect:
+		case CObex::EOpAbortNoFBit:
+		case CObex::EOpPut:
+		case CObex::EOpGet:	
+		default:
+			normalOperation = packetNotify->RequestPacket(opcode, response);
+			break;
+			}
+
+		if (!normalOperation) // Abandon processing of request
+			{
+			CheckServerAppResponseCode(aPacket.Opcode(), response); // a success response code => panic
+			iStateMachine->OverrideRequestHandling(response);
+			return;
+			}
+		}
+
+	// Normal processing
+	iStateMachine->OnPacketReceive(aPacket);
+	}
+
+/**
+This function is to ensure that a response a server application provides the Obex Server
+to respond to the Obex Client with when it has overriden the default handling of a request
+packet does not represent a success.
+
+The rationale for this is to attempt to keep the Obex peers synchronised.  As the packet has
+been dropped, the client should not be lead to believe it has been received successfully.
+
+Therefore, this function asserts that the application does not send a success response for 
+the request packet received.
+*/	
+void CObexServer::CheckServerAppResponseCode(TObexOpcode aOpcode, TObexResponse aResponse)
+	{
+	TBool valid = ETrue;
+	switch (aOpcode)
+		{
+		case CObex::EOpConnect:
+			if (aResponse == ERespSuccess)
+				{
+				valid = EFalse;
+				}
+			break;
+		case CObex::EOpPut:
+		case CObex::EOpGet:
+			if (aResponse == ERespSuccess || aResponse == ERespContinue)
+				{
+				valid = EFalse;
+				}
+			break;
+		case CObex::EOpSetPath:
+			if (aResponse == ERespSuccess)
+				{
+				valid = EFalse;
+				}
+			break;
+		case CObex::EOpDisconnect:
+		case CObex::EOpAbortNoFBit:
+			// We allow any response to a abort/disconnect request,
+			// as only success codes are allowed.
+		default:
+			break;
+		}
+	__ASSERT_ALWAYS(valid, IrOBEXUtil::Panic(EInvalidResponseCodeFromServerApp));
+	}
+
+void CObexServer::OnError(TInt aError)
+	{
+	FTRACE(FPrint(_L("OnError aError: %d iCurrentOperation: %d, iConnectState: %d"), aError, iCurrentOperation, iConnectState));
+
+	if (aError == KErrDisconnected)
+		{
+		// Note: It is not clear that iCurrentOperation is ever equal
+		// to EOpDisconnect but the check has been retained just in case
+		if ((iCurrentOperation != EOpDisconnect) && (iConnectState > EConnTransport))
+			{
+			 //extended error for IrObex,("peer device aborted data transmission/obex sending") 
+			iOwner->ErrorIndication(KErrIrObexServerPutPeerAborted);
+			}
+		}
+	else
+		{
+		iOwner->ErrorIndication(aError);
+		}
+	// The state machine needs to know about the error regardless of whether ErrorIndication() is called
+	iStateMachine->Error();
+	}
+
+void CObexServer::OnTransportUp()
+	{
+	iTargetReceived = EFalse;
+
+	// For servers on the device using USB, there is a possibility that
+	// this function can be called, even though the server is stopped,
+	// as OBEX does not control the transport, the USB host does.
+	// Hence the need to check if there is an active iOwner.
+	if (iOwner)
+		{
+		iOwner->TransportUpIndication();
+		}
+	iStateMachine->TransportUp(); // state machine needs to know about the event regardless of Server state
+	}
+
+/**
+Tell the MObexServerNotifyAsync observer the transport is down and listen
+for another connection.
+*/
+void CObexServer::OnTransportDown()
+	{// Cancel Anything waiting. Restart the accepter	
+
+	// For servers on the device using USB, there is a possibility that
+	// this function can be called, even though the server is stopped,
+	// as OBEX does not control the transport, the USB host does
+	// Hence the need to check if there is an active iOwner.
+	if (iOwner)
+		{
+		iOwner->TransportDownIndication();
+		}
+	iStateMachine->TransportDown(); // state machine needs to know about the event regardless of Server state
+	TInt err = AcceptConnection();
+	if(err != KErrNone)
+		Error(err);
+	}
+
+/** Signals an event has ocurred.
+
+@released
+@internalComponent
+@param aEvent The event that has occurred. (TObexPacketProcessEvent)
+*/
+void CObexServer::SignalPacketProcessEvent(TInt aEvent)
+	{
+	LOG_FUNC
+
+	// This is how we signal the completed send of an ACK to a disconnect 
+	// command. Tell the state machine so it can finish the disconnection 
+	// sequence.
+	if(aEvent & EObexWriteCompletedFinal)
+		{
+		iStateMachine->WriteComplete();
+		}
+
+	// Server will have definitely finished with the read packet so queue the next read
+	if(aEvent & EObexWriteCompleted)
+		{
+		iTransportController->Receive();
+		}
+		
+	if(aEvent & EObexReadActivityDetected)
+		{
+		iStateMachine->ReadActivityDetected();
+		}
+	}
+	
+// CObexServer
+/** Tests if the server is started, and is available to accept connections.
+	
+@return ETrue if the server is started, EFalse otherwise
+	
+@publishedAll
+@released
+*/
+EXPORT_C TBool CObexServer::IsStarted() 
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return iEnabled;
+	}
+
+/**
+Returns the operation currently being performed by the remote client, or 
+EOpIdle if between operations. Note that there is no implication of whether 
+the server is currently connected; EOpIdle will be returned regardless of 
+connection state, if no operation is currently being performed. Use 
+CObex::IsConnected () to find connection staus.
+
+@return Operation currently being performed by the remote client
+
+@publishedAll
+@released
+*/
+EXPORT_C CObex::TOperation CObexServer::CurrentOperation() const 
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return iCurrentOperation;
+	}
+
+/**
+Setter function to allow other classes in the DLL to set the Server's current operation.
+Used by the Server state machine.
+@see CObexServerStateMachine
+@param aOperation The operation currently being performed by the remote client
+@internalComponent
+*/
+void CObexServer::SetCurrentOperation(const CObex::TOperation aOperation)
+	{
+	iCurrentOperation = aOperation;
+	}
+
+/**
+Specify the set of headers to return to remote Obex client in final
+Put response packet. The total length of the headers when encoded 
+should not exceed the maximum Obex packet payload size.
+
+This function may be called at any point during a Put operation.
+Repeated calls to this replace rather than add to the header set
+for inclusion in the final Put response packet.
+
+It may be called with a NULL pointer, which means that no headers
+will be sent with the Put Final Response.
+
+Even if this function returns with an error (even KErrNotReady) a
+best-effort attempt will be made to send as many headers as will fit
+in the final Put response packet.
+
+@param aHeaderSet A set of headers to be encoded in the final Put
+response packet. Ownership of the header set always passes to 
+CObexServer.
+
+@return KErrNone if the operation completes successfully.
+		KErrNotReady if the current operation is not a Put.
+		KErrArgument if the length of the headers when encoded
+		exceeds the maximum Obex packet payload size.
+		
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexServer::SetPutFinalResponseHeaders(CObexHeaderSet* aHeaderSet)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	//	First, let the state machine take ownership of the headerset
+	iStateMachine->SetPutFinalResponseHeaderSet(aHeaderSet);
+
+	TInt err=KErrNone;
+
+	//	Easy check first - are we currently engaged in a Put?
+	if(iCurrentOperation != EOpPut)
+		{
+		err=KErrNotReady;
+		}
+
+	if(!err && aHeaderSet)
+		{
+		//	Next, the not so easy check. Will all the headers, when encoded,
+		//	fit inside a send packet? 
+		//	First, how much space do we have to play with?
+		TInt available = iTransportController->SendPacket().DataLimit() - KObexPacketHeaderSize;
+		
+		//	Next, what is the combined encoded size of all the headers?
+		TInt required = 0;
+		aHeaderSet->First();
+		while(aHeaderSet->This(iHeader) == KErrNone)
+			{
+			required+=iHeader->EncodedSize();
+			(void)aHeaderSet->Next();
+			}
+
+		if(required>available)
+			{
+			err=KErrArgument;
+			}
+		}
+		
+	return err;
+	}
+
+
+/**
+Complete an asynchronous callback, supplying a CObexBaseObject derived object.
+Passing in NULL results in an Obex level error being sent to the client -- the
+semantics are that either a PUT request has been rejected or a GET request has
+not found a suitable object to return.
+
+@panic Obex ENoNotificationToComplete Raised if the server does not have a request
+outstanding.
+@param aObject The object passed back from application
+@return result of state changes
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexServer::RequestIndicationCallback(CObexBaseObject* aObject)
+	{
+	LOG_LINE
+	LOG_FUNC
+	return iStateMachine->RequestNotificationCompleted(aObject);
+	}
+
+/**
+Complete an asynchronous callback, supplying a obex response code. Applications 
+should use this function when rejecting Get/Put RequestIndication in order to 
+specify the response code.
+
+@panic Obex ENoNotificationToComplete Raised if the server does not have a request
+outstanding.
+@panic Obex EInvalidResponseCodeFromServerApp raised if TObexResponse aResponseCode is outside range
+[1,255] or it is one of the successful response (e.g. ERespSuccess, ERespContinue) 
+@param TObexResponse aResponseCode Application's response to the indication as an Obex response Code. The Final bit is ignored.
+@return result of state changes
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexServer::RequestIndicationCallbackWithError(TObexResponse aResponseCode)
+	{
+	LOG_LINE
+	LOG_FUNC
+	return iStateMachine->RequestNotificationCompleted(aResponseCode);
+	}
+
+/**
+Complete an asynchronous callback, supplying a obex response code. Applications 
+should use this function when rejecting Get/Put RequestIndication in order to 
+specify the error code.
+
+@panic Obex ENoNotificationToComplete Raised if the server does not have a request
+outstanding.
+@panic Obex EInvalidResponseCodeFromServerApp raised if TObexResponse aResponseCode non-negtive. Note: KErrNone is 
+not acceptable because this function is only used when there is an error.
+@param aErrorCode Application's response to the indication as an Obex response Code. 
+@return result of state changes
+@publishedAll
+@released
+*/	
+EXPORT_C TInt CObexServer::RequestIndicationCallbackWithError(TInt aErrorCode)
+	{
+	LOG_LINE
+	LOG_FUNC
+	__ASSERT_ALWAYS(aErrorCode <= 0, IrOBEXUtil::Panic(EInvalidResponseCodeFromServerApp));
+	return iStateMachine->RequestNotificationCompleted(IrOBEXUtil::ObexResponse(aErrorCode, ERespSuccess));
+	}
+	
+	
+/**
+Complete an asynchronous callback, supplying a obex response code. This function is 
+used for asychronously handling PutComplete, GetComplete and SetPath Indication. 
+
+@panic Obex ENoNotificationToComplete Raised if the server does not have a request
+outstanding.
+@panic Obex EInvalidResponseCodeFromServerApp raised if TObexResponse aResponseCode is outside range
+[1,255] or it is ERespContinue (which would confuse the client)
+@param TObexResponse aResponseCode Application's response to the indication as an Obex response Code. The Final bit is ignored.
+@return result of state changes
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexServer::RequestCompleteIndicationCallback(TObexResponse aResponseCode)
+	{
+	LOG_LINE
+	LOG_FUNC
+	return iStateMachine->RequestCompleteNotificationCompleted(aResponseCode);
+	}
+
+/**
+Complete an asynchronous callback, supplying a obex response code. This function is 
+used for asychronously handling PutComplete, GetComplete and SetPath Indication. 
+
+@panic Obex ENoNotificationToComplete Raised if the server does not have a request
+outstanding.
+@panic Obex EInvalidResponseCodeFromServerApp raised if aErrorCode is positive, i.e. 
+invalid Symbian error code
+@param TObexResponse aResponseCode Application's response to the indication as a Symbian error code
+@return result of state changes
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexServer::RequestCompleteIndicationCallback(TInt aErrorCode)
+	{
+	LOG_LINE
+	LOG_FUNC
+	__ASSERT_ALWAYS(aErrorCode <= 0, IrOBEXUtil::Panic(EInvalidResponseCodeFromServerApp));
+	return iStateMachine->RequestCompleteNotificationCompleted(IrOBEXUtil::ObexResponse(aErrorCode, ERespSuccess));
+	}
+	
+/**
+Provides the pre-parsed contents of the most recently received request packet.
+
+@param aHeaderSet A reference to a pointer that will be modified to NULL if no headers
+are contained in the request packet, or to point to a new headerset containing
+representations of the headers within the packet. Ownership of the headerset
+(when aHeaderSet is not NULL) is passed to the caller.
+@return KErrNone if successful, otherwise a system wide error code.
+
+@publishedPartner
+@released
+*/
+EXPORT_C TInt CObexServer::PacketHeaders(CObexHeaderSet*& aHeaderSet)
+	{
+	FLOG(_L8("CObexServer::PacketHeaders"));
+
+	return DoPacketHeaders(aHeaderSet, NULL);	
+	}
+
+
+/**
+Provides the selectively pre-parsed contents of the most recently received request packet.
+
+@param aHeaderSet A reference to a pointer that will be modified to NULL if no interesting
+header are contained in the request packet, or to point to a new headerset containing
+representations of the headers within the packet that are of interest. Ownership of the 
+headerset (when aHeaderSet is not NULL) is passed to the caller.
+@param aHeaderCheck A reference to an MObexHeaderCheck derived class that encapsulates
+whether or not a particular header or headers should be included in the returned header
+set (i.e. whether the headers are "interesting").
+
+@return KErrNone if successful, otherwise a system wide error code.
+
+@publishedPartner
+@released
+*/
+EXPORT_C TInt CObexServer::PacketHeaders(CObexHeaderSet*& aHeaderSet, MObexHeaderCheck& aHeaderCheck)
+	{
+	FLOG(_L8("CObexServer::PacketHeaders (selective)"));
+
+	return DoPacketHeaders(aHeaderSet, &aHeaderCheck);
+	}
+
+/** Sets a read activity observer.
+
+This replaces any previous observer.  The observer will receive a callback
+when the first read arrives for a put or get request. 
+
+This does not transfer ownership.
+
+@publishedPartner
+@released
+@param aObserver The observer to receive packet process events.  This may
+				 be NULL.
+*/
+EXPORT_C void CObexServer::SetReadActivityObserver(MObexReadActivityObserver* aObserver)
+	{
+	iPacketProcessSignaller->SetReadActivityObserver(aObserver);
+	}
+/**
+Contains the functionality for the PacketHeader interface functions in a refactored way.
+
+@param aHeaderSet A reference to a pointer that will be modified to NULL if no interesting
+header are contained in the request packet, or to point to a new headerset containing
+representations of the headers within the packet that are of interest. Ownership of the 
+headerset (when aHeaderSet is not NULL) is passed to the caller.
+@param aHeaderCheck A pointer to an MObexHeaderCheck derived class that encapsulates
+whether or not a particular header or headers should be included in the returned header
+set (i.e. whether the headers are "interesting").  If the pointer is NULL then that is taken
+to mean that all headers should be added to the aHeaderSet.
+
+@return KErrNone if successful, otherwise a system wide error code.
+*/	
+TInt CObexServer::DoPacketHeaders(CObexHeaderSet*& aHeaderSet, MObexHeaderCheck* aHeaderCheck)
+	{
+	FLOG(_L8("CObexServer::DoPacketHeaders"));
+	
+	TRAPD(err, aHeaderSet = CObexHeaderSet::NewL());
+	if (err != KErrNone)
+		{
+		aHeaderSet = NULL;
+		return err;
+		}
+	
+	CObexPacket& packet = iTransportController->ReceivePacket();
+	
+	// for "non-standard" size requests ensure we correctly start
+	// extracting headers where they start.
+	switch (packet.Opcode())
+		{
+	case CObex::EOpConnect:
+			{
+			TObexConnectInfo connectInfo;
+			if (!iStateMachine->Transport().ExtractRemoteConnectInfo(packet, connectInfo.iVersion, connectInfo.iFlags))
+				{
+				err = KErrUnderflow;
+				}
+			}
+		break;
+	case CObex::EOpSetPath:
+			{
+			TObexSetPathData data;
+			if (!packet.ExtractData(data))
+				{
+				err = KErrUnderflow;
+				}
+			}
+		break;
+	default:	
+		break;	
+		}
+	
+	TBool interestingHeaders = EFalse;
+	TObexInternalHeader header;
+	// Call ExtractData() until it returns 0 bytes read - then we know the extract
+	// point will have been reset so the CObexPacket can be parsed again in the 
+	// future.  For this reason do not attempt to optimise this loop.
+	while(packet.ExtractData(header))
+		{
+		// if there was an error previously we want to just keep going through the
+		// loop to reset the CObexPacket extraction point.
+		if (err == KErrNone && (!aHeaderCheck || aHeaderCheck->Interested(header.HI())))
+			{
+			err = IrOBEXHeaderUtil::ParseHeader(header, *aHeaderSet);
+			if (!interestingHeaders && err == KErrNone)
+				{
+				interestingHeaders = ETrue;
+				}
+			}
+		}
+
+	if (err != KErrNone || !interestingHeaders)
+		{
+		delete aHeaderSet;
+		aHeaderSet = NULL;
+		}
+	return err;	
+	}
+
+/**
+Provides additional interfaces for CObexServer.
+
+@param aUid The UID of the interface that is required.
+@return A pointer to an instance implementing the interface represented by aUid.
+
+@leave KErrNotSupported if the given UID does not represent an interface CObexServer can provide.
+@leave KErrInUse if an instance of MObexServerRequestPacketNotifyRegister has already been provided
+				 by an earlier call to ExtensionInterfaceL, and it has not been released.
+
+@internalTechnology
+*/
+EXPORT_C TAny* CObexServer::ExtensionInterfaceL(TUid aUid)
+	{
+	// MObexServerRequestPacketNotifyRegister interface
+	if (aUid == KObexServerRequestPacketNotifyRegisterInterface)
+		{
+		// We only return an instance if there are no other packet access extensions
+		// hooked into the CObexServer instance (indicated by the existance of an engine).
+		if (iServerRequestPacketEngine)
+			{
+			User::Leave(KErrInUse);
+			}
+		iServerRequestPacketEngine = CObexServerRequestPacketEngine::NewL(*this);
+		return static_cast<MObexServerRequestPacketNotifyRegister*>(iServerRequestPacketEngine);
+		}
+	// if we don't know the interface UID then we don't support it.
+	User::Leave(KErrNotSupported);
+	return NULL; // to silence the compiler.
+	}
+
+/** 
+Returns a pointer to the TObexTransportInfo being used by the OBEX transport 
+layer. THE USER MUST NOT MODIFY THE OBJECT POINTED TO.
+This is useful primarily when using OBEX over RFCOMM and the user has 
+specified 'KRfcommPassiveAutoBind' as the port. KRfcommPassiveAutoBind makes 
+RFCOMM itself find a free port. The user needs to know which port is really 
+being used by RFCOMM in order to correctly populate the SDP record. 
+May be called meaningfully after CObexServer::Start has returned KErrNone. 
+@return Pointer to the transport layer's transport info.
+@publishedAll
+@released
+*/
+EXPORT_C const TObexTransportInfo* CObexServer::TransportInfo() const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	__ASSERT_DEBUG(iTransportController, IrOBEXUtil::Fault(ETransportControllerNotCreated));
+	return iTransportController->TransportInfo();
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexservernotify.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,43 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedAll
+*/
+
+#include <obexserver.h>
+
+/**
+This virtual function allows the M- classes to be extended in future in a binary
+compatible way by providing a method that clients can override in future to
+allow extra callbacks to be made via aObject.
+*/	
+EXPORT_C void MObexServerNotify::MOSN_ExtensionInterfaceL(TUid /*aInterface*/, void*& aObject)
+	{
+	aObject = NULL;
+	}
+
+/**
+This virtual function allows the M- classes to be extended in future in a binary
+compatible way by providing a method that clients can override in future to
+allow extra callbacks to be made via aObject.
+*/	
+EXPORT_C void MObexServerNotifyAsync::MOSNA_ExtensionInterfaceL(TUid /*aInterface*/, void*& aObject)
+	{
+	aObject = NULL;
+	}
+
+// EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexservernotifysyncwrapper.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,187 @@
+// 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:
+// All methods in this file act either to initialise the wrapper object or to forward calls
+// from the async server notify class to the synchronous version.
+// 
+//
+
+/**
+ @file
+ @internalComponent
+ @see MObexServerNotify
+ @see MObexServerNotifyAsync
+*/
+
+#include <e32base.h>
+#include <obexserver.h>
+#include <obexobjects.h>
+#include "logger.h"
+#include "OBEXUTIL.H"
+#include "obexservernotifysyncwrapper.h"
+#include "obexserverstatemachine.h"
+
+
+#ifdef _DEBUG
+// Save the return value as debugger will (hopefully) then make it easier to see...
+#define CHECK_NOERROR(expr) TInt _saved_error = (expr); __ASSERT_ALWAYS(_saved_error == KErrNone, IrOBEXUtil::Fault(ESyncWrapperCallbackError));
+#else
+#define CHECK_NOERROR(expr) (void)expr
+#endif
+//
+// Initialisation methods
+//
+CObexServerNotifySyncWrapper* CObexServerNotifySyncWrapper::NewL(CObexServer& aOwner, CObexServerStateMachine& aStateMachine)
+	{
+	CObexServerNotifySyncWrapper* self = new (ELeave) CObexServerNotifySyncWrapper(aOwner, aStateMachine);
+	return self;
+	}
+
+CObexServerNotifySyncWrapper::CObexServerNotifySyncWrapper(CObexServer& aOwner, CObexServerStateMachine& aStateMachine)
+	: iOwner(aOwner), iStateMachine(aStateMachine)
+	{}
+
+CObexServerNotifySyncWrapper::~CObexServerNotifySyncWrapper()
+	{
+	}
+
+void CObexServerNotifySyncWrapper::SetNotifier(MObexServerNotify* aNotify)
+	{
+	// if aNotify is NULL this will cause any forwarding methods to dereference NULL.
+	// But this should never happen.  K-E 3 will result if they do, but all we'd
+	// do otherwise would be to panic anyway...
+	iNotify = aNotify;
+	}
+
+//
+// Forwarding methods
+//
+void CObexServerNotifySyncWrapper::ErrorIndication(TInt aError)
+	{
+	iNotify->ErrorIndication(aError);
+	}
+
+void CObexServerNotifySyncWrapper::TransportUpIndication()
+	{
+	iNotify->TransportUpIndication();
+	}
+
+void CObexServerNotifySyncWrapper::TransportDownIndication()
+	{
+	iNotify->TransportDownIndication();
+	}
+
+void CObexServerNotifySyncWrapper::ObexConnectIndication(const TObexConnectInfo& aRemoteInfo, const TDesC8& aInfo)
+	{
+	// Explicitly code that we're ignoring the return value.  See the doxygen comment.
+	(void)iNotify->ObexConnectIndication(aRemoteInfo, aInfo);
+	}
+
+void CObexServerNotifySyncWrapper::ObexDisconnectIndication(const TDesC8& aInfo)
+	{
+	iNotify->ObexDisconnectIndication(aInfo);
+	}
+
+//
+// Forward the request to the MObexServerNotify implementation, then immediately
+// downcall into CObexServer.
+//
+void CObexServerNotifySyncWrapper::PutRequestIndication()
+	{
+	WRAPPER_LOG(_L8("Put request indication"));
+	iCallbackOutstanding = ETrue;
+	iStateMachine.SetAppResponse(ERespSuccess);
+	// A NULL return here is OK as it is the response to reject the request.
+	CObexBaseObject* object = iNotify->PutRequestIndication();
+	
+	WRAPPER_LOG(_L8("Put request indication complete"));
+	if(iCallbackOutstanding && (iStateMachine.AppResponse() == ERespSuccess))
+		{
+		CHECK_NOERROR(iOwner.RequestIndicationCallback(object));
+		}
+	}
+
+TInt CObexServerNotifySyncWrapper::PutPacketIndication()
+	{
+	return iNotify->PutPacketIndication();
+	}
+
+void CObexServerNotifySyncWrapper::PutCompleteIndication()
+	{
+	iCallbackOutstanding = ETrue;
+	TInt err = iNotify->PutCompleteIndication();
+	TObexResponse resp = IrOBEXUtil::ObexResponse(err, ERespSuccess);
+	if(iCallbackOutstanding)
+		{
+		CHECK_NOERROR(iOwner.RequestCompleteIndicationCallback(resp));
+		}
+	}
+
+//
+// Forward the request to the MObexServerNotify implementation, then immediately
+// downcall into CObexServer.
+//
+void CObexServerNotifySyncWrapper::GetRequestIndication(CObexBaseObject* aRequiredObject)
+	{
+	WRAPPER_LOG(_L8("Get request indication"));
+	iCallbackOutstanding = ETrue;
+	iStateMachine.SetAppResponse(ERespSuccess);
+	// A NULL return here is OK as it is the response to reject the request.
+	CObexBaseObject* object = iNotify->GetRequestIndication(aRequiredObject);
+	
+	WRAPPER_LOG(_L8("Get request indication complete"));
+	if(iCallbackOutstanding && (iStateMachine.AppResponse() == ERespSuccess))
+		{
+		CHECK_NOERROR(iOwner.RequestIndicationCallback(object));
+		}
+	}
+
+TInt CObexServerNotifySyncWrapper::GetPacketIndication()
+	{
+	return iNotify->GetPacketIndication();
+	}
+
+void CObexServerNotifySyncWrapper::GetCompleteIndication()
+	{
+	iCallbackOutstanding = ETrue;
+	TInt err = iNotify->GetCompleteIndication();
+	TObexResponse resp = IrOBEXUtil::ObexResponse(err, ERespSuccess);
+	if(iCallbackOutstanding)
+		{
+		CHECK_NOERROR(iOwner.RequestCompleteIndicationCallback(resp));
+		}
+	}
+
+void CObexServerNotifySyncWrapper::SetPathIndication(const CObex::TSetPathInfo& aPathInfo, const TDesC8& aInfo)
+	{
+	iCallbackOutstanding = ETrue;
+	TInt err = iNotify->SetPathIndication(aPathInfo, aInfo);
+	TObexResponse resp = IrOBEXUtil::ObexResponse(err, ERespSuccess);
+	if(iCallbackOutstanding)
+		{
+		CHECK_NOERROR(iOwner.RequestCompleteIndicationCallback(resp));
+		}
+	}
+
+void CObexServerNotifySyncWrapper::AbortIndication()
+	{
+	iNotify->AbortIndication();
+	}
+
+void CObexServerNotifySyncWrapper::CancelIndicationCallback()
+	{
+	//Appilcation may stop the obex server for whatever reason during an Indication 
+	//thus resets the state machine. We have to make sure not to call indication 
+	//callback in such cases because the statemachine will panic. 
+	iCallbackOutstanding = EFalse;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexserverrequestpacketengine.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#include "obexserverrequestpacketengine.h"
+#include <obexserver.h>
+
+CObexServerRequestPacketEngine* CObexServerRequestPacketEngine::NewL(CObexServer& aServer)
+	{
+	CObexServerRequestPacketEngine* self = new (ELeave) CObexServerRequestPacketEngine(aServer);
+	return self;
+	}
+	
+CObexServerRequestPacketEngine::~CObexServerRequestPacketEngine()
+	{
+
+	}
+	
+CObexServerRequestPacketEngine::CObexServerRequestPacketEngine(CObexServer& aServer)
+	: iServer(aServer)
+	{
+
+	}
+
+void CObexServerRequestPacketEngine::SetObexServerRequestPacketObserver(MObexServerRequestPacketNotify& aRequestPacketNotify)
+	{
+	iRequestPacketNotify = &aRequestPacketNotify;
+	}
+	
+void CObexServerRequestPacketEngine::DeleteObexServerRequestPacketNotifyRegister()
+	{
+	iServer.iServerRequestPacketEngine = NULL;
+	delete this;
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexserverstatemachine.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,477 @@
+// 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 <obex.h>
+#include <obex/internal/obexinternalheader.h>
+#include "obexserverstatemachine.h"
+
+#if ( defined __FLOG_ACTIVE && defined __LOG_FUNCTIONS__ )
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/**
+@file
+@internalComponent
+*/
+
+/**
+Constructs the state machine and the state classes
+
+@param aOwner Server object that owns the state machine
+@param aTransport Transport Controller associated with the Server
+
+@return Contructed CObexServerStateMachine object
+*/
+CObexServerStateMachine* CObexServerStateMachine::NewL(CObexServer& aOwner, CObexTransportControllerBase& aTransport)
+	{
+	CObexServerStateMachine* self = new(ELeave) CObexServerStateMachine(aOwner, aTransport);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+First phase constructor
+
+@param aOwner Server object that owns the state machine
+@param aTransport Transport Controller associated with the Server
+*/
+CObexServerStateMachine::CObexServerStateMachine(CObexServer& aOwner, CObexTransportControllerBase& aTransport)
+	: iCurrentState(&iStates[EDisconnected]), iTransport(aTransport), iOwner(aOwner), iServerStarted(EFalse)
+	{
+	// Use placement new here to create the state objects and put them into a pre-defined array
+	// This is done as the number of states is known at compile time and this avoids heap fragmentation
+	new(&iStates[EDisconnected]) TObexServerStateDisconnected();
+	new(&iStates[ETransportConnected]) TObexServerStateTransportConnected();
+	new(&iStates[EObexConnecting]) TObexServerStateObexConnecting();
+	new(&iStates[EWaitForUserPassword]) TObexServerStateWaitForUserPassword();
+	new(&iStates[EReady]) TObexServerStateReady();
+	new(&iStates[EPutOpWaitForUser]) TObexServerStatePutOpWaitForUser();
+	new(&iStates[EPutOpReceiveObject]) TObexServerStatePutOpReceiveObject();
+	new(&iStates[EGetOpReceiveSpecification]) TObexServerStateGetOpReceiveSpecification();
+	new(&iStates[EGetOpWaitForUser]) TObexServerStateGetOpWaitForUser();
+	new(&iStates[EGetOpSendObject]) TObexServerStateGetOpSendObject();
+	new(&iStates[ESetPathOp]) TObexServerStateSetPathOp();
+	new(&iStates[EPutOpFinal]) TObexServerStatePutOpFinal();
+	new(&iStates[EGetOpFinal]) TObexServerStateGetOpFinal();
+	new(&iStates[EDisconnecting]) TObexServerStateDisconnecting();
+	}
+
+/**
+Second phase constructor
+*/
+void CObexServerStateMachine::ConstructL()
+	{
+	iSpecObject = CObexNullObject::NewL();
+	iHeader = CObexHeader::NewL();
+	iCallBack = new(ELeave) CAsyncCallBack(CActive::EPriorityStandard);
+	}
+
+/**
+Destructor
+*/
+CObexServerStateMachine::~CObexServerStateMachine()
+	{
+	// No need to delete state array
+	delete iHeader;
+	delete iSpecObject;
+	delete iPutFinalResponseHeaderSet;
+	delete iCallBack;
+	}
+
+/**
+Move machine to a new state
+Note that this function is synchronous, so any code after calling this function
+will be executed with the machine in a different state.
+Usually the action after changing state should be to return from the current function.
+
+@param aState Index of new state
+@return Result of state change
+*/
+void CObexServerStateMachine::ChangeState(TObexServerOperationStateEnum aState)
+	{
+	STATE_LOG_2(_L8("Changing from state %S to %S"), &iCurrentState->iName, &iStates[aState].iName);
+	iCurrentState = &(iStates[aState]);
+	iCurrentStateEnum = aState;
+	iCurrentState->Entry(*this);
+	}
+
+void CObexServerStateMachine::ControlledTransportDown()
+	{
+	LOG_FUNC
+
+	iOwner.ControlledTransportDown();
+	}
+
+/**
+Process a received packet according to the packet's op-code and the current state
+
+@param aPacket Packet to process
+@return Result of any state changes
+*/
+void CObexServerStateMachine::OnPacketReceive(CObexPacket& aPacket)
+	{
+	if (!iServerStarted)
+		{
+		__ASSERT_DEBUG(iServerStarted, IrOBEXUtil::Fault(EPacketReceivedWhenServerNotStarted));
+		return;
+		}
+
+	iLastReceivedPacket = &aPacket;
+
+	if(Transport().IsWriteActive())
+ 		{
+ 		FLOG(_L("OnPacketReceive received request whilst writing... dropping connection\r\n"));
+		Notification().ObexDisconnectIndication(KNullDesC8);
+		// change state before issuing the transport down, as it may cause notifications
+		ChangeState(ETransportConnected);
+		ControlledTransportDown();
+		return;
+ 		}
+
+	// Initialise the send packet to ensure that we do not
+	// accidentally send the same packet as last time!
+	iTransport.SendPacket().Init(0);
+
+	switch (aPacket.Opcode())
+		{
+	case CObex::EOpConnect:
+		STATE_LOG(_L8("Calling connect"));
+		iCurrentState->Connect(*this, aPacket);
+		break;
+	case CObex::EOpDisconnect:
+		STATE_LOG(_L8("Calling disconnect"));
+		iCurrentState->Disconnect(*this, aPacket);
+		break;
+	case CObex::EOpPut:
+		STATE_LOG(_L8("Calling put"));
+		iCurrentState->Put(*this, aPacket);
+		break;
+	case CObex::EOpGet:
+		STATE_LOG(_L8("Calling get"));
+		iCurrentState->Get(*this, aPacket);
+		break;
+	case CObex::EOpSetPath:
+		STATE_LOG(_L8("Calling SetPath"));
+		iCurrentState->SetPath(*this, aPacket);
+		break;
+	case CObex::EOpAbortNoFBit:
+		// Abort does not check target headers (hence no need to send the packet to the event)
+		STATE_LOG(_L8("Calling abort"));
+		iCurrentState->Abort(*this);
+		break;
+
+	default:
+		// Unknown packet type
+		STATE_LOG(_L8("Unknown packet type"));
+		iTransport.Send(ERespNotImplemented);
+		break;
+		}
+	}
+
+/**
+Indicates a transport-level connection has been made to the Server
+*/
+void CObexServerStateMachine::TransportUp()
+	{
+	// This event could happen while the Server is stopped (as the transport state
+	// can be independent of whether the Server has requested a read)
+	iCurrentState->TransportUp(*this);
+	}
+
+/**
+Indicates the transport-level connection to the Server has disappeared
+*/
+void CObexServerStateMachine::TransportDown()
+	{
+	// This event could happen while the Server is stopped (as the transport state
+	// can be independent of whether the Server has requested a read)
+	iCurrentState->Reset(*this);
+	}
+
+/**
+Indicates a Protocol Error has occurred
+*/
+void CObexServerStateMachine::Error()
+	{
+	// This event could happen while the Server is stopped (as the transport state
+	// can be independent of whether the Server has requested a read)
+	iCurrentState->Reset(*this);
+	}
+
+/**
+Process an OBEX object received as part of an asynchronous Put/Get indication
+This object pointer can be NULL to indicate an error condition
+@see MObexServerNotifyAsync::PutRequestInidication
+@see MObexServerNotifyAsync::GetRequestInidication
+@see CObexServer::RequestIndicationCallback
+
+@param aObject OBEX object to use (NULL to indication an error condition)
+@return Result of any state changes
+*/
+TInt CObexServerStateMachine::RequestNotificationCompleted(CObexBaseObject* aObject)
+	{
+	__ASSERT_ALWAYS(iCurrentStateEnum == EPutOpWaitForUser ||
+					iCurrentStateEnum == EGetOpWaitForUser, IrOBEXUtil::Panic(EInvalidResponseCallback));
+	if (!iServerStarted)
+		{
+		return KErrIrObexServerStopped;
+		}
+
+	iCurrentState->RequestNotificationCompleted(*this, aObject);
+	return KErrNone;
+	}
+
+/**
+Process the response received as part of an asynchronous PutComplete/GetComplete/SetPath indication
+
+@param 	aAppResponse Application's response to the indication
+@return result of state changes
+*/
+TInt CObexServerStateMachine::RequestNotificationCompleted(TObexResponse aAppResponse)
+	{
+	__ASSERT_ALWAYS(iCurrentStateEnum == EPutOpWaitForUser ||
+					iCurrentStateEnum == EGetOpWaitForUser, IrOBEXUtil::Panic(EInvalidResponseCallback));
+	__ASSERT_ALWAYS(iCurrentState->ValidResponse(aAppResponse), IrOBEXUtil::Panic(EInvalidResponseCodeFromServerApp));
+	if (!iServerStarted)
+		{
+		return KErrIrObexServerStopped;
+		}
+
+	iCurrentState->RequestNotificationCompleted(*this, aAppResponse);
+	return KErrNone;
+	}
+	
+/**
+Process the response received as part of an asynchronous PutComplete/GetComplete/SetPath indication
+
+@param 	aAppResponse Application's response to the indication
+@return result of state changes
+*/
+TInt CObexServerStateMachine::RequestCompleteNotificationCompleted(TObexResponse aAppResponse)
+	{
+	__ASSERT_ALWAYS(iCurrentStateEnum == ESetPathOp || iCurrentStateEnum == EGetOpFinal ||
+					iCurrentStateEnum == EPutOpFinal, IrOBEXUtil::Panic(EInvalidResponseCallback));
+	__ASSERT_ALWAYS(iCurrentState->ValidResponse(aAppResponse), IrOBEXUtil::Panic(EInvalidResponseCodeFromServerApp));
+	if (!iServerStarted)
+		{
+		return KErrIrObexServerStopped;
+		}
+
+	iCurrentState->RequestCompleteNotificationCompleted(*this, aAppResponse);
+	return KErrNone;
+	}
+
+/**
+Indicates an OBEX level connection has been established
+
+@return Result of any state changes
+*/
+void CObexServerStateMachine::ConnectionComplete()
+	{
+	__ASSERT_ALWAYS(iServerStarted, IrOBEXUtil::Fault(EConnectionCompleteWhenServerStopped));
+
+	iCurrentState->ConnectionComplete(*this);
+	}
+
+/**
+Indicates Server has been started
+
+@param aNotify Notification interface to use
+*/
+void CObexServerStateMachine::Start(MObexServerNotifyAsync& aNotify)
+	{
+	iServerStarted = ETrue;
+	iNotification = &aNotify;	// state will panic if trying to change interface at an inappropriate point
+	iCurrentState->Start(*this);
+	}
+
+/**
+Indicates Server has been stopped
+*/
+void CObexServerStateMachine::Stop()
+	{
+	iCurrentState->Reset(*this);
+	iServerStarted = EFalse;
+	}
+	
+/**
+Indication that the Obex server application has chosen to override the
+handling of the request packet that has been received.
+
+@param aResponse The response the server application has indicated that should
+				 be sent to the Obex client.  The actual sending of the response
+				 is delegated to the individual states to handle as appropriate.
+@return Result of any state changes
+*/
+void CObexServerStateMachine::OverrideRequestHandling(TObexResponse aResponse)
+	{
+	iCurrentState->OverrideRequestHandling(*this, aResponse);
+	}
+
+/**
+Indicates that a write of a packet has been completed successfully at the 
+transport level.
+*/
+void CObexServerStateMachine::WriteComplete()
+	{
+	LOG_FUNC
+
+	iCurrentState->WriteComplete(*this);
+	}
+
+/**
+Indicates that a new obex packet is being read.
+*/
+void CObexServerStateMachine::ReadActivityDetected()
+	{
+	LOG_FUNC
+
+	iCurrentState->ReadActivityDetected(*this);
+	}
+
+/**
+@return Last packet processed by the state machine
+*/
+CObexPacket& CObexServerStateMachine::LastReceivedPacket() const
+	{
+	__ASSERT_DEBUG(iLastReceivedPacket, IrOBEXUtil::Fault(ENoReceivePacketAvailable));
+	return *iLastReceivedPacket;
+	}
+
+/**
+This sets pointer of the object received from the application
+and so can be NULL to indicate an error
+
+@see CObexServerStateMachine::NotificationComplete
+@return Specification Object - used to describe the OBEX object to Get
+*/
+CObexBaseObject* CObexServerStateMachine::SpecObject() const
+	{
+	return iSpecObject;
+	}
+
+/**
+This returns pointer to the object received from the application
+and so can be NULL to indicate an error
+
+@see CObexServerStateMachine::NotificationComplete
+@return Transfer object to exchange with the Client
+*/
+CObexBaseObject* CObexServerStateMachine::TransObject() const
+	{
+	return iTransObject;
+	}
+
+/**
+@param aTransObject New transfer object to exchange with the Client
+*/
+void CObexServerStateMachine::SetTransObject(CObexBaseObject* aTransObject)
+	{
+	iTransObject = aTransObject;
+	}
+
+/**
+@return Transport Controller associated with the Server
+*/
+CObexTransportControllerBase& CObexServerStateMachine::Transport() const
+	{
+	return iTransport;
+	}
+
+/**
+@return Server object associated with the State Machine
+*/
+CObexServer& CObexServerStateMachine::Owner() const
+	{
+	return iOwner;
+	}
+
+/**
+@return Notification interface associated with the Server
+*/
+MObexServerNotifyAsync& CObexServerStateMachine::Notification() const
+	{
+	__ASSERT_DEBUG(iNotification, IrOBEXUtil::Fault(ENoNotifierAvailable));
+	return *iNotification;
+	}
+
+/**
+@return Final Header set to send at the end of a Put operation
+*/
+CObexHeaderSet* CObexServerStateMachine::PutFinalResponseHeaderSet()
+	{
+	return iPutFinalResponseHeaderSet;
+	}
+
+/**
+@param aHeaderSet Final Header set to send at the end of a Put operation
+*/
+void CObexServerStateMachine::SetPutFinalResponseHeaderSet(CObexHeaderSet* aHeaderSet)
+	{
+	delete iPutFinalResponseHeaderSet;
+	iPutFinalResponseHeaderSet = aHeaderSet;
+	}
+
+/**
+@return Internal header object (used for sizing the final response header set)
+*/
+CObexHeader* CObexServerStateMachine::GetHeader()
+	{
+	return iHeader;
+	}
+
+/**
+Activate one-shot call-back to run from the Active Scheduler
+@param aFunction Pointer to the function to call
+*/
+void CObexServerStateMachine::CallBack(TInt (*aFunction)(TAny* aPtr))
+	{
+	iCallBack->Set(TCallBack(aFunction, this));
+	iCallBack->CallBack();
+	}
+
+/**
+Cancel one-shot call-back
+*/
+void CObexServerStateMachine::CancelCallBack()
+	{
+	iCallBack->Cancel();
+	}
+
+/**
+@return If one-shot call-back is active
+*/
+TBool CObexServerStateMachine::IsCallBackActive() const
+	{
+	return iCallBack->IsActive();
+	}
+
+TObexResponse CObexServerStateMachine::AppResponse() const
+	{
+	return iAppResponse;
+	}
+
+void CObexServerStateMachine::SetAppResponse(TObexResponse aAppResponse)
+	{
+	__ASSERT_DEBUG(aAppResponse>0 && aAppResponse<=255, IrOBEXUtil::Panic(EInvalidResponseCodeFromServerApp ));
+	
+	//remove the final bit, sorry about the horrible double casting. 
+	aAppResponse = static_cast<TObexResponse>(static_cast<TInt> (aAppResponse) & 0x7F); 
+	iAppResponse = aAppResponse;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexsetpathdata.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "obexsetpathdata.h"
+
+TObexSetPathData::TObexSetPathData ()
+	{
+	iFlags = 0;
+	iConstants = 0;
+	}
+
+TUint16 TObexSetPathData::DoTotalSize () const
+	{
+	return 2;
+	}
+
+TUint16 TObexSetPathData::ParseIn (TUint8* aSource, const TUint16 aMaxSize)
+	{
+	if (aMaxSize < TotalSize ())
+		{
+		return (0);
+		}
+	iFlags = aSource[0];
+	iConstants = aSource[1];
+	return (TotalSize ());
+	}
+
+TUint16 TObexSetPathData::WriteOut (TUint8* aDest, const TUint16 aMaxSize) const
+	{
+	if (aMaxSize < TotalSize ())
+		{
+		return (0);
+		}
+	aDest[0] = iFlags;
+	aDest[1] = iConstants;
+	return (TotalSize ());
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexsyncfilewriter.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,166 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+*/
+
+#include <f32file.h>
+#include "obexsyncfilewriter.h"
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+//
+// Panic category for CObexSyncFileWriter
+//
+_LIT(KObexSyncFileWriterPanic, "Obex-SFW");
+
+/**
+Panic codes for CObexSyncFileWriter
+
+@internalComponent
+@released
+*/
+enum TSyncObexFileWriterPanic
+	{
+	/** Null buffer pointer */
+	ENullBufferPointer
+	};
+
+//
+// Implementation of CObexSyncFileWriter
+//
+
+/**
+Factory function
+
+Note that we return a pointer to the interface class, so
+that this class can only be used through this interface.
+This class in an implementation of a strategy as part of
+a Strategy pattern.  CObexAsyncFileWriter provides an
+alternative strategy implementation, with CObexBufObject
+as the context for these strategies.
+
+@see MObexFileWriter
+@see CObexAsyncFileWriter
+@see CObexBufObject
+
+@internalComponent
+@released
+
+@param aFile The file we're writing to
+@return An MObexFileWriter for writing to file
+*/
+MObexFileWriter* CObexSyncFileWriter::NewL(RFile& aFile)
+	{
+	CObexSyncFileWriter* self = new(ELeave) CObexSyncFileWriter(aFile);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+Constructor
+
+@internalComponent
+@released
+
+@param aFile The file to write to
+*/
+CObexSyncFileWriter::CObexSyncFileWriter(RFile& aFile)
+	: iFile(aFile)
+	{
+	}
+
+/**
+2nd phase constructor
+
+@internalComponent
+@released
+*/	
+void CObexSyncFileWriter::ConstructL()
+	{
+	}
+
+/**
+Normal write to file
+
+@internalComponent
+@released
+
+@param aPos The file position
+@param aBuf The buffer we're to write. We use this buffer by copying the pointer
+			and return the buffer we previously wrote to the caller by updating
+			the pointer.  If an error occurs, the buffers are not swapped and
+			the pointer is not updated.  Note that this class never owns any
+			buffers and that passing a buffer to this function does not imply a
+			transfer of ownership.
+@return Symbian OS error code
+*/
+TInt CObexSyncFileWriter::Write(TInt aPos, CBufBase*& aBuf)
+	{
+	__ASSERT_ALWAYS(aBuf, PANIC(KObexSyncFileWriterPanic, ENullBufferPointer));
+
+	// Write the next block
+	return iFile.Write(aPos, aBuf->Ptr(0));
+	}
+
+/**
+Final, synchronous write to file
+
+@internalComponent
+@released
+
+@param aPos The file position
+@param aBuf The buffer we're to write. We use this buffer by copying the pointer
+            and return the buffer we previously wrote to the caller by updating
+            the pointer.  If an error occurs, the buffers are not swapped and
+            the pointer is not updated.  Note that this class never owns any
+            buffers and that passing a buffer to this function does not imply a
+            transfer of ownership.
+@param aLength The amount of the buffer to write
+@return Symbian OS error code
+*/	
+TInt CObexSyncFileWriter::FinalWrite(TInt aPos, CBufBase*& aBuf, TInt aLength)
+	{
+	__ASSERT_ALWAYS(aBuf, PANIC(KObexSyncFileWriterPanic, ENullBufferPointer));
+
+	// Write the final block
+	TInt err = iFile.Write(aPos, aBuf->Ptr(0), aLength);
+	if (err == KErrNone)
+		{
+		//flush the buffer, commit the write
+		return iFile.Flush();
+		}
+	else
+		{
+		return err;
+		}
+	}
+
+/**
+Destructor
+
+@internalComponent
+@released
+*/
+CObexSyncFileWriter::~CObexSyncFileWriter()
+	{
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/group/t_obexheadercheck.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,50 @@
+// 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:
+// Pointless file produced by test project; the test is that it 
+// compiles at all.
+// 
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+target			t_obexheadercheck.exe
+targettype		exe
+uid 			0
+VENDORID		0x70000001
+
+sourcepath		../src
+source			main.cpp
+source			t_obex.cpp
+source			t_obexbase.cpp
+source			t_obexbaseobject.cpp
+source			t_obexclient.cpp
+source			t_obexconstants.cpp
+source			t_obexheaders.cpp
+source			t_obexobjects.cpp
+source			t_obexserver.cpp
+source			t_obextypes.cpp
+source			t_obexfinalpacketobserver.cpp
+source			t_ObexTransportInfo.cpp
+source			t_ObexIrTransportInfo.cpp
+source			t_ObexBtTransportInfo.cpp
+source			t_ObexUsbTransportInfo.cpp
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+library 		euser.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/main.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,21 @@
+// 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:
+//
+
+#include <e32std.h>
+
+GLDEF_C TInt E32Main()
+	{
+	return KErrNone;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_ObexBtTransportInfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obexbttransportinfo.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_ObexIrTransportInfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obexirtransportinfo.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_ObexTransportInfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obextransportinfo.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_ObexUsbTransportInfo.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obexusbtransportinfo.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obex.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obex.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obexbase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obexbase.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obexbaseobject.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obexbaseobject.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obexclient.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obexclient.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obexconstants.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obexconstants.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obexfinalpacketobserver.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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 <obexfinalpacketobserver.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obexheaders.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obexheaders.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obexobjects.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obexobjects.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obexserver.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obexserver.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obextypes.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obextypes.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/testobexerrorcodes/TestObexErrorCodes.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,348 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <c32comm.h>
+#include "TestObexErrorCodes.h"
+
+#if defined (__WINS__)
+#define PDD_NAME _L("ECDRV")
+#define LDD_NAME _L("ECOMM")
+#else  // __GCC32__
+#define PDD_NAME _L("EUART2")
+#define LDD_NAME _L("ECOMM")
+#define FIR_PDD_NAME _L("DIFIR")	// Brutus FIR PDD
+#define FIR_LDD_NAME _L("EFIR")		// Brutus FIR LDD
+#endif
+
+
+
+void Startup()
+	{
+	CActiveScheduler *pA=new CActiveScheduler;
+	CActiveScheduler::Install(pA);
+
+	CControllerTestMasterClass* bigBoss = CControllerTestMasterClass::NewL();
+	
+	CActiveScheduler::Start();
+	delete bigBoss;
+	bigBoss = NULL;
+	delete pA;
+	}
+
+
+void CControllerTestMasterClass::ConstructL()
+	{
+	//make the initial active object everything
+	iConsoleTest = CControllerConsoleTest::NewL(this);
+
+	iConsoleTest->IssueRequest();
+
+	}
+
+CControllerTestMasterClass* CControllerTestMasterClass::NewL()
+	{
+	CControllerTestMasterClass* self = NewLC();
+	CleanupStack::Pop();
+	return self;
+	}
+
+CControllerTestMasterClass* CControllerTestMasterClass::NewLC()
+	{
+	CControllerTestMasterClass* self=new (ELeave) CControllerTestMasterClass;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+
+
+CControllerTestMasterClass::~CControllerTestMasterClass()
+	{
+	delete iConsoleTest;
+	iConsoleTest = NULL;
+	}
+	
+
+
+GLDEF_C TInt E32Main()
+	{
+
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
+
+	
+	// start scheduler 
+	TRAPD(error, Startup() );
+	__ASSERT_ALWAYS(!error,User::Panic(_L("Testing Registry"),error));
+
+
+	delete cleanup; // destroy clean-up stack
+	__UHEAP_MARKEND;
+	return KErrNone;
+	}
+
+
+
+//
+// CRegistryConsoleTest
+//
+CControllerConsoleTest::~CControllerConsoleTest()
+	{
+	Cancel();
+
+
+	delete iTest;
+	delete iConsole;
+	iConsole = NULL;
+	iOwner = NULL;  
+
+	}
+
+
+void CControllerConsoleTest::DoCancel()
+	{
+	iConsole->ReadCancel();
+	}
+
+
+void CControllerConsoleTest::Menu()
+	{
+	iConsole->Printf(_L("\nOBEX error code tests ..."));
+	iConsole->Printf(_L("\nPress '1' to start Client Side Tests"));
+	iConsole->Printf(_L("\nPress '2' to start Server Side Tests"));
+	iConsole->Printf(_L("\nPress '3' to start"));
+	iConsole->Printf(_L("\nPress '4' to stop"));
+	iConsole->Printf(_L("\nAny other key to exit"));
+	}
+
+void CControllerConsoleTest::IssueRequest()
+	{
+	Menu();
+	iConsole->Read(iStatus);
+	SetActive();
+	}
+void CControllerConsoleTest::ConstructL(CControllerTestMasterClass* aOwner)
+    {
+ 
+	iOwner = aOwner;
+	iConsole = Console::NewL(_L("Controller Test"),
+					TSize(-1,-1));
+	DoTest();	//set everything up, load everything
+
+
+	CActiveScheduler::Add(this); 
+    }
+
+TInt CControllerConsoleTest::RunError(TInt)
+	{
+	IssueRequest();
+	return KErrNone;
+	}
+
+
+void CControllerConsoleTest::StartTest()
+	{
+	iTest->Start();
+
+	iStarted = ETrue;
+	
+	}
+
+void CControllerConsoleTest::StopTest()
+	{
+
+	if ( iStarted )
+		{
+		iTest->Stop();
+
+		iStarted = EFalse;
+		}
+	else
+		{
+		iConsole->Printf(_L("DOOH, can't stop a test which hasn't started\n"));
+		}
+	}
+
+void CControllerConsoleTest::DoTest()
+	{
+	iStarted = EFalse;
+	iConsole->Printf(_L("\n Loading tests"));
+
+
+
+	TInt ret;
+#ifdef __EPOC32__
+	iConsole->Printf(_L("Loading C32...\n"));
+	ret=StartC32();
+	if (ret!=KErrNone && ret!=KErrAlreadyExists)
+		iConsole->Printf(_L("	Failed %d\n"), ret);
+	else
+		iConsole->Printf(_L("	Success\n"));
+#endif
+
+// load up the drivers
+	iConsole->Printf(_L("Loading SIR PDD...\n"));
+	ret=User::LoadPhysicalDevice(PDD_NAME);
+	if (ret!=KErrNone && ret!=KErrAlreadyExists)
+		iConsole->Printf(_L("	Failed %d\n"), ret);
+	else
+		iConsole->Printf(_L("	Success\n"));
+
+	iConsole->Printf(_L("Loading SIR LDD...\n"));
+    ret=User::LoadLogicalDevice(LDD_NAME);
+	if (ret!=KErrNone && ret!=KErrAlreadyExists)
+		iConsole->Printf(_L("	Failed %d\n"), ret);
+	else
+		iConsole->Printf(_L("	Success\n"));
+#ifdef __EPOC32__
+	iConsole->Printf(_L("Loading Fast IR PDD\n"));
+
+	ret=User::LoadPhysicalDevice(FIR_PDD_NAME);
+	if (ret!=KErrNone && ret!=KErrAlreadyExists)
+		iConsole->Printf(_L("	Failed %d\n"), ret);
+	else
+		iConsole->Printf(_L("	Success\n"));
+
+	iConsole->Printf(_L("Loading Fast IR LDD\n"));
+	ret=User::LoadLogicalDevice(FIR_LDD_NAME);
+	if (ret!=KErrNone && ret!=KErrAlreadyExists)
+		iConsole->Printf(_L("	Failed %d\n"), ret);
+	else
+		iConsole->Printf(_L("	Success\n"));
+#endif	
+
+
+	}
+
+
+void CControllerConsoleTest::RunL()
+	{
+
+	TInt key = iConsole->KeyCode();
+	switch (key)
+		{
+		case '1':
+			{
+			iTest = CTestObexErrorCodesClient::NewL(this);
+			IssueRequest(); //back to main menu
+			}
+			break;
+		case '2':
+			{
+			iTest = CTestObexErrorCodesServer::NewL(this);
+			IssueRequest(); //back to main menu
+			}
+			break;
+		case '3':
+			{
+			if ( !iStarted )
+				StartTest();
+			else 
+				iConsole->Printf(_L("Already Started\n"));
+
+			IssueRequest(); //back to main menu
+
+			}
+			break;
+		case '4':
+			{
+			if ( iStarted )
+				StopTest();
+			else 
+				iConsole->Printf(_L("Not started yet\n"));
+
+			IssueRequest(); //back to main menu
+			}
+			break;
+		default:
+			CActiveScheduler::Stop();
+			break;
+		}
+
+	}
+
+
+CControllerConsoleTest* CControllerConsoleTest::NewL(CControllerTestMasterClass* aOwner)
+	{
+	CControllerConsoleTest* self = NewLC(aOwner);
+	CleanupStack::Pop();
+	return self;
+	}
+
+CControllerConsoleTest* CControllerConsoleTest::NewLC(CControllerTestMasterClass* aOwner)
+	{
+	CControllerConsoleTest* self=new (ELeave) CControllerConsoleTest;
+	CleanupStack::PushL(self);
+	self->ConstructL(aOwner);
+	return self;
+
+	}
+
+CControllerConsoleTest::CControllerConsoleTest()
+			: CActive(CActive::EPriorityStandard)
+	{
+	}
+
+
+
+
+
+CBaseErrorCodeTest* CBaseErrorCodeTest::NewL(CControllerConsoleTest* aOwner)
+	{
+	CBaseErrorCodeTest* self = new(ELeave) CBaseErrorCodeTest;
+	CleanupStack::PushL(self);
+	self->ConstructL(aOwner);
+	CleanupStack::Pop( self );
+	return self;
+	}
+
+CBaseErrorCodeTest::~CBaseErrorCodeTest()
+	{
+	delete iObject;
+    delete iBuf;
+    iLibrary.Close();
+	}
+
+
+CBaseErrorCodeTest::CBaseErrorCodeTest()
+	{
+	}
+
+void CBaseErrorCodeTest::ConstructL(CControllerConsoleTest* aOwner)
+	{
+	iOwner = aOwner;
+
+	iOwner->iConsole->Printf(_L("About to load the IRObex DLL...\n"));
+
+    
+    TRAPD(ret,LoadObexL());	// Load Protocol
+    if (ret!=KErrNone)
+		iOwner->iConsole->Printf(_L("Error %d on loading IrObex DLL\r\n"),ret);
+    else
+		iOwner->iConsole->Printf(_L("Successfully loaded IrObex DLL\r\n"));
+	}
+
+void CBaseErrorCodeTest::LoadObexL()
+	{
+	User::LeaveIfError(iLibrary.Load(_L("IROBEX.DLL")));
+	}
+
+void CBaseErrorCodeTest::Start()
+	{
+	}
+
+void CBaseErrorCodeTest::Stop()
+	{
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/testobexerrorcodes/TestObexErrorCodes.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,209 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __TESTOBEXERRORCODES_H__
+#define __TESTOBEXERRORCODES_H__
+
+#include <e32cons.h>
+#include <e32def.h>
+#include <e32std.h>
+#include <e32base.h>
+#include <obex.h>
+
+class CControllerConsoleTest;
+class CBaseErrorCodeTest;
+class CObexClientHandler;
+
+enum TTestProgress { EIdle, EConnecting, EDisconnecting, EConnected, EPutting };
+
+class CControllerTestMasterClass : CBase
+	{
+public:
+	void ConstructL();
+	static CControllerTestMasterClass* NewL();
+	static CControllerTestMasterClass* NewLC();
+	~CControllerTestMasterClass();
+
+public:
+	CControllerConsoleTest* iConsoleTest;
+	};
+
+
+
+class CControllerConsoleTest : CActive
+	{
+
+public:	
+	void ConstructL(CControllerTestMasterClass*);
+	static CControllerConsoleTest* NewL(CControllerTestMasterClass*);
+	static CControllerConsoleTest* NewLC(CControllerTestMasterClass*);
+	~CControllerConsoleTest();
+public:
+	void IssueRequest(); 
+	void DoCancel();
+	void RunL();
+	void TestAll();
+	TInt RunError(TInt);
+	void DoTest();
+
+private:
+	CControllerConsoleTest();
+	void StartTest();
+	void StopTest();
+	void Menu();
+private:
+	CControllerTestMasterClass* iOwner;
+
+public:
+	CConsoleBase* iConsole;
+	CBaseErrorCodeTest* iTest;
+	TBool iStarted;
+	};
+
+
+
+class CBaseErrorCodeTest : public CBase 
+	{
+public:
+	static CBaseErrorCodeTest* NewL(CControllerConsoleTest* aOwner);
+	virtual ~CBaseErrorCodeTest();
+
+public:
+
+	virtual	void Start();
+	virtual void Stop();
+
+
+protected:
+
+	CBaseErrorCodeTest();
+	void ConstructL(CControllerConsoleTest* aOwner);
+	void LoadObexL();
+
+public:
+	CControllerConsoleTest* iOwner;
+
+
+
+protected:
+	CObexBufObject*  iObject;
+	CBufFlat *iBuf;
+	RLibrary         iLibrary;					// Use RLibrary object to interface to the DLL
+	TInt iErrorCode;
+	};
+
+/**
+*
+* The public API for Server test
+*            
+*/
+
+class CTestObexErrorCodesServer : public CBaseErrorCodeTest, MObexServerNotify
+	{
+public:
+	static CTestObexErrorCodesServer* NewL(CControllerConsoleTest* aOwner);
+	virtual ~CTestObexErrorCodesServer();
+	void StartIrdaServerL();
+
+public:
+
+	virtual	void Start();
+	virtual	void Stop();
+
+
+private:
+	CTestObexErrorCodesServer();
+
+
+	// Virtual functions from OBEX
+	virtual void ErrorIndication(TInt aError);
+	virtual void TransportUpIndication();
+	virtual void TransportDownIndication();
+	virtual TInt ObexConnectIndication(const TObexConnectInfo& aRemoteInfo, const TDesC8& aInfo);
+	virtual void ObexDisconnectIndication(const TDesC8& aInfo);
+	virtual CObexBufObject* PutRequestIndication();
+	virtual TInt PutPacketIndication();
+	virtual TInt PutCompleteIndication();
+	virtual CObexBufObject* GetRequestIndication(CObexBaseObject *aRequiredObject);
+	virtual TInt GetPacketIndication();
+	virtual TInt GetCompleteIndication();
+	virtual TInt SetPathIndication(const CObex::TSetPathInfo& aPathInfo, const TDesC8& aInfo);
+	virtual void AbortIndication();
+
+private:
+	CObexServer* iServer;
+	};
+
+/**
+*
+* The public API for Server test
+*            
+*/
+
+class CTestObexErrorCodesClient : public CBaseErrorCodeTest
+	{
+public:
+	static CTestObexErrorCodesClient* NewL(CControllerConsoleTest* aOwner);
+	virtual ~CTestObexErrorCodesClient();
+	void StartIrdaClientL();
+	void ActionComplete(TObexResponse aResponse);
+
+public:
+	void CallBack(TRequestStatus aStatus, TTestProgress aActivity);
+	virtual	void Start();
+	virtual	void Stop();
+
+
+private:
+	CTestObexErrorCodesClient();
+
+private:
+	CObexClientHandler* iClient;
+	};
+
+
+
+class CObexClientHandler : public CActive
+	{
+public:
+	static CObexClientHandler* NewL(CTestObexErrorCodesClient* aOwner, 
+									TObexProtocolInfo& aObexProtocolInfoPtr);
+	~CObexClientHandler();
+
+public:
+	void Connect();
+	void Disconnect();
+	void Put();
+
+private:
+
+	CObexClientHandler();
+	void ConstructL(CTestObexErrorCodesClient* aOwner,
+					TObexProtocolInfo& aObexProtocolInfoPtr);
+
+	void DoCancel();
+	void RunL();
+
+
+
+private:
+	CObexClient* iClient;
+	CTestObexErrorCodesClient* iOwner;	
+	TTestProgress iActivity;
+	CObexFileObject* iFileObject;
+
+	};
+
+#endif // __TESTOBEXERRORCODES_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/testobexerrorcodes/TestObexErrorCodes.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,50 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+*/
+
+TARGET        testobexerrorcodes.exe
+TARGETTYPE    exe
+
+
+SOURCEPATH		.
+
+SOURCE			TestObexErrorCodesServer.cpp TestObexErrorCodes.cpp TestObexErrorCodesClient.cpp
+
+
+USERINCLUDE		.
+ 
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+#ifdef __OMAP__
+SYSTEMINCLUDE	/epoc32/include/Kernel
+
+#endif //__OMAP__
+
+
+LIBRARY euser.lib irobex.lib irda.lib esock.lib efsrv.lib
+
+#ifndef WINS
+LIBRARY c32.lib
+#endif
+
+//
+ 
+VENDORID 0x70000001
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/testobexerrorcodes/TestObexErrorCodesClient.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,237 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <f32file.h>
+#include "TestObexErrorCodes.h"
+
+/**
+ * Static NewL
+ *
+ * @return Base class*
+ */
+CTestObexErrorCodesClient* CTestObexErrorCodesClient::NewL(CControllerConsoleTest* aOwner)
+	{
+	CTestObexErrorCodesClient* self = new(ELeave) CTestObexErrorCodesClient;
+	CleanupStack::PushL(self);
+	self->ConstructL(aOwner);
+	self->StartIrdaClientL();
+	CleanupStack::Pop( self );
+
+	return self;
+	}
+
+
+
+
+/**
+*
+* CTestObexErrorCodesClient
+*
+*/
+
+CTestObexErrorCodesClient::CTestObexErrorCodesClient()
+	{
+	}
+
+/**
+*
+* ~CTestObexErrorCodesClient
+*
+*/
+
+CTestObexErrorCodesClient::~CTestObexErrorCodesClient()
+	{
+	delete iClient;
+   	}
+
+void CTestObexErrorCodesClient::Stop()
+	{
+	iOwner->iConsole->Printf(_L("About to Stop the iClient ..\n"));
+
+
+	}
+
+
+void CTestObexErrorCodesClient::Start()
+	{
+//Start the test
+
+	iClient->Connect();	//should fail with appropriate error code
+
+
+	}
+
+
+
+
+void CTestObexErrorCodesClient::StartIrdaClientL()
+	{
+
+	iOwner->iConsole->Printf(_L("About to load the CObexClient...\n"));
+
+	TObexIrProtocolInfo aInfo;
+	aInfo.iTransport     = _L("IrTinyTP");
+	aInfo.iClassName     = _L8("OBEX");
+	aInfo.iAttributeName = _L8("IrDA:TinyTP:LsapSel");
+
+
+	iClient  = CObexClientHandler::NewL (this, aInfo);
+		
+
+	iBuf = CBufFlat::NewL(5000);//5000 - what should I put??
+	iObject  = CObexBufObject::NewL (iBuf);
+	iOwner->iConsole->Printf(_L("Irda Client loaded Success \n"));
+
+	
+	
+	}
+
+void CTestObexErrorCodesClient::CallBack(TRequestStatus aStatus, TTestProgress aActivity)
+	{
+	
+	//first of all establish what has just happened.
+	if ( aActivity == EConnecting ) //then it's time for the first PUT
+		{
+		iClient->Put();
+		iErrorCode = ERespContinue;
+		}
+	else if (aActivity == EPutting )
+		{
+		iOwner->iConsole->Printf(_L("Put Complete with Code %d \n"), aStatus.Int());
+		if ( iErrorCode < ERespDatabaseLocked )
+			{
+			iErrorCode++;
+			iClient->Put();
+			}
+		}
+
+	}
+
+
+
+
+CObexClientHandler* CObexClientHandler::NewL(CTestObexErrorCodesClient* aOwner,
+											 TObexProtocolInfo& aObexProtocolInfoPtr)
+	{
+	CObexClientHandler* self = new(ELeave) CObexClientHandler;
+	CleanupStack::PushL(self);
+	self->ConstructL(aOwner, aObexProtocolInfoPtr);
+	CleanupStack::Pop( self );
+
+	return self;
+	
+	}
+
+CObexClientHandler::~CObexClientHandler()
+	{
+	delete iClient;
+	}
+
+void CObexClientHandler::Connect()
+	{
+	if (!IsActive() )
+		{
+		iActivity = EConnecting;
+
+		iClient->Connect(iStatus);
+		SetActive();
+		}
+	else
+		iOwner->iOwner->iConsole->Printf(_L("\r\nError: Client handler already active\r\n"));
+	}
+
+void CObexClientHandler::Disconnect()
+	{
+	if (!IsActive() )
+		{
+		iActivity = EDisconnecting;
+		iClient->Disconnect(iStatus);
+		SetActive();
+		}
+	else
+		iOwner->iOwner->iConsole->Printf(_L("\r\nError: Client handler already active\r\n"));
+
+	}
+
+CObexClientHandler::CObexClientHandler()
+    : CActive(EPriorityNormal)
+	{
+	}
+
+void CObexClientHandler::ConstructL(CTestObexErrorCodesClient* aOwner,
+									TObexProtocolInfo& aObexProtocolInfoPtr)
+	{
+	iOwner = aOwner;
+
+    iFileObject = CObexFileObject::NewL();
+
+
+	iClient = CObexClient::NewL(aObexProtocolInfoPtr);
+    CActiveScheduler::Add(this);			// Add to active scheduler
+	iActivity = EIdle;
+	}
+
+void CObexClientHandler::DoCancel()
+	{
+	iClient->Abort();
+	}
+
+void CObexClientHandler::RunL()
+	{
+	
+	iOwner->CallBack(iStatus, iActivity);
+		
+	}
+
+void CObexClientHandler::Put()
+	{
+    if(IsActive())
+		{
+
+		iOwner->iOwner->iConsole->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+
+	TInt err;
+
+	TRAP(err, iFileObject->InitFromFileL (_L("Contacts.vcf")));
+
+	if (err != KErrNone)
+		{
+		RFs fs;
+		RFile f;
+		if ((fs.Connect () != KErrNone) || 
+			(f.Create (fs, _L("Contacts.vcf"), EFileShareExclusive | EFileWrite) != KErrNone))
+			iOwner->iOwner->iConsole->Printf(_L("\r\nError reading 'Contacts.vcf'.\r\nI tried to create this file for you, but failed to do that too. Sorry.\r\n\r\n"));
+		else
+			{
+			f.Write (_L8("Test file for sending from EPOC\r\n\r\nLooks like obex is sending OK!!\r\n"));
+			f.Close ();
+			iOwner->iOwner->iConsole->Printf(_L("\r\nFile 'Contacts.vcf' did not exist, so I've created one.\r\nPlease try again.\r\n\r\n"));
+			}
+		fs.Close ();
+		}
+
+
+	if( err != KErrNone)
+		{
+		iOwner->iOwner->iConsole->Printf(_L("\r\n Couldnt set up object : error %d \r\n"),err);
+		return;
+		}
+
+	iClient->Put(*iFileObject,iStatus);
+	SetActive();
+	iActivity = EPutting;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/testobexerrorcodes/TestObexErrorCodesServer.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,200 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "TestObexErrorCodes.h"
+
+/**
+ * Static NewL
+ *
+ * @return Base class*
+ */
+CTestObexErrorCodesServer* CTestObexErrorCodesServer::NewL(CControllerConsoleTest* aOwner)
+	{
+	CTestObexErrorCodesServer* self = new(ELeave) CTestObexErrorCodesServer;
+	CleanupStack::PushL(self);
+	self->ConstructL(aOwner);
+	self->StartIrdaServerL();
+	CleanupStack::Pop( self );
+
+	return self;
+	}
+
+
+
+
+/**
+*
+* CTestObexErrorCodesServer
+*
+*/
+
+CTestObexErrorCodesServer::CTestObexErrorCodesServer()
+	{
+	}
+
+/**
+*
+* ~CTestObexErrorCodesServer
+*
+*/
+
+CTestObexErrorCodesServer::~CTestObexErrorCodesServer()
+	{
+	delete iServer;
+   	}
+
+void CTestObexErrorCodesServer::Stop()
+	{
+	iOwner->iConsole->Printf(_L("About to Stop the iServer ..\n"));
+
+    if(iServer)
+		iServer->Stop();
+	iOwner->iConsole->Printf(_L("iServer Stopped ..\n"));
+
+	}
+
+
+void CTestObexErrorCodesServer::Start()
+	{
+
+	iOwner->iConsole->Printf(_L("About to Start the iServer ..\n"));
+
+	TInt err = iServer->Start (this);
+	iOwner->iConsole->Printf(_L("Server started with err=%d ..\n"), err);
+
+	iErrorCode = ERespSuccess;  //first returned code not Continue as this really breaks everything
+	}
+
+
+/**
+Virtual functions from OBEX
+*/
+
+void CTestObexErrorCodesServer::ErrorIndication(TInt /*aError*/)
+	{
+	}
+
+void CTestObexErrorCodesServer::TransportUpIndication()
+	{
+	iOwner->iConsole->Printf(_L("Transport layer now connected\n"));
+	}
+
+void CTestObexErrorCodesServer::TransportDownIndication()
+	{
+	iOwner->iConsole->Printf(_L("Transport layer has gone down\n"));
+	}
+
+TInt CTestObexErrorCodesServer::ObexConnectIndication(const TObexConnectInfo& /*aRemoteInfo*/, const TDesC8& /*aInfo*/)
+	{
+	return KErrNone;
+	}
+
+void CTestObexErrorCodesServer::ObexDisconnectIndication(const TDesC8& /*aInfo*/)
+	{
+    iOwner->iConsole->Printf(_L("\r\nObex Disconnected\n"));
+	}
+
+CObexBufObject* CTestObexErrorCodesServer::PutRequestIndication()
+	{
+	return (iObject);
+	}
+
+TInt CTestObexErrorCodesServer::PutPacketIndication()
+	{
+    return (KErrNone);
+	
+	}
+
+TInt CTestObexErrorCodesServer::PutCompleteIndication()
+	{
+
+	iOwner->iConsole->Printf(_L("PutComplete returning error code %d ..\n"), iErrorCode);
+	//return the changing error code here
+	TInt retValue = (iErrorCode * -1 ) + KErrIrObexRespBase;
+
+	iErrorCode++;
+
+	return (retValue);
+//	return (KErrNone);
+
+	}
+
+CObexBufObject* CTestObexErrorCodesServer::GetRequestIndication(CObexBaseObject* /*aRequiredObject*/)
+	{
+	return (NULL);
+	}
+
+TInt CTestObexErrorCodesServer::GetPacketIndication()
+	{
+	//return the changing error code here
+	TInt retValue = iErrorCode;
+	if ( iErrorCode < ERespDatabaseLocked )
+		iErrorCode++;
+	else
+		iErrorCode = ERespContinue;
+
+	return (retValue);
+	}
+
+TInt CTestObexErrorCodesServer::GetCompleteIndication()
+	{
+	//return the changing error code here
+	TInt retValue = iErrorCode;
+	if ( iErrorCode < ERespDatabaseLocked )
+		iErrorCode++;
+	else
+		iErrorCode = ERespContinue;
+
+	return (retValue);
+	}
+
+TInt CTestObexErrorCodesServer::SetPathIndication(const CObex::TSetPathInfo& /*aPathInfo*/, const TDesC8& /*aInfo*/)
+	{
+	//return the changing error code here
+	TInt retValue = iErrorCode;
+	if ( iErrorCode < ERespDatabaseLocked )
+		iErrorCode++;
+	else
+		iErrorCode = ERespContinue;
+
+	return (retValue);
+	}
+
+void CTestObexErrorCodesServer::AbortIndication()
+	{
+	}
+
+
+void CTestObexErrorCodesServer::StartIrdaServerL()
+	{
+
+	iOwner->iConsole->Printf(_L("About to load the CObexServer...\n"));
+
+	TObexIrProtocolInfo aInfo;
+	aInfo.iAddr.SetPort(9);//default obex server for now
+	aInfo.iTransport     = _L("IrTinyTP");
+	aInfo.iClassName     = _L8("OBEX");
+	aInfo.iAttributeName = _L8("IrDA:TinyTP:LsapSel");
+
+
+	iServer  = CObexServer::NewL (aInfo);
+		
+
+	iBuf = CBufFlat::NewL(5000);//5000 - what should I put??
+	iObject  = CObexBufObject::NewL (iBuf);
+	iOwner->iConsole->Printf(_L("Irda Server loaded Success \n"));
+
+
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/Contactsbak.vcf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,7 @@
+BEGIN:VCARD
+VERSION:2.1
+REV:20020312T103257Z
+UID:1000118a25d0b113-e079ae8022476c-158
+ADR;WORK:;;3 Ely Road;Milton;Cambridgeshire;CB4 6AA;UK
+ORG:Symbian Cambridge;
+END:VCARD
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/Contactsbak2.vcf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,7 @@
+BEGIN:VCARD
+VERSION:2.1
+REV:20020312T103555Z
+UID:1000118a25d0b113-e079ae8b82cce4-159
+ADR;WORK:;;2-6 Boundary Row;Southwark;London;SE1 8HP;UK
+ORG:Symbian International Headquarters;
+END:VCARD
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/Contactsbak3.vcf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,7 @@
+BEGIN:VCARD
+VERSION:2.1
+REV:20020312T103832Z
+UID:1000118a25d0b113-e079ae94deab2d-160
+ADR;WORK:;;Soft Center;Ronneby;;SE-372 25;Sweden
+ORG:Symbian Ronneby;
+END:VCARD
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/TOBEX.CPP	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,93 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <c32comm.h>
+#include "TOBEXCON.H"
+
+#ifdef __EPOC32__
+#define FIR_PDD_NAME _L("DIFIR")	// Brutus FIR PDD
+#define FIR_LDD_NAME _L("EFIR")		// Brutus FIR LDD
+#endif
+
+#ifdef __WINS__
+_LIT(KWinsPddName,"ecdrv");
+_LIT(KWinsLddName,"ecomm");
+#endif //__WINS__
+
+void RunAppL(void)
+	{
+	// Construct and install the active scheduler
+	CActiveScheduler *exampleScheduler = new (ELeave) CActiveScheduler();
+	// Push onto the cleanup stack
+	CleanupStack::PushL(exampleScheduler);
+	// Install as the active scheduler
+	CActiveScheduler::Install(exampleScheduler); 
+	//Create Obex objects and console handler
+	CConsoleBase* aConsole = 
+	  //Console::NewL(_L("OBEX DLL Test Code"),TSize(20,10));	
+	  Console::NewL(_L("OBEX DLL Test Code"),TSize(KConsFullScreen,KConsFullScreen));
+		// Load Device drivers
+
+#ifdef __EPOC32__
+	TInt ret1;
+	aConsole->Printf(_L("Loading C32...\n"));
+	ret1=StartC32();
+	if (ret1!=KErrNone && ret1!=KErrAlreadyExists)
+		aConsole->Printf(_L("	Failed %d\n"), ret1);
+	else
+		aConsole->Printf(_L("	Sucess\n"));
+#endif
+#ifdef __WINS__
+	User::LoadLogicalDevice(KWinsLddName);
+	User::LoadPhysicalDevice(KWinsPddName);
+#endif //__WINS__
+
+#ifdef __EPOC32__
+	TInt ret2;
+
+	aConsole->Printf(_L("Loading Fast IR PDD\n"));
+
+	ret2=User::LoadPhysicalDevice(FIR_PDD_NAME);
+	if (ret2!=KErrNone && ret2!=KErrAlreadyExists)
+		aConsole->Printf(_L("	Failed %d\n"), ret2);
+	else
+		aConsole->Printf(_L("	Sucess\n"));
+
+	aConsole->Printf(_L("Loading Fast IR LDD\n"));
+	ret2=User::LoadLogicalDevice(FIR_LDD_NAME);
+	if (ret2!=KErrNone && ret2!=KErrAlreadyExists)
+		aConsole->Printf(_L("	Failed %d\n"), ret2);
+	else
+		aConsole->Printf(_L("	Success\n"));
+#endif	
+
+	CleanupStack::PushL(aConsole);
+	CActiveConsole* my_console = CActiveConsole::NewLC(aConsole);
+	my_console->RequestCharacter();
+	CActiveScheduler::Start();
+	CleanupStack::PopAndDestroy(3); 
+	}
+
+TInt E32Main()
+	{
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
+	TRAPD(error,RunAppL()); // more initialization, then do example
+	__ASSERT_ALWAYS(!error,User::Panic(_L("TOBEX"),error));
+	delete cleanup; // destroy clean-up stack
+	__UHEAP_MARKEND;
+
+	return 0; // and return
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/TOBEX.MMP	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,83 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+*/
+
+TARGET			tobex.exe
+TARGETTYPE		exe
+
+UID				0x0 0x1020e1a4
+
+CAPABILITY		All -Tcb
+
+#define OBEX_EXTENSION_APIS //comment this out if the extension api is not present.
+//#define VERIFY_EMPTY_HEADERS_ACC //uncomment this is if you want to build the test code for checking the acceptance of OBEX requests containing empty headers
+
+SOURCEPATH		.             
+SOURCE			TOBEX.CPP
+SOURCE			TOBEXCON.CPP
+SOURCE			btutils.cpp
+SOURCE			clienthandler.cpp
+SOURCE			serverhandlerbase.cpp
+SOURCE			serverhandler.cpp
+SOURCE			serverhandlerfile.cpp
+SOURCE			TREFHANDLER.CPP
+SOURCE			serverasyncao.cpp
+
+#ifdef VERIFY_EMPTY_HEADERS_ACC
+SOURCE			emptyheaderstest.cpp
+MACRO EMPTY_HEADERS_TEST
+#endif //VERIFY_EMPTY_HEADERS_ACC
+
+#ifdef OBEX_EXTENSION_APIS
+SOURCE			serverpacketaccessui.cpp
+#endif // OBEX_EXTENSION_APIS
+
+USERINCLUDE		. ../../inc
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+LIBRARY			euser.lib efsrv.lib esock.lib obex.lib bafl.lib c32.lib 
+
+#ifdef OBEX_EXTENSION_APIS
+LIBRARY			obexextensionapis.lib
+#endif // OBEX_EXTENSION_APIS
+
+// ONLY FOR IRDA:
+LIBRARY			irda.lib
+
+// ONLY FOR BLUETOOTH:
+LIBRARY			bluetooth.lib btmanclient.lib sdpdatabase.lib sdpagent.lib btextnotifiers.lib
+
+// Only for USB:
+LIBRARY			usbman.lib
+
+// For > 1M objects
+EPOCHEAPSIZE 1024000 4096000
+
+
+// At least one of these two must be uncommented:
+MACRO TRANSPORT_BLUETOOTH  // Comment this out if OBEX is not to be tested over Bluetooth
+MACRO TRANSPORT_IRDA // Comment this out if OBEX is not to be tested over IrDA
+// Uncomment this to exercise the server via MObexServerNotifyAsync rather 
+// than MObexServerNotify.
+//MACRO ASYNC_INDICATION
+#ifdef OBEX_EXTENSION_APIS
+MACRO PACKET_ACCESS_EXTENSION
+MACRO ERROR_RESOLUTION_EXTENSION
+#endif //OBEX_EXTENSION_APIS
+
+VENDORID 0x70000001
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/TOBEXCON.CPP	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,966 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <es_sock.h>
+#include <ir_sock.h>
+#include <bautils.h>
+#include <usbman.h>
+#include <d32usbc.h>
+#include <e32keys.h>
+#include "TOBEXCON.H"
+#include "clienthandler.h"
+#include "serverhandlerbase.h"
+#include "serverhandler.h"
+#include "serverhandlerfile.h"
+#include "btextnotifiers.h"
+
+#ifdef EMPTY_HEADERS_TEST
+#include "emptyheaderstest.h"
+#endif //EMPTY_HEADERS_TEST
+
+#define EPOCIDENT _L8("EPOC32 ER5")
+
+
+CActiveConsole::CActiveConsole(CConsoleBase* aConsole) 
+    : CActive(EPriorityNormal),
+      iConsole(aConsole),
+      iTestMode(E_Inactive),
+      iDiscoverySlots(KObexIrdaDefaultDiscoverySlotsToUse),
+      iDiscoveryAttempts(KObexIrdaDefaultDiscoveryAttempts),
+      iRecvMTU(KObexPacketDefaultSize),
+      iTransmitMTU(KObexPacketDefaultSize)
+    {
+#ifdef EMPTY_HEADERS_TEST
+	iDisplayHeaders = ETrue;
+#endif //EMPTY_HEADERS_TEST    
+    }
+
+CActiveConsole* CActiveConsole::NewLC(CConsoleBase* aConsole)
+    {
+    CActiveConsole* self = new (ELeave) CActiveConsole(aConsole);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+    return self;
+    }
+
+void CActiveConsole::ConstructL ()
+    { 
+    iRefHandler = CReferenceHandler::NewL();
+    iConsole->Printf(_L("\r\n"));
+    CActiveScheduler::Add(this);			// Add to active scheduler
+    
+    // Create private path and set default Inbox path
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+	fs.CreatePrivatePath(EDriveC);
+	fs.SetSessionToPrivate(EDriveC);	
+	fs.SessionPath(iInboxRoot);
+	fs.Close();
+    }
+
+CActiveConsole::~CActiveConsole()
+	{
+	// Make sure we're cancelled
+	Cancel();
+
+	// safe to delete NULL
+	delete iObexClientHandler;
+	delete iObexServerHandler;
+	delete iObexServerHandlerFile;
+	delete iRefHandler;
+	}
+
+void  CActiveConsole::DoCancel()
+    {
+    iConsole->ReadCancel();
+    }
+
+void  CActiveConsole::RunL()
+    {
+	// Save the current test mode in case the next action leaves
+	TUint oldTestMode = iTestMode;
+    TRAPD(err,ProcessKeyPressL(TChar(iConsole->KeyCode())));
+	if(err != KErrNone)
+		{
+		iConsole->Printf(_L("Failed. Error: %d\r\n"),err);
+		// Put the test mode back again
+		iTestMode = oldTestMode;
+		RequestCharacter();
+		}
+    }
+
+void CActiveConsole::RequestCharacter()
+    {
+    // A request is issued to the CConsoleBase to accept a
+    // character from the keyboard.
+    if (iTestMode == E_Client)
+		{
+		iConsole->Printf(_L("Commands :- \r\n"));
+		iConsole->Printf(_L(" A  -  IrObex Abort\r\n"));
+		iConsole->Printf(_L(" 1  -  IrObex Connect Menu\r\n"));
+		iConsole->Printf(_L(" 2  -  IrObex Disconnect\r\n"));
+		iConsole->Printf(_L(" 3  -  IrObex Put obj 1 : %S\r\n"), &(iObexClientHandler->iFilename1));
+		iConsole->Printf(_L(" 4  -  IrObex Put Obj 2 : %S\r\n"), &(iObexClientHandler->iFilename2));
+		iConsole->Printf(_L(" z  -  IrObex Put Obj 3 : %S\r\n"), &(iObexClientHandler->iFilename3));
+		iConsole->Printf(_L(" y  -  Enter HTTP/App param Test Menu\r\n")); //E_Client_HTTP_Menu
+		iConsole->Printf(_L(" 5  -  IrObex Get by name\r\n"));
+		iConsole->Printf(_L(" 6  -  IrObex Get by type\r\n"));
+		iConsole->Printf(_L(" 7  -  IrObex SetPath\r\n"));
+		iConsole->Printf(_L(" 8  -  IrObex Put reference object\r\n"));
+		iConsole->Printf(_L(" 9  -  IrObex Get reference object\r\n"));
+		iConsole->Printf(_L(" 0  -  IrObex Setup OBEX\r\n"));
+		iConsole->Printf(_L(" h  -  Toggle display of object headers\r\n"));
+#ifdef ERROR_RESOLUTION_EXTENSION
+		iConsole->Printf(_L(" l  -  Display last error\r\n"));
+#endif
+#ifdef EMPTY_HEADERS_TEST
+		iConsole->Printf(_L(" t  -  Empty headers test menu\r\n"));
+#endif //EMPTY_HEADERS_TEST
+		iConsole->Printf(_L(" s  -  kill the Obex Client\r\n"));
+		}
+	if ( iTestMode == E_Client_HTTP_Menu )
+		{ 
+		iConsole->Printf(_L(" 1  -  HTTP Multiple Packets, will all arrive\r\n"));
+		iConsole->Printf(_L(" 2  -  HTTP Multiple Packets, too many arrive in two parts\r\n"));
+		iConsole->Printf(_L(" 3  -  HTTP Single Packet too large, nothing will arrive\r\n"));
+		iConsole->Printf(_L(" 4  -  HTTP Single Packet too large with several smaller packets which will arrive\r\n"));
+		iConsole->Printf(_L(" 5  -  App parameters test\r\n"));
+		iConsole->Printf(_L(" s  -  Back to Client Menu\r\n"));
+		}
+	if ( iTestMode == E_Client_Connect_Menu )
+		{
+		iConsole->Printf(_L(" 0  -  IrObex Disconnect\r\n"));
+		iConsole->Printf(_L(" 1  -  IrObex Connect\r\n"));
+		iConsole->Printf(_L(" 2  -  IrObex Connect with Authentication\r\n"));
+		iConsole->Printf(_L(" 3  -  IrObex Connect with Target Header\r\n"));
+		iConsole->Printf(_L(" 4  -  IrObex Connect with Authentication AND Target Header\r\n"));
+		iConsole->Printf(_L(" 5  -  Get remote address\r\n"));
+		iConsole->Printf(_L(" s  -  Back to Client Menu\r\n"));
+		}
+	if ( iTestMode == E_Client_Setup_Menu )
+		{
+		iConsole->Printf(_L(" 1  -  Change Put Object 1\r\n"));
+		iConsole->Printf(_L(" 2  -  Change Put Object 2\r\n"));
+		iConsole->Printf(_L(" 3  -  Change Obex Get Name : %S\r\n"), &(iObexClientHandler->iObexName));
+		iConsole->Printf(_L(" 4  -  Change Obex Get Type : %S\r\n"), &(iObexClientHandler->iGetType));
+		iConsole->Printf(_L(" 5  -  Enable password support (so they can challenge us)\r\n"));
+		iConsole->Printf(_L(" 6  -  Set challenge password : %S\r\n"), &(iObexClientHandler->iChallengePassword));
+		iConsole->Printf(_L(" 7  -  Change Authentication Challenge Header\r\n"));
+		iConsole->Printf(_L(" 8  -  Set Command Time-out\r\n"));
+		iConsole->Printf(_L(" s  -  Back to Client Menu\r\n"));
+		iConsole->Printf(_L(" p  -  Set default file path : %S\r\n"), &iInboxRoot);
+		}
+	if ( iTestMode == E_Client_Authentication_Header_Menu )
+		{
+		iConsole->Printf(_L(" 1  -  Suppress Options Header\r\n"));
+		iConsole->Printf(_L(" 2  -  Suppress Realm Header\r\n"));
+		iConsole->Printf(_L(" 3  -  Suppress Options and Realm Headers\r\n"));
+		iConsole->Printf(_L(" 4  -  Reset to Default Authentication Headers\r\n"));
+		iConsole->Printf(_L(" 5  -  Attempt Invalid Authentication Headers Value (i)\r\n"));
+		iConsole->Printf(_L(" s  -  Back to Client Menu\r\n"));
+		}
+	if (iTestMode == E_Server)
+		{
+		iConsole->Printf(_L(" 1  -  Make OBEX Challenge on all incoming connections\r\n"));
+		iConsole->Printf(_L(" 2  -  Disable authentication\r\n"));
+		iConsole->Printf(_L(" 3  -  Enable password support (so they can challenge us)\r\n"));
+		iConsole->Printf(_L(" 4  -  Set FTP local who (insist on target header\r\n"));
+		iConsole->Printf(_L(" 5  -  Change challenge password : %S\r\n"), &(iObexServerHandler->iChallengePassword));
+		iConsole->Printf(_L(" 6  -  Get remote address\r\n"));
+        iConsole->Printf(_L(" 7  -  Set Target Checking to NoChecking\r\n"));
+        iConsole->Printf(_L(" 8  -  Set Target Checking to IfPresent\r\n"));
+        iConsole->Printf(_L(" 9  -  Set Target Checking to Always\r\n"));
+		iConsole->Printf(_L(" h  -  Toggle display of object headers\r\n"));
+		iConsole->Printf(_L(" p  -  Set Inbox root directory : %S\r\n"), &iInboxRoot);
+#ifdef PACKET_ACCESS_EXTENSION
+		iConsole->Printf(_L(" a  -  Enable displaying of request packets\r\n"));
+#endif // PACKET_ACCESS_EXTENSION
+		if(iTransport == EIrda)
+			{
+			iConsole->Printf(_L(" o  -  start suppressing IrDA discovery requests\r\n"));
+			iConsole->Printf(_L(" c  -  stop suppressing IrDA discovery requests\r\n"));
+			}
+
+		iConsole->Printf(_L("press 's' to stop the Obex Server\r\n"));
+		iConsole->Printf(_L("press 'S' to start the Obex Server\r\n"));
+		}
+	if (iTestMode == E_Server_File)
+		{
+		iConsole->Printf(_L(" Started Obex server, receiving into file-backed buffer object\r\n"));
+		iConsole->Printf(_L(" 1  -  Make OBEX Challenge on all incoming connections\r\n"));
+		iConsole->Printf(_L(" 2  -  Disable authentication\r\n"));
+		iConsole->Printf(_L(" 3  -  Enable password support (so they can challenge us)\r\n"));
+		iConsole->Printf(_L(" 4  -  Set FTP local who (insist on target header\r\n"));
+		iConsole->Printf(_L(" 5  -  Change challenge password : %S\r\n"), &(iObexServerHandlerFile->iChallengePassword));
+		iConsole->Printf(_L(" 6  -  Get remote address\r\n"));
+		iConsole->Printf(_L(" 7  -  Toggle buffered file writes\r\n"));
+		iConsole->Printf(_L(" p  -  Set Inbox root directory : %S\r\n"), &iInboxRoot);
+		iConsole->Printf(_L("s - Stop the Obex Server\r\n"));
+		iConsole->Printf(_L("g - Start the Obex Server\r\n"));
+		iConsole->Printf(_L("press 'k' to kill the Obex Server\r\n"));
+		}
+
+    if(iTestMode == E_Inactive)
+		{
+		iConsole->Printf(_L("press '1' to start the Obex Client over Bluetooth\r\n"));
+		iConsole->Printf(_L("press '2' to start the Obex Server over Bluetooth\r\n"));
+		iConsole->Printf(_L("press '3' to start the Obex Client over Irda\r\n"));
+		iConsole->Printf(_L("press 'a' to set the number of discovery slots to use in Irda\r\n"));
+ 		iConsole->Printf(_L("press 'b' to set the number of discovery attempts to make in Irda\r\n"));
+		iConsole->Printf(_L("press '4' to start the Obex Server over Irda\r\n"));
+		iConsole->Printf(_L("press '5' to start the Obex Server over Irda (filename backed buffer object)\r\n"));
+		iConsole->Printf(_L("press 'r' to start the Obex Server over Irda (RFile backed buffer object)\r\n"));
+		iConsole->Printf(_L("press '6' to start the Obex Server over USB\r\n"));
+		iConsole->Printf(_L("press '7' to start the Obex Client over USB\r\n"));
+		iConsole->Printf(_L("press 'n' to set the IrDA Nickname\r\n"));
+		iConsole->Printf(_L("press 'm' to set the Obex Recv MTU\r\n"));
+		iConsole->Printf(_L("press 'M' to set the Obex Transmit MTU\r\n"));
+		iConsole->Printf(_L("press 'p' to toggle performance logging\r\n"));
+		}
+#ifdef EMPTY_HEADERS_TEST
+	if ( iTestMode == E_Empty_Headers_Accept_Test )
+		{
+		iConsole->Printf(_L(" 1  -  Sent a packet with NOT empty following headers:\n\t[ Name, Type, Description, Target, Application Parameters ]\r\n\n"));
+		iConsole->Printf(_L(" 2  -  Sent a packet with existing but empty following headers:\n\t[ Name, Type, Description, Target, Application Parameters ]\r\n\n"));
+		iConsole->Printf(_L(" s  -  Back to Client Menu\r\n"));
+		}
+#endif //EMPTY_HEADERS_TEST
+	if(iTestMode == E_GetIrDANickname && iIrDANicknameBuffer.Length() == 0)
+		{
+		iConsole->Printf(_L("Enter new IrDA nickname: "));
+		}
+	if(iTestMode == E_EnterRecvMTU && iRecvMTU == 0)
+		{
+		iConsole->Printf(_L("Enter new Receive MTU value (m=max, d=default): "));
+		}
+	if(iTestMode == E_EnterTransmitMTU && iTransmitMTU == 0)
+		{
+		iConsole->Printf(_L("Enter new Transmit MTU value (m=max, d=default): "));
+		}
+	//if(E_SdpQuery) // no extra options
+
+    if(iTestMode != E_GetIrDANickname &&
+       iTestMode != E_EnterRecvMTU &&
+       iTestMode != E_EnterTransmitMTU)
+    	{
+    	iConsole->Printf(_L("press Escape to quit\r\n\r\n"));
+    	}
+    iConsole->Read(iStatus); 
+    SetActive();
+    }
+
+void CActiveConsole::ProcessKeyPressL(TChar aChar)
+    {
+    if (aChar == EKeyEscape)
+		{
+		CActiveScheduler::Stop();
+		return;
+		}
+
+    if(iTestMode ==E_Inactive)
+		{
+		switch (aChar)
+			{
+		case '1': 
+			iTestMode = E_SdpQuery;
+			iTransport = EBluetooth;
+			iObexClientHandler = CObexClientHandler::NewL(this, EBluetooth);
+			break;
+		case'3':
+			iTestMode = E_Client;
+			iTransport = EIrda;
+			iObexClientHandler = CObexClientHandler::NewL(this, EIrda);
+			break;
+		case 'a':
+ 			SetNumber(iDiscoverySlots);
+ 			break;
+ 		case 'b':
+ 			SetNumber(iDiscoveryAttempts);
+ 			break;	
+		case 'n':
+			iTestMode = E_GetIrDANickname;
+			iIrDANicknameBuffer.Zero();
+			break;
+		case 'p':
+			// Toggle the internal state.
+			iPerformanceLoggingEnabled = !iPerformanceLoggingEnabled;
+			if(iPerformanceLoggingEnabled)
+				{
+				iConsole->Printf(_L("\r\nPerformance logging enabled.\r\n\r\n"));
+				}
+			else
+				{
+				iConsole->Printf(_L("\r\nPerformance logging disabled.\r\n\r\n"));
+				}
+			break;
+		case '2':
+			iTestMode = E_Server;
+			iTransport = EBluetooth;
+			iObexServerHandler = CObexServerHandler::NewL(this, EBluetooth);
+			break;
+		case '4':
+			iTestMode = E_Server;
+			iTransport = EIrda;
+			iObexServerHandler = CObexServerHandler::NewL(this, EIrda);
+			break;
+		case '5':
+			iTestMode = E_Server_File;	// Added test for file-backed buffer object receive
+			iTransport = EIrda;
+			iObexServerHandlerFile = CObexServerHandlerFile::NewL(this,EIrda);
+			break;
+		case 'r':
+			iTestMode = E_Server_File;	// Added test for file-backed buffer object receive
+			iTransport = EIrda;
+			iObexServerHandlerFile = CObexServerHandlerFile::NewL(this,EIrda,ETrue);
+			break;
+		case '6':
+			{
+			iTestMode = E_Server;
+			
+#ifndef __WINS__
+			iTransport = EUsb;
+
+			// For USB, we unfortunately need to start it, then register our
+			// interfaces, then do a soft connect.
+			TInt err = User::LoadLogicalDevice(_L("EUSBC"));
+			if (err != KErrNone && err != KErrAlreadyExists)
+				{
+				User::Leave(err);
+				}
+			
+			RUsb usb;
+			User::LeaveIfError(usb.Connect());
+			TRequestStatus status;
+			usb.TryStart(2, status);
+			User::WaitForRequest(status);
+			iConsole->Printf(_L("Starting USB returned %d\n"), status.Int());
+            User::LeaveIfError(status.Int());
+			usb.Close();
+			
+			RDevUsbcClient usbDriver;
+			User::LeaveIfError(usbDriver.Open(0));
+			User::LeaveIfError(usbDriver.DeviceDisconnectFromHost());
+			
+			iObexServerHandler = CObexServerHandler::NewL(this, EUsb);
+
+			User::LeaveIfError(usbDriver.DeviceConnectToHost());
+			usbDriver.Close();
+
+#else
+
+			iTransport = EWin32Usb;
+			iObexServerHandler = CObexServerHandler::NewL(this, EWin32Usb);
+#endif
+
+			}
+			break;
+		case '7':
+			{
+			iTestMode = E_Client;
+			
+#ifdef __WINS__
+			iTransport = EWin32Usb;
+			iObexClientHandler = CObexClientHandler::NewL(this, EWin32Usb);
+			
+#else
+
+			iTransport = EUsb;
+			
+			// For USB, we unfortunately need to start it, then register our
+			// interfaces, then do a soft connect.
+			TInt loaded = User::LoadLogicalDevice(_L("EUSBC"));
+			iConsole->Printf(_L("Loading ldd returned %d\n"), loaded);
+			
+			RUsb usb;
+			User::LeaveIfError(usb.Connect());
+			iConsole->Printf(_L("Connected to USB\n"));
+			TRequestStatus status;
+			usb.TryStart(2,status);
+			User::WaitForRequest(status);
+			iConsole->Printf(_L("Starting USB returned %d\n"), status.Int());
+		    User::LeaveIfError(status.Int());
+			usb.Close();
+			
+			RDevUsbcClient usbDriver;
+			User::LeaveIfError(usbDriver.Open(0));
+			User::LeaveIfError(usbDriver.DeviceDisconnectFromHost());
+			
+			iObexClientHandler = CObexClientHandler::NewL(this, EUsb);
+
+			User::LeaveIfError(usbDriver.DeviceConnectToHost());
+			usbDriver.Close();
+#endif
+
+			}
+			break;
+		case 'm':
+			// Reset MTU value.
+			iRecvMTU = 0;
+			iTestMode = E_EnterRecvMTU;
+			break;
+
+		case 'M':
+			// Reset MTU value.
+			iTransmitMTU = 0;
+			iTestMode = E_EnterTransmitMTU;
+			break;
+			
+		default:
+			break;
+			}
+		}
+
+    else if(iTestMode == E_Server)
+		{
+		switch (aChar)
+			{
+		case 's': 
+			iObexServerHandler->Stop();
+			break;
+		case 'S':
+			iObexServerHandler->Start();
+			break;
+		case 'g': case 'G':
+			iObexServerHandler->Start();
+			break;
+		case 'h': case 'H':
+			iDisplayHeaders = !iDisplayHeaders;
+			break;
+		case 'k': case 'K':
+			delete iObexServerHandler;
+			iObexServerHandler = NULL;
+			iTestMode = E_Inactive;
+			break;
+		case 'o':
+			if(iTransport == EIrda)
+				{
+				iSupp.Open();
+				}
+			break;
+		case 'c':
+			if(iTransport == EIrda)
+				{
+				iSupp.Close();
+				}
+			break;
+		case '1':
+			iObexServerHandler->EnableAuthentication();
+			break;
+		case '2':
+			iObexServerHandler->DisableAuthentication();
+			break;
+		case '3':
+			iObexServerHandler->EnablePassword();
+			break;
+		case '4':
+			iObexServerHandler->SetLocalWho();
+			break;
+		case '5':
+			iObexServerHandler->ChangeChallengePassword();
+			break;
+		case '6':
+			iObexServerHandler->RemoteAddress();
+			break;
+        case '7':
+			iObexServerHandler->SetTargetChecking(CObexServer::ENoChecking);
+			break;
+		case '8':
+			iObexServerHandler->SetTargetChecking(CObexServer::EIfPresent);
+			break;
+		case '9':
+            iObexServerHandler->SetTargetChecking(CObexServer::EAlways);
+			break;
+		case 'p':
+			SetInboxRoot();
+			break;
+#ifdef PACKET_ACCESS_EXTENSION
+		case 'a':
+			iObexServerHandler->PacketAccessUiL(ETrue);
+			break;
+#endif // PACKET_ACCESS_EXTENSION
+		default:
+			iConsole->Printf(_L("\r\nUnknown Command\r\n\r\n"));
+			break;
+			}
+		}
+
+	else if(iTestMode == E_Server_File)
+		{
+		switch (aChar)
+			{
+		case 's': case 'S':
+			iObexServerHandlerFile->Stop();
+			delete iObexServerHandlerFile;
+			iObexServerHandlerFile = NULL;
+			iTestMode = E_Inactive;
+			break;
+		case '1':
+			iObexServerHandlerFile->EnableAuthentication();
+			break;
+		case '2':
+			iObexServerHandlerFile->DisableAuthentication();
+			break;
+		case '3':
+			iObexServerHandlerFile->EnablePassword();
+			break;
+		case '4':
+			iObexServerHandlerFile->SetLocalWho();
+			break;
+		case '5':
+			iObexServerHandlerFile->ChangeChallengePassword();
+			break;
+		case '6':
+			iObexServerHandlerFile->RemoteAddress();
+			break;
+		case '7':
+			iObexServerHandlerFile->ToggleWriteBuffering();
+			break;
+		case 'p':
+			SetInboxRoot();
+			break;
+		
+		default:
+			iConsole->Printf(_L("\r\nUnknown Command\r\n\r\n"));
+			break;
+			}
+		}
+	
+	else if (iTestMode == E_Client_Connect_Menu )
+		{
+		switch (aChar)
+			{
+		case '0':
+			iObexClientHandler->Disconnect();
+			break;
+		case '1':
+			iObexClientHandler->Connect();
+			break;
+		case '2':
+			iObexClientHandler->ConnectWithAuthenticationL();
+			break;
+		case '3':
+			iObexClientHandler->ConnectWithTarget();
+			break;
+		case '4':
+			iObexClientHandler->ConnectWithAuthenticationAndTargetL();
+			break;
+		case '5':
+			iObexClientHandler->RemoteAddress();
+			break;
+		default:
+			iTestMode = E_Client;
+			break;
+			}
+		}
+	else if ( iTestMode == E_Client_HTTP_Menu )
+		{
+		switch (aChar)	//tam
+			{
+		case '1':	//HTTP Multiple Packets;
+			iObexClientHandler->HTTPTest1L();
+			break;
+		case '2':	//HTTP Multiple Packets, too many, will arrive in two parts
+			iObexClientHandler->HTTPTest2L();
+			break;
+		case '3':	//HTTP Single Packet too large, nothing will arrive
+			iObexClientHandler->HTTPTest3L();
+			break;
+		case '4':	//HTTP Single Packet too large
+					//with several smaller packets which will arrive
+			iObexClientHandler->HTTPTest4L();
+			break;
+		case '5':	//App parameters test
+			iObexClientHandler->AppParamsTestL();
+		default:
+			iTestMode = E_Client;
+			break;
+			}
+
+		}
+	else if (iTestMode == E_Client_Setup_Menu )
+		{
+		switch (aChar)
+			{
+		case '1': 
+			iObexClientHandler->SetName(iObexClientHandler->iFilename1);
+			break;
+		case '2':
+			iObexClientHandler->SetName(iObexClientHandler->iFilename2);
+			break;
+		case '3':
+			iObexClientHandler->SetObexName();
+			break;
+		case '4': 
+			iObexClientHandler->SetType();
+			break;
+		case '5':
+			iObexClientHandler->EnablePassword();
+			break;
+		case '6':
+			iObexClientHandler->ChangeChallengePassword();
+			break;
+		case '7':
+			iTestMode = E_Client_Authentication_Header_Menu;
+			break;
+		case '8':
+			iObexClientHandler->SetCommandTimeout();
+			break;
+		case 'p':
+			SetInboxRoot();
+			break;
+		default:
+			iTestMode = E_Client;
+			break;
+			}
+		}
+	else if(iTestMode == E_Client)
+		{
+		switch (aChar)
+			{
+		case 'a': case 'A':
+			iObexClientHandler->Abort();
+			break;
+		case '1': 
+			iTestMode = E_Client_Connect_Menu;
+			break;
+		case '2':
+			iObexClientHandler->Disconnect();
+			break;
+		case '3': 
+			iObexClientHandler->Put(iObexClientHandler->iFilename1);
+			break;
+		case '4': 
+			iObexClientHandler->Put(iObexClientHandler->iFilename2);
+			break;
+		case 'y':case 'Y':
+			iTestMode = E_Client_HTTP_Menu;
+			break;
+		case 'z':case 'Z':
+			iObexClientHandler->Put(iObexClientHandler->iFilename3);
+			break;
+		case '5':
+			iObexClientHandler->GetByNameL();
+			break;
+		case '6':
+			iObexClientHandler->GetByTypeL();
+			break;
+		case '7':
+			iObexClientHandler->SetPath();
+			break;
+		case '8':
+			iObexClientHandler->SetCurrentTestNumber(); 
+			iObexClientHandler->PutReferenceL(10);
+			break;
+		case '9':
+			iObexClientHandler->SetCurrentTestNumber(); 
+			iObexClientHandler->GetReferenceL(8);
+			break;
+		case '0': 
+			iTestMode = E_Client_Setup_Menu;
+			break;
+		case 'h': case 'H':
+			iDisplayHeaders = !iDisplayHeaders;
+			break;
+#ifdef ERROR_RESOLUTION_EXTENSION
+		case 'l': case 'L':
+			iObexClientHandler->LastError();
+			break;
+#endif // ERROR_RESOLUTION_EXTENSION
+
+#ifdef EMPTY_HEADERS_TEST
+		case 't': 
+			iTestMode = E_Empty_Headers_Accept_Test;
+			break;
+#endif //EMPTY_HEADERS_TEST
+
+		case 's': case 'S':
+			delete iObexClientHandler;
+			iObexClientHandler = NULL;
+			iTestMode = E_Inactive;
+			break;
+		default:
+			iConsole->Printf(_L("\r\nUnknown Command\r\n\r\n"));
+			break;
+			}
+		}
+	else if(iTestMode == E_Client_Authentication_Header_Menu)
+		{
+		switch (aChar)
+			{
+		case '1':
+		case '2':
+		case '3':
+		case '4':
+		case '5':
+			iObexClientHandler->ChangeAuthenticationChallengeHeaders(aChar);
+			break;
+		case 's': case 'S':
+			iTestMode = E_Client_Setup_Menu;
+			break;
+		default:
+			iConsole->Printf(_L("\r\nUnknown Command\r\n\r\n"));
+			break;
+			}
+		}
+	else if(iTestMode == E_GetIrDANickname)
+		{
+		if(aChar.IsControl() ||
+		   iIrDANicknameBuffer.Length() == iIrDANicknameBuffer.MaxSize())
+			{
+			// Return to main menu.
+			iTestMode = E_Inactive;
+			iConsole->Printf(_L("\nNickname set to: %S\n\n"), &iIrDANicknameBuffer);
+			}
+		else
+			{
+			iConsole->Printf(_L("%c"), aChar.operator TUint());
+			iIrDANicknameBuffer.Append(aChar);
+			}
+		}
+	else if(iTestMode == E_EnterRecvMTU)
+		{
+		if(aChar.IsDigit())
+			{
+			iRecvMTU *= 10;
+			iRecvMTU += aChar.GetNumericValue();
+			iConsole->Printf(_L("%c"), aChar.operator TUint());			
+			if(iRecvMTU >= KObexPacketMaxSize)
+				{
+				// Return to main menu.
+				iTestMode = E_Inactive;
+				}
+			}
+		else
+			{
+			if(aChar == 'm')
+				{
+				// Set max MTU
+				iRecvMTU = KObexPacketMaxSize;
+				// Return to main menu.
+				iTestMode = E_Inactive;
+				}
+			else if(aChar == 'd')
+				{
+				// Set defualt MTU
+				iRecvMTU = 4000;
+				// Return to main menu.
+				iTestMode = E_Inactive;
+				}
+			else if(aChar.IsControl())
+				{
+				// Return to main menu.
+				iTestMode = E_Inactive;
+				}
+
+			iConsole->Printf(_L("\nReceive MTU set to: %d\n\n"), iRecvMTU);
+			}
+		}
+	else if(iTestMode == E_EnterTransmitMTU)
+		{
+		if(aChar.IsDigit())
+			{
+			iTransmitMTU *= 10;
+			iTransmitMTU += aChar.GetNumericValue();
+			iConsole->Printf(_L("%c"), aChar.operator TUint());			
+			if(iTransmitMTU >= KObexPacketMaxSize)
+				{
+				// Return to main menu.
+				iTestMode = E_Inactive;
+				}
+			}
+		else
+			{
+			if(aChar == 'm')
+				{
+				// Set max MTU
+				iTransmitMTU = KObexPacketMaxSize;
+				// Return to main menu.
+				iTestMode = E_Inactive;
+				}
+			else if(aChar == 'd')
+				{
+				// Set defualt MTU
+				iTransmitMTU = 4000;
+				// Return to main menu.
+				iTestMode = E_Inactive;
+				}
+			else if(aChar.IsControl())
+				{
+				// Return to main menu.
+				iTestMode = E_Inactive;
+				}
+
+			iConsole->Printf(_L("\nTransmit MTU set to: %d\n\n"), iTransmitMTU);
+			}
+		}
+#ifdef EMPTY_HEADERS_TEST
+	else if ( iTestMode == E_Empty_Headers_Accept_Test )
+		{
+		switch (aChar)
+			{
+				case '1' : 
+					iObexClientHandler->EmptyHeaderTestL(_L("Name header"), _L8("Type header"), _L("Description header"), _L8("Target header"), _L8("Application param header"));
+				break;
+
+				case '2': 
+					iObexClientHandler->EmptyHeaderTestL(_L(""), _L8(""), _L(""), _L8(""), _L8(""));
+				break;
+				
+				case 's': 
+				 iTestMode = E_Client;
+				break;
+				
+				default :
+					iConsole->Printf(_L("\r\nUnknown Command\r\n\r\n"));
+			}
+		
+		}
+#endif	//EMPTY_HEADERS_TEST	
+
+	else
+		{
+		CActiveScheduler::Stop();
+		return;
+		}
+	RequestCharacter ();
+	return;
+    }
+
+CConsoleBase* CActiveConsole::Console()
+	{
+	return iConsole;
+	}
+
+void CActiveConsole::SetPassword(TDes& aPassword)
+    {
+	iConsole->Printf(_L("\nEnter a password: %S"),&aPassword);
+
+	GetString(aPassword);
+
+	iConsole->Printf(_L("\n"));
+	iConsole->Printf( _L("\n Password size = %d\n"),aPassword.Length());
+    }
+
+
+void CActiveConsole::SetInboxRoot()
+	{
+	iConsole->Printf(_L("\nEnter a path: %S"), &iInboxRoot);
+
+	GetString(iInboxRoot);
+
+	iConsole->Printf(_L("\n"));
+	}
+
+
+TBool CActiveConsole::DisplayHeaders()
+	{
+	return iDisplayHeaders;
+	}
+	
+TBool CActiveConsole::SetNumber(TUint& aNumber)
+ 	{
+ 	TKeyCode code;
+ 	TBuf<1> ch;
+ 	TBuf<64> input;
+ 	TUint oldNumber = aNumber;
+ 
+ 	input.Num(aNumber);
+ 	iConsole->Printf(_L("\nEnter a number: %S"), &input);
+ 
+ 	FOREVER
+ 		{
+ 		code = iConsole->Getch();
+ 		ch.SetLength(0);
+ 		ch.Append(code);
+ 
+ 		iConsole->Printf(_L("%S"), &ch);
+ 
+ 		// If <CR> finish editing string.
+ 		if (code == EKeyEnter)
+ 			{
+ 			break;
+ 			}
+ 
+ 		// If <BS> remove last character.
+ 		if ((code == EKeyBackspace) && (input.Length() != 0))
+ 			{
+ 			input.SetLength((input.Length() - 1));
+ 			}
+ 		else
+ 			{
+ 			input.Append(code);
+ 			}
+ 		}
+ 	iConsole->Printf(_L("\n"));
+ 
+ 	TLex lex(input);
+ 	if (lex.Val(aNumber) != KErrNone)
+ 		{
+ 		iConsole->Printf(_L("\r\nError: You did not enter a number.\r\n"));
+ 		aNumber = oldNumber;
+ 		return EFalse;
+ 		}
+ 		
+ 	return ETrue;
+	}
+ 
+void CActiveConsole::GetString(TDes& aString)
+	{
+	TKeyCode code;
+	TBuf<1> character;
+	
+	FOREVER
+		{
+		code = iConsole->Getch();
+		character.SetLength(0);
+		character.Append(code);
+
+		iConsole->Printf(_L("%S"),&character);
+	
+		// If <CR> finish editing string
+		if (code == EKeyEnter)
+			break;
+		
+		// if <BS> remove last character
+		if ((code == EKeyBackspace) && (aString.Length() != 0))
+			{
+			aString.SetLength((aString.Length()-1));
+			}
+		else if (aString.Length() < aString.MaxLength())
+			{
+			aString.Append(code);
+			}
+		}
+	}
+
+void CActiveConsole::ClientErrored()
+	{
+	iTestMode = E_Inactive;
+	Cancel();
+	RequestCharacter();
+	delete iObexClientHandler;
+	iObexClientHandler = 0;
+	}
+
+TBool CActiveConsole::UseIrdaNickname() const
+	{
+	return (iIrDANicknameBuffer.Length() != 0);
+	}
+	
+const TDesC& CActiveConsole::GetIrdaNickname() const
+	{
+	return iIrDANicknameBuffer;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/TOBEXCON.H	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#ifndef _TOBEXCON_H
+#define _TOBEXCON_H
+
+#include <e32test.h>
+#include <e32cons.h>
+#include <irdaextensions.h>
+#include <obex.h>
+#include <btmanclient.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obex/internal/obexinternalconstants.h>
+#include <btsdp.h>
+#include <obexfinalpacketobserver.h>
+#include "constants.h"
+
+
+class CObexClientHandler;
+class CObexServerHandler;
+class CObexServerHandlerFile;
+class CReferenceHandler;
+
+class CActiveConsole : public CActive
+//-----------------------------------
+	{
+public:
+	  // Construction
+	CActiveConsole(CConsoleBase* aConsole);
+	static CActiveConsole* NewLC(CConsoleBase* aConsole);
+	void ConstructL();
+
+	  // Destruction
+	~CActiveConsole();
+
+	  // Issue request
+	void RequestCharacter();
+	
+	  // Cancel request.
+	  // Defined as pure virtual by CActive;
+	  // implementation provided by this class.
+	void DoCancel();
+
+	  // Service completed request.
+	  // Defined as pure virtual by CActive;
+	  // implementation provided by this class,
+	void RunL();
+
+	void ProcessKeyPressL(TChar aChar);
+
+	CConsoleBase* Console();
+	void SetPassword(TDes& aPassword);
+	void SetInboxRoot();
+	TBool DisplayHeaders();
+	void GetString(TDes& aPassword);
+	TBool SetNumber(TUint& aNumber);
+	void ClientErrored();
+	
+	TBool UseIrdaNickname() const;
+	const TDesC& GetIrdaNickname() const;
+	 
+public:
+	  // Data members defined by this class
+	CConsoleBase*			iConsole;					// A console for reading from
+	CObexClientHandler*		iObexClientHandler;	// Client wrapper for CObexClient
+	CObexServerHandler*		iObexServerHandler;	// Client wrapper for CObexServer
+	CObexServerHandlerFile*	iObexServerHandlerFile; //Client wrapper for CObexServer
+	TUint					iTestMode;
+	TTransport				iTransport;
+	CReferenceHandler*		iRefHandler;
+	TBool					iDisplayHeaders;
+	TPath					iInboxRoot;
+	TUint 					iDiscoverySlots;
+	TUint 					iDiscoveryAttempts;
+	TUint16					iRecvMTU;
+	TUint16					iTransmitMTU;
+	RIrdaDiscoveryResponseSuppressor iSupp;
+	TBuf<20> iIrDANicknameBuffer;
+	TBool iPerformanceLoggingEnabled;
+	};
+
+
+
+
+class CReferenceHandler : public CBase
+	{
+public:
+
+	enum TObexBufObjectComparison
+		{
+		EAllSame = 0,
+		EDifferentName = 1,
+		EDifferentType = 2,
+		EDifferentLength = 4,
+		EDifferentTime = 8,
+		EDifferentDescription = 16,
+		EDifferentTarget = 32,
+		EDifferentBuf = 64,
+		EDifferentHttp = 128,
+		EDifferentAppParam = 256,
+		EDifferentUserDefined = 512,
+		EDifferentCount = 1024,
+		EDifferentCreatorID = 2048,
+		EDifferentWanUUID = 4096, 
+		EDifferentObjectClass = 8192};
+
+	static CReferenceHandler* NewL();
+	CReferenceHandler();
+	~CReferenceHandler();
+
+	void CreateReferenceL(CObexBufObject& aObject, CBufFlat& aObjectBuf, TInt aReferenceId, TTransport aTransport);
+
+	TInt CompareObjectToReferenceL(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+
+private:
+	void CreateReferenceObject1L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+	void CreateReferenceObject2L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+	void CreateReferenceObject3L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+	void CreateReferenceObject4L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+	void CreateReferenceObject5L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+	void CreateReferenceObject6L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+	void CreateReferenceObject7L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+	void CreateReferenceObject8L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+	void CreateReferenceObject9L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+	void CreateReferenceObject10L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+
+	};
+
+#endif // _TOBEXCON_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/TREFHANDLER.CPP	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1236 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "TOBEXCON.H"
+#include "obexconstantsinternal.h"
+
+//reference object constants
+_LIT8(KAlphabet, "abcdefghijklmnopqrstuvwxyz");
+
+_LIT8(KRefType, "text/plain");
+_LIT8(KRefRichTextType, "text/richtext");
+_LIT8(KRefImageJpegType, "image/jpeg");
+
+_LIT8(KRefIrMCTarget, "IRMC-SYNC");
+_LIT8(KRefSyncMLTarget, "SYNCML-SYNC");
+
+
+CReferenceHandler* CReferenceHandler::NewL()
+{
+    CReferenceHandler* self = new (ELeave) CReferenceHandler();
+    return self;
+}
+
+CReferenceHandler::CReferenceHandler()
+{
+}
+
+CReferenceHandler::~CReferenceHandler()
+{
+}
+
+
+
+void CReferenceHandler::CreateReferenceL(CObexBufObject& aObject, CBufFlat& aObjectBuf, TInt aReferenceId, TTransport aTransport)
+{
+   switch (aReferenceId)
+   {
+   case (1) : 
+   		CreateReferenceObject1L(aObject,aObjectBuf,aTransport);
+   		break;
+   case (2) : 
+   		CreateReferenceObject2L(aObject,aObjectBuf,aTransport);
+   		break;
+   case (3) : 
+   		CreateReferenceObject3L(aObject,aObjectBuf,aTransport);
+   		break;
+   case (4) : 
+   		CreateReferenceObject4L(aObject,aObjectBuf,aTransport);
+   		break;
+   case (5) : 
+   		CreateReferenceObject5L(aObject,aObjectBuf,aTransport);
+   		break;
+   case (6) : 
+   		CreateReferenceObject6L(aObject,aObjectBuf,aTransport);
+   		break;
+   case (7) : 
+   		CreateReferenceObject7L(aObject,aObjectBuf,aTransport);
+   		break;
+   case (8) : 
+   		CreateReferenceObject8L(aObject,aObjectBuf,aTransport);
+   		break;
+   case (9) : 
+   		CreateReferenceObject9L(aObject,aObjectBuf,aTransport);
+   		break;
+   case (10) : 
+   		CreateReferenceObject10L(aObject,aObjectBuf,aTransport);
+   		break;
+   default : 
+   		CreateReferenceObject1L(aObject,aObjectBuf,aTransport);
+   		break;
+   }
+}
+
+void CReferenceHandler::CreateReferenceObject1L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+	//Reset the object (also resets the buffer)
+	aObject.Reset();
+	const TUint KNumOfAlphabets = 2;
+	aObjectBuf.ResizeL(KNumOfAlphabets * 30);
+	//populate the buffer...
+	TBuf8<4> buf;
+	TUint i;
+	for (i=0; i<KNumOfAlphabets; i++)
+		{
+		buf.Zero();
+		buf.AppendNumFixedWidth(i, EDecimal, 4);
+		aObjectBuf.Write(30*i, buf);
+		aObjectBuf.Write(30*i + 4, KAlphabet);
+		}
+	//populate the object
+	aObject.SetNameL(KRef2Name); // check the deletecurrentheader method
+	aObject.SetNameL(KRef1Name);
+
+	_LIT8(KRef1HTTP, "Accept: text/*");
+	_LIT8(KRef2HTTP, "Location: http://www.w3.org");
+	_LIT8(KRef3HTTP, "Date: Tue, 10 Nov 2002 09:17:21 GMT");
+
+	// add Http header using old API
+	//
+/*	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+
+	// USE THE HEADER MASK TO REMOVE HTTP HEADERS FROM HEADERSET
+	// THIS DOES NOT REMOVE THE ITEMS FROM iHttp LIST - this tests 
+	// the Http() function which should remove items from iHttp list
+	//
+
+	TObexMatchHeader* headerMask = new(ELeave) TObexMatchHeader;
+	headerMask->SetHeader(TObexInternalHeader::EName); 
+	aObject.HeaderSet().SetMask(headerMask);
+	aObject.HeaderSet().DeleteMasked();
+	aObject.HeaderSet().SetMask(NULL);
+	delete headerMask;
+
+*/
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+
+/*	if (aObject.Http())
+		{
+		NULL;
+		}
+*/
+	// add a Count header using new API
+	//
+	CObexHeader* tempheader = CObexHeader::NewL();
+	CleanupStack::PushL(tempheader);
+	tempheader->SetFourByte(TObexInternalHeader::ECount, 0xFE22FF54);
+	aObject.AddHeaderL(*tempheader);
+	CleanupStack::Pop(tempheader);
+
+	// add an Http header using new API
+	//
+	tempheader = CObexHeader::NewL();
+	CleanupStack::PushL(tempheader);
+	tempheader->SetByteSeqL(TObexInternalHeader::EHttp, KRef1HTTP);
+	aObject.AddHeaderL(*tempheader);
+	CleanupStack::Pop(tempheader);
+
+	aObject.SetTypeL(KRefType);
+	// set again to check header update functionality
+	aObject.SetTypeL(KRefType);
+	aObject.SetLengthL(aObjectBuf.Size());
+	// set again to check header update functionality
+	aObject.SetLengthL(aObjectBuf.Size());
+
+	TBuf8<40> param;
+	param.Copy(_L("\x04"));
+	param.Append(_L("\x03"));
+	param.Append(_L("App params 123"));
+	aObject.SetAppParamL(param);
+	// set again to check header update functionality
+	aObject.SetAppParamL(param);
+
+	const TTime KRef1Time = TDateTime(2003, EApril, 29, 10, 10, 10, 0);
+	aObject.SetTimeL(KRef1Time);
+	// set again to check header update functionality
+	aObject.SetTimeL(KRef1Time);
+
+	// Set up the MF description header
+	const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+	HBufC* descBuf = HBufC::NewLC(KDescLength);
+	ASSERT(descBuf);
+	TPtr ptr(descBuf->Des());
+	ptr.Zero();
+	for (i=0; i<KDescLength; i++)
+		{
+		ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+		}
+	aObject.SetDescriptionL(ptr);
+	// set again to check header update functionality
+	aObject.SetDescriptionL(ptr);
+
+	CleanupStack::PopAndDestroy(descBuf);
+
+	aObject.SetTargetL(KRefTarget);
+	// set again to check header update functionality
+	aObject.SetTargetL(KRefTarget);
+
+	CObexHeader* header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetUnicodeL(0x30, KRef1Name);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetFourByte(TObexInternalHeader::ECreatorID, 0x5F3A2343);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetUnicodeL(0x36, KRef5Name);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByteSeqL(TObexInternalHeader::EWanUUID, KRefTarget);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetUnicodeL(0x3F, KRef5Name);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByte(0xB0, 0x03);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByte(0xBF, 0x12);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByte(0xBE, 0x12);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetFourByte(0xF0, 0x54545454);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+// THIS NEXT HEADER IS A NEGATIVE TEST. It should cause a panic
+// 0x2F header doesnt have a FourByte HI Type.
+/*	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetFourByte(0x2F, 0x54);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+*/
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetFourByte(0xFF, 0x00111243);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByteSeqL(0x73, KRefTarget);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header); 
+	header->SetByteSeqL(TObexInternalHeader::EObjectClass, KRefTarget);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	aObject.SetHeaderMask(KObexHdrName |KObexHdrType | KObexHdrLength  | KObexHdrTime | KObexHdrDescription | KObexHdrTarget | KObexHdrHttp | KObexHdrCount | KObexHdrAppParam | KObexHdrUserDefined | KObexHdrObjectClass | KObexHdrWanUUID  | KObexHdrCreatorID);
+
+}
+
+void CReferenceHandler::CreateReferenceObject2L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+	//Reset the object (also resets the buffer)
+	aObject.Reset();
+	const TUint KNumOfObjects = 2;
+	aObjectBuf.ResizeL(KNumOfObjects * 20);
+	//populate the buffer...
+	_LIT8(KRefDesc2, "*Reference Object 2*");
+	TUint i;
+	for (i=0; i<KNumOfObjects; i++)
+		{
+		aObjectBuf.Write(20*i, KRefDesc2);
+		}
+	//populate the object
+	aObject.SetNameL(KRef2Name);
+	aObject.SetTypeL(KRefType);
+	aObject.SetLengthL(aObjectBuf.Size());
+	const TTime KRef2Time = TDateTime(2002, EJanuary, 0, 0, 0, 0, 0);
+	aObject.SetTimeL(KRef2Time);
+
+	// Set up the MF description header
+	const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+	HBufC* descBuf = HBufC::NewLC(KDescLength);
+	ASSERT(descBuf);
+	TPtr ptr(descBuf->Des());
+	ptr.Zero();
+	for (i=0; i<KDescLength; i++)
+		{
+		ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+		}
+	aObject.SetDescriptionL(ptr);
+	CleanupStack::PopAndDestroy(descBuf);
+	aObject.SetTargetL(KRefIrMCTarget);
+	aObject.SetHeaderMask(KObexHdrName | KObexHdrType | KObexHdrLength  | KObexHdrTime | KObexHdrDescription | KObexHdrTarget);
+}
+
+void CReferenceHandler::CreateReferenceObject3L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+	//Reset the object (also resets the buffer)
+	aObject.Reset();
+	const TUint KNumOfAlphabets = 1000;
+	aObjectBuf.ResizeL(KNumOfAlphabets * 30);
+	//populate the buffer...
+	TBuf8<4> buf;
+	TUint i;
+	for (i=0; i<KNumOfAlphabets; i++)
+		{
+		buf.Zero();
+		buf.AppendNumFixedWidth(i, EDecimal, 4);
+		aObjectBuf.Write(30*i, buf);
+		aObjectBuf.Write(30*i + 4, KAlphabet);
+		}
+	//populate the object
+	aObject.SetNameL(KRef3Name);
+	aObject.SetTypeL(KRefRichTextType);
+	aObject.SetLengthL(aObjectBuf.Size());
+	const TTime KRef3Time = TDateTime(2002, EJanuary, 0, 0, 0, 0, 0);
+	aObject.SetTimeL(KRef3Time);
+
+	// Set up the MF description header
+	const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+	HBufC* descBuf = HBufC::NewLC(KDescLength);
+	ASSERT(descBuf);
+	TPtr ptr(descBuf->Des());
+	ptr.Zero();
+	for (i=0; i<KDescLength; i++)
+		{
+		ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+		}
+	aObject.SetDescriptionL(ptr);
+	CleanupStack::PopAndDestroy(descBuf);
+	aObject.SetTargetL(KRefTarget);
+
+	CObexHeader* header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetUnicodeL(0x30, KRef1Name);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetUnicodeL(0x36, KRef5Name);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetUnicodeL(0x3F, KRef5Name);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByte(0xB0, 0x03);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByte(0xBF, 0x12);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetFourByte(0xF0, 0x54);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+// THIS NEXT HEADER IS A NEGATIVE TEST. It should cause a panic
+// 0x2F header doesnt have a FourByte HI Type.
+/*	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetFourByte(0x2F, 0x54);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+*/
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetFourByte(0xFF, 0x43);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByteSeqL(0x73, KRefTarget);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	aObject.SetHeaderMask(KObexHdrName | KObexHdrType | KObexHdrLength  | KObexHdrTime | KObexHdrDescription | KObexHdrTarget | KObexHdrUserDefined);
+}
+
+void CReferenceHandler::CreateReferenceObject4L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+	//Reset the object (also resets the buffer)
+	aObject.Reset();
+	const TUint KNumOfAlphabets = 200;
+	aObjectBuf.ResizeL(KNumOfAlphabets * 30);
+	//populate the buffer...
+	TBuf8<4> buf;
+	TUint i;
+	for (i=0; i<KNumOfAlphabets; i++)
+		{
+		buf.Zero();
+		buf.AppendNumFixedWidth(i, EDecimal, 4);
+		aObjectBuf.Write(30*i, buf);
+		aObjectBuf.Write(30*i + 4, KAlphabet);
+		}
+	//populate the object
+
+	aObject.SetNameL(KRef4Name);
+	aObject.SetLengthL(aObjectBuf.Size());
+
+	// Set up the MF description header
+	const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+	HBufC* descBuf = HBufC::NewLC(KDescLength);
+	ASSERT(descBuf);
+	TPtr ptr(descBuf->Des());
+	ptr.Zero();
+	for (i=0; i<KDescLength; i++)
+		{
+		ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+		}
+	aObject.SetDescriptionL(ptr);
+	CleanupStack::PopAndDestroy(descBuf);
+	aObject.SetTargetL(KRefTarget);
+
+	TBuf8<40> param;
+	param.Copy(_L("\x04"));
+	param.Append(_L("\x03"));
+	param.Append(_L("App params 456"));
+	aObject.SetAppParamL(param);
+
+	aObject.SetHeaderMask(KObexHdrName | KObexHdrLength | KObexHdrDescription | KObexHdrTarget | KObexHdrAppParam);
+}
+
+void CReferenceHandler::CreateReferenceObject5L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+	//Reset the object (also resets the buffer)
+	aObject.Reset();
+	const TUint KNumOfAlphabets = 200;
+	aObjectBuf.ResizeL(KNumOfAlphabets * 30);
+	//populate the buffer...
+	TBuf8<4> buf;
+	TUint i;
+	for (i=0; i<KNumOfAlphabets; i++)
+		{
+		buf.Zero();
+		buf.AppendNumFixedWidth(i, EDecimal, 4);
+		aObjectBuf.Write(30*i, buf);
+		aObjectBuf.Write(30*i + 4, KAlphabet);
+		}
+	//populate the object
+	aObject.SetNameL(KRef5Name);
+	aObject.SetTypeL(KRefImageJpegType);
+	aObject.SetLengthL(aObjectBuf.Size());
+	const TTime KRef5Time = TDateTime(2001, EFebruary, 14, 15, 38, 24, 0);//set time to 15:38:24.0 on 14th Feb 2001 - obex doesn't transfer microseconds!!
+	aObject.SetTimeL(KRef5Time);
+
+	_LIT8(KRef1HTTP, "Accept: text/*");
+	_LIT8(KRef2HTTP, "Location: http://www.w3.org");
+	_LIT8(KRef3HTTP, "Date: Tue, 10 Nov 2002 09:17:21 GMT");
+
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+
+	// Set up the MF description header
+	const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+	HBufC* descBuf = HBufC::NewLC(KDescLength);
+	ASSERT(descBuf);
+	TPtr ptr(descBuf->Des());
+	ptr.Zero();
+	for (i=0; i<KDescLength; i++)
+		{
+		ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+		}
+	aObject.SetDescriptionL(ptr);
+	CleanupStack::PopAndDestroy(descBuf);
+	aObject.SetTargetL(KRefTarget);
+	aObject.SetHeaderMask(KObexHdrName | KObexHdrType  | KObexHdrTime | KObexHdrLength  | KObexHdrTime | KObexHdrDescription | KObexHdrHttp | KObexHdrTarget);
+}
+
+void CReferenceHandler::CreateReferenceObject6L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+	//Reset the object (also resets the buffer)
+	aObject.Reset();
+	const TUint KNumOfAlphabets = 200;
+	aObjectBuf.ResizeL(KNumOfAlphabets * 30);
+	//populate the buffer...
+	TBuf8<4> buf;
+	TUint i;
+	for (i=0; i<KNumOfAlphabets; i++)
+		{
+		buf.Zero();
+		buf.AppendNumFixedWidth(i, EDecimal, 4);
+		aObjectBuf.Write(30*i, buf);
+		aObjectBuf.Write(30*i + 4, KAlphabet);
+		}
+	//populate the object
+
+	aObject.SetNameL(KRef6Name);
+	aObject.SetTypeL(KRefImageJpegType);
+	aObject.SetLengthL(aObjectBuf.Size());
+	const TTime KRef5Time = TDateTime(2001, EFebruary, 14, 15, 38, 24, 0);//set time to 15:38:24.0 on 14th Feb 2001 - obex doesn't transfer microseconds!!
+	aObject.SetTimeL(KRef5Time);
+
+	_LIT8(KRef1HTTP, "Accept: text/*");
+	_LIT8(KRef2HTTP, "Location: http://www.w3.org");
+	_LIT8(KRef3HTTP, "Date: Tue, 10 Nov 2002 09:17:21 GMT");
+/*
+	TObexMatchHeader* headerMask = new(ELeave) TObexMatchHeader;
+
+	headerMask->SetHeader(TObexInternalHeader::EName); 
+	aObject.HeaderSet().SetMask(headerMask);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+	if (aObject.Http())
+		{
+		NULL;
+		}
+	aObject.HeaderSet().SetMask(headerMask);
+	aObject.HeaderSet().DeleteMasked();
+	aObject.AddHttpL(KRef3HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+	if (aObject.Http())
+		{
+		NULL;
+		}
+	aObject.HeaderSet().SetMask(headerMask);
+	aObject.HeaderSet().DeleteMasked();
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+	
+
+	if (aObject.Http())
+		{
+		NULL;
+		}
+
+	aObject.HeaderSet().SetMask(headerMask);
+	aObject.HeaderSet().DeleteMasked();
+	delete headerMask;
+*/
+
+	aObject.AddHttpL(KRef3HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+
+/*
+	if (aObject.Http())
+		{
+		NULL;
+		}
+
+
+	aObject.HeaderSet().SetMask(NULL);
+*/
+
+	// Set up the MF description header
+	const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+	HBufC* descBuf = HBufC::NewLC(KDescLength);
+/*	ASSERT(descBuf);
+	TPtr ptr(descBuf->Des());
+	ptr.Zero();
+	for (i=0; i<KDescLength; i++)
+		{
+		ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+		}
+	aObject.SetDescriptionL(ptr);
+*/	CleanupStack::PopAndDestroy(descBuf);
+
+	aObject.SetTargetL(KRefTarget);
+
+	CObexHeader* header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetUnicodeL(0x30, KRef1Name);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetUnicodeL(0x36, KRef5Name);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetUnicodeL(0x3F, KRef5Name);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByte(0xB0, 0x03);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByte(0xBF, 0x12);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetFourByte(0xF0, 0x54);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+// THIS NEXT HEADER IS A NEGATIVE TEST. It should cause a panic
+// 0x2F header doesnt have a FourByte HI Type.
+/*	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetFourByte(0x2F, 0x54);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+*/
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetFourByte(0xFF, 0x43);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByteSeqL(0x73, KRefTarget);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	aObject.SetHeaderMask(KObexHdrName | KObexHdrType  | KObexHdrTime | KObexHdrLength | KObexHdrHttp | KObexHdrTarget | KObexHdrUserDefined );
+}
+
+
+void CReferenceHandler::CreateReferenceObject7L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+	//Reset the object (also resets the buffer)
+	aObject.Reset();
+	const TUint KNumOfAlphabets = 200;
+	aObjectBuf.ResizeL(KNumOfAlphabets * 30);
+	//populate the buffer...
+	TBuf8<4> buf;
+	TUint i;
+	for (i=0; i<KNumOfAlphabets; i++)
+		{
+		buf.Zero();
+		buf.AppendNumFixedWidth(i, EDecimal, 4);
+		aObjectBuf.Write(30*i, buf);
+		aObjectBuf.Write(30*i + 4, KAlphabet);
+		}
+	//populate the object
+
+	aObject.SetNameL(KRef7Name);
+	aObject.SetTypeL(KRefImageJpegType);
+	aObject.SetLengthL(aObjectBuf.Size());
+	const TTime KRef5Time = TDateTime(2001, EFebruary, 14, 15, 38, 24, 0);//set time to 15:38:24.0 on 14th Feb 2001 - obex doesn't transfer microseconds!!
+	aObject.SetTimeL(KRef5Time);
+
+	_LIT8(KRef1HTTP, "Accept: text/*");
+	_LIT8(KRef2HTTP, "Location: http://www.w3.org");
+	_LIT8(KRef3HTTP, "Date: Tue, 10 Nov 2002 09:17:21 GMT");
+
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+
+
+	// Set up the MF description header
+	const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+	HBufC* descBuf = HBufC::NewLC(KDescLength);
+/*	ASSERT(descBuf);
+	TPtr ptr(descBuf->Des());
+	ptr.Zero();
+	for (i=0; i<KDescLength; i++)
+		{
+		ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+		}
+	aObject.SetDescriptionL(ptr);
+*/
+	CleanupStack::PopAndDestroy(descBuf);
+
+	aObject.SetTargetL(KRefSyncMLTarget);
+	aObject.SetHeaderMask(KObexHdrName | KObexHdrType  | KObexHdrTime | KObexHdrLength | KObexHdrHttp | KObexHdrTarget);
+}
+
+void CReferenceHandler::CreateReferenceObject8L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+	//Reset the object (also resets the buffer)
+	aObject.Reset();
+	const TUint KNumOfAlphabets = 200;
+	aObjectBuf.ResizeL(KNumOfAlphabets * 30);
+
+	//populate the buffer...
+	TBuf8<4> buf;
+	TUint i;
+	for (i=0; i<KNumOfAlphabets; i++)
+		{
+		buf.Zero();
+		buf.AppendNumFixedWidth(i, EDecimal, 4);
+		aObjectBuf.Write(30*i, buf);
+		aObjectBuf.Write(30*i + 4, KAlphabet);
+		}
+		
+	//populate the object
+
+	aObject.SetNameL(KRef8Name);
+	aObject.SetTypeL(KRefType);
+	const TTime KRef10Time = TDateTime(2005, EJanuary, 17, 14, 35, 30, 0);
+	aObject.SetTimeL(KRef10Time);
+	aObject.SetTargetL(KRefIrMCTarget);
+	TBuf8<40> param;
+	param.Copy(_L("\x04"));
+	param.Append(_L("\x03"));
+	param.Append(_L("PARAM 435"));
+	aObject.SetAppParamL(param);
+
+	_LIT8(KRef1HTTP, "Accept: text/*");
+	aObject.AddHttpL(KRef1HTTP);
+
+	CObexHeader* header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	_LIT(KUserDefUnicode2, "UserDef2");
+	header->SetUnicodeL(0x34, KUserDefUnicode2);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByte(0xBC, 0x23);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+	
+	// Set up the MF description header
+	const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+	HBufC* descBuf = HBufC::NewLC(KDescLength);
+/*	ASSERT(descBuf);
+ 	Ptr ptr(descBuf->Des());
+	ptr.Zero();
+	for (i=0; i<KDescLength; i++)
+		{
+		ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+		}
+	aObject.SetDescriptionL(ptr);
+*/
+	CleanupStack::PopAndDestroy(descBuf);
+
+	aObject.SetHeaderMask(KObexHdrName | KObexHdrType | KObexHdrTime | KObexHdrTarget | KObexHdrAppParam | KObexHdrHttp |KObexHdrUserDefined);
+}
+
+void CReferenceHandler::CreateReferenceObject9L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+	//Reset the object (also resets the buffer)
+	aObject.Reset();
+	const TUint KNumOfAlphabets = 1000;
+	aObjectBuf.ResizeL(KNumOfAlphabets * 30);
+	//populate the buffer...
+	TBuf8<4> buf;
+	TUint i;
+	for (i=0; i<KNumOfAlphabets; i++)
+		{
+		buf.Zero();
+		buf.AppendNumFixedWidth(i, EDecimal, 4);
+		aObjectBuf.Write(30*i, buf);
+		aObjectBuf.Write(30*i + 4, KAlphabet);
+		}
+	//populate the object
+	aObject.SetNameL(KRef9Name);
+	aObject.SetTypeL(KRefType);
+	aObject.SetLengthL(aObjectBuf.Size());
+	const TTime KRef3Time = TDateTime(2002, EJanuary, 0, 0, 0, 0, 0);
+	aObject.SetTimeL(KRef3Time);
+
+	_LIT8(KRef1HTTP, "Accept: text/*");
+	_LIT8(KRef2HTTP, "Location: http://www.bluetooth.com");
+	_LIT8(KRef3HTTP, "Date: Tue, 10 Nov 2002 09:17:21 GMT");
+
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+	aObject.AddHttpL(KRef1HTTP);
+	aObject.AddHttpL(KRef2HTTP);
+	aObject.AddHttpL(KRef3HTTP);
+
+	// Set up the MF description header
+	const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+	HBufC* descBuf = HBufC::NewLC(KDescLength);
+/*	ASSERT(descBuf);
+ 	Ptr ptr(descBuf->Des());
+	ptr.Zero();
+	for (i=0; i<KDescLength; i++)
+		{
+		ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+		}
+	aObject.SetDescriptionL(ptr);
+*/
+	CleanupStack::PopAndDestroy(descBuf);
+	aObject.SetTargetL(KRefSyncMLTarget);
+	aObject.SetHeaderMask(KObexHdrName | KObexHdrHttp | KObexHdrType | KObexHdrLength  | KObexHdrTime | KObexHdrDescription | KObexHdrTarget);
+}
+
+//Empty object with EoB headder
+void CReferenceHandler::CreateReferenceObject10L(CObexBufObject& aObject, CBufFlat& /*aObjectBuf*/, TTransport /*aTransport*/)
+{
+	//Reset the object (also resets the buffer)
+	aObject.Reset();
+
+	aObject.SetNameL(KRef8Name);
+	aObject.SetTypeL(KRefType);
+	const TTime KRef10Time = TDateTime(2005, EJanuary, 17, 14, 35, 30, 0);
+	aObject.SetTimeL(KRef10Time);
+	aObject.SetTargetL(KRefIrMCTarget);
+	TBuf8<40> param;
+	param.Copy(_L("\x04"));
+	param.Append(_L("\x03"));
+	param.Append(_L("PARAM 435"));
+	aObject.SetAppParamL(param);
+
+	_LIT8(KRef1HTTP, "Accept: text/*");
+	aObject.AddHttpL(KRef1HTTP);
+
+	CObexHeader* header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	_LIT(KUserDefUnicode2, "UserDef2");
+	header->SetUnicodeL(0x34, KUserDefUnicode2);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	header->SetByte(0xBC, 0x23);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+	
+	header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	TBuf8<1000> dummy;
+	header->SetByteSeqL(TObexInternalHeader::EEndOfBody, dummy);
+	aObject.AddHeaderL(*header);
+	CleanupStack::Pop(header);
+
+
+	HBufC* descBuf = HBufC::NewLC(0);
+	CleanupStack::PopAndDestroy(descBuf);
+}
+
+TInt CReferenceHandler::CompareObjectToReferenceL(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+	CBufFlat* buf = CBufFlat::NewL(3000);
+	CleanupStack::PushL(buf);
+	CObexBufObject* obj = CObexBufObject::NewL(buf);
+	CleanupStack::PushL(obj);
+
+	if (aObject.Name() == KRef1Name)
+		CreateReferenceObject1L(*obj, *buf, aTransport);
+	else if (aObject.Name() == KRef2Name)
+		CreateReferenceObject2L(*obj, *buf, aTransport);
+	else if (aObject.Name() == KRef3Name)
+		CreateReferenceObject3L(*obj, *buf, aTransport);
+	else if (aObject.Name() == KRef4Name)
+		CreateReferenceObject4L(*obj, *buf, aTransport);
+	else if (aObject.Name() == KRef5Name)
+		CreateReferenceObject5L(*obj, *buf, aTransport);
+	else if (aObject.Name() == KRef6Name)
+		CreateReferenceObject6L(*obj, *buf, aTransport);
+	else if (aObject.Name() == KRef7Name)
+		CreateReferenceObject7L(*obj, *buf, aTransport);
+	else if (aObject.Name() == KRef8Name)
+		CreateReferenceObject8L(*obj, *buf, aTransport);
+	else if (aObject.Name() == KRef9Name)
+		CreateReferenceObject9L(*obj, *buf, aTransport);
+	else //default
+		CreateReferenceObject1L(*obj, *buf, aTransport);
+
+	TInt res = 0;
+	
+	if (aObject.Name() != obj->Name())
+		res |= EDifferentName;
+	if (aObject.Type() != obj->Type())
+		res |= EDifferentType;
+	if (aObject.Length() != obj->Length())
+		res |= EDifferentLength;
+	if (aObject.Time() != obj->Time())
+		res |= EDifferentTime;
+	if (aObject.Description() != obj->Description())
+		res |= EDifferentDescription;
+	if (aObject.Target() != obj->Target())
+		res |= EDifferentTarget;
+	if (aObjectBuf.Ptr(0) != buf->Ptr(0))
+		res |= EDifferentBuf;
+	if (aObject.AppParam() != obj->AppParam())
+		res |= EDifferentAppParam;
+	if (aObject.Http())
+		{
+			if ( ((aObject.Http())->Count()) == ((obj->Http())->Count())) 
+			{	
+				TInt arrayIndex = 0;
+				while (arrayIndex < ((aObject.Http())->Count()))
+				{
+					if ((((*aObject.Http())[arrayIndex])->Des()) != (((*obj->Http())[arrayIndex])->Des()))
+					{
+						res |= EDifferentHttp;
+					}
+					arrayIndex++;
+				}
+			}
+			else
+			{
+				res |= EDifferentHttp;
+			}
+		}
+	
+	
+	CObexHeader* firstHeader = CObexHeader::NewL();
+	CObexHeader* secondHeader = CObexHeader::NewL();
+
+	TInt err1 =0;
+	TInt err2 =0;
+
+/*
+	TObexMatchHeader* headerMask = new(ELeave) TObexMatchHeader;
+
+	headerMask->SetHeader(TObexInternalHeader::EName); 
+
+	aObject.HeaderSet().SetMask(headerMask);
+	err1 = aObject.HeaderSet().This(firstHeader);
+	obj->HeaderSet().SetMask(headerMask);
+	err2 = obj->HeaderSet().This(secondHeader);
+	
+	if (err1 == err2)
+		{
+		if (firstHeader->AsUnicodeL() != secondHeader->AsUnicodeL())
+			{
+			res |= EDifferentName;
+			}
+		}
+	else
+		{
+		res |= EDifferentName;
+		}
+
+	aObject.HeaderSet().SetMask(NULL);
+	obj->HeaderSet().SetMask(NULL);
+	
+	delete headerMask;
+	delete firstHeader;
+	delete secondHeader;
+
+*/
+
+	if (aObject.Http())
+		{
+		if (obj->Http())
+			{
+			aObject.HeaderSet().First();
+			obj->HeaderSet().First();
+
+			err1 = aObject.HeaderSet().Find(TObexInternalHeader::EHttp, *firstHeader);
+			err2 = obj->HeaderSet().Find(TObexInternalHeader::EHttp, *secondHeader);
+	
+			while (err1 == KErrNone && err2 == KErrNone)
+				{
+				if (firstHeader->AsByteSeq() != secondHeader->AsByteSeq())
+					{
+					res |= EDifferentHttp;
+					}
+				aObject.HeaderSet().Next();
+				obj->HeaderSet().Next();
+				err1 = aObject.HeaderSet().Find(TObexInternalHeader::EHttp, *firstHeader);
+				err2 = obj->HeaderSet().Find(TObexInternalHeader::EHttp, *secondHeader);
+				}
+			if (err1 != err2)
+				{
+				res |= EDifferentHttp;
+				}
+
+			}
+		else
+			{
+			res |= EDifferentHttp;
+			}
+		}
+	else
+		{
+		if (obj->Http())
+			{
+			res |= EDifferentHttp;
+			}
+		}
+
+
+//	delete firstHeader;
+//	delete secondHeader;
+
+	for (TUint8 headerNameIndex = KObexUserDefinedHdrAddrMin; 
+	 		headerNameIndex <= KObexUserDefinedHdrAddrMax; headerNameIndex++)
+		{
+		TUint8 localHI =  static_cast<TUint8>(headerNameIndex | TObexInternalHeader::EUnicode);
+		
+		aObject.HeaderSet().First();
+		obj->HeaderSet().First();
+
+		err1 = aObject.HeaderSet().Find(localHI, *firstHeader);
+		err2 = obj->HeaderSet().Find(localHI, *secondHeader);
+		
+		if (err1 == err2)
+			{
+			if (err1 == KErrNone)
+				{
+				if (firstHeader->AsUnicode() != secondHeader->AsUnicode())
+					{
+					res |= EDifferentUserDefined;
+					}
+				}
+			}
+		else
+			{
+			res |= EDifferentUserDefined;
+			}
+					
+		localHI =  static_cast<TUint8>(headerNameIndex | TObexInternalHeader::EByteSeq);
+		
+		aObject.HeaderSet().First();
+		obj->HeaderSet().First();
+
+		err1 = aObject.HeaderSet().Find(localHI, *firstHeader);
+		err2 = obj->HeaderSet().Find(localHI, *secondHeader);
+		
+		if (err1 == err2)
+			{
+			if (err1 == KErrNone)
+				{
+				if (firstHeader->AsByteSeq() != secondHeader->AsByteSeq())
+					{
+					res |= EDifferentUserDefined;
+					}
+				}
+			}
+		else
+			{
+			res |= EDifferentUserDefined;
+			}
+
+		localHI =  static_cast<TUint8>(headerNameIndex | TObexInternalHeader::E1Byte);
+		
+		aObject.HeaderSet().First();
+		obj->HeaderSet().First();
+
+		err1 = aObject.HeaderSet().Find(localHI, *firstHeader);
+		err2 = obj->HeaderSet().Find(localHI, *secondHeader);
+		
+		if (err1 == err2)
+			{
+			if (err1 == KErrNone)
+				{
+				if (firstHeader->AsByte() != secondHeader->AsByte())
+					{
+					res |= EDifferentUserDefined;
+					}
+				}
+			}
+		else
+			{
+			res |= EDifferentUserDefined;
+			}
+
+		localHI =  static_cast<TUint8>(headerNameIndex | TObexInternalHeader::E4Byte);
+		
+		aObject.HeaderSet().First();
+		obj->HeaderSet().First();
+
+		err1 = aObject.HeaderSet().Find(localHI, *firstHeader);
+		err2 = obj->HeaderSet().Find(localHI, *secondHeader);
+		
+		if (err1 == err2)
+			{
+			if (err1 == KErrNone)
+				{
+				if (firstHeader->AsFourByte() != secondHeader->AsFourByte())
+					{
+					res |= EDifferentUserDefined;
+					}
+				}
+			}
+		else
+			{
+			res |= EDifferentUserDefined;
+			}
+		}
+
+	aObject.HeaderSet().First();
+	obj->HeaderSet().First();
+	err1 = aObject.HeaderSet().Find(TObexInternalHeader::ECount, *firstHeader);
+	err2 = obj->HeaderSet().Find(TObexInternalHeader::ECount, *secondHeader);
+
+	if (err1 == err2)
+		{
+		if (err1 == KErrNone)
+			{
+			if (firstHeader->AsFourByte() != secondHeader->AsFourByte())
+				{
+				res |= EDifferentCount;
+				}
+			}
+		}
+	else
+		{
+		res |= EDifferentCount;
+		}
+
+	aObject.HeaderSet().First();
+	obj->HeaderSet().First();
+	err1 = aObject.HeaderSet().Find(TObexInternalHeader::ECreatorID, *firstHeader);
+	err2 = obj->HeaderSet().Find(TObexInternalHeader::ECreatorID, *secondHeader);
+
+	if (err1 == err2)
+		{
+		if (err1 == KErrNone)
+			{
+			if (firstHeader->AsFourByte() != secondHeader->AsFourByte())
+				{
+				res |= EDifferentCreatorID;
+				}
+			}
+		}
+	else
+		{
+		res |= EDifferentCreatorID;
+		}
+
+	aObject.HeaderSet().First();
+	obj->HeaderSet().First();
+	err1 = aObject.HeaderSet().Find(TObexInternalHeader::EWanUUID, *firstHeader);
+	err2 = obj->HeaderSet().Find(TObexInternalHeader::EWanUUID, *secondHeader);
+
+	if (err1 == err2)
+		{
+		if (err1 == KErrNone)
+			{
+			if (firstHeader->AsByteSeq() != secondHeader->AsByteSeq())
+				{
+				res |= EDifferentWanUUID;
+				}
+			}
+		}
+	else
+		{
+		res |= EDifferentWanUUID;
+		}
+
+	aObject.HeaderSet().First();
+	obj->HeaderSet().First();
+	err1 = aObject.HeaderSet().Find(TObexInternalHeader::EObjectClass, *firstHeader);
+	err2 = obj->HeaderSet().Find(TObexInternalHeader::EObjectClass, *secondHeader);
+
+	if (err1 == err2)
+		{
+		if (err1 == KErrNone)
+			{
+			if (firstHeader->AsByteSeq() != secondHeader->AsByteSeq())
+				{
+				res |= EDifferentObjectClass;
+				}
+			}
+		}
+	else
+		{
+		res |= EDifferentObjectClass;
+		}
+
+	delete firstHeader;
+	delete secondHeader;
+
+	CleanupStack::PopAndDestroy(2); //obj, buf
+
+	return res;
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/btutils.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,146 @@
+// 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 <es_sock.h>
+#include <ir_sock.h>
+#include <bautils.h>
+#include <usbman.h>
+#include <d32usbc.h>
+#include "btutils.h" 
+#include "btextnotifiers.h"
+
+#define EPOCIDENT _L8("EPOC32 ER5")
+
+
+CRFCOMMServiceFinder* CRFCOMMServiceFinder::NewL(	const TUUID& aServiceClass,
+							const TBTDevAddr& aDevAddr,
+							MRFCOMMServiceSeeker& aSeeker)
+	{
+	CRFCOMMServiceFinder* self= new (ELeave) CRFCOMMServiceFinder(aSeeker);
+	CleanupStack::PushL(self);
+	self->ConstructL(aDevAddr, aServiceClass);
+	CleanupStack::Pop();
+	return (self);
+	}
+
+
+CRFCOMMServiceFinder::~CRFCOMMServiceFinder()
+	{
+	delete iPattern;
+	delete iAgent;
+	}
+
+	
+CRFCOMMServiceFinder::CRFCOMMServiceFinder(MRFCOMMServiceSeeker& aSeeker)
+: iSeeker(aSeeker)
+	{
+
+	}
+
+void CRFCOMMServiceFinder::ConstructL(const TBTDevAddr& aDevAddr, const TUUID& aServiceClass)
+	{
+	iPattern=CSdpSearchPattern::NewL();
+	iPattern->AddL(aServiceClass);
+	iAgent=CSdpAgent::NewL(*this, aDevAddr);
+	iAgent->SetRecordFilterL(*iPattern);
+	}
+
+void CRFCOMMServiceFinder::FindPortL()
+	{
+	iSearchState = ENoUuidFound;	
+	iProfileVersion = -1;	// version is unit16 in the spec - so this is an invalid version	
+							// that will never be returned from a query	
+	iPort=0xFF;	// 0xFF will never be returned from a query, 	
+				// because RFCOMM server channels only go up to 30.
+	iAgent->NextRecordRequestL();
+	}
+
+void CRFCOMMServiceFinder::NextRecordRequestComplete(TInt aError, TSdpServRecordHandle aHandle, TInt /*aTotalRecordsCount*/) 
+	{
+	if (aError == KErrNone)
+		{
+		//We have the record, kick off the attribute request
+		TRAP(aError,AttributeRequestL(aHandle)); 
+		}
+
+	if (aError != KErrNone)
+		{
+		iSeeker.SearchResult(aError, 0, 0);
+		}
+	}
+
+void CRFCOMMServiceFinder::AttributeRequestL(TSdpServRecordHandle aHandle) 	
+	{	
+	CSdpAttrIdMatchList* attrList = CSdpAttrIdMatchList::NewL();	
+	CleanupStack::PushL(attrList);	
+	attrList->AddL(TAttrRange(KSdpAttrIdProtocolDescriptorList)); 	
+	attrList->AddL(TAttrRange(KSdpAttrIdBluetoothProfileDescriptorList)); 	
+
+	iAgent->AttributeRequestL(this, aHandle, *attrList); 	
+
+	CleanupStack::PopAndDestroy(attrList);	
+	}
+
+MSdpElementBuilder* CRFCOMMServiceFinder::BuildUintL(const TDesC8& aUint)
+	{
+	switch (iSearchState)	
+		{	
+	// Extract port number	
+	case EFoundRfcommUuid:	
+		iPort = SdpUtil::GetUint(aUint);
+		break;	
+
+	// Extract version number	
+	case EFoundProfileUuid:	
+		iProfileVersion = SdpUtil::GetUint(aUint);
+		break;	
+		}	
+
+	// Reset search state
+	iSearchState = ENoUuidFound;
+	return this;
+	}
+ 
+MSdpElementBuilder* CRFCOMMServiceFinder::BuildUUIDL(const TUUID& aUUID)
+	{
+	if ((aUUID == TUUID(3)) && (iPort == 0xFF)) 	
+		{	
+		// Found RFCOMM so need to get the port	
+		iSearchState = EFoundRfcommUuid;	
+		}	
+	if ((aUUID == iPattern->At(0)) && (iProfileVersion == -1))  	
+		{	
+		// Found Profile so need to get the version	
+		iSearchState = EFoundProfileUuid;	
+		}
+
+	return this;				
+	}
+
+//The search can be concluded by calling back when AttributeRequestComplete gets called;
+void CRFCOMMServiceFinder::AttributeRequestComplete(TSdpServRecordHandle /*aHandle*/, TInt aError)
+	{
+	// Check if the RFCOMM port was found, send a suitable error code if not	
+	if ((aError == KErrNone) && (iPort == 0xFF))	
+		{	
+		aError = KErrNotFound;	
+		}	
+
+	iSeeker.SearchResult(aError, iPort, iProfileVersion);
+	}
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/btutils.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#ifndef _BTUTILS_H
+#define _BTUTILS_H
+
+#include <es_sock.h>
+#include <e32test.h>
+#include <es_prot.h>
+#include <e32cons.h>
+#include <obex.h>
+#include <btmanclient.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obex/internal/obexinternalconstants.h>
+#include <btsdp.h>
+#include <obexfinalpacketobserver.h>
+
+
+
+class CRFCOMMServiceFinder; 
+
+class MRFCOMMServiceSeeker
+	{
+public:
+	virtual void SearchResult(TInt aError, TUint8 aPort, TInt aProfileVersion)=0;	// user implemented
+	};
+
+
+class CRFCOMMServiceFinder : public CBase, 
+		public MSdpElementBuilder, public MSdpAgentNotifier
+	{
+public:
+	static CRFCOMMServiceFinder* NewL(	const TUUID& aServiceClass,
+							const TBTDevAddr& aDevAddr,
+							MRFCOMMServiceSeeker& aSeeker);
+
+	~CRFCOMMServiceFinder();
+
+	void FindPortL();	//Starts the search
+	//Inherits MSdpElementBuilder and MSdpAgentNotifier interfaces, 
+	//most importantly...
+	MSdpElementBuilder* BuildUintL(const TDesC8& aUint); 
+	MSdpElementBuilder* BuildUUIDL(const TUUID& aUUID);
+	MSdpElementBuilder* BuildDESL() {return this;}
+	MSdpElementBuilder* BuildDEAL() {return this;}
+	MSdpElementBuilder* StartListL() {return this;}
+	MSdpElementBuilder* EndListL() {return this;}
+	// All others are errors, so don’t override the default (leaves)
+	void NextRecordRequestComplete(TInt aError, TSdpServRecordHandle aHandle, TInt aTotalRecordsCount);
+
+	void AttributeRequestResult(TSdpServRecordHandle,TSdpAttributeID,CSdpAttrValue*) {User::Panic(_L("RFCOMMSEEK"), 0);} // Not using this API form
+	void AttributeRequestComplete(TSdpServRecordHandle aHandle, TInt aError);
+private:
+	CRFCOMMServiceFinder(MRFCOMMServiceSeeker& aSeeker);
+	void ConstructL(const TBTDevAddr& aDevAddr, const TUUID& aServiceClass);
+	void AttributeRequestL(TSdpServRecordHandle aHandle);
+
+private:
+	enum TSdpSearchState { ENoUuidFound, EFoundRfcommUuid, EFoundProfileUuid };
+	CSdpAgent* iAgent;
+	CSdpSearchPattern* iPattern;
+	TSdpSearchState iSearchState;
+	TUint8 iPort;
+	TInt iProfileVersion;
+	MRFCOMMServiceSeeker& iSeeker;//initialised from aSeeker in the constructor
+	};
+
+
+
+#endif // _BTUTILS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/clienthandler.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1087 @@
+// 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 <es_sock.h>
+#include <ir_sock.h>
+#include <bautils.h>
+#include <usbman.h>
+#include <d32usbc.h>
+#include <e32keys.h>
+#include "clienthandler.h"
+#include "TOBEXCON.H"
+#include "btextnotifiers.h"
+#include "obexconstantsinternal.h"
+
+#define EPOCIDENT _L8("EPOC32 ER5")
+
+
+
+CObexClientHandler::CObexClientHandler(CActiveConsole* aParent)
+    : CActive(EPriorityNormal), iParent(aParent), iState(EIdle)
+    {
+    }
+
+CObexClientHandler* CObexClientHandler::NewL(CActiveConsole* aParent, TTransport aTransport)
+    {
+    CObexClientHandler* self = new (ELeave) CObexClientHandler(aParent);
+
+    CleanupStack::PushL (self);
+    self->ConstructL(aTransport);
+    CActiveScheduler::Add (self);
+    CleanupStack::Pop ();
+    return (self);
+    }
+
+void CObexClientHandler::ConstructL(TTransport aTransport)
+    {
+	if (aTransport == EBluetooth)
+		{
+		// Check if an address has been provided on the cmd line.
+		TBuf<20> cmdline;
+		User::CommandLine(cmdline);
+
+		TInt ret = iDevAddr.SetReadable(cmdline);
+		if (ret < KErrNone)
+			{
+			iParent->Console()->Printf(_L("\nNo address found on command line\n"));
+
+			//Ask user which device address we should connect to...
+			RNotifier notify;
+			User::LeaveIfError(notify.Connect());
+			TBTDeviceSelectionParamsPckg pckg;
+			TBTDeviceResponseParamsPckg resPckg;
+			TRequestStatus stat;
+			notify.StartNotifierAndGetResponse(stat, KDeviceSelectionNotifierUid, pckg, resPckg);
+			User::WaitForRequest(stat);
+			notify.CancelNotifier(KDeviceSelectionNotifierUid);
+			notify.Close();
+			User::LeaveIfError(stat.Int()); 
+
+			iDevAddr = resPckg().BDAddr();
+			}
+			
+		// Find UUID to search for
+		iParent->Console()->Printf(_L("\nPress F: FTP, Any other key: OPP"));
+		TChar code (iParent->Console()->Getch());
+		TUUID searchUUID;
+		switch(code)
+			{
+		case 'f': case 'F':
+			searchUUID = TUUID(0x1106); //FTP
+			break;
+		case 'o': case 'O':
+		default:
+			searchUUID = TUUID(0x1105); //OPP
+			}
+
+		//start the SDP Query
+		delete iSdpServiceFinder;
+		iSdpServiceFinder=0;
+		iSdpServiceFinder = CRFCOMMServiceFinder::NewL(searchUUID, iDevAddr, *this);
+		iSdpServiceFinder->FindPortL();
+		iParent->Console()->Printf(_L("\nSearching for SDP service....\n"));
+
+		// For bluetooth the client is created in SearchResult().
+		}
+	else if (aTransport == EIrda)
+		{
+		TObexIrProtocolInfo aInfo;
+		aInfo.iTransport= KObexIrTTPProtocolV2;
+		aInfo.iClassName     = _L8("OBEX");					//same for unicode and narrow builds
+		aInfo.iAttributeName = _L8("IrDA:TinyTP:LsapSel");
+		aInfo.iDiscoverySlots = iParent->iDiscoverySlots;
+ 		aInfo.iDiscoveryAttempts = iParent->iDiscoveryAttempts;	
+		//now create the obex client...
+	    iClient = CObexClient::NewL (aInfo);
+	    iClient->SetFinalPacketObserver(this);
+#ifdef ERROR_RESOLUTION_EXTENSION
+		iClientErrorResolver = CObexClientErrorResolver::NewL(*iClient);
+#endif // ERROR_RESOLUTION_EXTENSION
+		}
+	else if (aTransport == EUsb)
+		{
+		TObexUsbProtocolInfo aInfo;
+		aInfo.iTransport = KObexUsbProtocol;
+		aInfo.iInterfaceStringDescriptor = _L("TOBEX Client Interface");
+		//now create the obex client...
+	    iClient = CObexClient::NewL (aInfo);
+	    iClient->SetFinalPacketObserver(this);
+#ifdef ERROR_RESOLUTION_EXTENSION
+		iClientErrorResolver = CObexClientErrorResolver::NewL(*iClient);
+#endif // ERROR_RESOLUTION_EXTENSION
+		}
+	else if (aTransport == EWin32Usb)
+		{
+		TObexUsbProtocolInfo aInfo;
+		aInfo.iTransport = _L("Win32Usb");
+		//now create the obex client...
+	    iClient = CObexClient::NewL (aInfo);
+	    iClient->SetFinalPacketObserver(this);
+#ifdef ERROR_RESOLUTION_EXTENSION
+		iClientErrorResolver = CObexClientErrorResolver::NewL(*iClient);
+#endif // ERROR_RESOLUTION_EXTENSION
+		}
+	else
+		{
+		User::Invariant();
+		}
+
+#ifdef EMPTY_HEADERS_TEST
+	iObexEmptyHeaderTest = CObexEmptyHeaderTest::NewL();
+#endif //EMPTY_HEADERS_TEST
+    iFileObject = CObexFileObject::NewL();
+    iObjectBuffer = CBufFlat::NewL(8);
+    iObject = CObexBufObject::NewL(iObjectBuffer);
+	iObexName = _L("");
+	iGetType = _L("text/x-vcard");
+
+	iFilename1 = _L("Contacts.vcf"); 
+	iFilename2 = _L("Contacts2.vcf");
+	iFilename3 = _L("Contacts3.vcf");
+
+	iChallengePassword = _L("SecretPassword");
+	iResponsePassword = _L("SecretPassword");
+
+	iTargetHeaderObject = CObexNullObject::NewL();
+	iTargetHeaderObject->SetTargetL(KRefTarget);
+	iTargetHeaderObject->SetHeaderMask(KObexHdrTarget);
+    }
+
+
+void CObexClientHandler::SearchResult(TInt aError, TUint8 aPort, TInt aProfileVersion)
+	{
+	if (aError != KErrNone)
+		{
+		iParent->Console()->Printf(_L("\r\n Could not find SDP service in remote device : error %d \r\n"),aError);	
+		iParent->ClientErrored();
+		return;
+		}
+
+	if (aProfileVersion >= 0)	
+		{	
+		iParent->Console()->Printf(_L("\nProfile Version 0x%04x\n"), aProfileVersion);	
+		}	
+	else	
+		{	
+		iParent->Console()->Printf(_L("\nProfile Version not supplied\n"));	
+		}	
+	iParent->Console()->Printf(_L("RFCOMM Port %d\n"), aPort);	
+
+	TObexBluetoothProtocolInfo aInfo;
+	aInfo.iAddr.SetBTAddr(iDevAddr);
+	aInfo.iAddr.SetPort(aPort); 
+	aInfo.iTransport     = KObexRfcommProtocol;
+
+	TObexProtocolPolicy policy;
+	policy.SetReceiveMtu(iParent->iRecvMTU);
+	policy.SetTransmitMtu(iParent->iTransmitMTU);
+
+	//now create the obex client...
+	TRAP(aError, iClient = CObexClient::NewL(aInfo, policy));
+	if (aError)
+		{
+		iParent->Console()->Printf(_L("\r\n Could not create client! : error %d \r\n"),aError);
+		iParent->ClientErrored();
+		return;
+		}
+	iClient->SetFinalPacketObserver(this);
+#ifdef ERROR_RESOLUTION_EXTENSION
+	TRAP(aError,iClientErrorResolver = CObexClientErrorResolver::NewL(*iClient));
+	if (aError != KErrNone)
+		{
+		iParent->Console()->Printf(_L("\r\n Could not create client error resolver! : error %d \r\n"),aError);
+		iParent->ClientErrored();
+		return;
+		}
+#endif // ERROR_RESOLUTION_EXTENSION
+	iParent->Console()->Printf(_L("\nSDP search complete OK!\n"));
+	iParent->iTestMode = E_Client;
+
+	iParent->Cancel(); // cancel request for key
+	iParent->RequestCharacter(); // re-request, to re-display menu
+	}
+
+void CObexClientHandler::SetCurrentTestNumber()
+{
+	iCurrentTestNumber = 1;
+}
+
+void CObexClientHandler::ResetCurrentTestNumber()
+{
+	iCurrentTestNumber = 0;
+}
+
+void CObexClientHandler::MofpoFinalPacketStarted()
+	{
+	iParent->Console()->Printf(_L("\nFinal packet started\n"));
+	}
+
+void CObexClientHandler::MofpoFinalPacketFinished()
+	{
+	iParent->Console()->Printf(_L("\nFinal packet finished\n"));
+	}
+
+CObexClientHandler::~CObexClientHandler()
+    {
+    Cancel();
+#ifdef EMPTY_HEADERS_TEST    
+    delete iObexEmptyHeaderTest;
+#endif //EMPTY_HEADERS_TEST
+    delete iObject;
+	delete iFileObject;
+    delete iClient;
+#ifdef ERROR_RESOLUTION_EXTENSION
+	delete iClientErrorResolver;
+#endif // ERROR_RESOLUTION_EXTENSION
+
+	delete iObjectBuffer;
+	delete iTargetHeaderObject;
+	delete iSdpServiceFinder;
+    }
+
+void CObexClientHandler::Abort()
+    {
+    if((iState != EPutting)&&(iState != EGetting))
+		iParent->Console()->Printf(_L("\r\n NOTE: Wrong Obex state for issuing abort\r\n"));
+	iClient->Abort();
+    }
+
+
+
+void CObexClientHandler::Connect()
+    {
+    if(IsActive())
+		{
+		iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+   
+    TObexConnectInfo iLocalInfo = iClient->LocalInfo();
+    iLocalInfo.iWho = _L8("");
+    iLocalInfo.iWho = EPOCIDENT;  
+    iLocalInfo.iWho.Append(_L8(" EikIrOBEXFile "));
+
+    iClient->Connect(iStatus);
+    SetActive();
+    iState = EConnecting;
+    }
+
+void CObexClientHandler::RemoteAddress()
+	{
+	TSockAddr aAddr;
+	iClient->RemoteAddr( aAddr);
+	TBTDevAddr addr = static_cast <TBTSockAddr>(aAddr).BTAddr();
+	
+	TChar aChar;
+
+	iParent->Console()->Printf(_L("Remote Address = "));
+	for(TInt count = 0; count < addr.Des().Length(); count++) 
+		{
+		aChar = (addr.Des()[count] & 0xf0)>>4;
+		if (aChar <= 9)
+			aChar += 0x30;
+		else if ((aChar >= 0x0a) && (aChar <= 0x0f))
+			aChar += 'A' - 0x0a;
+		iParent->Console()->Printf(_L("%C"),(TUint)aChar);
+
+		aChar = (addr.Des()[count] & 0x0f);
+		if (aChar <= 9)
+			aChar += 0x30;
+		else if ((aChar >= 0x0a) && (aChar <= 0x0f))
+			aChar += 'A' - 0x0a;
+		iParent->Console()->Printf(_L("%C"),(TUint)aChar);
+		}
+    iParent->Console()->Printf(_L("\r\n"));
+
+	}
+
+void CObexClientHandler::Disconnect()
+    {
+    if(IsActive())
+		{
+		iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+    
+	iClient->Disconnect(iStatus);
+    SetActive();
+    iState = EDisconnecting;
+    }
+
+void CObexClientHandler::GetByNameL()
+    {
+    if(IsActive())
+		{
+		iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+
+    iObject->Reset ();
+	SetName(iObexName);
+    iObject->SetNameL (iObexName);
+    iClient->Get(*iObject, iStatus);
+    SetActive();
+    iState = EGetting;
+    }
+
+
+void CObexClientHandler::GetByTypeL()
+    {
+    if(IsActive())
+		{
+		iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+
+    iObject->Reset ();
+	TBuf8<300> buf;
+	buf.Copy(iGetType);
+	buf.Append(0);
+	iObject->SetTypeL (buf);
+    iClient->Get(*iObject, iStatus);
+    SetActive();
+    iState = EGetting;
+
+    }
+
+void CObexClientHandler::Put(TDes& aFilename)
+    {
+    if(IsActive())
+		{
+		iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+
+	TInt err;
+
+	err = SetUpObject (aFilename);
+
+	if( err != KErrNone)
+		{
+		iParent->Console()->Printf(_L("\r\n Couldnt set up object : error %d \r\n"),err);
+		return;
+		}
+
+	// Start the timer.
+	iStartTime.HomeTime();
+	
+	iClient->Put(*iFileObject,iStatus);
+	SetActive();
+	iState = EPutting;
+	}
+
+void CObexClientHandler::GetReferenceL(TInt aReferenceId)
+	{
+    if(IsActive())
+		{
+		iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+	iParent->iRefHandler->CreateReferenceL(*iObject, *iObjectBuffer, aReferenceId, iParent->iTransport);
+	iClient->Get(*iObject, iStatus);
+    SetActive();
+    iState = EGettingReference;
+	}
+
+
+//multiple HTTP packets sent in a single Obex packet
+void CObexClientHandler::HTTPTest1L() //tam
+	{
+    if(IsActive())
+		{
+		iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+
+    iObject->Reset ();
+	SetName(iObexName);
+    iObject->SetNameL (iObexName);
+
+	//now add in the HTTP headers
+
+	iObject->AddHttpL(_L8("Test 1 HTTP header 1\r\n"));
+	iObject->AddHttpL(_L8("Test 1 HTTP header 2\r\n"));
+	iObject->AddHttpL(_L8("Test 1 HTTP header 3\r\n"));
+	iObject->AddHttpL(_L8("Test 1 HTTP header 4\r\n"));
+	iObject->AddHttpL(_L8("Test 1 HTTP header 5\r\n"));
+	iObject->AddHttpL(_L8("Test 1 HTTP header 6\r\n"));
+	iObject->AddHttpL(_L8("Test 1 HTTP header 7\r\n"));
+	iObject->AddHttpL(_L8("Test 1 HTTP header 8\r\n"));
+	iObject->AddHttpL(_L8("Test 1 HTTP header 9\r\n"));
+	iObject->AddHttpL(_L8("Test 1 HTTP header 10\r\n"));
+	
+    
+	iClient->Get(*iObject, iStatus);
+    SetActive();
+    iState = EGetting;
+	}
+
+//multiple HHTP packets sent in multiple Obex packets
+void CObexClientHandler::HTTPTest2L()
+	{
+
+
+	TBuf8<520> localBuf;
+
+    if(IsActive())
+		{
+		iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+
+
+    iObject->Reset ();
+	SetName(iObexName);
+    iObject->SetNameL (iObexName);
+
+	for ( TUint x = 0; x < 10; x++ ) //should be 10*512 HTTP packets,
+		{							//		which is in excess of the 4K Tranport size
+		localBuf = _L8("Test 2 HTTP Header");
+		localBuf.AppendFill(TUint(x + '1'), 500);
+
+		iObject->AddHttpL(localBuf);
+		}
+	
+	iClient->Get(*iObject, iStatus);
+    SetActive();
+    iState = EGetting;
+	}
+
+//single HHTP packet too large for an Obex packet will not go
+void CObexClientHandler::HTTPTest3L()
+	{
+	HBufC8* localBuf = HBufC8::NewL(5020);
+
+
+	TPtr8 ptr = localBuf->Des();
+
+    if(IsActive())
+		{
+		iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+
+    iObject->Reset ();
+	SetName(iObexName);
+    iObject->SetNameL (iObexName);
+    
+
+	ptr = _L8("Test 3 HTTP Header ");
+	ptr.AppendFill(TUint('A'), 5000);
+
+	iObject->AddHttpL(ptr);
+
+	
+	iClient->Get(*iObject, iStatus);
+    SetActive();
+    iState = EGetting;
+	}
+
+//a single (too) large HTTP packet, with multiple HTTP packets
+//large one ignored, multiple smaller should all go
+void CObexClientHandler::HTTPTest4L()
+	{
+	HBufC8* localBuf = HBufC8::NewL(5020);
+
+	TPtr8 ptr = localBuf->Des();
+    if(IsActive())
+		{
+		iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+
+    iObject->Reset ();
+	SetName(iObexName);
+    iObject->SetNameL (iObexName);
+
+
+	ptr = _L8("Test 4 HTTP header 1");
+	iObject->AddHttpL(ptr);
+
+    //now for the excessively large header
+	ptr = _L8("Test 4 HTTP header 2");
+	ptr.AppendFill(TUint('B'), 5000);
+	iObject->AddHttpL(ptr);
+
+	//and a reasonable header again
+
+	ptr = _L8("Test 4 HTTP header 3");
+	iObject->AddHttpL(ptr);
+
+	iClient->Get(*iObject, iStatus);
+    SetActive();
+    iState = EGetting;
+	}
+
+
+void CObexClientHandler::AppParamsTestL()
+	{
+    if(IsActive())
+		{
+		iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+
+    iObject->Reset ();
+	SetName(iObexName);
+    iObject->SetNameL (iObexName);
+
+	TBuf8<40> param;
+	param.Copy(_L("\x04"));
+	param.Append(_L("\x03"));
+	param.Append(_L("App params 123"));
+	iObject->SetAppParamL(param);
+
+
+	iClient->Get(*iObject, iStatus);
+    SetActive();
+    iState = EGetting;
+	
+	
+	}
+
+void CObexClientHandler::ChangeAuthenticationChallengeHeaders(TChar aChar)
+	{
+	switch(aChar)
+		{
+	case '1':
+		// Suppress 'Options'
+		iClient->SuppressAuthenticationHeaderElements(CObex::EObexSuppressChallengeOptionsAuthElement);
+		break;
+	case '2':
+		// Suppress 'Realm'
+		iClient->SuppressAuthenticationHeaderElements(CObex::EObexSuppressRealmAuthElement);
+		break;
+	case '3':
+		// Supress both
+		iClient->SuppressAuthenticationHeaderElements(CObex::EObexSuppressAllAuthElements);
+		break;
+	case '4':
+		// Reset to default
+		iClient->SuppressAuthenticationHeaderElements(CObex::EObexNoSuppressedAuthElements);
+		break;
+	case '5':
+		// Invalid enum (magic number)
+		iClient->SuppressAuthenticationHeaderElements(static_cast<CObex::TObexSuppressedAuthElements>(0x08));
+		break;
+	default:
+		break;
+		}
+	}
+
+void CObexClientHandler::PutReferenceL(TInt aReferenceId)
+	{
+    if(IsActive())
+		{
+		iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+
+	iParent->iRefHandler->CreateReferenceL(*iObject, *iObjectBuffer, aReferenceId, iParent->iTransport);
+	iClient->Put(*iObject,iStatus);
+	SetActive();
+	iState = EPuttingReference;
+	}
+
+TInt CObexClientHandler::SetUpObject(TDes& filename)
+    {
+//	iFileObject->SetDataFileL(KNullDesC);
+	TRAPD (err, iFileObject->InitFromFileL (filename));
+
+	if (err != KErrNone)
+		{
+		RFs fs;
+		RFile f;
+		if ((fs.Connect () != KErrNone) || 
+			(f.Create (fs, filename, EFileShareExclusive | EFileWrite) != KErrNone))
+			iParent->Console()->Printf(_L("\r\nError reading '%s'.\r\nI tried to create this file for you, but failed to do that too. Sorry.\r\n\r\n"), filename.PtrZ ());
+		else
+			{
+			f.Write (_L8("Test file for sending from EPOC\r\n\r\nLooks like obex is sending OK!!\r\n"));
+			f.Close ();
+			iParent->Console()->Printf(_L("\r\nFile '%s' did not exist, so I've created one.\r\nPlease try again.\r\n\r\n"), filename.PtrZ ());
+			}
+		fs.Close ();
+		}
+	
+	//iFileObject->SetNameL(iObexName);
+
+	return err;
+    }
+
+
+void CObexClientHandler::RunL ()
+    {
+    if (iStatus != KErrNone)
+		{// Handle error
+		}
+
+    switch (iState)
+		{
+	case EConnecting:
+		iParent->Console()->Printf(_L("\r\nConnect completed with error code: %d\r\n\r\n"),iStatus.Int());
+		iState = EConnected;//may not be connected actually
+		break;
+		
+	case EPutting:
+		{
+		TTime finishTime;
+		finishTime.HomeTime();
+		TTimeIntervalMicroSeconds diff = finishTime.MicroSecondsFrom(iStartTime);	
+
+		iParent->Console()->Printf(_L("\nObject Sent in %d"), diff.Int64());
+		
+		iState = EConnected;
+		iParent->Console()->Printf(_L("\r\nPut completed with error code: %d\r\n\r\n"),iStatus.Int());
+		}
+		break;
+		
+	case EGetting:
+		iState = EConnected;
+		iParent->Console()->Printf(_L("\r\nGet completed with error code: %d\r\n\r\n"),iStatus.Int());
+		DisplayObjectL();
+		SaveObject();
+		iObject->Reset ();
+		break;
+
+	case EGettingReference:
+		{
+		iState = EConnected;
+		iParent->Console()->Printf(_L("\r\nGet completed with error code: %d\r\n\r\n"),iStatus.Int());
+		if(iStatus == KErrNone)
+			{
+			DisplayObjectL();
+			TInt objComp = iParent->iRefHandler->CompareObjectToReferenceL(*iObject, *iObjectBuffer, iParent->iTransport);
+			ASSERT(objComp == 0); // Make sure what we sent (the ref obj) matches what we got
+			(void) objComp; // avoid build warning
+	//		iParent->Console()->Printf(_L("\r\nReference Object Comparison Result: %d\r\n\r\n"), objComp);
+			iParent->Console()->Printf(_L("\r\nReference Object Comparison OK\r\n\r\n"));
+			}
+		else
+			{
+			iParent->Console()->Printf(_L("GET REFERENCE OBJECT FAILED\n"));
+			}
+		iObject->Reset();
+
+		if (iCurrentTestNumber < KMaxNumOfTests)
+			GetReferenceL(++iCurrentTestNumber);
+		else
+			{
+			iParent->Console()->Printf(_L("All GET tests completed\n"));
+			ResetCurrentTestNumber();
+			}
+		break;
+		}
+	case EPuttingReference:
+		iState = EConnected;
+		iParent->Console()->Printf(_L("\r\nReference Put completed with error code: %d\r\n\r\n"),iStatus.Int());
+		if(iStatus != KErrNone)
+			{
+			iParent->Console()->Printf(_L("PUT REFERENCE OBJECT FAILED\n"));
+			}
+		if (iCurrentTestNumber < KMaxNumOfTests)
+			PutReferenceL(++iCurrentTestNumber);
+		else
+			{
+			iParent->Console()->Printf(_L("All PUT tests completed\n"));
+			ResetCurrentTestNumber();
+			}
+
+		break;
+
+	case EDisconnecting:
+		iParent->Console()->Printf(_L("\r\nDisconnect completed with error code: %d\r\n\r\n"),iStatus.Int());
+		iState = EIdle;
+		break;
+	case ESettingPath:
+		iParent->Console()->Printf(_L("\r\nSetPath completed with error code: %d\r\n\r\n"),iStatus.Int());
+		iState = EConnected;
+		break;
+	default:
+		iParent->Console()->Printf(_L("\r\nTest Code is in an incorrect state: %d\r\n\r\n"),iState);
+		}
+    }
+
+void CObexClientHandler::DoCancel()
+    {
+    delete iClient;
+    iClient = NULL;
+#ifdef ERROR_RESOLUTION_EXTENSION
+    delete iClientErrorResolver;
+    iClientErrorResolver = NULL;
+#endif // ERROR_RESOLUTION_EXTENSION
+    }
+
+void CObexClientHandler::DisplayObjectL()
+    {
+    // Display Contents of CBufFlat data on current console
+	// This size is wrong if we abort, due to size being pre-allocated! DOH!
+
+	iParent->Console()->Printf(_L("Size of received object = %d\n"),iObjectBuffer->Size());
+
+	TInt err = KErrNone;
+	if (iParent->DisplayHeaders())
+	{
+		CObexHeader* header = CObexHeader::NewL();
+		CleanupStack::PushL(header);
+
+		iObject->HeaderSet().SetMask(NULL);
+		iObject->HeaderSet().First();
+
+		while (err == KErrNone)
+			{
+			err = iObject->HeaderSet().This(header);
+
+			switch (header->Type())
+			{
+				case (0x00): //Unicode
+					{
+					HBufC16* buf = NULL;
+					TRAPD(err, buf = HBufC16::NewL((header->AsUnicode()).Size()));
+					if (err)
+						{
+						iParent->iConsole->Printf(_L("Unicode Header (0x%x)- Error allocating memory to display\r\n"), header->HI());
+						}
+					else
+						{
+						TPtr16 type(buf->Des());
+						type.Copy(header->AsUnicode());
+
+						iParent->iConsole->Printf(_L("Unicode Header (0x%x) =  : \"%S\"\r\n"), header->HI(), &type);
+						}
+					delete buf;
+					break;
+					}
+				case (0x01): // ByteSeq
+					{
+					HBufC16* buf = NULL;
+					TRAPD(err, buf = HBufC16::NewL((header->AsByteSeq()).Size()));
+					if (err)
+						{
+						iParent->iConsole->Printf(_L("ByteSeq Header (0x%x)- Error allocating memory to display\r\n"), header->HI());
+						}
+					else
+						{
+						TPtr16 type(buf->Des());
+						type.Copy(header->AsByteSeq());
+
+						iParent->iConsole->Printf(_L("ByteSeq Header (0x%x) =  : \"%S\"\r\n"), header->HI(), &type);
+						}
+					delete buf;
+					break;
+					}
+				case (0x02): // Byte
+					{
+					iParent->iConsole->Printf(_L("Byte Header (0x%x) =  : 0x%x\r\n"), header->HI(), header->AsByte());
+					break;
+					}
+				case (0x03): //FourByte
+					{
+					iParent->iConsole->Printf(_L("FourByte Header (0x%x) =  : 0x%x\r\n"), header->HI(), header->AsFourByte());
+					break;
+					}
+				default : {break;}
+			}
+			
+			err = iObject->HeaderSet().Next();
+			}
+		
+		CleanupStack::Pop(header);
+		delete header;
+	}		
+
+	TDateTime dt = iObject->Time().DateTime();
+	iParent->Console()->Printf(_L("\r\nTimestamp: %d/%d/%d, %d:%d:%d\r\n\r\n"),
+				   dt.Day()+1, dt.Month()+1, dt.Year(), dt.Hour(), dt.Minute(), dt.Second());
+
+    TBuf8<1024> tempBuffer;
+//	iObjectBuffer->Read(0, tempBuffer, iObjectBuffer->Size());
+	iObjectBuffer->Read(0, tempBuffer, tempBuffer.MaxSize() < iObjectBuffer->Size() ? tempBuffer.MaxSize() : iObjectBuffer->Size());
+	// Printf fails with Descriptor bigger than X hundred bytes so write byte at a time
+	for(TInt count = 0; count < tempBuffer.Size(); count++) 
+		{
+		iParent->Console()->Printf(_L("%C"),tempBuffer[count]);
+		}
+    }
+
+void CObexClientHandler::SaveObject()
+	{
+	
+	TFileName name;	
+	TParse parser;
+	TBool bIsFullPath = EFalse;
+		
+	_LIT(KDrive, "");
+	TBufC<10> drive(KDrive);
+	
+	TPtr pDrive(drive.Des());
+	
+	TInt ret = parser.Set(iObject->Name() ,0,0);  
+	 
+	if(KErrNone == ret)
+		{
+		pDrive = parser.Drive();
+
+		if(pDrive.Length() != 0) // if == 0, relative path
+			{
+			bIsFullPath = ETrue;			
+			} 		
+		}
+		// the case ret != KErrNone is kept for legacy purpose, TODO cope with return codes
+		
+	if(!bIsFullPath)
+		{
+		name = iParent->iInboxRoot;
+		}			
+
+	name.Append(iObject->Name());
+	
+	TInt err = iObject->WriteToFile(name);
+	if (err  == KErrAlreadyExists)
+		{
+		iParent->Console()->Printf(_L("\r\nWrite failed, File Already Exists\n"));
+		}
+	} 
+	
+
+void CObexClientHandler::SetPath()
+	{
+    if(IsActive())
+		{
+		iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+
+	CObex::TSetPathInfo info;
+	iParent->Console()->Printf(_L("Please enter path name ('..' = parent, '!' = Create, ' ' = empty name):\n"));
+	info.iNamePresent = ETrue;
+	SetName(info.iName);
+	info.iFlags |= 2; // Set "Don't Create" flag as default.
+	
+	// Parent
+	if (info.iName.Length() >= 2 && info.iName[0] == '.' && info.iName[1] == '.')
+		{
+		info.iName.Delete(0, 2);
+		info.iFlags |= 1;
+		}
+	// Create
+	if (info.iName.Length() >= 1 && info.iName[0] == '!')
+		{
+		info.iName.Delete(0, 1);
+		info.iFlags &= ~(2); // Clear the "Don't Create" bit
+		}
+	// Empty Name
+	if (info.iName.Length() >= 1 && info.iName[0] == ' ')
+		{
+		info.iName.Delete(0, 1);
+		}
+	else if (info.iName.Length() <= 0)
+		info.iNamePresent = EFalse;
+    iClient->SetPath(info,iStatus);
+    SetActive();
+    iState = ESettingPath;
+	}
+
+void CObexClientHandler::SetObexName()
+	{
+	SetName(iObexName);
+	}
+
+void CObexClientHandler::SetType()
+	{
+	iParent->Console()->Printf(_L("\nEnter Mime type, or 1 for text/x-vcard, 2 for x-obex/folder-listing"));
+	SetName(iGetType);
+	if (iGetType == _L("1"))
+		iGetType = _L("text/x-vcard");
+	else if (iGetType == _L("2"))
+		iGetType = _L("x-obex/folder-listing");
+	}
+
+
+void CObexClientHandler::SetName(TDes& aName)
+    {
+	TBuf<64> oldName;
+	oldName = aName;
+
+	TKeyCode aCode;
+	TBuf<1> aChar;
+	iParent->Console()->Printf(_L("\nEnter a name: %S"),&aName);
+	FOREVER
+		{
+		aCode = iParent->Console()->Getch();
+		aChar.SetLength(0);
+		aChar.Append(aCode);
+
+		iParent->Console()->Printf(_L("%S"),&aChar);
+	
+		// If <CR> finish editing string
+		if (aCode == EKeyEnter)
+			break;
+		
+		// if <BS> remove last character
+		if ((aCode == EKeyBackspace)&&(aName.Length() != 0))
+			aName.SetLength((aName.Length()-1));
+		else
+			aName.Append(aCode);
+		}
+	iParent->Console()->Printf(_L("\n"));
+//	if (aName.Length()>0)
+//		iParent->Console()->Printf( _L("\n name size = %d\n"),aName.Length());
+//	else
+//		{
+//		iParent->Console()->Printf(_L("\nERROR: name of length zero, name unchanged!\n"),aName.Length());
+//		aName = oldName;
+//		}
+
+    }
+
+void CObexClientHandler::ConnectWithAuthenticationL()
+	{
+    if(IsActive())
+		{
+		iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+    
+    iClient->ConnectL(iChallengePassword, iStatus);
+    SetActive();
+    iState = EConnecting;
+	}
+
+void CObexClientHandler::ConnectWithTarget()
+	{
+	if(IsActive())
+		{
+		iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+	iClient->Connect(*iTargetHeaderObject, iStatus);
+	SetActive();
+	iState = EConnecting;
+	}
+
+void CObexClientHandler::ConnectWithAuthenticationAndTargetL()
+	{
+	if(IsActive())
+		{
+		iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+	iClient->ConnectL(*iTargetHeaderObject, iChallengePassword, iStatus);
+	SetActive();
+	iState = EConnecting;
+	}
+
+
+void CObexClientHandler::EnablePassword()
+	{
+	iClient->SetCallBack(*this);
+	}
+
+void CObexClientHandler::ChangeChallengePassword()
+	{
+	iParent->SetPassword(iChallengePassword);
+	}
+	
+void CObexClientHandler::SetCommandTimeout()
+	{
+	TUint timeout = 0;
+	if (iParent->SetNumber(timeout))
+		{
+		const TTimeIntervalMicroSeconds32 temp = timeout;
+		iClient->CObexClient::SetCommandTimeOut(temp);
+		iParent->Console()->Printf(_L("\r\nCommand Sucessful\r\n"));
+		}
+	}
+
+void CObexClientHandler::ChangeResponsePassword()
+	{
+	iParent->Cancel();
+	iParent->SetPassword(iResponsePassword);
+	iParent->RequestCharacter();
+	}
+
+void CObexClientHandler::GetUserPasswordL(const TDesC& aUserID)
+	{
+	iParent->Console()->Printf(_L("\r\nClient has been challenged by %S"), &aUserID);
+	ChangeResponsePassword(); //get the password from user
+//	iParent->Console()->Printf(_L("\r\nUser Password requested for %S"), &aUserID);
+	iClient->UserPasswordL(iResponsePassword); 
+	}
+
+#ifdef ERROR_RESOLUTION_EXTENSION
+void CObexClientHandler::LastError()
+	{
+	if (iClientErrorResolver == NULL)
+		{
+		iParent->Console()->Printf(_L("Client not started\r\n"));
+		}
+	else
+		{
+		switch (iClientErrorResolver->LastError())
+			{
+			case EObexNoExtendedError:
+				{
+				iParent->Console()->Printf(_L("No extended error\r\n"));
+				}
+				break;
+			case EObexRequestAccepted:
+				{
+				iParent->Console()->Printf(_L("Request accepted\r\n"));
+				}
+				break;
+			case EObexRequestNotAccepted:
+				{
+				iParent->Console()->Printf(_L("Request not accepted\r\n"));
+				}
+				break;
+			case EObexRequestTimeout:
+				{
+				iParent->Console()->Printf(_L("Request timeout\r\n"));
+				}
+				break;
+			case EObexRequestLocalInterruption:
+				{
+				iParent->Console()->Printf(_L("Request local interruption\r\n"));
+				}
+				break;
+			case EObexRequestLinkInterruption:
+				{
+				iParent->Console()->Printf(_L("Request link interruption\r\n"));
+				}
+				break;
+			default:
+				{
+				iParent->Console()->Printf(_L("Last Error value returned from client not recognised\r\n"));
+				}
+			}
+		}
+	}
+#endif // ERROR_RESOLUTION_EXTENSION
+
+#ifdef EMPTY_HEADERS_TEST
+void CObexClientHandler::EmptyHeaderTestL(TPtrC aName, TPtrC8 aType, TPtrC aDesc, TPtrC8 aTarget, TPtrC8 aAppParam)
+	{
+	if(IsActive())
+		{
+		iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+		return;
+		}
+		iObexEmptyHeaderTest->SetHeadersL(aName, aType, aDesc, aTarget, aAppParam);
+		iClient->Put(*(iObexEmptyHeaderTest->ObexObject()),iStatus);
+		SetActive();
+		iState = EPutting;
+	}
+#endif //EMPTY_HEADERS_TEST
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/clienthandler.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,156 @@
+// 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 _CLIENTHANDLER_H
+#define _CLIENTHANDLER_H
+
+#include <es_sock.h>
+#include <e32test.h>
+#include <es_prot.h>
+#include <e32cons.h>
+#include <obex.h>
+#include <btmanclient.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obex/internal/obexinternalconstants.h>
+#include <btsdp.h>
+#include <obexfinalpacketobserver.h>
+
+#ifdef ERROR_RESOLUTION_EXTENSION
+#include <obex/extensionapis/obexclienterrorresolver.h>
+#endif // ERROR_RESOLUTION_EXTENSION
+
+#ifdef EMPTY_HEADERS_TEST
+#include "emptyheaderstest.h"
+#endif //EMPTY_HEADERS_TEST
+
+#include "btutils.h"
+#include "constants.h"
+
+
+class CActiveConsole;
+
+class CObexClientHandler : public CActive, public MObexAuthChallengeHandler,
+							private MRFCOMMServiceSeeker,
+							public MObexFinalPacketObserver
+//-----------------------------------------------------------
+	{
+public:
+	// Construction
+	CObexClientHandler(CActiveConsole* aParent);
+	static CObexClientHandler* NewL(CActiveConsole* aParent, TTransport aTransport);
+	void ConstructL(TTransport aTransport);
+
+	// Destruction
+	~CObexClientHandler();
+
+	void SetMode(TUint mode);
+
+	void Abort();
+	void Connect();
+	void Disconnect();
+	void GetByNameL();
+	void GetByTypeL();
+	void Put(TDes& filename);
+	void SetName(TDes& aName);
+	void SetObexName();
+	void SetPath();
+	void SetType();
+	void GetReferenceL(TInt aReferenceId);
+	void PutReferenceL(TInt aReferenceId);
+	void ChangeAuthenticationChallengeHeaders(TChar aChar);
+
+	void ConnectWithAuthenticationL();
+	void ConnectWithTarget();
+	void ConnectWithAuthenticationAndTargetL();
+	void EnablePassword();
+	void ChangeChallengePassword();
+	void SetCommandTimeout();
+	void ChangeResponsePassword();
+	void RemoteAddress();
+	void GetUserPasswordL(const TDesC& aUserID);
+	void SearchResult(TInt aError, TUint8 aPort, TInt aProfileVersion);
+	void HTTPTest1L();
+	void HTTPTest2L();
+	void HTTPTest3L();
+	void HTTPTest4L();
+	void AppParamsTestL();
+	void SetCurrentTestNumber();
+	void ResetCurrentTestNumber();
+	
+	void MofpoFinalPacketStarted();
+	void MofpoFinalPacketFinished();
+#ifdef ERROR_RESOLUTION_EXTENSION
+	void LastError();
+#endif // ERROR_RESOLUTION_EXTENSION
+
+#ifdef EMPTY_HEADERS_TEST
+	void EmptyHeaderTestL(TPtrC aName, TPtrC8 aType, TPtrC aDesc, TPtrC8 aTarget, TPtrC8 aAppParam);
+#endif //EMPTY_HEADERS_TEST
+
+private:
+	void RunL ();
+	void DoCancel ();
+	TInt SetUpObject (TDes& filename);
+	void DisplayObjectL();
+	void SaveObject();
+
+public:
+	TBuf<64> iObexName;
+	TBuf<64> iFilename1;
+	TBuf<64> iFilename2;
+	TBuf<64> iFilename3;
+	TBuf<16> iChallengePassword;
+	TBuf<16> iResponsePassword;
+	TBuf<32> iGetType;
+	TPath iInboxRoot;
+	
+private:
+	enum TSendState
+		{
+		EIdle,
+		EConnecting,
+		EConnected,
+		EPutting,
+		EGetting,
+		EDisconnecting,
+		ESettingPath,
+		EGettingReference,
+		EPuttingReference
+		};
+
+	CActiveConsole* iParent;
+	CObexClient* iClient;
+#ifdef ERROR_RESOLUTION_EXTENSION
+	CObexClientErrorResolver* iClientErrorResolver;
+#endif // ERROR_RESOLUTION_EXTENSION
+
+#ifdef EMPTY_HEADERS_TEST
+	CObexEmptyHeaderTest* iObexEmptyHeaderTest;
+#endif //EMPTY_HEADERS_TEST
+	
+	CObexFileObject* iFileObject;
+	CObexBufObject* iObject;
+	CBufFlat* iObjectBuffer;
+	TSendState iState;
+	CObexNullObject* iTargetHeaderObject;
+	CRFCOMMServiceFinder* iSdpServiceFinder;
+	TBTDevAddr iDevAddr;
+	TInt iCurrentTestNumber;
+
+	TTime iStartTime;
+	};
+
+
+#endif // _CLIENTHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/constants.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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 _TOBEXCONSTANTS_H
+#define _TOBEXCONSTANTS_H
+
+// Required to receive into a file (inc. buffered writes)
+_LIT(KFileName, "obex-temp.tmp");
+_LIT(KRFileTestFileName, "obex-RFile-temp.txt");
+
+
+_LIT(KRef1Name, "EPOCREF1OBJ");
+_LIT(KRef2Name, "EPOCREF2OBJ");
+_LIT(KRef3Name, "EPOCREF3OBJ");
+_LIT(KRef4Name, "EPOCREF4OBJ");
+_LIT(KRef5Name, "EPOCREF5OBJ");
+_LIT(KRef6Name, "EPOCREF6OBJ");
+_LIT(KRef7Name, "EPOCREF7OBJ");
+_LIT(KRef8Name, "EPOCREF8OBJ");
+_LIT(KRef9Name, "EPOCREF9OBJ");
+
+_LIT8(KRefTarget, "\xF9\xEC\x7B\xC4\x95\x3C\x11\xd2\x98\x4E\x52\x54\x00\xDC\x9E\x09"); // Folder Browsing
+
+const TInt KMaxNumOfTests = 1;
+
+static const TUid KObexTestUid = {0x12342468};
+
+enum TestMode
+	{
+	E_Inactive,
+	E_Server,
+	E_Server_File,
+	E_Client,
+	E_Client_Connect_Menu,
+	E_Client_Setup_Menu,
+	E_Client_Authentication_Header_Menu,
+	E_SdpQuery,
+	E_Auto,
+	E_Client_HTTP_Menu,
+	E_GetIrDANickname,
+	E_EnterRecvMTU,
+	E_EnterTransmitMTU,
+#ifdef EMPTY_HEADERS_TEST
+	E_Empty_Headers_Accept_Test,
+#endif //EMPTY_HEADERS_TEST
+	};
+
+enum TTransport
+	{
+	EBluetooth,
+	EIrda,
+	EUsb,
+	
+	//Place holder should a Win32 emulator USB transport be created
+	EWin32Usb
+	};
+
+#endif // _TOBEXCONSTANTS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/emptyheaderstest.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,89 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifdef EMPTY_HEADERS_TEST
+
+#pragma message("Building with additional test code to allow the checking of the acceptance of OBEX requests that contain empty headers.")
+#include <e32base.h>
+#include <obexheaders.h>
+#include "emptyheaderstest.h"
+
+
+CObexEmptyHeaderTest* CObexEmptyHeaderTest::NewL(TPtrC aName, TPtrC8 aType, TPtrC aDesc, TPtrC8 aTarget, TPtrC8 aAppParam)
+	{
+	CObexEmptyHeaderTest* ret = new (ELeave) CObexEmptyHeaderTest();
+	CleanupStack::PushL(ret);
+	ret->ConstructL( aName, aType, aDesc, aTarget, aAppParam );
+	CleanupStack::Pop();
+	return ret;
+	}
+
+
+CObexEmptyHeaderTest* CObexEmptyHeaderTest::NewL()
+	{
+	CObexEmptyHeaderTest* ret = new (ELeave) CObexEmptyHeaderTest();
+	CleanupStack::PushL(ret);
+	ret->ConstructL( _L(""), _L8(""), _L(""), _L8(""), _L8("") );
+	CleanupStack::Pop();
+	return ret;
+	}
+	
+CObexEmptyHeaderTest::CObexEmptyHeaderTest()
+	{
+
+	}
+
+void CObexEmptyHeaderTest::ConstructL(TPtrC aName, TPtrC8 aType, TPtrC aDesc, TPtrC8 aTarget, TPtrC8 aAppParam)
+	{
+	iBuffer = CBufFlat::NewL(10);
+	iBuffer->InsertL(0, _L8("CObexEmptyHeaderTest constructed, which allows the checking of the acceptance of OBEX requests that contain empty headers."));
+
+	iObexBufObject = CObexBufObject::NewL(iBuffer);
+		
+	iNameHeader = CObexHeader::NewL();
+	iTypeHeader = CObexHeader::NewL();
+	iDescriptionHeader = CObexHeader::NewL();
+	iTargetHeader = CObexHeader::NewL();
+	iAppParamHeader = CObexHeader::NewL();
+	
+	SetHeaders(aName, aType, aDesc, aTarget, aAppParam);
+	
+	iObexBufObject->AddHeaderL( *iNameHeader );
+	iObexBufObject->AddHeaderL( *iTypeHeader );
+	iObexBufObject->AddHeaderL( *iDescriptionHeader );
+	iObexBufObject->AddHeaderL( *iTargetHeader );
+	iObexBufObject->AddHeaderL( *iAppParamHeader );
+	}
+	
+void CObexEmptyHeaderTest::SetHeadersL(TPtrC aName, TPtrC8 aType, TPtrC aDesc, TPtrC8 aTarget, TPtrC8 aAppParam)
+	{
+	iNameHeader->SetUnicodeL( 0x01, aName );
+	iTypeHeader->SetByteSeqL(0x42, aType);
+	iDescriptionHeader ->SetUnicodeL(0x05, aDesc); 
+	iTargetHeader->SetByteSeqL(0x46, aTarget);
+	iAppParamHeader->SetByteSeqL(0x4C, aAppParam);
+	}
+
+CObexEmptyHeaderTest::~CObexEmptyHeaderTest()
+	{
+	delete iObexBufObject;
+	delete iBuffer;
+	}
+
+CObexBufObject* CObexEmptyHeaderTest::ObexObject() const
+	{
+	return iObexBufObject;
+	}
+#endif //EMPTY_HEADERS_TEST
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/emptyheaderstest.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,50 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obexobjects.h>
+
+#ifndef COBEXEMPTYHEADERTEST_HEADER
+#define COBEXEMPTYHEADERTEST_HEADER
+
+class CObexEmptyHeaderTest : public CBase
+{
+
+	public:
+		static CObexEmptyHeaderTest* NewL(TPtrC aName, TPtrC8 aType, TPtrC aDesc, TPtrC8 aTarget, TPtrC8 aAppParam);
+		static CObexEmptyHeaderTest* NewL();
+		virtual ~CObexEmptyHeaderTest();
+		
+		void SetHeadersL(TPtrC aName, TPtrC8 aType, TPtrC aDesc, TPtrC8 aTarget, TPtrC8 aAppParam);
+		//todo const ??
+		CObexBufObject* ObexObject() const;
+
+		
+	private:
+		CObexEmptyHeaderTest();
+		void ConstructL(TPtrC aName, TPtrC8 aType, TPtrC aDesc, TPtrC8 aTarget, TPtrC8 aAppParam);
+		
+		
+	private:			
+		CObexHeader* iNameHeader;
+		CObexHeader* iTypeHeader;
+		CObexHeader* iDescriptionHeader;
+		CObexHeader* iTargetHeader;
+		CObexHeader* iAppParamHeader;
+		
+		CBufFlat *iBuffer; 
+		CObexBufObject *iObexBufObject;
+};
+
+#endif //COBEXEMPTYHEADERTEST_HEADER
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/readme.txt	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+TObex - Readme.txt
+
+
+TObex provides provision for the existance of a Win32 emulator USB transport plugin, 
+together with a Symbian Win32 USB driver. 
+These would allow TObex to use USB when running on the emulator.
+However NEITHER a Win32 emulator USB transport plugin NOR a Symbian Win32 USB driver 
+are currently available. 
+An attempt to load USB when running TObex on the emulator will result in a 
+KErrNotFound error being posted.
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverasyncao.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,153 @@
+// 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 "serverasyncao.h"
+#include <e32cons.h>
+#include <obexserver.h>
+
+#include <obexobjects.h>
+
+
+CServerAsyncAO* CServerAsyncAO::NewL(CObexServer& aObexServer)
+	{
+	CServerAsyncAO* self = new(ELeave) CServerAsyncAO(aObexServer);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+	}
+	
+CServerAsyncAO::CServerAsyncAO(CObexServer& aObexServer)
+:CActive(EPriorityStandard),
+ iObexServer(aObexServer)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CServerAsyncAO::ConstructL()
+	{
+	iConsole = Console::NewL(_L("OBEX DLL Test Code"),TSize(55,12));
+	}
+
+CServerAsyncAO::~CServerAsyncAO()
+	{
+	delete iConsole;
+	}
+
+void CServerAsyncAO::CompletionIndication(CObex::TOperation aOpcode, TObexResponse aResponse)
+	{
+	_LIT(KPutIndication, "PutCompleteIndication\n");
+	_LIT(KGetIndication, "GetCompleteIndication\n");
+	_LIT(KSetPathIndication, "SetPathIndication\n");
+	
+	iState = ECompleteIndication;
+	iDefaultResponse = aResponse;
+	
+	switch(aOpcode)
+		{
+		case CObex::EOpPut:
+			iConsole->Printf(KPutIndication);
+			break;
+		case CObex::EOpGet:
+			iConsole->Printf(KGetIndication);
+			break;
+		case CObex::EOpSetPath:
+			iConsole->Printf(KSetPathIndication);
+			break;
+		default:
+			User::Invariant();
+		}
+
+	iConsole->Printf(_L("Please enter the response code: 0x%x"), aResponse);
+	iConsole->Read(iStatus);	
+	SetActive();
+	}
+
+void CServerAsyncAO::RequestIndication(CObex::TOperation aOpcode, CObexBaseObject *aObject)
+	{
+	if(aOpcode == CObex::EOpPut)
+		{
+		iConsole->Printf(_L("Put"));
+		}
+	else if(aOpcode == CObex::EOpGet)
+		{
+		iConsole->Printf(_L("Get"));
+		}
+	else
+		{
+		User::Invariant();
+		}
+	iState = ERequestIndication;
+	iObject = aObject;
+	iConsole->Printf(_L("RequestIndication, press any key to continue\n"));
+	iConsole->Read(iStatus);
+	SetActive();
+	}
+
+void CServerAsyncAO::RunL()
+	{
+	TObexResponse resp = ERespSuccess; 
+	TBuf<2> buf;
+
+	TKeyCode key = iConsole->KeyCode();
+	
+	if(iState == ECompleteIndication)
+		{
+		buf.AppendFormat(_L("%x"), iDefaultResponse);
+		do	{
+		
+			if(key == EKeyBackspace&&buf.Length()!=0)
+				{
+				buf.SetLength(buf.Length()-1);
+				}
+			else if( buf.Length() < buf.MaxLength())
+				{
+				buf.Append(key);
+				}
+			else 
+				continue;
+			iConsole->Printf(_L("%c"),key);
+			}
+		while((key = iConsole->Getch())!=EKeyEnter);
+		iConsole->Printf(_L("\n"));
+		
+		TLex lex(buf);
+		TUint value;
+		TInt lex_err = lex.Val(value, EHex); 
+		
+		if(lex_err == KErrNone)
+			{
+			resp = static_cast<TObexResponse>(value);
+			}
+		else 
+			{
+			iConsole->Printf(_L("Input parsing failed, use success as default response\n"));
+			}
+			
+		TInt ret = iObexServer.RequestCompleteIndicationCallback(resp);
+		iConsole->Printf(_L("Server returned with error code %d\n\n"), ret);
+		}
+	else
+		{
+		TInt ret = iObexServer.RequestIndicationCallback(iObject);
+		iConsole->Printf(_L("Server returned with error code %d\n\n"), ret);
+		}
+	}
+
+void CServerAsyncAO::DoCancel()
+	{
+	iConsole->ReadCancel();
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverasyncao.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#ifndef __SERVERASYNCCAO_H
+#define __SERVERASYNCCAO_H
+
+#include <obexconstants.h>
+#include <obexbase.h>
+
+class CConsoleBase;
+class CObexServer;
+
+class CServerAsyncAO : public CActive
+	{
+public:
+    static CServerAsyncAO* NewL(CObexServer& aObexServer);
+	
+	~CServerAsyncAO();
+	void CompletionIndication(CObex::TOperation aOpcode, TObexResponse aResponse);
+    void RequestIndication(CObex::TOperation aOpcode, CObexBaseObject* aObject);
+
+    void RunL();
+
+private:
+	CServerAsyncAO(CObexServer& aObexServer);
+	void ConstructL();
+	void DoCancel();
+private:
+    CConsoleBase* iConsole;
+    CObexServer& iObexServer;
+    CObexBaseObject* iObject;
+
+    enum TIndicationState
+    	{
+    	ERequestIndication,
+    	ECompleteIndication
+    	};
+    TIndicationState iState;
+    TObexResponse iDefaultResponse;
+    };
+
+#endif //SERVERASYNCCAO_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverhandler.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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 <es_sock.h>
+#include <ir_sock.h>
+#include <bautils.h>
+#include <usbman.h>
+#include <d32usbc.h>
+#include "serverhandlerbase.h"
+#include "serverhandler.h"
+#include "TOBEXCON.H"
+#include "btextnotifiers.h"
+
+
+CObexServerHandler::CObexServerHandler(CActiveConsole* aParent)
+	: CObexServerHandlerBase(aParent)
+    {}
+
+CObexServerHandler* CObexServerHandler::NewL(CActiveConsole* aParent, TTransport aTransport)
+    {
+    CObexServerHandler* self = new (ELeave) CObexServerHandler(aParent);
+
+    CleanupStack::PushL(self);
+    self->ConstructL(aTransport);
+    CleanupStack::Pop();
+    return (self);
+    }
+
+void CObexServerHandler::ConstructL(TTransport aTransport)
+    {
+    BaseConstructL(aTransport);
+    
+    iBuf = CBufFlat::NewL(5000);//5000 - what should I put??
+    iObject  = CObexBufObject::NewL(NULL);
+    
+    iObject->SetDataBufL(iBuf);
+	}
+
+CObexServerHandler::~CObexServerHandler()
+	{
+	delete iObject; iObject = 0;
+    delete iBuf; iBuf = 0;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverhandler.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#ifndef _SERVERHANDLER_H
+#define _SERVERHANDLER_H
+
+#include <es_sock.h>
+#include <e32test.h>
+#include <es_prot.h>
+#include <e32cons.h>
+#include <obex.h>
+#include <btmanclient.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obex/internal/obexinternalconstants.h>
+#include <btsdp.h>
+#include <obexfinalpacketobserver.h>
+
+class CActiveConsole;
+
+class CObexServerHandler : public CObexServerHandlerBase
+//-----------------------------------------------------------
+	{
+public:
+	// Construction
+	static CObexServerHandler* NewL(CActiveConsole* aParent, TTransport aTransport);
+	void ConstructL(TTransport aTransport);
+	
+	~CObexServerHandler();
+
+private:
+	CObexServerHandler(CActiveConsole* aParent);
+	};
+
+
+#endif // _SERVERHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverhandlerbase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1007 @@
+// 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 <es_sock.h>
+#include <ir_sock.h>
+#include <bautils.h>
+#include <usbman.h>
+#include <d32usbc.h>
+#include "serverhandlerbase.h" 
+#include "TOBEXCON.H"
+#include "btextnotifiers.h"
+#include "serverasyncao.h"
+#include <obexconstants.h>
+#include <obexbttransportinfo.h>
+#include <obexirtransportinfo.h>
+#include "obexconstantsinternal.h"
+
+#include "serverpacketaccessui.h"
+
+CObexServerHandlerBase::CObexServerHandlerBase(CActiveConsole* aParent)
+	: iAcceptPuts(ETrue), iParent(aParent)
+    {
+    }
+
+
+void CObexServerHandlerBase::BaseConstructL(TTransport aTransport)
+    {
+
+	iTransportLayer = aTransport;
+	switch (aTransport)
+		{
+		case (EBluetooth):
+			InitBluetoothL();
+			break;
+		
+		case (EIrda):
+			{
+			if(iParent->UseIrdaNickname())
+				{
+				TObexIrV3TransportInfo aInfo;
+				aInfo.iTransportName = KObexIrTTPProtocolV3;
+				aInfo.iReceiveMtu = iParent->iRecvMTU;
+				aInfo.iTransmitMtu = iParent->iTransmitMTU;
+				aInfo.iAddr.SetPort(KAutoBindLSAP);//default obex server for now
+				_LIT8(KClassName, "OBEX");
+				_LIT8(KAttributeName, "IrDA:TinyTP:LsapSel");
+				aInfo.iClassName     = KClassName;
+				aInfo.iAttributeName = KAttributeName;
+				aInfo.iDiscoverySlots = iParent->iDiscoverySlots;
+				aInfo.iDiscoveryAttempts = iParent->iDiscoveryAttempts;
+				aInfo.iLocalDeviceNickname = iParent->GetIrdaNickname();
+				aInfo.iLocalDeviceNicknameValid = ETrue;
+				iServer = CObexServer::NewL(aInfo);
+				}
+			else
+				{
+				TObexIrV2TransportInfo aInfo;
+				aInfo.iTransportName = KObexIrTTPProtocolV2;
+				aInfo.iReceiveMtu = iParent->iRecvMTU;
+				aInfo.iTransmitMtu = iParent->iTransmitMTU;
+				aInfo.iAddr.SetPort(KAutoBindLSAP);//default obex server for now
+				_LIT8(KClassName, "OBEX");
+				_LIT8(KAttributeName, "IrDA:TinyTP:LsapSel");
+				aInfo.iClassName     = KClassName;
+				aInfo.iAttributeName = KAttributeName;
+				aInfo.iDiscoverySlots = iParent->iDiscoverySlots;
+				aInfo.iDiscoveryAttempts = iParent->iDiscoveryAttempts;
+				iServer = CObexServer::NewL(aInfo);
+				}
+			User::LeaveIfError(iServer->Start(this));
+			
+/*			// Uncomment this code to demonstrate CObexServer::TransportInfo 
+			// API with TTP transport.
+			// We get back an TObexIrTransportInfo because we asked for KObexIrTTPProtocol.
+			const TObexIrTransportInfo* transportInfo = static_cast<const TObexIrTransportInfo*>(iServer->TransportInfo());
+			iParent->Console()->Printf(_L("Transport info: \r\n"));
+			iParent->Console()->Printf(_L("\ttransport name: %S\r\n"), &transportInfo->iTransportName);
+			iParent->Console()->Printf(_L("\tversion: %d\r\n"), transportInfo->iVersion);
+			iParent->Console()->Printf(_L("\treceive MTU: %d\r\n"), transportInfo->iReceiveMtu);
+			iParent->Console()->Printf(_L("\ttransmitMTU: %d\r\n"), transportInfo->iTransmitMtu);
+			iParent->Console()->Printf(_L("\tTinyTP port: 0x%02x\r\n"), transportInfo->iAddr.Port());
+			TName wide;
+			wide.Copy(transportInfo->iClassName);
+			iParent->Console()->Printf(_L("\tclass name: %S\r\n"), &wide);
+			wide.Copy(transportInfo->iAttributeName);
+			iParent->Console()->Printf(_L("\tattribute name: %S\r\n"), &wide);
+*/
+			break;
+			}
+		
+		case (EUsb):
+			{
+			TObexUsbProtocolInfo info;
+			info.iTransport = KObexUsbProtocol;
+			info.iInterfaceStringDescriptor = _L("TOBEX Server Interface");
+
+			iServer = CObexServer::NewL (info);
+			User::LeaveIfError(iServer->Start (this));
+			
+/*			// Uncomment this code to demonstrate CObexServer::TransportInfo 
+			// API with USB transport.
+			// We get back an TObexUsbTransportInfo because we asked for KObexUsbProtocol.
+			const TObexUsbTransportInfo* transportInfo = static_cast<const TObexUsbTransportInfo*>(iServer->TransportInfo());
+			iParent->Console()->Printf(_L("Transport info: \r\n"));
+			iParent->Console()->Printf(_L("\ttransport name: %S\r\n"), &transportInfo->iTransportName);
+			iParent->Console()->Printf(_L("\tversion: %d\r\n"), transportInfo->iVersion);
+			iParent->Console()->Printf(_L("\treceive MTU: %d\r\n"), transportInfo->iReceiveMtu);
+			iParent->Console()->Printf(_L("\ttransmitMTU: %d\r\n"), transportInfo->iTransmitMtu);
+			iParent->Console()->Printf(_L("\tinterface string desc: %S\r\n"), &transportInfo->iInterfaceStringDescriptor);
+*/
+			break;
+			}
+		
+		case (EWin32Usb):
+			{
+			TObexUsbProtocolInfo aInfo;
+			aInfo.iTransport = _L("Win32Usb");
+	        aInfo.iInterfaceStringDescriptor = _L("TOBEX Server Interface");
+	        
+			iServer = CObexServer::NewL (aInfo);
+			User::LeaveIfError(iServer->Start (this));
+			
+/*			// Uncomment this code to demonstrate CObexServer::TransportInfo 
+			// API with Win32USB transport.
+			// We get back an TObexUsbTransportInfo because we asked for KObexUsbProtocol.
+			const TObexUsbTransportInfo* transportInfo = static_cast<const TObexUsbTransportInfo*>(iServer->TransportInfo());
+			iParent->Console()->Printf(_L("Transport info: \r\n"));
+			iParent->Console()->Printf(_L("\ttransport name: %S\r\n"), &transportInfo->iTransportName);
+			iParent->Console()->Printf(_L("\tversion: %d\r\n"), transportInfo->iVersion);
+			iParent->Console()->Printf(_L("\treceive MTU: %d\r\n"), transportInfo->iReceiveMtu);
+			iParent->Console()->Printf(_L("\ttransmitMTU: %d\r\n"), transportInfo->iTransmitMtu);
+			iParent->Console()->Printf(_L("\tinterface string desc: %S\r\n"), &transportInfo->iInterfaceStringDescriptor);
+*/
+			break;
+			}
+		}
+	
+#ifdef ASYNC_INDICATION
+    iServerAsyncAO = CServerAsyncAO::NewL(*iServer);
+#endif
+	}
+
+void CObexServerHandlerBase::InitBluetoothL()
+	{
+	TBTServiceSecurity serv;
+	serv.SetUid(KObexTestUid);
+	
+	// UPF - change security here for Bluetooth security testing
+	serv.SetAuthentication(EFalse);
+	serv.SetAuthorisation(EFalse);
+	serv.SetEncryption(EFalse);
+
+	// now set up Obex...
+	TObexBluetoothProtocolInfo info;
+	info.iTransport = KObexRfcommProtocol;
+	info.iAddr.SetPort(KRfcommPassiveAutoBind);
+	info.iAddr.SetSecurity(serv);
+
+	TObexProtocolPolicy policy;
+	policy.SetReceiveMtu(iParent->iRecvMTU);
+	policy.SetTransmitMtu(iParent->iTransmitMTU);
+
+	iServer  = CObexServer::NewL(info, policy);
+	iServer->SetReadActivityObserver(this);
+
+	User::LeaveIfError(iServer->Start (this));
+	// We get back an TObexBtTransportInfo because we asked for KObexRfcommProtocol.
+	const TObexBtTransportInfo* transportInfo = static_cast<const TObexBtTransportInfo*>(iServer->TransportInfo());
+	iParent->Console()->Printf(_L("Transport info: \r\n"));
+	iParent->Console()->Printf(_L("\ttransport name: %S\r\n"), &transportInfo->iTransportName);
+	iParent->Console()->Printf(_L("\tversion: %d\r\n"), transportInfo->iVersion);
+	iParent->Console()->Printf(_L("\treceive MTU: %d\r\n"), transportInfo->iReceiveMtu);
+	iParent->Console()->Printf(_L("\ttransmitMTU: %d\r\n"), transportInfo->iTransmitMtu);
+	iParent->Console()->Printf(_L("\tRFCOMM port: 0x%02x\r\n"), transportInfo->iAddr.Port());
+	
+	// SDP registration 
+	User::LeaveIfError(iSdp.Connect());
+	User::LeaveIfError(iSdpdb.Open(iSdp));
+
+	TSdpServRecordHandle handle;
+	iSdpdb.CreateServiceRecordL(TUUID(0x1105), handle);
+	iSdpdb.UpdateAttributeL(handle, 0x100, _L8("Obex push server"));
+	
+
+	TSdpServRecordHandle ftphandle;
+	iSdpdb.CreateServiceRecordL(TUUID(0x1106), ftphandle);
+	iSdpdb.UpdateAttributeL(ftphandle, 0x100, _L8("File transfer server"));
+			
+	// Protocol Descriptor List (same for both profiles)
+	iProtDescList = CSdpAttrValueDES::NewDESL(0);
+
+	iProtDescList
+	->StartListL()
+		->BuildDESL()
+		->StartListL()
+			->BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP
+		->EndListL()
+		->BuildDESL()
+		->StartListL()
+			->BuildUUIDL(TUUID(TUint16(0x0003))) // RFCOMM
+			->BuildUintL(TSdpIntBuf<TInt8>(transportInfo->iAddr.Port()))
+		->EndListL()
+		->BuildDESL()
+		->StartListL()
+			->BuildUUIDL(TUUID(TUint16(0x0008))) // OBEX
+		->EndListL()
+	->EndListL();
+
+	iSdpdb.UpdateAttributeL(handle, 4, *iProtDescList);
+	iSdpdb.UpdateAttributeL(ftphandle, 4, *iProtDescList); // put into both records
+	delete iProtDescList;
+	iProtDescList = NULL;
+
+	// Supported formats list (OPP only)
+	iProtDescList = CSdpAttrValueDES::NewDESL(0);
+
+	iProtDescList->StartListL()
+		->BuildUintL(TSdpIntBuf<TUint8>(0xFF)) // Accept any type of object
+	->EndListL();
+
+	iSdpdb.UpdateAttributeL(handle, 0x0303, *iProtDescList);
+	
+	delete iProtDescList;
+	iProtDescList = NULL;
+	
+	// Add OPP to the supported profiles list
+	iProtDescList = CSdpAttrValueDES::NewDESL(0);
+
+	iProtDescList->StartListL()
+		->BuildDESL()
+		->StartListL()
+			->BuildUUIDL(TUUID(0x1105)) // OPP Profile
+			->BuildUintL(TSdpIntBuf<TUint16>(0x0100)) // Profile version
+		->EndListL()
+	->EndListL();
+
+	iSdpdb.UpdateAttributeL(handle, 9, *iProtDescList); // profile list
+
+	delete iProtDescList;
+	iProtDescList = NULL;
+
+	// Add FTP to the supported profiles list
+	iProtDescList = CSdpAttrValueDES::NewDESL(0);
+
+	iProtDescList->StartListL()
+		->BuildDESL()
+		->StartListL()
+			->BuildUUIDL(TUUID(0x1106)) // FTP Profile
+			->BuildUintL(TSdpIntBuf<TUint16>(0x0100)) // Profile version
+		->EndListL()
+	->EndListL();
+
+	iSdpdb.UpdateAttributeL(ftphandle, 9, *iProtDescList); // profile list
+
+	delete iProtDescList;
+	iProtDescList = NULL;
+	
+	// Set host name
+	RSocketServ ss;
+	ss.Connect();
+
+	RHostResolver hr;
+	User::LeaveIfError(hr.Open(ss,KBTAddrFamily,KBTLinkManager));
+	User::LeaveIfError(hr.SetHostName(_L("Symbian Push Server")));
+	ss.Close();
+
+	// Enable enquiry and page scan
+	User::LeaveIfError(RProperty::Set(KPropertyUidBluetoothCategory, KPropertyKeyBluetoothSetScanningStatus, EInquiryAndPageScan));
+	}
+
+CObexServerHandlerBase::~CObexServerHandlerBase ()
+    {
+    Stop();
+
+	if (iTransportLayer == EBluetooth)
+		{
+		// security now cleared with socket closure
+		iSdpdb.Close();
+		iSdp.Close();
+		}
+#ifdef PACKET_ACCESS_EXTENSION
+	delete iPacketAccessUi;
+#endif // PACKET_ACCESS_EXTENSION
+
+#ifdef ASYNC_INDICATION		
+	delete iServerAsyncAO;
+#endif
+    delete iServer;
+	delete iProtDescList;
+    }
+
+void CObexServerHandlerBase::RemoteAddress()
+	{
+	TSockAddr aAddr;
+	iServer->RemoteAddr( aAddr);
+	TBTDevAddr addr = static_cast <TBTSockAddr>(aAddr).BTAddr();
+	
+	TChar aChar;
+
+	iParent->Console()->Printf(_L("Remote Address = "));
+	for(TInt count = 0; count < addr.Des().Length(); count++) 
+		{
+		aChar = (addr.Des()[count] & 0xf0)>>4;
+		if (aChar <= 9)
+			aChar += 0x30;
+		else if ((aChar >= 0x0a) && (aChar <= 0x0f))
+			aChar += 'A' - 0x0a;
+		iParent->Console()->Printf(_L("%C"),(TUint)aChar);
+
+		aChar = (addr.Des()[count] & 0x0f);
+		if (aChar <= 9)
+			aChar += 0x30;
+		else if ((aChar >= 0x0a) && (aChar <= 0x0f))
+			aChar += 'A' - 0x0a;
+		iParent->Console()->Printf(_L("%C"),(TUint)aChar);
+		}
+    iParent->Console()->Printf(_L("\r\n"));
+	}
+
+
+void CObexServerHandlerBase::Start()
+    {
+    if (iServer)
+		{
+		iServer->Start(this);
+		}
+    }
+
+void CObexServerHandlerBase::Stop()
+    {
+	if (iServer)
+		{
+		iServer->Stop();
+		}
+    }
+
+void CObexServerHandlerBase::SetTargetChecking(CObexServer::TTargetChecking aValue)
+	{
+    iServer->SetTargetChecking(aValue);
+	}
+
+
+
+// MObexServerNotify interface functions
+
+void CObexServerHandlerBase::ErrorIndication (TInt aError)
+    {
+    iParent->Console()->Printf(_L("Obex Server Error: %d\r\n"), aError);
+    }
+
+void CObexServerHandlerBase::TransportUpIndication ()
+    {
+    iParent->Console()->Printf(_L("\r\nTransport layer now connected\r\n\r\n"));
+    }
+
+void CObexServerHandlerBase::TransportDownIndication ()
+    {
+    iParent->Console()->Printf(_L("\r\nTransport layer has gone down\r\n\r\n"));
+    
+    if (iObject)
+		{
+		if(!iObject->BytesReceived())
+			{
+			return;
+			}
+		
+		iParent->Console()->Printf(_L("\r\nWe have received part of an Obex object\r\n\r\n"));
+
+		iObject->Reset();//close file handle
+		}
+    }
+#ifdef ASYNC_INDICATION
+void CObexServerHandlerBase::ObexConnectIndication(const TObexConnectInfo& aRemoteInfo, const TDesC8& /*aInfo*/)
+#else
+TInt CObexServerHandlerBase::ObexConnectIndication(const TObexConnectInfo& aRemoteInfo, const TDesC8& /*aInfo*/)
+#endif
+    {
+	iParent->Console()->Printf(_L("\r\nCObexServerHandler::ObexConnectIndication"));
+	iParent->Console()->Printf(_L("\r\nConnected to machine with OBEX version %d.%d\r\n"), 
+		     aRemoteInfo.VersionMajor (), aRemoteInfo.VersionMinor ());
+
+	if ( aRemoteInfo.iWho.Length() > 0 )
+		{
+		iParent->Console()->Printf(_L("EWho received from remote side ="));
+
+		for(TInt count = 0; count < aRemoteInfo.iWho.Length(); count++) 
+			{
+
+			TChar aChar;
+
+			aChar = (aRemoteInfo.iWho[count] & 0xf0)>>4;
+			if (aChar <= 9)
+				aChar += 0x30;
+			else if ((aChar >= 0x0a) && (aChar <= 0x0f))
+				aChar += 'A' - 0x0a;
+			iParent->Console()->Printf(_L("%C"),(TUint)aChar);
+
+			aChar = (aRemoteInfo.iWho[count] & 0x0f);
+			if (aChar <= 9)
+				aChar += 0x30;
+			else if ((aChar >= 0x0a) && (aChar <= 0x0f))
+				aChar += 'A' - 0x0a;
+			iParent->Console()->Printf(_L("%C"),(TUint)aChar);
+
+			}
+		iParent->Console()->Printf(_L("\r\n"));
+		}
+	else
+		iParent->Console()->Printf(_L("No Who Header received\r\n"));
+
+	if ( aRemoteInfo.iTargetHeader.Length() > 0 )
+		{
+		iParent->Console()->Printf(_L("ETarget received from remote side ="));
+		for(TInt count = 0; count < aRemoteInfo.iTargetHeader.Length(); count++) 
+			{
+			TChar aChar;
+
+			aChar = (aRemoteInfo.iTargetHeader[count] & 0xf0)>>4;
+			if (aChar <= 9)
+				aChar += 0x30;
+			else if ((aChar >= 0x0a) && (aChar <= 0x0f))
+				aChar += 'A' - 0x0a;
+			iParent->Console()->Printf(_L("%C"),(TUint)aChar);
+
+			aChar = (aRemoteInfo.iTargetHeader[count] & 0x0f);
+			if (aChar <= 9)
+				aChar += 0x30;
+			else if ((aChar >= 0x0a) && (aChar <= 0x0f))
+				aChar += 'A' - 0x0a;
+			iParent->Console()->Printf(_L("%C"),(TUint)aChar);
+			}
+		iParent->Console()->Printf(_L("\r\n"));
+		}
+	else
+		iParent->Console()->Printf(_L("No Target Header received\r\n"));
+
+#ifndef ASYNC_INDICATION
+	return KErrNone;
+#endif	
+    } 
+
+void CObexServerHandlerBase::ObexDisconnectIndication (const TDesC8& /*aInfo*/)
+    {
+    iParent->Console()->Printf(_L("\r\nObex Disconnected\r\n\r\n"));
+    }
+
+#ifdef ASYNC_INDICATION
+void CObexServerHandlerBase::PutRequestIndication ()
+#else
+CObexBufObject* CObexServerHandlerBase::PutRequestIndication ()
+#endif
+    {
+	iStartTime.HomeTime();
+	
+    iParent->Console()->Printf(_L("Receiving object...\r\n"));
+    iObject->Reset ();
+#ifdef ASYNC_INDICATION
+	iServerAsyncAO->RequestIndication(CObex::EOpPut, iAcceptPuts?iObject:NULL);
+#else
+	return iAcceptPuts?iObject:NULL;
+#endif
+    }
+
+TInt CObexServerHandlerBase::PutPacketIndication ()
+    {
+    // Only output % received if performance logging is disabled.
+	if(!iParent->iPerformanceLoggingEnabled)
+		{
+		TUint length = iObject->Length();
+		TUint received = iObject->BytesReceived();
+		TUint8 percent = 0;
+	    if (length > 0)
+			{
+			percent = TUint8((100 * received) / length);
+			iParent->Console()->Printf(_L("\r%d %%      "), percent);
+			}
+	    else
+			{
+			iParent->Console()->Printf(_L("\r%d Bytes      "), iObject->BytesReceived ());
+			}
+		}
+    return (KErrNone);
+    }
+    
+#ifdef ASYNC_INDICATION
+void CObexServerHandlerBase::PutCompleteIndication()
+#else
+TInt CObexServerHandlerBase::PutCompleteIndication()
+#endif
+    {
+	TTime finishTime;
+	finishTime.HomeTime();
+	TTimeIntervalMicroSeconds diff = finishTime.MicroSecondsFrom(iStartTime);	
+
+	iParent->Console()->Printf(_L("\nObject Received in %d"), diff.Int64());
+
+    TPtrC name=iObject->Name();
+	TBuf<100> type;
+	type.Copy(iObject->Type());
+	iParent->Console()->Printf(_L("\r\nSuccessfully received '%S'\r\nType[%d]: '%S'\r\n"), &name, type.Length(), &type);
+	
+	TInt err = KErrNone;
+	if (iParent->DisplayHeaders())
+		{
+		// No need to put header on the cleanup stack, as there are no leaving functions during its lifetime
+		CObexHeader* header = NULL;
+		TRAP(err, header = CObexHeader::NewL());
+		if (err)
+			{
+			iParent->iConsole->Printf(_L("Error allocating memory to display\r\n"));
+			}
+
+		iObject->HeaderSet().SetMask(NULL);
+		iObject->HeaderSet().First();
+
+		while (err == KErrNone)
+			{
+			err = iObject->HeaderSet().This(header);
+
+			switch (header->Type())
+				{
+				case (0x00): //Unicode
+					{
+					HBufC16* buf = NULL;
+					TRAPD(headerErr, buf = HBufC16::NewL((header->AsUnicode()).Size()));
+					if (headerErr)
+						{
+						iParent->iConsole->Printf(_L("Unicode Header (0x%x)- Error allocating memory to display\r\n"), header->HI());
+						}
+					else
+						{
+						TPtr16 type(buf->Des());
+						type.Copy(header->AsUnicode());
+
+						iParent->iConsole->Printf(_L("Unicode Header (0x%x) =  : \"%S\"\r\n"), header->HI(), &type);
+						delete buf;
+						}
+					break;
+					}
+				case (0x01): // ByteSeq
+					{
+					HBufC16* buf = NULL;
+					TRAPD(headerErr, buf = HBufC16::NewL((header->AsByteSeq()).Size()));
+					if (headerErr)
+						{
+						iParent->iConsole->Printf(_L("ByteSeq Header (0x%x)- Error allocating memory to display\r\n"), header->HI());
+						}
+					else
+						{
+						TPtr16 type(buf->Des());
+						type.Copy(header->AsByteSeq());
+
+						iParent->iConsole->Printf(_L("ByteSeq Header (0x%x) =  : \"%S\"\r\n"), header->HI(), &type);
+						delete buf;
+						}
+					break;
+					}
+				case (0x02): // Byte
+					{
+					iParent->iConsole->Printf(_L("Byte Header (0x%x) =  : 0x%x\r\n"), header->HI(), header->AsByte());
+					break;
+					}
+				case (0x03): //FourByte
+					{
+					iParent->iConsole->Printf(_L("FourByte Header (0x%x) =  : 0x%x\r\n"), header->HI(), header->AsFourByte());
+					break;
+					}
+				default : {break;}
+				}
+			
+			err = iObject->HeaderSet().Next();
+			}
+		
+		delete header;
+		}	
+
+	TDateTime dt = iObject->Time().DateTime();
+	iParent->Console()->Printf(_L("\r\nTimestamp: %d/%d/%d, %d:%d:%d\r\n\r\n"),
+				   dt.Day()+1, dt.Month()+1, dt.Year(), dt.Hour(), dt.Minute(), dt.Second());
+
+	// Reset err to no error;
+	err = KErrNone;
+
+	if ((iObject->Name() == KRef1Name) ||
+	    (iObject->Name() == KRef2Name) ||
+	    (iObject->Name() == KRef3Name) ||
+	    (iObject->Name() == KRef4Name) ||
+	    (iObject->Name() == KRef5Name) ||
+	    (iObject->Name() == KRef6Name) ||
+	    (iObject->Name() == KRef7Name) ||
+	    (iObject->Name() == KRef8Name) ||
+	    (iObject->Name() == KRef9Name))
+		{
+		iParent->Console()->Printf(_L("\r\nReference Object Received"));
+		TInt objComp = 0;
+		TRAP(err, objComp = iParent->iRefHandler->CompareObjectToReferenceL(*iObject, *iBuf, iParent->iTransport));
+		if ((objComp != 0) || (err != KErrNone)) // Make sure the objects match
+			{
+			User::Panic(_L("TOBEX - OBJCOMP"), err);
+			}
+		iParent->Console()->Printf(_L("\r\nReference Object Comparison OK\r\n\r\n"));
+		}
+	else
+		{
+		iParent->Console()->Printf(_L("Size of received object = %d\n"),iBuf->Size());
+
+	    // Only output packet contents info if performance logging is disabled.
+		if(!iParent->iPerformanceLoggingEnabled)
+			{
+		    TBuf8<1024> tempBuffer;
+			iBuf->Read(0, tempBuffer, tempBuffer.MaxSize() < iBuf->Size() ? tempBuffer.MaxSize() : iBuf->Size());
+
+			// Printf fails with Descriptor beigger than X hundred bytes so write byte at a time
+			for(TInt count = 0; count < tempBuffer.Size(); count++) 
+				{
+				iParent->Console()->Printf(_L("%C"),tempBuffer[count]);
+				}
+			}
+
+		if (iObject->Name() != KNullDesC )
+			{
+			TFileName filename;
+			filename = iParent->iInboxRoot;
+			
+			TInt bufSpaceLeft = filename.MaxLength() - filename.Length();
+			TInt objNameLen = iObject->Name().Length();
+			TInt numToCopy = objNameLen;
+			if (bufSpaceLeft < objNameLen)
+				{
+				numToCopy = bufSpaceLeft;
+				iParent->Console()->Printf(_L("Truncated resulting local filename\n"));
+				}
+			filename.Append(iObject->Name().Ptr(), numToCopy);
+			
+			err = iObject->WriteToFile(filename);
+
+			if (err == KErrAlreadyExists)
+				{
+				iParent->Console()->Printf(_L("\r\nWrite failed, File Already Exists\n"));
+				}
+			else if (err != KErrNone)
+				{
+				iParent->Console()->Printf(_L("\r\nWrite failed with error %d\n"), err);
+				}
+			}
+		else
+			{
+			err = KErrNone;
+			iParent->Console()->Printf(_L("\r\nReceived object with empty Name Header.\nNot writing to a file\n"));
+			}
+		}
+
+	TObexHeaderMask headers = iObject->ValidHeaders();
+	iParent->Console()->Printf(_L("\n"));
+	if (headers & KObexHdrBody)
+		iParent->Console()->Printf(_L("Body header received\n"));
+	if (headers & KObexHdrEndOfBody)
+		iParent->Console()->Printf(_L("EndOfBody header received\n"));
+
+    iObject->Reset ();
+#ifdef ASYNC_INDICATION    
+	if(err)
+		{
+		iServerAsyncAO->CompletionIndication(CObex::EOpPut, ERespNotAcceptable);
+		}
+	else
+		{
+		iServerAsyncAO->CompletionIndication(CObex::EOpPut, ERespSuccess);
+		}
+		
+#else
+	return err;
+#endif
+    }
+
+void CObexServerHandlerBase::HandleGetReferenceObjL(CObexBaseObject* aRequiredObject)
+	{
+	CObexBufObject& obj = *static_cast<CObexBufObject*>(aRequiredObject);
+	CBufFlat* dummyBufPtr = CBufFlat::NewL(0);
+	CleanupStack::PushL(dummyBufPtr);
+
+	// See if what we got in the Get request is the same as the reference object...
+	TInt objComp = iParent->iRefHandler->CompareObjectToReferenceL(obj, *dummyBufPtr, iParent->iTransport);
+	CleanupStack::PopAndDestroy(dummyBufPtr);
+	ASSERT(objComp == CReferenceHandler::EDifferentBuf);
+
+	// Everythings OK so set up the reference object to be returned
+	iParent->Console()->Printf(_L("Obex Get Reference Object Request\r\n"));
+
+
+	if (aRequiredObject->Name() == KRef1Name)
+		iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 1, iParent->iTransport);
+	else if (aRequiredObject->Name() == KRef2Name)
+		iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 2, iParent->iTransport);
+	else if (aRequiredObject->Name() == KRef3Name)
+		iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 3, iParent->iTransport);
+	else if (aRequiredObject->Name() == KRef4Name)
+		iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 4, iParent->iTransport);
+	else if (aRequiredObject->Name() == KRef5Name)
+		iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 5, iParent->iTransport);
+	else if (aRequiredObject->Name() == KRef6Name)
+		iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 6, iParent->iTransport);
+	else if (aRequiredObject->Name() == KRef7Name)
+		iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 7, iParent->iTransport);
+	else if (aRequiredObject->Name() == KRef8Name)
+		iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 8, iParent->iTransport);
+	else if (aRequiredObject->Name() == KRef9Name)
+		iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 9, iParent->iTransport);
+	else // capture error condition (use reference 1)
+		iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 1, iParent->iTransport);
+
+	}
+
+#ifdef ASYNC_INDICATION
+void CObexServerHandlerBase::GetRequestIndication (CObexBaseObject* aRequiredObject)
+#else
+CObexBufObject* CObexServerHandlerBase::GetRequestIndication (CObexBaseObject* aRequiredObject)
+#endif
+    {
+	//check if app params header sent across
+	if ( aRequiredObject->ValidHeaders() & KObexHdrAppParam )
+		{
+		TBuf<30> localBuf;
+		localBuf.Copy(aRequiredObject->AppParam());
+		
+		iParent->iConsole->Printf(_L(" App Param received =  : %S\r\n"), &localBuf);
+		}
+	else 
+		{
+		iParent->iConsole->Printf(_L(" No App Param Headers received\r\n"));
+		}
+
+	//check if any HTTP headers were sent across
+	if ( aRequiredObject->ValidHeaders() & KObexHdrHttp)
+		{
+		//OK so lets get them out
+		const RPointerArray<HBufC8>* localHttpArray = aRequiredObject->Http(); 
+		//how many?
+		TInt count = localHttpArray->Count();
+		HBufC8* localArray;
+		TBuf8<30> localBuf;
+		TBuf<40> buf;
+		TInt size = 30;
+		for ( TInt x = 0; x < count; x++ )
+			{
+			localArray = (*localHttpArray)[x];
+			size = Max(localArray->Size(), 30);
+			localBuf.Copy(localArray->Ptr(), size);
+			buf.Copy(localBuf);
+			iParent->iConsole->Printf(_L(" HTTP Header Received : %S\r\n"), &buf);
+			}
+		}
+	else 
+		{
+		iParent->iConsole->Printf(_L(" No HTTP Headers received\r\n"));
+		}
+	
+	if ((aRequiredObject->Name() == KRef1Name) ||
+	    (aRequiredObject->Name() == KRef2Name) ||
+	    (aRequiredObject->Name() == KRef3Name) ||
+	    (aRequiredObject->Name() == KRef4Name) ||
+	    (aRequiredObject->Name() == KRef5Name) ||
+	    (aRequiredObject->Name() == KRef6Name) ||
+	    (aRequiredObject->Name() == KRef7Name) ||
+	    (aRequiredObject->Name() == KRef8Name) ||
+	    (aRequiredObject->Name() == KRef9Name))
+		{
+#ifdef _DEBUG
+		TRAPD(err, HandleGetReferenceObjL(aRequiredObject));
+		ASSERT(err==0);
+#else
+		TRAP_IGNORE(HandleGetReferenceObjL(aRequiredObject));
+#endif
+		}
+	else
+		{
+		TRAPD(err,SetUpGetObjectL(aRequiredObject));
+		if (err != KErrNone)
+			{
+			iParent->Console()->Printf(_L("\nSetUpGetObjectL() returned %d.\n"), err);
+#ifdef ASYNC_INDICATION
+			iServerAsyncAO->RequestIndication(CObex::EOpGet, NULL);
+#else
+			iServer->RequestIndicationCallbackWithError(err); //added to test PDEF097129
+			return (NULL);
+#endif
+			}
+		}
+#ifdef ASYNC_INDICATION
+	iServerAsyncAO->RequestIndication(CObex::EOpGet, iObject);
+#else
+	return (iObject);
+#endif
+	}
+
+TInt CObexServerHandlerBase::GetPacketIndication ()
+    {
+    if (iObject->Length () > 0)
+    	{
+    	TInt percentComplete = 100 * iObject->BytesSent () / iObject->Length ();
+    	iParent->Console()->Printf(_L("\r%d %%      "), percentComplete);
+    	}
+    else
+    	{
+    	iParent->Console()->Printf(_L("\r%d Bytes      "), iObject->BytesSent ());
+    	}
+    
+    return (KErrNone);
+    }
+
+#ifdef ASYNC_INDICATION
+void CObexServerHandlerBase::GetCompleteIndication ()
+#else
+TInt CObexServerHandlerBase::GetCompleteIndication ()
+#endif
+    {
+    iParent->Console()->Printf(_L("Obex Get Complete\r\n"));
+    iObject->Reset ();
+#ifdef ASYNC_INDICATION   
+	iServerAsyncAO->CompletionIndication(CObex::EOpGet, ERespSuccess);
+#else
+	return KErrNone;
+#endif
+    }
+
+#ifdef ASYNC_INDICATION
+void CObexServerHandlerBase::SetPathIndication (const CObex::TSetPathInfo& aPathInfo, const TDesC8& /*aInfo*/)
+#else
+TInt CObexServerHandlerBase::SetPathIndication (const CObex::TSetPathInfo& aPathInfo, const TDesC8& /*aInfo*/)
+#endif
+    {
+    iParent->Console()->Printf(_L("Obex SetPath request:\r\n"));
+    iParent->Console()->Printf(_L("   --- Flags = '%d' - Constants = '%d' - "), aPathInfo.iFlags, aPathInfo.iConstants);
+    if (aPathInfo.iNamePresent)
+		iParent->Console()->Printf(_L("Name = %S\r\n"), &aPathInfo.iName);
+	else
+		iParent->Console()->Printf(_L("> No Name Present <\r\n"));
+
+    iParent->Console()->Printf(_L("\nReturning success...!\n"));
+#ifdef ASYNC_INDICATION
+	iServerAsyncAO->CompletionIndication(CObex::EOpSetPath, ERespSuccess);
+#else
+	return (KErrNone);
+#endif
+    }
+
+void CObexServerHandlerBase::AbortIndication ()
+    {
+    iParent->Console()->Printf(_L("Obex Operation aborted\r\n"));
+    if(iObject)
+		{
+		if(!iObject->BytesReceived())
+		    return;
+		iParent->Console()->Printf(_L("\r\nWe have received part of an Obex object\r\n\r\n"));
+
+		iObject->Reset();//closes file handle
+		}
+    }
+
+void CObexServerHandlerBase::MoraoReadActivity()
+	{
+    iParent->Console()->Printf(_L("Obex Server: 'Read Activity' signalled\r\n"));
+	}
+	
+void CObexServerHandlerBase::SetUpGetObjectL(CObexBaseObject *aRequestedObject)
+	{
+	TFileName name;
+	name = iParent->iInboxRoot;
+	name.Append(aRequestedObject->Name ());
+	if(name.Length())
+		{
+		iParent->Console()->Printf(_L("Obex Get Request for name '%s'\r\n"), name.PtrZ ());
+		}
+	else if (aRequestedObject->Type().Length())
+		{
+		name = iParent->iInboxRoot;
+		TBuf<32> temp;
+		temp.Copy(aRequestedObject->Type());
+		name.Append(temp);
+		iParent->Console()->Printf(_L("Obex Get Request for type '%s'\r\n"), name.PtrZ ());
+		TInt pos;
+		while((pos=name.Locate('/')) >= 0)
+			name[pos] = '_';
+		pos=name.Length()-1;
+		if(pos>=0 && name[pos] == 0)
+			name.SetLength(pos); // Work around last character possibly being NULL
+		}
+	else
+		{
+		iParent->Console()->Printf(_L("Obex Get Request unknown details\r\n"));
+		User::Leave(KErrNotSupported);
+		}
+	iObject->Reset();
+
+	RFs fs;
+	RFile f;
+	if ((fs.Connect () != KErrNone) || 
+		(f.Open (fs, name, EFileShareReadersOnly | EFileRead) != KErrNone))
+		{
+		iParent->Console()->Printf(_L("\r\nError reading '%S'."), &name);
+		User::Leave(KErrNotFound);
+		}
+
+	TInt size = 0;
+	User::LeaveIfError(f.Size (size));
+	iBuf->ResizeL(size);
+	TPtr8 data (iBuf->Ptr(0));
+	f.Read (data);
+	if (iBuf->Size() < size)
+		User::Leave(KErrGeneral);
+	iObject->SetNameL(name);
+	iObject->SetLengthL(size);
+	TTime time;
+	if (f.Modified(time) == KErrNone)
+		iObject->SetTimeL(time);
+	}
+
+void CObexServerHandlerBase::EnableAuthentication()
+	{
+	TRAPD(err, iServer->SetChallengeL(iChallengePassword));
+	if (err == KErrNone)
+		{
+		iIsAuthenticationEnabled = ETrue;
+		}
+	else
+		{
+		iParent->iConsole->Printf(_L("Failed to set authentication password\r\n"));
+		}
+	}
+
+void CObexServerHandlerBase::DisableAuthentication()
+	{
+	iServer->ResetChallenge();
+	iIsAuthenticationEnabled = EFalse;
+	}
+
+void CObexServerHandlerBase::EnablePassword()
+	{
+	iServer->SetCallBack(*this);
+	}
+
+void CObexServerHandlerBase::ChangeChallengePassword(TDesC* aPassword)
+	{
+	if (aPassword)
+		iChallengePassword = *aPassword;
+	else
+		iParent->SetPassword(iChallengePassword);
+
+	if (iIsAuthenticationEnabled)
+		{
+		DisableAuthentication();
+		EnableAuthentication();
+		}
+	}
+
+void CObexServerHandlerBase::ChangeResponsePassword()
+	{
+	iParent->Cancel();
+	iParent->SetPassword(iResponsePassword);
+	iParent->RequestCharacter(); // re-request, to re-display menu
+	}
+
+void CObexServerHandlerBase::GetUserPasswordL(const TDesC& aUserID)
+	{
+	iParent->Console()->Printf(_L("\r\nServer has been challenged by %S"), &aUserID);
+	ChangeResponsePassword(); //get the password from user
+	iServer->UserPasswordL(iResponsePassword);
+	}
+
+void CObexServerHandlerBase::SetLocalWho()
+	{
+	iServer->SetLocalWho(KRefTarget);
+	}
+
+#ifdef ASYNC_INDICATION
+void CObexServerHandlerBase::CancelIndicationCallback()
+	{
+	iServerAsyncAO->Cancel();
+	}
+#endif
+
+#ifdef PACKET_ACCESS_EXTENSION	
+void CObexServerHandlerBase::PacketAccessUiL(TBool aEnable)
+	{
+	if (aEnable)
+		{
+		iPacketAccessUi = CObexServerPacketAccessUi::NewL(*this, *iServer);
+		}
+	else
+		{
+		delete iPacketAccessUi;
+		iPacketAccessUi = NULL;
+		}
+	}
+#endif // PACKET_ACCESS_EXTENSION
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverhandlerbase.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,137 @@
+// 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 _SERVERHANDLERBASE_H
+#define _SERVERHANDLERBASE_H
+
+
+#include <es_sock.h>
+#include <e32test.h>
+#include <es_prot.h>
+#include <e32cons.h>
+#include <obex.h>
+#include <btmanclient.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obex/internal/obexinternalconstants.h>
+#include <btsdp.h>
+#include <obexfinalpacketobserver.h>
+#include <obexreadactivityobserver.h>
+#include "constants.h"
+
+class CServerAsyncAO;
+class CActiveConsole;
+class CObexServerPacketAccessUi;
+
+
+class CObexServerHandlerBase : public CBase,
+#ifdef ASYNC_INDICATION
+							   private MObexServerNotifyAsync, 
+#else
+							   private MObexServerNotify,
+#endif						   							   
+							   public MObexAuthChallengeHandler,
+							   
+							   public MObexReadActivityObserver
+//-----------------------------------------------------------
+	{
+public:
+	// Construction
+	void BaseConstructL(TTransport aTransport);
+
+	void Start();
+	void Stop();
+	// Destruction
+	virtual ~CObexServerHandlerBase();
+
+	void EnableAuthentication();
+	void DisableAuthentication();
+	void EnablePassword();
+	void ChangeChallengePassword(TDesC* aPassword = NULL);
+	void ChangeResponsePassword();
+	void SetLocalWho();
+    void SetTargetChecking(CObexServer::TTargetChecking aValue);
+	void GetUserPasswordL(const TDesC& aUserID);
+	void RemoteAddress();
+#ifdef PACKET_ACCESS_EXTENSION
+	void PacketAccessUiL(TBool aEnable);
+#endif // PACKET_ACCESS_EXTENSION
+	
+protected:
+	CObexServerHandlerBase(CActiveConsole* aParent);
+
+private:
+	// Implementation of MObexServerNotify interface
+	virtual void ErrorIndication (TInt aError);
+	virtual void TransportUpIndication ();
+	virtual void TransportDownIndication ();
+	
+	virtual void ObexDisconnectIndication (const TDesC8& aInfo);
+	virtual TInt PutPacketIndication ();
+	virtual TInt GetPacketIndication ();
+	virtual void AbortIndication ();
+
+	
+#ifdef ASYNC_INDICATION
+	void GetCompleteIndication ();
+	void PutCompleteIndication ();
+	void SetPathIndication (const CObex::TSetPathInfo& aPathInfo, const TDesC8& aInfo);
+	void CancelIndicationCallback();
+	void ObexConnectIndication  (const TObexConnectInfo& aRemoteInfo, const TDesC8& aInfo);
+	void PutRequestIndication ();
+	void GetRequestIndication (CObexBaseObject *aRequestedObject);
+#else
+	TInt ObexConnectIndication  (const TObexConnectInfo& aRemoteInfo, const TDesC8& aInfo);
+	TInt GetCompleteIndication ();
+	TInt PutCompleteIndication ();
+	TInt SetPathIndication (const CObex::TSetPathInfo& aPathInfo, const TDesC8& aInfo);
+	CObexBufObject* PutRequestIndication ();
+	CObexBufObject* GetRequestIndication (CObexBaseObject *aRequestedObject);
+#endif
+
+	// Implementation of MObexReadActivityObserver interface
+	void MoraoReadActivity();
+	void SetUpGetObjectL(CObexBaseObject *aRequestedObject);
+	void HandleGetReferenceObjL(CObexBaseObject* aRequiredObject);
+	
+	void InitBluetoothL();
+
+public:
+	TBuf<16> iChallengePassword;
+	TBuf<16> iResponsePassword;
+	TBool iAcceptPuts;
+
+protected:
+	CObexBufObject*  iObject;
+	CBufFlat* iBuf;
+	CActiveConsole* iParent;
+
+private:
+	CObexServer*  iServer;
+	TBool iIsAuthenticationEnabled;
+	TTransport iTransportLayer;
+	CSdpAttrValueDES* iProtDescList;
+	RSdp iSdp;
+	RSdpDatabase iSdpdb;
+#ifdef ASYNC_INDICATION
+	CServerAsyncAO* iServerAsyncAO;
+#endif
+#ifdef PACKET_ACCESS_EXTENSION	
+	CObexServerPacketAccessUi* iPacketAccessUi;
+#endif // PACKET_ACCESS_EXTENSION
+
+	TTime iStartTime;
+	};
+
+#endif // _SERVERHANDLERBASE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverhandlerfile.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,110 @@
+// 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 <es_sock.h>
+#include <ir_sock.h>
+#include <bautils.h>
+#include <usbman.h>
+#include <d32usbc.h>
+#include "serverhandlerbase.h"
+#include "serverhandlerfile.h"
+#include "TOBEXCON.H"
+#include "btextnotifiers.h"
+
+#define EPOCIDENT _L8("EPOC32 ER5")
+
+
+CObexServerHandlerFile::CObexServerHandlerFile(CActiveConsole* aParent)
+	: CObexServerHandlerBase(aParent)
+    {
+    }
+
+CObexServerHandlerFile* CObexServerHandlerFile::NewL(CActiveConsole* aParent, TTransport aTransport, TBool aUseRFile)
+    {
+    CObexServerHandlerFile* self = new (ELeave) CObexServerHandlerFile(aParent);
+
+    CleanupStack::PushL(self);
+    self->ConstructL(aTransport, aUseRFile);
+    CleanupStack::Pop();
+    return (self);
+    }
+
+void CObexServerHandlerFile::ConstructL(TTransport aTransport, TBool aUseRFile)
+    {
+    BaseConstructL(aTransport);
+    
+    iUseRFile = aUseRFile;
+   
+    iBuf = CBufFlat::NewL(10);//Was 5000, reduced to force more writes to file
+
+	// Required to configure buffer for memory backed file writes
+	iBuf->ResizeL(10); //was 5000
+
+	// New style construction
+	iObject = CObexBufObject::NewL(NULL);
+
+	if(!iUseRFile)
+		{
+		iBuffering = ETrue;
+
+		iObject->SetDataBufL(static_cast<const TDesC>(KFileName), iBuf);		
+		}
+	else
+		{
+		//Create the RFile to be used
+		User::LeaveIfError(iFs.Connect());
+		iFs.Delete(KRFileTestFileName); //Try deleting the file, in case it wasn't cleaned up previously.
+		User::LeaveIfError(iFile.Create(iFs,KRFileTestFileName,EFileWrite));
+		iParent->Console()->Printf(_L("\r\nCreated RFile '%S'\r\n"),&KRFileTestFileName);
+		
+		//Create a TObexRFileBackedBuffer object
+		TObexRFileBackedBuffer details(*iBuf,iFile,CObexBufObject::ESingleBuffering);
+	
+		//Call CObexBufObject::SetDataBuf
+		iObject->SetDataBufL(details);	
+		}
+
+	iParent->Console()->Printf(_L("\r\nStarting server\r\n"));
+	}
+
+CObexServerHandlerFile::~CObexServerHandlerFile ()
+    {
+	delete iObject; iObject = 0;
+    delete iBuf; iBuf = 0;
+    
+	if(iUseRFile)
+		{
+		//Clean up the RFile we created for this test
+		//File will already have been closed by obex.
+		iFs.Delete(KRFileTestFileName);
+		iFs.Close();	
+		}
+    }
+
+void CObexServerHandlerFile::ToggleWriteBuffering()
+	{
+	iBuffering = !iBuffering;
+	
+	if (iBuffering)
+		{
+		iParent->Console()->Printf(_L("Enabling buffering...\r\n"));
+		iObject->SetDataBufL(static_cast<const TDesC>(KFileName), iBuf);//Qualified
+		}
+	else
+		{
+		iParent->Console()->Printf(_L("Disabling buffering...\r\n"));
+		iObject->SetDataBufL(static_cast<const TDesC>(KFileName));//Qualified
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverhandlerfile.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,56 @@
+// 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 _SERVERHANDLERFILE_H
+#define _SERVERHANDLERFILE_H
+
+#include <es_sock.h>
+#include <e32test.h>
+#include <es_prot.h>
+#include <e32cons.h>
+#include <obex.h>
+#include <btmanclient.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obex/internal/obexinternalconstants.h>
+#include <btsdp.h>
+#include <obexfinalpacketobserver.h>
+
+class CActiveConsole;
+
+class CObexServerHandlerFile : public CObexServerHandlerBase
+//-----------------------------------------------------------
+	{
+public:
+	// Construction
+	static CObexServerHandlerFile* NewL(CActiveConsole* aParent, TTransport aTransport, TBool aUseRFile=EFalse);
+	void ConstructL(TTransport aTransport, TBool aUseRFile);
+	~CObexServerHandlerFile();
+	
+	void ToggleWriteBuffering();
+
+private:
+	CObexServerHandlerFile(CActiveConsole* aParent);
+
+private:
+	TBool iUseRFile;
+	RFs iFs;
+	RFile iFile;
+	TBool iBuffering;
+	};
+
+
+
+
+#endif // _SERVERHANDLERFILE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverpacketaccessui.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,456 @@
+// 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 "serverpacketaccessui.h"
+
+#include <e32cons.h>
+#include <obex/extensionapis/obexserverpacketaccessextension.h>
+#include <obexserver.h>
+#include <obexheaders.h>
+#include "serverhandlerbase.h"
+
+
+CObexServerPacketAccessUi* CObexServerPacketAccessUi::NewL(CObexServerHandlerBase& aHandler, CObexServer& aServer)
+	{
+	CObexServerPacketAccessUi* self = new (ELeave) CObexServerPacketAccessUi(aHandler, aServer);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+CObexServerPacketAccessUi::~CObexServerPacketAccessUi()
+	{
+	Cancel();
+	
+	delete iPacketAccess;
+	delete iConsole;
+	}
+
+CObexServerPacketAccessUi::CObexServerPacketAccessUi(CObexServerHandlerBase& aHandler, CObexServer& aServer)
+	: CActive(EPriorityNormal), iHandler(aHandler), iServer(aServer)
+	{
+	CActiveScheduler::Add(this);
+	}
+	
+void CObexServerPacketAccessUi::ConstructL()
+	{	
+	TRAPD(err, iConsole = Console::NewL(_L("Request Packets"),TSize(50,40)));
+	if (err != KErrNone)
+		{
+		TRAPD(err, iConsole = Console::NewL(_L("Request Packets"),TSize(50,15)));
+		if (err != KErrNone)
+			{
+			// we had a problem creating the console, probably because it was too big
+			// so try again and make it full screen. If we leave this time then just
+			// go with it.
+			iConsole = Console::NewL(_L("Request Packets"),TSize(KConsFullScreen,KConsFullScreen));
+			}
+		}
+	iPacketAccess = CObexServerPacketAccessExtension::NewL(iServer, *this);
+	
+	SetKeypressActive();
+	}
+	
+void CObexServerPacketAccessUi::RunL()
+	{
+    TRAPD(err, ProcessKeyPressL(TChar(iConsole->KeyCode())));
+	if(err != KErrNone)
+		{
+		iConsole->Printf(_L("Error: %d\r\n"),err);
+		}
+	SetKeypressActive();
+	}
+
+void CObexServerPacketAccessUi::DoCancel()
+	{
+	iConsole->ReadCancel();
+	}
+	
+void CObexServerPacketAccessUi::SetKeypressActive()
+	{
+	iConsole->Read(iStatus); 
+	SetActive();
+	}
+	
+void CObexServerPacketAccessUi::ProcessKeyPressL(TChar aChar)
+	{
+	if (aChar == EKeyEscape)
+		{
+		iHandler.PacketAccessUiL(EFalse);
+		return;
+		}
+
+	switch (aChar)
+		{
+		case 'E': case 'e': // Enable
+			{
+			delete iPacketAccess;
+			iPacketAccess = CObexServerPacketAccessExtension::NewL(iServer, *this);
+			}
+			break;
+		case 'D': case 'd': // Disable
+			{
+			delete iPacketAccess;
+			iPacketAccess = NULL;
+			}
+			break;
+		case 'I': case 'i': // Interactive mode toggle
+			{
+			iInteractive = !iInteractive;
+			}
+			break;
+		default:
+			{
+			iConsole->Printf(_L("Invalid Key - valid keys 'e','d','i','Esc'\r\n"));
+			}
+			break;
+		}
+	}
+	
+TBool CObexServerPacketAccessUi::RequestPacket(TObexRequestCode aRequest, TObexResponse& aResponse)
+	{
+	TBool requestPacketResult(ETrue);
+	
+	iConsole->Printf(_L("Request code %d\r\n"), aRequest);
+	
+	// Use Packet Headers now
+	CObexHeaderSet* headerSet = NULL;
+	iServer.PacketHeaders(headerSet);
+	if (headerSet)
+		{
+		// Ensures that if the function leaves then the only option is to 
+		// report a false operation.  As RequestPacket function signiture is published partner
+		TRAPD(err,PrintHeadersL(*headerSet));
+		if (err != KErrNone)
+			{
+			requestPacketResult = EFalse;						
+			}
+		delete headerSet;
+		}
+	
+	if (requestPacketResult)
+		{
+		requestPacketResult = RequestPacketReturn(aResponse);
+		}
+		
+	// Provide function result to caller	
+	return requestPacketResult;
+	}
+	
+TBool CObexServerPacketAccessUi::RequestPacket(TObexRequestCode aRequest, TObexConnectInfo& aConnectInfo, TObexResponse& aResponse)
+	{
+	TBool requestPacketResult(ETrue);
+	
+	iConsole->Printf(_L("Request code %d - Connect\r\n"), aRequest);
+	iConsole->Printf(_L("\tMajor version=%d, Minor version=%d\r\n"), aConnectInfo.VersionMajor(), aConnectInfo.VersionMinor());
+	iConsole->Printf(_L("\tConnection flags=0x%02x\r\n"), aConnectInfo.iFlags);
+	if (aConnectInfo.iWho.Length() > 0)
+		{
+		iConsole->Printf(_L("\tWho attribute=%S\r\n"), &(aConnectInfo.iWho));
+		}
+	if (aConnectInfo.iTargetHeader.Length() > 0)
+		{
+		iConsole->Printf(_L("\tTarget header=%S\r\n"), &(aConnectInfo.iTargetHeader));
+		}
+		
+	// Use Packet Headers now
+	CObexHeaderSet* headerSet = NULL;
+	iServer.PacketHeaders(headerSet);
+	if (headerSet)
+		{
+		// Ensures that if the function leaves then the only option is to 
+		// report a false operation.  As RequestPacket function signiture is published partner
+		TRAPD(err,PrintHeadersL(*headerSet));
+		if (err != KErrNone)
+			{
+			requestPacketResult = EFalse;						
+			}
+		delete headerSet;
+		}
+			
+	if (requestPacketResult)
+		{
+		requestPacketResult = RequestPacketReturn(aResponse);
+		}
+		
+	// Provide function result to caller
+	return requestPacketResult;
+	}
+	
+TBool CObexServerPacketAccessUi::RequestPacket(TObexRequestCode aRequest, CObex::TSetPathInfo& aSetPathInfo, TObexResponse& aResponse)
+	{
+	TBool requestPacketResult(ETrue);
+			
+	iConsole->Printf(_L("Request code %d - SetPath\r\n"), aRequest);
+	iConsole->Printf(_L("\tParent=%d\r\n"), aSetPathInfo.Parent());
+	iConsole->Printf(_L("\tSetPath flags=0x%02x, constants=0x%02x\r\n"), aSetPathInfo.iFlags, aSetPathInfo.iConstants);
+	if (aSetPathInfo.iNamePresent)
+		{
+		iConsole->Printf(_L("\tDestination directory=%S\r\n"), &(aSetPathInfo.iName));
+		}
+	
+	// Use Packet Headers now
+	CObexHeaderSet* headerSet = NULL;
+	iServer.PacketHeaders(headerSet);
+	if (headerSet)
+		{
+		// Ensures that if the function leaves then the only option is to 
+		// report a false operation.  As RequestPacket function signiture is published partner
+		TRAPD(err,PrintHeadersL(*headerSet));
+		if (err != KErrNone)
+			{
+			requestPacketResult = EFalse;						
+			}
+		delete headerSet;
+		}
+	
+	if (requestPacketResult)
+		{
+		requestPacketResult = RequestPacketReturn(aResponse);
+		}
+	
+	// Provide function result to caller
+	return requestPacketResult; 
+	}
+	
+TBool CObexServerPacketAccessUi::RequestPacketReturn(TObexResponse& aResponse)
+	{
+	if (iInteractive)
+		{
+		TKeyCode key(EKeyNull);
+		TBuf<2> buf;
+		aResponse = ERespBadRequest; 
+		
+		Cancel(); // cancel getting key presses will in "submenu"
+		
+		iConsole->Printf(_L("Adandon Packet? (y/n) "));
+		while (key != 'y' && key != 'Y' && key != 'n' && key != 'N')
+			{
+			key = iConsole->Getch();
+			}
+		iConsole->Printf(_L("%c"),key);
+		if (key == 'n' || key == 'N')
+			{
+			SetKeypressActive(); // reactivate key handling
+			iConsole->Printf(_L("\r\n"));
+			return ETrue;
+			}
+		
+		// If here then we are abandoning the packet
+		iConsole->Printf(_L("\r\nResponse to send? 0x"));
+		
+		while ((key = iConsole->Getch()) != EKeyEnter)
+			{
+			if (key == EKeyBackspace && buf.Length()!=0)
+				{
+				buf.SetLength(buf.Length()-1);
+				}
+			else if( buf.Length() < buf.MaxLength())
+				{
+				buf.Append(key);
+				}
+			else 
+				continue;
+			iConsole->Printf(_L("%c"),key);
+			}
+		iConsole->Printf(_L("\r\n"));
+		
+		TLex lex(buf);
+		TUint value;
+		TInt lex_err = lex.Val(value, EHex); 
+		
+		if(lex_err == KErrNone)
+			{
+			aResponse = static_cast<TObexResponse>(value);
+			}
+		else 
+			{
+			iConsole->Printf(_L("Input parsing failed, use ERespBadRequest as default response\r\n"));
+			}
+		SetKeypressActive(); // reactivate key handling
+		return EFalse;
+		}
+	else
+		{
+		return ETrue;
+		}
+	}
+	
+CConsoleBase& CObexServerPacketAccessUi::Console() const
+	{
+	return *iConsole;
+	}
+	
+void CObexServerPacketAccessUi::PrintHeadersL(CObexHeaderSet& aHeaderSet) const
+	{
+	CObexHeader* header = CObexHeader::NewL();
+	CleanupStack::PushL(header);
+	
+	aHeaderSet.First();
+	TInt err(aHeaderSet.This(header));
+	if (err == KErrNone)
+		{
+		iConsole->Printf(_L("Packet header contents...\r\n"));
+		}
+	while (err == KErrNone)
+		{
+		// get the next header
+		err = aHeaderSet.This(header);
+		if (err != KErrNone)
+			{
+			break;
+			}
+		
+		PrintHeader(*header);
+		
+		err = aHeaderSet.Next();
+		}
+		
+	CleanupStack::PopAndDestroy(header);
+	}
+	
+void CObexServerPacketAccessUi::PrintHeader(CObexHeader& aHeader) const
+	{
+		// appropriately print the header
+		iConsole->Printf(_L("\tHI: %d\r\n"),aHeader.HI());
+		
+		CObexHeader::THeaderType type = aHeader.Type();
+		switch(type)
+			{
+			case CObexHeader::EUnicode:
+				{
+				const TDesC16& headerdes = aHeader.AsUnicode();
+				const TUint8* bytes = reinterpret_cast<const TUint8*>(headerdes.Ptr());
+				PrintHex(bytes, headerdes.Size());
+				}		
+				break;
+			case CObexHeader::EByteSeq:
+				{
+				const TDesC8& headerbyteseq = aHeader.AsByteSeq();
+				PrintHex(headerbyteseq.Ptr(), headerbyteseq.Size());
+				}
+				break;
+			case CObexHeader::EByte:
+				{
+				const TUint8 headerbyte = aHeader.AsByte();
+				PrintHex(&headerbyte, 1);
+				}
+				break;
+			case CObexHeader::EFourByte:
+				{
+				const TUint32 headerbytes = aHeader.AsFourByte();
+				const TUint8* bytes = reinterpret_cast<const TUint8*>(&headerbytes);
+				PrintHex(bytes, 4);
+				}
+				break;
+			default:
+				// panic here maybe??
+				break;
+			}
+	}
+	
+void CObexServerPacketAccessUi::PrintHex(const TUint8* aPtr, TInt aLength) const
+	{
+	// local constants
+	const TUint32 widthC = 8;
+	_LIT(KPrintHexByte, "%02x ");
+	_LIT(KPrintHexTab, "\t");
+	_LIT(KPrintHexChar, "%c ");
+	_LIT(KPrintHexNonchar, ". ");
+	_LIT(KPrintHexNewline, "\r\n");
+	_LIT(KPrintHex2Spaces, "  ");
+	_LIT(KPrintHex3Spaces, "   ");
+	
+	// function begins...
+	TInt length = 0;
+	TUint32 cursor = 0;
+	
+	TUint8 printArray[widthC];
+	
+	while (length < aLength)
+		{
+		printArray[cursor] = *aPtr;
+		
+		// move along.
+		aPtr++;
+		length++;
+		cursor = length % widthC;
+		
+		if (cursor == 0)
+			{
+			// we have a full array so print it.
+			iConsole->Printf(KPrintHexTab());
+			for (TUint i=0;i<widthC;i++)
+				{
+				iConsole->Printf(KPrintHexByte(),printArray[i]);
+				}
+			iConsole->Printf(KPrintHexTab());
+			for (TUint i=0;i<widthC;i++)
+				{
+				TUint8 c = printArray[i];
+				if (c >= 32 && c <= 126)
+					{
+					iConsole->Printf(KPrintHexChar(), c);
+					}
+				else
+					{
+					iConsole->Printf(KPrintHexNonchar());
+					}
+				}
+			iConsole->Printf(KPrintHexNewline());
+			}
+		}
+		
+		// if we haven't completely finished a set -> finish it
+		if (cursor > 0)
+			{
+			iConsole->Printf(KPrintHexTab());
+			for (TUint i=0;i<widthC;i++)
+				{
+				if (i >= cursor)
+					{
+					iConsole->Printf(KPrintHex3Spaces());
+					}
+				else
+					{
+					iConsole->Printf(KPrintHexByte(),printArray[i]);
+					}
+				}
+			iConsole->Printf(KPrintHexTab());
+			for (TUint i=0;i<widthC;i++)
+				{
+				if (i >= cursor)
+					{
+					iConsole->Printf(KPrintHex2Spaces());
+					}
+				else
+					{
+					TUint8 c = printArray[i];
+					if (c >= 32 && c <= 126)
+						{
+						iConsole->Printf(KPrintHexChar(), c);
+						}
+					else
+						{
+						iConsole->Printf(KPrintHexNonchar());
+						}
+					}
+				}
+			iConsole->Printf(KPrintHexNewline());
+			}
+			
+		// should be printed now
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverpacketaccessui.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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 _SERVERPACKETACCESSUI_H
+#define _SERVERPACKETACCESSUI_H
+
+#include <e32base.h>
+#include <obex/extensionapis/mobexserverrequestpacketnotify.h>
+
+
+class CObexServerHandlerBase;
+class CConsoleBase;
+class CObexServerPacketAccessExtension;
+class CObexServer;
+
+
+NONSHARABLE_CLASS(CObexServerPacketAccessUi) : public CActive, MObexServerRequestPacketNotify
+	{
+	
+public:
+	static CObexServerPacketAccessUi* NewL(CObexServerHandlerBase& aHandler, CObexServer& aServer);
+	~CObexServerPacketAccessUi();
+	
+	void SetKeypressActive();
+	CConsoleBase& Console() const;
+
+private:	
+	// MObexServerRequestPacketNotify
+	virtual TBool RequestPacket(TObexRequestCode aRequest, TObexResponse& aResponse);
+	virtual TBool RequestPacket(TObexRequestCode aRequest, TObexConnectInfo& aConnectInfo, TObexResponse& aResponse);
+	virtual TBool RequestPacket(TObexRequestCode aRequest, CObex::TSetPathInfo& aSetPathInfo, TObexResponse& aResponse);
+
+private:
+	CObexServerPacketAccessUi(CObexServerHandlerBase& aHandler, CObexServer& aServer);
+	void ConstructL();
+	
+	void RunL();
+	void DoCancel();
+	
+	void ProcessKeyPressL(TChar aChar);
+	
+	void PrintHeadersL(CObexHeaderSet& aHeaderSet) const;
+	void PrintHeader(CObexHeader& aHeader) const;
+	void PrintHex(const TUint8* aPtr, TInt aLength) const;
+	
+	TBool RequestPacketReturn(TObexResponse& aResponse);
+
+private:
+	CObexServerHandlerBase& iHandler;
+	CObexServer& iServer;
+
+	CConsoleBase* iConsole;
+	CObexServerPacketAccessExtension* iPacketAccess;
+	
+	TBool iInteractive;
+	
+	};
+
+
+#endif // _SERVERPACKETACCESSUI_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/group/BLD.INF	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,17 @@
+// 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
+ObexBtRfcommTransportController.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/group/ObexBtRfcommTransportController.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,56 @@
+// 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:
+// ObexBtRfcommTransportController.dll Part of the Obex BT RFCOMM 
+// Controller plugin, used to control the RFCOMM transport.
+// ObexBtRfcommTransportController.rsc Part of the Obex BT RFCOMM 
+// Controller plugin, used to control the RFCOMM transport.
+// 
+//
+
+/**
+ @file
+*/
+
+TARGET			obexbtrfcommtransportcontroller.dll //Recommended unpaged
+TARGETTYPE		PLUGIN
+// UID2 = 0x10009d8d for ECOM plugins.
+// UID3 = the 'DLL UID' (see resource file)
+UID             0x10009d8d 0x1020E043
+VENDORID		0x70000001
+CAPABILITY		All -Tcb
+
+SOURCEPATH		../src
+SOURCE			ObexBtRfcommImpCollection.cpp
+SOURCE			ObexBtRfcommTransportController.cpp
+SOURCE			ObexActiveRfcommConnector.cpp
+SOURCE			ObexListenerRfcommConnector.cpp
+SOURCE			ObexRfcommConnector.cpp
+
+START RESOURCE	1020E043.rss
+target obexbtrfcommtransportcontroller.rsc
+END
+
+USERINCLUDE		../inc
+USERINCLUDE		../../common
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+LIBRARY			euser.lib 
+LIBRARY			obexcommontransport.lib
+LIBRARY			esock.lib
+LIBRARY 		bluetooth.lib
+
+NOEXPORTLIBRARY
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/inc/ObexActiveRfcommConnector.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#ifndef OBEXACTIVERFCOMMCONNECTOR_H
+#define OBEXACTIVERFCOMMCONNECTOR_H
+
+#include <e32base.h>
+#include <bt_sock.h>
+
+class MConnectObserver;
+
+/**
+Simple active object to call Connect on a socket. Only one Connect operation 
+may be outstanding at any time. 
+*/
+NONSHARABLE_CLASS(CObexActiveRfcommConnector) : public CActive
+	{
+public:
+	CObexActiveRfcommConnector(MConnectObserver& aParent,
+		RSocketServ& aSocketServ,
+		RSocket& aSocket,
+		const TProtocolDesc& aProtocolDesc,
+		const TBTSockAddr& aAddr);
+	~CObexActiveRfcommConnector();
+
+public:
+	void ConnectL();
+
+private: // from CActive
+	void RunL();
+	void DoCancel();
+
+private: // unowned
+	MConnectObserver& iParent;
+	RSocketServ& iSocketServ;
+	RSocket& iSocket;
+	const TProtocolDesc& iProtocolDesc;
+	const TBTSockAddr& iAddr;
+	};
+
+#endif // OBEXACTIVERFCOMMCONNECTOR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/inc/ObexBtRfcommTransportController.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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 __OBEXBTRFCOMMTRANSPORTCONTROLLER_H__
+#define __OBEXBTRFCOMMTRANSPORTCONTROLLER_H__
+
+#include <obex/transport/obextransportcontrollerbase.h>
+
+/**
+@internalComponent
+Transport Controller for the transport BT RFCOMM
+*/
+NONSHARABLE_CLASS(CObexBtRfcommTransportController) : public CObexTransportControllerBase
+	{
+public:
+	static CObexBtRfcommTransportController* NewL(TObexTransportInfo& aTransportInfo);
+	~CObexBtRfcommTransportController();
+	
+private: // from CObexTransportControllerBase
+	void DoRemoteAddr(TSockAddr& aAddr);
+	void NewTransportL(TObexConnectionInfo& aInfo);
+	TBool DoIsTransportRestartable() const;
+	TUint16 GetReceivePacketDataLimit();
+	void DoProcess(CObexPacket& aPacket);
+	void DoError(TInt aError);
+	void DoTransportUp(TObexConnectionInfo& aInfo);
+	
+private:
+	CObexBtRfcommTransportController();
+	void ConstructL(TObexTransportInfo& aTransportInfo);
+	};
+
+#endif // __OBEXBTRFCOMMTRANSPORTCONTROLLER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/inc/ObexListenerRfcommConnector.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,56 @@
+// 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 OBEXLISTENERRFCOMMCONNECTOR_H
+#define OBEXLISTENERRFCOMMCONNECTOR_H
+
+#include <e32base.h>
+#include <bt_sock.h>
+
+class MConnectObserver;
+
+/**
+Simple Active Object to call Accept for a socket. Only one accept operation 
+may be outstanding at any time. It has its own listening socket. 
+*/
+NONSHARABLE_CLASS(CObexListenerRfcommConnector) : public CActive
+	{
+public:
+	CObexListenerRfcommConnector(MConnectObserver& aParent,
+		RSocketServ& aSocketServ,
+		RSocket& aSocket,
+		const TProtocolDesc& aProtocolDesc,
+		TBTSockAddr& aAddr);
+	~CObexListenerRfcommConnector();
+	
+public:
+	void AcceptL();
+
+private: // from CActive
+	void RunL();
+	void DoCancel();
+
+private: // unowned
+	MConnectObserver& iParent;
+	RSocketServ& iSocketServ;
+	RSocket& iSocket;
+	const TProtocolDesc& iProtocolDesc;
+	TBTSockAddr& iAddr;
+					
+private: // owned
+	RSocket iListeningSocket;
+	};
+
+#endif // OBEXLISTENERRFCOMMCONNECTOR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/inc/ObexRfcommConnector.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,65 @@
+// 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 OBEXRFCOMMCONNECTOR_H
+#define OBEXRFCOMMCONNECTOR_H
+
+#include <bt_sock.h>
+#include <obex/transport/obexconnector.h>
+#include "connectobserver.h"
+
+class CObexActiveRfcommConnector;
+class CObexListenerRfcommConnector;
+class MObexTransportNotify;
+class TObexBtTransportInfo;
+
+NONSHARABLE_CLASS(CObexRfcommConnector) : public CObexConnector,
+											public MConnectObserver
+	{
+public:
+	static CObexRfcommConnector* NewL(MObexTransportNotify& aOwner, 
+						 TBTSockAddr& aAddr);
+	~CObexRfcommConnector();
+
+public:
+	RSocket& GetSocket();
+
+private: 
+	CObexRfcommConnector(MObexTransportNotify& aOwner, 
+						 TBTSockAddr& aAddr);
+	void ConstructL();
+	
+private: // from CObexConnector
+	void ConnectL();
+	void CancelConnect();
+	void AcceptL();
+	void CancelAccept();
+	TBool BringTransportDown();
+	void SignalTransportError();
+	
+private: // from MConnectObserver
+	void ConnectComplete(TInt aError, TObexConnectionInfo& aSockinfo);
+
+private: // owned
+	CObexActiveRfcommConnector* iConnector;
+	CObexListenerRfcommConnector* iReceiver;
+	TBool iTransportUp;
+	RSocket iSocket;
+	RSocketServ iSocketServ;
+	TBTSockAddr& iAddr;
+	TProtocolDesc iProtocolDesc;
+	};
+
+#endif // OBEXRFCOMMCONNECTOR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/inc/connectobserver.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+// Interface for notification of the completion of a connect request.
+// 
+//
+
+/**
+ @file
+*/
+
+#ifndef CONNECTOBSERVER_H
+#define CONNECTOBSERVER_H
+
+#include <e32base.h>
+
+class TObexConnectionInfo;
+
+class MConnectObserver
+	{
+public:
+	/** A connect request has completed with the given error. If this is 
+	KErrNone, aSockinfo will hold connection information. */
+	virtual void ConnectComplete(TInt aError, TObexConnectionInfo& aSockinfo) = 0;
+	};
+
+#endif // CONNECTOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/inc/obexbtfaults.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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 __OBEXBTFAULTS_H
+#define __OBEXBTFAULTS_H
+
+/**
+@file
+
+This file contains bt specific panics internal to obex
+@internalComponent
+*/
+
+enum TObexBtFaultCode
+	{
+	EActiveRfcommConnInternalError = 0,
+	EListRfcommInternalError = 1,
+	ERfcommConnectorInternalError = 2,
+	ERfcommTcInternalError = 3,
+	};
+
+#endif // __OBEXBTFAULTS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/src/1020E043.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -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 <ecom/registryinfo.rh>
+#include <obex/transport/obextransport.hrh>
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = 0x1020E043;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = KObexTransportInterfaceUid;
+			implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x1020E044;
+					version_no = 1;
+					display_name = "ObexBtRfcomm";
+					default_data = "RFCOMM";
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/src/ObexActiveRfcommConnector.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#include <obex/transport/obexconnector.h>
+#include "ObexActiveRfcommConnector.h"
+#include "connectobserver.h"
+#include "logger.h"
+#include "obexbtfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "RFCOMM");
+#endif
+
+#ifdef _DEBUG
+_LIT(KPanicCat, "ActiveRfcommConn");
+#endif
+
+CObexActiveRfcommConnector::CObexActiveRfcommConnector(MConnectObserver& aParent,
+													   RSocketServ& aSocketServ,
+													   RSocket& aSocket,
+													   const TProtocolDesc& aProtocolDesc,
+													   const TBTSockAddr& aAddr)
+ :	CActive(EPriorityStandard),
+	iParent(aParent),
+	iSocketServ(aSocketServ),
+	iSocket(aSocket),
+	iProtocolDesc(aProtocolDesc),
+	iAddr(aAddr)
+	{
+	LOG_FUNC
+	LOG(_L8("\taAddr:"));
+	LOGHEXDESC(aAddr);
+
+	CActiveScheduler::Add(this);
+	}
+
+CObexActiveRfcommConnector::~CObexActiveRfcommConnector()
+	{
+	LOG_FUNC
+
+	Cancel();
+	}
+
+void CObexActiveRfcommConnector::RunL()
+	{
+	LOG_LINE
+	LOG_FUNC
+	LOG1(_L8("\tiStatus = %d"), iStatus.Int());
+
+	// This exists purely as a sanity-check on our internal state.
+	__ASSERT_DEBUG(iSocket.SubSessionHandle(), PANIC(KPanicCat, EActiveRfcommConnInternalError));
+
+	TObexConnectionInfo sockinfo;
+	if ( iStatus == KErrNone )
+		{
+		sockinfo.iSocketType = TObexConnectionInfo::ESocketStream;
+		
+		TPckgBuf<TUint> optBuf(65535); //If all else fails we should get a max 64K buffer
+		iSocket.GetOpt(KRFCOMMMaximumMTU, KSolBtRFCOMM, optBuf);
+
+		// Set socket buffer sizes based on negotiated MTU
+		iSocket.SetOpt(KSOSendBuf, KSOLSocket, optBuf);
+		iSocket.SetOpt(KSORecvBuf, KSOLSocket, optBuf);		
+		}
+	else
+		{
+		iSocket.Close();
+		}
+
+	iParent.ConnectComplete(iStatus.Int(), sockinfo);
+	}
+
+void CObexActiveRfcommConnector::DoCancel()
+	{
+	LOG_FUNC
+
+	// This exists purely as a sanity-check on our internal state.
+	__ASSERT_DEBUG(iSocket.SubSessionHandle(), PANIC(KPanicCat, EActiveRfcommConnInternalError));
+	iSocket.CancelConnect();
+	iSocket.Close();
+	}
+
+void CObexActiveRfcommConnector::ConnectL()
+	{
+	LOG_FUNC
+
+	__ASSERT_DEBUG(!iSocket.SubSessionHandle(), PANIC(KPanicCat, EActiveRfcommConnInternalError));
+	LEAVEIFERRORL(iSocket.Open(iSocketServ, 
+							   iProtocolDesc.iAddrFamily,
+							   iProtocolDesc.iSockType, 
+							   iProtocolDesc.iProtocol));
+
+	// iAddr is logically const, and needs constness casting away for this 
+	// API.
+	iSocket.Connect(const_cast<TBTSockAddr&>(iAddr), iStatus);
+	SetActive();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/src/ObexBtRfcommImpCollection.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,30 @@
+// 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 <ecom/ecom.h>
+#include <ecom/implementationproxy.h>
+#include "ObexBtRfcommTransportController.h"
+
+const TImplementationProxy ObexTCImplementationTable[] =
+	{
+	IMPLEMENTATION_PROXY_ENTRY(0x1020E044, CObexBtRfcommTransportController::NewL),
+	};
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+	{
+	aTableCount = sizeof(ObexTCImplementationTable) / sizeof(TImplementationProxy);
+
+	return ObexTCImplementationTable;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/src/ObexBtRfcommTransportController.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,163 @@
+// 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 <obexbttransportinfo.h>
+#include <obex/transport/obexactivereader.h>
+#include <obex/transport/obexactivewriter.h>
+#include "ObexBtRfcommTransportController.h"
+#include "ObexRfcommConnector.h"
+#include "logger.h"
+#include "obexbtfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "RFCOMM");
+#endif
+
+#ifdef _DEBUG
+_LIT(KPanicCat, "BtRfcommTc");
+#endif
+
+/**
+Constructs a CObexBtRfcommTransportController object.
+@return Ownership of a new CObexIrdaTtpTransportController object.
+*/
+CObexBtRfcommTransportController* CObexBtRfcommTransportController::NewL(TObexTransportInfo& aTransportInfo)
+	{
+	LOG_STATIC_FUNC_ENTRY
+
+	CObexBtRfcommTransportController* self = new(ELeave) CObexBtRfcommTransportController;
+	CleanupStack::PushL(self);
+	self->ConstructL(aTransportInfo);
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+/** Constructor.
+*/
+CObexBtRfcommTransportController::CObexBtRfcommTransportController()
+	:CObexTransportControllerBase()
+	{
+	LOG_FUNC
+	}
+
+/** 2nd phase construction.
+*/
+void CObexBtRfcommTransportController::ConstructL(TObexTransportInfo& aTransportInfo)
+	{
+	LOG_FUNC
+
+	// It's important in the current implementation to do these these in 
+	// roughly this order. We pass the address part of the base class's 
+	// transport info by reference to the connector and thence to the 
+	// listener. If the user has specified RFCOMM 'passive auto bind' then 
+	// just updating the address in the listener will update the transport 
+	// controller base's transport info for later query by the user. Using 
+	// references saves having to add functions to achieve a manual update of 
+	// the data.
+	iTransportInfo = new(ELeave) TObexBtTransportInfo;
+	Mem::Copy(iTransportInfo, &aTransportInfo, sizeof(TObexBtTransportInfo));
+	TObexBtTransportInfo* btTransportInfo = static_cast<TObexBtTransportInfo*>(iTransportInfo);
+	iConnector = CObexRfcommConnector::NewL(*this, btTransportInfo->iAddr);
+	}
+
+/** Destructor.
+*/
+CObexBtRfcommTransportController::~CObexBtRfcommTransportController()
+	{
+	LOG_FUNC
+	}
+	
+/**
+Gets the socket associated with the connector and asks the socket for its  remote name. 
+This can be cast to the appropriate TSockAddr-derived class (TBTSockAddr for BT). 
+*/
+void CObexBtRfcommTransportController::DoRemoteAddr(TSockAddr& aAddr)
+	{
+	LOG_FUNC
+	LOG(_L8("\taAddr:"));
+	LOGHEXDESC(aAddr);
+
+	__ASSERT_DEBUG(iConnector, PANIC(KPanicCat, ERfcommTcInternalError));
+	RSocket& socket = static_cast<CObexRfcommConnector*>(iConnector)->GetSocket();
+	socket.RemoteName(aAddr);
+	}
+	
+TBool CObexBtRfcommTransportController::DoIsTransportRestartable() const	
+	{
+	LOG_FUNC
+
+	return ETrue;
+	}
+
+TUint16 CObexBtRfcommTransportController::GetReceivePacketDataLimit() 
+	{
+	LOG_FUNC
+	
+	// Set initial "software throttle" for packets (how big OBEX says they are)
+	__ASSERT_DEBUG(iTransportInfo, PANIC(KPanicCat, ERfcommTcInternalError));
+	TUint16 receivePacketDataLimit = iTransportInfo->iReceiveMtu;
+	return receivePacketDataLimit;
+	}
+	
+/**
+Creates the reader and writer and constructs the packets
+@param aInfo Connection info to pass to active reader/writer classes
+*/	
+void CObexBtRfcommTransportController::NewTransportL(TObexConnectionInfo& aInfo)
+	{
+	LOG_FUNC
+
+	__ASSERT_DEBUG(iConnector, PANIC(KPanicCat, ERfcommTcInternalError));
+	RSocket& socket = static_cast<CObexRfcommConnector*>(iConnector)->GetSocket();
+	iActiveReader = CObexActiveReader::NewL(*this, socket, aInfo);
+	iActiveWriter = CObexActiveWriter::NewL(*this, socket, aInfo);
+	}
+	
+//From MObexTransportNotify
+/**
+Process the received packet
+@param aPacket Packet to process
+*/
+void CObexBtRfcommTransportController::DoProcess(CObexPacket &aPacket)
+	{
+	LOG_FUNC
+
+	CObexTransportControllerBase::DoProcess(aPacket);
+	}
+	
+/**
+Calls base implementation
+Future proofing against BC breaks
+@param aError Error code
+*/
+void CObexBtRfcommTransportController::DoError(TInt aError) 
+	{
+	LOG_FUNC
+	LOG1(_L8("\taError = %d"), aError);
+
+	CObexTransportControllerBase::DoError(aError);
+	}
+	
+/**
+Calls base implementation
+Future proofing against BC breaks
+@param aInfo Connection info to pass to active reader/writer classes
+*/
+void CObexBtRfcommTransportController::DoTransportUp(TObexConnectionInfo& aInfo) 
+	{
+	LOG_FUNC
+
+	CObexTransportControllerBase::DoTransportUp(aInfo);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/src/ObexListenerRfcommConnector.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,138 @@
+// 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 <obex/transport/obexconnector.h>
+#include "ObexListenerRfcommConnector.h"
+#include "connectobserver.h"
+#include "logger.h"
+#include "obexbtfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "RFCOMM");
+#endif
+
+#ifdef _DEBUG
+_LIT(KPanicCat, "ListRfcomm");
+#endif
+
+CObexListenerRfcommConnector::CObexListenerRfcommConnector(MConnectObserver& aParent,
+														   RSocketServ& aSocketServ,
+														   RSocket& aSocket,
+														   const TProtocolDesc& aProtocolDesc,
+														   TBTSockAddr& aAddr)
+ :	CActive(EPriorityStandard),
+	iParent(aParent),
+	iSocketServ(aSocketServ),
+	iSocket(aSocket),
+	iProtocolDesc(aProtocolDesc),
+	iAddr(aAddr)
+	{
+	LOG_FUNC
+	LOG(_L8("\taAddr:"));
+	LOGHEXDESC(aAddr);
+
+	CActiveScheduler::Add(this);
+	}
+
+CObexListenerRfcommConnector::~CObexListenerRfcommConnector()
+	{
+	LOG_FUNC
+
+	Cancel();
+
+	// iListeningSocket will only have been open if there was a request 
+	// outstanding, in which case it will have been closed in DoCancel, so no 
+	// need to do it here.
+	__ASSERT_DEBUG(!iListeningSocket.SubSessionHandle(), PANIC(KPanicCat, EListRfcommInternalError));
+	}
+
+void CObexListenerRfcommConnector::RunL()
+	{
+	LOG_LINE
+	LOG_FUNC
+	LOG1(_L8("\tiStatus = %d"), iStatus.Int());
+
+	// These exists purely as sanity-checks on our internal state.
+	__ASSERT_DEBUG(iSocket.SubSessionHandle(), PANIC(KPanicCat, EListRfcommInternalError));
+	__ASSERT_DEBUG(iListeningSocket.SubSessionHandle(), PANIC(KPanicCat, EListRfcommInternalError));
+
+	TObexConnectionInfo sockinfo;
+	if ( iStatus == KErrNone )
+		{
+		sockinfo.iSocketType = TObexConnectionInfo::ESocketStream;
+
+		TPckgBuf<TUint> optBuf(65535); //If all else fails we should get a max 64K buffer
+		iSocket.GetOpt(KRFCOMMMaximumMTU, KSolBtRFCOMM, optBuf);
+
+		// Set socket buffer sizes based on negotiated MTU
+		iSocket.SetOpt(KSOSendBuf, KSOLSocket, optBuf);
+		iSocket.SetOpt(KSORecvBuf, KSOLSocket, optBuf);		
+		}
+	else
+		{
+		iSocket.Close();
+		}
+
+	iListeningSocket.Close();
+	iParent.ConnectComplete(iStatus.Int(), sockinfo);
+	}
+
+void CObexListenerRfcommConnector::DoCancel()
+	{
+	LOG_FUNC
+
+	// These exist purely as sanity-checks on our internal state.
+	__ASSERT_DEBUG(iSocket.SubSessionHandle(), PANIC(KPanicCat, EListRfcommInternalError));
+	__ASSERT_DEBUG(iListeningSocket.SubSessionHandle(), PANIC(KPanicCat, EListRfcommInternalError));
+	iListeningSocket.CancelAccept();
+	iListeningSocket.Close();
+	iSocket.Close();
+	}
+
+void CObexListenerRfcommConnector::AcceptL()
+	{
+	LOG_FUNC
+
+	__ASSERT_DEBUG(!iSocket.SubSessionHandle(), PANIC(KPanicCat, EListRfcommInternalError));
+
+	__ASSERT_DEBUG(!iListeningSocket.SubSessionHandle(), PANIC(KPanicCat, EListRfcommInternalError));
+	LEAVEIFERRORL(iListeningSocket.Open(iSocketServ,
+										iProtocolDesc.iAddrFamily,
+										iProtocolDesc.iSockType,
+										iProtocolDesc.iProtocol));
+	CleanupClosePushL(iListeningSocket);
+
+	LEAVEIFERRORL(iListeningSocket.Bind(iAddr));
+	if ( iAddr.Port() == KRfcommPassiveAutoBind )
+		{
+		const TUint port = iListeningSocket.LocalPort();
+		LOG1(_L8("\tKRfcommPassiveAutoBind was specified- really using port %d"), port);
+		// This updates the concrete transport controller's iTransportInfo member (by reference).
+		iAddr.SetPort(port);
+		}
+	// We try to set the Object Transfer bit in our service class.  If this fails we
+	// ignore it, as it's better to carry on without it than to fail to start listening.
+	(void)iListeningSocket.SetOpt(KBTRegisterCodService, KSolBtRFCOMM, EMajorServiceObjectTransfer);
+	LEAVEIFERRORL(iListeningSocket.Listen(4)); // queue size of 4
+
+	// NB Client does SDP & Sec registration.
+
+	LEAVEIFERRORL(iSocket.Open(iSocketServ));
+
+	CleanupStack::Pop(&iListeningSocket);
+
+	iListeningSocket.Accept(iSocket, iStatus);
+	SetActive();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/src/ObexRfcommConnector.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,176 @@
+// 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 <obex/transport/mobextransportnotify.h>
+#include <obexbttransportinfo.h>
+#include "ObexRfcommConnector.h"
+#include "ObexActiveRfcommConnector.h"
+#include "ObexListenerRfcommConnector.h"
+#include "logger.h"
+#include "obexbtfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "RFCOMM");
+#endif
+
+#ifdef _DEBUG
+_LIT(KPanicCat, "RfcommConnector");
+#endif
+
+CObexRfcommConnector* CObexRfcommConnector::NewL(MObexTransportNotify& aOwner, 
+						 TBTSockAddr& aAddr)
+	{
+	LOG_STATIC_FUNC_ENTRY
+
+	CObexRfcommConnector* self = new(ELeave) CObexRfcommConnector(aOwner, aAddr);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CObexRfcommConnector::CObexRfcommConnector(MObexTransportNotify& aObserver, 
+										   TBTSockAddr& aAddr)
+ :	CObexConnector(aObserver),
+	iAddr(aAddr)
+	{
+	LOG_FUNC
+	LOG(_L8("\taAddr:"));
+	LOGHEXDESC(aAddr);
+	}
+
+void CObexRfcommConnector::ConstructL()
+	{
+	LOG_FUNC
+
+	LEAVEIFERRORL(iSocketServ.Connect());
+	LEAVEIFERRORL(iSocketServ.FindProtocol(_L("RFCOMM"), iProtocolDesc));
+
+	iConnector = new(ELeave) CObexActiveRfcommConnector(*this, iSocketServ, iSocket, iProtocolDesc, iAddr);
+	iReceiver = new(ELeave) CObexListenerRfcommConnector(*this, iSocketServ, iSocket, iProtocolDesc, iAddr);
+
+	BaseConstructL();
+	}
+
+CObexRfcommConnector::~CObexRfcommConnector()
+	{
+	LOG_FUNC
+
+	delete iConnector;
+	delete iReceiver;
+	iSocket.Close();
+	iSocketServ.Close();
+	}
+
+void CObexRfcommConnector::ConnectL()
+	{
+	LOG_FUNC
+
+	__ASSERT_DEBUG(iConnector, PANIC(KPanicCat, ERfcommConnectorInternalError));
+	iConnector->ConnectL();
+	}
+
+void CObexRfcommConnector::CancelConnect()
+	{
+	LOG_FUNC
+
+	__ASSERT_DEBUG(iConnector, PANIC(KPanicCat, ERfcommConnectorInternalError));
+	iConnector->Cancel();
+	}
+
+void CObexRfcommConnector::AcceptL()
+	{
+	LOG_FUNC
+
+	__ASSERT_DEBUG(iReceiver, PANIC(KPanicCat, ERfcommConnectorInternalError));
+	iReceiver->AcceptL();
+	}
+
+void CObexRfcommConnector::CancelAccept()
+	{
+	LOG_FUNC
+
+	__ASSERT_DEBUG(iReceiver, PANIC(KPanicCat, ERfcommConnectorInternalError));
+	iReceiver->Cancel();
+	}
+
+TBool CObexRfcommConnector::BringTransportDown()
+	{
+	LOG_FUNC
+
+	// There's a nasty contract going on here- at most, only one of these AOs 
+	// should be active at any time. They each use this object's iSocket, 
+	// opening and closing it, and asserting its SubSessionHandle at various 
+	// points. They may be better designed as a single AO state machine.
+	__ASSERT_DEBUG(iConnector, PANIC(KPanicCat, ERfcommConnectorInternalError));
+	iConnector->Cancel();
+	__ASSERT_DEBUG(iReceiver, PANIC(KPanicCat, ERfcommConnectorInternalError));
+	iReceiver->Cancel();
+
+	// For cases where the underlying transport has gone we'll
+	// do an Immediate Shutdown to prevent Close() from blocking.
+	// This should stop dialogs from "freezing". 
+	//returns true as this transport proceeds with taking down the transport
+	if ( iTransportUp )
+		{
+		TRequestStatus status;
+		iSocket.Shutdown(RSocket::EImmediate, status);
+		User::WaitForRequest(status);
+		iTransportUp = EFalse;
+		}
+
+	iSocket.Close();
+	return ETrue;
+	}
+
+/** Used to set any link layer specific error condition flags. Bluetooth has 
+none, so the function is a stub. */
+void CObexRfcommConnector::SignalTransportError()
+	{
+	LOG_FUNC
+	}
+	
+/**
+Returns the socket instance iSocket
+@return RSocket
+*/
+RSocket& CObexRfcommConnector::GetSocket()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return iSocket;
+	}
+	
+/**
+This method is used to field completed connections from both the active 
+connector and the listen/acceptor.
+*/
+void CObexRfcommConnector::ConnectComplete(TInt aError, TObexConnectionInfo& aSockinfo)
+	{
+	LOG_FUNC
+	LOG1(_L8("\taError = %d"), aError);
+
+	if ( aError == KErrNone )
+		{
+		Observer().TransportUp(aSockinfo);
+		iTransportUp = ETrue;
+		}
+	else
+		{
+		Observer().Error(aError);
+		__ASSERT_DEBUG(!iTransportUp, PANIC(KPanicCat, ERfcommConnectorInternalError));
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/group/BLD.INF	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+ @file
+*/
+
+PRJ_EXPORTS
+
+// Files intended for 3rd party use go into \epoc32\include. (NB This includes 
+// files which must be presented to 3rd parties for compatibility reasons.)
+../public/mobexnotify.h				SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(mobexnotify.h)
+
+// Files which are needed or which may be needed to make a transport 
+// controller go into \epoc32\include\obex\transport.
+../public/obexactivereader.h 				SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/transport/obexactivereader.h)
+../public/obexactivewriter.h 				SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/transport/obexactivewriter.h)
+../public/mobextransportnotify.h 			SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/transport/mobextransportnotify.h)
+../public/obexconnector.h					SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/transport/obexconnector.h)
+../public/obextransportcontrollerbase.h		SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/transport/obextransportcontrollerbase.h)
+../public/obextransport.hrh					/epoc32/include/obex/transport/obextransport.hrh
+../public/ObexWriterBase.h					SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/transport/obexwriterbase.h)
+../public/ObexReaderBase.h					SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/transport/obexreaderbase.h)
+
+// Files which are internal to Symbian go into \epoc32\include\obex\internal. 
+../public/obexactiverw.h 					SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/obexactiverw.h)
+../public/obexdata.h 						SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/obexdata.h)
+../public/obexinternalheader.h 				SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/obexinternalheader.h)
+../public/obexpacket.h 						SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/obexpacket.h)
+../public/obexinternalconstants.h 			SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/obexinternalconstants.h)
+../public/obextransportconstants.h			SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/obextransportconstants.h)
+../public/mobexnotifyextend.h				SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/mobexnotifyextend.h)
+
+
+PRJ_MMPFILES
+obexcommontransport.MMP
+
+PRJ_TESTMMPFILES
+../test/headercheck/group/t_obextransportheadercheck.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/group/obexcommontransport.MMP	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,61 @@
+// 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:
+// obex common transport classes mmp file
+// ObexCommonTransport.dll Obex common transport classes
+// 
+//
+
+/**
+ @file
+*/
+
+target obexcommontransport.dll //Recommended unpaged
+
+CAPABILITY All -Tcb
+TARGETTYPE	dll
+
+uid			0x1000008d 0x1020dfff 
+
+SOURCEPATH 	../src
+SOURCE 		obextransportcontrollerbase.cpp
+SOURCE        	obexpacket.cpp
+SOURCE        	obexdata.cpp
+SOURCE 		obexinternalheader.cpp
+SOURCE 		obexconnectdata.cpp
+SOURCE         	ObexTransportUtil.cpp
+SOURCE 		obexconnector.cpp
+SOURCE        	obexactiverw.cpp
+SOURCE          mobextransportnotify.cpp
+SOURCE 		obexactivereader.cpp
+SOURCE 		obexactivewriter.cpp
+SOURCE          ObexReaderBase.cpp
+SOURCE 		ObexWriterBase.cpp
+
+// Logging functions
+SOURCE		logengine.cpp
+
+USERINCLUDE 	../inc
+USERINCLUDE		../../common
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+library			euser.lib
+library			ecom.lib
+library 		esock.lib
+
+VENDORID 0x70000001
+
+#include <comms-infras/commsdebugutility.mmh>
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/inc/ObexTransportUtil.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#ifndef __OBEXTRANSPORTUTIL_H
+#define __OBEXTRANSPORTUTIL_H
+
+#include <e32std.h>
+#include <ecom/ecom.h>
+
+//Used to push a pointer array on to the cleanup stack
+//ensuring that it will be reset and destroyed when popped
+void CleanupResetAndDestroyPushL(RImplInfoPtrArray& aArray);
+	
+#endif // __OBEXTRANSPORTUTIL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/inc/obexconnectdata.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,44 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXCONNECTDATA_H__
+#define __OBEXCONNECTDATA_H__
+
+#include <e32def.h>
+#include <obex/internal/obexdata.h>
+
+/** 
+@file
+
+TObexConnectData contains the non-standard connect information from connect and connect 
+response packets.
+*/
+NONSHARABLE_CLASS(TObexConnectData) : public TObexData
+	{
+public:
+	TObexConnectData ();
+	
+protected:
+	// Implementation of TObexData functions
+	virtual TUint16 DoTotalSize () const;	//< Total size of header
+	virtual TUint16 ParseIn (TUint8* aSource, const TUint16 aMaxSize);
+	virtual TUint16 WriteOut (TUint8* aDest, const TUint16 aMaxSize) const;
+public:
+	TUint8 iVersion;
+	TUint8 iFlags;
+	TUint16 iMaxPacketLength;
+	};
+
+#endif // __OBEXCONNECTDATA_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/inc/obextransportfaults.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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 __OBEXTRANSPORTFAULTS_H
+#define __OBEXTRANSPORTFAULTS_H
+/**
+@file 
+@internalComponent
+*/
+
+enum TObexTransportFaultCode
+	{
+	ETransportNullPointer					= 0,
+	EStringOverflow							= 1,
+	EPacketOverrun							= 2,
+	EInvalidHeaderSize						= 3,
+	EInvalidPacketSize						= 4,
+	EDataLimitLargerThanBuffer				= 5,
+	EOwnerAlreadySet						= 6,
+	};
+	
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/ObexReaderBase.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#ifndef __OBEXREADERBASE_H__
+#define __OBEXREADERBASE_H__
+
+#include <obex/internal/obexactiverw.h>
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+/**
+CObexReaderBase provides obex specific reader behaviour for concrete readers to use.  
+Derive from this class when providing a reader for a specific transport.  
+
+In a concrete reader the following things must be done:
+(a) In DoTransfer a read data transfer is issued over the reader's transport
+(b) GetMaxPacketSize must return the maximum packet size that can be received
+(c) GetInitialPacketSize must return a packet size that can be used in the event  that the packet 
+size of the packet to be read  is not yet known (for example irda and bt use the obexpacketheadersize and usb
+uses the buffer size of the packet created to receive the data)
+(d)The NewL function must call BaseConstructL().  This is future proofing in the event that the iFuture1 variable is used
+and requires initialisation
+*/
+class CObexReaderBase : public CObexActiveRW
+	{
+public:
+	IMPORT_C virtual ~CObexReaderBase();
+	
+protected:
+	IMPORT_C CObexReaderBase(TPriority aPriority, MObexTransportNotify& aOwner, TObexConnectionInfo& aInfo);
+	IMPORT_C void BaseConstructL();
+
+protected: // from CObexActiveRW
+	IMPORT_C virtual void StartTransfer (CObexPacket& aPacket);
+	IMPORT_C TBool CompleteTransfer ();
+	IMPORT_C void OnReadActivity();
+	IMPORT_C virtual void OnCompleteTransfer();
+	IMPORT_C TInt Remaining();
+	IMPORT_C TInt GetObexPacketBufferSize();
+	IMPORT_C TInt GetObexPacketHeaderSize();
+	IMPORT_C TInt GetObexPacketDataLimit();
+	/** This method issues either a read of data over the relevant  transport object.  	
+	@see NewRequest*/
+	virtual void DoTransfer () =0;
+	
+	//ExtensionPattern
+	IMPORT_C virtual TAny* GetInterface(TUid aUid);
+	/** Returns the maximum packet size that can be received */
+	virtual TInt GetMaxPacketSize() = 0;
+	
+	/** Returns a initial packet size when the packet size of iPacket is not know.  This is used
+	when determining the remaining bytes to be read. */
+	virtual TInt GetInitialPacketSize() = 0;
+
+private:
+	TBool iGotHeader;
+	TInt iTransferError;
+
+	//For future data expansion
+	TAny* iFuture1; 
+	};
+
+#endif // __OBEXREADERBASE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/ObexWriterBase.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#ifndef __OBEXWRITERBASE_H__
+#define __OBEXWRITERBASE_H__
+
+#include <obex/internal/obexactiverw.h>
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+/**
+CObexWriterBase provides obex specific writer behaviour for concrete writers to use.  
+Derive from this class when providing a writer for a specific transport.  
+
+In a concrete writer the following things must be done:
+(a)In DoTransfer a write transfer is issued over the writer's transport
+(b)The NewL function must call BaseConstructL().  This is future proofing in the event that the iFuture1 variable is used
+and requires initialisation
+*/
+class CObexWriterBase : public CObexActiveRW
+	{
+public:
+	IMPORT_C virtual ~CObexWriterBase();
+
+protected:
+	IMPORT_C CObexWriterBase(TPriority aPriority, MObexTransportNotify& aOwner, TObexConnectionInfo& aInfo);
+	IMPORT_C void BaseConstructL();
+
+protected: // from CObexActiveRW
+	IMPORT_C virtual TBool CompleteTransfer();
+	IMPORT_C virtual void OnCompleteTransfer();
+	IMPORT_C virtual void StartTransfer(CObexPacket& aPacket);
+	IMPORT_C virtual TInt Remaining();
+	/**
+	This method issues a write of data over the relevant transport object.
+	@see NewRequest
+	*/
+	virtual void DoTransfer () =0;
+
+	//ExtensionPattern
+	IMPORT_C virtual TAny* GetInterface(TUid aUid);
+
+protected: // owned
+	// For future data expansion
+	TAny* iFuture1;
+	};
+
+#endif // __OBEXWRITERBASE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/mobexnotify.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,43 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __MOBEXNOTIFY_H__
+#define __MOBEXNOTIFY_H__
+
+#include <e32std.h>
+
+class CObexPacket;
+
+/**
+@internalComponent
+
+This class is only for internal use.
+
+Originally it provided the call back interface for anything owned by CObex.
+Note:  This is an internal class which is not intended for use outside of
+the Transport<->Obex interface.  Even where access rules allow it, external
+users should not call these functions as their implementation may change.
+*/
+NONSHARABLE_CLASS(MObexNotify)
+
+	{
+public:
+	virtual void Process(CObexPacket &aPacket) =0;
+	virtual void Error(TInt aError) =0;
+	virtual void TransportUp() =0;
+	virtual void TransportDown(TBool aForceTransportDeletion) =0;
+	};
+
+#endif // __MOBEXNOTIFY_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/mobexnotifyextend.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#ifndef MOBEXNOTIFYEXTEND_H
+#define MOBEXNOTIFYEXTEND_H
+
+/**
+@file
+@released
+@internalTechnology
+*/
+
+#include <e32std.h>
+#include <mobexnotify.h>
+#include <obex/internal/obextransportconstants.h>
+
+class CObexPacket;
+/**
+Provides the call back interface for anything using CObexTransport (ie CObex).
+Note:  This is an internal class which is not intended for use outside of
+the Transport<->Obex interface.  Even where access rules allow it, external
+users should not call these functions as their implementation may change.
+*/
+NONSHARABLE_CLASS(MObexNotifyExtend) : public MObexNotify
+	{
+public:
+	// original functions as found in MObexNotify
+	virtual void Process(CObexPacket& aPacket) =0;
+	virtual void Error(TInt aError) =0;
+	virtual void TransportUp() =0;
+	
+	// This is non-pure as derivers may not care about any events so we
+	// don't want to force them into handling them.
+	virtual void SignalPacketProcessEvent(TObexPacketProcessEvent /*aEvent*/){}; 
+	};
+
+#endif // MOBEXNOTIFYEXTEND_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/mobextransportnotify.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+#ifndef __MOBEXTRANSPORTNOTIFY_H__
+#define __MOBEXTRANSPORTNOTIFY_H__
+
+#include <e32std.h>
+#include <obex/internal/obextransportconstants.h>
+
+class CObexPacket;
+struct TObexConnectionInfo;
+
+/**
+Provides the call back interface for anything owned  by CObexTransportControllerBase 
+(ie CObexConnector or CObexActiveRW derived classes).
+Note:  This is an internal class which is not intended for use outside of
+the Transport<->Connector/Reader/Writer  interface.  Even where access rules allow it, external
+users should not call these functions as their implementation may change.
+
+@publishedPartner
+@released
+*/
+NONSHARABLE_CLASS(MObexTransportNotify)
+	{
+	
+public:
+	IMPORT_C void Process(CObexPacket &aPacket) ;
+	IMPORT_C void Error(TInt aError);
+	IMPORT_C void TransportUp(TObexConnectionInfo& aInfo) ;			// Call back to start the obex sessio 
+	IMPORT_C void SignalPacketProcessEvent(TObexPacketProcessEvent aEvent);
+		
+protected:
+	virtual void DoProcess(CObexPacket &aPacket) =0;
+	virtual void DoError(TInt aError) =0;
+	virtual void DoTransportUp(TObexConnectionInfo& aInfo) =0;
+	virtual void DoSignalPacketProcessEvent(TObexPacketProcessEvent aEvent) =0;
+			
+	};
+	
+#endif // __MOBEXTRANSPORTNOTIFY_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obexactivereader.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,51 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#ifndef __OBEXACTIVEREADER_H__
+#define __OBEXACTIVEREADER_H__
+
+#include <obex/transport/obexreaderbase.h>
+
+class RSocket;
+
+/**
+Functionality specific to reading from a socket 
+@internalTechnology
+*/
+NONSHARABLE_CLASS(CObexActiveReader) : public CObexReaderBase
+	{
+public:
+	IMPORT_C static CObexActiveReader* NewL(MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo);
+	IMPORT_C ~CObexActiveReader ();
+
+private:
+	CObexActiveReader (MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo);
+
+private: // from CObexReaderBase
+	virtual void DoCancel ();
+	virtual void DoTransfer ();
+	virtual TInt GetMaxPacketSize();
+	virtual TInt GetInitialPacketSize();
+
+private:
+	RSocket& iSocket;
+	};
+
+#endif // __OBEXACTIVEREADER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obexactiverw.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,123 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXACTIVERW_H__
+#define __OBEXACTIVERW_H__
+
+/**
+@file
+@internalTechnology
+*/
+
+#include <e32def.h>
+#include <e32base.h>
+
+class MObexTransportNotify;
+struct TObexConnectionInfo;
+class CObexPacket;
+
+/**
+Base class for a specific transport's active reader and writer classes. 
+The derived classes are responsible for sending and receiving data for their 
+transport. 
+
+@see CObexReaderBase
+@see CObexWriterBase
+*/
+NONSHARABLE_CLASS(CObexActiveRW) : public CActive
+	{
+public:
+	CObexActiveRW(TPriority aP, MObexTransportNotify& aOwner, TObexConnectionInfo& aInfo);
+	~CObexActiveRW();
+	void Transfer(CObexPacket& aPacket);
+
+protected: // functions to be implemented by derived classes
+	/**
+	This method does any required initialisation of data for the transfer, 
+	including the received, aPacket, before calling NewRequest.
+	
+	@see Transfer
+	@see NewRequest(CObexPacket& aPacket)
+	@param aPacket The packet to read into or written
+	*/
+	virtual void StartTransfer(CObexPacket& aPacket) =0; //called by non virtual Transfer
+
+	/**
+	This method issues either a read or write of data over the relevant 
+	transport object. This method is called from NewRequest.
+	
+	@see NewRequest
+	*/
+	virtual void DoTransfer () =0;
+
+	/**
+	This method compares the number of bytes, iCount, read/ written, against 
+	the packet size. In the case of a write, ETrue is returned if all the 
+	bytes have been written, otherwise EFalse.
+	
+	For reads, check if the header is received and if so assign iPacketSize 
+	with the packet size indicated in the header of the received packet. Note 
+	that the claimed packet size must be greater than the required obex header 
+	size and no more than the maximum packet size this transport handles.
+	
+	@see CObexTransportControllerBase::Process()
+	@return TBool return ETrue if the transfer has completed else EFalse
+	*/
+	virtual TBool CompleteTransfer () =0; // check if packet read/write has completed
+
+	/**
+	This method is called when a transfer is complete. Any actions associated 
+	with completion of a transfer should be performed here, for instance 
+	sending the packet to the owner of the reader to be processed.
+	*/
+	virtual void OnCompleteTransfer() =0; // perform action associated with read/write completion
+
+	/**
+	Return the number bytes left to transfer
+	@return TInt the number of bytes left to be transferred
+	*/
+	virtual TInt Remaining () =0; // how much is left to transfer
+	
+	//function used by derived classes
+	void NewRequest (CObexPacket& aPacket); // start new packet send/receive
+	
+	//RunL for derived classes
+	IMPORT_C void RunL ();
+	
+// Data
+protected:
+	/**The owner of the derived reader or writer class. Required at construction.*/
+	MObexTransportNotify& iOwner;
+
+	/**The obex packet, received from the owner, that will be sent or written into iLocation.*/
+	CObexPacket* iPacket;
+	
+	/**A pointer to the iPacket buffer at the point where data is to be written 
+	from or read into. The maximum length is the remaining bytes to be read or 
+	written. Data is read from this buffer into the transport, or written from 
+	the transport into this buffer.	*/
+	TPtr8 iLocation;
+	
+	/**The number of bytes that have been read or written*/
+	TInt iCount;
+	
+	/**The size of the obex packet	*/
+	TInt iPacketSize;
+	
+	/**Is true if the transport is a packet based transport*/
+	TBool iPacketBased;
+	};
+
+#endif // __OBEXACTIVERW_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obexactivewriter.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,53 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#ifndef __OBEXACTIVEWRITER_H__
+#define __OBEXACTIVEWRITER_H__
+
+#include <obex/transport/obexwriterbase.h>
+#include <obex/transport/obexconnector.h>
+
+class RSocket;
+
+/**
+Functionality specific to writing to a socket.
+@internalTechnology
+*/
+NONSHARABLE_CLASS(CObexActiveWriter) : public CObexWriterBase
+	{
+public:
+	IMPORT_C static CObexActiveWriter* NewL(MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo);
+	IMPORT_C ~CObexActiveWriter();
+
+private:
+	CObexActiveWriter(MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo);
+
+private: // from CObexWriterBase
+	virtual void StartTransfer(CObexPacket& aPacket);
+	virtual void DoCancel();
+	virtual void DoTransfer();
+
+private:
+	TInt iTransportWriteLimit;
+	TObexConnectionInfo iInfo; // used to find out transport limits per transfer
+	RSocket& iSocket;
+	};
+
+#endif // __OBEXACTIVEWRITER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obexconnector.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,127 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Defines the interface to an obex connector
+// 
+//
+
+#ifndef __OBEXCONNECTOR_H__
+#define __OBEXCONNECTOR_H__
+
+#include <e32base.h>
+
+class MObexTransportNotify;
+
+/**
+@publishedPartner
+@released
+*/
+struct TObexConnectionInfo
+	{
+	enum TSocketType
+		{
+		ESocketPacket,
+		ESocketStream,
+		EUsbStream,
+		};
+	TSocketType iSocketType;
+	TInt iMaxSendSize;
+	TInt iMaxRecvSize;
+	};
+
+/**
+Base type for OBEX connectors
+To make an OBEX protocol connector: Derive from this class and override the 
+pure virtual functions with the relevent implementation  
+
+@publishedPartner
+@released
+*/
+class CObexConnector : public CBase
+	{
+public:
+	/**
+	This function is called as a result of an Obex client connect being 
+	issued. This function may either 
+	1. attempt to make a transport level connection with the transport level 
+	of an Obex server. For example, in the case of socket based transports, a 
+	socket is opened and a socket connect is issued. 
+	2. check that a transport link exists. For example in the case of the usb 
+	standard transport the connection may already be there
+	In both cases, if successful, the connector will notify its owner that the 
+	transport is up. Otherwise the connector may 'error' the owner or leave as 
+	appropriate.
+	 
+	@see MObexTransportNotify::TransportUp()
+	@see MObexTransportNotify::Error()
+	*/
+	virtual void ConnectL()=0;
+	
+	/**
+	This function cancels actions taken as a result of the ConnectL() request
+	@see ConnectL()
+	*/
+	virtual void CancelConnect ()=0 ;
+	
+	/**
+	This function is called as a result of an Obex server accept being issued. 
+	This function will start a transport object listening for a connect from 
+	the transport layer of an Obex client, if the transport layer has not 
+	already been established. 
+	
+	In both cases, if successful, the connector will notify its owner that the 
+	transport is up. Otherwise the connector may 'error' the owner or leave as 
+	appropriate.
+	@see MObexTransportNotify::TransportUp()
+	@see MObexTransportNotify::Error()
+	*/
+	virtual void AcceptL ()=0 ;
+	
+	/**
+	This function cancels actions taken as a result of the AcceptL() request
+	
+	@see AcceptL()
+	*/
+	virtual void CancelAccept ()=0;
+	
+	/**
+	This function takes down the transport link. If there are reasons why the 
+	transport link cannot be taken down, then the function should return 
+	EFalse. 
+	*/
+	virtual TBool BringTransportDown()=0;
+	
+	/**
+	This function is a notification from the obex protocol layer that a 
+	transport error has occured. Set any transport specific error condition 
+	flags in this function.
+	*/
+	virtual void SignalTransportError()=0;
+	
+public:
+	IMPORT_C CObexConnector(MObexTransportNotify& aObserver);
+	IMPORT_C ~CObexConnector();
+
+protected:
+	IMPORT_C virtual TAny* GetInterface(TUid aUid);
+	IMPORT_C void BaseConstructL();
+	IMPORT_C MObexTransportNotify& Observer();
+	
+private: // owned
+	TAny* iFuture1;
+
+private: // unowned
+	MObexTransportNotify& iObserver;
+	};
+
+#endif // __OBEXCONNECTOR_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obexdata.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,45 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#ifndef __OBEXDATA_H__
+#define __OBEXDATA_H__
+
+#include <e32def.h>
+
+class CObexPacket;                      // Forward
+
+/**	
+Abstraction for any struct that lives inside packet payload areas.     
+@internalTechnology
+*/
+NONSHARABLE_CLASS(TObexData)
+	{
+friend class CObexPacket;
+
+public:
+	IMPORT_C TUint16 TotalSize () const;
+
+protected:
+	virtual TUint16 DoTotalSize() const = 0;
+	virtual TUint16 ParseIn (TUint8* aSource, const TUint16 aMaxSize) =0;
+	virtual TUint16 WriteOut (TUint8* aDest, const TUint16 aMaxSize) const =0;
+	};
+
+#endif // __OBEXDATA_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obexinternalconstants.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,38 @@
+// 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:
+//
+
+#ifndef __OBEXINTERNALCONSTANTS_H
+#define __OBEXINTERNALCONSTANTS_H
+
+#include <e32def.h>
+
+/**
+@internalTechnology
+@released
+*/
+
+// Constants describing miniumum, maximum and default OBEX pakcet sizes
+// These are set to maintain backwards compatibility, so change with caution!
+
+const TUint16 KObexPacketMaxSize		= 0xffff;	// Maximum possible packet size (64kB)
+const TUint16 KObexPacketDefaultSize	= 4000;		// Fixed buffer size in previous implementations
+const TUint16 KObexPacketMinSize		= 255;		// Minimum legal size of a pakcet
+
+// ########## Constant Data ##########
+
+const TUint8  KObexPacketFinalBit 	= 0x80;		// Most signif. Bit is final flag.//used only by obexpacket
+const TUint16 KObexPacketHeaderSize		= 3;		// Head = Opcode (1) + Size (2) //this const is used all over
+
+#endif // __OBEXINTERNALCONSTANTS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obexinternalheader.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,129 @@
+// 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
+ @internalTechnology
+*/
+	
+#ifndef __OBEXINTERNALHEADER_H__
+#define __OBEXINTERNALHEADER_H__
+
+#include <e32def.h>
+#include <e32cmn.h>
+#include <obex/internal/obexdata.h>
+
+// ########## Constant Data ##########
+
+const TUint8  KObexHeaderHILongSize		= 3;		// Unicode or Byte sequence
+const TUint8  KObexHeaderHIShortSize	= 1;		// Byte of 4 byte headers
+
+/**
+Two parts to headers: header IDs (HI) and header values (HV).
+There are some strange things going on in this class, due it sourcing data 
+(HV) from either obex or epoc, and having to then either stream it obex or 
+return it to epoc. Might be tidier having a finer class hierarcy, but the 
+implemented method does allow for complete generality.
+
+Partly due to this strangeness, this is only used internally.  There is also
+a CObexHeader class which is used for the external representation of a data
+header.
+@internalTechnology
+@see CObexHeader
+*/
+NONSHARABLE_CLASS(TObexInternalHeader) : public TObexData
+
+	{
+public:
+	// Header specific types
+	typedef TUint8 THeaderID;
+	IMPORT_C enum THeaderType 
+		{ 
+		EUnicode = 0x00,
+		EByteSeq = 0x40,
+		E1Byte   = 0x80,
+		E4Byte   = 0xC0
+		};
+	
+	IMPORT_C enum TWellKnownHI
+		{
+		ECount				= 0x00 | E4Byte,
+		EName				= 0x01 | EUnicode,
+		EType				= 0x02 | EByteSeq,
+		ELength				= 0x03 | E4Byte,
+		ETime				= 0x04 | EByteSeq,
+		EDescription		= 0x05 | EUnicode,
+		ETarget				= 0x06 | EByteSeq,
+		EHttp				= 0x07 | EByteSeq,
+		EBody				= 0x08 | EByteSeq,
+		EEndOfBody			= 0x09 | EByteSeq,
+		EWho				= 0x0A | EByteSeq,
+		EConnectionID		= 0x0B | E4Byte,
+		EAppParam			= 0x0C | EByteSeq,
+		EAuthChallenge		= 0x0D | EByteSeq,
+		EAuthResponse		= 0x0E | EByteSeq,
+		ECreatorID			= 0x0F | E4Byte,
+		EWanUUID			= 0x10 | EByteSeq,
+		EObjectClass  		= 0x11 | EByteSeq
+		};
+	
+	IMPORT_C  enum THVRepresentation 
+		{ 
+		EHVObexDefault,
+		EHVMachineText,
+		EHVInt,
+		EHVDefered
+		};
+
+	IMPORT_C TObexInternalHeader ();
+
+	// Setters
+	IMPORT_C void SetHI (THeaderID aHID);
+	IMPORT_C void Set (THeaderID aHID, TInt aValue);
+	IMPORT_C void Set (THeaderID aHID, TUint8* aHV, TInt aHVSize);
+	IMPORT_C void Set (THeaderID aHID, const TDesC& aString);
+	IMPORT_C void SetDeferred (THeaderID aHID, TPtr8* aDataInserter, TInt aMinSize, TInt aMaxSize = 0);
+
+    // Getters
+	IMPORT_C THeaderID HI () const;
+	IMPORT_C THeaderType HIType () const;
+	IMPORT_C TInt HVInt () const;
+	IMPORT_C TUint8* HVByteSeq () const;
+	IMPORT_C TInt GetHVText (TDes& aString) const;
+
+	IMPORT_C TUint16 HISize () const;
+	IMPORT_C TUint16 HVSize () const;
+	
+protected:
+	// Implementation of TObexData functions
+	TUint16 DoTotalSize () const;	// Total size of header
+	virtual TUint16 ParseIn (TUint8* aSource, const TUint16 aMaxSize);
+	virtual TUint16 WriteOut (TUint8* aDest, const TUint16 aMaxSize) const;
+
+private:
+	THeaderID	iHI;
+	union
+		{
+		TUint8*	iObex;
+		TText*	iMachine;
+		TInt	iInt;
+		TPtr8*  iDefered;
+		} iHV;
+	THVRepresentation		iHVRep;
+	TUint16		iHVSize;
+	TUint16		iHVMaxSize;		// Used for defered data entry
+	};	// TObexInternalHeader
+
+#endif // __OBEXINTERNALHEADER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obexpacket.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,91 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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
+ @internalTechnology
+*/
+
+#ifndef __OBEXPACKET_H__
+#define __OBEXPACKET_H__
+
+#include <e32base.h>
+#include <obex/internal/obexinternalconstants.h>
+#include <obex/internal/obextransportconstants.h>
+#include <obextypes.h>
+
+class TObexData;
+
+/**	
+Packets, which are the basic unit transfered between CObex and the transport
+@internalTechnology
+*/ 
+NONSHARABLE_CLASS(CObexPacket) : public CBase
+	{
+friend class CObexActiveRW;
+
+public:
+	IMPORT_C ~CObexPacket ();
+	IMPORT_C static CObexPacket* NewL (TUint16 aBufferSize, TUint16 aDataLimit);
+													  
+	// Functions to set packet data
+	IMPORT_C void Init (TObexOpcode aOpcode);
+	
+	IMPORT_C TObexOpcode Opcode () const;
+	IMPORT_C void SetOpcode (TObexOpcode aOpcode);
+
+	IMPORT_C TBool IsFinal () const;
+	IMPORT_C void SetFinal (TBool aFinal = ETrue);
+	
+	// Get/Set the current packet size
+	// These refer size encoded in the OBEX packet itself (not the buffer used to contain the packet)
+    	IMPORT_C TUint16 PacketSize () const;
+	IMPORT_C void SetPacketSize (TUint16 aSize);
+
+	// Get/Set the buffer size/data limit
+	IMPORT_C TUint16 SetLegalDataLimit (TUint16 aSize);
+	IMPORT_C TUint16 DataLimit () const; 
+	IMPORT_C TUint16 BufferSize () const;
+
+	// Setters & Getters, payload
+	IMPORT_C TBool InsertData (const TObexData& aHeader);
+	IMPORT_C TBool ExtractData (TObexData& aHeader);
+	IMPORT_C TUint16 RemainingInsertSpace () const;
+	IMPORT_C TUint16 RemainingExtractSpace () const;
+	IMPORT_C void AddPacketProcessEvents(TObexPacketProcessEvents aEvents);
+	IMPORT_C void RemovePacketProcessEvents(TObexPacketProcessEvents aEvents);
+	IMPORT_C TObexPacketProcessEvents PacketProcessNotificationEvents() const;
+	IMPORT_C void Dump() const;
+
+private:
+	CObexPacket (TUint16 aBufferSize, TUint16 aDataLimit);
+	void ConstructL ();
+
+	inline const TUint8* Payload () const {return (&iBuffer[KObexPacketHeaderSize]);};
+	inline TUint8* Payload () {return (&iBuffer[KObexPacketHeaderSize]);};
+	inline TUint16 PayloadSize () const {return (STATIC_CAST(TUint16, PacketSize () - KObexPacketHeaderSize));};
+
+
+// Data
+private:
+	TUint16 iBufferSize;	// how big the buffer actually is
+	TUint16 iDataLimit;		// how large the data can be (usually set per conenction)
+	TUint8* iInsertPoint;
+	TUint8* iExtractPoint;
+	TUint8* iBuffer;
+	TObexPacketProcessEvents iNotificationEvents;
+	};	// CObexPacket
+	
+#endif // __OBEXPACKET_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obextransport.hrh	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+// Definition of interface UID for OBEX transport controller plugins.
+// Definition of interface UID for OBEX transport controller plugins.
+// 
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+#define KObexTransportInterfaceUid 0x10208755
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obextransportconstants.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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 __OBEXTRANSPORTCONSTANTS_H__
+#define __OBEXTRANSPORTCONSTANTS_H__
+
+/**
+@file
+@internalTechnology
+*/
+
+#include <e32base.h>
+
+const TUint8 KObexConnectionIDLength = 4;
+
+typedef TBuf8<KObexConnectionIDLength> TConnId;
+typedef TBuf8<16> TRequestDigest;
+
+/**
+This enum is for INTERNAL USE ONLY.
+
+The enum values are signals sent between layers in OBEX. Some of them result 
+in user-visible notifications and some don't.
+
+Their numerical values are not significant, with the exception of the fact 
+that EObexFinalPacketStarted must have a lower numerical value than 
+EObexFinalPacketFinished. If both of these signals are outstanding on a packet 
+at once, the user will be notified in numerical-value order. The 'final packet 
+observer' API requires that the signals are given to the user in the order 
+'final packet started' then 'final packet finished'. 
+
+These are to be used as fields in a bitmask, so a value must always bit set.
+*/
+enum TObexPacketProcessEvent
+	{
+	/** The transport layer has started to write a final packet. */
+	EObexFinalPacketStarted = 0x1,
+
+	/** The transport layer has finished writing a final packet. */
+	EObexFinalPacketFinished = 0x2,
+
+	/** A packet has finished being written. */
+	EObexWriteCompleted = 0x4,
+	
+	/** A packet has finished being written. This is signalled upwards by the 
+	transport layer last of all	because it signals the completion of the 
+	sending of an ACK to a disconnect command. The OBEX server uses this 
+	signal to progress the disconnection. */
+	EObexWriteCompletedFinal = 0x8,
+	
+	/** Read activity has been detected. This is signalled upwards by the 
+	transport layer AT LEAST when the first read of a new Obex operation 
+	is detected.	*/
+	EObexReadActivityDetected = 0x10,
+	};
+
+typedef TUint TObexPacketProcessEvents;
+
+#endif //__OBEXTRANSPORTCONSTANTS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obextransportcontrollerbase.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,145 @@
+// 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 __OBEXTRANSPORTCONTROLLERBASE_H__
+#define __OBEXTRANSPORTCONTROLLERBASE_H__
+
+#include <e32base.h>
+#include <obex/transport/mobextransportnotify.h>
+#include <obex/transport/obexconnector.h>
+#include <obex/internal/obextransportconstants.h>
+#include <obex/transport/obextransport.hrh>
+#include <obextypes.h>
+
+class CObexPacket;
+class MObexNotifyExtend;
+class TSockAddr;
+class CObexActiveRW;
+class TObexTransportInfo;
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+/**
+Interface UID for transport controllers.
+Transport controllers are instantiations of this interface.
+*/
+const TInt KObexTransportControllerInterfaceUid = KObexTransportInterfaceUid;
+
+/**
+Abstraction for transport controller implementations. Defines an interface to 
+be used by Obex protocol layer as the facade to the transport layer.
+
+In a concrete transport controller's NewL, the following things must be done: 
+(a) CObexTransportControllerBase::iConnector must be assigned to a 
+CObexConnector-derived type. (This may be reliant on the TObexTransportInfo 
+object passed in at this time.) iConnector is owned by 
+CObexTransportControllerBase.
+(b) CObexTransportControllerBase::iTransportInfo must be assigned to a 
+persistent (i.e. heap-based) TObexTransportInfo or derived type. The derived 
+transport controller may cast the TObexTransportInfo given at construction 
+time to a known derived type and copy the data from it to the new instance on 
+the heap. Note that ownership of the given TObexTransportInfo *remains with 
+the client*. iTransportInfo is then owned by CObexTransportControllerBase.
+
+In a concrete transport controller's NewTransportL, two instances of types 
+derived from CObexActiveRW must be created, and stored in 
+CObexTransportControllerBase::iActiveReader and 
+CObexTransportControllerBase::iActiveWriter. CObexTransportControllerBase owns 
+these.
+*/
+class CObexTransportControllerBase : public CBase, public MObexTransportNotify
+	{
+public:
+	IMPORT_C static CObexTransportControllerBase* NewL(TObexTransportInfo& aTransportInfo);
+	IMPORT_C ~CObexTransportControllerBase();
+	
+public:
+	IMPORT_C void SetOwner(MObexNotifyExtend& aOwner);
+
+	//delegated to activerw class
+	IMPORT_C CObexPacket& SendPacket () ;	//< Access packet buffers
+	IMPORT_C CObexPacket& ReceivePacket ();
+	IMPORT_C void Send ();						//< Actually carry out transfer
+	IMPORT_C void Send (TObexOpcode aOpcode);	//< Prepare and send a 3 byte packet
+	IMPORT_C void Receive ();
+	
+	IMPORT_C TBool IsWriteActive () const;				//< is the ActiveWriter busy
+	IMPORT_C TInt InsertLocalConnectInfo (CObexPacket &aPacket, TUint8 aVersion, TUint8 aFlags);
+	IMPORT_C TBool ExtractRemoteConnectInfo (CObexPacket &aPacket, TUint8& aVersion, TUint8& aFlags);
+	IMPORT_C void CancelTransfers();
+	
+	//delegated to connector class
+	IMPORT_C void ConnectL ();
+	IMPORT_C void CancelConnect();
+	IMPORT_C void AcceptConnectionL();
+	IMPORT_C void CancelAccept();
+	IMPORT_C TBool  BringTransportDown();
+	IMPORT_C void SignalTransportError();
+	
+	//public non-virtual methods to aid preventing bc/sc breaks when the client interface changes
+	IMPORT_C void RemoteAddr(TSockAddr& aAddr);
+	IMPORT_C TBool IsTransportRestartable() const;
+	IMPORT_C const TObexTransportInfo* TransportInfo() const;
+	
+protected:
+	IMPORT_C CObexTransportControllerBase();
+
+private:
+	void BaseConstructL();
+
+private: // implemented  by derived controller 
+	virtual void DoRemoteAddr(TSockAddr& aAddr)=0;
+	virtual TBool DoIsTransportRestartable() const = 0;
+	virtual void NewTransportL(TObexConnectionInfo& aInfo) = 0;
+	virtual TUint16 GetReceivePacketDataLimit() = 0;
+	
+protected: // from MObexTransportNotify
+	IMPORT_C virtual void DoProcess(CObexPacket &aPacket);
+	IMPORT_C virtual void DoError(TInt aError);
+	IMPORT_C virtual void DoTransportUp(TObexConnectionInfo& aInfo);
+	IMPORT_C virtual void DoSignalPacketProcessEvent(TObexPacketProcessEvent aEvent);
+	
+protected:	//Extension pattern
+	IMPORT_C virtual TAny* GetInterface(TUid aUid);
+	
+private: // utility
+	void DeleteTransport();
+	void ConstructPacketsL();
+	void InitialiseTransportL(TObexConnectionInfo& aInfo);
+	void TransportUpError(TInt aError);
+
+protected: // owned
+	CObexConnector* iConnector;
+	CObexActiveRW* iActiveReader;
+	CObexActiveRW* iActiveWriter;
+	TObexConnectionInfo iConnectionInfo;
+	TObexTransportInfo* iTransportInfo;
+
+private: // unowned
+	MObexNotifyExtend* iOwner;
+
+private: // owned 
+	CObexPacket* iReceivePacket;
+	CObexPacket* iSendPacket;
+	TAny* iFuture1;
+	// Instance identifier key
+	TUid iPrivateEComUID; 
+	};
+
+#endif // __OBEXTRANSPORTCONTROLLERBASE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/ObexReaderBase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,243 @@
+// 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 <obex/transport/obexreaderbase.h>
+#include <obex/internal/obexpacket.h>
+#include <obex/transport/mobextransportnotify.h>
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+/**
+*Constructor
+*/
+EXPORT_C CObexReaderBase::CObexReaderBase(TPriority aPriority, 
+										  MObexTransportNotify& aOwner, 
+										  TObexConnectionInfo& aInfo)
+	: CObexActiveRW (aPriority, aOwner, aInfo)
+	{
+	LOG_LINE
+	LOG_FUNC
+	}
+
+/**
+* Destructor
+*/
+EXPORT_C CObexReaderBase::~CObexReaderBase()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	Cancel();
+	}
+
+/**
+This function is a place holder for future use. If the iFuture1 variable is 
+used it will need this function for any allocation required.  
+
+To prevent binary compatiblity breaks if the iFuture1 variable is used, this 
+function must be called from the 
+NewL of derived classes.  
+*/
+EXPORT_C void CObexReaderBase::BaseConstructL()
+	{
+	LOG_LINE
+	LOG_FUNC
+	}
+
+/**
+Start transfer. Calls into CObexActiveRW, which eventually queues a read 
+
+@param aPacket The Obex packet to read into.
+*/
+EXPORT_C void CObexReaderBase::StartTransfer (CObexPacket& aPacket)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	// Ensure that we don't try to queue two reads at once (this should probably
+	// never happen anyway).
+	if (IsActive())
+		{
+		FLOG(_L("\treturning because already active..."));
+		return;
+		}
+	iGotHeader = EFalse;
+	// Initial packet size indicates how much data we should ask for on the 
+	// first read
+	// Packet & stream based transports do the same thing here due to ESOCK 
+	// flexibility.
+	// See Remaining() and CompleteTransfer() for a clearer picture
+	iPacketSize = 0;
+	aPacket.Init(0);
+	NewRequest (aPacket);
+	}
+
+/**
+Check if the packet read is complete 
+@return ETrue if the read is complete.  EFalse otherwise.
+*/
+EXPORT_C TBool CObexReaderBase::CompleteTransfer ()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iTransferError = KErrNone;
+
+	// Can't check anything until we have at least the OBEX packet header
+	if (iCount >= KObexPacketHeaderSize)
+		{// iCount is the number of bytes read thus far
+		if (!iGotHeader)
+			{
+			iPacketSize = iPacket->PacketSize ();
+
+			// Check packet's claimed size is at least as big as the header just sent
+			if ( iPacketSize < KObexPacketHeaderSize )
+				{
+				iTransferError = KErrCommsFrame;
+				return ETrue;
+				}
+				TInt maxPacketSize = GetMaxPacketSize();
+				LOG1(_L8("\taMaxPacketSize = %d"), maxPacketSize);
+			if (iPacketSize > maxPacketSize)
+				{// The peer is sending us a packet thats too large for us
+				iTransferError = KErrCommsFrame;
+				return (ETrue);
+				}
+			iGotHeader = ETrue;
+			OnReadActivity();
+			}
+
+
+		if (iCount >= iPacketSize)
+			{// We've got the whole packet.
+			return (ETrue);
+			}
+		}
+	return (EFalse);
+		
+	}
+
+/** 
+	Called when read activity is detected. 
+	This method will certainly be called when read activity is 
+	first detected on an Obex operation, and it may be called 
+	from time to time thereafter until that Obex operation is
+	completed.
+*/
+EXPORT_C void CObexReaderBase::OnReadActivity()
+	{
+	iOwner.SignalPacketProcessEvent(EObexReadActivityDetected);
+	}
+
+/** Performs any actions necessary on completion of a read.
+*/
+EXPORT_C void CObexReaderBase::OnCompleteTransfer()
+	{
+	if(iTransferError)
+		{
+		iOwner.Error(iTransferError);
+		}
+	else
+		{
+		iOwner.Process(*iPacket);
+		}
+	}
+
+/*
+Returns the number of bytes remaining to be read based on the default packet 
+size if the packet size is unknown, otherwise based on the packet size
+
+@return TInt the number of bytes remaining to be read
+*/
+EXPORT_C TInt CObexReaderBase::Remaining()
+	{
+	LOG_LINE
+	LOG_FUNC
+	
+
+	TInt remaining;
+	
+	if (iPacketSize == 0)
+		{	
+		// If we don't know the size of the packet yet, ask for as much as 
+		// an initial or default size (-iCount) specifies
+		TInt defaultPacketSize = GetInitialPacketSize();
+		LOG1(_L8("\taRemainingLimit = %d"), defaultPacketSize);
+		remaining = defaultPacketSize - iCount;
+		}
+	else
+		{
+		remaining = iPacketSize - iCount;
+		}
+	
+	if (remaining < 0)
+		{
+		remaining = 0;
+		}
+	
+	return remaining;
+	}
+
+/**
+This function returns the buffer size of the read packet.  
+
+@return TInt the size of the buffer held by the iPacket member variable
+*/
+EXPORT_C TInt CObexReaderBase::GetObexPacketBufferSize()
+	{
+	return iPacket->BufferSize();
+	}
+
+/**
+This function returns the size of the obex packet's header
+
+@return TInt the size of the obex header
+*/
+EXPORT_C TInt CObexReaderBase::GetObexPacketHeaderSize()
+	{
+	return KObexPacketHeaderSize;
+	}
+
+/**
+This function return the maximum limit the received data can be
+
+@return TInt the data limit of the obex packet
+*/
+EXPORT_C TInt CObexReaderBase::GetObexPacketDataLimit()
+	{
+	return iPacket->DataLimit();
+	}
+		
+/**
+This function is part of the extension pattern and is implemented by all 
+derived instantiable classes that need to extend it's interface.
+
+By default this returns null. Any derived class that is required to extend its 
+interface and that of this base class returns its new interface in the form of 
+an M class, that it extends, if and only if  the corresponding TUid, aUid, is 
+received. Otherwise the function calls the base class implementation, 
+returning NULL.
+
+@return TAny* The M Class representing the extension to the interface 
+otherwise NULL
+@param aUid The uid associated with the M Class that is being implemented
+*/
+EXPORT_C TAny* CObexReaderBase::GetInterface(TUid /*aUid*/)
+	{
+	return NULL;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/ObexTransportUtil.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,43 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "ObexTransportUtil.h"
+#include "logger.h"
+
+/**
+Function passed in as a parameter to TCleanupItem constructor to 
+reset and destroy the received aPtr.
+
+@param aPtr a pointer to the object that is to be cleaned up
+*/
+void ResetAndDestroy(TAny* aPtr)
+	{
+	reinterpret_cast<RImplInfoPtrArray*>(aPtr)->ResetAndDestroy();
+	}
+
+/**
+Function that creates a clean up item for the received, aArray and
+specifies the cleanup function, ResetAndDestroy. When the item is 
+removed from the cleanup stack the function, ResetAndDestroy will be
+called on aArray
+
+@param aArray the array to be pushed onto the cleanup stack
+*/
+void CleanupResetAndDestroyPushL(RImplInfoPtrArray& aArray)
+   	{  	    
+	TCleanupItem item(ResetAndDestroy, &aArray);
+   	CleanupStack::PushL(item);
+   	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/ObexWriterBase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,144 @@
+// 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 <obex/transport/obexwriterbase.h>
+#include <obex/internal/obexpacket.h>
+#include <obex/transport/mobextransportnotify.h>
+#include "logger.h"
+#include "obextransportfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+#ifdef _DEBUG
+_LIT(KPanicCat, "ObexWriterBase");
+#endif
+
+/**
+Constructor
+*/
+EXPORT_C CObexWriterBase::CObexWriterBase(TPriority aPriority, 
+										  MObexTransportNotify& aOwner, 
+										  TObexConnectionInfo& aInfo)
+	: CObexActiveRW (aPriority,  aOwner, aInfo)
+	{
+	LOG_LINE
+	LOG_FUNC
+	}
+
+/**
+Destructor
+*/
+EXPORT_C CObexWriterBase::~CObexWriterBase()
+	{
+	LOG_LINE
+	LOG_FUNC
+	}
+	
+/**
+This function is a placeholder for future use. If the iFuture1 variable is 
+used it will need this function for any allocation required.
+
+To prevent binary compatiblity breaks if the iFuture1 variable is used, this 
+function must be called from the NewL of derived classes.
+*/
+EXPORT_C void CObexWriterBase::BaseConstructL()
+	{
+	LOG_LINE
+	LOG_FUNC
+	}
+
+/**
+Start transfer. Calls into CObexActiveRW, which eventaully queues a write 
+
+@param aPacket The Obex packet to write
+ */
+EXPORT_C void CObexWriterBase::StartTransfer (CObexPacket& aPacket)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iPacketSize = aPacket.PacketSize();
+	NewRequest(aPacket);
+
+	if(iPacket->IsFinal() &&
+	  (iPacket->PacketProcessNotificationEvents() & EObexFinalPacketStarted))
+		{
+		iOwner.SignalPacketProcessEvent(EObexFinalPacketStarted);
+		}
+	}
+
+/**
+Returns true if the transfer has completed
+
+@return TBool return true if the transfer if complete otherwise return false
+*/
+EXPORT_C TBool CObexWriterBase::CompleteTransfer ()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return (iCount >= iPacketSize);
+	}
+
+/** Performs any actions necessary on completion of a write.
+*/
+EXPORT_C void CObexWriterBase::OnCompleteTransfer()
+	{
+	iOwner.SignalPacketProcessEvent(EObexWriteCompleted);
+
+	if(iPacket->IsFinal() &&
+	  (iPacket->PacketProcessNotificationEvents() & EObexFinalPacketFinished))
+		{
+		iOwner.SignalPacketProcessEvent(EObexFinalPacketFinished);
+		}
+
+	// Signal this after dereferences of iPacket because it might result in 
+	// our destruction.
+	iOwner.SignalPacketProcessEvent(EObexWriteCompletedFinal);
+	}
+	
+/**
+Return number of bytes remaining to be sent	
+@return TInt number of bytes remaining to be sent
+*/
+EXPORT_C TInt CObexWriterBase::Remaining ()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	__ASSERT_DEBUG (iPacketSize >= KObexPacketHeaderSize, PANIC(KPanicCat, EInvalidPacketSize));
+	return (iPacketSize - iCount);
+	}
+
+/**
+This function is part of the extension pattern and is implemented by all 
+derived instantiable classes that need to extend its interface.
+
+By default this returns null. Any derived class that is required to extend its 
+interface and that of this base class returns its new interface in the form of 
+an M class, that it extends, if and only if the corresponding TUid, aUid, is 
+received. Otherwise the function calls the base class implementation, 
+returning NULL.
+
+@return TAny* The M Class representing the extension to the interface 
+otherwise NULL
+@param aUid The uid associated with the M Class that is being implemented
+*/	
+EXPORT_C TAny* CObexWriterBase::GetInterface(TUid /*aUid*/)
+	{
+	return NULL;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/logengine.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,355 @@
+// 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
+ @internalTechnology
+*/
+
+
+#include <e32base.h>
+#include <comms-infras/commsdebugutility.h>
+#include "logger.h"
+
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KSubsystem, "obex");
+_LIT8(KLogCmpt, "logengine");
+#endif
+
+
+NONSHARABLE_CLASS(TLogData)
+	{
+	public:
+#ifdef __FLOG_ACTIVE
+		TLogData();
+		
+		void SetLogTags(const TDesC8& aCmpt);
+
+		TInt iAccessCount;
+
+		RFileLogger iLogEngine;
+		TBuf8<KMaxTagLength> iCurrentComponent;
+#endif
+	};
+
+
+#ifdef __FLOG_ACTIVE
+TLogData::TLogData()
+	: iAccessCount(0), iCurrentComponent(KNullDesC8)
+	{}
+
+void TLogData::SetLogTags(const TDesC8& aCmpt)
+	{
+	if (aCmpt != iCurrentComponent)
+		{
+		iLogEngine.SetLogTags(KSubsystem, aCmpt.Left(KMaxTagLength));
+		iCurrentComponent = aCmpt.Left(KMaxTagLength);
+		}
+	}
+#endif
+
+#define GETLOG TLogData* __logger = static_cast<TLogData*>(Dll::Tls());
+
+
+
+EXPORT_C /*static*/ TInt CObexLog::Connect()
+	{
+#ifdef __FLOG_ACTIVE
+	GETLOG;
+	
+	if (!__logger)
+		{
+		CObexLog::Write(KLogCmpt, _L8("Opening new logger connection"));
+		__logger = new TLogData();
+		if (!__logger)
+			{
+			CObexLog::Write(KLogCmpt, _L8("Opening logger connection failed, no memory"));
+			return KErrNoMemory;
+			}
+		
+		__logger->iLogEngine.Connect();
+		Dll::SetTls(__logger);
+		}
+	
+	__logger->iAccessCount++;
+	CObexLog::WriteFormat(KLogCmpt, _L8("Opening -- %d instances now open"), __logger->iAccessCount);
+		
+	return KErrNone;
+#else
+	return KErrNotSupported;
+#endif
+	}
+
+
+EXPORT_C /*static*/ void CObexLog::Close()
+	{
+#ifdef __FLOG_ACTIVE
+	GETLOG;
+	
+	if (__logger)
+		{
+		TInt& count = __logger->iAccessCount;
+		
+		if (count)
+			{
+			count--;
+			CObexLog::WriteFormat(KLogCmpt, _L8("Closing -- %d instance(s) left open"), count);
+			if (!count)
+				{
+				__logger->iLogEngine.Close();
+				delete __logger;
+				Dll::SetTls(NULL);
+				CObexLog::Write(KLogCmpt, _L8("Fully closed and deleted, now flogging statically."));
+				}
+			}
+		else
+			{
+			CObexLog::Write(KLogCmpt, _L8("Not closing -- not opened"));
+			}
+		}
+#endif
+	}
+
+
+
+EXPORT_C /*static*/ void CObexLog::Write(const TDesC8& IF_FLOGGING(aCmpt), const TDesC8& IF_FLOGGING(aText))
+	{
+#ifdef __FLOG_ACTIVE
+	GETLOG;
+	
+	if (__logger)
+		{
+		__logger->SetLogTags(aCmpt);
+		__logger->iLogEngine.Write(aText);
+		}
+	else
+		{
+		RFileLogger::Write(KSubsystem, aCmpt, aText);
+		}
+#endif
+	}
+
+
+EXPORT_C /*static*/ void CObexLog::WriteFormat(const TDesC8& IF_FLOGGING(aCmpt), TRefByValue<const TDesC8> IF_FLOGGING(aFmt), ...)
+	{
+#ifdef __FLOG_ACTIVE
+	VA_LIST list;
+	VA_START(list, aFmt);
+
+	GETLOG;
+	
+	if (__logger)
+		{
+		__logger->SetLogTags(aCmpt);
+		__logger->iLogEngine.WriteFormat(aFmt, list);
+		}
+	else
+		{
+		RFileLogger::WriteFormat(KSubsystem, aCmpt, aFmt, list);
+		}
+#endif
+	}
+
+
+EXPORT_C /*static*/ void CObexLog::WriteFormat(const TDesC8& IF_FLOGGING(aCmpt), TRefByValue<const TDesC8> IF_FLOGGING(aFmt), VA_LIST& IF_FLOGGING(aList))
+	{
+#ifdef __FLOG_ACTIVE
+	GETLOG;
+	
+	if (__logger)
+		{
+		__logger->SetLogTags(aCmpt);
+		__logger->iLogEngine.WriteFormat(aFmt, aList);
+		}
+	else
+		{
+		RFileLogger::WriteFormat(KSubsystem, aCmpt, aFmt, aList);
+		}
+#endif
+	}
+
+
+EXPORT_C /*static*/ void CObexLog::Write(const TDesC8& IF_FLOGGING(aCmpt), const TDesC16& IF_FLOGGING(aText))
+	{
+#ifdef __FLOG_ACTIVE
+	GETLOG;
+	
+	if (__logger)
+		{
+		__logger->SetLogTags(aCmpt);
+		__logger->iLogEngine.Write(aText);
+		}
+	else
+		{
+		RFileLogger::WriteFormat(KSubsystem, aCmpt, aText);
+		}
+#endif
+	}
+
+
+EXPORT_C /*static*/ void CObexLog::WriteFormat(const TDesC8& IF_FLOGGING(aCmpt), TRefByValue<const TDesC16> IF_FLOGGING(aFmt), ...)
+	{
+#ifdef __FLOG_ACTIVE
+	VA_LIST list;
+	VA_START(list, aFmt);
+
+	GETLOG;
+	
+	if (__logger)
+		{
+		__logger->SetLogTags(aCmpt);
+		__logger->iLogEngine.WriteFormat(aFmt, list);
+		}
+	else
+		{
+		RFileLogger::WriteFormat(KSubsystem, aCmpt, aFmt, list);
+		}
+#endif
+	}
+
+
+EXPORT_C /*static*/ void CObexLog::WriteFormat(const TDesC8& IF_FLOGGING(aCmpt), TRefByValue<const TDesC16> IF_FLOGGING(aFmt), VA_LIST& IF_FLOGGING(aList))
+	{
+#ifdef __FLOG_ACTIVE
+	GETLOG;
+	
+	if (__logger)
+		{
+		__logger->SetLogTags(aCmpt);
+		__logger->iLogEngine.WriteFormat(aFmt, aList);
+		}
+	else
+		{
+		RFileLogger::WriteFormat(KSubsystem, aCmpt, aFmt, aList);
+		}
+#endif
+	}
+
+
+EXPORT_C /*static*/ void CObexLog::HexDump(const TDesC8& IF_FLOGGING(aCmpt), const TText* IF_FLOGGING(aHeader), const TText* IF_FLOGGING(aMargin), const TUint8* IF_FLOGGING(aPtr), TInt IF_FLOGGING(aLen))
+	{
+#ifdef __FLOG_ACTIVE
+	GETLOG;
+	
+	if (__logger)
+		{
+		__logger->SetLogTags(aCmpt);
+		__logger->iLogEngine.HexDump(aHeader, aMargin, aPtr, aLen);
+		}
+	else
+		{
+		RFileLogger::HexDump(KSubsystem, aCmpt, TPtrC8(aPtr, aLen), KNullDesC8);
+		}
+#endif
+	}
+
+
+
+
+
+
+
+/**
+Leave (if error) verbosely- log name of file and line number just before 
+leaving.
+@param aFile The file we're leaving from.
+@param aLine The line number we're leaving from.
+@param aReason The leave code.
+*/
+EXPORT_C void VerboseLeaveIfErrorL(const TDesC8& IF_FLOGGING(aCpt), 
+						  char* IF_FLOGGING(aFile), 
+						  TInt IF_FLOGGING(aLine), 
+						  TInt IF_FLOGGING(aReason))
+	{
+#ifdef __FLOG_ACTIVE
+	// only leave if an error value
+	if ( aReason >= KErrNone )
+		{
+		return;
+		}
+
+	_LIT8(KLeavePrefix, "LEAVE: ");
+
+	TPtrC8 fullFileName((const TUint8*)aFile);
+	TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1);
+
+	TBuf8<256> buf;
+	buf.Append(KLeavePrefix);
+	buf.AppendFormat(_L8("aReason = %d [file %S, line %d]"), aReason, &fileName, 
+		aLine);
+	CObexLog::Write(aCpt, buf);
+
+	// finally
+	User::Leave(aReason);
+#endif
+	}
+
+/**
+Panic verbosely- log name of file and line number just before panicking.
+@param aFile The file that's panicking.
+@param aLine The line number that's panicking.
+@param aReason The panic code.
+@param aPanicName The text of the panic code.
+@param aPanicCategory The panic category.
+*/
+EXPORT_C void VerbosePanic(const TDesC8& IF_FLOGGING(aCpt), 
+				  char* IF_FLOGGING(aFile), 
+				  TInt IF_FLOGGING(aLine), 
+				  TInt IF_FLOGGING(aPanicCode), 
+				  TText8* IF_FLOGGING(aPanicName),
+				  const TDesC& IF_FLOGGING(aPanicCategory))
+	{
+#ifdef __FLOG_ACTIVE
+	_LIT8(KPanicPrefix, "PANIC: code ");
+	
+	TPtrC8 fullFileName((const TUint8*)aFile);
+	TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1);
+
+	TBuf8<256> buf;
+	buf.Append(KPanicPrefix);
+	buf.AppendFormat(_L8("%d = %s [file %S, line %d]"), 
+		aPanicCode, 
+		aPanicName, 
+		&fileName, 
+		aLine);
+	CObexLog::Write(aCpt, buf);
+
+	// finally
+	User::Panic(aPanicCategory, aPanicCode);
+#endif
+	}
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KInstrumentIn, ">>%S this = [0x%08x]");
+_LIT8(KInstrumentOut, "<<%S");
+#endif
+
+EXPORT_C TFunctionLogger::TFunctionLogger(const TDesC8& IF_FLOGGING(aCpt), const TDesC8& IF_FLOGGING(aString), TAny* IF_FLOGGING(aThis))
+	{
+#ifdef __FLOG_ACTIVE
+	iCpt.Set(aCpt);
+	iString.Set(aString);
+	CObexLog::WriteFormat(iCpt, KInstrumentIn, &iString, aThis);
+#endif
+	}
+
+EXPORT_C TFunctionLogger::~TFunctionLogger()
+	{
+#ifdef __FLOG_ACTIVE
+	CObexLog::WriteFormat(iCpt, KInstrumentOut, &iString);
+#endif
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/mobextransportnotify.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,66 @@
+// 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 <obex/transport/mobextransportnotify.h>
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+/**
+Process the received packet.
+@param aPacket An obex packet.
+*/
+EXPORT_C void MObexTransportNotify::Process(CObexPacket &aPacket) 
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	DoProcess(aPacket);
+	}
+	
+/**
+Indicate that an error has occurred in the transport.
+@param aError The error that has occurred.
+*/	
+EXPORT_C void MObexTransportNotify::Error(TInt aError)
+	{
+	LOG_LINE
+	LOG_FUNC
+	LOG1(_L8("\taError = %d"), aError);
+
+	DoError(aError);		
+	}
+	
+/**
+Indicate that the transport is up.
+@param aInfo The connection info. 
+*/	
+EXPORT_C void MObexTransportNotify::TransportUp(TObexConnectionInfo& aInfo) 
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	DoTransportUp(aInfo);		
+	}
+
+/** Signals that an event related to processing the packet has occurred.
+@param aEvent The event that has occurred.
+*/	
+EXPORT_C void MObexTransportNotify::SignalPacketProcessEvent(TObexPacketProcessEvent aEvent)
+	{
+	DoSignalPacketProcessEvent(aEvent);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obexactivereader.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,113 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/obexactivereader.h>
+#include <es_sock.h>
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+/**
+Factory function.
+@param  aOwner the owner of this 
+@param aSocket  a socket for reading and writing
+@param aInfo connection information
+@return Ownership of a new active reader.
+*/
+EXPORT_C CObexActiveReader* CObexActiveReader::NewL(MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo)
+	{
+	CObexActiveReader* self = new(ELeave) CObexActiveReader(aOwner, aSocket, aInfo);
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+Constructor
+@param  aOwner the owner of this 
+@param aSocket  a socket for reading and writing
+@param aInfo connection information
+*/
+CObexActiveReader::CObexActiveReader (MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo)
+	: CObexReaderBase (EPriorityStandard, aOwner, aInfo),
+	iSocket(aSocket)
+	{
+	LOG_LINE
+	LOG_FUNC
+	}
+
+/**
+Destructor
+*/
+EXPORT_C CObexActiveReader::~CObexActiveReader ()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	Cancel ();
+	}
+
+/**
+Called to actually transfer some data into iLocation 
+*/
+void CObexActiveReader::DoTransfer ()
+	{
+	LOG_FUNC
+
+	iSocket.Recv(iLocation, KSockReadContinuation, iStatus);
+	SetActive ();
+	}
+
+/**
+Return the maximum packet size
+@return TInt the maximum packet size for this transport
+*/
+TInt CObexActiveReader::GetMaxPacketSize()
+	{
+	LOG_FUNC
+
+	// Some slightly dubious logic here...
+	// IrDA has a degenerate case when running over a 256 byte transport layer link, we claim
+	// to support <255 bytes. The Obex spec says that all stations must be able to handle
+	// 255 bytes, so some stacks may ignore our limit.
+	// Thus we compare against the actual buffer size, rather than what we told the remote end
+	// we could handle, so we *may* be able to handle being sent a few bytes more than expected...
+
+	TInt ret = GetObexPacketBufferSize();
+	LOG1(_L8("\tret = %d"), ret);
+	return ret;
+	}
+
+/**
+Returns a initial packet size when the packet size of iPacket is not know.  This is used
+when determining the remaining bytes to be read.  
+@return TInt the initial packet size
+*/
+TInt CObexActiveReader::GetInitialPacketSize ()
+	{
+	LOG_FUNC
+
+	return GetObexPacketHeaderSize();
+	}
+
+void CObexActiveReader::DoCancel ()
+	{
+	LOG_FUNC
+
+	iSocket.CancelRecv ();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obexactiverw.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,139 @@
+// 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 <obex/internal/obexactiverw.h>
+#include <obex/internal/obexpacket.h>
+#include <obex/transport/mobextransportnotify.h>
+#include <obex/transport/obexconnector.h>
+#include "ObexTransportUtil.h"
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+/**
+Constructor
+
+@param aPriority a priority
+@param aOwner the owner 
+@param aInfo connection information
+*/
+CObexActiveRW::CObexActiveRW(TPriority aPriority,
+							 MObexTransportNotify& aOwner,
+							 TObexConnectionInfo& aInfo)
+ :	CActive (aPriority), 
+	iOwner(aOwner), 
+	iLocation (NULL, 0)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	CActiveScheduler::Add (this);
+	iPacketBased = aInfo.iSocketType==TObexConnectionInfo::ESocketPacket ? ETrue : EFalse;
+	}
+
+/**
+Destructor
+*/
+CObexActiveRW::~CObexActiveRW()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	Cancel();
+	}
+
+/**
+Start a new write or read
+Reset the pointer descriptor to the start of the buffer and make the call to 
+start the transfer
+
+@param aPacket the obex packet to read or write
+*/
+void CObexActiveRW::NewRequest(CObexPacket& aPacket)
+	{
+	LOG_FUNC
+
+	iPacket = &aPacket;
+	iCount = 0;
+	// Set descriptor to start of buffer
+	// Size pointer according to either the number of bytes remaining in packet
+	// OR maximum number of bytes we can receive (see Remaining())
+	iLocation.Set(iPacket->iBuffer, 0, Remaining ());
+	DoTransfer();
+	}
+
+/*
+Non-virtual method calling virtual method StartTransfer. BC protection.
+
+@param aPacket  the obex packet to transfer
+*/
+void CObexActiveRW::Transfer(CObexPacket& aPacket)
+	{
+	LOG_FUNC
+
+	StartTransfer(aPacket);
+	}
+
+/**
+RunL called after a read/write has completed
+Check to see if we need to issue another request, otherwise process the 
+complete packet
+*/
+EXPORT_C void CObexActiveRW::RunL()
+	{
+	LOG_LINE
+	LOG_FUNC
+	LOG1(_L8("\tiStatus = %d"), iStatus.Int());
+
+/*
+	TBuf<256> hexBuf;
+	FTRACE(FPrint(_L("CObexActiveRW::RunL iLocation.Length() = %d"), iLocation.Length()));
+	for (TInt i = 0; i < iLocation.Length(); i++)
+		{
+		hexBuf.AppendFormat(_L("%02X "), iLocation[i]);
+		if ((i % 16) == 15)
+			{
+			FLOG(hexBuf);
+			hexBuf = KNullDesC;
+			}
+		}
+	FLOG(hexBuf);
+*/
+
+	// Check the request completed OK
+	if ( iStatus != KErrNone )
+		{
+		iOwner.Error(iStatus.Int());
+		return;
+		}
+
+	// Update the byte count and check to see if the transfer is complete
+	iCount += iLocation.Size();
+	if ( CompleteTransfer() )
+		{
+		// Inform interested parties
+		OnCompleteTransfer();
+		return;
+		}
+	// Otherwise update the buffer pointer and start another transfer
+	LOG1(_L8("CObexActiveRW::RunL Setting location, remaining=%d"), Remaining());
+	iLocation.Set (&iPacket->iBuffer[iCount], 0, Remaining());
+	if ( iLocation.MaxLength() > 0 )
+		{
+		DoTransfer();
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obexactivewriter.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,95 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/obexactivewriter.h>
+#include <obex/internal/obexpacket.h>
+#include <es_sock.h>
+#include <obex/transport/mobextransportnotify.h>
+#include "ObexTransportUtil.h"
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+EXPORT_C CObexActiveWriter* CObexActiveWriter::NewL(MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo)
+	{
+	CObexActiveWriter* self = new(ELeave) CObexActiveWriter(aOwner, aSocket, aInfo);
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CObexActiveWriter::CObexActiveWriter (MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo)
+ :	CObexWriterBase (EPriorityHigh, aOwner, aInfo),
+	iInfo ( aInfo ),
+	iSocket(aSocket)
+	{
+	LOG_LINE
+	LOG_FUNC
+	}
+
+EXPORT_C CObexActiveWriter::~CObexActiveWriter ()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	Cancel ();
+	}
+
+/**
+Start transfer.
+Calls into CObexActiveRW, which eventaully queues a write which is limited by 
+the smaller of iInfo's max send size and aPacket's data limit
+
+@param aPacket The Obex packet to write
+*/
+void CObexActiveWriter::StartTransfer (CObexPacket& aPacket)
+	{
+	LOG_FUNC
+
+	// Find out how much we can write to the remote end per transfer
+	iTransportWriteLimit = Min(iInfo.iMaxSendSize, aPacket.DataLimit());
+	LOG1(_L8("\tiTransportWriteLimit = %d"), iTransportWriteLimit);
+	CObexWriterBase::StartTransfer(aPacket);
+	}
+	
+
+// Called to actually transfer some data out from iLocation 
+void CObexActiveWriter::DoTransfer ()
+	{
+	LOG_FUNC
+
+	// Send the biggest chunk we can over the transport
+	if (iPacketBased && (iLocation.MaxLength () > iTransportWriteLimit))
+		{
+		iLocation.SetLength (iTransportWriteLimit);
+		}
+	else
+		{
+		iLocation.SetMax ();
+		}
+
+	iSocket.Write (iLocation, iStatus);
+	SetActive ();
+	}
+
+void CObexActiveWriter::DoCancel ()
+	{
+	LOG_FUNC
+
+	iSocket.CancelSend ();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obexconnectdata.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,49 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <es_sock.h>
+#include "obexconnectdata.h"
+
+TObexConnectData::TObexConnectData ()
+	{
+	iVersion = 0;
+	iFlags = 0x00;
+	iMaxPacketLength = 0x0000;
+	}
+
+TUint16 TObexConnectData::DoTotalSize () const
+	{
+	return (4);
+	}
+
+TUint16 TObexConnectData::ParseIn (TUint8* aSource, const TUint16 aMaxSize)
+	{
+	if (aMaxSize < TotalSize ())
+		return (0);
+	iVersion = aSource[0];
+	iFlags = aSource[1];
+	iMaxPacketLength = BigEndian::Get16 (&aSource[2]);
+	return (TotalSize ());
+	}
+
+TUint16 TObexConnectData::WriteOut (TUint8* aDest, const TUint16 aMaxSize) const
+	{
+	if (aMaxSize < TotalSize ())
+		return (0);
+	aDest[0] = iVersion;
+	aDest[1] = iFlags;
+	BigEndian::Put16 (&aDest[2], iMaxPacketLength);
+	return (TotalSize ());
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obexconnector.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,78 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/obexconnector.h>
+
+/**
+This function is a placeholder for future use. If iFuture1 variable is 
+used it will need this function for any allocation required.
+
+To prevent binary compatibility breaks if the iFuture1 variable is used, 
+this function must be called from the NewL of derived classes.
+*/
+EXPORT_C void CObexConnector::BaseConstructL()
+	{
+	}
+
+/**
+This function is part of the extension pattern and must be implemented by 
+all derived instantiable classes.
+By default this returns null.  Any derived class that is required to 
+extend its interface and that of this base class returns its new interface 
+in the form of an M class, that it extends, if and only if  the 
+corresponding TUid, aUid, is received. Otherwise the function calls the 
+base class implementation, returning NULL.
+
+@return TAny* The M Class representing the extension to the interface 
+otherwise NULL
+@param  aUid The uid associated with the M Class that is being implemented
+@publishedPartner
+@released
+*/		
+EXPORT_C TAny* CObexConnector::GetInterface(TUid /*aUid*/)
+	{
+	return NULL;
+	}
+
+/** Constructor.
+@param aObserver The MObexTransportNotify object to notify of 
+transport-related events. This object will typically be the concrete 
+CObexTransportControllerBase.
+*/
+EXPORT_C CObexConnector::CObexConnector(MObexTransportNotify& aObserver)
+:	iObserver(aObserver)
+	{
+	}
+
+/**
+Destructor.
+Currently does no work (NB BaseConstructL currently does no work either). If 
+BaseConstructL ever allocates memory into iFuture1, we'll need to free it 
+here. But by then licensee connectors' vtables will already have been 
+built, *pointing at CBase's destructor*. We need this destructor here so 
+that iFuture1, if it's ever allocated, will be freed correctly.
+*/
+EXPORT_C CObexConnector::~CObexConnector()
+	{
+	}
+
+/** Accessor for the observer (an MObexTransportNotify).
+@return The MObexTransportNotify to notify of transport-related events.
+*/
+EXPORT_C MObexTransportNotify& CObexConnector::Observer()
+	{
+	return iObserver;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obexdata.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,21 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/internal/obexdata.h>
+
+EXPORT_C TUint16 TObexData::TotalSize () const
+	{
+	return DoTotalSize();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obexinternalheader.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,463 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/internal/obexinternalheader.h>
+#include <es_sock.h>
+#include "logger.h"
+#include "obextransportfaults.h"
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+#ifdef _DEBUG
+_LIT(KPanicCat, "ObexIntHdr");
+#endif
+
+/** @internalComponent */
+const TUint8 KObexHeaderTypeMask = 0xc0;
+
+/**
+Constructor
+*/
+EXPORT_C TObexInternalHeader::TObexInternalHeader ()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iHVSize = 0;
+	}
+
+/**
+Try to read a header from aSource, taking up to a maximum of aMaxSize bytes.
+Returns the number of bytes actually read out.
+*/
+TUint16 TObexInternalHeader::ParseIn (TUint8* aSource, const TUint16 aMaxSize)
+	{
+	iHVSize = 1;
+	if (aMaxSize < KObexHeaderHIShortSize + 1) return (0);
+	SetHI (STATIC_CAST(THeaderID, *aSource));
+
+	switch (HIType ())
+		{
+	case EUnicode:
+	case EByteSeq:	
+		if (aMaxSize < KObexHeaderHILongSize) return (0);
+		{
+		TInt hvsize = BigEndian::Get16 (&aSource[1]) - HISize ();
+		if (hvsize < 0) return (0);
+		iHVSize = STATIC_CAST(TUint16, hvsize);
+		}
+		iHV.iObex = &aSource[KObexHeaderHILongSize];
+		iHVRep = EHVObexDefault;
+		break;
+	case E4Byte:
+		iHVSize = 4; //fallthrough to case E1Byte
+	case E1Byte:
+		iHV.iObex = &aSource[KObexHeaderHIShortSize];
+		iHVRep = EHVObexDefault;
+		break;
+	default:
+		return (0);
+		}
+	if (aMaxSize < TotalSize ()) 
+		return (0);
+	return (TotalSize ());
+	}
+
+/**
+Write this header out to aDest, writting up to a max of aMaxSize bytes.
+returns the number of bytes actually written.
+All complicated by the fact that the internal rep. of the data in the header
+might be in one of a number of forms, as well as having to convert to the 
+correct OBEX form, all with heavy consideration for thick and thin builds.
+For unicode on the wire, we also need to to endian conversion too....
+*/
+TUint16 TObexInternalHeader::WriteOut (TUint8* aDest, const TUint16 aMaxSize) const
+	{
+	TInt byteswritten = TotalSize ();
+	if (aMaxSize < byteswritten) return (0);
+	*aDest = iHI;
+
+	switch (HIType ())
+		{
+	case EUnicode:
+	case EByteSeq:
+	// The following is arranged in order of expected frequency of use.
+	// The less common the conversion, the less effort is put to efficiency.
+		if (iHVRep == EHVDefered)
+			{// The data will actually be written after the header is inserted.
+			byteswritten = iHVMaxSize + KObexHeaderHILongSize;
+			if (byteswritten > aMaxSize)	
+				byteswritten = aMaxSize;
+			iHV.iDefered->Set (&aDest[KObexHeaderHILongSize], 0, byteswritten - KObexHeaderHILongSize);
+			}
+		else if (iHVRep == EHVObexDefault)
+			{// The easy case: just send the data directly
+			Mem::Copy (&aDest[KObexHeaderHILongSize], iHV.iObex, iHVSize);
+			}
+		else
+			{// Big time (Uniocde/Ascii) conversions necessary
+			TBufC<40> numbuf;
+			TPtr src (numbuf.Des ());
+			if (iHVRep == EHVInt)
+				{
+				if ( GetHVText(src) != KErrNone )
+					{
+					return (0);
+					}
+				}
+			else
+				{
+				src.Set (iHV.iMachine, iHVSize / sizeof (TText), iHVSize / sizeof (TText));
+				}
+			TInt i;
+			if (HIType () == EUnicode)
+				{// Need to convert to Unicode, from internal machine rep
+				byteswritten = KObexHeaderHILongSize;
+				if(src.Length())
+					{// Only need null term if the length is non-zero
+					byteswritten += (2 * (src.Length () + 1)); 
+									// 2 = Unicode word size, + 1 for null terminal
+					if (aMaxSize < byteswritten) return (0);
+					for (i = 0; i < src.Length (); ++i)
+						BigEndian::Put16 (&aDest[KObexHeaderHILongSize + (i * 2)], src[i]);
+					BigEndian::Put16 (&aDest[KObexHeaderHILongSize + (i * 2)], 0);		// Null term
+					}
+				}
+			else	// HIType == ByteSeq
+				{// Convert to obex "byte sequence", from internal machine rep.
+				byteswritten = KObexHeaderHILongSize + src.Length ();
+				if (aMaxSize < byteswritten) return (0);
+				for (i = 0; i < src.Length (); ++i)
+					aDest[KObexHeaderHILongSize + i] = STATIC_CAST(TUint8, src[i]);
+				}
+			}
+		BigEndian::Put16 (&aDest[1], STATIC_CAST(TUint16, byteswritten));
+		break;
+	case E1Byte:
+		aDest[KObexHeaderHIShortSize] = STATIC_CAST(TUint8, HVInt ());
+		break;
+	case E4Byte:
+		BigEndian::Put32 (&aDest[KObexHeaderHIShortSize], HVInt ());
+		break;
+	default:
+		return (0);
+		}
+	return (STATIC_CAST(TUint16, byteswritten));
+	}
+
+/**
+Setter for the header id
+
+@param aHID Header id
+*/
+EXPORT_C void TObexInternalHeader::SetHI (THeaderID aHID)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iHI = aHID;
+	}
+	
+/**
+Setter for the header id and header value
+
+@param aHID Header id
+@param aValue Value for the header
+@see SetHI
+*/
+EXPORT_C void TObexInternalHeader::Set (THeaderID aHID, TInt aValue)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	SetHI (aHID);
+	iHV.iInt = aValue;
+	iHVRep = EHVInt;
+	}
+
+/**
+Setter for the header id,  header value and size of the header value
+
+@param aHID Header id
+@param aHV Header value
+@param aHVSize Size of the header value
+@see SetHI
+*/
+EXPORT_C void TObexInternalHeader::Set (THeaderID aHID, TUint8* aHV, TInt aHVSize)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	__ASSERT_DEBUG (aHV, PANIC (KPanicCat, ETransportNullPointer));
+	__ASSERT_DEBUG (aHVSize >= 0, PANIC (KPanicCat, EInvalidHeaderSize));
+	__ASSERT_DEBUG (aHVSize < (TInt)(KMaxTUint16 - 3), PANIC (KPanicCat, EInvalidHeaderSize));
+	SetHI (aHID);
+	iHV.iObex = aHV;
+	iHVSize = STATIC_CAST(TUint16, aHVSize);
+	iHVRep = EHVObexDefault;
+	}
+	
+/**
+Setter for the header id,  header value and size of the header value
+
+@param aHID Header id
+@param aString Descriptor containing the header value and its size
+@see SetHI
+*/
+EXPORT_C void TObexInternalHeader::Set (THeaderID aHID, const TDesC& aString)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	__ASSERT_DEBUG (aString.Size () <= (TInt)(KMaxTUint16 - 3), PANIC(KPanicCat, EStringOverflow));
+	SetHI (aHID);
+	iHV.iMachine = CONST_CAST(TText*, aString.Ptr ());
+	iHVSize = STATIC_CAST(TUint16, aString.Size ());
+	iHVRep = EHVMachineText;
+	}
+	
+/**
+Setter for the header id, the header value data inserter, min and max size
+
+@param aHID Header id
+@param aDataInserter Data inserter
+@param aMinSize Min size of header value
+@param aMaxSize Max size of header value
+@see SetHI
+*/
+EXPORT_C void TObexInternalHeader::SetDeferred (THeaderID aHID, TPtr8* aDataInserter, TInt aMinSize, TInt aMaxSize)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	__ASSERT_DEBUG (aMinSize > 0, PANIC(KPanicCat, EInvalidHeaderSize));
+	SetHI (aHID);
+	iHV.iDefered = aDataInserter;
+	iHVSize = STATIC_CAST (TUint16, aMinSize);
+	if (aMaxSize > TInt(KMaxTUint16 - KObexHeaderHILongSize))
+		iHVMaxSize = TUint16(KMaxTUint16 - (TUint)(KObexHeaderHILongSize));
+	else
+		iHVMaxSize = STATIC_CAST (TUint16, aMaxSize > aMinSize ? aMaxSize : aMinSize);
+	iHVRep = EHVDefered;
+	aDataInserter->Set (NULL, 0, 0);
+	}
+	
+/**
+Returns the internal header ID
+
+@return Internal header ID
+*/	 
+EXPORT_C TObexInternalHeader::THeaderID TObexInternalHeader::HI () const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return (iHI);
+	}
+
+/**
+Returns the internal header type
+
+@return Internal header type
+*/	
+EXPORT_C TObexInternalHeader::THeaderType TObexInternalHeader::HIType () const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return (STATIC_CAST(THeaderType, (HI () & KObexHeaderTypeMask)));
+	}
+
+/**
+Returns the internal header value
+
+@return Internal header value
+*/	
+EXPORT_C TInt TObexInternalHeader::HVInt () const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if (iHVRep == EHVObexDefault)
+		{
+		if (HIType () == E4Byte)
+			return (BigEndian::Get32 (iHV.iObex));
+		else
+			return (*iHV.iObex);
+		}
+	if (iHVRep == EHVInt)
+		return (iHV.iInt);
+	// Don't bother converting machine strings to ints!
+	return (0);				
+	}
+
+/**
+Returns a pointer to the internal header value byte sequence
+
+@return Pointer to the internal header value byte sequence
+*/
+EXPORT_C TUint8* TObexInternalHeader::HVByteSeq () const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if (iHVRep == EHVObexDefault)
+		return (iHV.iObex);
+	// Could do alsorts of fancy stuff else.
+	return (NULL);			
+	}
+
+/**
+Returns header value as text
+
+Take the HV and put "an appropriate" representation of it into aString.
+The stable mate of "WriteOut" in terms of nasty conversions, but again all 
+necessary in order to support both thick & thin builds.
+
+@return Error code
+*/
+EXPORT_C TInt TObexInternalHeader::GetHVText (TDes& aString) const
+    {
+	LOG_LINE
+	LOG_FUNC
+
+	switch (iHVRep)
+		{
+	case EHVMachineText:
+		FLOG(_L8("EHVMachineText"));
+		if (aString.Length () < STATIC_CAST(TInt, TUint(iHVSize / sizeof(TText))))
+			{
+			FLOG(_L8("Target descriptor too small"));
+			return (KErrBadDescriptor);
+			}
+			
+		aString.Copy (TPtr (iHV.iMachine, iHVSize / sizeof(TText), iHVSize / sizeof(TText)));
+		return (KErrNone);
+	
+	case EHVObexDefault:
+		FLOG(_L8("EHVObexDefault"));
+		if (HIType () == EUnicode)
+			{
+			// Unicode: read big endian and shove into descriptor
+			FLOG(_L8(" -Unicode"));
+			if (aString.MaxLength () < iHVSize / 2)
+				{
+				FLOG(_L8("Target descriptor too small"));
+				return (KErrBadDescriptor);
+				}
+			
+			aString.SetLength (iHVSize / 2);
+			TInt i;
+			for (i = 0; i < iHVSize / 2; ++i)
+				{
+				aString[i] = STATIC_CAST (TText, BigEndian::Get16 (&iHV.iObex[i * 2]));
+				}
+				
+			if (i > 0 && aString[--i] == 0) // Zero length headers have no null terminal!
+				{
+				// Make sure last char is null term, and chop it off
+				aString.SetLength (i);
+				}
+			
+			return (KErrNone);
+			}
+		
+		if (HIType () == EByteSeq)
+			{
+			// Descriptors can actually do the conversion for us here.
+			FLOG(_L8(" -ByteSeq"));
+			if (aString.MaxLength () < iHVSize)
+				{
+				FLOG(_L8("Target descriptor too small"));
+				return (KErrBadDescriptor);
+				}
+			
+			aString.Copy (TPtrC8 (iHV.iObex, iHVSize));
+			return (KErrNone);
+			}
+		break;
+		
+	case EHVInt:
+		FLOG(_L8("EHVInt"));
+		aString.Num (HVInt ());
+		return (KErrNone);
+	
+	default:
+		break;
+		}
+	
+	FLOG(_L8("Unknown error..."));
+	aString.SetLength (0);
+	return (KErrGeneral);
+	}
+
+ TUint16 TObexInternalHeader::DoTotalSize () const
+	{
+	return (STATIC_CAST(TUint16, HISize () + HVSize ()));
+	}
+
+/**
+Returns the size of the internal header
+
+@return Size of the internal header
+*/
+EXPORT_C TUint16 TObexInternalHeader::HISize () const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	switch (HIType ())
+		{
+	case EUnicode:
+	case EByteSeq:	
+		return (KObexHeaderHILongSize);
+	case E1Byte:
+	case E4Byte:
+		return (KObexHeaderHIShortSize);
+	default:
+		return (0);
+		}
+	}
+	
+/**
+Returns the size of the internal header value
+
+@return Size of the internal header value
+*/
+EXPORT_C TUint16 TObexInternalHeader::HVSize () const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if (iHVRep == EHVObexDefault || iHVRep == EHVDefered)
+		return (iHVSize);
+	TInt fact = 1;
+	switch (HIType ())
+		{
+	case EUnicode:
+		fact = 2; //fallthrough to case EByteSeq
+	case EByteSeq:	
+		if (iHVRep == EHVMachineText)
+			return (STATIC_CAST(TUint16, fact * iHVSize / sizeof (TText)));
+		return (40);
+	case E1Byte:
+		return (1);
+	case E4Byte:
+		return (4);
+	default:
+		return (0);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obexpacket.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,334 @@
+// 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 <es_sock.h>
+#include <obex/internal/obexpacket.h>
+#include <obex/internal/obexinternalconstants.h>
+#include <obex/internal/obexdata.h>
+#include "logger.h"
+#include "obextransportfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+_LIT(KPanicCat, "ObexPacket");
+CObexPacket::CObexPacket (TUint16 aBufferSize, TUint16 aDataLimit) : iBufferSize ( aBufferSize ), iDataLimit ( aDataLimit )
+	{
+	LOG_FUNC
+ 	}
+
+/**
+Destructor
+*/
+EXPORT_C CObexPacket::~CObexPacket ()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	delete[] iBuffer;
+	}
+
+/**
+*/
+EXPORT_C CObexPacket* CObexPacket::NewL (TUint16 aBufferSize, TUint16 aDataLimit)
+	{
+	LOG_LINE
+	LOG_STATIC_FUNC_ENTRY
+	LOG2(_L8("\taBufferSize = %d, aDataLimit = %d"), aBufferSize, aDataLimit);
+
+	// Data limit can't be larger than the buffer
+	__ASSERT_ALWAYS ( aBufferSize >= aDataLimit, PANIC(KPanicCat, EDataLimitLargerThanBuffer) );
+
+	CObexPacket* self = new (ELeave) CObexPacket ( aBufferSize, aDataLimit );
+	CleanupStack::PushL (self);
+	self->ConstructL ();
+	CleanupStack::Pop (self);
+	return (self);
+	}
+
+void CObexPacket::ConstructL ()
+	{
+//	FTRACE(FPrint(_L("CObexPacket::ConstructL buffer %d data limit %d"), iBufferSize, iDataLimit));
+
+	iBuffer = new (ELeave) TUint8 [ iBufferSize ];
+	Init ( 0 );
+	}
+/**
+Set up as a fresh packet with the given opcode.
+@param aOpcode a opcode
+*/
+EXPORT_C void CObexPacket::Init (TObexOpcode aOpcode)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	SetOpcode (aOpcode);
+	SetPacketSize (KObexPacketHeaderSize);
+	iInsertPoint = Payload ();
+	iExtractPoint = Payload ();
+	iNotificationEvents = 0;
+	}
+	
+/**
+Returns the packet opcode, with the final bit cleared (regardless of its actual value) 
+@return TObexOpcode
+*/
+EXPORT_C TObexOpcode CObexPacket::Opcode () const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return (STATIC_CAST(TObexOpcode, iBuffer[0] & ~KObexPacketFinalBit));
+	}
+
+/**
+Set the packet opcode to the passed value -- final bit will get through too.
+@param aOpcode an Opcode
+*/
+EXPORT_C void CObexPacket::SetOpcode (TObexOpcode aOpcode)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iBuffer[0] = aOpcode;
+	}
+
+/**
+True if the packet's final bit is set 
+@return TBool true if this is the final packet
+*/
+EXPORT_C TBool CObexPacket::IsFinal () const
+	{
+	LOG_LINE
+
+	const TBool isFinal = (iBuffer[0] & KObexPacketFinalBit);
+
+	LOG1(_L8("CObexPacket::IsFinal returning %d"), isFinal);
+
+	return isFinal;
+	}
+
+/**
+If aFinal == ETrue (default), the final bit is set, otherwise it is cleared.
+@param aFinal whether or not to set or clear the final bit
+*/
+EXPORT_C void CObexPacket::SetFinal (TBool aFinal)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iBuffer[0] = STATIC_CAST(TObexOpcode, aFinal ? (iBuffer[0] | KObexPacketFinalBit) : (iBuffer[0] & ~KObexPacketFinalBit));
+	}
+
+/**
+Returns the total size of the current packet.
+@return TUint16 total size of the packet
+*/
+EXPORT_C TUint16 CObexPacket::PacketSize () const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return (BigEndian::Get16 (&iBuffer[1]));
+	}
+
+/**
+Sets the crruent packet's size.
+@param aSize a packet size
+*/
+EXPORT_C void CObexPacket::SetPacketSize (TUint16 aSize)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	BigEndian::Put16 (&iBuffer[1], aSize);
+	}
+
+/**
+Sets the data limit of the buffer, ensuring it's larger than minimum possible but not larger than the buffer
+Parameter passed in is the requested new data limit
+Returns size that was set
+@param aRequestedSize a Requested size for the data limit
+@return TUint16  the data limit size
+*/
+EXPORT_C TUint16 CObexPacket::SetLegalDataLimit (TUint16 aRequestedSize)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+//	FTRACE(FPrint(_L("CObexPacket::SetLegalDataLimit requested size %d"), aRequestedSize));
+
+	aRequestedSize = Max ( KObexPacketMinSize, aRequestedSize );
+	aRequestedSize = Min ( iBufferSize, aRequestedSize );
+
+//	FTRACE(FPrint(_L("CObexPacket::SetLegalDataLimit set size %d"), aRequestedSize));
+	iDataLimit = aRequestedSize;
+	return iDataLimit;
+	}
+	
+/**	
+return the data limit
+@return TUint16 the data limit
+*/
+EXPORT_C TUint16 CObexPacket::DataLimit () const	
+	{ 
+	LOG_LINE
+	LOG_FUNC
+
+	return iDataLimit; 
+	}
+	
+/**
+return the buffer size	
+@return TUint16 the buffer size
+*/
+EXPORT_C TUint16 CObexPacket::BufferSize() const
+  	{
+	LOG_LINE
+	LOG_FUNC
+
+   	return iBufferSize; 
+  	}
+  
+/**
+Insert the passed packet data object at iInsertPoint 
+@param aHeader OBEX header to insert
+@return True if the number of bytes is not zero and there is enough space to insert data
+*/
+EXPORT_C TBool CObexPacket::InsertData (const TObexData& aHeader)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if (aHeader.TotalSize () > RemainingInsertSpace ()) return EFalse;
+	TUint16 bytesInserted = aHeader.WriteOut (iInsertPoint, RemainingInsertSpace ());
+	iInsertPoint += bytesInserted;
+	SetPacketSize (STATIC_CAST(TUint16, PacketSize () + bytesInserted));
+	return (bytesInserted != 0);
+	}
+
+/**
+Extract into the passed data object from iExtractPoint 
+@param aHeader Container for extracted data
+@return True if bytes read is not zero
+*/
+EXPORT_C TBool CObexPacket::ExtractData (TObexData& aHeader)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	TUint16 bytesRead = aHeader.ParseIn (iExtractPoint, RemainingExtractSpace ());
+	iExtractPoint += bytesRead;
+	
+	// If no bytes have been read two possible conditions have occured
+	// 1. There is no remaining extract space in the packet (i.e. at the end)
+	// 2. There has been an error when parsing.
+	// In either case iExtractPoint will not move and aHeader has not really
+	// changed its state (iHI, iHV, iHVSize and iHVRep will change but get
+	// reset on the next ParseIn.  So if no bytes are read then from the API we
+	// assume that we have finished processing the packet, and so can reset the
+	// extract point, in case it needs to be parsed again.
+	if (bytesRead == 0)
+		{
+		iExtractPoint = Payload();
+		}
+	
+	return (bytesRead != 0);
+	}
+
+/**
+Returns the number of bytes of unused space in the obex packet (on writes)
+@return Remaining insert space
+*/
+EXPORT_C TUint16 CObexPacket::RemainingInsertSpace () const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	__ASSERT_DEBUG (iInsertPoint >= Payload () && iInsertPoint <= &iBuffer[iDataLimit], PANIC(KPanicCat, EPacketOverrun));
+	return (TUint16)((&iBuffer[iDataLimit]) - iInsertPoint);
+	}
+
+/**
+Returns the number of bytes of unread data in the obex packet (on reads) 
+@return Remaining extract space
+*/
+EXPORT_C TUint16 CObexPacket::RemainingExtractSpace () const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	__ASSERT_DEBUG (iExtractPoint >= Payload () && iExtractPoint <= &iBuffer[PacketSize ()], PANIC (KPanicCat, EPacketOverrun));
+	return (TUint16)((&iBuffer[PacketSize ()] - iExtractPoint));
+	}
+
+/** Adds events that should be notified.
+
+Add events into the packet process events mask.  When this packet
+is processed this mask will be checked and notifications will be
+issued only if the appropriate bits are set.
+
+@param aEvents The additional events to notify on.
+*/
+EXPORT_C void CObexPacket::AddPacketProcessEvents(TObexPacketProcessEvents aEvents)
+	{
+	LOG_LINE
+	LOG_FUNC
+	iNotificationEvents |= aEvents;
+	}
+	
+/** Removes events from packet notification.
+
+Remove events from the packet process events mask.  When this packet
+is processed this mask will be checked and notifications will be
+issued only if the appropriate bits are set.
+
+@param aEvents The events to cease notification of.
+*/
+EXPORT_C void CObexPacket::RemovePacketProcessEvents(TObexPacketProcessEvents aEvents)
+	{
+	LOG_LINE
+	LOG_FUNC
+	iNotificationEvents &= ~aEvents;
+	}
+
+/** Gets events that will be notified.
+
+Retrieves the packet process events mask.  When this packet
+is processed this mask will be checked and notifications will be
+issued only if the appropriate bits are set.
+
+@return The events that will be notified.
+*/
+EXPORT_C TObexPacketProcessEvents CObexPacket::PacketProcessNotificationEvents() const
+	{
+	LOG_LINE
+	LOG_FUNC
+	return iNotificationEvents;
+	}
+
+/**
+Logs the size of the packet. 
+If __LOG_PACKET_DUMP__ is defined (obex/common/logger.h) then also logs the 
+packet's contents.
+*/
+EXPORT_C void CObexPacket::Dump () const
+	{
+	LOG1(_L8("PacketSize = %d, Packet Dump:"), PacketSize ());
+#ifdef __LOG_PACKET_DUMP__
+	LOGHEXRAW(iBuffer, iBufferSize);
+#endif
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obextransportcontrollerbase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,594 @@
+// 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 <ecom/ecom.h>
+#include <obex/transport/obextransportcontrollerbase.h>
+#include <obex/internal/mobexnotifyextend.h>
+#include <obexirtransportinfo.h>
+#include <obex/internal/obexactiverw.h>
+#include <obextransportinfo.h>
+#include <obex/internal/obexpacket.h>
+#include <obexpanics.h>
+#include "ObexTransportUtil.h" 
+#include "obexconnectdata.h" 
+#include "logger.h"
+#include "obextransportfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+//Category used for internal panics
+_LIT(KPanicCat, "TransCTBase");
+
+// The minimum allowed number of 'transport controller' implementations. If 
+// NewL doesn't find at least this many, then in debug NewL panics, and in 
+// release it leaves.
+const TUint KMinimumNumImplementations = 1;
+
+/**
+Constructs a CObexTransportControllerBase PlugIn object.
+ 
+@internalTechnology
+@return	A new CObexTransportControllerBase PlugIn object	
+@panic TransCTBase EInvalidNumberOfTransportImplementations if there is more than one implementation for a given interface uid and transport name (equal to the default data in the plugin resource file
+*/
+EXPORT_C CObexTransportControllerBase* CObexTransportControllerBase::NewL(TObexTransportInfo& aTransportInfo)
+	{
+	LOG_LINE
+	LOG_STATIC_FUNC_ENTRY
+
+	//Making a copy as Collapse modifies the original iTransportName
+	TBuf<60> transportName = aTransportInfo.iTransportName;
+	TPtrC8 params = transportName.Collapse();	
+	TEComResolverParams resolverParams; 
+	resolverParams.SetDataType(*reinterpret_cast<TDesC8*>(&params));
+	
+	RImplInfoPtrArray implInfoArray;
+	REComSession::ListImplementationsL(TUid::Uid(KObexTransportControllerInterfaceUid), resolverParams, KRomOnlyResolverUid,  implInfoArray);
+	
+	CleanupResetAndDestroyPushL(implInfoArray);
+	__ASSERT_DEBUG(implInfoArray.Count() <= KMinimumNumImplementations, PANIC(KObexTransportPanicCat, EInvalidNumberOfTransportImplementations) ); 
+	if (implInfoArray.Count() <  KMinimumNumImplementations)
+		{
+		User::Leave(KErrNotFound);
+		}
+
+	const TUid uid = implInfoArray[KMinimumNumImplementations - 1]->ImplementationUid();
+	CleanupStack::PopAndDestroy(&implInfoArray);
+	
+	CObexTransportControllerBase* ptr = reinterpret_cast<CObexTransportControllerBase*> 
+		(REComSession::CreateImplementationL(uid, _FOFF(CObexTransportControllerBase, iPrivateEComUID), 
+			reinterpret_cast<TAny*>(&aTransportInfo)));
+			
+	CleanupStack::PushL(ptr);
+	// Do any base construction here. This may in future include allocation of 
+	// iFuture1.
+	ptr->BaseConstructL();
+	CleanupStack::Pop(ptr);
+	return ptr;
+	}
+	
+/**
+Constructor.
+ 
+@publishedPartner
+@released
+*/
+EXPORT_C CObexTransportControllerBase::CObexTransportControllerBase()
+	{
+	LOG_LINE
+	LOG_FUNC
+	}
+
+/**
+This function is a place holder for future use. If iFuture1 variable is used 
+it will need this function for any allocation required.
+This function is called from CObexTransportControllerBase::NewL. 
+*/
+void CObexTransportControllerBase::BaseConstructL()
+	{
+	LOG_LINE
+	LOG_FUNC
+	}
+
+/**
+Sets the owner information from the received aOwner
+
+@internalTechnology
+*/
+EXPORT_C void CObexTransportControllerBase::SetOwner(MObexNotifyExtend& aOwner)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	__ASSERT_ALWAYS(iOwner==NULL, PANIC(KPanicCat, EOwnerAlreadySet));
+	iOwner = &aOwner;
+	}
+
+/**
+Destructor.
+ 
+@publishedPartner
+@released
+*/
+EXPORT_C CObexTransportControllerBase::~CObexTransportControllerBase()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	delete iConnector;
+	DeleteTransport();
+	delete iTransportInfo;
+
+	REComSession::DestroyedImplementation(iPrivateEComUID);
+	}
+/**
+Cancels outstanding reads or writes
+
+@internalTechnology
+*/
+EXPORT_C void CObexTransportControllerBase::CancelTransfers()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if (iActiveReader)
+		{
+		iActiveReader->Cancel();
+		}
+	if (iActiveWriter)
+		{
+		iActiveWriter->Cancel();
+		}
+	}
+/**
+Calls on the constructor to take down the transport
+
+@internalTechnology
+@return TBool ETrue if the transport was taken down
+*/
+EXPORT_C TBool CObexTransportControllerBase::BringTransportDown()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	DeleteTransport();
+	return iConnector->BringTransportDown();
+	}
+
+/**
+Calls ConnectL on the connector
+
+@internalTechnology
+*/	
+EXPORT_C void CObexTransportControllerBase::ConnectL ()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iConnector->ConnectL();
+	}
+
+/**
+Ask Connector to cancel connect
+
+@see CObexTransportControllerBase::ConnectL
+@internalTechnology
+*/	
+EXPORT_C void CObexTransportControllerBase::CancelConnect()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iConnector->CancelConnect();
+	}
+
+/**
+Calls accept connection on the connector
+@internalTechnology
+*/
+EXPORT_C void CObexTransportControllerBase::AcceptConnectionL()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iConnector->AcceptL();
+	}
+
+/**
+Calls Cancel Accept on he connector
+
+@see CObexTransportControllerBase::AcceptConnectionL
+@internalTechnology
+*/	
+EXPORT_C void CObexTransportControllerBase::CancelAccept()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if ( iConnector)
+		{
+		iConnector->CancelAccept();
+		}
+	}
+
+/**
+Calls signal transport error on the connector
+
+@internalTechnology
+*/
+EXPORT_C void CObexTransportControllerBase::SignalTransportError()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	// If this is called during construction, iConnector could be NULL
+	if(iConnector)
+		{
+		iConnector->SignalTransportError();
+		}
+	}
+
+/**
+returns the send packet
+
+@return CObexPacket the packet that will be sent
+@internalTechnology
+*/	
+EXPORT_C CObexPacket& CObexTransportControllerBase::SendPacket ()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return *iSendPacket;
+	}
+
+/**
+Returns the packet received
+
+@return CObexPacket the packet that will be sent
+@internalTechnology
+*/
+EXPORT_C CObexPacket& CObexTransportControllerBase::ReceivePacket ()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return *iReceivePacket;
+	}
+
+/**
+Ask active writer to do a send
+
+@internalTechnology
+*/
+EXPORT_C void CObexTransportControllerBase::Send ()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	LOG3(_L8("Packet Sent, Opcode 0x%2x (0x%2x with final bit cleared), Length %d"), (iSendPacket->IsFinal() ? (iSendPacket->Opcode() | KObexPacketFinalBit) : iSendPacket->Opcode()), iSendPacket->Opcode(), iSendPacket->PacketSize());
+	FTRACE(iSendPacket->Dump ());
+
+	iActiveWriter->Transfer (*iSendPacket);
+	}
+
+/**
+Init the send packet wtih the received, aOpcode, set final to true,  and send the packet
+
+@internalTechnology
+*/
+EXPORT_C void CObexTransportControllerBase::Send (TObexOpcode aOpcode)
+	{
+	LOG_LINE
+	LOG_FUNC
+	LOG1(_L8("\taOpcode = %d"), aOpcode);
+
+	iSendPacket->Init (aOpcode);
+	iSendPacket->SetFinal (ETrue);
+	Send ();
+	}
+
+/**
+Ask activer reader to do a read
+
+@internalTechnology
+*/
+EXPORT_C void CObexTransportControllerBase::Receive ()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	iActiveReader->Transfer (*iReceivePacket);
+	}
+
+/**
+Is there a write outstanding
+
+@return TBool  return ETrue is there is a write activer otherwise EFalse
+@internalTechnology
+*/		
+EXPORT_C TBool CObexTransportControllerBase::IsWriteActive ()  const
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if (iActiveWriter)
+		{
+		return (iActiveWriter->IsActive());
+		}
+	else // this has been added incase of null iActiveWriter
+		{
+		return EFalse;
+		}
+	}
+
+/**
+Insert local Connection info with the received, aVersion, aFlags and from iReceivePacket into the receive packet, aPacket
+
+@return TInt KErrNone or a symbian error
+@param aPacket the packet that is updated with local connection info
+@param aVersion 
+@param aFlags
+@internalTechnology
+*/
+EXPORT_C TInt CObexTransportControllerBase::InsertLocalConnectInfo (CObexPacket &aPacket, TUint8 aVersion, TUint8 aFlags)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if (iReceivePacket)
+		{
+		TObexConnectData localinfo;
+		localinfo.iVersion = aVersion;
+		localinfo.iFlags = aFlags;
+		localinfo.iMaxPacketLength = iReceivePacket->DataLimit();	// maximum packet length we can receive
+		return (aPacket.InsertData (localinfo));	
+		}
+	else
+		{
+		return KErrGeneral;
+		}
+	}
+
+/**
+Extract the local information from the received packet 
+
+@return EFalse- failed to extract the information. ETrue- extraction succeeded.
+@param aPacket The packet from which  local connection info is extracted
+@param aVersion
+@param aFlags
+@internalTechnology
+*/
+EXPORT_C TBool CObexTransportControllerBase::ExtractRemoteConnectInfo(CObexPacket &aPacket, TUint8& aVersion, TUint8& aFlags)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	if (iSendPacket)
+		{
+		TObexConnectData remoteinfo;
+		if (!aPacket.ExtractData (remoteinfo))
+			{
+			return EFalse;
+			}
+		aVersion = remoteinfo.iVersion;
+		aFlags = remoteinfo.iFlags;
+
+		// Set the send buffer data limit (i.e. how much OBEX can use) to match the size of the
+		// remote receive buffer (the setter function ensures it's a legal size)
+		(void)iSendPacket->SetLegalDataLimit (remoteinfo.iMaxPacketLength);
+		return ETrue;
+		}
+	else
+		{
+		return EFalse;
+		}
+	}
+
+/**
+@internalTechnology
+*/
+void CObexTransportControllerBase::ConstructPacketsL() 
+	{
+	LOG_FUNC
+
+	// Set actual packet sizes
+	// Receive must be at least KObexPacketDefaultSize to maintain functional compatibility with previous implentations
+	// (to ensure that remote ends that ignore how big we say our receive buffer is get that same grace on buffer overflow)
+	__ASSERT_DEBUG(iTransportInfo, PANIC(KPanicCat, ETransportNullPointer)); 
+	TUint16 receivePacketBufferSize = Max ( iTransportInfo->iReceiveMtu, KObexPacketDefaultSize );
+	TUint16 sendPacketBufferSize = iTransportInfo->iTransmitMtu;
+
+	// Set initial "software throttle" for packets (how big OBEX says they are)
+	// Send packet is set to miniumum, so initial transmit cannot overflow remote end
+	TUint16 receivePacketDataLimit = GetReceivePacketDataLimit();
+	TUint16 sendPacketDataLimit = KObexPacketMinSize;
+		
+	LOG2(_L8("CObexTransportControllerBase::ConstructPacketsL send buffer %d send data limit %d"), sendPacketBufferSize, sendPacketDataLimit);
+	LOG2(_L8("CObexTransportControllerBase::ConstructPacketsL receive buffer %d receive data limit %d"), receivePacketBufferSize, receivePacketDataLimit);
+
+	// Create the packets
+	iSendPacket = CObexPacket::NewL(sendPacketBufferSize, sendPacketDataLimit);
+	iReceivePacket = CObexPacket::NewL(receivePacketBufferSize, receivePacketDataLimit);
+	}
+
+/**
+Gets the socket associated with the connector and asks the socket for its  remote name. 
+This can be cast to the appropriate TSockAddr-derived class TIrdaSockAddr for IrDA. 
+
+@publishedPartner
+@released
+*/
+EXPORT_C void CObexTransportControllerBase::RemoteAddr(TSockAddr& aAddr)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	DoRemoteAddr(aAddr);
+	}
+
+/**
+Returns true if the derived transport can re-connect when an obex connection is re-connected
+This is used to determine whether to take the transport down when an obex connection has been disconnected
+
+@see DoIsTransportRestartable
+@return TBool return ETrue if the derived transport can support re-connection when obex re-connects
+@publishedPartner
+@released
+*/	
+EXPORT_C TBool CObexTransportControllerBase::IsTransportRestartable() const	
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	return DoIsTransportRestartable();
+	}
+
+//MObexTransport Notify Protected 
+/**
+Process a Packet.  Upcall to the owner
+
+@publishedPartner
+@released
+*/
+EXPORT_C void CObexTransportControllerBase::DoProcess(CObexPacket &aPacket)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	__ASSERT_DEBUG(iOwner, PANIC(KPanicCat, ETransportNullPointer)); 
+	iOwner->Process(aPacket);
+	}
+
+/**
+Reports and error to the owner
+
+@publishedPartner
+@released
+*/
+EXPORT_C void CObexTransportControllerBase::DoError(TInt aError) 
+	{
+	LOG_LINE
+	LOG_FUNC
+	LOG1(_L8("\taError = %d"), aError);
+
+	__ASSERT_DEBUG(iOwner, PANIC(KPanicCat, ETransportNullPointer)); 
+	iOwner->Error(aError);
+	}
+
+/**
+Create the transport objects and reports that the transport is up to the owner
+
+@publishedPartner
+@released
+*/	
+EXPORT_C void CObexTransportControllerBase::DoTransportUp(TObexConnectionInfo& aInfo)
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	DeleteTransport();
+	TRAPD(err, InitialiseTransportL(aInfo));
+	if(err != KErrNone)
+		{
+		TransportUpError(err);
+		}
+	else
+		{
+		__ASSERT_DEBUG(iOwner, PANIC(KPanicCat, ETransportNullPointer));
+		iOwner->TransportUp();
+		Receive();
+		}
+	}
+
+void CObexTransportControllerBase::InitialiseTransportL(TObexConnectionInfo& aInfo)
+	{
+	NewTransportL(aInfo);
+	ConstructPacketsL();
+	}
+
+void CObexTransportControllerBase::TransportUpError(TInt aError)
+	{
+	// At this stage the transport controller will have a connection set-up.
+	// As a result if we get an error while setting up Obex we should bring
+	// the transport down (the owner has alrady been informed of the error,
+	// but we shouldn't expect them to have to bring the transport down).
+	TBool broughtDown = BringTransportDown();
+	// If we failed to bring down the transport there isn't much
+	// more we can do.
+	(void)broughtDown;
+
+	Error(aError); // Signal error indication
+	}
+
+/**
+Signals that an event related to processing the packet has occurred.
+@param aEvent The event that has occurred.
+*/
+EXPORT_C void CObexTransportControllerBase::DoSignalPacketProcessEvent(TObexPacketProcessEvent aEvent)
+	{
+	LOG_FUNC
+	
+	__ASSERT_DEBUG(iOwner, PANIC(KPanicCat, ETransportNullPointer)); 
+	iOwner->SignalPacketProcessEvent(aEvent);
+	}
+
+/**
+Returns a pointer to the transport info being used by the transport. This may 
+be cast to the transport info type associated with the known concrete 
+transport controller.
+*/
+EXPORT_C const TObexTransportInfo* CObexTransportControllerBase::TransportInfo() const
+	{
+	LOG_FUNC
+
+	return iTransportInfo;
+	}
+
+/**
+This function is part of the extension pattern and must be implemented by all derived instantiable classes.
+By default this returns null.  Any derived class that is required to extend its interface and that of this base 
+class returns its new interface in the form of an M class, that it extends, if and only if  the corresponding TUid, 
+aUid, is received. Otherwise the function calls the base class implementation, returning NULL.
+
+@return The M Class representing the extension to the interface otherwise NULL
+@param aUid The uid associated with the M Class that is being implemented
+@publishedPartner
+@released
+*/
+EXPORT_C TAny* CObexTransportControllerBase::GetInterface(TUid /*aUid*/)
+	{
+	LOG_FUNC
+	
+	return NULL;
+	}
+
+//private
+void CObexTransportControllerBase::DeleteTransport()
+	{
+	LOG_LINE
+	LOG_FUNC
+
+	delete iActiveWriter;
+	delete iActiveReader;
+	delete iReceivePacket;
+	delete iSendPacket;
+	iActiveWriter = NULL;
+	iActiveReader = NULL;
+	iReceivePacket = NULL;
+	iSendPacket = NULL;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/group/t_obextransportheadercheck.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,51 @@
+// 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:
+// Pointless file produced by test project; the test is that it 
+// compiles at all.
+// 
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+target			t_obextransportheadercheck.exe
+targettype		exe
+uid 			0
+VENDORID		0x70000001
+
+sourcepath		../src
+source			main.cpp
+source			t_mobexnotify.cpp
+source			t_mobextransportnotify.cpp
+source			t_obexactivereader.cpp
+source			t_obexactiverw.cpp
+source			t_obexactivewriter.cpp
+source			t_obexconnector.cpp
+source			t_obexdata.cpp
+source			t_obexinternalconstants.cpp
+source			t_obexinternalheader.cpp
+source			t_obexpacket.cpp
+source			t_ObexReaderBase.cpp
+source			t_obextransportconstants.cpp
+source			t_obextransportcontrollerbase.cpp
+source			t_ObexWriterBase.cpp
+source			t_mobexnotifyextend.cpp
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+library 		euser.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/main.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,21 @@
+// 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:
+//
+
+#include <e32std.h>
+
+GLDEF_C TInt E32Main()
+	{
+	return KErrNone;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_ObexReaderBase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obex/transport/obexreaderbase.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_ObexWriterBase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obex/transport/obexwriterbase.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_Obextransport.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obex\transport\obextransport.hrh>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_mobexnotify.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <mobexnotify.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_mobexnotifyextend.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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 <obex/internal/mobexnotifyextend.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_mobextransportnotify.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obex/transport/mobextransportnotify.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obexactivereader.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obex/transport/obexactivereader.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obexactiverw.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obex/internal/obexactiverw.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obexactivewriter.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obex/transport/obexactivewriter.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obexconnector.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obex/transport/obexconnector.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obexdata.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obex/internal/obexdata.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obexinternalconstants.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obex/internal/obexinternalconstants.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obexinternalheader.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obex/internal/obexinternalheader.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obexpacket.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obex/internal/obexpacket.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obextransportconstants.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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 <obex/internal/obextransportconstants.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obextransportcontrollerbase.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,16 @@
+// 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:
+//
+
+#include <obex/transport/obextransportcontrollerbase.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/group/BLD.INF	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,17 @@
+// 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
+ObexUsbTransportController.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/group/ObexUsbTransportController.mmp	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+// ObexUsbTransportController.dll Obex USB Controller plug-in, used to load the USB transport.
+// ObexUsbTransportController.rsc The rsc file for the USB controller plug-in, used by ECOM to locate the correct plugin.
+// 
+//
+
+/**
+ @file
+*/
+
+
+target obexusbtransportcontroller.dll //Recommended unpaged
+CAPABILITY All -Tcb
+targettype plugin
+
+// ECom Dll recognition UID followed by the unique dll UID 
+UID              	0x10009d8d 0x1020de87
+VENDORID 0x70000001
+
+SOURCEPATH		../src
+SOURCE			ObexUsbImpCollection.cpp
+SOURCE			ObexUsbTransportController.cpp
+SOURCE			usbconn.cpp 
+
+START resource 1020DE87.rss
+target obexusbtransportcontroller.rsc
+END
+
+USERINCLUDE		../inc
+USERINCLUDE		../../common
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+LIBRARY			euser.lib 
+LIBRARY			obexcommontransport.lib
+
+//Since this component is a plug-in, there is no need to produce a .lib file.
+NOEXPORTLIBRARY 
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/inc/ObexUsbTransportController.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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:
+//
+
+/**
+ @file
+ @internalComponent 
+*/
+
+
+#ifndef __OBEXUSBTRANSPORTCONTROLLER_H__
+#define __OBEXUSBTRANSPORTCONTROLLER_H__
+
+#include <obex/transport/obextransportcontrollerbase.h>
+
+/**
+CObexUsbTransportController
+Transport Controller for the usb transport
+*/
+NONSHARABLE_CLASS(CObexUsbTransportController) : public CObexTransportControllerBase
+	{
+public://NewL functions
+	static CObexUsbTransportController* NewL(TObexTransportInfo& aTransportInfo);
+
+public://Functions derived from CBase
+	virtual  ~CObexUsbTransportController();
+	
+public://Functions derived from  CObexTransportControllerBase
+	virtual void DoRemoteAddr(TSockAddr& aAddr);
+	virtual void NewTransportL(TObexConnectionInfo& aInfo);
+	virtual TBool DoIsTransportRestartable() const;
+	TUint16 GetReceivePacketDataLimit();
+	
+public://Functions implemented from MObexTransportNotify
+	virtual void DoProcess(CObexPacket &aPacket) ;
+	virtual void DoError(TInt aError) ;
+	virtual void DoTransportUp(TObexConnectionInfo& aInfo);	
+	
+private:	
+	void ConstructL(TObexTransportInfo& aTransportInfo);
+	CObexUsbTransportController();
+	};
+
+#endif //__OBEXUSBTRANSPORTCONTROLLER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/inc/obexusbfaults.h	Tue Feb 02 01:11:40 2010 +0200
@@ -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 __OBEXUSBFAULTS_H
+#define __OBEXUSBFAULTS_H
+/**
+@file 
+
+This file contains usb specific panics internal to obex
+@internalComponent
+*/
+
+enum TObexUsbFaultCode
+	{
+	EUnknownUsbState = 0,
+	EUnknownUsbTransport = 1,
+	EDmaAllocationFailedEndpointIn = 2,
+	EDmaAllocationFailedEndpointOut = 3,
+	};
+	
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/inc/usbconn.h	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,297 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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 __USBCONN_H__
+#define __USBCONN_H__
+
+#include <e32base.h>
+#include <usb.h>
+#include <d32usbc.h>
+#include <obex/transport/obexreaderbase.h>
+#include <obex/transport/obexwriterbase.h>
+#include <obex/transport/obexconnector.h>
+#include <obex/transport/mobextransportnotify.h>
+#include <obexconstants.h>
+#include <obexusbtransportinfo.h>
+#include "ObexUsbTransportController.h"
+
+//
+// LDD name
+//
+_LIT(KUsbLddName, "eusbc");
+
+// Transmit and receive endpoints
+// Note that these are the virtual endpoint numbers for the bulk interface and
+// should be put in the same order in the TUsbcEndpointInfo array in RegInterfacesL
+const TEndpointNumber KTransmitEndpoint = EEndpoint1;
+const TEndpointNumber KReceiveEndpoint  = EEndpoint2;
+
+// These are taken from section 6.5 of the WMCDC spec.
+const TUint KObexDescriptorLength = 18;
+const TUint KObexMinNumEndpoints = 3;
+const TUint KObexClassNumber = 0x02;
+const TUint KObexNumInterfaces = 2;
+const TUint KObexSubClassNumber = 0x0b;
+const TUint KObexProtocolNumber = 0x0;
+const TUint KObexTotalEndpoints = 2;
+
+const TUint KObexDataClass = 0x0A;
+const TUint KObexDataSubClass = 0;
+const TUint KObexAlt0 = 0;
+const TUint KObexAlt1 = 1;
+const TUint KObexFunctionalDescriptorLength = 5;
+const TUint KObexDefaultInterfaceDescriptorLength = 100; //Default value used prior to OS 9.2
+const TUint KObexInterfaceDescriptorBlockLength = 16;
+
+const TUint8 KCdcVersionNumber[2] = { 0x10, 0x01 }; // CDC v1.1
+const TUint8 KHeaderFunctionalDescriptor = 0x00;
+const TUint8 KObexFunctionalDescriptor = 0x15;
+const TUint8 KWmcdcVersionNumber[2] = { 0x00, 0x01 }; // WMCDC v1.0
+const TUint8 KUnionFunctionalDescriptor = 0x06;
+
+const TInt KMaxPacketTypeBulkFS = 64;
+const TInt KMaxPacketTypeBulkHS = 512;
+
+
+/**
+USB Active Writer class
+*/
+NONSHARABLE_CLASS(CObexUsbActiveWriter) : public CObexWriterBase
+//------------------------------------------------------------------------------------
+	{
+public:
+	static CObexUsbActiveWriter* NewL(MObexTransportNotify& aOwner, RDevUsbcClient& aUsb, TObexConnectionInfo& aInfo, TInt aPacketSize);
+	~CObexUsbActiveWriter();
+
+private:
+	virtual void DoCancel();
+	virtual void DoTransfer();
+
+private:
+	CObexUsbActiveWriter(MObexTransportNotify& aOwner, RDevUsbcClient& aUsb, TObexConnectionInfo& aInfo, TInt aPacketSize);
+
+private:
+	RDevUsbcClient& iUsb;       // USB logical device driver
+	TInt iPacketSize;
+	};
+
+
+/**
+USB Active Reader class
+*/
+NONSHARABLE_CLASS(CObexUsbActiveReader) : public CObexReaderBase
+//------------------------------------------------------------------------------------
+    {
+public:
+	static CObexUsbActiveReader* NewL(MObexTransportNotify& aOwner, RDevUsbcClient& aUsb, TObexConnectionInfo& aInfo);
+	~CObexUsbActiveReader();
+
+private:
+	virtual void DoCancel();
+	virtual void DoTransfer();
+	virtual TInt GetMaxPacketSize();
+	virtual TInt GetInitialPacketSize();	
+private:
+	CObexUsbActiveReader(MObexTransportNotify& aOwner, RDevUsbcClient& aUsb, TObexConnectionInfo& aInfo);
+private:
+	RDevUsbcClient& iUsb;       // USB logical device driver
+	TBool iGotHeader;
+    };
+    
+
+/**
+Used by the USB underlying object to notify changes in the transport link.
+*/
+NONSHARABLE_CLASS(MObexUsbConnector)
+//------------------------------------------------------------------------------------
+	{
+public:
+	/**
+	@internalComponent
+	Called in response to the USB transport coming up.
+	*/
+	virtual void TransportUp() =0;
+	
+	/**
+	@internalComponent
+	Called in response to the USB transport going down.
+	@param aErr An error value associated with the transport down event.
+	*/
+	virtual void TransportDown(TInt aErr = KErrDisconnected) =0;
+	
+	/**
+	@internalComponent
+	Called when an endpoint stall has been cleared.
+	*/
+	virtual void StallCleared() =0;
+	};
+
+
+/**
+Handles the underlying details of a USB connection.  Monitors the state of
+the transport and notifies owner as transport goes up and down.
+*/
+NONSHARABLE_CLASS(CObexUsbHandler) : public CActive
+//------------------------------------------------------------------------------------
+    {
+public:
+	virtual ~CObexUsbHandler();
+
+	static CObexUsbHandler* NewL(TObexUsbTransportInfo& aUsbTransportInfo,
+		MObexUsbConnector& aOwner, RDevUsbcClient& aUsb);
+
+	void Start();
+
+	// Implements CActive
+	void RunL();
+	TInt RunError(TInt /*aError*/);
+
+private:
+	CObexUsbHandler(TObexUsbTransportInfo& aUsbProtocolInfo, MObexUsbConnector& aOwner, RDevUsbcClient& aUsb);
+	void DoCancel();
+	void ConstructL();
+	void RegInterfacesL();
+	void AllocateDma();
+	static void CleanupReleaseInterface0(TAny* aInterface);
+
+private:
+	TObexUsbTransportInfo& iObexTransportInfo; // Note: Cannot assume this is valid outside of construction phases
+	MObexUsbConnector& iOwner;
+
+	RDevUsbcClient& iUsb;           // USB LDD used for Data Class interface
+	RDevUsbcClient iUsbComms;		// USB LDD used for Comms Class interface
+
+	TUint iUsbState;		    	// Used by RDevUsbcClient::AlternateDeviceStatusNotify()
+	TBool iTransportUp;             // TRUE when device is configured
+
+	// Interface performance configuration parameters
+	// (for extended USB Client Driver API)
+	TInt iBandwidthPriority;
+	TBool iRequestDmaOnOutEndpoint;
+	TBool iRequestDmaOnInEndpoint;
+    };
+
+
+/**
+Class to stall then monitor an endpoint and notify owner when the halt state has been cleared.
+*/
+NONSHARABLE_CLASS(CObexUsbStaller) : public CActive
+//------------------------------------------------------------------------------------
+	{
+public:
+	static CObexUsbStaller* NewL(RDevUsbcClient& aUsb, MObexUsbConnector& iOwner);
+	~CObexUsbStaller();
+	
+	void Start();
+	
+private:
+	CObexUsbStaller(RDevUsbcClient& aUsb, MObexUsbConnector& iOwner);
+	
+	virtual void DoCancel();
+	virtual TInt RunError(TInt /*aError*/);
+	virtual void RunL();
+		
+private:
+	RDevUsbcClient& iUsb;
+	MObexUsbConnector& iOwner;
+	TUint iEndpointStatus;
+	};
+
+
+/**
+Class to support connecting to other USB devices.
+Server mode is relatively straightforward as this corresponds
+exactly to how USB works from the device perspective.  Obex client
+support though requires some 'magic'.
+*/
+NONSHARABLE_CLASS(CObexUsbConnector) : public CObexConnector, public MObexUsbConnector
+//------------------------------------------------------------------------------------
+	{
+public:
+	/**
+	This enum holds the three different states which the connector
+	can be in.  In DefaultClient mode, the connector is behaving as
+	a client but can be switched to server behaviour.  Once the mode
+	has been moved out of DefaultClient (to either Client or Server),
+	the mode is locked for the lifetime of the object.  Other
+	connectors can provide different behaviour for other CObexServer
+	or CObexClient objects.
+	*/
+	enum TObexUsbMode
+		{
+		EDefaultClient,
+		EClient,
+		EServer
+		};
+	static CObexUsbConnector* NewL(MObexTransportNotify& aOwner, TObexUsbTransportInfo& aUsbTransportInfo);	
+	CObexUsbConnector (MObexTransportNotify& aOwner, TObexUsbTransportInfo& aUsbTransportInfo);
+
+	~CObexUsbConnector();
+
+	virtual void ConstructL();
+
+	//Implement MObexUsbConnector interface
+	virtual void TransportUp();
+	virtual void TransportDown(TInt aErr = KErrDisconnected);
+	virtual void StallCleared();	
+
+	//Overrides for pure virtuals in CObexConnector
+	virtual void ConnectL();
+	virtual void CancelConnect();
+	virtual void AcceptL();
+	virtual void CancelAccept();
+	virtual TBool BringTransportDown();
+	virtual void SignalTransportError();
+	
+	//required to pass the RDevUsbcClient to the activer reader and writer
+	RDevUsbcClient* TransportObject();
+	TInt GetTransportPacketSize();
+
+private:
+	void OpenUsbL(TInt aUnit);	
+	static TInt LinkUp(TAny* aConn);
+	static TInt NoDevice(TAny* aConn);
+	void SignalUp();
+	void SignalDown(TInt aErr);
+	
+	void ResetTransportPacketSize();
+	void SetTransportPacketSize();
+
+// Data
+private:
+	RDevUsbcClient iUsb;	// USB logical device driver
+							// Note: This is the handle used for reads and writes.
+	TObexUsbTransportInfo& iObexTransportInfo;	// Reference to protocol info to pass on to CObexUsbHandler
+												// Note: Cannot assume this is valid outside of construction phases
+	TObexUsbMode iMode;
+	
+	CAsyncCallBack* iCallback;
+	TBool iTransportLinkAvailable;
+	TBool iConnectRequested;
+	TBool iWaitingForLink;
+	CObexUsbHandler* iHandler;
+	CObexUsbStaller* iStaller;
+	
+	TInt iPacketSize;
+	};
+
+
+#endif /* __USBCONN_H__ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/src/1020DE87.rss	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,48 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "ecom/registryinfo.rh"
+#include <obex/transport/obextransport.hrh>
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = 0x1020DE87;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = KObexTransportInterfaceUid;
+			implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x1020DE88;
+					version_no = 1;
+					display_name = "Obex USB";
+					default_data = "USB";										
+					opaque_data = "";
+					},
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x1020DEA4;
+					version_no = 1;
+					display_name = "Obex USB-V2";
+					default_data = "USB-V2";
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/src/ObexUsbImpCollection.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,44 @@
+// 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 
+*/
+
+#include <ecom/ecom.h>
+#include <ecom/implementationproxy.h>
+#include "ObexUsbTransportController.h"
+
+/**
+Define the private interface UIDs
+2 implementations are defined to cater for the USB and USB-V2 variants. Both
+interfaces call the same NewL function.
+ECOM passes a TObexTransportInfo parameter. The iTransportName member will
+be used to cast the parameter to the correct type.
+*/
+const TImplementationProxy ObexTCImplementationTable[] =
+    {
+	IMPLEMENTATION_PROXY_ENTRY(0x1020de88, CObexUsbTransportController::NewL),//USB implementation
+	IMPLEMENTATION_PROXY_ENTRY(0x1020dea4, CObexUsbTransportController::NewL),//USB V2 implementation
+    };
+    
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ObexTCImplementationTable) / sizeof(TImplementationProxy);
+
+    return ObexTCImplementationTable;
+    }
+    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/src/ObexUsbTransportController.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,190 @@
+// 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 
+*/
+
+#include <c32comm.h>
+#include <obexusbtransportinfo.h>
+#include "ObexUsbTransportController.h"
+#include "usbconn.h"
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "USB");
+#endif
+
+#ifdef _DEBUG
+_LIT(KPanicCat, "ObexUsbTC");
+enum
+	{
+	KUsbTCError = 0,
+	};
+#endif
+
+
+/**
+Constructs a CObexUsbTransportController object
+
+@param	aTransportInfo	 Reference to a TObexTransportInfo object. Will be cast to TObexUsbTransportInfo.
+
+@return	A new CObexUsbTransportController  object
+*/
+CObexUsbTransportController* CObexUsbTransportController::NewL(TObexTransportInfo& aTransportInfo)
+	{
+	CObexUsbTransportController* self = new(ELeave) CObexUsbTransportController;
+	CleanupStack::PushL(self);
+	self->ConstructL(aTransportInfo);
+	CleanupStack::Pop(self);
+	return(self);
+	}
+
+/**
+CObexUsbTransportController constructor.
+*/
+CObexUsbTransportController::CObexUsbTransportController()
+	:CObexTransportControllerBase()
+	{
+	}
+	
+	
+/**
+2nd Phase Construction.
+
+@param	aTransportInfo	Reference to a TObexTransportInfo object. Will be cast to TObexUsbTransportInfo.
+*/
+void CObexUsbTransportController::ConstructL(TObexTransportInfo& aTransportInfo)
+	{
+	//Note: The CObexUsbConnector will determine if UsbTransportInfo has type TObexUsbTransportInfo or TObexUsbV2TransportInfo.
+	//CObexUsbTransportController does not need to know	
+	TObexUsbTransportInfo& usbTransportInfo = static_cast<TObexUsbTransportInfo&>(aTransportInfo);
+	
+	iConnector  = CObexUsbConnector::NewL(*this,  usbTransportInfo); 
+	iTransportInfo = new(ELeave) TObexUsbTransportInfo;
+	Mem::Copy(iTransportInfo, &usbTransportInfo, sizeof(TObexUsbTransportInfo));
+	}
+
+/**
+CObexUsbTransportController destructor
+*/
+CObexUsbTransportController::~CObexUsbTransportController()
+	{
+	}
+
+
+/**
+Gets the socket associated with the connector and asks the socket for its  remote name. 
+ 
+@param	aAddr	Reference to a TSockAddr. Since this is the USB transport controller, there is no socket
+					address to return, so the reference is zeroed.
+*/
+void CObexUsbTransportController::DoRemoteAddr(TSockAddr& aAddr)
+	{
+	Mem::FillZ(&aAddr, sizeof(TSockAddr));
+	}
+
+
+/**
+Used indirectly by CObex::ControlledTransportDown() to determine whether the transport
+can be forced down, or if the connection should just be cancelled and cleaned up.
+
+@return	The USB transport cannot be restarted, so should not be forced down. Hence return EFalse	
+*/
+TBool CObexUsbTransportController::DoIsTransportRestartable() const
+	{
+	return EFalse;
+	}
+
+
+/**
+Returns the receive packet data limit
+
+@return	The receive packet data limit	
+*/
+TUint16 CObexUsbTransportController::GetReceivePacketDataLimit()
+	{
+	LOG_FUNC
+	
+	// Set initial "software throttle" for packets (how big OBEX says they are)
+	__ASSERT_DEBUG(iTransportInfo, PANIC(KPanicCat, KUsbTCError));
+	TUint16 receivePacketDataLimit = iTransportInfo->iReceiveMtu;
+	return receivePacketDataLimit;
+	}
+	
+	
+/*
+Creates the reader and writer and constructs the packets
+Called via CObexTransportControllerBase::DoTransportUp
+
+@param	aInfo Connection info to pass to active reader/writer classes
+*/	
+void CObexUsbTransportController::NewTransportL(TObexConnectionInfo& aInfo)
+	{
+	__ASSERT_DEBUG((aInfo.iSocketType == TObexConnectionInfo::EUsbStream), PANIC(KPanicCat, KUsbTCError));
+	
+	//Get the RDevUsbcClient to pass to the active reader/writer
+	RDevUsbcClient* usbc = reinterpret_cast<CObexUsbConnector*>(iConnector)->TransportObject();
+	
+	// Get the packet size of the link
+	TInt pktSize = reinterpret_cast<CObexUsbConnector*>(iConnector)->GetTransportPacketSize();
+	
+	//CObexUsbActiveReader(MObexTransportNotify* aOwner, RDevUsbcClient& aUsb, TObexConnectionInfo& aInfo);
+	iActiveReader = CObexUsbActiveReader::NewL(*this, *usbc, aInfo);	
+	//CObexUsbActiveWriter(MObexTransportNotify* aOwner, RDevUsbcClient& aUsb, TObexConnectionInfo& aInfo);
+	iActiveWriter = CObexUsbActiveWriter::NewL(*this, *usbc, aInfo, pktSize);
+	
+	iConnectionInfo = aInfo;
+	}
+
+	
+/**
+Implements MObexTransportNotify
+Process the received packet.
+
+@param	aPacket	A reference to a CObexPacket
+*/
+void CObexUsbTransportController::DoProcess(CObexPacket &aPacket)
+	{
+	CObexTransportControllerBase::DoProcess(aPacket);
+	}
+
+	
+/*
+Implements MObexTransportNotify
+Calls base implementation
+Future proofing against BC breaks
+
+@param	aError	The error value
+*/
+void CObexUsbTransportController::DoError(TInt aError) 
+	{
+	CObexTransportControllerBase::DoError(aError);
+	}
+
+	
+/*
+Implements MObexTransportNotify
+Calls base implementation
+Future proofing against BC breaks
+
+@param	aInfo Connection info to pass to active reader/writer classes
+*/
+void CObexUsbTransportController::DoTransportUp(TObexConnectionInfo& aInfo) 
+	{
+	CObexTransportControllerBase::DoTransportUp(aInfo);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/src/usbconn.cpp	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,1295 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies 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 
+*/
+
+
+#include <obexusbtransportinfo.h>
+#include "usbconn.h"
+#include <obex/transport/obexconnector.h>
+#include "logger.h"
+#include "obexusbfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "USB");
+#endif
+
+#ifdef _DEBUG
+_LIT(KPanicCat, "ObexUsbHandler");
+#endif
+
+
+//
+
+/**
+CObexUsbActiveWriter factory function
+
+@param	aTransport	Reference to a CObexUsbTransportController object. Required for a call to the CObexUsbActiveReader
+@param	aOwner		Reference to a MObexTransportNotify object
+@param	aUsb		Reference to a RDevUsbcClient object
+@param	aInfo		Reference to a TObexConnectionInfo object
+@param  aPacketSize The size of packets used on the underlying link, dependent on High Speed mode.
+@return Ownership of a new CObexUsbActiveWriter.
+*/
+CObexUsbActiveWriter* CObexUsbActiveWriter::NewL(MObexTransportNotify& aOwner, RDevUsbcClient& aUsb,
+										   TObexConnectionInfo& aInfo, TInt aPacketSize)
+	{
+	CObexUsbActiveWriter* self = new(ELeave) CObexUsbActiveWriter(aOwner, aUsb, aInfo, aPacketSize);
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+CObexUsbActiveWriter constructor
+
+@param	aTransport	Reference to a CObexUsbTransportController object. Required for a call to the CObexUsbActiveReader
+@param	aOwner		Reference to a MObexTransportNotify object
+@param	aUsb		Reference to a RDevUsbcClient object
+@param	aInfo		Reference to a TObexConnectionInfo object
+@param  aPacketSize The size of packets used on the underlying link, dependent on High Speed mode.
+*/
+CObexUsbActiveWriter::CObexUsbActiveWriter(MObexTransportNotify& aOwner, RDevUsbcClient& aUsb,
+										   TObexConnectionInfo& aInfo, TInt aPacketSize)
+: CObexWriterBase(EPriorityHigh, aOwner, aInfo),
+ iUsb(aUsb), iPacketSize(aPacketSize)
+	{
+	}
+
+
+/**
+CObexUsbActiveWriter destructor.
+*/
+CObexUsbActiveWriter::~CObexUsbActiveWriter()
+	{
+	LOG_FUNC
+
+	Cancel();
+	}
+
+
+/**
+Start actual transfer.  May be called several times by CObexActiveRW::RunL.
+Queues a write on USB endpoint.
+*/
+void CObexUsbActiveWriter::DoTransfer()
+	{
+	LOG_FUNC
+	LOG1(_L("CObexUsbActiveWriter::DoTransfer [Length=%d]"),iLocation.Length());
+	
+	iLocation.SetMax();
+	iUsb.Write(iStatus, KTransmitEndpoint, iLocation, iLocation.Length(), ETrue);
+	SetActive();
+	}
+
+
+/**
+Cancels an outstanding write.
+*/
+void CObexUsbActiveWriter::DoCancel()
+	{
+	LOG_FUNC
+
+	//Only cancel the write if there's more than 1 packet left to write.
+	//This restriction is imposed to prevent the SUCCESS response being
+	//cancelled when an ObexServer is handling a disconnect and bringing 
+	//the transport down.
+	if(Remaining() > iPacketSize)
+		{
+		iUsb.WriteCancel(KTransmitEndpoint);
+		}		
+	}
+		
+
+//
+
+/**
+CObexUsbActiveReader factory function
+
+@param	aOwner		Reference to a MObexTransportNotify object
+@param	aUsb		Reference to a RDevUsbcClient object
+@param	aInfo		Reference to a TObexConnectionInfo object
+@return Ownership of a new CObexUsbActiveWriter.
+*/
+CObexUsbActiveReader* CObexUsbActiveReader::NewL(MObexTransportNotify& aOwner, RDevUsbcClient& aUsb,
+										   TObexConnectionInfo& aInfo)
+	{
+	CObexUsbActiveReader* self = new(ELeave) CObexUsbActiveReader(aOwner, aUsb, aInfo);
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+CObexUsbActiveReader constructor
+
+@param	aOwner		Reference to a MObexTransportNotify object
+@param	aUsb		Reference to a RDevUsbcClient object
+@param	aInfo		Reference to a TObexConnectionInfo object
+*/
+CObexUsbActiveReader::CObexUsbActiveReader(MObexTransportNotify& aOwner, RDevUsbcClient& aUsb,
+										   TObexConnectionInfo& aInfo)
+: CObexReaderBase(EPriorityStandard, aOwner, aInfo), iUsb(aUsb)
+	{
+	}
+
+
+/**
+CObexUsbActiveReader destructor.
+*/
+CObexUsbActiveReader::~CObexUsbActiveReader()
+	{
+	LOG_FUNC
+
+	Cancel();
+	}
+
+
+/**
+Start actual transfer.  May be called several times by CObexActiveRW::RunL.
+Queues a read on USB endpoint.
+*/
+void CObexUsbActiveReader::DoTransfer()
+	{
+	LOG_FUNC
+	LOG1(_L("CObexUsbActiveReader::DoTransfer [maxLength=%d]"),iLocation.MaxLength());
+
+	iUsb.ReadUntilShort(iStatus, KReceiveEndpoint, iLocation);
+	SetActive();
+	}
+
+
+/**
+Cancels an outstanding read,
+ */
+void CObexUsbActiveReader::DoCancel()
+	{
+	FLOG(_L("CObexUsbActiveReader::DoCancel"));
+
+	iUsb.ReadCancel(KReceiveEndpoint);
+	}
+
+
+/**
+Return the maximum packet size
+@return TInt the maximum packet size for this transport
+*/
+TInt CObexUsbActiveReader::GetMaxPacketSize()
+	{
+	LOG_FUNC
+
+	return GetObexPacketDataLimit();
+	}
+
+
+/**
+Returns a initial packet size when the packet size of iPacket is not know.  This is used
+when determining the remaining bytes to be read.  
+@return TInt the initial packet size
+*/
+TInt CObexUsbActiveReader::GetInitialPacketSize ()
+	{
+	LOG_FUNC
+	
+	return GetObexPacketBufferSize();
+	}
+//
+
+/**
+CObexUsbConnector constructor.
+*/
+CObexUsbConnector::CObexUsbConnector(MObexTransportNotify& aObserver, TObexUsbTransportInfo& aUsbTransportInfo)
+ :	CObexConnector(aObserver), 
+	iObexTransportInfo(aUsbTransportInfo), 
+	iMode(EDefaultClient)
+	{
+	LOG_FUNC
+	// Note iObexTransportInfo reference is only kept so that it can be used in the ConstructL
+	// It may not be safe to use this variables outside of the construction phases
+	}
+
+
+/*
+Returns an instance of CObexUsbConnector
+
+@param	aController  	Reference to a MObexTransportNotify object (the CObexUsbTransportController that owns this)
+@param	aTransportInfo 	Reference to a TObexUsbTransportInfo object containing the transport information
+
+@return	A pointer to a CObexUsbConnector object
+*/
+CObexUsbConnector* CObexUsbConnector::NewL(MObexTransportNotify& aController, TObexUsbTransportInfo& aTransportInfo)
+	{
+	CObexUsbConnector* self = new(ELeave) CObexUsbConnector(aController, aTransportInfo);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return(self);
+	}
+
+
+/**
+Second phase construction.
+*/
+void CObexUsbConnector::ConstructL()
+	{
+	LOG_FUNC
+
+	OpenUsbL(0);
+
+	FLOG(_L("USB opened"));
+
+	iHandler  = CObexUsbHandler::NewL(iObexTransportInfo, *this, iUsb);
+	iCallback = new(ELeave) CAsyncCallBack(EPriorityHigh);
+	iStaller = CObexUsbStaller::NewL(iUsb, *this);
+	iHandler->Start();
+
+	BaseConstructL();
+	}
+
+
+/**
+CObexUsbConnector destructor. Releases endpoint and closes USB object if we have an open connection.
+*/
+CObexUsbConnector::~CObexUsbConnector()
+	{
+	LOG_FUNC
+
+	delete iCallback;
+	delete iHandler;
+	delete iStaller;
+	
+	if (iUsb.Handle())
+		{	
+		iUsb.Close();
+		}
+	}
+
+
+/**
+Attempt to open a client-type connection.
+This will succeed if the USB host has already opened a connection to us
+*/
+void CObexUsbConnector::ConnectL()
+	{
+	LOG_FUNC
+
+	if (iMode == EServer)
+		{
+		// Already performed a server-type connect, so can't act as a
+		// client as well.
+		FLOG(_L(" -- In server mode, give up"));
+		LEAVEIFERRORL(KErrNotSupported);		
+		}
+		
+		
+	FLOG(_L(" -- Not in server mode"));
+
+	iMode = EClient;
+	if (iTransportLinkAvailable)
+		{
+		FLOG(_L(" -- Link available, set a callback"));
+
+		TCallBack callback(LinkUp, this);
+		iCallback->Set(callback);
+		iCallback->CallBack();
+		iConnectRequested = ETrue;
+		}
+	else
+		{
+		FLOG(_L(" -- No link available, set a callback"));
+
+		TCallBack callback(NoDevice, this);
+		iCallback->Set(callback);
+		iCallback->CallBack();
+		}
+	}
+
+
+/*
+@param	aConn	A pointer to a connector object. Will be cast to CObexUsbConnector
+
+@return	KErrNone
+*/
+TInt CObexUsbConnector::LinkUp(TAny* aConn)
+	{
+	FLOG(_L("CObexUsbConnector::LinkUp"));
+
+	reinterpret_cast<CObexUsbConnector*>(aConn)->SignalUp();
+	return KErrNone;
+	}
+
+
+/*
+@param	aConn	A pointer to a connector object. Will be cast to CObexUsbConnector
+
+@return	KErrNone
+*/
+TInt CObexUsbConnector::NoDevice(TAny* aConn)
+	{
+	FLOG(_L("CObexUsbConnector::NoDevice"));
+
+	reinterpret_cast<CObexUsbConnector*>(aConn)->SignalDown(KErrIrObexClientPeerDoesNotHaveObex);
+	return KErrNone;
+	}
+
+
+/**
+Cancel an active connection attempt.  This is unlikely to succeed, as a client
+connection over USB will complete almost immediately.
+*/
+void CObexUsbConnector::CancelConnect()
+	{
+	LOG_FUNC
+
+	if (iMode == EClient)
+		{
+		iCallback->Cancel();
+		}
+	
+	iConnectRequested = EFalse;
+	}
+
+
+/**
+Start listening for a connection to us.
+*/
+void CObexUsbConnector::AcceptL()
+	{
+	LOG_FUNC
+
+	if (iMode == EClient)
+		{
+		// Already carried out a client side connection.  Therefore we
+		// can't be a server as well.
+		FLOG(_L(" -- In client mode, give up"));
+
+		LEAVEIFERRORL(KErrNotSupported);		
+		}
+	
+	FLOG(_L(" -- Not in client mode"));
+
+	iMode = EServer;
+	if (iTransportLinkAvailable)
+		{
+		FLOG(_L(" -- Transport link currently available, set a callback"));
+
+		TCallBack callback(LinkUp, this);
+		iCallback->Set(callback);
+		iCallback->CallBack();
+		}
+	else
+		{
+		FLOG(_L(" -- No link available, wait for one"));
+
+		iWaitingForLink = ETrue;
+		}
+	}
+
+/**
+Stop listening for connections.
+*/
+void CObexUsbConnector::CancelAccept()
+	{
+	LOG_FUNC
+
+	if (iMode == EServer)
+		{
+		iWaitingForLink = EFalse;
+		iCallback->Cancel();
+		}
+	}
+
+
+/**
+Called to indicate transport layer has come up.
+*/
+void CObexUsbConnector::TransportUp()
+	{
+	LOG_FUNC
+	
+	SetTransportPacketSize();
+
+	iTransportLinkAvailable = ETrue;
+	
+	if ((iMode == EServer) && (iWaitingForLink))
+		{
+		FLOG(_L(" -- Signalling link available"));
+
+		iWaitingForLink = EFalse;
+		SignalUp();
+		}
+	}
+
+/**
+Called to indicate transport layer has gone down.
+
+@param	aErr 	Any error code associated with disconnection. Defaults to KErrDisconnected.
+*/
+void CObexUsbConnector::TransportDown(TInt aErr)
+	{
+	LOG_FUNC
+	
+	ResetTransportPacketSize();
+	
+	iStaller->Cancel();
+
+	iTransportLinkAvailable = EFalse;
+		
+	if (iMode == EServer)
+		{
+		FLOG(_L(" -- In server mode, signal link down"));
+
+		SignalDown(aErr);
+		}
+	else
+		{
+		FLOG(_L(" -- In client mode"));
+
+		// Client or default client state
+		if (iConnectRequested)
+			{
+			FLOG(_L(" -- Outstanding client connection. Signal link down"));
+
+			iConnectRequested = EFalse;
+			SignalDown(aErr);
+			}
+		}
+	}
+
+/**
+Signals to the transport controller that the transport is up
+*/
+void CObexUsbConnector::SignalUp()
+	{
+	LOG_FUNC
+
+	// Indicate transport now up
+	TObexConnectionInfo sockinfo;
+	sockinfo.iMaxRecvSize = 0;	// set these to zero as we can't find them out
+	sockinfo.iMaxSendSize = 0;	// and they are not used
+	sockinfo.iSocketType = TObexConnectionInfo::EUsbStream;
+	Observer().TransportUp(sockinfo);
+	}
+
+
+/**
+Signals (with an error code) to the transport controller that the transport has gone down 
+*/
+void CObexUsbConnector::SignalDown(TInt aErr)
+	{
+	FLOG(_L("CObexUsbConnector::SignalDown"));
+
+	Observer().Error(aErr);
+	}
+
+
+/**
+The Obex server running over USB is not able to bring the transport
+down itself. It will only delete the transport object when an error
+has occurred (such as the link being brought down) and hence the
+transport is no longer valid.
+
+@return	ETrue
+*/
+TBool CObexUsbConnector::BringTransportDown()
+{
+	// This cancel function needs to be called here because it
+	// doesn't get called anywhere else. Bluetooth and IrDA rely
+	// on the socket shutdown to cancel the accept.
+	CancelAccept();
+	return ETrue;
+}
+
+
+/**
+Return the transport layer object for use by USB transport objects
+
+@return Pointer to the USB transport layer object
+*/
+RDevUsbcClient* CObexUsbConnector::TransportObject()
+	{
+	return &iUsb;
+	}
+
+
+/**
+Sets a bus stall condition on the IN endpoint.  This will cause the USB
+host to initiate a CLEAR_FEATURE sequence, which notifies the server that the
+Obex link has been reset (equivalent to dropping the Obex level connection)
+*/
+void CObexUsbConnector::SignalTransportError()
+	{
+	LOG_FUNC
+	
+	iStaller->Start();
+	iTransportLinkAvailable = EFalse;
+	iConnectRequested = EFalse;
+	}
+
+
+/**
+Stall cleared => transport available.
+This upcall has been separated from the TransportUp upcall for two
+reasons---it's called from a different class and it happens when an
+error condition has been cleared.  Currently it has no special
+meaning, but this could change in future.
+*/
+void CObexUsbConnector::StallCleared()
+	{
+	LOG_FUNC
+	
+	TransportUp();
+	}
+
+
+/**
+Opens USB and prepares it for use.
+
+@param	aUnit	According to the RDevUsbcClient documentation, this should be 0. 
+*/
+void CObexUsbConnector::OpenUsbL(TInt aUnit)
+	{
+	LOG1(_L("CObexUsbConnector::OpenUsbL called for unit=%d"), aUnit);
+	
+	// Load ldd
+	TInt err = User::LoadLogicalDevice(KUsbLddName);
+
+	if (err != KErrNone && err != KErrAlreadyExists)
+		{
+		LEAVEIFERRORL(err);
+		}
+
+	// Open the requested unit and initialise local state
+	LEAVEIFERRORL(iUsb.Open(aUnit));
+	}
+
+
+void CObexUsbConnector::ResetTransportPacketSize()
+	{
+	iPacketSize = 0;
+	}
+
+
+void CObexUsbConnector::SetTransportPacketSize()
+	{
+	if (iUsb.CurrentlyUsingHighSpeed())
+		{
+		iPacketSize = KMaxPacketTypeBulkHS;
+		}
+	else
+		{
+		iPacketSize = KMaxPacketTypeBulkFS;
+		}
+	}
+
+
+TInt CObexUsbConnector::GetTransportPacketSize()
+	{
+	return iPacketSize;
+	}
+
+
+//
+
+/**
+Constructs a CObexUsbHandler object
+
+@param	aUsbTransportInfo	Reference to a TObexTransportInfo object. Will be cast to TObexUsbTransportInfo.
+@param	aOwner				Reference to a MObexUsbConnector that owns this handler
+@param	aUsb				Reference to a RDevUsbcClient object.
+
+@return	A new CObexUsbHandler object
+*/
+CObexUsbHandler* CObexUsbHandler::NewL(TObexUsbTransportInfo& aUsbTransportInfo,
+									   MObexUsbConnector& aOwner,
+									   RDevUsbcClient& aUsb)
+	{
+	FLOG(_L("CObexUsbHandler::NewL"));
+	
+	CObexUsbHandler* self = new (ELeave) CObexUsbHandler(aUsbTransportInfo, aOwner, aUsb);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+
+/**
+CObexUsbHandler constructor.
+
+Note that the iObexTransportInfo may not be valid outside of the construction phases
+The constructor copies out most of the information it needs into member variables
+apart from the interface string descriptor, which is used from RegInterfacesL
+
+@param	aUsbTransportInfo	Reference to a TObexTransportInfo object. Will be cast to TObexUsbTransportInfo.
+@param	aOwner				Reference to a MObexUsbConnector that owns this handler
+@param	aUsb				Reference to a RDevUsbcClient object.
+*/
+CObexUsbHandler::CObexUsbHandler(TObexUsbTransportInfo& aUsbTransportInfo,
+								 MObexUsbConnector& aOwner,
+								 RDevUsbcClient& aUsb)
+ : CActive(EPriorityStandard), iObexTransportInfo(aUsbTransportInfo),
+   iOwner(aOwner), iUsb(aUsb)
+	{
+	LOG_FUNC
+	
+	CActiveScheduler::Add(this);
+
+	// Set interface performance configuration parameters
+	if (aUsbTransportInfo.iTransportName == KObexUsbProtocol)
+		// Default values if transport is normal USB - no extra bandwidth, no DMA
+		{
+		FLOG(_L("CObexUsbHandler - Using default USB protocol info"));
+		iBandwidthPriority = EUsbcBandwidthOUTDefault | EUsbcBandwidthINDefault;
+		iRequestDmaOnOutEndpoint = EFalse;
+		iRequestDmaOnInEndpoint = EFalse;
+		}
+	else if (aUsbTransportInfo.iTransportName == KObexUsbProtocolV2)
+		// If transport is extended USB take values from the protocol info
+		{
+		FLOG(_L("CObexUsbHandler - Using USB protocol extended info"));
+		TObexUsbV2TransportInfo& infoV2 = static_cast<TObexUsbV2TransportInfo&>(aUsbTransportInfo);
+		iBandwidthPriority       = infoV2.iBandwidthPriority;
+		iRequestDmaOnOutEndpoint = infoV2.iDmaOnOutEndpoint;
+		iRequestDmaOnInEndpoint  = infoV2.iDmaOnInEndpoint;
+		}
+	else
+		{
+		//aUsbTransportInfo.iTransportName is used to load the correct plug-in, so if this code
+		//is being executed it must have contained one of the options above. Else something
+		//has gone badly wrong.
+		__ASSERT_DEBUG(false, PANIC(KPanicCat, EUnknownUsbTransport));
+		}
+
+	LOG3(_L("CObexUsbHandler - iBandwidthPriority 0x%X, iDmaOnOutEndpoint, %d iDmaOnInEndpoint %d"),
+						iBandwidthPriority, iRequestDmaOnOutEndpoint, iRequestDmaOnInEndpoint);
+	}
+
+
+/**
+Second phase construction.
+*/
+void CObexUsbHandler::ConstructL()
+	{
+
+	// Check bandwidth priority to make sure it makes sense
+	// Reasoning is that the bitwise OR of the maximum values of IN and OUT priorities
+	// covers all the bits that can be set in iBandwidthPriority so, using this as a mask,
+	// anything set outside of this indicates that iBandwidthPriority is corrupt
+	if ( ( iBandwidthPriority & ~( EUsbcBandwidthOUTMaximum | EUsbcBandwidthINMaximum ) ) != 0 )
+		{
+		LEAVEIFERRORL(KErrArgument);
+		}
+
+	FLOG(_L("About to open USB comms interface connection"));
+
+	LEAVEIFERRORL(iUsbComms.Open(0));
+
+	FLOG(_L("Registering interfaces"));
+
+	RegInterfacesL();
+	}
+
+
+/**
+CObexUsbHandler destructor.
+*/
+CObexUsbHandler::~CObexUsbHandler()
+	{
+	LOG_FUNC
+	Cancel();
+
+	// Must release interfaces from highest alternate setting downwards
+	if (iUsb.Handle())
+		{
+#ifndef NO_ALTERNATE_USB_INTERFACE_SUPPORT
+		iUsb.ReleaseInterface(1 /*alternate setting*/);
+#endif
+		iUsb.ReleaseInterface(0 /*alternate setting*/);
+		}
+
+	if (iUsbComms.Handle())
+		{	
+		iUsbComms.ReleaseInterface(0 /*alternate setting*/);
+		}
+
+	iUsbComms.Close();
+	}
+
+
+/**
+Standard active object error function.
+
+@return	KErrNone because currently nothing should cause this to be called.
+*/
+TInt CObexUsbHandler::RunError(TInt /*aError*/)
+	{
+	return KErrNone;
+	}
+
+
+/**
+This function will be called upon a change in the state of the device
+(as set up in AcceptL).
+*/
+void CObexUsbHandler::RunL()
+	{
+	LOG1(_L("CObexUsbHandler::RunL called state=0x%X"), iUsbState);
+	
+	if (iStatus != KErrNone)
+		{
+		LOG1(_L("CObexUsbHandler::RunL() - Error = %d"),iStatus.Int());
+
+		iTransportUp = EFalse;
+		iOwner.TransportDown(iStatus.Int());
+		return;
+		}
+
+	// Check whether the alternate setting to use or the device state has changed.
+	// We have to check the device state to handle the unplugging of the cable. We can't
+	// rely on the always-outstanding read to complete with an error, because the driver
+	// doesn't have a well-defined error code for this.
+
+	if (iUsbState & KUsbAlternateSetting)
+		{
+		iUsbState &= ~KUsbAlternateSetting;
+
+		LOG1(_L("switched to alternate setting %d"), iUsbState);
+
+		if (iUsbState == KObexAlt0)
+			{
+			// alternate setting 0 - function inactive
+			if (iTransportUp)
+				{
+				FLOG(_L("CObexUsbHandler::RunL - transport layer going down..."));
+
+				iTransportUp = EFalse;
+				iOwner.TransportDown();
+				}
+			}
+		else if (iUsbState == KObexAlt1)
+			{
+			// alternate setting 1 - function active
+			if (!iTransportUp)
+				{
+				FLOG(_L("CObexUsbHandler::RunL - transport layer coming up..."));
+
+				// Now the transport is selected, DMA can be allocated to the endpoints, if required
+				AllocateDma();
+
+				iTransportUp = ETrue;
+
+				iOwner.TransportUp();
+				}
+			}
+		else
+			{
+			FLOG(_L("WARNING: unknown setting!"));
+			}
+		}
+	else
+		{
+		TUsbcDeviceState deviceState = static_cast<TUsbcDeviceState>(iUsbState);
+
+		switch(deviceState)
+			{
+			case EUsbcDeviceStateUndefined:
+			case EUsbcDeviceStateAttached:
+			case EUsbcDeviceStatePowered:
+			case EUsbcDeviceStateDefault:
+			case EUsbcDeviceStateAddress:
+#ifdef ERRONEOUS_SUSPEND_INDICATIONS
+			// On Lubbock, we sometimes get "suspended" when the cable is unplugged.
+			case EUsbcDeviceStateSuspended:
+#endif // ERRONEOUS_SUSPEND_INDICATIONS
+				if (iTransportUp)
+					{
+					FLOG(_L("CObexUsbHandler::RunL - transport layer going down..."));
+
+					iTransportUp = EFalse;
+					iOwner.TransportDown();
+					}
+				break;
+
+#ifndef ERRONEOUS_SUSPEND_INDICATIONS
+			case EUsbcDeviceStateSuspended:
+				break;
+#endif // !ERRONEOUS_SUSPEND_INDICATIONS
+
+			case EUsbcDeviceStateConfigured:
+				// Normally, we don't do anything here, because the transport only goes up when
+				// we actually receive the alternate interface change.
+#ifdef NO_ALTERNATE_USB_INTERFACE_SUPPORT
+				if (!iTransportUp)
+					{
+					FLOG(_L("Device now configured: transport layer coming up..."));
+
+					iTransportUp = ETrue;
+
+					// DMA can be allocated to the endpoints, if required
+					// This has to be done here for no alternate interface devices
+					// as they will not receive interface change notification
+					AllocateDma();
+
+					iOwner.TransportUp();
+					}
+#endif // NO_ALTERNATE_USB_INTERFACE_SUPPORT
+				break;
+
+			default:
+				__ASSERT_DEBUG(false, PANIC(KPanicCat, EUnknownUsbState));
+				break;
+			}
+		}
+
+	// Await further notification of a state change. We may have called Error(), which
+	// would already have set this notification request.
+	if (!IsActive())
+		{
+		iUsb.AlternateDeviceStatusNotify(iStatus, iUsbState);
+		SetActive();
+		}
+
+	FLOG(_L("CObexUsbHandler::RunL finished"));
+	}
+
+
+/**
+Standard active object cancellation function.
+*/
+void CObexUsbHandler::DoCancel()
+	{
+	LOG_FUNC
+
+	iUsb.AlternateDeviceStatusNotifyCancel();
+	}
+
+
+/**
+Registers the required comms and data interfaces.
+*/
+void CObexUsbHandler::RegInterfacesL()
+	{
+	LOG_FUNC
+
+	// Setup a CDC Communication Class interface
+	TUsbcInterfaceInfoBuf ifc;
+
+	// Extract the interface string from the transport info structure we were
+	// passed on construction. This isn't const because the SetInterface API
+	// requires it not to be.
+	// This is the only point where iObexTransportInfo is used directly
+	// Do not use iObexTransportInfo outside of construction phases
+	TPtrC string(iObexTransportInfo.iInterfaceStringDescriptor);
+
+	LOG1(_L("Using interface string \"%S\""), &string);
+		
+	ifc().iString = &string;
+	ifc().iClass.iClassNum = KObexClassNumber;		
+	ifc().iClass.iSubClassNum = KObexSubClassNumber;
+	ifc().iClass.iProtocolNum = KObexProtocolNumber;
+	ifc().iTotalEndpointsUsed = 0;
+	
+	// Indicate that this interface does not expect any control transfers 
+	// from EP0.
+	ifc().iFeatureWord |= KUsbcInterfaceInfo_NoEp0RequestsPlease;
+	
+	FLOG(_L("CObexUsbListeningConnector::RegInterfacesL - setting comms interface")); 
+	
+	TInt err = iUsbComms.SetInterface(0, ifc);
+
+	if (err != KErrNone) 
+		{ 
+		LOG1(_L("SetInterface failed with error %d"), err);
+		LEAVEIFERRORL(err);
+		}
+
+	// Get the interface number for later 
+	TInt intDescSize;
+	err = iUsbComms.GetInterfaceDescriptorSize(0,intDescSize);	
+	if(err != KErrNone)
+		{
+		LOG1(_L("Failed to get interface descriptor size. Err = %d"),err);
+		intDescSize = KObexDefaultInterfaceDescriptorLength; //Default is 100
+		}
+	HBufC8* interfaceDescriptor;
+	interfaceDescriptor = HBufC8::NewLC(intDescSize);
+	TPtr8 pIntDesc = interfaceDescriptor->Des();
+	iUsbComms.GetInterfaceDescriptor(0, pIntDesc);
+	TUint8 obexIntNo = interfaceDescriptor->Ptr()[2];
+	CleanupStack::PopAndDestroy();
+
+	TBuf8<KObexInterfaceDescriptorBlockLength> desc;
+
+	// Comms Class Header Functional Descriptor
+
+	desc.Append(KObexFunctionalDescriptorLength);
+	desc.Append(KUsbDescType_CS_Interface);
+	desc.Append(KHeaderFunctionalDescriptor);
+	desc.Append(KCdcVersionNumber[0]);
+	desc.Append(KCdcVersionNumber[1]);
+
+	// Obex Functional Descriptor
+
+	desc.Append(KObexFunctionalDescriptorLength);
+	desc.Append(KUsbDescType_CS_Interface);
+	desc.Append(KObexFunctionalDescriptor);
+	desc.Append(KWmcdcVersionNumber[0]);
+	desc.Append(KWmcdcVersionNumber[1]);
+
+	// Union Functional Descriptor
+	
+	desc.Append(KObexFunctionalDescriptorLength);
+	desc.Append(KUsbDescType_CS_Interface); 
+	desc.Append(KUnionFunctionalDescriptor);
+	desc.Append(obexIntNo); 
+	TInt dataInt = obexIntNo + 1;
+	desc.Append(static_cast<TUint8>(dataInt));		
+
+	err = iUsbComms.SetCSInterfaceDescriptorBlock(0, desc);
+	if (err != KErrNone)
+		{
+		LOG1(_L("SetCSInterfaceDescriptorBlock failed with error %d"), err);
+		LEAVEIFERRORL(err);
+		}
+
+	// Setup CDC Data Class interfaces
+
+	// Only set the "function inactive" interface (alternate setting 0)
+	// if the device can support alternate interfaces
+#ifndef NO_ALTERNATE_USB_INTERFACE_SUPPORT
+	TUsbcInterfaceInfoBuf dataifc;
+
+	dataifc().iString = NULL;
+	dataifc().iClass.iClassNum = KObexDataClass;		
+	dataifc().iClass.iSubClassNum = KObexDataSubClass;
+	dataifc().iClass.iProtocolNum = 0;
+	dataifc().iTotalEndpointsUsed = 0;
+
+	// Indicate that this interface does not expect any control transfers 
+	// from EP0.
+	dataifc().iFeatureWord |= KUsbcInterfaceInfo_NoEp0RequestsPlease;
+
+	FLOG(_L("Setting data class interface (alt setting 0")); 
+	
+	err = iUsb.SetInterface(0 /*alternate setting*/, dataifc, iBandwidthPriority);
+	if (err != KErrNone) 
+		{
+		LOG1(_L("Cannot set data interface (alternate setting 0): error %d"), err);
+		LEAVEIFERRORL(err);
+		}
+
+	// If anything below this point leaves, make sure this alternate setting
+	// gets released.
+	CleanupStack::PushL(TCleanupItem(CleanupReleaseInterface0, &iUsb));
+#endif // NO_ALTERNATE_USB_INTERFACE_SUPPORT
+
+	// Check the device has enough endpoints for the "function active" data interface
+	TUsbDeviceCaps dCaps;
+	LEAVEIFERRORL(iUsb.DeviceCaps(dCaps));
+	
+	TInt n = dCaps().iTotalEndpoints;
+	if (n < KObexMinNumEndpoints) 
+		{
+		LEAVEIFERRORL(KErrOverflow);
+		}
+	
+	// Use the hardware's HS capability to determine maximum bulk transfer packet size
+	TInt maxPacketSize = (dCaps().iHighSpeed) ? KMaxPacketTypeBulkHS : KMaxPacketTypeBulkFS;
+	
+		
+	// Get information on the available endpoints from the driver
+	TUsbcEndpointData data[KUsbcMaxEndpoints];
+	TPtr8 dataptr(REINTERPRET_CAST(TUint8*, data), sizeof(data), sizeof(data));
+	LEAVEIFERRORL(iUsb.EndpointCaps(dataptr));
+
+	// Check to see if there are suitably capable IN and OUT endpoints available
+	// and fill dataifc2 structure accordingly.
+	//
+	// NOTE: The order the iEndpointData array is filled matches the order used for the
+	// virtual endpoint numbers KTransmitEndpoint and KReceiveEndpoint - so change with caution!
+	//
+	// The virtual endpoint numbers are 1-based, whereas the iEndpointData array is 0 based
+	// hence the subtraction in the array indices
+	//
+	// NOTE: IN and OUT refer to the host so in this case:
+	//			IN  => device to PC = KTransmitEndpoint
+	//			OUT => PC to device = KReceiveEndpoint
+	TUsbcInterfaceInfoBuf dataifc2;
+	TBool foundIn = EFalse;
+	TBool foundOut = EFalse;
+	for (TInt i = 0; !(foundIn && foundOut) && i < n; i++)
+		{
+		const TUsbcEndpointCaps* caps = &data[i].iCaps;
+		if (data[i].iInUse)
+			{
+			continue;
+			}
+			
+		const TUint KBulkInFlags = KUsbEpTypeBulk | KUsbEpDirIn;
+		const TUint KBulkOutFlags = KUsbEpTypeBulk | KUsbEpDirOut;
+
+		if (!foundIn && (caps->iTypesAndDir & KBulkInFlags) == KBulkInFlags)
+			{
+			dataifc2().iEndpointData[KTransmitEndpoint - 1].iType  = KUsbEpTypeBulk;
+			dataifc2().iEndpointData[KTransmitEndpoint - 1].iDir   = KUsbEpDirIn;	
+			TInt maxSize = caps->MaxPacketSize();
+			if (maxSize > maxPacketSize)
+				{
+				maxSize = maxPacketSize;
+				}
+			dataifc2().iEndpointData[KTransmitEndpoint - 1].iSize  = maxSize;
+			foundIn = ETrue;
+			}
+		else if (!foundOut && (caps->iTypesAndDir & KBulkOutFlags) == KBulkOutFlags)
+			{
+			dataifc2().iEndpointData[KReceiveEndpoint - 1].iType = KUsbEpTypeBulk;
+			dataifc2().iEndpointData[KReceiveEndpoint - 1].iDir = KUsbEpDirOut;
+			TInt maxSize = caps->MaxPacketSize();
+			if (maxSize > maxPacketSize)
+				{
+				maxSize = maxPacketSize;
+				}
+			dataifc2().iEndpointData[KReceiveEndpoint - 1].iSize  = maxSize;
+			foundOut = ETrue;
+			}
+		}
+		
+	if (!(foundIn && foundOut)) 
+		{
+		LEAVEIFERRORL(KErrHardwareNotAvailable);
+		}
+	
+	// Set the active interface.
+	dataifc2().iString = NULL;
+	dataifc2().iClass.iClassNum = KObexDataClass;		
+	dataifc2().iClass.iSubClassNum = KObexDataSubClass;
+	dataifc2().iClass.iProtocolNum = 0;
+	dataifc2().iTotalEndpointsUsed = KObexTotalEndpoints;
+	
+	// Indicate that this interface does not expect any control transfers 
+	// from EP0.
+	dataifc2().iFeatureWord |= KUsbcInterfaceInfo_NoEp0RequestsPlease;
+		
+#ifdef NO_ALTERNATE_USB_INTERFACE_SUPPORT
+	// For devices that don't suport alternate interfaces, have to place the "function active"
+	// interface at alternate setting 0, although the CDC specification says if should be alternate setting 1
+	FLOG(_L("Setting data class interface (no alternate interface support)"));
+	
+	err = iUsb.SetInterface(0 /*alternate setting*/, dataifc2, iBandwidthPriority);
+
+	if (err != KErrNone) 
+		{
+		//FTRACE(FPrint(_L("Cannot set data interface (no alternate interface support): error %d"), err));
+		LOG1(_L("Cannot set data interface (no alternate interface support): error %d"), err);
+		LEAVEIFERRORL(err);
+		}
+#else
+	FLOG(_L("Setting data class interface (alternate setting 1)"));
+	
+	err = iUsb.SetInterface(1 /*alternate setting*/, dataifc2, iBandwidthPriority); 
+
+	if (err != KErrNone) 
+		{
+		//FTRACE(FPrint(_L("Cannot set data interface (alternate setting 1): error %d"), err));
+		LOG1(_L("Cannot set data interface (alternate setting 1): error %d"), err);
+		LEAVEIFERRORL(err);
+		}
+
+	CleanupStack::Pop(); // ReleaseInterface0
+#endif
+
+	FLOG(_L("CObexUsbHandler::RegInterfacesL - finished."));
+	}
+
+
+/**
+Utility function which releases the first alternate setting of the specified
+interface. Used when setting up Obex interfaces.
+
+@param	aInterface	The interface to release
+*/
+void CObexUsbHandler::CleanupReleaseInterface0(TAny* aInterface)
+	{
+	reinterpret_cast<RDevUsbcClient*>(aInterface)->ReleaseInterface(0 /*alternate setting*/);
+	}
+
+
+/**
+Accept an incoming connection.
+*/
+void CObexUsbHandler::Start()
+	{
+	LOG_FUNC
+
+	// Await notification of a state change (this is like waiting for a connect...).
+	iUsb.AlternateDeviceStatusNotify(iStatus, iUsbState);
+	SetActive();
+	}
+
+	
+/**
+Utility function to allocate DMA to the bulk endpoints - if they have been requested
+This function is called during a connect, once the device is configured,
+so if the allocations fail it wont complain in release builds but debug builds will
+panic with either EDmaAllocationFailedEndpointIn or EDmaAllocationFailedEndpointOut. 
+*/
+void CObexUsbHandler::AllocateDma()
+	{
+	LOG_FUNC
+
+	if (iRequestDmaOnInEndpoint)
+		{
+		TInt err = iUsb.AllocateEndpointResource(KTransmitEndpoint, EUsbcEndpointResourceDMA);
+		// The following log message is checked for in the test code - change with caution!
+		LOG1(_L("IN Endpoint DMA resource allocation result %d"), err);
+		(void)err; // to stop compilers complaining about unused variables
+		}
+
+	if (iRequestDmaOnOutEndpoint)
+		{
+		TInt err = iUsb.AllocateEndpointResource(KReceiveEndpoint, EUsbcEndpointResourceDMA);
+		// The following log message is checked for in the test code - change with caution!
+		LOG1(_L("OUT Endpoint DMA resource allocation result %d"), err);
+		(void)err; // to stop compilers complaining about unused variables
+		}
+	}
+
+
+//
+
+/**
+Constructs a CObexUsbStaller object
+
+@param	aUsb			Reference to a RDevUsbcClient object.
+@param	aOwner			Reference to a MObexUsbConnector that owns this handler
+
+@return	A new CObexUsbStaller object
+*/
+CObexUsbStaller* CObexUsbStaller::NewL(RDevUsbcClient& aUsb, MObexUsbConnector& aOwner)
+	{
+	CObexUsbStaller* self = new(ELeave) CObexUsbStaller(aUsb, aOwner);
+	return self;
+	}
+
+/**
+CObexUsbStaller constructor.
+
+@param	aUsb			Reference to a RDevUsbcClient object.
+@param	aOwner			Reference to a MObexUsbConnector that owns this handler
+*/
+CObexUsbStaller::CObexUsbStaller(RDevUsbcClient& aUsb, MObexUsbConnector& aOwner)
+	: CActive(EPriorityStandard), iUsb(aUsb), iOwner(aOwner)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+
+/**
+CObexUsbStaller destructor.
+*/
+CObexUsbStaller::~CObexUsbStaller()
+	{
+	Cancel();
+	}
+
+
+/**
+Starts the staller
+*/
+void CObexUsbStaller::Start()
+	{
+	LOG_FUNC
+	
+	if (!IsActive())
+		{
+		FLOG(_L("Halting transmit endpoint..."));
+		iUsb.HaltEndpoint(KTransmitEndpoint);
+		iUsb.EndpointStatusNotify(iStatus, iEndpointStatus);
+		SetActive();
+		}
+	}
+	
+
+/**
+Called when the transmit endpoint has changed state
+*/
+void CObexUsbStaller::RunL()
+	{
+	LOG_FUNC
+	
+	TEndpointState endpointState;
+	iUsb.EndpointStatus(KTransmitEndpoint, endpointState);	
+#ifdef __FLOG_ACTIVE
+	switch (endpointState)
+		{
+		case EEndpointStateNotStalled:
+			{
+			FLOG(_L("Receive endpoint not stalled"));
+			break;
+			}
+		case EEndpointStateStalled:
+			{
+			FLOG(_L("Receive endpoint stalled"));
+			break;
+			}
+		case EEndpointStateUnknown:
+			{
+			FLOG(_L("Receive endpoint unknown state"));
+			break;
+			}
+		}
+#endif		 
+	if (endpointState == EEndpointStateNotStalled)
+		{
+		LOG1(_L("CObexUsbStallWatcher::RunL -- endpoint no longer stalled (0x%08x)"), iEndpointStatus);
+		iOwner.StallCleared();
+		}
+	else
+		{
+		LOG1(_L("CObexUsbStallWatcher::RunL -- endpoint still stalled (0x%08x)"), iEndpointStatus);
+		iUsb.EndpointStatusNotify(iStatus, iEndpointStatus);
+		SetActive();
+		}
+	}
+
+
+/**
+Standard active object error function.
+
+@return	KErrNone because currently nothing should cause this to be called.
+*/
+TInt CObexUsbStaller::RunError(TInt /*aError*/)
+	{
+	LOG_FUNC
+	
+	return KErrNone;
+	}
+	
+
+/**
+Standard active object cancellation function.
+*/	
+void CObexUsbStaller::DoCancel()
+	{
+	FLOG(_L("CObexUsbStaller -- Cancelling status notification"));
+	iUsb.EndpointStatusNotifyCancel();
+	}
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/package_definition.xml	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<SystemDefinition schema="3.0.0">
+  <package id="remoteconn" name="Remote Connectivity" levels="plugin framework server generic specific">
+    <collection id="connectivitymodules" name="Connectivity Modules" level="framework">
+      <component id="secon" filter="s60" name="Service Controllers">
+        <unit bldFile="connectivitymodules/secon/group"/>
+      </component>
+    </collection>
+    <collection id="remoteconn_info" name="Remote Connectivity Info" level="specific">
+      <component id="remoteconn_plat" filter="s60" name="Remote Connectivity Platform Interfaces" class="api">
+        <unit bldFile="remoteconn_plat/group"/>
+      </component>
+      <component id="remoteconn_metadata" name="Remote Connectivity Metadata" class="config" introduced="^2" purpose="development" target="desktop">
+        <unit mrp="remoteconn_info/remoteconn_metadata/remoteconn_metadata.mrp"/>
+      </component>
+    </collection>
+    <collection id="mtptransports" name="MTP Transports" level="plugin">
+      <component id="mtpusbtransport" name="MTP USB Transport" introduced="^2" purpose="optional" class="plugin">
+        <unit bldFile="mtptransports/mtpusbtransport/group" mrp="mtptransports/mtpusbtransport/group/mtp_usbsic.mrp"/>
+      </component>
+      <component id="mtpptpiptransport" name="MTP PTP-IP Transport" introduced="^3" purpose="optional" class="plugin">
+        <unit bldFile="mtptransports/mtpptpiptransport/group" mrp="mtptransports/mtpptpiptransport/group/mtp_ptpip.mrp"/>
+      </component>
+      <component id="mtpcontroller" name="MTP Controller" introduced="^3" purpose="optional" class="plugin">
+        <unit bldFile="mtptransports/mtpcontroller/group" mrp="mtptransports/mtpcontroller/group/mtpcontroller.mrp"/>
+      </component>
+    </collection>
+    <collection id="mtpfws" name="MTP Frameworks" level="framework">
+      <component id="mtpfw" name="MTP Framework" introduced="^2" purpose="optional">
+        <unit bldFile="mtpfws/mtpfw/group" mrp="mtpfws/mtpfw/group/mtp_framework.mrp"/>
+      </component>
+      
+    </collection>
+    <collection id="mtpdataproviders" name="MTP Data Providers" level="generic">
+      <component id="mtpfileandfolderdp" name="MTP File and Folder Provider" introduced="^2" purpose="optional" class="plugin">
+        <unit bldFile="mtpdataproviders/mtpfileandfolderdp/group" mrp="mtpdataproviders/mtpfileandfolderdp/group/mtp_filedp.mrp"/>
+      </component>
+    </collection>
+    <collection id="backupandrestore" name="Backup and Restore" level="specific">
+      <component id="backupengine" name="Backup Engine" introduced="9.0" purpose="optional">
+        <unit bldFile="backupandrestore/backupengine/group" mrp="backupandrestore/backupengine/group/connectivity_backupengine.mrp"/>
+      </component>
+     <component id="backuptest" name="Backup Test" introduced="^2" purpose="development">
+        <unit bldFile="backupandrestore/backuptest/group" mrp="backupandrestore/backuptest/group/connectivity_backuptest.mrp"/>
+      </component>
+    </collection>
+    <collection id="obex" name="OBEX" level="generic">
+      <component id="obexprotocol" name="OBEX Protocol" introduced="9.1" purpose="optional">
+        <unit bldFile="obex/obexprotocol/group" mrp="obex/obexprotocol/group/obex.mrp"/>
+      </component>
+      <component id="obexextensionapi" name="OBEX Extension API" introduced="9.2" purpose="optional">
+        <unit bldFile="obex/obexextensionapi/group" mrp="obex/obexextensionapi/group/obex_extensionapis.mrp"/>
+      </component>
+    </collection>
+  </package>
+</SystemDefinition>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/group/bld.inf	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,19 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Includes all the Domain API specific bld.inf files, which 
+*                export files.
+*
+*/
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysdef_1_4_0.dtd	Tue Feb 02 01:11:40 2010 +0200
@@ -0,0 +1,86 @@
+ <!ELEMENT SystemDefinition (systemModel?, build?)>
+ <!ATTLIST SystemDefinition
+  name CDATA #REQUIRED
+  schema CDATA #REQUIRED>
+ <!ELEMENT systemModel (layer+)>
+ <!ELEMENT layer (logicalset* | module*)*>
+ <!ATTLIST layer
+  name CDATA #REQUIRED
+  levels CDATA #IMPLIED
+  span CDATA #IMPLIED>
+ <!ELEMENT logicalset (logicalsubset* | module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalset name CDATA #REQUIRED>
+ <!ELEMENT logicalsubset (module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalsubset name CDATA #REQUIRED>
+ <!ELEMENT module (component* | unit* | package* | prebuilt*)*>
+ <!ATTLIST module
+  name CDATA #REQUIRED
+  level CDATA #IMPLIED>
+ <!ELEMENT component (unit* | package* | prebuilt*)*>
+ <!ATTLIST component name CDATA #REQUIRED>
+ <!ELEMENT unit EMPTY>
+ <!ATTLIST unit
+  unitID ID #REQUIRED
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  bldFile CDATA #REQUIRED
+  priority CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT package EMPTY>
+ <!ATTLIST package
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT prebuilt EMPTY>
+ <!ATTLIST prebuilt
+  name CDATA #REQUIRED
+  version CDATA #REQUIRED
+  late (Y|N) #IMPLIED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT build (option* | target+ | targetList+ | unitList+ | configuration+)*>
+ <!ELEMENT unitList (unitRef+)>
+ <!ATTLIST unitList
+  name ID #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT unitRef EMPTY>
+ <!ATTLIST unitRef unit IDREF #REQUIRED>
+ <!ELEMENT targetList EMPTY>
+ <!ATTLIST targetList
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  target IDREFS #REQUIRED>
+ <!ELEMENT target EMPTY>
+ <!ATTLIST target
+  name ID #REQUIRED
+  abldTarget CDATA #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT option EMPTY>
+ <!ATTLIST option
+  name ID #REQUIRED
+  abldOption CDATA #REQUIRED
+  description CDATA #REQUIRED
+  enable (Y | N | y | n) #REQUIRED>
+ <!ELEMENT configuration (unitListRef+ | layerRef+ | task+)*>
+ <!ATTLIST configuration
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  filter CDATA #REQUIRED>
+ <!ELEMENT task ( unitListRef* , (buildLayer | specialInstructions))>
+ <!ELEMENT unitListRef EMPTY>
+ <!ATTLIST unitListRef unitList IDREF #REQUIRED>
+ <!ELEMENT layerRef EMPTY>
+ <!ATTLIST layerRef layerName CDATA #REQUIRED>
+ <!ELEMENT buildLayer EMPTY>
+ <!ATTLIST buildLayer
+  command CDATA #REQUIRED
+  targetList IDREFS #IMPLIED
+  unitParallel (Y | N | y | n) #REQUIRED
+  targetParallel (Y | N | y | n) #IMPLIED>
+ <!ELEMENT specialInstructions EMPTY>
+ <!ATTLIST specialInstructions
+  name CDATA #REQUIRED
+  cwd CDATA #REQUIRED
+  command CDATA #REQUIRED>